[Home] [Help]
PACKAGE BODY: APPS.XLA_00707_AAD_S_000020_PKG
Source
1 PACKAGE BODY XLA_00707_AAD_S_000020_PKG AS
2 --
3 /*======================================================================+
4 | Copyright (c) 1997 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | Package Name |
9 | XLA_00707_AAD_S_000020_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Permanent Inventory Cost Management Encumbrance |
14 | Code : PI_COST_MANAGEMENT_ENC |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 06:03:03 by user ANONYMOUS |
20 +=======================================================================*/
21 --
22 --
23 TYPE t_rec_array_event IS RECORD
24 (array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
25 ,array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
26 ,array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
27 ,array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
28 ,array_event_id xla_number_array_type --XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
29 ,array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
30 ,array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
31 ,array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
32 ,array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
33 ,array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
34 ,array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
35 ,array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
36 ,array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
37 ,array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
38 ,array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
39 ,array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
40 ,array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
41 ,array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
42 ,array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
43 ,array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
44 ,array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
45 ,array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L
46 );
47 --
48 type t_array_value_num is table of number index by varchar2(30);
49 type t_array_value_char is table of varchar2(240) index by varchar2(30);
50 type t_array_value_date is table of date index by varchar2(30);
51
52 type t_rec_value is record
53 (array_value_num t_array_value_num
54 ,array_value_char t_array_value_char
55 ,array_value_date t_array_value_date);
56
57 type t_array_event is table of t_rec_value index by binary_integer;
58
59 g_array_event t_array_event;
60
61 --=============================================================================
62 -- *********** Diagnostics **********
63 --=============================================================================
64
65 g_diagnostics_mode VARCHAR2(1);
66 g_last_hdr_idx NUMBER; -- 4262811 MPA
67 g_hdr_extract_count PLS_INTEGER;
68
69 --=============================================================================
70 -- *********** Local Trace Routine **********
71 --=============================================================================
72
73 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
74 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
75 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
76 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
77 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
78 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
79
80 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
81 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_00707_AAD_S_000020_PKG';
82
83 C_CHAR CONSTANT VARCHAR2(30) := fnd_global.local_chr(12); -- 4219869 Business flow
84 C_NUM CONSTANT NUMBER := 9.99E125; -- 4219869 Business flow
85
86 g_log_level NUMBER;
87 g_log_enabled BOOLEAN;
88
89 PROCEDURE trace
90 (p_msg IN VARCHAR2
91 ,p_level IN NUMBER
92 ,p_module IN VARCHAR2 ) IS
93 BEGIN
94 ----------------------------------------------------------------------------
95 -- Following is for FND log.
96 ----------------------------------------------------------------------------
97 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
98 fnd_log.message(p_level, p_module);
99 ELSIF p_level >= g_log_level THEN
100 fnd_log.string(p_level, p_module, p_msg);
101 END IF;
102
103 EXCEPTION
104 WHEN xla_exceptions_pkg.application_exception THEN
105 RAISE;
106 WHEN OTHERS THEN
107 xla_exceptions_pkg.raise_message
108 (p_location => 'XLA_00707_AAD_S_000020_PKG.trace');
109 END trace;
110
111 --
112 --+============================================+
113 --| |
114 --| PRIVATE PROCEDURES/FUNCTIONS |
115 --| |
116 --+============================================+
117 --
118
119 --
120 /*======================================================================+
121 | |
122 | Private Function |
123 | ValidateLookupMeaning |
124 | |
125 +======================================================================*/
126 FUNCTION ValidateLookupMeaning(
127 p_meaning IN VARCHAR2
128 , p_lookup_code IN VARCHAR2
129 , p_lookup_type IN VARCHAR2
130 , p_source_code IN VARCHAR2
131 , p_source_type_code IN VARCHAR2
132 , p_source_application_id IN INTEGER
133 )
134 RETURN VARCHAR2
135 IS
136 l_log_module VARCHAR2(240);
137 BEGIN
138 IF g_log_enabled THEN
139 l_log_module := C_DEFAULT_MODULE||'.ValidateLookupMeaning';
140 END IF;
141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142 trace
143 (p_msg => 'BEGIN of ValidateLookupMeaning'
144 ,p_level => C_LEVEL_PROCEDURE
145 ,p_module => l_log_module);
146 END IF;
147 --
148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
149 trace
150 (p_msg => 'p_source_code = '|| p_source_code||
151 ' - p_source_type_code = '|| p_source_type_code||
152 ' - p_source_application_id = '|| p_source_application_id||
153 ' - p_lookup_code = '|| p_lookup_code||
154 ' - p_lookup_type = '|| p_lookup_type||
155 ' - p_meaning = '|| p_meaning
156 ,p_level => C_LEVEL_PROCEDURE
157 ,p_module => l_log_module);
158
159 END IF;
160
161 IF p_lookup_code IS NOT NULL AND p_meaning IS NULL THEN
162 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
166 ,p_token_1 => 'SOURCE_NAME'
167 ,p_value_1 => xla_ae_sources_pkg.GetSourceName(
168 p_source_code
169 , p_source_type_code
170 , p_source_application_id
171 )
172 ,p_token_2 => 'LOOKUP_CODE'
173 ,p_value_2 => p_lookup_code
174 ,p_token_3 => 'LOOKUP_TYPE'
175 ,p_value_3 => p_lookup_type
176 ,p_token_4 => 'PRODUCT_NAME'
177 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
178 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
179 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
180 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
181 );
182
183 IF (C_LEVEL_ERROR >= g_log_level) THEN
184 trace
185 (p_msg => 'ERROR: XLA_AP_NO_LOOKUP_MEANING'
186 ,p_level => C_LEVEL_ERROR
187 ,p_module => l_log_module);
188 END IF;
189 END IF;
190
191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192 trace
193 (p_msg => 'END of ValidateLookupMeaning'
194 ,p_level => C_LEVEL_PROCEDURE
195 ,p_module => l_log_module);
196 END IF;
197 RETURN p_meaning;
198 EXCEPTION
199 WHEN xla_exceptions_pkg.application_exception THEN
200 RETURN p_meaning;
201 WHEN OTHERS THEN
202 xla_exceptions_pkg.raise_message
203 (p_location => 'XLA_00707_AAD_S_000020_PKG.ValidateLookupMeaning');
204 --
205 END ValidateLookupMeaning;
206 --
207 --
208
209 --
210 ---------------------------------------
211 --
212 -- PUBLIC FUNCTION
213 -- GetMeaning
214 --
215 ---------------------------------------
216 FUNCTION GetMeaning (
217 p_flex_value_set_id IN INTEGER
218 , p_flex_value IN VARCHAR2
219 , p_source_code IN VARCHAR2
220 , p_source_type_code IN VARCHAR2
221 , p_source_application_id IN INTEGER
222 )
223 RETURN VARCHAR2
224 IS
225 l_meaning_meaning VARCHAR2(4000);
226 l_array_meaning xla_ae_sources_pkg.t_array_meaning;
227 l_Idx INTEGER;
228 l_log_module VARCHAR2(240);
229 --
230 BEGIN
231 IF g_log_enabled THEN
232 l_log_module := C_DEFAULT_MODULE||'.GetMeaning';
233 END IF;
234 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
235 trace
236 (p_msg => 'BEGIN of GetMeaning'||
237 'p_flex_value_set_id = '||p_flex_value_set_id||
238 'p_flex_value = '||p_flex_value
239 ,p_level => C_LEVEL_PROCEDURE
240 ,p_module => l_log_module);
241 END IF;
242 --
243 l_array_meaning := xla_ae_sources_pkg.g_array_meaning;
244 --
245 IF p_flex_value IS NULL THEN
246
247 l_meaning_meaning := NULL;
248
249 ELSE
250
251 CASE p_flex_value_set_id
252
253 WHEN 1009615 THEN
254
255 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
256
257 trace
258 (p_msg => '-> CALL DBMS_UTILITY.get_hash_value'
259 ,p_level => C_LEVEL_PROCEDURE
260 ,p_module => l_log_module);
261
262 END IF;
263
264 l_Idx := DBMS_UTILITY.get_hash_value(TO_CHAR(p_flex_value),1,1073741824);
265
266 IF l_array_meaning.EXISTS(1009615) AND
267 l_array_meaning(1009615).array_flex_value.EXISTS(l_Idx) AND
268 l_array_meaning(1009615).array_flex_value(l_Idx) = p_flex_value THEN
269
270 l_meaning_meaning := l_array_meaning(1009615).array_meaning(l_Idx);
271
272 ELSE
273
274 SELECT COST_ELEMENT
275 INTO l_meaning_meaning
276 FROM CST_COST_ELEMENTS
277 WHERE COST_ELEMENT_ID = p_flex_value
278 ;
279
280 l_array_meaning(1009615).array_flex_value(l_Idx) := p_flex_value;
281 l_array_meaning(1009615).array_meaning(l_Idx) := l_meaning_meaning;
282
283 END IF;
284
285 WHEN 1009622 THEN
286
287 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
288
289 trace
290 (p_msg => '-> CALL DBMS_UTILITY.get_hash_value'
291 ,p_level => C_LEVEL_PROCEDURE
292 ,p_module => l_log_module);
293
294 END IF;
295
296 l_Idx := DBMS_UTILITY.get_hash_value(TO_CHAR(p_flex_value),1,1073741824);
297
298 IF l_array_meaning.EXISTS(1009622) AND
299 l_array_meaning(1009622).array_flex_value.EXISTS(l_Idx) AND
300 l_array_meaning(1009622).array_flex_value(l_Idx) = p_flex_value THEN
301
302 l_meaning_meaning := l_array_meaning(1009622).array_meaning(l_Idx);
303
304 ELSE
305
306 SELECT msi.secondary_inventory_name
307 INTO l_meaning_meaning
308 FROM MTL_SECONDARY_INVENTORIES MSI, MTL_PARAMETERS MP
309 WHERE msi.secondary_inventory_name = p_flex_value AND msi.organization_id = mp.organization_id ;
310
311 l_array_meaning(1009622).array_flex_value(l_Idx) := p_flex_value;
312 l_array_meaning(1009622).array_meaning(l_Idx) := l_meaning_meaning;
313
314 END IF;
315
316 WHEN 1010619 THEN
317
318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
319
320 trace
321 (p_msg => '-> CALL DBMS_UTILITY.get_hash_value'
322 ,p_level => C_LEVEL_PROCEDURE
323 ,p_module => l_log_module);
324
325 END IF;
326
327 l_Idx := DBMS_UTILITY.get_hash_value(TO_CHAR(p_flex_value),1,1073741824);
328
329 IF l_array_meaning.EXISTS(1010619) AND
330 l_array_meaning(1010619).array_flex_value.EXISTS(l_Idx) AND
331 l_array_meaning(1010619).array_flex_value(l_Idx) = p_flex_value THEN
332
333 l_meaning_meaning := l_array_meaning(1010619).array_meaning(l_Idx);
334
335 ELSE
336
337 SELECT ORGANIZATION_CODE
338 INTO l_meaning_meaning
339 FROM ORG_ORGANIZATION_DEFINITIONS
340 WHERE ORGANIZATION_ID = p_flex_value
341 ;
342
343 l_array_meaning(1010619).array_flex_value(l_Idx) := p_flex_value;
344 l_array_meaning(1010619).array_meaning(l_Idx) := l_meaning_meaning;
345
346 END IF;
347
348 WHEN 1010619 THEN
349
350 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
351
352 trace
353 (p_msg => '-> CALL DBMS_UTILITY.get_hash_value'
354 ,p_level => C_LEVEL_PROCEDURE
355 ,p_module => l_log_module);
356
357 END IF;
358
359 l_Idx := DBMS_UTILITY.get_hash_value(TO_CHAR(p_flex_value),1,1073741824);
360
361 IF l_array_meaning.EXISTS(1010619) AND
362 l_array_meaning(1010619).array_flex_value.EXISTS(l_Idx) AND
363 l_array_meaning(1010619).array_flex_value(l_Idx) = p_flex_value THEN
364
365 l_meaning_meaning := l_array_meaning(1010619).array_meaning(l_Idx);
366
367 ELSE
368
369 SELECT ORGANIZATION_CODE
370 INTO l_meaning_meaning
371 FROM ORG_ORGANIZATION_DEFINITIONS
372 WHERE ORGANIZATION_ID = p_flex_value
373 ;
374
375 l_array_meaning(1010619).array_flex_value(l_Idx) := p_flex_value;
376 l_array_meaning(1010619).array_meaning(l_Idx) := l_meaning_meaning;
377
378 END IF;
379
380 ELSE
381 l_meaning_meaning := NULL;
382 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
383 xla_accounting_err_pkg.build_message
384 (p_appli_s_name => 'XLA'
385 ,p_msg_name => 'XLA_AP_FLEX_VALUE_MEANING'
386 ,p_token_1 => 'VALUE_SET_NAME'
387 ,p_value_1 => xla_flex_pkg.get_value_set_name(p_flex_value_set_id)
388 ,p_token_2 => 'FLEX_VALUE'
389 ,p_value_2 => p_flex_value
390 ,p_token_3 => 'SOURCE_NAME'
391 ,p_value_3 => xla_ae_sources_pkg.GetSourceName(
392 p_source_code
393 , p_source_type_code
394 , p_source_application_id
395 )
396 ,p_token_4 => 'PRODUCT_NAME'
397 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
398 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
399 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
400 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
401 );
402 IF (C_LEVEL_ERROR >= g_log_level) THEN
403 trace
404 (p_msg => 'ERROR: XLA_AP_FLEX_VALUE_MEANING'
405 ,p_level => C_LEVEL_ERROR
406 ,p_module => l_log_module);
407 END IF;
408 END CASE;
409 --
410 END IF;
411 --
412 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
413
414 trace
415 (p_msg => 'return value. meaning = '||l_meaning_meaning
416 ,p_level => C_LEVEL_PROCEDURE
417 ,p_module => l_log_module);
418
419 trace
420 (p_msg => 'END of GetMeaning'
421 ,p_level => C_LEVEL_PROCEDURE
422 ,p_module => l_log_module);
423 END IF;
424 --
425 xla_ae_sources_pkg.g_array_meaning := l_array_meaning ;
426 --
427 RETURN l_meaning_meaning ;
428 --
429 EXCEPTION
430 WHEN NO_DATA_FOUND OR TOO_MANY_ROWS THEN
431 --
432 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
433 xla_accounting_err_pkg.build_message
434 (p_appli_s_name => 'XLA'
435 ,p_msg_name => 'XLA_AP_FLEX_VALUE_MEANING'
436 ,p_token_1 => 'VALUE_SET_NAME'
437 ,p_value_1 => xla_flex_pkg.get_value_set_name(p_flex_value_set_id)
438 ,p_token_2 => 'FLEX_VALUE'
439 ,p_value_2 => p_flex_value
440 ,p_token_3 => 'SOURCE_NAME'
441 ,p_value_3 => xla_ae_sources_pkg.GetSourceName(
442 p_source_code
443 , p_source_type_code
444 , p_source_application_id
445 )
446 ,p_token_4 => 'PRODUCT_NAME'
447 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
448 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
449 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
450 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
451 );
452
453 IF (C_LEVEL_ERROR >= g_log_level) THEN
454 trace
455 (p_msg => 'ERROR: XLA_AP_FLEX_VALUE_MEANING'
456 ,p_level => C_LEVEL_ERROR
457 ,p_module => l_log_module);
458 END IF;
459
460 RETURN NULL;
461 WHEN xla_exceptions_pkg.application_exception THEN
462 RAISE;
463 WHEN OTHERS THEN
464 xla_exceptions_pkg.raise_message
465 (p_location => 'XLA_00707_AAD_S_000020_PKG.GetMeaning');
466 END GetMeaning;
467 --
468
469 ---------------------------------------
470 --
471 -- PRIVATE FUNCTION
472 -- Description_1
473 --
474 ---------------------------------------
475 FUNCTION Description_1 (
476 p_application_id IN NUMBER
477 , p_ae_header_id IN NUMBER DEFAULT NULL
478 --TRANSACTION_ID
479 , p_source_1 IN NUMBER
480 --Item Concatenated Segments
481 , p_source_2 IN VARCHAR2
482 --Transaction Quantity
483 , p_source_3 IN NUMBER
484 --Transaction Unit of Measure Code
485 , p_source_4 IN VARCHAR2
486 --Inventory Transaction Type Description
487 , p_source_5 IN VARCHAR2
488 )
489 RETURN VARCHAR2
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_ledger_language VARCHAR2(30) ;
497 l_source VARCHAR2(1996) ;
498 l_description VARCHAR2(2000) ;
499 l_log_module VARCHAR2(240) ;
500 BEGIN
501 IF g_log_enabled THEN
502 l_log_module := C_DEFAULT_MODULE||'.Description_1';
503 END IF;
504 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
505 trace
506 (p_msg => 'BEGIN of Description_1'
507 ,p_level => C_LEVEL_PROCEDURE
508 ,p_module => l_log_module);
509 END IF;
510
511 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
512 l_component_type := 'AMB_DESCRIPTION';
513 l_component_code := 'PI_MATERIAL_TRANSACTION';
514 l_component_type_code := 'S';
515 l_component_appl_id := 707;
516 l_amb_context_code := 'DEFAULT';
517 l_source := NULL;
518 l_description := NULL;
519
520
521
522 l_source := SUBSTR(TO_CHAR(p_source_1),1,1996);
523 IF l_source IS NOT NULL THEN
524 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
525 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
526 END IF;
527 IF
528 l_ledger_language = 'US' THEN
529 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
530 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
531 END IF;
532 l_source := SUBSTR(p_source_2,1,1996);
533 IF l_source IS NOT NULL THEN
534 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
535 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
536 END IF;
537 IF
538 l_ledger_language = 'US' THEN
539 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
540 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
541 END IF;
542 l_source := SUBSTR(TO_CHAR(p_source_3),1,1996);
543 IF l_source IS NOT NULL THEN
544 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
545 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
546 END IF;
547 IF
548 l_ledger_language = 'US' THEN
549 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
550 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
551 END IF;
552 l_source := SUBSTR(p_source_4,1,1996);
553 IF l_source IS NOT NULL THEN
554 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
555 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
556 END IF;
557 IF
558 l_ledger_language = 'US' THEN
559 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
560 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
561 END IF;
562 l_source := SUBSTR(p_source_5,1,1996);
563 IF l_source IS NOT NULL THEN
564 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
565 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
566 END IF;
567 l_description := SUBSTR(l_description,1,1996);
568 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
569 trace
570 (p_msg => 'END of Description_1'
571 ,p_level => C_LEVEL_PROCEDURE
572 ,p_module => l_log_module);
573
574 END IF;
575 RETURN l_description;
576
577 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
578 trace
579 (p_msg => 'END of Description_1'
580 ,p_level => C_LEVEL_PROCEDURE
581 ,p_module => l_log_module);
582 END IF;
583 RETURN NULL;
584 EXCEPTION
585 WHEN VALUE_ERROR THEN
586 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
587 trace
588 (p_msg => 'ERROR: '||sqlerrm
589 ,p_level => C_LEVEL_EXCEPTION
590 ,p_module => l_log_module);
591 END IF;
592 RAISE;
593 WHEN xla_exceptions_pkg.application_exception THEN
594 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
595 trace
596 (p_msg => 'ERROR: '||sqlerrm
597 ,p_level => C_LEVEL_EXCEPTION
598 ,p_module => l_log_module);
599 END IF;
600 RAISE;
601 WHEN OTHERS THEN
602 xla_exceptions_pkg.raise_message
603 (p_location => 'XLA_00707_AAD_S_000020_PKG.Description_1');
604 END Description_1;
605
606 ---------------------------------------
607 --
608 -- PRIVATE FUNCTION
609 -- Description_2
610 --
611 ---------------------------------------
612 FUNCTION Description_2 (
613 p_application_id IN NUMBER
614 , p_ae_header_id IN NUMBER DEFAULT NULL
615 --TRANSACTION_ID
616 , p_source_1 IN NUMBER
617 --Transaction Unit of Measure Code
618 , p_source_4 IN VARCHAR2
619 --Primary Quantity of the Transaction
620 , p_source_6 IN NUMBER
621 --WIP Transaction Type
622 , p_source_7 IN NUMBER
623 , p_source_7_meaning IN VARCHAR2
624 )
625 RETURN VARCHAR2
626 IS
627 l_component_type VARCHAR2(80) ;
628 l_component_code VARCHAR2(30) ;
629 l_component_type_code VARCHAR2(1) ;
630 l_component_appl_id INTEGER ;
631 l_amb_context_code VARCHAR2(30) ;
632 l_ledger_language VARCHAR2(30) ;
633 l_source VARCHAR2(1996) ;
634 l_description VARCHAR2(2000) ;
635 l_log_module VARCHAR2(240) ;
636 BEGIN
637 IF g_log_enabled THEN
638 l_log_module := C_DEFAULT_MODULE||'.Description_2';
639 END IF;
640 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
641 trace
642 (p_msg => 'BEGIN of Description_2'
643 ,p_level => C_LEVEL_PROCEDURE
644 ,p_module => l_log_module);
645 END IF;
646
647 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
648 l_component_type := 'AMB_DESCRIPTION';
649 l_component_code := 'PI_OUTSIDE_PROCESSING';
650 l_component_type_code := 'S';
651 l_component_appl_id := 707;
652 l_amb_context_code := 'DEFAULT';
653 l_source := NULL;
654 l_description := NULL;
655
656
657
658 l_source := SUBSTR(TO_CHAR(p_source_6),1,1996);
659 IF l_source IS NOT NULL THEN
660 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
661 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
662 END IF;
663 IF
664 l_ledger_language = 'US' THEN
665 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
666 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
667 END IF;
668 l_source := SUBSTR(p_source_4,1,1996);
669 IF l_source IS NOT NULL THEN
670 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
671 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
672 END IF;
673 IF
674 l_ledger_language = 'US' THEN
675 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
676 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
677 END IF;
678 l_source := SUBSTR(TO_CHAR(p_source_1),1,1996);
679 IF l_source IS NOT NULL THEN
680 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
681 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
682 END IF;
683 IF
684 l_ledger_language = 'US' THEN
685 l_description := SUBSTR(CONCAT(l_description,'-'),1,2000);
686 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
687 END IF;
688 l_source := SUBSTR(TO_CHAR(
689 ValidateLookupMeaning(
690 p_meaning => p_source_7_meaning
691 , p_lookup_code => TO_CHAR(p_source_7)
692 , p_lookup_type => 'WIP_TRANSACTION_TYPE'
693 , p_source_code => 'WIP_TRANSACTION_TYPE_ID'
694 , p_source_type_code => 'S'
695 , p_source_application_id => 707
696 )
697 ),1,1996);
698 IF l_source IS NOT NULL THEN
699 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
700 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
701 END IF;
702 l_description := SUBSTR(l_description,1,1996);
703 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
704 trace
705 (p_msg => 'END of Description_2'
706 ,p_level => C_LEVEL_PROCEDURE
707 ,p_module => l_log_module);
708
709 END IF;
710 RETURN l_description;
711
712 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
713 trace
714 (p_msg => 'END of Description_2'
715 ,p_level => C_LEVEL_PROCEDURE
716 ,p_module => l_log_module);
717 END IF;
718 RETURN NULL;
719 EXCEPTION
720 WHEN VALUE_ERROR THEN
721 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
722 trace
723 (p_msg => 'ERROR: '||sqlerrm
724 ,p_level => C_LEVEL_EXCEPTION
725 ,p_module => l_log_module);
726 END IF;
727 RAISE;
728 WHEN xla_exceptions_pkg.application_exception THEN
729 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
730 trace
731 (p_msg => 'ERROR: '||sqlerrm
732 ,p_level => C_LEVEL_EXCEPTION
733 ,p_module => l_log_module);
734 END IF;
735 RAISE;
736 WHEN OTHERS THEN
737 xla_exceptions_pkg.raise_message
738 (p_location => 'XLA_00707_AAD_S_000020_PKG.Description_2');
739 END Description_2;
740
741 ---------------------------------------
742 --
743 -- PRIVATE FUNCTION
744 -- AcctDerRule_3
745 --
746 ---------------------------------------
747 FUNCTION AcctDerRule_3 (
748 p_application_id IN NUMBER
749 , p_ae_header_id IN NUMBER
750 , p_side IN VARCHAR2
751 --Accrual Account for the Write Off
752 , p_source_8 IN NUMBER
753 , x_transaction_coa_id OUT NOCOPY NUMBER
754 , x_accounting_coa_id OUT NOCOPY NUMBER
755 , x_value_type_code OUT NOCOPY VARCHAR2
756 )
757 RETURN NUMBER
758 IS
759 l_component_type VARCHAR2(80) ;
760 l_component_code VARCHAR2(30) ;
761 l_component_type_code VARCHAR2(1) ;
762 l_component_appl_id INTEGER ;
763 l_amb_context_code VARCHAR2(30) ;
764 l_log_module VARCHAR2(240) ;
765 l_output_value NUMBER ;
766 BEGIN
767 IF g_log_enabled THEN
768 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
769 END IF;
770 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
771 trace
772 (p_msg => 'BEGIN of AcctDerRule_3'
773 ,p_level => C_LEVEL_PROCEDURE
774 ,p_module => l_log_module);
775 END IF;
776 --
777 l_component_type := 'AMB_ADR';
778 l_component_code := 'CST_AWO_ACCRUAL';
779 l_component_type_code := 'S';
780 l_component_appl_id := 707;
781 l_amb_context_code := 'DEFAULT';
782 x_transaction_coa_id := null;
783 x_accounting_coa_id := null;
784 --
785
786 --
787 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
788 trace
789 (p_msg => 'END of AcctDerRule_3'
790 ,p_level => C_LEVEL_PROCEDURE
791 ,p_module => l_log_module);
792 END IF;
793 x_value_type_code := 'S';
794 l_output_value := TO_NUMBER(TO_NUMBER(p_source_8));
795 RETURN l_output_value;
796
797 --
798 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
799 trace
800 (p_msg => 'END of AcctDerRule_3(invalid)'
801 ,p_level => C_LEVEL_PROCEDURE
802 ,p_module => l_log_module);
803 END IF;
804 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
805 x_value_type_code := null;
806 l_output_value := null;
807 xla_accounting_err_pkg.build_message
808 (p_appli_s_name => 'XLA'
809 ,p_msg_name => 'XLA_AP_INVALID_ADR'
810 ,p_token_1 => 'COMPONENT_NAME'
811 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
812 l_component_type
813 , l_component_code
814 , l_component_type_code
815 , l_component_appl_id
816 , l_amb_context_code
817 )
818 ,p_token_2 => 'OWNER'
819 ,p_value_2 => xla_lookups_pkg.get_meaning(
820 'XLA_OWNER_TYPE'
821 ,l_component_type_code
822 )
823 ,p_token_3 => 'PAD_NAME'
824 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
825 ,p_token_4 => 'PAD_OWNER'
826 ,p_value_4 => xla_lookups_pkg.get_meaning(
827 'XLA_OWNER_TYPE'
828 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
829 )
830 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
831 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
832 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
833 ,p_ae_header_id => NULL
834 );
835 RETURN l_output_value;
836 EXCEPTION
837 WHEN xla_exceptions_pkg.application_exception THEN
838 RAISE;
839 WHEN OTHERS THEN
840 xla_exceptions_pkg.raise_message
841 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_3');
842 END AcctDerRule_3;
843 --
844
845 ---------------------------------------
846 --
847 -- PRIVATE FUNCTION
848 -- AcctDerRule_4
849 --
850 ---------------------------------------
851 FUNCTION AcctDerRule_4 (
852 p_application_id IN NUMBER
853 , p_ae_header_id IN NUMBER
854 , p_side IN VARCHAR2
855 --Write-Off Variance Account
856 , p_source_9 IN NUMBER
857 , x_transaction_coa_id OUT NOCOPY NUMBER
858 , x_accounting_coa_id OUT NOCOPY NUMBER
859 , x_value_type_code OUT NOCOPY VARCHAR2
860 )
861 RETURN NUMBER
862 IS
863 l_component_type VARCHAR2(80) ;
864 l_component_code VARCHAR2(30) ;
865 l_component_type_code VARCHAR2(1) ;
866 l_component_appl_id INTEGER ;
867 l_amb_context_code VARCHAR2(30) ;
868 l_log_module VARCHAR2(240) ;
869 l_output_value NUMBER ;
870 BEGIN
871 IF g_log_enabled THEN
872 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_4';
873 END IF;
874 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
875 trace
876 (p_msg => 'BEGIN of AcctDerRule_4'
877 ,p_level => C_LEVEL_PROCEDURE
878 ,p_module => l_log_module);
879 END IF;
880 --
881 l_component_type := 'AMB_ADR';
882 l_component_code := 'CST_AWO_ERV';
883 l_component_type_code := 'S';
884 l_component_appl_id := 707;
885 l_amb_context_code := 'DEFAULT';
886 x_transaction_coa_id := null;
887 x_accounting_coa_id := null;
888 --
889
890 --
891 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
892 trace
893 (p_msg => 'END of AcctDerRule_4'
894 ,p_level => C_LEVEL_PROCEDURE
895 ,p_module => l_log_module);
896 END IF;
897 x_value_type_code := 'S';
898 l_output_value := TO_NUMBER(TO_NUMBER(p_source_9));
899 RETURN l_output_value;
900
901 --
902 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
903 trace
904 (p_msg => 'END of AcctDerRule_4(invalid)'
905 ,p_level => C_LEVEL_PROCEDURE
906 ,p_module => l_log_module);
907 END IF;
908 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
909 x_value_type_code := null;
910 l_output_value := null;
911 xla_accounting_err_pkg.build_message
912 (p_appli_s_name => 'XLA'
913 ,p_msg_name => 'XLA_AP_INVALID_ADR'
914 ,p_token_1 => 'COMPONENT_NAME'
915 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
916 l_component_type
917 , l_component_code
918 , l_component_type_code
919 , l_component_appl_id
920 , l_amb_context_code
921 )
922 ,p_token_2 => 'OWNER'
923 ,p_value_2 => xla_lookups_pkg.get_meaning(
924 'XLA_OWNER_TYPE'
925 ,l_component_type_code
926 )
927 ,p_token_3 => 'PAD_NAME'
928 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
929 ,p_token_4 => 'PAD_OWNER'
930 ,p_value_4 => xla_lookups_pkg.get_meaning(
931 'XLA_OWNER_TYPE'
932 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
933 )
934 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
935 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
936 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
937 ,p_ae_header_id => NULL
938 );
939 RETURN l_output_value;
940 EXCEPTION
941 WHEN xla_exceptions_pkg.application_exception THEN
942 RAISE;
943 WHEN OTHERS THEN
944 xla_exceptions_pkg.raise_message
945 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_4');
946 END AcctDerRule_4;
947 --
948
949 ---------------------------------------
950 --
951 -- PRIVATE FUNCTION
952 -- AcctDerRule_5
953 --
954 ---------------------------------------
955 FUNCTION AcctDerRule_5 (
956 p_application_id IN NUMBER
957 , p_ae_header_id IN NUMBER
958 , p_side IN VARCHAR2
959 --Offset Account for the Write Off
960 , p_source_10 IN NUMBER
961 , x_transaction_coa_id OUT NOCOPY NUMBER
962 , x_accounting_coa_id OUT NOCOPY NUMBER
963 , x_value_type_code OUT NOCOPY VARCHAR2
964 )
965 RETURN NUMBER
966 IS
967 l_component_type VARCHAR2(80) ;
968 l_component_code VARCHAR2(30) ;
969 l_component_type_code VARCHAR2(1) ;
970 l_component_appl_id INTEGER ;
971 l_amb_context_code VARCHAR2(30) ;
972 l_log_module VARCHAR2(240) ;
973 l_output_value NUMBER ;
974 BEGIN
975 IF g_log_enabled THEN
976 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
977 END IF;
978 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
979 trace
980 (p_msg => 'BEGIN of AcctDerRule_5'
981 ,p_level => C_LEVEL_PROCEDURE
982 ,p_module => l_log_module);
983 END IF;
984 --
985 l_component_type := 'AMB_ADR';
986 l_component_code := 'CST_AWO_OFFSET';
987 l_component_type_code := 'S';
988 l_component_appl_id := 707;
989 l_amb_context_code := 'DEFAULT';
990 x_transaction_coa_id := null;
991 x_accounting_coa_id := null;
992 --
993
994 --
995 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
996 trace
997 (p_msg => 'END of AcctDerRule_5'
998 ,p_level => C_LEVEL_PROCEDURE
999 ,p_module => l_log_module);
1000 END IF;
1001 x_value_type_code := 'S';
1002 l_output_value := TO_NUMBER(TO_NUMBER(p_source_10));
1003 RETURN l_output_value;
1004
1005 --
1006 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1007 trace
1008 (p_msg => 'END of AcctDerRule_5(invalid)'
1009 ,p_level => C_LEVEL_PROCEDURE
1010 ,p_module => l_log_module);
1011 END IF;
1012 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
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_00707_AAD_S_000020_PKG.AcctDerRule_5');
1050 END AcctDerRule_5;
1051 --
1052
1053 ---------------------------------------
1054 --
1055 -- PRIVATE FUNCTION
1056 -- AcctDerRule_6
1057 --
1058 ---------------------------------------
1059 FUNCTION AcctDerRule_6 (
1060 p_application_id IN NUMBER
1061 , p_ae_header_id IN NUMBER
1062 , p_side IN VARCHAR2
1063 --Cost Management Default Account
1064 , p_source_11 IN NUMBER
1065 , x_transaction_coa_id OUT NOCOPY NUMBER
1066 , x_accounting_coa_id OUT NOCOPY NUMBER
1067 , x_value_type_code OUT NOCOPY VARCHAR2
1068 )
1069 RETURN NUMBER
1070 IS
1071 l_component_type VARCHAR2(80) ;
1072 l_component_code VARCHAR2(30) ;
1073 l_component_type_code VARCHAR2(1) ;
1074 l_component_appl_id INTEGER ;
1075 l_amb_context_code VARCHAR2(30) ;
1076 l_log_module VARCHAR2(240) ;
1077 l_output_value NUMBER ;
1078 BEGIN
1079 IF g_log_enabled THEN
1080 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
1081 END IF;
1082 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1083 trace
1084 (p_msg => 'BEGIN of AcctDerRule_6'
1085 ,p_level => C_LEVEL_PROCEDURE
1086 ,p_module => l_log_module);
1087 END IF;
1088 --
1089 l_component_type := 'AMB_ADR';
1090 l_component_code := 'CST_DEFAULT';
1091 l_component_type_code := 'S';
1092 l_component_appl_id := 707;
1093 l_amb_context_code := 'DEFAULT';
1094 x_transaction_coa_id := null;
1095 x_accounting_coa_id := null;
1096 --
1097
1098 --
1099 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1100 trace
1101 (p_msg => 'END of AcctDerRule_6'
1102 ,p_level => C_LEVEL_PROCEDURE
1103 ,p_module => l_log_module);
1104 END IF;
1105 x_value_type_code := 'S';
1106 l_output_value := TO_NUMBER(TO_NUMBER(p_source_11));
1107 RETURN l_output_value;
1108
1109 --
1110 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1111 trace
1112 (p_msg => 'END of AcctDerRule_6(invalid)'
1113 ,p_level => C_LEVEL_PROCEDURE
1114 ,p_module => l_log_module);
1115 END IF;
1116 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1117 x_value_type_code := null;
1118 l_output_value := null;
1119 xla_accounting_err_pkg.build_message
1120 (p_appli_s_name => 'XLA'
1121 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1122 ,p_token_1 => 'COMPONENT_NAME'
1123 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1124 l_component_type
1125 , l_component_code
1126 , l_component_type_code
1127 , l_component_appl_id
1128 , l_amb_context_code
1129 )
1130 ,p_token_2 => 'OWNER'
1131 ,p_value_2 => xla_lookups_pkg.get_meaning(
1132 'XLA_OWNER_TYPE'
1133 ,l_component_type_code
1134 )
1135 ,p_token_3 => 'PAD_NAME'
1136 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1137 ,p_token_4 => 'PAD_OWNER'
1138 ,p_value_4 => xla_lookups_pkg.get_meaning(
1139 'XLA_OWNER_TYPE'
1140 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1141 )
1142 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1143 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1144 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1145 ,p_ae_header_id => NULL
1146 );
1147 RETURN l_output_value;
1148 EXCEPTION
1149 WHEN xla_exceptions_pkg.application_exception THEN
1150 RAISE;
1151 WHEN OTHERS THEN
1152 xla_exceptions_pkg.raise_message
1153 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_6');
1154 END AcctDerRule_6;
1155 --
1156
1157 ---------------------------------------
1158 --
1159 -- PRIVATE FUNCTION
1160 -- AcctDerRule_7
1161 --
1162 ---------------------------------------
1163 FUNCTION AcctDerRule_7 (
1164 p_application_id IN NUMBER
1165 , p_ae_header_id IN NUMBER
1166 , p_side IN VARCHAR2
1167 --Discrete Job WIP accounting class expense account
1168 , p_source_12 IN NUMBER
1169 , x_transaction_coa_id OUT NOCOPY NUMBER
1170 , x_accounting_coa_id OUT NOCOPY NUMBER
1171 , x_value_type_code OUT NOCOPY VARCHAR2
1172 )
1173 RETURN NUMBER
1174 IS
1175 l_component_type VARCHAR2(80) ;
1176 l_component_code VARCHAR2(30) ;
1177 l_component_type_code VARCHAR2(1) ;
1178 l_component_appl_id INTEGER ;
1179 l_amb_context_code VARCHAR2(30) ;
1180 l_log_module VARCHAR2(240) ;
1181 l_output_value NUMBER ;
1182 BEGIN
1183 IF g_log_enabled THEN
1184 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_7';
1185 END IF;
1186 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1187 trace
1188 (p_msg => 'BEGIN of AcctDerRule_7'
1189 ,p_level => C_LEVEL_PROCEDURE
1190 ,p_module => l_log_module);
1191 END IF;
1192 --
1193 l_component_type := 'AMB_ADR';
1194 l_component_code := 'DIS_JOB_WIP_ACCT_CLASS_EXP';
1195 l_component_type_code := 'S';
1196 l_component_appl_id := 707;
1197 l_amb_context_code := 'DEFAULT';
1198 x_transaction_coa_id := null;
1199 x_accounting_coa_id := null;
1200 --
1201
1202 --
1203 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1204 trace
1205 (p_msg => 'END of AcctDerRule_7'
1206 ,p_level => C_LEVEL_PROCEDURE
1207 ,p_module => l_log_module);
1208 END IF;
1209 x_value_type_code := 'S';
1210 l_output_value := TO_NUMBER(TO_NUMBER(p_source_12));
1211 RETURN l_output_value;
1212
1213 --
1214 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1215 trace
1216 (p_msg => 'END of AcctDerRule_7(invalid)'
1217 ,p_level => C_LEVEL_PROCEDURE
1218 ,p_module => l_log_module);
1219 END IF;
1220 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1221 x_value_type_code := null;
1222 l_output_value := null;
1223 xla_accounting_err_pkg.build_message
1224 (p_appli_s_name => 'XLA'
1225 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1226 ,p_token_1 => 'COMPONENT_NAME'
1227 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1228 l_component_type
1229 , l_component_code
1230 , l_component_type_code
1231 , l_component_appl_id
1232 , l_amb_context_code
1233 )
1234 ,p_token_2 => 'OWNER'
1235 ,p_value_2 => xla_lookups_pkg.get_meaning(
1236 'XLA_OWNER_TYPE'
1237 ,l_component_type_code
1238 )
1239 ,p_token_3 => 'PAD_NAME'
1240 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1241 ,p_token_4 => 'PAD_OWNER'
1242 ,p_value_4 => xla_lookups_pkg.get_meaning(
1243 'XLA_OWNER_TYPE'
1244 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1245 )
1246 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1247 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1248 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1249 ,p_ae_header_id => NULL
1250 );
1251 RETURN l_output_value;
1252 EXCEPTION
1253 WHEN xla_exceptions_pkg.application_exception THEN
1254 RAISE;
1255 WHEN OTHERS THEN
1256 xla_exceptions_pkg.raise_message
1257 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_7');
1258 END AcctDerRule_7;
1259 --
1260
1261 ---------------------------------------
1262 --
1263 -- PRIVATE FUNCTION
1264 -- AcctDerRule_8
1265 --
1266 ---------------------------------------
1267 FUNCTION AcctDerRule_8 (
1268 p_application_id IN NUMBER
1269 , p_ae_header_id IN NUMBER
1270 , p_side IN VARCHAR2
1271 --Resource/ Overhead Absorption Account
1272 , p_source_13 IN NUMBER
1273 , x_transaction_coa_id OUT NOCOPY NUMBER
1274 , x_accounting_coa_id OUT NOCOPY NUMBER
1275 , x_value_type_code OUT NOCOPY VARCHAR2
1276 )
1277 RETURN NUMBER
1278 IS
1279 l_component_type VARCHAR2(80) ;
1280 l_component_code VARCHAR2(30) ;
1281 l_component_type_code VARCHAR2(1) ;
1282 l_component_appl_id INTEGER ;
1283 l_amb_context_code VARCHAR2(30) ;
1284 l_log_module VARCHAR2(240) ;
1285 l_output_value NUMBER ;
1286 BEGIN
1287 IF g_log_enabled THEN
1288 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_8';
1289 END IF;
1290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1291 trace
1292 (p_msg => 'BEGIN of AcctDerRule_8'
1293 ,p_level => C_LEVEL_PROCEDURE
1294 ,p_module => l_log_module);
1295 END IF;
1296 --
1297 l_component_type := 'AMB_ADR';
1298 l_component_code := 'PI_ABSORPTION';
1299 l_component_type_code := 'S';
1300 l_component_appl_id := 707;
1301 l_amb_context_code := 'DEFAULT';
1302 x_transaction_coa_id := null;
1303 x_accounting_coa_id := null;
1304 --
1305
1306 --
1307 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1308 trace
1309 (p_msg => 'END of AcctDerRule_8'
1310 ,p_level => C_LEVEL_PROCEDURE
1311 ,p_module => l_log_module);
1312 END IF;
1313 x_value_type_code := 'S';
1314 l_output_value := TO_NUMBER(TO_NUMBER(p_source_13));
1315 RETURN l_output_value;
1316
1317 --
1318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1319 trace
1320 (p_msg => 'END of AcctDerRule_8(invalid)'
1321 ,p_level => C_LEVEL_PROCEDURE
1322 ,p_module => l_log_module);
1323 END IF;
1324 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1325 x_value_type_code := null;
1326 l_output_value := null;
1327 xla_accounting_err_pkg.build_message
1328 (p_appli_s_name => 'XLA'
1329 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1330 ,p_token_1 => 'COMPONENT_NAME'
1331 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1332 l_component_type
1333 , l_component_code
1334 , l_component_type_code
1335 , l_component_appl_id
1336 , l_amb_context_code
1337 )
1338 ,p_token_2 => 'OWNER'
1339 ,p_value_2 => xla_lookups_pkg.get_meaning(
1340 'XLA_OWNER_TYPE'
1341 ,l_component_type_code
1342 )
1343 ,p_token_3 => 'PAD_NAME'
1344 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1345 ,p_token_4 => 'PAD_OWNER'
1346 ,p_value_4 => xla_lookups_pkg.get_meaning(
1347 'XLA_OWNER_TYPE'
1348 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1349 )
1350 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1351 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1352 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1353 ,p_ae_header_id => NULL
1354 );
1355 RETURN l_output_value;
1356 EXCEPTION
1357 WHEN xla_exceptions_pkg.application_exception THEN
1358 RAISE;
1359 WHEN OTHERS THEN
1360 xla_exceptions_pkg.raise_message
1361 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_8');
1362 END AcctDerRule_8;
1363 --
1364
1365 ---------------------------------------
1366 --
1367 -- PRIVATE FUNCTION
1368 -- AcctDerRule_9
1369 --
1370 ---------------------------------------
1371 FUNCTION AcctDerRule_9 (
1372 p_application_id IN NUMBER
1373 , p_ae_header_id IN NUMBER
1374 , p_side IN VARCHAR2
1375 --Transaction Material Account
1376 , p_source_14 IN NUMBER
1377 --Cost Element Name
1378 , p_source_15 IN NUMBER
1379 --Transaction Material Overhead Account
1380 , p_source_16 IN NUMBER
1381 --Transaction Resource Account
1382 , p_source_17 IN NUMBER
1383 --Transaction Outside Processing Account
1384 , p_source_18 IN NUMBER
1385 --Transaction Overhead Account
1386 , p_source_19 IN NUMBER
1387 --Transaction Distribution Account
1388 , p_source_20 IN NUMBER
1389 , x_transaction_coa_id OUT NOCOPY NUMBER
1390 , x_accounting_coa_id OUT NOCOPY NUMBER
1391 , x_value_type_code OUT NOCOPY VARCHAR2
1392 )
1393 RETURN NUMBER
1394 IS
1395 l_component_type VARCHAR2(80) ;
1396 l_component_code VARCHAR2(30) ;
1397 l_component_type_code VARCHAR2(1) ;
1398 l_component_appl_id INTEGER ;
1399 l_amb_context_code VARCHAR2(30) ;
1400 l_log_module VARCHAR2(240) ;
1401 l_output_value NUMBER ;
1402 BEGIN
1403 IF g_log_enabled THEN
1404 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_9';
1405 END IF;
1406 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1407 trace
1408 (p_msg => 'BEGIN of AcctDerRule_9'
1409 ,p_level => C_LEVEL_PROCEDURE
1410 ,p_module => l_log_module);
1411 END IF;
1412 --
1413 l_component_type := 'AMB_ADR';
1414 l_component_code := 'PI_AVG_COST_UPT_OFFSET';
1415 l_component_type_code := 'S';
1416 l_component_appl_id := 707;
1417 l_amb_context_code := 'DEFAULT';
1418 x_transaction_coa_id := null;
1419 x_accounting_coa_id := null;
1420 --
1421
1422 IF NVL(p_source_15,9E125) = 1
1423 THEN
1424 --
1425 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1426 trace
1427 (p_msg => 'END of AcctDerRule_9'
1428 ,p_level => C_LEVEL_PROCEDURE
1429 ,p_module => l_log_module);
1430 END IF;
1431 x_value_type_code := 'S';
1432 l_output_value := TO_NUMBER(TO_NUMBER(p_source_14));
1433 RETURN l_output_value;
1434
1435 ELSIF NVL(p_source_15,9E125) = 2
1436 THEN
1437 --
1438 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1439 trace
1440 (p_msg => 'END of AcctDerRule_9'
1441 ,p_level => C_LEVEL_PROCEDURE
1442 ,p_module => l_log_module);
1443 END IF;
1444 x_value_type_code := 'S';
1445 l_output_value := TO_NUMBER(TO_NUMBER(p_source_16));
1446 RETURN l_output_value;
1447
1448 ELSIF NVL(p_source_15,9E125) = 3
1449 THEN
1450 --
1451 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1452 trace
1453 (p_msg => 'END of AcctDerRule_9'
1454 ,p_level => C_LEVEL_PROCEDURE
1455 ,p_module => l_log_module);
1456 END IF;
1457 x_value_type_code := 'S';
1458 l_output_value := TO_NUMBER(TO_NUMBER(p_source_17));
1459 RETURN l_output_value;
1460
1461 ELSIF NVL(p_source_15,9E125) = 4
1462 THEN
1463 --
1464 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1465 trace
1466 (p_msg => 'END of AcctDerRule_9'
1467 ,p_level => C_LEVEL_PROCEDURE
1468 ,p_module => l_log_module);
1469 END IF;
1470 x_value_type_code := 'S';
1471 l_output_value := TO_NUMBER(TO_NUMBER(p_source_18));
1472 RETURN l_output_value;
1473
1474 ELSIF NVL(p_source_15,9E125) = 5
1475 THEN
1476 --
1477 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1478 trace
1479 (p_msg => 'END of AcctDerRule_9'
1480 ,p_level => C_LEVEL_PROCEDURE
1481 ,p_module => l_log_module);
1482 END IF;
1483 x_value_type_code := 'S';
1484 l_output_value := TO_NUMBER(TO_NUMBER(p_source_19));
1485 RETURN l_output_value;
1486
1487 END IF;
1488
1489 --
1490 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1491 trace
1492 (p_msg => 'END of AcctDerRule_9'
1493 ,p_level => C_LEVEL_PROCEDURE
1494 ,p_module => l_log_module);
1495 END IF;
1496 x_value_type_code := 'S';
1497 l_output_value := TO_NUMBER(TO_NUMBER(p_source_20));
1498 RETURN l_output_value;
1499
1500 --
1501 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1502 trace
1503 (p_msg => 'END of AcctDerRule_9(invalid)'
1504 ,p_level => C_LEVEL_PROCEDURE
1505 ,p_module => l_log_module);
1506 END IF;
1507 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1508 x_value_type_code := null;
1509 l_output_value := null;
1510 xla_accounting_err_pkg.build_message
1511 (p_appli_s_name => 'XLA'
1512 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1513 ,p_token_1 => 'COMPONENT_NAME'
1514 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1515 l_component_type
1516 , l_component_code
1517 , l_component_type_code
1518 , l_component_appl_id
1519 , l_amb_context_code
1520 )
1521 ,p_token_2 => 'OWNER'
1522 ,p_value_2 => xla_lookups_pkg.get_meaning(
1523 'XLA_OWNER_TYPE'
1524 ,l_component_type_code
1525 )
1526 ,p_token_3 => 'PAD_NAME'
1527 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1528 ,p_token_4 => 'PAD_OWNER'
1529 ,p_value_4 => xla_lookups_pkg.get_meaning(
1530 'XLA_OWNER_TYPE'
1531 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1532 )
1533 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1534 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1535 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1536 ,p_ae_header_id => NULL
1537 );
1538 RETURN l_output_value;
1539 EXCEPTION
1540 WHEN xla_exceptions_pkg.application_exception THEN
1541 RAISE;
1542 WHEN OTHERS THEN
1543 xla_exceptions_pkg.raise_message
1544 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_9');
1545 END AcctDerRule_9;
1546 --
1547
1548 ---------------------------------------
1549 --
1550 -- PRIVATE FUNCTION
1551 -- AcctDerRule_10
1552 --
1553 ---------------------------------------
1554 FUNCTION AcctDerRule_10 (
1555 p_application_id IN NUMBER
1556 , p_ae_header_id IN NUMBER
1557 , p_side IN VARCHAR2
1558 --Inventory Organization Average Cost Variance Account
1559 , p_source_21 IN NUMBER
1560 , x_transaction_coa_id OUT NOCOPY NUMBER
1561 , x_accounting_coa_id OUT NOCOPY NUMBER
1562 , x_value_type_code OUT NOCOPY VARCHAR2
1563 )
1564 RETURN NUMBER
1565 IS
1566 l_component_type VARCHAR2(80) ;
1567 l_component_code VARCHAR2(30) ;
1568 l_component_type_code VARCHAR2(1) ;
1569 l_component_appl_id INTEGER ;
1570 l_amb_context_code VARCHAR2(30) ;
1571 l_log_module VARCHAR2(240) ;
1572 l_output_value NUMBER ;
1573 BEGIN
1574 IF g_log_enabled THEN
1575 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_10';
1576 END IF;
1577 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1578 trace
1579 (p_msg => 'BEGIN of AcctDerRule_10'
1580 ,p_level => C_LEVEL_PROCEDURE
1581 ,p_module => l_log_module);
1582 END IF;
1583 --
1584 l_component_type := 'AMB_ADR';
1585 l_component_code := 'PI_AVG_CST_VARIANCE';
1586 l_component_type_code := 'S';
1587 l_component_appl_id := 707;
1588 l_amb_context_code := 'DEFAULT';
1589 x_transaction_coa_id := null;
1590 x_accounting_coa_id := null;
1591 --
1592
1593 --
1594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1595 trace
1596 (p_msg => 'END of AcctDerRule_10'
1597 ,p_level => C_LEVEL_PROCEDURE
1598 ,p_module => l_log_module);
1599 END IF;
1600 x_value_type_code := 'S';
1601 l_output_value := TO_NUMBER(TO_NUMBER(p_source_21));
1602 RETURN l_output_value;
1603
1604 --
1605 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1606 trace
1607 (p_msg => 'END of AcctDerRule_10(invalid)'
1608 ,p_level => C_LEVEL_PROCEDURE
1609 ,p_module => l_log_module);
1610 END IF;
1611 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1612 x_value_type_code := null;
1613 l_output_value := null;
1614 xla_accounting_err_pkg.build_message
1615 (p_appli_s_name => 'XLA'
1616 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1617 ,p_token_1 => 'COMPONENT_NAME'
1618 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1619 l_component_type
1620 , l_component_code
1621 , l_component_type_code
1622 , l_component_appl_id
1623 , l_amb_context_code
1624 )
1625 ,p_token_2 => 'OWNER'
1626 ,p_value_2 => xla_lookups_pkg.get_meaning(
1627 'XLA_OWNER_TYPE'
1628 ,l_component_type_code
1629 )
1630 ,p_token_3 => 'PAD_NAME'
1631 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1632 ,p_token_4 => 'PAD_OWNER'
1633 ,p_value_4 => xla_lookups_pkg.get_meaning(
1634 'XLA_OWNER_TYPE'
1635 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1636 )
1637 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1638 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1639 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1640 ,p_ae_header_id => NULL
1641 );
1642 RETURN l_output_value;
1643 EXCEPTION
1644 WHEN xla_exceptions_pkg.application_exception THEN
1645 RAISE;
1646 WHEN OTHERS THEN
1647 xla_exceptions_pkg.raise_message
1648 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_10');
1649 END AcctDerRule_10;
1650 --
1651
1652 ---------------------------------------
1653 --
1654 -- PRIVATE FUNCTION
1655 -- AcctDerRule_11
1656 --
1657 ---------------------------------------
1658 FUNCTION AcctDerRule_11 (
1659 p_application_id IN NUMBER
1660 , p_ae_header_id IN NUMBER
1661 , p_side IN VARCHAR2
1662 --Product Line Accounting Category Bridging Account
1663 , p_source_22 IN NUMBER
1664 , x_transaction_coa_id OUT NOCOPY NUMBER
1665 , x_accounting_coa_id OUT NOCOPY NUMBER
1666 , x_value_type_code OUT NOCOPY VARCHAR2
1667 )
1668 RETURN NUMBER
1669 IS
1670 l_component_type VARCHAR2(80) ;
1671 l_component_code VARCHAR2(30) ;
1672 l_component_type_code VARCHAR2(1) ;
1673 l_component_appl_id INTEGER ;
1674 l_amb_context_code VARCHAR2(30) ;
1675 l_log_module VARCHAR2(240) ;
1676 l_output_value NUMBER ;
1677 BEGIN
1678 IF g_log_enabled THEN
1679 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_11';
1680 END IF;
1681 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1682 trace
1683 (p_msg => 'BEGIN of AcctDerRule_11'
1684 ,p_level => C_LEVEL_PROCEDURE
1685 ,p_module => l_log_module);
1686 END IF;
1687 --
1688 l_component_type := 'AMB_ADR';
1689 l_component_code := 'PI_BRIDGING_ACCOUNT';
1690 l_component_type_code := 'S';
1691 l_component_appl_id := 707;
1692 l_amb_context_code := 'DEFAULT';
1693 x_transaction_coa_id := null;
1694 x_accounting_coa_id := null;
1695 --
1696
1697 --
1698 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1699 trace
1700 (p_msg => 'END of AcctDerRule_11'
1701 ,p_level => C_LEVEL_PROCEDURE
1702 ,p_module => l_log_module);
1703 END IF;
1704 x_value_type_code := 'S';
1705 l_output_value := TO_NUMBER(TO_NUMBER(p_source_22));
1706 RETURN l_output_value;
1707
1708 --
1709 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1710 trace
1711 (p_msg => 'END of AcctDerRule_11(invalid)'
1712 ,p_level => C_LEVEL_PROCEDURE
1713 ,p_module => l_log_module);
1714 END IF;
1715 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1716 x_value_type_code := null;
1717 l_output_value := null;
1718 xla_accounting_err_pkg.build_message
1719 (p_appli_s_name => 'XLA'
1720 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1721 ,p_token_1 => 'COMPONENT_NAME'
1722 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1723 l_component_type
1724 , l_component_code
1725 , l_component_type_code
1726 , l_component_appl_id
1727 , l_amb_context_code
1728 )
1729 ,p_token_2 => 'OWNER'
1730 ,p_value_2 => xla_lookups_pkg.get_meaning(
1731 'XLA_OWNER_TYPE'
1732 ,l_component_type_code
1733 )
1734 ,p_token_3 => 'PAD_NAME'
1735 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1736 ,p_token_4 => 'PAD_OWNER'
1737 ,p_value_4 => xla_lookups_pkg.get_meaning(
1738 'XLA_OWNER_TYPE'
1739 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1740 )
1741 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1742 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1743 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1744 ,p_ae_header_id => NULL
1745 );
1746 RETURN l_output_value;
1747 EXCEPTION
1748 WHEN xla_exceptions_pkg.application_exception THEN
1749 RAISE;
1750 WHEN OTHERS THEN
1751 xla_exceptions_pkg.raise_message
1752 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_11');
1753 END AcctDerRule_11;
1754 --
1755
1756 ---------------------------------------
1757 --
1758 -- PRIVATE FUNCTION
1759 -- AcctDerRule_12
1760 --
1761 ---------------------------------------
1762 FUNCTION AcctDerRule_12 (
1763 p_application_id IN NUMBER
1764 , p_ae_header_id IN NUMBER
1765 , p_side IN VARCHAR2
1766 --Product Line Accounting Category Average Cost Variance Account
1767 , p_source_23 IN NUMBER
1768 , x_transaction_coa_id OUT NOCOPY NUMBER
1769 , x_accounting_coa_id OUT NOCOPY NUMBER
1770 , x_value_type_code OUT NOCOPY VARCHAR2
1771 )
1772 RETURN NUMBER
1773 IS
1774 l_component_type VARCHAR2(80) ;
1775 l_component_code VARCHAR2(30) ;
1776 l_component_type_code VARCHAR2(1) ;
1777 l_component_appl_id INTEGER ;
1778 l_amb_context_code VARCHAR2(30) ;
1779 l_log_module VARCHAR2(240) ;
1780 l_output_value NUMBER ;
1781 BEGIN
1782 IF g_log_enabled THEN
1783 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_12';
1784 END IF;
1785 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1786 trace
1787 (p_msg => 'BEGIN of AcctDerRule_12'
1788 ,p_level => C_LEVEL_PROCEDURE
1789 ,p_module => l_log_module);
1790 END IF;
1791 --
1792 l_component_type := 'AMB_ADR';
1793 l_component_code := 'PI_CATEGORY_ACV_ADR';
1794 l_component_type_code := 'S';
1795 l_component_appl_id := 707;
1796 l_amb_context_code := 'DEFAULT';
1797 x_transaction_coa_id := null;
1798 x_accounting_coa_id := null;
1799 --
1800
1801 --
1802 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1803 trace
1804 (p_msg => 'END of AcctDerRule_12'
1805 ,p_level => C_LEVEL_PROCEDURE
1806 ,p_module => l_log_module);
1807 END IF;
1808 x_value_type_code := 'S';
1809 l_output_value := TO_NUMBER(TO_NUMBER(p_source_23));
1810 RETURN l_output_value;
1811
1812 --
1813 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1814 trace
1815 (p_msg => 'END of AcctDerRule_12(invalid)'
1816 ,p_level => C_LEVEL_PROCEDURE
1817 ,p_module => l_log_module);
1818 END IF;
1819 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1820 x_value_type_code := null;
1821 l_output_value := null;
1822 xla_accounting_err_pkg.build_message
1823 (p_appli_s_name => 'XLA'
1824 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1825 ,p_token_1 => 'COMPONENT_NAME'
1826 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1827 l_component_type
1828 , l_component_code
1829 , l_component_type_code
1830 , l_component_appl_id
1831 , l_amb_context_code
1832 )
1833 ,p_token_2 => 'OWNER'
1834 ,p_value_2 => xla_lookups_pkg.get_meaning(
1835 'XLA_OWNER_TYPE'
1836 ,l_component_type_code
1837 )
1838 ,p_token_3 => 'PAD_NAME'
1839 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1840 ,p_token_4 => 'PAD_OWNER'
1841 ,p_value_4 => xla_lookups_pkg.get_meaning(
1842 'XLA_OWNER_TYPE'
1843 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1844 )
1845 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1846 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1847 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1848 ,p_ae_header_id => NULL
1849 );
1850 RETURN l_output_value;
1851 EXCEPTION
1852 WHEN xla_exceptions_pkg.application_exception THEN
1853 RAISE;
1854 WHEN OTHERS THEN
1855 xla_exceptions_pkg.raise_message
1856 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_12');
1857 END AcctDerRule_12;
1858 --
1859
1860 ---------------------------------------
1861 --
1862 -- PRIVATE FUNCTION
1863 -- AcctDerRule_13
1864 --
1865 ---------------------------------------
1866 FUNCTION AcctDerRule_13 (
1867 p_application_id IN NUMBER
1868 , p_ae_header_id IN NUMBER
1869 , p_side IN VARCHAR2
1870 --Product Line Accounting Category Expense Account
1871 , p_source_24 IN NUMBER
1872 , x_transaction_coa_id OUT NOCOPY NUMBER
1873 , x_accounting_coa_id OUT NOCOPY NUMBER
1874 , x_value_type_code OUT NOCOPY VARCHAR2
1875 )
1876 RETURN NUMBER
1877 IS
1878 l_component_type VARCHAR2(80) ;
1879 l_component_code VARCHAR2(30) ;
1880 l_component_type_code VARCHAR2(1) ;
1881 l_component_appl_id INTEGER ;
1882 l_amb_context_code VARCHAR2(30) ;
1883 l_log_module VARCHAR2(240) ;
1884 l_output_value NUMBER ;
1885 BEGIN
1886 IF g_log_enabled THEN
1887 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_13';
1888 END IF;
1889 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1890 trace
1891 (p_msg => 'BEGIN of AcctDerRule_13'
1892 ,p_level => C_LEVEL_PROCEDURE
1893 ,p_module => l_log_module);
1894 END IF;
1895 --
1896 l_component_type := 'AMB_ADR';
1897 l_component_code := 'PI_CATEGORY_EXPENSE';
1898 l_component_type_code := 'S';
1899 l_component_appl_id := 707;
1900 l_amb_context_code := 'DEFAULT';
1901 x_transaction_coa_id := null;
1902 x_accounting_coa_id := null;
1903 --
1904
1905 --
1906 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1907 trace
1908 (p_msg => 'END of AcctDerRule_13'
1909 ,p_level => C_LEVEL_PROCEDURE
1910 ,p_module => l_log_module);
1911 END IF;
1912 x_value_type_code := 'S';
1913 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
1914 RETURN l_output_value;
1915
1916 --
1917 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1918 trace
1919 (p_msg => 'END of AcctDerRule_13(invalid)'
1920 ,p_level => C_LEVEL_PROCEDURE
1921 ,p_module => l_log_module);
1922 END IF;
1923 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1924 x_value_type_code := null;
1925 l_output_value := null;
1926 xla_accounting_err_pkg.build_message
1927 (p_appli_s_name => 'XLA'
1928 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1929 ,p_token_1 => 'COMPONENT_NAME'
1930 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1931 l_component_type
1932 , l_component_code
1933 , l_component_type_code
1934 , l_component_appl_id
1935 , l_amb_context_code
1936 )
1937 ,p_token_2 => 'OWNER'
1938 ,p_value_2 => xla_lookups_pkg.get_meaning(
1939 'XLA_OWNER_TYPE'
1940 ,l_component_type_code
1941 )
1942 ,p_token_3 => 'PAD_NAME'
1943 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1944 ,p_token_4 => 'PAD_OWNER'
1945 ,p_value_4 => xla_lookups_pkg.get_meaning(
1946 'XLA_OWNER_TYPE'
1947 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1948 )
1949 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1950 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1951 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1952 ,p_ae_header_id => NULL
1953 );
1954 RETURN l_output_value;
1955 EXCEPTION
1956 WHEN xla_exceptions_pkg.application_exception THEN
1957 RAISE;
1958 WHEN OTHERS THEN
1959 xla_exceptions_pkg.raise_message
1960 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_13');
1961 END AcctDerRule_13;
1962 --
1963
1964 ---------------------------------------
1965 --
1966 -- PRIVATE FUNCTION
1967 -- AcctDerRule_14
1968 --
1969 ---------------------------------------
1970 FUNCTION AcctDerRule_14 (
1971 p_application_id IN NUMBER
1972 , p_ae_header_id IN NUMBER
1973 , p_side IN VARCHAR2
1974 --Product Line Accounting Category Expense Account
1975 , p_source_24 IN NUMBER
1976 --Transfer to Subinventory or Cost Group category expense account
1977 , p_source_25 IN NUMBER
1978 --Cost Group Identifier
1979 , p_source_26 IN NUMBER
1980 --INV Header Transfer Cost Group ID
1981 , p_source_27 IN NUMBER
1982 --INV Header Cost Group ID
1983 , p_source_28 IN NUMBER
1984 --Subinventory Name
1985 , p_source_29 IN VARCHAR2
1986 --INV Header Subinventory
1987 , p_source_30 IN VARCHAR2
1988 , x_transaction_coa_id OUT NOCOPY NUMBER
1989 , x_accounting_coa_id OUT NOCOPY NUMBER
1990 , x_value_type_code OUT NOCOPY VARCHAR2
1991 )
1992 RETURN NUMBER
1993 IS
1994 l_component_type VARCHAR2(80) ;
1995 l_component_code VARCHAR2(30) ;
1996 l_component_type_code VARCHAR2(1) ;
1997 l_component_appl_id INTEGER ;
1998 l_amb_context_code VARCHAR2(30) ;
1999 l_log_module VARCHAR2(240) ;
2000 l_output_value NUMBER ;
2001 BEGIN
2002 IF g_log_enabled THEN
2003 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_14';
2004 END IF;
2005 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2006 trace
2007 (p_msg => 'BEGIN of AcctDerRule_14'
2008 ,p_level => C_LEVEL_PROCEDURE
2009 ,p_module => l_log_module);
2010 END IF;
2011 --
2012 l_component_type := 'AMB_ADR';
2013 l_component_code := 'PI_CATEGORY_EXPENSE_ADR';
2014 l_component_type_code := 'S';
2015 l_component_appl_id := 707;
2016 l_amb_context_code := 'DEFAULT';
2017 x_transaction_coa_id := null;
2018 x_accounting_coa_id := null;
2019 --
2020
2021 IF p_source_26 IS NOT NULL AND
2022 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
2023 THEN
2024 --
2025 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2026 trace
2027 (p_msg => 'END of AcctDerRule_14'
2028 ,p_level => C_LEVEL_PROCEDURE
2029 ,p_module => l_log_module);
2030 END IF;
2031 x_value_type_code := 'S';
2032 l_output_value := TO_NUMBER(TO_NUMBER(p_source_25));
2033 RETURN l_output_value;
2034
2035 ELSIF p_source_26 IS NOT NULL AND
2036 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
2037 THEN
2038 --
2039 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2040 trace
2041 (p_msg => 'END of AcctDerRule_14'
2042 ,p_level => C_LEVEL_PROCEDURE
2043 ,p_module => l_log_module);
2044 END IF;
2045 x_value_type_code := 'S';
2046 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
2047 RETURN l_output_value;
2048
2049 ELSIF p_source_29 IS NOT NULL AND
2050 NVL(p_source_29,'
2051 ') = NVL(p_source_30,'
2052 ')
2053 THEN
2054 --
2055 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2056 trace
2057 (p_msg => 'END of AcctDerRule_14'
2058 ,p_level => C_LEVEL_PROCEDURE
2059 ,p_module => l_log_module);
2060 END IF;
2061 x_value_type_code := 'S';
2062 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
2063 RETURN l_output_value;
2064
2065 END IF;
2066
2067 --
2068 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2069 trace
2070 (p_msg => 'END of AcctDerRule_14'
2071 ,p_level => C_LEVEL_PROCEDURE
2072 ,p_module => l_log_module);
2073 END IF;
2074 x_value_type_code := 'S';
2075 l_output_value := TO_NUMBER(TO_NUMBER(p_source_25));
2076 RETURN l_output_value;
2077
2078 --
2079 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2080 trace
2081 (p_msg => 'END of AcctDerRule_14(invalid)'
2082 ,p_level => C_LEVEL_PROCEDURE
2083 ,p_module => l_log_module);
2084 END IF;
2085 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2086 x_value_type_code := null;
2087 l_output_value := null;
2088 xla_accounting_err_pkg.build_message
2089 (p_appli_s_name => 'XLA'
2090 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2091 ,p_token_1 => 'COMPONENT_NAME'
2092 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2093 l_component_type
2094 , l_component_code
2095 , l_component_type_code
2096 , l_component_appl_id
2097 , l_amb_context_code
2098 )
2099 ,p_token_2 => 'OWNER'
2100 ,p_value_2 => xla_lookups_pkg.get_meaning(
2101 'XLA_OWNER_TYPE'
2102 ,l_component_type_code
2103 )
2104 ,p_token_3 => 'PAD_NAME'
2105 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2106 ,p_token_4 => 'PAD_OWNER'
2107 ,p_value_4 => xla_lookups_pkg.get_meaning(
2108 'XLA_OWNER_TYPE'
2109 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2110 )
2111 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2112 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2113 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2114 ,p_ae_header_id => NULL
2115 );
2116 RETURN l_output_value;
2117 EXCEPTION
2118 WHEN xla_exceptions_pkg.application_exception THEN
2119 RAISE;
2120 WHEN OTHERS THEN
2121 xla_exceptions_pkg.raise_message
2122 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_14');
2123 END AcctDerRule_14;
2124 --
2125
2126 ---------------------------------------
2127 --
2128 -- PRIVATE FUNCTION
2129 -- AcctDerRule_15
2130 --
2131 ---------------------------------------
2132 FUNCTION AcctDerRule_15 (
2133 p_application_id IN NUMBER
2134 , p_ae_header_id IN NUMBER
2135 , p_side IN VARCHAR2
2136 --Product Line Accounting Category Expense Account
2137 , p_source_24 IN NUMBER
2138 --Transfer to Subinventory or Cost Group category expense account
2139 , p_source_25 IN NUMBER
2140 --Cost Group Identifier
2141 , p_source_26 IN NUMBER
2142 --INV Header Transfer Cost Group ID
2143 , p_source_27 IN NUMBER
2144 --INV Header Cost Group ID
2145 , p_source_28 IN NUMBER
2146 --Subinventory Name
2147 , p_source_29 IN VARCHAR2
2148 --INV Header Transfer Subinventory
2149 , p_source_31 IN VARCHAR2
2150 , x_transaction_coa_id OUT NOCOPY NUMBER
2151 , x_accounting_coa_id OUT NOCOPY NUMBER
2152 , x_value_type_code OUT NOCOPY VARCHAR2
2153 )
2154 RETURN NUMBER
2155 IS
2156 l_component_type VARCHAR2(80) ;
2157 l_component_code VARCHAR2(30) ;
2158 l_component_type_code VARCHAR2(1) ;
2159 l_component_appl_id INTEGER ;
2160 l_amb_context_code VARCHAR2(30) ;
2161 l_log_module VARCHAR2(240) ;
2162 l_output_value NUMBER ;
2163 BEGIN
2164 IF g_log_enabled THEN
2165 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_15';
2166 END IF;
2167 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2168 trace
2169 (p_msg => 'BEGIN of AcctDerRule_15'
2170 ,p_level => C_LEVEL_PROCEDURE
2171 ,p_module => l_log_module);
2172 END IF;
2173 --
2174 l_component_type := 'AMB_ADR';
2175 l_component_code := 'PI_CATEGORY_OFFSET_ADR';
2176 l_component_type_code := 'S';
2177 l_component_appl_id := 707;
2178 l_amb_context_code := 'DEFAULT';
2179 x_transaction_coa_id := null;
2180 x_accounting_coa_id := null;
2181 --
2182
2183 IF p_source_26 IS NOT NULL AND
2184 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
2185 THEN
2186 --
2187 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2188 trace
2189 (p_msg => 'END of AcctDerRule_15'
2190 ,p_level => C_LEVEL_PROCEDURE
2191 ,p_module => l_log_module);
2192 END IF;
2193 x_value_type_code := 'S';
2194 l_output_value := TO_NUMBER(TO_NUMBER(p_source_25));
2195 RETURN l_output_value;
2196
2197 ELSIF p_source_26 IS NOT NULL AND
2198 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
2199 THEN
2200 --
2201 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2202 trace
2203 (p_msg => 'END of AcctDerRule_15'
2204 ,p_level => C_LEVEL_PROCEDURE
2205 ,p_module => l_log_module);
2206 END IF;
2207 x_value_type_code := 'S';
2208 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
2209 RETURN l_output_value;
2210
2211 ELSIF p_source_29 IS NOT NULL AND
2212 NVL(p_source_29,'
2213 ') = NVL(p_source_31,'
2214 ')
2215 THEN
2216 --
2217 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2218 trace
2219 (p_msg => 'END of AcctDerRule_15'
2220 ,p_level => C_LEVEL_PROCEDURE
2221 ,p_module => l_log_module);
2222 END IF;
2223 x_value_type_code := 'S';
2224 l_output_value := TO_NUMBER(TO_NUMBER(p_source_25));
2225 RETURN l_output_value;
2226
2227 END IF;
2228
2229 --
2230 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2231 trace
2232 (p_msg => 'END of AcctDerRule_15'
2233 ,p_level => C_LEVEL_PROCEDURE
2234 ,p_module => l_log_module);
2235 END IF;
2236 x_value_type_code := 'S';
2237 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
2238 RETURN l_output_value;
2239
2240 --
2241 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2242 trace
2243 (p_msg => 'END of AcctDerRule_15(invalid)'
2244 ,p_level => C_LEVEL_PROCEDURE
2245 ,p_module => l_log_module);
2246 END IF;
2247 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2248 x_value_type_code := null;
2249 l_output_value := null;
2250 xla_accounting_err_pkg.build_message
2251 (p_appli_s_name => 'XLA'
2252 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2253 ,p_token_1 => 'COMPONENT_NAME'
2254 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2255 l_component_type
2256 , l_component_code
2257 , l_component_type_code
2258 , l_component_appl_id
2259 , l_amb_context_code
2260 )
2261 ,p_token_2 => 'OWNER'
2262 ,p_value_2 => xla_lookups_pkg.get_meaning(
2263 'XLA_OWNER_TYPE'
2264 ,l_component_type_code
2265 )
2266 ,p_token_3 => 'PAD_NAME'
2267 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2268 ,p_token_4 => 'PAD_OWNER'
2269 ,p_value_4 => xla_lookups_pkg.get_meaning(
2270 'XLA_OWNER_TYPE'
2271 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2272 )
2273 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2274 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2275 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2276 ,p_ae_header_id => NULL
2277 );
2278 RETURN l_output_value;
2279 EXCEPTION
2280 WHEN xla_exceptions_pkg.application_exception THEN
2281 RAISE;
2282 WHEN OTHERS THEN
2283 xla_exceptions_pkg.raise_message
2284 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_15');
2285 END AcctDerRule_15;
2286 --
2287
2288 ---------------------------------------
2289 --
2290 -- PRIVATE FUNCTION
2291 -- AcctDerRule_16
2292 --
2293 ---------------------------------------
2294 FUNCTION AcctDerRule_16 (
2295 p_application_id IN NUMBER
2296 , p_ae_header_id IN NUMBER
2297 , p_side IN VARCHAR2
2298 --Transaction Distribution Account
2299 , p_source_20 IN NUMBER
2300 , x_transaction_coa_id OUT NOCOPY NUMBER
2301 , x_accounting_coa_id OUT NOCOPY NUMBER
2302 , x_value_type_code OUT NOCOPY VARCHAR2
2303 )
2304 RETURN NUMBER
2305 IS
2306 l_component_type VARCHAR2(80) ;
2307 l_component_code VARCHAR2(30) ;
2308 l_component_type_code VARCHAR2(1) ;
2309 l_component_appl_id INTEGER ;
2310 l_amb_context_code VARCHAR2(30) ;
2311 l_log_module VARCHAR2(240) ;
2312 l_output_value NUMBER ;
2313 BEGIN
2314 IF g_log_enabled THEN
2315 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_16';
2316 END IF;
2317 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2318 trace
2319 (p_msg => 'BEGIN of AcctDerRule_16'
2320 ,p_level => C_LEVEL_PROCEDURE
2321 ,p_module => l_log_module);
2322 END IF;
2323 --
2324 l_component_type := 'AMB_ADR';
2325 l_component_code := 'PI_DISTRIBUTION';
2326 l_component_type_code := 'S';
2327 l_component_appl_id := 707;
2328 l_amb_context_code := 'DEFAULT';
2329 x_transaction_coa_id := null;
2330 x_accounting_coa_id := null;
2331 --
2332
2333 --
2334 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2335 trace
2336 (p_msg => 'END of AcctDerRule_16'
2337 ,p_level => C_LEVEL_PROCEDURE
2338 ,p_module => l_log_module);
2339 END IF;
2340 x_value_type_code := 'S';
2341 l_output_value := TO_NUMBER(TO_NUMBER(p_source_20));
2342 RETURN l_output_value;
2343
2344 --
2345 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2346 trace
2347 (p_msg => 'END of AcctDerRule_16(invalid)'
2348 ,p_level => C_LEVEL_PROCEDURE
2349 ,p_module => l_log_module);
2350 END IF;
2351 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2352 x_value_type_code := null;
2353 l_output_value := null;
2354 xla_accounting_err_pkg.build_message
2355 (p_appli_s_name => 'XLA'
2356 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2357 ,p_token_1 => 'COMPONENT_NAME'
2358 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2359 l_component_type
2360 , l_component_code
2361 , l_component_type_code
2362 , l_component_appl_id
2363 , l_amb_context_code
2364 )
2365 ,p_token_2 => 'OWNER'
2366 ,p_value_2 => xla_lookups_pkg.get_meaning(
2367 'XLA_OWNER_TYPE'
2368 ,l_component_type_code
2369 )
2370 ,p_token_3 => 'PAD_NAME'
2371 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2372 ,p_token_4 => 'PAD_OWNER'
2373 ,p_value_4 => xla_lookups_pkg.get_meaning(
2374 'XLA_OWNER_TYPE'
2375 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2376 )
2377 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2378 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2379 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2380 ,p_ae_header_id => NULL
2381 );
2382 RETURN l_output_value;
2383 EXCEPTION
2384 WHEN xla_exceptions_pkg.application_exception THEN
2385 RAISE;
2386 WHEN OTHERS THEN
2387 xla_exceptions_pkg.raise_message
2388 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_16');
2389 END AcctDerRule_16;
2390 --
2391
2392 ---------------------------------------
2393 --
2394 -- PRIVATE FUNCTION
2395 -- AcctDerRule_17
2396 --
2397 ---------------------------------------
2398 FUNCTION AcctDerRule_17 (
2399 p_application_id IN NUMBER
2400 , p_ae_header_id IN NUMBER
2401 , p_side IN VARCHAR2
2402 --Transaction Transportation Distribution Account
2403 , p_source_32 IN NUMBER
2404 , x_transaction_coa_id OUT NOCOPY NUMBER
2405 , x_accounting_coa_id OUT NOCOPY NUMBER
2406 , x_value_type_code OUT NOCOPY VARCHAR2
2407 )
2408 RETURN NUMBER
2409 IS
2410 l_component_type VARCHAR2(80) ;
2411 l_component_code VARCHAR2(30) ;
2412 l_component_type_code VARCHAR2(1) ;
2413 l_component_appl_id INTEGER ;
2414 l_amb_context_code VARCHAR2(30) ;
2415 l_log_module VARCHAR2(240) ;
2416 l_output_value NUMBER ;
2417 BEGIN
2418 IF g_log_enabled THEN
2419 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_17';
2420 END IF;
2421 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2422 trace
2423 (p_msg => 'BEGIN of AcctDerRule_17'
2424 ,p_level => C_LEVEL_PROCEDURE
2425 ,p_module => l_log_module);
2426 END IF;
2427 --
2428 l_component_type := 'AMB_ADR';
2429 l_component_code := 'PI_FREIGHT';
2430 l_component_type_code := 'S';
2431 l_component_appl_id := 707;
2432 l_amb_context_code := 'DEFAULT';
2433 x_transaction_coa_id := null;
2434 x_accounting_coa_id := null;
2435 --
2436
2437 --
2438 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2439 trace
2440 (p_msg => 'END of AcctDerRule_17'
2441 ,p_level => C_LEVEL_PROCEDURE
2442 ,p_module => l_log_module);
2443 END IF;
2444 x_value_type_code := 'S';
2445 l_output_value := TO_NUMBER(TO_NUMBER(p_source_32));
2446 RETURN l_output_value;
2447
2448 --
2449 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2450 trace
2451 (p_msg => 'END of AcctDerRule_17(invalid)'
2452 ,p_level => C_LEVEL_PROCEDURE
2453 ,p_module => l_log_module);
2454 END IF;
2455 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2456 x_value_type_code := null;
2457 l_output_value := null;
2458 xla_accounting_err_pkg.build_message
2459 (p_appli_s_name => 'XLA'
2460 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2461 ,p_token_1 => 'COMPONENT_NAME'
2462 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2463 l_component_type
2464 , l_component_code
2465 , l_component_type_code
2466 , l_component_appl_id
2467 , l_amb_context_code
2468 )
2469 ,p_token_2 => 'OWNER'
2470 ,p_value_2 => xla_lookups_pkg.get_meaning(
2471 'XLA_OWNER_TYPE'
2472 ,l_component_type_code
2473 )
2474 ,p_token_3 => 'PAD_NAME'
2475 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2476 ,p_token_4 => 'PAD_OWNER'
2477 ,p_value_4 => xla_lookups_pkg.get_meaning(
2478 'XLA_OWNER_TYPE'
2479 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2480 )
2481 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2482 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2483 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2484 ,p_ae_header_id => NULL
2485 );
2486 RETURN l_output_value;
2487 EXCEPTION
2488 WHEN xla_exceptions_pkg.application_exception THEN
2489 RAISE;
2490 WHEN OTHERS THEN
2491 xla_exceptions_pkg.raise_message
2492 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_17');
2493 END AcctDerRule_17;
2494 --
2495
2496 ---------------------------------------
2497 --
2498 -- PRIVATE FUNCTION
2499 -- AcctDerRule_18
2500 --
2501 ---------------------------------------
2502 FUNCTION AcctDerRule_18 (
2503 p_application_id IN NUMBER
2504 , p_ae_header_id IN NUMBER
2505 , p_side IN VARCHAR2
2506 --Interorg Revenue Account
2507 , p_source_33 IN NUMBER
2508 , x_transaction_coa_id OUT NOCOPY NUMBER
2509 , x_accounting_coa_id OUT NOCOPY NUMBER
2510 , x_value_type_code OUT NOCOPY VARCHAR2
2511 )
2512 RETURN NUMBER
2513 IS
2514 l_component_type VARCHAR2(80) ;
2515 l_component_code VARCHAR2(30) ;
2516 l_component_type_code VARCHAR2(1) ;
2517 l_component_appl_id INTEGER ;
2518 l_amb_context_code VARCHAR2(30) ;
2519 l_log_module VARCHAR2(240) ;
2520 l_output_value NUMBER ;
2521 BEGIN
2522 IF g_log_enabled THEN
2523 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_18';
2524 END IF;
2525 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2526 trace
2527 (p_msg => 'BEGIN of AcctDerRule_18'
2528 ,p_level => C_LEVEL_PROCEDURE
2529 ,p_module => l_log_module);
2530 END IF;
2531 --
2532 l_component_type := 'AMB_ADR';
2533 l_component_code := 'PI_INTEROG_REVENUE';
2534 l_component_type_code := 'S';
2535 l_component_appl_id := 707;
2536 l_amb_context_code := 'DEFAULT';
2537 x_transaction_coa_id := null;
2538 x_accounting_coa_id := null;
2539 --
2540
2541 --
2542 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2543 trace
2544 (p_msg => 'END of AcctDerRule_18'
2545 ,p_level => C_LEVEL_PROCEDURE
2546 ,p_module => l_log_module);
2547 END IF;
2548 x_value_type_code := 'S';
2549 l_output_value := TO_NUMBER(TO_NUMBER(p_source_33));
2550 RETURN l_output_value;
2551
2552 --
2553 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2554 trace
2555 (p_msg => 'END of AcctDerRule_18(invalid)'
2556 ,p_level => C_LEVEL_PROCEDURE
2557 ,p_module => l_log_module);
2558 END IF;
2559 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2560 x_value_type_code := null;
2561 l_output_value := null;
2562 xla_accounting_err_pkg.build_message
2563 (p_appli_s_name => 'XLA'
2564 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2565 ,p_token_1 => 'COMPONENT_NAME'
2566 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2567 l_component_type
2568 , l_component_code
2569 , l_component_type_code
2570 , l_component_appl_id
2571 , l_amb_context_code
2572 )
2573 ,p_token_2 => 'OWNER'
2574 ,p_value_2 => xla_lookups_pkg.get_meaning(
2575 'XLA_OWNER_TYPE'
2576 ,l_component_type_code
2577 )
2578 ,p_token_3 => 'PAD_NAME'
2579 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2580 ,p_token_4 => 'PAD_OWNER'
2581 ,p_value_4 => xla_lookups_pkg.get_meaning(
2582 'XLA_OWNER_TYPE'
2583 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2584 )
2585 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2586 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2587 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2588 ,p_ae_header_id => NULL
2589 );
2590 RETURN l_output_value;
2591 EXCEPTION
2592 WHEN xla_exceptions_pkg.application_exception THEN
2593 RAISE;
2594 WHEN OTHERS THEN
2595 xla_exceptions_pkg.raise_message
2596 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_18');
2597 END AcctDerRule_18;
2598 --
2599
2600 ---------------------------------------
2601 --
2602 -- PRIVATE FUNCTION
2603 -- AcctDerRule_19
2604 --
2605 ---------------------------------------
2606 FUNCTION AcctDerRule_19 (
2607 p_application_id IN NUMBER
2608 , p_ae_header_id IN NUMBER
2609 , p_side IN VARCHAR2
2610 --Interorg Expense Account
2611 , p_source_34 IN NUMBER
2612 , x_transaction_coa_id OUT NOCOPY NUMBER
2613 , x_accounting_coa_id OUT NOCOPY NUMBER
2614 , x_value_type_code OUT NOCOPY VARCHAR2
2615 )
2616 RETURN NUMBER
2617 IS
2618 l_component_type VARCHAR2(80) ;
2619 l_component_code VARCHAR2(30) ;
2620 l_component_type_code VARCHAR2(1) ;
2621 l_component_appl_id INTEGER ;
2622 l_amb_context_code VARCHAR2(30) ;
2623 l_log_module VARCHAR2(240) ;
2624 l_output_value NUMBER ;
2625 BEGIN
2626 IF g_log_enabled THEN
2627 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_19';
2628 END IF;
2629 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2630 trace
2631 (p_msg => 'BEGIN of AcctDerRule_19'
2632 ,p_level => C_LEVEL_PROCEDURE
2633 ,p_module => l_log_module);
2634 END IF;
2635 --
2636 l_component_type := 'AMB_ADR';
2637 l_component_code := 'PI_INTERORG_EXPENSE';
2638 l_component_type_code := 'S';
2639 l_component_appl_id := 707;
2640 l_amb_context_code := 'DEFAULT';
2641 x_transaction_coa_id := null;
2642 x_accounting_coa_id := null;
2643 --
2644
2645 --
2646 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2647 trace
2648 (p_msg => 'END of AcctDerRule_19'
2649 ,p_level => C_LEVEL_PROCEDURE
2650 ,p_module => l_log_module);
2651 END IF;
2652 x_value_type_code := 'S';
2653 l_output_value := TO_NUMBER(TO_NUMBER(p_source_34));
2654 RETURN l_output_value;
2655
2656 --
2657 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2658 trace
2659 (p_msg => 'END of AcctDerRule_19(invalid)'
2660 ,p_level => C_LEVEL_PROCEDURE
2661 ,p_module => l_log_module);
2662 END IF;
2663 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2664 x_value_type_code := null;
2665 l_output_value := null;
2666 xla_accounting_err_pkg.build_message
2667 (p_appli_s_name => 'XLA'
2668 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2669 ,p_token_1 => 'COMPONENT_NAME'
2670 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2671 l_component_type
2672 , l_component_code
2673 , l_component_type_code
2674 , l_component_appl_id
2675 , l_amb_context_code
2676 )
2677 ,p_token_2 => 'OWNER'
2678 ,p_value_2 => xla_lookups_pkg.get_meaning(
2679 'XLA_OWNER_TYPE'
2680 ,l_component_type_code
2681 )
2682 ,p_token_3 => 'PAD_NAME'
2683 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2684 ,p_token_4 => 'PAD_OWNER'
2685 ,p_value_4 => xla_lookups_pkg.get_meaning(
2686 'XLA_OWNER_TYPE'
2687 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2688 )
2689 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2690 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2691 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2692 ,p_ae_header_id => NULL
2693 );
2694 RETURN l_output_value;
2695 EXCEPTION
2696 WHEN xla_exceptions_pkg.application_exception THEN
2697 RAISE;
2698 WHEN OTHERS THEN
2699 xla_exceptions_pkg.raise_message
2700 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_19');
2701 END AcctDerRule_19;
2702 --
2703
2704 ---------------------------------------
2705 --
2706 -- PRIVATE FUNCTION
2707 -- AcctDerRule_20
2708 --
2709 ---------------------------------------
2710 FUNCTION AcctDerRule_20 (
2711 p_application_id IN NUMBER
2712 , p_ae_header_id IN NUMBER
2713 , p_side IN VARCHAR2
2714 --Interorg Payables Account
2715 , p_source_35 IN NUMBER
2716 , x_transaction_coa_id OUT NOCOPY NUMBER
2717 , x_accounting_coa_id OUT NOCOPY NUMBER
2718 , x_value_type_code OUT NOCOPY VARCHAR2
2719 )
2720 RETURN NUMBER
2721 IS
2722 l_component_type VARCHAR2(80) ;
2723 l_component_code VARCHAR2(30) ;
2724 l_component_type_code VARCHAR2(1) ;
2725 l_component_appl_id INTEGER ;
2726 l_amb_context_code VARCHAR2(30) ;
2727 l_log_module VARCHAR2(240) ;
2728 l_output_value NUMBER ;
2729 BEGIN
2730 IF g_log_enabled THEN
2731 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_20';
2732 END IF;
2733 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2734 trace
2735 (p_msg => 'BEGIN of AcctDerRule_20'
2736 ,p_level => C_LEVEL_PROCEDURE
2737 ,p_module => l_log_module);
2738 END IF;
2739 --
2740 l_component_type := 'AMB_ADR';
2741 l_component_code := 'PI_INTERORG_PAYABLES';
2742 l_component_type_code := 'S';
2743 l_component_appl_id := 707;
2744 l_amb_context_code := 'DEFAULT';
2745 x_transaction_coa_id := null;
2746 x_accounting_coa_id := null;
2747 --
2748
2749 --
2750 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2751 trace
2752 (p_msg => 'END of AcctDerRule_20'
2753 ,p_level => C_LEVEL_PROCEDURE
2754 ,p_module => l_log_module);
2755 END IF;
2756 x_value_type_code := 'S';
2757 l_output_value := TO_NUMBER(TO_NUMBER(p_source_35));
2758 RETURN l_output_value;
2759
2760 --
2761 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2762 trace
2763 (p_msg => 'END of AcctDerRule_20(invalid)'
2764 ,p_level => C_LEVEL_PROCEDURE
2765 ,p_module => l_log_module);
2766 END IF;
2767 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2768 x_value_type_code := null;
2769 l_output_value := null;
2770 xla_accounting_err_pkg.build_message
2771 (p_appli_s_name => 'XLA'
2772 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2773 ,p_token_1 => 'COMPONENT_NAME'
2774 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2775 l_component_type
2776 , l_component_code
2777 , l_component_type_code
2778 , l_component_appl_id
2779 , l_amb_context_code
2780 )
2781 ,p_token_2 => 'OWNER'
2782 ,p_value_2 => xla_lookups_pkg.get_meaning(
2783 'XLA_OWNER_TYPE'
2784 ,l_component_type_code
2785 )
2786 ,p_token_3 => 'PAD_NAME'
2787 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2788 ,p_token_4 => 'PAD_OWNER'
2789 ,p_value_4 => xla_lookups_pkg.get_meaning(
2790 'XLA_OWNER_TYPE'
2791 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2792 )
2793 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2794 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2795 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2796 ,p_ae_header_id => NULL
2797 );
2798 RETURN l_output_value;
2799 EXCEPTION
2800 WHEN xla_exceptions_pkg.application_exception THEN
2801 RAISE;
2802 WHEN OTHERS THEN
2803 xla_exceptions_pkg.raise_message
2804 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_20');
2805 END AcctDerRule_20;
2806 --
2807
2808 ---------------------------------------
2809 --
2810 -- PRIVATE FUNCTION
2811 -- AcctDerRule_21
2812 --
2813 ---------------------------------------
2814 FUNCTION AcctDerRule_21 (
2815 p_application_id IN NUMBER
2816 , p_ae_header_id IN NUMBER
2817 , p_side IN VARCHAR2
2818 --Interorg Price Variance Account
2819 , p_source_36 IN NUMBER
2820 , x_transaction_coa_id OUT NOCOPY NUMBER
2821 , x_accounting_coa_id OUT NOCOPY NUMBER
2822 , x_value_type_code OUT NOCOPY VARCHAR2
2823 )
2824 RETURN NUMBER
2825 IS
2826 l_component_type VARCHAR2(80) ;
2827 l_component_code VARCHAR2(30) ;
2828 l_component_type_code VARCHAR2(1) ;
2829 l_component_appl_id INTEGER ;
2830 l_amb_context_code VARCHAR2(30) ;
2831 l_log_module VARCHAR2(240) ;
2832 l_output_value NUMBER ;
2833 BEGIN
2834 IF g_log_enabled THEN
2835 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_21';
2836 END IF;
2837 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2838 trace
2839 (p_msg => 'BEGIN of AcctDerRule_21'
2840 ,p_level => C_LEVEL_PROCEDURE
2841 ,p_module => l_log_module);
2842 END IF;
2843 --
2844 l_component_type := 'AMB_ADR';
2845 l_component_code := 'PI_INTERORG_PRICE_VARIANCE';
2846 l_component_type_code := 'S';
2847 l_component_appl_id := 707;
2848 l_amb_context_code := 'DEFAULT';
2849 x_transaction_coa_id := null;
2850 x_accounting_coa_id := null;
2851 --
2852
2853 --
2854 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2855 trace
2856 (p_msg => 'END of AcctDerRule_21'
2857 ,p_level => C_LEVEL_PROCEDURE
2858 ,p_module => l_log_module);
2859 END IF;
2860 x_value_type_code := 'S';
2861 l_output_value := TO_NUMBER(TO_NUMBER(p_source_36));
2862 RETURN l_output_value;
2863
2864 --
2865 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2866 trace
2867 (p_msg => 'END of AcctDerRule_21(invalid)'
2868 ,p_level => C_LEVEL_PROCEDURE
2869 ,p_module => l_log_module);
2870 END IF;
2871 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2872 x_value_type_code := null;
2873 l_output_value := null;
2874 xla_accounting_err_pkg.build_message
2875 (p_appli_s_name => 'XLA'
2876 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2877 ,p_token_1 => 'COMPONENT_NAME'
2878 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2879 l_component_type
2880 , l_component_code
2881 , l_component_type_code
2882 , l_component_appl_id
2883 , l_amb_context_code
2884 )
2885 ,p_token_2 => 'OWNER'
2886 ,p_value_2 => xla_lookups_pkg.get_meaning(
2887 'XLA_OWNER_TYPE'
2888 ,l_component_type_code
2889 )
2890 ,p_token_3 => 'PAD_NAME'
2891 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2892 ,p_token_4 => 'PAD_OWNER'
2893 ,p_value_4 => xla_lookups_pkg.get_meaning(
2894 'XLA_OWNER_TYPE'
2895 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2896 )
2897 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2898 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2899 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2900 ,p_ae_header_id => NULL
2901 );
2902 RETURN l_output_value;
2903 EXCEPTION
2904 WHEN xla_exceptions_pkg.application_exception THEN
2905 RAISE;
2906 WHEN OTHERS THEN
2907 xla_exceptions_pkg.raise_message
2908 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_21');
2909 END AcctDerRule_21;
2910 --
2911
2912 ---------------------------------------
2913 --
2914 -- PRIVATE FUNCTION
2915 -- AcctDerRule_22
2916 --
2917 ---------------------------------------
2918 FUNCTION AcctDerRule_22 (
2919 p_application_id IN NUMBER
2920 , p_ae_header_id IN NUMBER
2921 , p_side IN VARCHAR2
2922 --Profit in Inventory Account
2923 , p_source_37 IN NUMBER
2924 , x_transaction_coa_id OUT NOCOPY NUMBER
2925 , x_accounting_coa_id OUT NOCOPY NUMBER
2926 , x_value_type_code OUT NOCOPY VARCHAR2
2927 )
2928 RETURN NUMBER
2929 IS
2930 l_component_type VARCHAR2(80) ;
2931 l_component_code VARCHAR2(30) ;
2932 l_component_type_code VARCHAR2(1) ;
2933 l_component_appl_id INTEGER ;
2934 l_amb_context_code VARCHAR2(30) ;
2935 l_log_module VARCHAR2(240) ;
2936 l_output_value NUMBER ;
2937 BEGIN
2938 IF g_log_enabled THEN
2939 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_22';
2940 END IF;
2941 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2942 trace
2943 (p_msg => 'BEGIN of AcctDerRule_22'
2944 ,p_level => C_LEVEL_PROCEDURE
2945 ,p_module => l_log_module);
2946 END IF;
2947 --
2948 l_component_type := 'AMB_ADR';
2949 l_component_code := 'PI_INTERORG_PROFIT';
2950 l_component_type_code := 'S';
2951 l_component_appl_id := 707;
2952 l_amb_context_code := 'DEFAULT';
2953 x_transaction_coa_id := null;
2954 x_accounting_coa_id := null;
2955 --
2956
2957 --
2958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2959 trace
2960 (p_msg => 'END of AcctDerRule_22'
2961 ,p_level => C_LEVEL_PROCEDURE
2962 ,p_module => l_log_module);
2963 END IF;
2964 x_value_type_code := 'S';
2965 l_output_value := TO_NUMBER(TO_NUMBER(p_source_37));
2966 RETURN l_output_value;
2967
2968 --
2969 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2970 trace
2971 (p_msg => 'END of AcctDerRule_22(invalid)'
2972 ,p_level => C_LEVEL_PROCEDURE
2973 ,p_module => l_log_module);
2974 END IF;
2975 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2976 x_value_type_code := null;
2977 l_output_value := null;
2978 xla_accounting_err_pkg.build_message
2979 (p_appli_s_name => 'XLA'
2980 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2981 ,p_token_1 => 'COMPONENT_NAME'
2982 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2983 l_component_type
2984 , l_component_code
2985 , l_component_type_code
2986 , l_component_appl_id
2987 , l_amb_context_code
2988 )
2989 ,p_token_2 => 'OWNER'
2990 ,p_value_2 => xla_lookups_pkg.get_meaning(
2991 'XLA_OWNER_TYPE'
2992 ,l_component_type_code
2993 )
2994 ,p_token_3 => 'PAD_NAME'
2995 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2996 ,p_token_4 => 'PAD_OWNER'
2997 ,p_value_4 => xla_lookups_pkg.get_meaning(
2998 'XLA_OWNER_TYPE'
2999 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3000 )
3001 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3002 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3003 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3004 ,p_ae_header_id => NULL
3005 );
3006 RETURN l_output_value;
3007 EXCEPTION
3008 WHEN xla_exceptions_pkg.application_exception THEN
3009 RAISE;
3010 WHEN OTHERS THEN
3011 xla_exceptions_pkg.raise_message
3012 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_22');
3013 END AcctDerRule_22;
3014 --
3015
3016 ---------------------------------------
3017 --
3018 -- PRIVATE FUNCTION
3019 -- AcctDerRule_23
3020 --
3021 ---------------------------------------
3022 FUNCTION AcctDerRule_23 (
3023 p_application_id IN NUMBER
3024 , p_ae_header_id IN NUMBER
3025 , p_side IN VARCHAR2
3026 --Product Line Accounting Category Expense Account
3027 , p_source_24 IN NUMBER
3028 --Inventory Organization Expense Account
3029 , p_source_38 IN NUMBER
3030 --Primary Cost Method
3031 , p_source_39 IN NUMBER
3032 , p_source_39_meaning IN VARCHAR2
3033 , x_transaction_coa_id OUT NOCOPY NUMBER
3034 , x_accounting_coa_id OUT NOCOPY NUMBER
3035 , x_value_type_code OUT NOCOPY VARCHAR2
3036 )
3037 RETURN NUMBER
3038 IS
3039 l_component_type VARCHAR2(80) ;
3040 l_component_code VARCHAR2(30) ;
3041 l_component_type_code VARCHAR2(1) ;
3042 l_component_appl_id INTEGER ;
3043 l_amb_context_code VARCHAR2(30) ;
3044 l_log_module VARCHAR2(240) ;
3045 l_output_value NUMBER ;
3046 BEGIN
3047 IF g_log_enabled THEN
3048 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_23';
3049 END IF;
3050 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3051 trace
3052 (p_msg => 'BEGIN of AcctDerRule_23'
3053 ,p_level => C_LEVEL_PROCEDURE
3054 ,p_module => l_log_module);
3055 END IF;
3056 --
3057 l_component_type := 'AMB_ADR';
3058 l_component_code := 'PI_INTERORG_SHIP_EXPENSE';
3059 l_component_type_code := 'S';
3060 l_component_appl_id := 707;
3061 l_amb_context_code := 'DEFAULT';
3062 x_transaction_coa_id := null;
3063 x_accounting_coa_id := null;
3064 --
3065
3066 IF NVL(p_source_39,9E125) = 1
3067 THEN
3068 --
3069 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3070 trace
3071 (p_msg => 'END of AcctDerRule_23'
3072 ,p_level => C_LEVEL_PROCEDURE
3073 ,p_module => l_log_module);
3074 END IF;
3075 x_value_type_code := 'S';
3076 l_output_value := TO_NUMBER(TO_NUMBER(p_source_38));
3077 RETURN l_output_value;
3078
3079 ELSIF NVL(p_source_39,9E125) <> 1
3080 THEN
3081 --
3082 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3083 trace
3084 (p_msg => 'END of AcctDerRule_23'
3085 ,p_level => C_LEVEL_PROCEDURE
3086 ,p_module => l_log_module);
3087 END IF;
3088 x_value_type_code := 'S';
3089 l_output_value := TO_NUMBER(TO_NUMBER(p_source_24));
3090 RETURN l_output_value;
3091
3092 END IF;
3093 --
3094 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3095 trace
3096 (p_msg => 'END of AcctDerRule_23(invalid)'
3097 ,p_level => C_LEVEL_PROCEDURE
3098 ,p_module => l_log_module);
3099 END IF;
3100 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3101 x_value_type_code := null;
3102 l_output_value := null;
3103 xla_accounting_err_pkg.build_message
3104 (p_appli_s_name => 'XLA'
3105 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3106 ,p_token_1 => 'COMPONENT_NAME'
3107 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3108 l_component_type
3109 , l_component_code
3110 , l_component_type_code
3111 , l_component_appl_id
3112 , l_amb_context_code
3113 )
3114 ,p_token_2 => 'OWNER'
3115 ,p_value_2 => xla_lookups_pkg.get_meaning(
3116 'XLA_OWNER_TYPE'
3117 ,l_component_type_code
3118 )
3119 ,p_token_3 => 'PAD_NAME'
3120 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3121 ,p_token_4 => 'PAD_OWNER'
3122 ,p_value_4 => xla_lookups_pkg.get_meaning(
3123 'XLA_OWNER_TYPE'
3124 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3125 )
3126 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3127 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3128 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3129 ,p_ae_header_id => NULL
3130 );
3131 RETURN l_output_value;
3132 EXCEPTION
3133 WHEN xla_exceptions_pkg.application_exception THEN
3134 RAISE;
3135 WHEN OTHERS THEN
3136 xla_exceptions_pkg.raise_message
3137 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_23');
3138 END AcctDerRule_23;
3139 --
3140
3141 ---------------------------------------
3142 --
3143 -- PRIVATE FUNCTION
3144 -- AcctDerRule_24
3145 --
3146 ---------------------------------------
3147 FUNCTION AcctDerRule_24 (
3148 p_application_id IN NUMBER
3149 , p_ae_header_id IN NUMBER
3150 , p_side IN VARCHAR2
3151 --Interorg Transfer Credit Account
3152 , p_source_40 IN NUMBER
3153 , x_transaction_coa_id OUT NOCOPY NUMBER
3154 , x_accounting_coa_id OUT NOCOPY NUMBER
3155 , x_value_type_code OUT NOCOPY VARCHAR2
3156 )
3157 RETURN NUMBER
3158 IS
3159 l_component_type VARCHAR2(80) ;
3160 l_component_code VARCHAR2(30) ;
3161 l_component_type_code VARCHAR2(1) ;
3162 l_component_appl_id INTEGER ;
3163 l_amb_context_code VARCHAR2(30) ;
3164 l_log_module VARCHAR2(240) ;
3165 l_output_value NUMBER ;
3166 BEGIN
3167 IF g_log_enabled THEN
3168 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_24';
3169 END IF;
3170 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3171 trace
3172 (p_msg => 'BEGIN of AcctDerRule_24'
3173 ,p_level => C_LEVEL_PROCEDURE
3174 ,p_module => l_log_module);
3175 END IF;
3176 --
3177 l_component_type := 'AMB_ADR';
3178 l_component_code := 'PI_INTERORG_TRANSFER';
3179 l_component_type_code := 'S';
3180 l_component_appl_id := 707;
3181 l_amb_context_code := 'DEFAULT';
3182 x_transaction_coa_id := null;
3183 x_accounting_coa_id := null;
3184 --
3185
3186 --
3187 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3188 trace
3189 (p_msg => 'END of AcctDerRule_24'
3190 ,p_level => C_LEVEL_PROCEDURE
3191 ,p_module => l_log_module);
3192 END IF;
3193 x_value_type_code := 'S';
3194 l_output_value := TO_NUMBER(TO_NUMBER(p_source_40));
3195 RETURN l_output_value;
3196
3197 --
3198 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3199 trace
3200 (p_msg => 'END of AcctDerRule_24(invalid)'
3201 ,p_level => C_LEVEL_PROCEDURE
3202 ,p_module => l_log_module);
3203 END IF;
3204 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3205 x_value_type_code := null;
3206 l_output_value := null;
3207 xla_accounting_err_pkg.build_message
3208 (p_appli_s_name => 'XLA'
3209 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3210 ,p_token_1 => 'COMPONENT_NAME'
3211 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3212 l_component_type
3213 , l_component_code
3214 , l_component_type_code
3215 , l_component_appl_id
3216 , l_amb_context_code
3217 )
3218 ,p_token_2 => 'OWNER'
3219 ,p_value_2 => xla_lookups_pkg.get_meaning(
3220 'XLA_OWNER_TYPE'
3221 ,l_component_type_code
3222 )
3223 ,p_token_3 => 'PAD_NAME'
3224 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3225 ,p_token_4 => 'PAD_OWNER'
3226 ,p_value_4 => xla_lookups_pkg.get_meaning(
3227 'XLA_OWNER_TYPE'
3228 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3229 )
3230 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3231 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3232 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3233 ,p_ae_header_id => NULL
3234 );
3235 RETURN l_output_value;
3236 EXCEPTION
3237 WHEN xla_exceptions_pkg.application_exception THEN
3238 RAISE;
3239 WHEN OTHERS THEN
3240 xla_exceptions_pkg.raise_message
3241 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_24');
3242 END AcctDerRule_24;
3243 --
3244
3245 ---------------------------------------
3246 --
3247 -- PRIVATE FUNCTION
3248 -- AcctDerRule_25
3249 --
3250 ---------------------------------------
3251 FUNCTION AcctDerRule_25 (
3252 p_application_id IN NUMBER
3253 , p_ae_header_id IN NUMBER
3254 , p_side IN VARCHAR2
3255 --Cost Management Default Account
3256 , p_source_11 IN NUMBER
3257 --Cost Element Name
3258 , p_source_15 IN NUMBER
3259 --Primary Cost Method
3260 , p_source_39 IN NUMBER
3261 , p_source_39_meaning IN VARCHAR2
3262 --Product Line Accounting Category Material Account
3263 , p_source_41 IN NUMBER
3264 --Product Line Accounting Category Material Overhead Account
3265 , p_source_42 IN NUMBER
3266 --Product Line Accounting Category Resource Account
3267 , p_source_43 IN NUMBER
3268 --Product Line Accounting Category Outside Processing Account
3269 , p_source_44 IN NUMBER
3270 --Product Line Accounting Category Overhead Account
3271 , p_source_45 IN NUMBER
3272 , x_transaction_coa_id OUT NOCOPY NUMBER
3273 , x_accounting_coa_id OUT NOCOPY NUMBER
3274 , x_value_type_code OUT NOCOPY VARCHAR2
3275 )
3276 RETURN NUMBER
3277 IS
3278 l_component_type VARCHAR2(80) ;
3279 l_component_code VARCHAR2(30) ;
3280 l_component_type_code VARCHAR2(1) ;
3281 l_component_appl_id INTEGER ;
3282 l_amb_context_code VARCHAR2(30) ;
3283 l_log_module VARCHAR2(240) ;
3284 l_output_value NUMBER ;
3285 BEGIN
3286 IF g_log_enabled THEN
3287 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_25';
3288 END IF;
3289 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3290 trace
3291 (p_msg => 'BEGIN of AcctDerRule_25'
3292 ,p_level => C_LEVEL_PROCEDURE
3293 ,p_module => l_log_module);
3294 END IF;
3295 --
3296 l_component_type := 'AMB_ADR';
3297 l_component_code := 'PI_INTRANSIT_ACCOUNT';
3298 l_component_type_code := 'S';
3299 l_component_appl_id := 707;
3300 l_amb_context_code := 'DEFAULT';
3301 x_transaction_coa_id := null;
3302 x_accounting_coa_id := null;
3303 --
3304
3305 IF NVL(p_source_39,9E125) = 1
3306 THEN
3307 --
3308 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3309 trace
3310 (p_msg => 'END of AcctDerRule_25'
3311 ,p_level => C_LEVEL_PROCEDURE
3312 ,p_module => l_log_module);
3313 END IF;
3314 x_value_type_code := 'S';
3315 l_output_value := TO_NUMBER(TO_NUMBER(p_source_11));
3316 RETURN l_output_value;
3317
3318 ELSIF NVL(p_source_15,9E125) = 1 AND
3319 NVL(p_source_39,9E125) <> 1
3320 THEN
3321 --
3322 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3323 trace
3324 (p_msg => 'END of AcctDerRule_25'
3325 ,p_level => C_LEVEL_PROCEDURE
3326 ,p_module => l_log_module);
3327 END IF;
3328 x_value_type_code := 'S';
3329 l_output_value := TO_NUMBER(TO_NUMBER(p_source_41));
3330 RETURN l_output_value;
3331
3332 ELSIF NVL(p_source_15,9E125) = 2 AND
3333 NVL(p_source_39,9E125) <> 1
3334 THEN
3335 --
3336 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3337 trace
3338 (p_msg => 'END of AcctDerRule_25'
3339 ,p_level => C_LEVEL_PROCEDURE
3340 ,p_module => l_log_module);
3341 END IF;
3342 x_value_type_code := 'S';
3343 l_output_value := TO_NUMBER(TO_NUMBER(p_source_42));
3344 RETURN l_output_value;
3345
3346 ELSIF NVL(p_source_15,9E125) = 3 AND
3347 NVL(p_source_39,9E125) <> 1
3348 THEN
3349 --
3350 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3351 trace
3352 (p_msg => 'END of AcctDerRule_25'
3353 ,p_level => C_LEVEL_PROCEDURE
3354 ,p_module => l_log_module);
3355 END IF;
3356 x_value_type_code := 'S';
3357 l_output_value := TO_NUMBER(TO_NUMBER(p_source_43));
3358 RETURN l_output_value;
3359
3360 ELSIF NVL(p_source_15,9E125) = 4 AND
3361 NVL(p_source_39,9E125) <> 1
3362 THEN
3363 --
3364 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3365 trace
3366 (p_msg => 'END of AcctDerRule_25'
3367 ,p_level => C_LEVEL_PROCEDURE
3368 ,p_module => l_log_module);
3369 END IF;
3370 x_value_type_code := 'S';
3371 l_output_value := TO_NUMBER(TO_NUMBER(p_source_44));
3372 RETURN l_output_value;
3373
3374 ELSIF NVL(p_source_15,9E125) = 5 AND
3375 NVL(p_source_39,9E125) <> 1
3376 THEN
3377 --
3378 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3379 trace
3380 (p_msg => 'END of AcctDerRule_25'
3381 ,p_level => C_LEVEL_PROCEDURE
3382 ,p_module => l_log_module);
3383 END IF;
3384 x_value_type_code := 'S';
3385 l_output_value := TO_NUMBER(TO_NUMBER(p_source_45));
3386 RETURN l_output_value;
3387
3388 END IF;
3389 --
3390 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3391 trace
3392 (p_msg => 'END of AcctDerRule_25(invalid)'
3393 ,p_level => C_LEVEL_PROCEDURE
3394 ,p_module => l_log_module);
3395 END IF;
3396 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3397 x_value_type_code := null;
3398 l_output_value := null;
3399 xla_accounting_err_pkg.build_message
3400 (p_appli_s_name => 'XLA'
3401 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3402 ,p_token_1 => 'COMPONENT_NAME'
3403 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3404 l_component_type
3405 , l_component_code
3406 , l_component_type_code
3407 , l_component_appl_id
3408 , l_amb_context_code
3409 )
3410 ,p_token_2 => 'OWNER'
3411 ,p_value_2 => xla_lookups_pkg.get_meaning(
3412 'XLA_OWNER_TYPE'
3413 ,l_component_type_code
3414 )
3415 ,p_token_3 => 'PAD_NAME'
3416 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3417 ,p_token_4 => 'PAD_OWNER'
3418 ,p_value_4 => xla_lookups_pkg.get_meaning(
3419 'XLA_OWNER_TYPE'
3420 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3421 )
3422 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3423 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3424 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3425 ,p_ae_header_id => NULL
3426 );
3427 RETURN l_output_value;
3428 EXCEPTION
3429 WHEN xla_exceptions_pkg.application_exception THEN
3430 RAISE;
3431 WHEN OTHERS THEN
3432 xla_exceptions_pkg.raise_message
3433 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_25');
3434 END AcctDerRule_25;
3435 --
3436
3437 ---------------------------------------
3438 --
3439 -- PRIVATE FUNCTION
3440 -- AcctDerRule_26
3441 --
3442 ---------------------------------------
3443 FUNCTION AcctDerRule_26 (
3444 p_application_id IN NUMBER
3445 , p_ae_header_id IN NUMBER
3446 , p_side IN VARCHAR2
3447 --Interorg Bridging Account
3448 , p_source_46 IN NUMBER
3449 , x_transaction_coa_id OUT NOCOPY NUMBER
3450 , x_accounting_coa_id OUT NOCOPY NUMBER
3451 , x_value_type_code OUT NOCOPY VARCHAR2
3452 )
3453 RETURN NUMBER
3454 IS
3455 l_component_type VARCHAR2(80) ;
3456 l_component_code VARCHAR2(30) ;
3457 l_component_type_code VARCHAR2(1) ;
3458 l_component_appl_id INTEGER ;
3459 l_amb_context_code VARCHAR2(30) ;
3460 l_log_module VARCHAR2(240) ;
3461 l_output_value NUMBER ;
3462 BEGIN
3463 IF g_log_enabled THEN
3464 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_26';
3465 END IF;
3466 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3467 trace
3468 (p_msg => 'BEGIN of AcctDerRule_26'
3469 ,p_level => C_LEVEL_PROCEDURE
3470 ,p_module => l_log_module);
3471 END IF;
3472 --
3473 l_component_type := 'AMB_ADR';
3474 l_component_code := 'PI_INTRANSIT_BRIDGING';
3475 l_component_type_code := 'S';
3476 l_component_appl_id := 707;
3477 l_amb_context_code := 'DEFAULT';
3478 x_transaction_coa_id := null;
3479 x_accounting_coa_id := null;
3480 --
3481
3482 --
3483 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3484 trace
3485 (p_msg => 'END of AcctDerRule_26'
3486 ,p_level => C_LEVEL_PROCEDURE
3487 ,p_module => l_log_module);
3488 END IF;
3489 x_value_type_code := 'S';
3490 l_output_value := TO_NUMBER(TO_NUMBER(p_source_46));
3491 RETURN l_output_value;
3492
3493 --
3494 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3495 trace
3496 (p_msg => 'END of AcctDerRule_26(invalid)'
3497 ,p_level => C_LEVEL_PROCEDURE
3498 ,p_module => l_log_module);
3499 END IF;
3500 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3501 x_value_type_code := null;
3502 l_output_value := null;
3503 xla_accounting_err_pkg.build_message
3504 (p_appli_s_name => 'XLA'
3505 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3506 ,p_token_1 => 'COMPONENT_NAME'
3507 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3508 l_component_type
3509 , l_component_code
3510 , l_component_type_code
3511 , l_component_appl_id
3512 , l_amb_context_code
3513 )
3514 ,p_token_2 => 'OWNER'
3515 ,p_value_2 => xla_lookups_pkg.get_meaning(
3516 'XLA_OWNER_TYPE'
3517 ,l_component_type_code
3518 )
3519 ,p_token_3 => 'PAD_NAME'
3520 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3521 ,p_token_4 => 'PAD_OWNER'
3522 ,p_value_4 => xla_lookups_pkg.get_meaning(
3523 'XLA_OWNER_TYPE'
3524 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3525 )
3526 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3527 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3528 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3529 ,p_ae_header_id => NULL
3530 );
3531 RETURN l_output_value;
3532 EXCEPTION
3533 WHEN xla_exceptions_pkg.application_exception THEN
3534 RAISE;
3535 WHEN OTHERS THEN
3536 xla_exceptions_pkg.raise_message
3537 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_26');
3538 END AcctDerRule_26;
3539 --
3540
3541 ---------------------------------------
3542 --
3543 -- PRIVATE FUNCTION
3544 -- AcctDerRule_27
3545 --
3546 ---------------------------------------
3547 FUNCTION AcctDerRule_27 (
3548 p_application_id IN NUMBER
3549 , p_ae_header_id IN NUMBER
3550 , p_side IN VARCHAR2
3551 --Product Line Accounting Category Bridging Account
3552 , p_source_22 IN NUMBER
3553 --Cost Group Identifier
3554 , p_source_26 IN NUMBER
3555 --INV Header Transfer Cost Group ID
3556 , p_source_27 IN NUMBER
3557 --INV Header Cost Group ID
3558 , p_source_28 IN NUMBER
3559 --Subinventory Name
3560 , p_source_29 IN VARCHAR2
3561 --INV Header Subinventory
3562 , p_source_30 IN VARCHAR2
3563 --Transfer to Subinventory or Cost Group category bridging account
3564 , p_source_47 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_27';
3581 END IF;
3582 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3583 trace
3584 (p_msg => 'BEGIN of AcctDerRule_27'
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 := 'PI_INTRAORG_TRX_BRIDGING_ADR';
3591 l_component_type_code := 'S';
3592 l_component_appl_id := 707;
3593 l_amb_context_code := 'DEFAULT';
3594 x_transaction_coa_id := null;
3595 x_accounting_coa_id := null;
3596 --
3597
3598 IF p_source_26 IS NOT NULL AND
3599 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
3600 THEN
3601 --
3602 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3603 trace
3604 (p_msg => 'END of AcctDerRule_27'
3605 ,p_level => C_LEVEL_PROCEDURE
3606 ,p_module => l_log_module);
3607 END IF;
3608 x_value_type_code := 'S';
3609 l_output_value := TO_NUMBER(TO_NUMBER(p_source_47));
3610 RETURN l_output_value;
3611
3612 ELSIF p_source_26 IS NOT NULL AND
3613 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
3614 THEN
3615 --
3616 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3617 trace
3618 (p_msg => 'END of AcctDerRule_27'
3619 ,p_level => C_LEVEL_PROCEDURE
3620 ,p_module => l_log_module);
3621 END IF;
3622 x_value_type_code := 'S';
3623 l_output_value := TO_NUMBER(TO_NUMBER(p_source_22));
3624 RETURN l_output_value;
3625
3626 ELSIF p_source_29 IS NOT NULL AND
3627 NVL(p_source_29,'
3628 ') = NVL(p_source_30,'
3629 ')
3630 THEN
3631 --
3632 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3633 trace
3634 (p_msg => 'END of AcctDerRule_27'
3635 ,p_level => C_LEVEL_PROCEDURE
3636 ,p_module => l_log_module);
3637 END IF;
3638 x_value_type_code := 'S';
3639 l_output_value := TO_NUMBER(TO_NUMBER(p_source_22));
3640 RETURN l_output_value;
3641
3642 END IF;
3643
3644 --
3645 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3646 trace
3647 (p_msg => 'END of AcctDerRule_27'
3648 ,p_level => C_LEVEL_PROCEDURE
3649 ,p_module => l_log_module);
3650 END IF;
3651 x_value_type_code := 'S';
3652 l_output_value := TO_NUMBER(TO_NUMBER(p_source_47));
3653 RETURN l_output_value;
3654
3655 --
3656 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3657 trace
3658 (p_msg => 'END of AcctDerRule_27(invalid)'
3659 ,p_level => C_LEVEL_PROCEDURE
3660 ,p_module => l_log_module);
3661 END IF;
3662 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3663 x_value_type_code := null;
3664 l_output_value := null;
3665 xla_accounting_err_pkg.build_message
3666 (p_appli_s_name => 'XLA'
3667 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3668 ,p_token_1 => 'COMPONENT_NAME'
3669 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3670 l_component_type
3671 , l_component_code
3672 , l_component_type_code
3673 , l_component_appl_id
3674 , l_amb_context_code
3675 )
3676 ,p_token_2 => 'OWNER'
3677 ,p_value_2 => xla_lookups_pkg.get_meaning(
3678 'XLA_OWNER_TYPE'
3679 ,l_component_type_code
3680 )
3681 ,p_token_3 => 'PAD_NAME'
3682 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3683 ,p_token_4 => 'PAD_OWNER'
3684 ,p_value_4 => xla_lookups_pkg.get_meaning(
3685 'XLA_OWNER_TYPE'
3686 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3687 )
3688 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3689 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3690 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3691 ,p_ae_header_id => NULL
3692 );
3693 RETURN l_output_value;
3694 EXCEPTION
3695 WHEN xla_exceptions_pkg.application_exception THEN
3696 RAISE;
3697 WHEN OTHERS THEN
3698 xla_exceptions_pkg.raise_message
3699 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_27');
3700 END AcctDerRule_27;
3701 --
3702
3703 ---------------------------------------
3704 --
3705 -- PRIVATE FUNCTION
3706 -- AcctDerRule_28
3707 --
3708 ---------------------------------------
3709 FUNCTION AcctDerRule_28 (
3710 p_application_id IN NUMBER
3711 , p_ae_header_id IN NUMBER
3712 , p_side IN VARCHAR2
3713 --Cost Element Name
3714 , p_source_15 IN NUMBER
3715 --Product Line Accounting Category Material Account
3716 , p_source_41 IN NUMBER
3717 --Product Line Accounting Category Material Overhead Account
3718 , p_source_42 IN NUMBER
3719 --Product Line Accounting Category Resource Account
3720 , p_source_43 IN NUMBER
3721 --Product Line Accounting Category Outside Processing Account
3722 , p_source_44 IN NUMBER
3723 --Product Line Accounting Category Overhead Account
3724 , p_source_45 IN NUMBER
3725 , x_transaction_coa_id OUT NOCOPY NUMBER
3726 , x_accounting_coa_id OUT NOCOPY NUMBER
3727 , x_value_type_code OUT NOCOPY VARCHAR2
3728 )
3729 RETURN NUMBER
3730 IS
3731 l_component_type VARCHAR2(80) ;
3732 l_component_code VARCHAR2(30) ;
3733 l_component_type_code VARCHAR2(1) ;
3734 l_component_appl_id INTEGER ;
3735 l_amb_context_code VARCHAR2(30) ;
3736 l_log_module VARCHAR2(240) ;
3737 l_output_value NUMBER ;
3738 BEGIN
3739 IF g_log_enabled THEN
3740 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_28';
3741 END IF;
3742 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3743 trace
3744 (p_msg => 'BEGIN of AcctDerRule_28'
3745 ,p_level => C_LEVEL_PROCEDURE
3746 ,p_module => l_log_module);
3747 END IF;
3748 --
3749 l_component_type := 'AMB_ADR';
3750 l_component_code := 'PI_INVENTORY_ACCOUNT';
3751 l_component_type_code := 'S';
3752 l_component_appl_id := 707;
3753 l_amb_context_code := 'DEFAULT';
3754 x_transaction_coa_id := null;
3755 x_accounting_coa_id := null;
3756 --
3757
3758 IF NVL(p_source_15,9E125) = 1
3759 THEN
3760 --
3761 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3762 trace
3763 (p_msg => 'END of AcctDerRule_28'
3764 ,p_level => C_LEVEL_PROCEDURE
3765 ,p_module => l_log_module);
3766 END IF;
3767 x_value_type_code := 'S';
3768 l_output_value := TO_NUMBER(TO_NUMBER(p_source_41));
3769 RETURN l_output_value;
3770
3771 ELSIF NVL(p_source_15,9E125) = 2
3772 THEN
3773 --
3774 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3775 trace
3776 (p_msg => 'END of AcctDerRule_28'
3777 ,p_level => C_LEVEL_PROCEDURE
3778 ,p_module => l_log_module);
3779 END IF;
3780 x_value_type_code := 'S';
3781 l_output_value := TO_NUMBER(TO_NUMBER(p_source_42));
3782 RETURN l_output_value;
3783
3784 ELSIF NVL(p_source_15,9E125) = 3
3785 THEN
3786 --
3787 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3788 trace
3789 (p_msg => 'END of AcctDerRule_28'
3790 ,p_level => C_LEVEL_PROCEDURE
3791 ,p_module => l_log_module);
3792 END IF;
3793 x_value_type_code := 'S';
3794 l_output_value := TO_NUMBER(TO_NUMBER(p_source_43));
3795 RETURN l_output_value;
3796
3797 ELSIF NVL(p_source_15,9E125) = 4
3798 THEN
3799 --
3800 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3801 trace
3802 (p_msg => 'END of AcctDerRule_28'
3803 ,p_level => C_LEVEL_PROCEDURE
3804 ,p_module => l_log_module);
3805 END IF;
3806 x_value_type_code := 'S';
3807 l_output_value := TO_NUMBER(TO_NUMBER(p_source_44));
3808 RETURN l_output_value;
3809
3810 ELSIF NVL(p_source_15,9E125) = 5
3811 THEN
3812 --
3813 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3814 trace
3815 (p_msg => 'END of AcctDerRule_28'
3816 ,p_level => C_LEVEL_PROCEDURE
3817 ,p_module => l_log_module);
3818 END IF;
3819 x_value_type_code := 'S';
3820 l_output_value := TO_NUMBER(TO_NUMBER(p_source_45));
3821 RETURN l_output_value;
3822
3823 END IF;
3824 --
3825 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3826 trace
3827 (p_msg => 'END of AcctDerRule_28(invalid)'
3828 ,p_level => C_LEVEL_PROCEDURE
3829 ,p_module => l_log_module);
3830 END IF;
3831 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3832 x_value_type_code := null;
3833 l_output_value := null;
3834 xla_accounting_err_pkg.build_message
3835 (p_appli_s_name => 'XLA'
3836 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3837 ,p_token_1 => 'COMPONENT_NAME'
3838 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3839 l_component_type
3840 , l_component_code
3841 , l_component_type_code
3842 , l_component_appl_id
3843 , l_amb_context_code
3844 )
3845 ,p_token_2 => 'OWNER'
3846 ,p_value_2 => xla_lookups_pkg.get_meaning(
3847 'XLA_OWNER_TYPE'
3848 ,l_component_type_code
3849 )
3850 ,p_token_3 => 'PAD_NAME'
3851 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3852 ,p_token_4 => 'PAD_OWNER'
3853 ,p_value_4 => xla_lookups_pkg.get_meaning(
3854 'XLA_OWNER_TYPE'
3855 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3856 )
3857 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3858 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3859 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3860 ,p_ae_header_id => NULL
3861 );
3862 RETURN l_output_value;
3863 EXCEPTION
3864 WHEN xla_exceptions_pkg.application_exception THEN
3865 RAISE;
3866 WHEN OTHERS THEN
3867 xla_exceptions_pkg.raise_message
3868 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_28');
3869 END AcctDerRule_28;
3870 --
3871
3872 ---------------------------------------
3873 --
3874 -- PRIVATE FUNCTION
3875 -- AcctDerRule_29
3876 --
3877 ---------------------------------------
3878 FUNCTION AcctDerRule_29 (
3879 p_application_id IN NUMBER
3880 , p_ae_header_id IN NUMBER
3881 , p_side IN VARCHAR2
3882 --Cost Element Name
3883 , p_source_15 IN NUMBER
3884 --Cost Group Identifier
3885 , p_source_26 IN NUMBER
3886 --INV Header Transfer Cost Group ID
3887 , p_source_27 IN NUMBER
3888 --INV Header Cost Group ID
3889 , p_source_28 IN NUMBER
3890 --Subinventory Name
3891 , p_source_29 IN VARCHAR2
3892 --INV Header Transfer Subinventory
3893 , p_source_31 IN VARCHAR2
3894 --Product Line Accounting Category Material Account
3895 , p_source_41 IN NUMBER
3896 --Product Line Accounting Category Material Overhead Account
3897 , p_source_42 IN NUMBER
3898 --Product Line Accounting Category Resource Account
3899 , p_source_43 IN NUMBER
3900 --Product Line Accounting Category Outside Processing Account
3901 , p_source_44 IN NUMBER
3902 --Product Line Accounting Category Overhead Account
3903 , p_source_45 IN NUMBER
3904 --Transfer to Subinventory or Cost Group category material account
3905 , p_source_48 IN NUMBER
3906 --Transfer to Subinventory or Cost Group category material overhead account
3907 , p_source_49 IN NUMBER
3908 --Transfer to Subinventory or Cost Group category resource account
3909 , p_source_50 IN NUMBER
3910 --Transfer to Subinventory or Cost Group category outside processing account
3911 , p_source_51 IN NUMBER
3912 --Transfer to Subinventory or Cost Group category overhead account
3913 , p_source_52 IN NUMBER
3914 , x_transaction_coa_id OUT NOCOPY NUMBER
3915 , x_accounting_coa_id OUT NOCOPY NUMBER
3916 , x_value_type_code OUT NOCOPY VARCHAR2
3917 )
3918 RETURN NUMBER
3919 IS
3920 l_component_type VARCHAR2(80) ;
3921 l_component_code VARCHAR2(30) ;
3922 l_component_type_code VARCHAR2(1) ;
3923 l_component_appl_id INTEGER ;
3924 l_amb_context_code VARCHAR2(30) ;
3925 l_log_module VARCHAR2(240) ;
3926 l_output_value NUMBER ;
3927 BEGIN
3928 IF g_log_enabled THEN
3929 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_29';
3930 END IF;
3931 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3932 trace
3933 (p_msg => 'BEGIN of AcctDerRule_29'
3934 ,p_level => C_LEVEL_PROCEDURE
3935 ,p_module => l_log_module);
3936 END IF;
3937 --
3938 l_component_type := 'AMB_ADR';
3939 l_component_code := 'PI_INVENTORY_ACCOUNT_ADR';
3940 l_component_type_code := 'S';
3941 l_component_appl_id := 707;
3942 l_amb_context_code := 'DEFAULT';
3943 x_transaction_coa_id := null;
3944 x_accounting_coa_id := null;
3945 --
3946
3947 IF NVL(p_source_15,9E125) = 1 AND
3948 p_source_26 IS NOT NULL AND
3949 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
3950 THEN
3951 --
3952 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3953 trace
3954 (p_msg => 'END of AcctDerRule_29'
3955 ,p_level => C_LEVEL_PROCEDURE
3956 ,p_module => l_log_module);
3957 END IF;
3958 x_value_type_code := 'S';
3959 l_output_value := TO_NUMBER(TO_NUMBER(p_source_48));
3960 RETURN l_output_value;
3961
3962 ELSIF NVL(p_source_15,9E125) = 1 AND
3963 p_source_26 IS NOT NULL AND
3964 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
3965 THEN
3966 --
3967 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3968 trace
3969 (p_msg => 'END of AcctDerRule_29'
3970 ,p_level => C_LEVEL_PROCEDURE
3971 ,p_module => l_log_module);
3972 END IF;
3973 x_value_type_code := 'S';
3974 l_output_value := TO_NUMBER(TO_NUMBER(p_source_41));
3975 RETURN l_output_value;
3976
3977 ELSIF NVL(p_source_15,9E125) = 1 AND
3978 p_source_29 IS NOT NULL AND
3979 NVL(p_source_29,'
3980 ') = NVL(p_source_31,'
3981 ')
3982 THEN
3983 --
3984 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3985 trace
3986 (p_msg => 'END of AcctDerRule_29'
3987 ,p_level => C_LEVEL_PROCEDURE
3988 ,p_module => l_log_module);
3989 END IF;
3990 x_value_type_code := 'S';
3991 l_output_value := TO_NUMBER(TO_NUMBER(p_source_48));
3992 RETURN l_output_value;
3993
3994 ELSIF NVL(p_source_15,9E125) = 1
3995 THEN
3996 --
3997 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3998 trace
3999 (p_msg => 'END of AcctDerRule_29'
4000 ,p_level => C_LEVEL_PROCEDURE
4001 ,p_module => l_log_module);
4002 END IF;
4003 x_value_type_code := 'S';
4004 l_output_value := TO_NUMBER(TO_NUMBER(p_source_41));
4005 RETURN l_output_value;
4006
4007 ELSIF NVL(p_source_15,9E125) = 2 AND
4008 p_source_26 IS NOT NULL AND
4009 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
4010 THEN
4011 --
4012 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4013 trace
4014 (p_msg => 'END of AcctDerRule_29'
4015 ,p_level => C_LEVEL_PROCEDURE
4016 ,p_module => l_log_module);
4017 END IF;
4018 x_value_type_code := 'S';
4019 l_output_value := TO_NUMBER(TO_NUMBER(p_source_49));
4020 RETURN l_output_value;
4021
4022 ELSIF NVL(p_source_15,9E125) = 2 AND
4023 p_source_26 IS NOT NULL AND
4024 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
4025 THEN
4026 --
4027 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4028 trace
4029 (p_msg => 'END of AcctDerRule_29'
4030 ,p_level => C_LEVEL_PROCEDURE
4031 ,p_module => l_log_module);
4032 END IF;
4033 x_value_type_code := 'S';
4034 l_output_value := TO_NUMBER(TO_NUMBER(p_source_42));
4035 RETURN l_output_value;
4036
4037 ELSIF NVL(p_source_15,9E125) = 2 AND
4038 p_source_29 IS NOT NULL AND
4039 NVL(p_source_29,'
4040 ') = NVL(p_source_31,'
4041 ')
4042 THEN
4043 --
4044 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4045 trace
4046 (p_msg => 'END of AcctDerRule_29'
4047 ,p_level => C_LEVEL_PROCEDURE
4048 ,p_module => l_log_module);
4049 END IF;
4050 x_value_type_code := 'S';
4051 l_output_value := TO_NUMBER(TO_NUMBER(p_source_49));
4052 RETURN l_output_value;
4053
4054 ELSIF NVL(p_source_15,9E125) = 2
4055 THEN
4056 --
4057 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4058 trace
4059 (p_msg => 'END of AcctDerRule_29'
4060 ,p_level => C_LEVEL_PROCEDURE
4061 ,p_module => l_log_module);
4062 END IF;
4063 x_value_type_code := 'S';
4064 l_output_value := TO_NUMBER(TO_NUMBER(p_source_42));
4065 RETURN l_output_value;
4066
4067 ELSIF NVL(p_source_15,9E125) = 3 AND
4068 p_source_26 IS NOT NULL AND
4069 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
4070 THEN
4071 --
4072 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4073 trace
4074 (p_msg => 'END of AcctDerRule_29'
4075 ,p_level => C_LEVEL_PROCEDURE
4076 ,p_module => l_log_module);
4077 END IF;
4078 x_value_type_code := 'S';
4079 l_output_value := TO_NUMBER(TO_NUMBER(p_source_50));
4080 RETURN l_output_value;
4081
4082 ELSIF NVL(p_source_15,9E125) = 3 AND
4083 p_source_26 IS NOT NULL AND
4084 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
4085 THEN
4086 --
4087 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4088 trace
4089 (p_msg => 'END of AcctDerRule_29'
4090 ,p_level => C_LEVEL_PROCEDURE
4091 ,p_module => l_log_module);
4092 END IF;
4093 x_value_type_code := 'S';
4094 l_output_value := TO_NUMBER(TO_NUMBER(p_source_43));
4095 RETURN l_output_value;
4096
4097 ELSIF NVL(p_source_15,9E125) = 3 AND
4098 p_source_29 IS NOT NULL AND
4099 NVL(p_source_29,'
4100 ') = NVL(p_source_31,'
4101 ')
4102 THEN
4103 --
4104 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4105 trace
4106 (p_msg => 'END of AcctDerRule_29'
4107 ,p_level => C_LEVEL_PROCEDURE
4108 ,p_module => l_log_module);
4109 END IF;
4110 x_value_type_code := 'S';
4111 l_output_value := TO_NUMBER(TO_NUMBER(p_source_50));
4112 RETURN l_output_value;
4113
4114 ELSIF NVL(p_source_15,9E125) = 3
4115 THEN
4116 --
4117 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4118 trace
4119 (p_msg => 'END of AcctDerRule_29'
4120 ,p_level => C_LEVEL_PROCEDURE
4121 ,p_module => l_log_module);
4122 END IF;
4123 x_value_type_code := 'S';
4124 l_output_value := TO_NUMBER(TO_NUMBER(p_source_43));
4125 RETURN l_output_value;
4126
4127 ELSIF NVL(p_source_15,9E125) = 4 AND
4128 p_source_26 IS NOT NULL AND
4129 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
4130 THEN
4131 --
4132 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4133 trace
4134 (p_msg => 'END of AcctDerRule_29'
4135 ,p_level => C_LEVEL_PROCEDURE
4136 ,p_module => l_log_module);
4137 END IF;
4138 x_value_type_code := 'S';
4139 l_output_value := TO_NUMBER(TO_NUMBER(p_source_51));
4140 RETURN l_output_value;
4141
4142 ELSIF NVL(p_source_15,9E125) = 4 AND
4143 p_source_26 IS NOT NULL AND
4144 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
4145 THEN
4146 --
4147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4148 trace
4149 (p_msg => 'END of AcctDerRule_29'
4150 ,p_level => C_LEVEL_PROCEDURE
4151 ,p_module => l_log_module);
4152 END IF;
4153 x_value_type_code := 'S';
4154 l_output_value := TO_NUMBER(TO_NUMBER(p_source_44));
4155 RETURN l_output_value;
4156
4157 ELSIF NVL(p_source_15,9E125) = 4 AND
4158 p_source_29 IS NOT NULL AND
4159 NVL(p_source_29,'
4160 ') = NVL(p_source_31,'
4161 ')
4162 THEN
4163 --
4164 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4165 trace
4166 (p_msg => 'END of AcctDerRule_29'
4167 ,p_level => C_LEVEL_PROCEDURE
4168 ,p_module => l_log_module);
4169 END IF;
4170 x_value_type_code := 'S';
4171 l_output_value := TO_NUMBER(TO_NUMBER(p_source_51));
4172 RETURN l_output_value;
4173
4174 ELSIF NVL(p_source_15,9E125) = 4
4175 THEN
4176 --
4177 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4178 trace
4179 (p_msg => 'END of AcctDerRule_29'
4180 ,p_level => C_LEVEL_PROCEDURE
4181 ,p_module => l_log_module);
4182 END IF;
4183 x_value_type_code := 'S';
4184 l_output_value := TO_NUMBER(TO_NUMBER(p_source_44));
4185 RETURN l_output_value;
4186
4187 ELSIF NVL(p_source_15,9E125) = 5 AND
4188 p_source_26 IS NOT NULL AND
4189 NVL(p_source_26,9E125) = NVL(p_source_27,9E125)
4190 THEN
4191 --
4192 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4193 trace
4194 (p_msg => 'END of AcctDerRule_29'
4195 ,p_level => C_LEVEL_PROCEDURE
4196 ,p_module => l_log_module);
4197 END IF;
4198 x_value_type_code := 'S';
4199 l_output_value := TO_NUMBER(TO_NUMBER(p_source_52));
4200 RETURN l_output_value;
4201
4202 ELSIF NVL(p_source_15,9E125) = 5 AND
4203 p_source_26 IS NOT NULL AND
4204 NVL(p_source_26,9E125) = NVL(p_source_28,9E125)
4205 THEN
4206 --
4207 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4208 trace
4209 (p_msg => 'END of AcctDerRule_29'
4210 ,p_level => C_LEVEL_PROCEDURE
4211 ,p_module => l_log_module);
4212 END IF;
4213 x_value_type_code := 'S';
4214 l_output_value := TO_NUMBER(TO_NUMBER(p_source_45));
4215 RETURN l_output_value;
4216
4217 ELSIF NVL(p_source_15,9E125) = 5 AND
4218 p_source_29 IS NOT NULL AND
4219 NVL(p_source_29,'
4220 ') = NVL(p_source_31,'
4221 ')
4222 THEN
4223 --
4224 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4225 trace
4226 (p_msg => 'END of AcctDerRule_29'
4227 ,p_level => C_LEVEL_PROCEDURE
4228 ,p_module => l_log_module);
4229 END IF;
4230 x_value_type_code := 'S';
4231 l_output_value := TO_NUMBER(TO_NUMBER(p_source_52));
4232 RETURN l_output_value;
4233
4234 ELSIF NVL(p_source_15,9E125) = 5
4235 THEN
4236 --
4237 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4238 trace
4239 (p_msg => 'END of AcctDerRule_29'
4240 ,p_level => C_LEVEL_PROCEDURE
4241 ,p_module => l_log_module);
4242 END IF;
4243 x_value_type_code := 'S';
4244 l_output_value := TO_NUMBER(TO_NUMBER(p_source_45));
4245 RETURN l_output_value;
4246
4247 END IF;
4248 --
4249 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4250 trace
4251 (p_msg => 'END of AcctDerRule_29(invalid)'
4252 ,p_level => C_LEVEL_PROCEDURE
4253 ,p_module => l_log_module);
4254 END IF;
4255 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4256 x_value_type_code := null;
4257 l_output_value := null;
4258 xla_accounting_err_pkg.build_message
4259 (p_appli_s_name => 'XLA'
4260 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4261 ,p_token_1 => 'COMPONENT_NAME'
4262 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4263 l_component_type
4264 , l_component_code
4265 , l_component_type_code
4266 , l_component_appl_id
4267 , l_amb_context_code
4268 )
4269 ,p_token_2 => 'OWNER'
4270 ,p_value_2 => xla_lookups_pkg.get_meaning(
4271 'XLA_OWNER_TYPE'
4272 ,l_component_type_code
4273 )
4274 ,p_token_3 => 'PAD_NAME'
4275 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4276 ,p_token_4 => 'PAD_OWNER'
4277 ,p_value_4 => xla_lookups_pkg.get_meaning(
4278 'XLA_OWNER_TYPE'
4279 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4280 )
4281 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4282 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4283 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4284 ,p_ae_header_id => NULL
4285 );
4286 RETURN l_output_value;
4287 EXCEPTION
4288 WHEN xla_exceptions_pkg.application_exception THEN
4289 RAISE;
4290 WHEN OTHERS THEN
4291 xla_exceptions_pkg.raise_message
4292 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_29');
4293 END AcctDerRule_29;
4294 --
4295
4296 ---------------------------------------
4297 --
4298 -- PRIVATE FUNCTION
4299 -- AcctDerRule_30
4300 --
4301 ---------------------------------------
4302 FUNCTION AcctDerRule_30 (
4303 p_application_id IN NUMBER
4304 , p_ae_header_id IN NUMBER
4305 , p_side IN VARCHAR2
4306 --Inventory Item Expense Account
4307 , p_source_53 IN NUMBER
4308 , x_transaction_coa_id OUT NOCOPY NUMBER
4309 , x_accounting_coa_id OUT NOCOPY NUMBER
4310 , x_value_type_code OUT NOCOPY VARCHAR2
4311 )
4312 RETURN NUMBER
4313 IS
4314 l_component_type VARCHAR2(80) ;
4315 l_component_code VARCHAR2(30) ;
4316 l_component_type_code VARCHAR2(1) ;
4317 l_component_appl_id INTEGER ;
4318 l_amb_context_code VARCHAR2(30) ;
4319 l_log_module VARCHAR2(240) ;
4320 l_output_value NUMBER ;
4321 BEGIN
4322 IF g_log_enabled THEN
4323 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_30';
4324 END IF;
4325 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4326 trace
4327 (p_msg => 'BEGIN of AcctDerRule_30'
4328 ,p_level => C_LEVEL_PROCEDURE
4329 ,p_module => l_log_module);
4330 END IF;
4331 --
4332 l_component_type := 'AMB_ADR';
4333 l_component_code := 'PI_ITEM_EXPENSE';
4334 l_component_type_code := 'S';
4335 l_component_appl_id := 707;
4336 l_amb_context_code := 'DEFAULT';
4337 x_transaction_coa_id := null;
4338 x_accounting_coa_id := null;
4339 --
4340
4341 --
4342 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4343 trace
4344 (p_msg => 'END of AcctDerRule_30'
4345 ,p_level => C_LEVEL_PROCEDURE
4346 ,p_module => l_log_module);
4347 END IF;
4348 x_value_type_code := 'S';
4349 l_output_value := TO_NUMBER(TO_NUMBER(p_source_53));
4350 RETURN l_output_value;
4351
4352 --
4353 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4354 trace
4355 (p_msg => 'END of AcctDerRule_30(invalid)'
4356 ,p_level => C_LEVEL_PROCEDURE
4357 ,p_module => l_log_module);
4358 END IF;
4359 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4360 x_value_type_code := null;
4361 l_output_value := null;
4362 xla_accounting_err_pkg.build_message
4363 (p_appli_s_name => 'XLA'
4364 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4365 ,p_token_1 => 'COMPONENT_NAME'
4366 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4367 l_component_type
4368 , l_component_code
4369 , l_component_type_code
4370 , l_component_appl_id
4371 , l_amb_context_code
4372 )
4373 ,p_token_2 => 'OWNER'
4374 ,p_value_2 => xla_lookups_pkg.get_meaning(
4375 'XLA_OWNER_TYPE'
4376 ,l_component_type_code
4377 )
4378 ,p_token_3 => 'PAD_NAME'
4379 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4380 ,p_token_4 => 'PAD_OWNER'
4381 ,p_value_4 => xla_lookups_pkg.get_meaning(
4382 'XLA_OWNER_TYPE'
4383 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4384 )
4385 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4386 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4387 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4388 ,p_ae_header_id => NULL
4389 );
4390 RETURN l_output_value;
4391 EXCEPTION
4392 WHEN xla_exceptions_pkg.application_exception THEN
4393 RAISE;
4394 WHEN OTHERS THEN
4395 xla_exceptions_pkg.raise_message
4396 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_30');
4397 END AcctDerRule_30;
4398 --
4399
4400 ---------------------------------------
4401 --
4402 -- PRIVATE FUNCTION
4403 -- AcctDerRule_31
4404 --
4405 ---------------------------------------
4406 FUNCTION AcctDerRule_31 (
4407 p_application_id IN NUMBER
4408 , p_ae_header_id IN NUMBER
4409 , p_side IN VARCHAR2
4410 --Discrete Job Bridging Account
4411 , p_source_54 IN NUMBER
4412 --WIP Entity Type
4413 , p_source_55 IN NUMBER
4414 , p_source_55_meaning IN VARCHAR2
4415 --Flow Schedule Bridging Account
4416 , p_source_56 IN NUMBER
4417 --Repetitive Item Bridging Account
4418 , p_source_57 IN NUMBER
4419 , x_transaction_coa_id OUT NOCOPY NUMBER
4420 , x_accounting_coa_id OUT NOCOPY NUMBER
4421 , x_value_type_code OUT NOCOPY VARCHAR2
4422 )
4423 RETURN NUMBER
4424 IS
4425 l_component_type VARCHAR2(80) ;
4426 l_component_code VARCHAR2(30) ;
4427 l_component_type_code VARCHAR2(1) ;
4428 l_component_appl_id INTEGER ;
4429 l_amb_context_code VARCHAR2(30) ;
4430 l_log_module VARCHAR2(240) ;
4431 l_output_value NUMBER ;
4432 BEGIN
4433 IF g_log_enabled THEN
4434 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_31';
4435 END IF;
4436 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4437 trace
4438 (p_msg => 'BEGIN of AcctDerRule_31'
4439 ,p_level => C_LEVEL_PROCEDURE
4440 ,p_module => l_log_module);
4441 END IF;
4442 --
4443 l_component_type := 'AMB_ADR';
4444 l_component_code := 'PI_OSP_BRIDGING';
4445 l_component_type_code := 'S';
4446 l_component_appl_id := 707;
4447 l_amb_context_code := 'DEFAULT';
4448 x_transaction_coa_id := null;
4449 x_accounting_coa_id := null;
4450 --
4451
4452 IF NVL(p_source_55,9E125) = 1 OR
4453 NVL(p_source_55,9E125) = 3
4454 THEN
4455 --
4456 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4457 trace
4458 (p_msg => 'END of AcctDerRule_31'
4459 ,p_level => C_LEVEL_PROCEDURE
4460 ,p_module => l_log_module);
4461 END IF;
4462 x_value_type_code := 'S';
4463 l_output_value := TO_NUMBER(TO_NUMBER(p_source_54));
4464 RETURN l_output_value;
4465
4466 ELSIF NVL(p_source_55,9E125) = 4
4467 THEN
4468 --
4469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4470 trace
4471 (p_msg => 'END of AcctDerRule_31'
4472 ,p_level => C_LEVEL_PROCEDURE
4473 ,p_module => l_log_module);
4474 END IF;
4475 x_value_type_code := 'S';
4476 l_output_value := TO_NUMBER(TO_NUMBER(p_source_56));
4477 RETURN l_output_value;
4478
4479 ELSIF NVL(p_source_55,9E125) = 2
4480 THEN
4481 --
4482 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4483 trace
4484 (p_msg => 'END of AcctDerRule_31'
4485 ,p_level => C_LEVEL_PROCEDURE
4486 ,p_module => l_log_module);
4487 END IF;
4488 x_value_type_code := 'S';
4489 l_output_value := TO_NUMBER(TO_NUMBER(p_source_57));
4490 RETURN l_output_value;
4491
4492 END IF;
4493 --
4494 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4495 trace
4496 (p_msg => 'END of AcctDerRule_31(invalid)'
4497 ,p_level => C_LEVEL_PROCEDURE
4498 ,p_module => l_log_module);
4499 END IF;
4500 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4501 x_value_type_code := null;
4502 l_output_value := null;
4503 xla_accounting_err_pkg.build_message
4504 (p_appli_s_name => 'XLA'
4505 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4506 ,p_token_1 => 'COMPONENT_NAME'
4507 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4508 l_component_type
4509 , l_component_code
4510 , l_component_type_code
4511 , l_component_appl_id
4512 , l_amb_context_code
4513 )
4514 ,p_token_2 => 'OWNER'
4515 ,p_value_2 => xla_lookups_pkg.get_meaning(
4516 'XLA_OWNER_TYPE'
4517 ,l_component_type_code
4518 )
4519 ,p_token_3 => 'PAD_NAME'
4520 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4521 ,p_token_4 => 'PAD_OWNER'
4522 ,p_value_4 => xla_lookups_pkg.get_meaning(
4523 'XLA_OWNER_TYPE'
4524 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4525 )
4526 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4527 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4528 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4529 ,p_ae_header_id => NULL
4530 );
4531 RETURN l_output_value;
4532 EXCEPTION
4533 WHEN xla_exceptions_pkg.application_exception THEN
4534 RAISE;
4535 WHEN OTHERS THEN
4536 xla_exceptions_pkg.raise_message
4537 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_31');
4538 END AcctDerRule_31;
4539 --
4540
4541 ---------------------------------------
4542 --
4543 -- PRIVATE FUNCTION
4544 -- AcctDerRule_32
4545 --
4546 ---------------------------------------
4547 FUNCTION AcctDerRule_32 (
4548 p_application_id IN NUMBER
4549 , p_ae_header_id IN NUMBER
4550 , p_side IN VARCHAR2
4551 --Inventory Organization Purchase Price Variance Account
4552 , p_source_58 IN NUMBER
4553 , x_transaction_coa_id OUT NOCOPY NUMBER
4554 , x_accounting_coa_id OUT NOCOPY NUMBER
4555 , x_value_type_code OUT NOCOPY VARCHAR2
4556 )
4557 RETURN NUMBER
4558 IS
4559 l_component_type VARCHAR2(80) ;
4560 l_component_code VARCHAR2(30) ;
4561 l_component_type_code VARCHAR2(1) ;
4562 l_component_appl_id INTEGER ;
4563 l_amb_context_code VARCHAR2(30) ;
4564 l_log_module VARCHAR2(240) ;
4565 l_output_value NUMBER ;
4566 BEGIN
4567 IF g_log_enabled THEN
4568 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_32';
4569 END IF;
4570 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4571 trace
4572 (p_msg => 'BEGIN of AcctDerRule_32'
4573 ,p_level => C_LEVEL_PROCEDURE
4574 ,p_module => l_log_module);
4575 END IF;
4576 --
4577 l_component_type := 'AMB_ADR';
4578 l_component_code := 'PI_PURCHASE_PRICE_VAR';
4579 l_component_type_code := 'S';
4580 l_component_appl_id := 707;
4581 l_amb_context_code := 'DEFAULT';
4582 x_transaction_coa_id := null;
4583 x_accounting_coa_id := null;
4584 --
4585
4586 --
4587 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4588 trace
4589 (p_msg => 'END of AcctDerRule_32'
4590 ,p_level => C_LEVEL_PROCEDURE
4591 ,p_module => l_log_module);
4592 END IF;
4593 x_value_type_code := 'S';
4594 l_output_value := TO_NUMBER(TO_NUMBER(p_source_58));
4595 RETURN l_output_value;
4596
4597 --
4598 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4599 trace
4600 (p_msg => 'END of AcctDerRule_32(invalid)'
4601 ,p_level => C_LEVEL_PROCEDURE
4602 ,p_module => l_log_module);
4603 END IF;
4604 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4605 x_value_type_code := null;
4606 l_output_value := null;
4607 xla_accounting_err_pkg.build_message
4608 (p_appli_s_name => 'XLA'
4609 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4610 ,p_token_1 => 'COMPONENT_NAME'
4611 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4612 l_component_type
4613 , l_component_code
4614 , l_component_type_code
4615 , l_component_appl_id
4616 , l_amb_context_code
4617 )
4618 ,p_token_2 => 'OWNER'
4619 ,p_value_2 => xla_lookups_pkg.get_meaning(
4620 'XLA_OWNER_TYPE'
4621 ,l_component_type_code
4622 )
4623 ,p_token_3 => 'PAD_NAME'
4624 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4625 ,p_token_4 => 'PAD_OWNER'
4626 ,p_value_4 => xla_lookups_pkg.get_meaning(
4627 'XLA_OWNER_TYPE'
4628 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4629 )
4630 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4631 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4632 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4633 ,p_ae_header_id => NULL
4634 );
4635 RETURN l_output_value;
4636 EXCEPTION
4637 WHEN xla_exceptions_pkg.application_exception THEN
4638 RAISE;
4639 WHEN OTHERS THEN
4640 xla_exceptions_pkg.raise_message
4641 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_32');
4642 END AcctDerRule_32;
4643 --
4644
4645 ---------------------------------------
4646 --
4647 -- PRIVATE FUNCTION
4648 -- AcctDerRule_33
4649 --
4650 ---------------------------------------
4651 FUNCTION AcctDerRule_33 (
4652 p_application_id IN NUMBER
4653 , p_ae_header_id IN NUMBER
4654 , p_side IN VARCHAR2
4655 --Interorg Receivables Account
4656 , p_source_59 IN NUMBER
4657 , x_transaction_coa_id OUT NOCOPY NUMBER
4658 , x_accounting_coa_id OUT NOCOPY NUMBER
4659 , x_value_type_code OUT NOCOPY VARCHAR2
4660 )
4661 RETURN NUMBER
4662 IS
4663 l_component_type VARCHAR2(80) ;
4664 l_component_code VARCHAR2(30) ;
4665 l_component_type_code VARCHAR2(1) ;
4666 l_component_appl_id INTEGER ;
4667 l_amb_context_code VARCHAR2(30) ;
4668 l_log_module VARCHAR2(240) ;
4669 l_output_value NUMBER ;
4670 BEGIN
4671 IF g_log_enabled THEN
4672 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_33';
4673 END IF;
4674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4675 trace
4676 (p_msg => 'BEGIN of AcctDerRule_33'
4677 ,p_level => C_LEVEL_PROCEDURE
4678 ,p_module => l_log_module);
4679 END IF;
4680 --
4681 l_component_type := 'AMB_ADR';
4682 l_component_code := 'PI_RECEIVABLES';
4683 l_component_type_code := 'S';
4684 l_component_appl_id := 707;
4685 l_amb_context_code := 'DEFAULT';
4686 x_transaction_coa_id := null;
4687 x_accounting_coa_id := null;
4688 --
4689
4690 --
4691 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4692 trace
4693 (p_msg => 'END of AcctDerRule_33'
4694 ,p_level => C_LEVEL_PROCEDURE
4695 ,p_module => l_log_module);
4696 END IF;
4697 x_value_type_code := 'S';
4698 l_output_value := TO_NUMBER(TO_NUMBER(p_source_59));
4699 RETURN l_output_value;
4700
4701 --
4702 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4703 trace
4704 (p_msg => 'END of AcctDerRule_33(invalid)'
4705 ,p_level => C_LEVEL_PROCEDURE
4706 ,p_module => l_log_module);
4707 END IF;
4708 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4709 x_value_type_code := null;
4710 l_output_value := null;
4711 xla_accounting_err_pkg.build_message
4712 (p_appli_s_name => 'XLA'
4713 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4714 ,p_token_1 => 'COMPONENT_NAME'
4715 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4716 l_component_type
4717 , l_component_code
4718 , l_component_type_code
4719 , l_component_appl_id
4720 , l_amb_context_code
4721 )
4722 ,p_token_2 => 'OWNER'
4723 ,p_value_2 => xla_lookups_pkg.get_meaning(
4724 'XLA_OWNER_TYPE'
4725 ,l_component_type_code
4726 )
4727 ,p_token_3 => 'PAD_NAME'
4728 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4729 ,p_token_4 => 'PAD_OWNER'
4730 ,p_value_4 => xla_lookups_pkg.get_meaning(
4731 'XLA_OWNER_TYPE'
4732 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4733 )
4734 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4735 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4736 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4737 ,p_ae_header_id => NULL
4738 );
4739 RETURN l_output_value;
4740 EXCEPTION
4741 WHEN xla_exceptions_pkg.application_exception THEN
4742 RAISE;
4743 WHEN OTHERS THEN
4744 xla_exceptions_pkg.raise_message
4745 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_33');
4746 END AcctDerRule_33;
4747 --
4748
4749 ---------------------------------------
4750 --
4751 -- PRIVATE FUNCTION
4752 -- AcctDerRule_34
4753 --
4754 ---------------------------------------
4755 FUNCTION AcctDerRule_34 (
4756 p_application_id IN NUMBER
4757 , p_ae_header_id IN NUMBER
4758 , p_side IN VARCHAR2
4759 --Transaction Expense Account
4760 , p_source_60 IN NUMBER
4761 , x_transaction_coa_id OUT NOCOPY NUMBER
4762 , x_accounting_coa_id OUT NOCOPY NUMBER
4763 , x_value_type_code OUT NOCOPY VARCHAR2
4764 )
4765 RETURN NUMBER
4766 IS
4767 l_component_type VARCHAR2(80) ;
4768 l_component_code VARCHAR2(30) ;
4769 l_component_type_code VARCHAR2(1) ;
4770 l_component_appl_id INTEGER ;
4771 l_amb_context_code VARCHAR2(30) ;
4772 l_log_module VARCHAR2(240) ;
4773 l_output_value NUMBER ;
4774 BEGIN
4775 IF g_log_enabled THEN
4776 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_34';
4777 END IF;
4778 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4779 trace
4780 (p_msg => 'BEGIN of AcctDerRule_34'
4781 ,p_level => C_LEVEL_PROCEDURE
4782 ,p_module => l_log_module);
4783 END IF;
4784 --
4785 l_component_type := 'AMB_ADR';
4786 l_component_code := 'PI_TRANSACTION_EXPENSE';
4787 l_component_type_code := 'S';
4788 l_component_appl_id := 707;
4789 l_amb_context_code := 'DEFAULT';
4790 x_transaction_coa_id := null;
4791 x_accounting_coa_id := null;
4792 --
4793
4794 --
4795 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4796 trace
4797 (p_msg => 'END of AcctDerRule_34'
4798 ,p_level => C_LEVEL_PROCEDURE
4799 ,p_module => l_log_module);
4800 END IF;
4801 x_value_type_code := 'S';
4802 l_output_value := TO_NUMBER(TO_NUMBER(p_source_60));
4803 RETURN l_output_value;
4804
4805 --
4806 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4807 trace
4808 (p_msg => 'END of AcctDerRule_34(invalid)'
4809 ,p_level => C_LEVEL_PROCEDURE
4810 ,p_module => l_log_module);
4811 END IF;
4812 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4813 x_value_type_code := null;
4814 l_output_value := null;
4815 xla_accounting_err_pkg.build_message
4816 (p_appli_s_name => 'XLA'
4817 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4818 ,p_token_1 => 'COMPONENT_NAME'
4819 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4820 l_component_type
4821 , l_component_code
4822 , l_component_type_code
4823 , l_component_appl_id
4824 , l_amb_context_code
4825 )
4826 ,p_token_2 => 'OWNER'
4827 ,p_value_2 => xla_lookups_pkg.get_meaning(
4828 'XLA_OWNER_TYPE'
4829 ,l_component_type_code
4830 )
4831 ,p_token_3 => 'PAD_NAME'
4832 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4833 ,p_token_4 => 'PAD_OWNER'
4834 ,p_value_4 => xla_lookups_pkg.get_meaning(
4835 'XLA_OWNER_TYPE'
4836 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
4837 )
4838 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4839 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4840 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
4841 ,p_ae_header_id => NULL
4842 );
4843 RETURN l_output_value;
4844 EXCEPTION
4845 WHEN xla_exceptions_pkg.application_exception THEN
4846 RAISE;
4847 WHEN OTHERS THEN
4848 xla_exceptions_pkg.raise_message
4849 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_34');
4850 END AcctDerRule_34;
4851 --
4852
4853 ---------------------------------------
4854 --
4855 -- PRIVATE FUNCTION
4856 -- AcctDerRule_35
4857 --
4858 ---------------------------------------
4859 FUNCTION AcctDerRule_35 (
4860 p_application_id IN NUMBER
4861 , p_ae_header_id IN NUMBER
4862 , p_side IN VARCHAR2
4863 --Transaction Distribution Account
4864 , p_source_20 IN NUMBER
4865 --Discrete Job Bridging Account
4866 , p_source_54 IN NUMBER
4867 --WIP Entity Type
4868 , p_source_55 IN NUMBER
4869 , p_source_55_meaning IN VARCHAR2
4870 --Flow Schedule Bridging Account
4871 , p_source_56 IN NUMBER
4872 --Repetitive Item Bridging Account
4873 , p_source_57 IN NUMBER
4874 --TRANSACTION_SOURCE_ID
4875 , p_source_61 IN NUMBER
4876 --Transaction Action Name
4877 , p_source_62 IN NUMBER
4878 , p_source_62_meaning IN VARCHAR2
4879 , x_transaction_coa_id OUT NOCOPY NUMBER
4880 , x_accounting_coa_id OUT NOCOPY NUMBER
4881 , x_value_type_code OUT NOCOPY VARCHAR2
4882 )
4883 RETURN NUMBER
4884 IS
4885 l_component_type VARCHAR2(80) ;
4886 l_component_code VARCHAR2(30) ;
4887 l_component_type_code VARCHAR2(1) ;
4888 l_component_appl_id INTEGER ;
4889 l_amb_context_code VARCHAR2(30) ;
4890 l_log_module VARCHAR2(240) ;
4891 l_output_value NUMBER ;
4892 BEGIN
4893 IF g_log_enabled THEN
4894 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_35';
4895 END IF;
4896 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4897 trace
4898 (p_msg => 'BEGIN of AcctDerRule_35'
4899 ,p_level => C_LEVEL_PROCEDURE
4900 ,p_module => l_log_module);
4901 END IF;
4902 --
4903 l_component_type := 'AMB_ADR';
4904 l_component_code := 'PI_WIP_BRIDGING';
4905 l_component_type_code := 'S';
4906 l_component_appl_id := 707;
4907 l_amb_context_code := 'DEFAULT';
4908 x_transaction_coa_id := null;
4909 x_accounting_coa_id := null;
4910 --
4911
4912 IF NVL(p_source_61,9E125) = 5 AND
4913 NVL(p_source_62,9E125) = 30
4914 THEN
4915 --
4916 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4917 trace
4918 (p_msg => 'END of AcctDerRule_35'
4919 ,p_level => C_LEVEL_PROCEDURE
4920 ,p_module => l_log_module);
4921 END IF;
4922 x_value_type_code := 'S';
4923 l_output_value := TO_NUMBER(TO_NUMBER(p_source_20));
4924 RETURN l_output_value;
4925
4926 ELSIF NVL(p_source_55,9E125) = 1 OR
4927 NVL(p_source_55,9E125) = 3 OR
4928 NVL(p_source_55,9E125) = 5 OR
4929 NVL(p_source_55,9E125) = 8
4930 THEN
4931 --
4932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4933 trace
4934 (p_msg => 'END of AcctDerRule_35'
4935 ,p_level => C_LEVEL_PROCEDURE
4936 ,p_module => l_log_module);
4937 END IF;
4938 x_value_type_code := 'S';
4939 l_output_value := TO_NUMBER(TO_NUMBER(p_source_54));
4940 RETURN l_output_value;
4941
4942 ELSIF NVL(p_source_55,9E125) = 4
4943 THEN
4944 --
4945 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4946 trace
4947 (p_msg => 'END of AcctDerRule_35'
4948 ,p_level => C_LEVEL_PROCEDURE
4949 ,p_module => l_log_module);
4950 END IF;
4951 x_value_type_code := 'S';
4952 l_output_value := TO_NUMBER(TO_NUMBER(p_source_56));
4953 RETURN l_output_value;
4954
4955 ELSIF NVL(p_source_55,9E125) = 2
4956 THEN
4957 --
4958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4959 trace
4960 (p_msg => 'END of AcctDerRule_35'
4961 ,p_level => C_LEVEL_PROCEDURE
4962 ,p_module => l_log_module);
4963 END IF;
4964 x_value_type_code := 'S';
4965 l_output_value := TO_NUMBER(TO_NUMBER(p_source_57));
4966 RETURN l_output_value;
4967
4968 END IF;
4969 --
4970 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4971 trace
4972 (p_msg => 'END of AcctDerRule_35(invalid)'
4973 ,p_level => C_LEVEL_PROCEDURE
4974 ,p_module => l_log_module);
4975 END IF;
4976 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4977 x_value_type_code := null;
4978 l_output_value := null;
4979 xla_accounting_err_pkg.build_message
4980 (p_appli_s_name => 'XLA'
4981 ,p_msg_name => 'XLA_AP_INVALID_ADR'
4982 ,p_token_1 => 'COMPONENT_NAME'
4983 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
4984 l_component_type
4985 , l_component_code
4986 , l_component_type_code
4987 , l_component_appl_id
4988 , l_amb_context_code
4989 )
4990 ,p_token_2 => 'OWNER'
4991 ,p_value_2 => xla_lookups_pkg.get_meaning(
4992 'XLA_OWNER_TYPE'
4993 ,l_component_type_code
4994 )
4995 ,p_token_3 => 'PAD_NAME'
4996 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
4997 ,p_token_4 => 'PAD_OWNER'
4998 ,p_value_4 => xla_lookups_pkg.get_meaning(
4999 'XLA_OWNER_TYPE'
5000 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
5001 )
5002 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
5003 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
5004 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
5005 ,p_ae_header_id => NULL
5006 );
5007 RETURN l_output_value;
5008 EXCEPTION
5009 WHEN xla_exceptions_pkg.application_exception THEN
5010 RAISE;
5011 WHEN OTHERS THEN
5012 xla_exceptions_pkg.raise_message
5013 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_35');
5014 END AcctDerRule_35;
5015 --
5016
5017 ---------------------------------------
5018 --
5019 -- PRIVATE FUNCTION
5020 -- AcctDerRule_36
5021 --
5022 ---------------------------------------
5023 FUNCTION AcctDerRule_36 (
5024 p_application_id IN NUMBER
5025 , p_ae_header_id IN NUMBER
5026 , p_side IN VARCHAR2
5027 --Cost Element Name
5028 , p_source_15 IN NUMBER
5029 --WIP Entity Type
5030 , p_source_55 IN NUMBER
5031 , p_source_55_meaning IN VARCHAR2
5032 --Discrete Job Material Account
5033 , p_source_63 IN NUMBER
5034 --Discrete Job Material Overhead Account
5035 , p_source_64 IN NUMBER
5036 --Discrete Job Resource Account
5037 , p_source_65 IN NUMBER
5038 --Discrete Job Outside Processing Account
5039 , p_source_66 IN NUMBER
5040 --Discrete Job Overhead Account
5041 , p_source_67 IN NUMBER
5042 --Repetitive Schedule Material Account
5043 , p_source_68 IN NUMBER
5044 --Repetitive Schedule Material Overhead Account
5045 , p_source_69 IN NUMBER
5046 --Repetitive Schedule Resource Account
5047 , p_source_70 IN NUMBER
5048 --Repetitive Schedule Outside Processing Account
5049 , p_source_71 IN NUMBER
5050 --Repetitive Schedule Overhead Account
5051 , p_source_72 IN NUMBER
5052 --Flow Schedule Material Account
5053 , p_source_73 IN NUMBER
5054 --Flow Schedule Material Overhead Account
5055 , p_source_74 IN NUMBER
5056 --Flow Schedule Resource Account
5057 , p_source_75 IN NUMBER
5058 --Flow Schedule Outside Processing Account
5059 , p_source_76 IN NUMBER
5060 --Flow Schedule Overhead Account
5061 , p_source_77 IN NUMBER
5062 , x_transaction_coa_id OUT NOCOPY NUMBER
5063 , x_accounting_coa_id OUT NOCOPY NUMBER
5064 , x_value_type_code OUT NOCOPY VARCHAR2
5065 )
5066 RETURN NUMBER
5067 IS
5068 l_component_type VARCHAR2(80) ;
5069 l_component_code VARCHAR2(30) ;
5070 l_component_type_code VARCHAR2(1) ;
5071 l_component_appl_id INTEGER ;
5072 l_amb_context_code VARCHAR2(30) ;
5073 l_log_module VARCHAR2(240) ;
5074 l_output_value NUMBER ;
5075 BEGIN
5076 IF g_log_enabled THEN
5077 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_36';
5078 END IF;
5079 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5080 trace
5081 (p_msg => 'BEGIN of AcctDerRule_36'
5082 ,p_level => C_LEVEL_PROCEDURE
5083 ,p_module => l_log_module);
5084 END IF;
5085 --
5086 l_component_type := 'AMB_ADR';
5087 l_component_code := 'PI_WIP_VALUATION';
5088 l_component_type_code := 'S';
5089 l_component_appl_id := 707;
5090 l_amb_context_code := 'DEFAULT';
5091 x_transaction_coa_id := null;
5092 x_accounting_coa_id := null;
5093 --
5094
5095 IF (NVL(p_source_55,9E125) = 1 OR
5096 NVL(p_source_55,9E125) = 3 OR
5097 NVL(p_source_55,9E125) = 5 OR
5098 NVL(p_source_55,9E125) = 8) AND
5099 NVL(p_source_15,9E125) = 1
5100 THEN
5101 --
5102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5103 trace
5104 (p_msg => 'END of AcctDerRule_36'
5105 ,p_level => C_LEVEL_PROCEDURE
5106 ,p_module => l_log_module);
5107 END IF;
5108 x_value_type_code := 'S';
5109 l_output_value := TO_NUMBER(TO_NUMBER(p_source_63));
5110 RETURN l_output_value;
5111
5112 ELSIF (NVL(p_source_55,9E125) = 1 OR
5113 NVL(p_source_55,9E125) = 3 OR
5114 NVL(p_source_55,9E125) = 5 OR
5115 NVL(p_source_55,9E125) = 8) AND
5116 NVL(p_source_15,9E125) = 2
5117 THEN
5118 --
5119 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5120 trace
5121 (p_msg => 'END of AcctDerRule_36'
5122 ,p_level => C_LEVEL_PROCEDURE
5123 ,p_module => l_log_module);
5124 END IF;
5125 x_value_type_code := 'S';
5126 l_output_value := TO_NUMBER(TO_NUMBER(p_source_64));
5127 RETURN l_output_value;
5128
5129 ELSIF (NVL(p_source_55,9E125) = 1 OR
5130 NVL(p_source_55,9E125) = 3 OR
5131 NVL(p_source_55,9E125) = 5 OR
5132 NVL(p_source_55,9E125) = 8) AND
5133 NVL(p_source_15,9E125) = 3
5134 THEN
5135 --
5136 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5137 trace
5138 (p_msg => 'END of AcctDerRule_36'
5139 ,p_level => C_LEVEL_PROCEDURE
5140 ,p_module => l_log_module);
5141 END IF;
5142 x_value_type_code := 'S';
5143 l_output_value := TO_NUMBER(TO_NUMBER(p_source_65));
5144 RETURN l_output_value;
5145
5146 ELSIF (NVL(p_source_55,9E125) = 1 OR
5147 NVL(p_source_55,9E125) = 3 OR
5148 NVL(p_source_55,9E125) = 5 OR
5149 NVL(p_source_55,9E125) = 8) AND
5150 NVL(p_source_15,9E125) = 4
5151 THEN
5152 --
5153 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5154 trace
5155 (p_msg => 'END of AcctDerRule_36'
5156 ,p_level => C_LEVEL_PROCEDURE
5157 ,p_module => l_log_module);
5158 END IF;
5159 x_value_type_code := 'S';
5160 l_output_value := TO_NUMBER(TO_NUMBER(p_source_66));
5161 RETURN l_output_value;
5162
5163 ELSIF (NVL(p_source_55,9E125) = 1 OR
5164 NVL(p_source_55,9E125) = 3 OR
5165 NVL(p_source_55,9E125) = 5 OR
5166 NVL(p_source_55,9E125) = 8) AND
5167 NVL(p_source_15,9E125) = 5
5168 THEN
5169 --
5170 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5171 trace
5172 (p_msg => 'END of AcctDerRule_36'
5173 ,p_level => C_LEVEL_PROCEDURE
5174 ,p_module => l_log_module);
5175 END IF;
5176 x_value_type_code := 'S';
5177 l_output_value := TO_NUMBER(TO_NUMBER(p_source_67));
5178 RETURN l_output_value;
5179
5180 ELSIF NVL(p_source_55,9E125) = 2 AND
5181 NVL(p_source_15,9E125) = 1
5182 THEN
5183 --
5184 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5185 trace
5186 (p_msg => 'END of AcctDerRule_36'
5187 ,p_level => C_LEVEL_PROCEDURE
5188 ,p_module => l_log_module);
5189 END IF;
5190 x_value_type_code := 'S';
5191 l_output_value := TO_NUMBER(TO_NUMBER(p_source_68));
5192 RETURN l_output_value;
5193
5194 ELSIF NVL(p_source_55,9E125) = 2 AND
5195 NVL(p_source_15,9E125) = 2
5196 THEN
5197 --
5198 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5199 trace
5200 (p_msg => 'END of AcctDerRule_36'
5201 ,p_level => C_LEVEL_PROCEDURE
5202 ,p_module => l_log_module);
5203 END IF;
5204 x_value_type_code := 'S';
5205 l_output_value := TO_NUMBER(TO_NUMBER(p_source_69));
5206 RETURN l_output_value;
5207
5208 ELSIF NVL(p_source_55,9E125) = 2 AND
5209 NVL(p_source_15,9E125) = 3
5210 THEN
5211 --
5212 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5213 trace
5214 (p_msg => 'END of AcctDerRule_36'
5215 ,p_level => C_LEVEL_PROCEDURE
5216 ,p_module => l_log_module);
5217 END IF;
5218 x_value_type_code := 'S';
5219 l_output_value := TO_NUMBER(TO_NUMBER(p_source_70));
5220 RETURN l_output_value;
5221
5222 ELSIF NVL(p_source_55,9E125) = 2 AND
5223 NVL(p_source_15,9E125) = 4
5224 THEN
5225 --
5226 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5227 trace
5228 (p_msg => 'END of AcctDerRule_36'
5229 ,p_level => C_LEVEL_PROCEDURE
5230 ,p_module => l_log_module);
5231 END IF;
5232 x_value_type_code := 'S';
5233 l_output_value := TO_NUMBER(TO_NUMBER(p_source_71));
5234 RETURN l_output_value;
5235
5236 ELSIF NVL(p_source_55,9E125) = 2 AND
5237 NVL(p_source_15,9E125) = 5
5238 THEN
5239 --
5240 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5241 trace
5242 (p_msg => 'END of AcctDerRule_36'
5243 ,p_level => C_LEVEL_PROCEDURE
5244 ,p_module => l_log_module);
5245 END IF;
5246 x_value_type_code := 'S';
5247 l_output_value := TO_NUMBER(TO_NUMBER(p_source_72));
5248 RETURN l_output_value;
5249
5250 ELSIF NVL(p_source_55,9E125) = 4 AND
5251 NVL(p_source_15,9E125) = 1
5252 THEN
5253 --
5254 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5255 trace
5256 (p_msg => 'END of AcctDerRule_36'
5257 ,p_level => C_LEVEL_PROCEDURE
5258 ,p_module => l_log_module);
5259 END IF;
5260 x_value_type_code := 'S';
5261 l_output_value := TO_NUMBER(TO_NUMBER(p_source_73));
5262 RETURN l_output_value;
5263
5264 ELSIF NVL(p_source_55,9E125) = 4 AND
5265 NVL(p_source_15,9E125) = 2
5266 THEN
5267 --
5268 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5269 trace
5270 (p_msg => 'END of AcctDerRule_36'
5271 ,p_level => C_LEVEL_PROCEDURE
5272 ,p_module => l_log_module);
5273 END IF;
5274 x_value_type_code := 'S';
5275 l_output_value := TO_NUMBER(TO_NUMBER(p_source_74));
5276 RETURN l_output_value;
5277
5278 ELSIF NVL(p_source_55,9E125) = 4 AND
5279 NVL(p_source_15,9E125) = 3
5280 THEN
5281 --
5282 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5283 trace
5284 (p_msg => 'END of AcctDerRule_36'
5285 ,p_level => C_LEVEL_PROCEDURE
5286 ,p_module => l_log_module);
5287 END IF;
5288 x_value_type_code := 'S';
5289 l_output_value := TO_NUMBER(TO_NUMBER(p_source_75));
5290 RETURN l_output_value;
5291
5292 ELSIF NVL(p_source_55,9E125) = 4 AND
5293 NVL(p_source_15,9E125) = 4
5294 THEN
5295 --
5296 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5297 trace
5298 (p_msg => 'END of AcctDerRule_36'
5299 ,p_level => C_LEVEL_PROCEDURE
5300 ,p_module => l_log_module);
5301 END IF;
5302 x_value_type_code := 'S';
5303 l_output_value := TO_NUMBER(TO_NUMBER(p_source_76));
5304 RETURN l_output_value;
5305
5306 ELSIF NVL(p_source_55,9E125) = 4 AND
5307 NVL(p_source_15,9E125) = 5
5308 THEN
5309 --
5310 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5311 trace
5312 (p_msg => 'END of AcctDerRule_36'
5313 ,p_level => C_LEVEL_PROCEDURE
5314 ,p_module => l_log_module);
5315 END IF;
5316 x_value_type_code := 'S';
5317 l_output_value := TO_NUMBER(TO_NUMBER(p_source_77));
5318 RETURN l_output_value;
5319
5320 END IF;
5321 --
5322 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5323 trace
5324 (p_msg => 'END of AcctDerRule_36(invalid)'
5325 ,p_level => C_LEVEL_PROCEDURE
5326 ,p_module => l_log_module);
5327 END IF;
5328 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
5329 x_value_type_code := null;
5330 l_output_value := null;
5331 xla_accounting_err_pkg.build_message
5332 (p_appli_s_name => 'XLA'
5333 ,p_msg_name => 'XLA_AP_INVALID_ADR'
5334 ,p_token_1 => 'COMPONENT_NAME'
5335 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
5336 l_component_type
5337 , l_component_code
5338 , l_component_type_code
5339 , l_component_appl_id
5340 , l_amb_context_code
5341 )
5342 ,p_token_2 => 'OWNER'
5343 ,p_value_2 => xla_lookups_pkg.get_meaning(
5344 'XLA_OWNER_TYPE'
5345 ,l_component_type_code
5346 )
5347 ,p_token_3 => 'PAD_NAME'
5348 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
5349 ,p_token_4 => 'PAD_OWNER'
5350 ,p_value_4 => xla_lookups_pkg.get_meaning(
5351 'XLA_OWNER_TYPE'
5352 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
5353 )
5354 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
5355 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
5356 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
5357 ,p_ae_header_id => NULL
5358 );
5359 RETURN l_output_value;
5360 EXCEPTION
5361 WHEN xla_exceptions_pkg.application_exception THEN
5362 RAISE;
5363 WHEN OTHERS THEN
5364 xla_exceptions_pkg.raise_message
5365 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctDerRule_36');
5366 END AcctDerRule_36;
5367 --
5368
5369 ---------------------------------------
5370 --
5371 -- PRIVATE FUNCTION
5372 -- AcctLineType_37
5373 --
5374 ---------------------------------------
5375 PROCEDURE AcctLineType_37 (
5376 p_application_id IN NUMBER
5377 ,p_event_id IN NUMBER
5378 ,p_calculate_acctd_flag IN VARCHAR2
5379 ,p_calculate_g_l_flag IN VARCHAR2
5380 ,p_actual_flag IN OUT VARCHAR2
5381 ,p_balance_type_code OUT VARCHAR2
5382 ,p_gain_or_loss_ref OUT VARCHAR2
5383
5384 --Cost Management Default Account
5385 , p_source_11 IN NUMBER
5386 --Receiving Accounting Line Type
5387 , p_source_78 IN VARCHAR2
5388 --Applied to Application ID
5389 , p_source_79 IN NUMBER
5390 --Applied to Distribution Link Type
5391 , p_source_80 IN VARCHAR2
5392 --Applied to Entity Code
5393 , p_source_81 IN VARCHAR2
5394 --PO_DISTRIBUTION_ID
5395 , p_source_82 IN NUMBER
5396 --Applied To Purchase Document Identifier
5397 , p_source_83 IN NUMBER
5398 --DISTRIBUTION_IDENTIFIER
5399 , p_source_84 IN NUMBER
5400 --Distribution Type
5401 , p_source_85 IN VARCHAR2
5402 , p_source_85_meaning IN VARCHAR2
5403 --PO Budget Account
5404 , p_source_86 IN NUMBER
5405 --Encumbrance Reversal Amount Entered
5406 , p_source_87 IN NUMBER
5407 --Entered Currency Code
5408 , p_source_88 IN VARCHAR2
5409 --Transaction Encumbrance Reversal Amount
5410 , p_source_89 IN NUMBER
5411 --Costing Period End Accrual Encumbrance Upgrade Option
5412 , p_source_90 IN VARCHAR2
5413 --Entered Amount
5414 , p_source_91 IN NUMBER
5415 --Currency Conversion Date
5416 , p_source_92 IN DATE
5417 --Currency Conversion Rate
5418 , p_source_93 IN NUMBER
5419 --Currency Conversion Type
5420 , p_source_94 IN VARCHAR2
5421 --Accounted Amount
5422 , p_source_95 IN NUMBER
5423 --Purchasing Encumbrance Type Identifier
5424 , p_source_96 IN NUMBER
5425 )
5426 IS
5427
5428 l_component_type VARCHAR2(80);
5429 l_component_code VARCHAR2(30);
5430 l_component_type_code VARCHAR2(1);
5431 l_component_appl_id INTEGER;
5432 l_amb_context_code VARCHAR2(30);
5433 l_entity_code VARCHAR2(30);
5434 l_event_class_code VARCHAR2(30);
5435 l_ae_header_id NUMBER;
5436 l_event_type_code VARCHAR2(30);
5437 l_line_definition_code VARCHAR2(30);
5438 l_line_definition_owner_code VARCHAR2(1);
5439 --
5440 -- adr variables
5441 l_segment VARCHAR2(30);
5442 l_ccid NUMBER;
5443 l_adr_transaction_coa_id NUMBER;
5444 l_adr_accounting_coa_id NUMBER;
5445 l_adr_flexfield_segment_code VARCHAR2(30);
5446 l_adr_flex_value_set_id NUMBER;
5447 l_adr_value_type_code VARCHAR2(30);
5448 l_adr_value_combination_id NUMBER;
5449 l_adr_value_segment_code VARCHAR2(30);
5450
5451 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5452 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5453 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5454 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5455
5456 -- 4262811 Variables ------------------------------------------------------------------------------------------
5457 l_entered_amt_idx NUMBER;
5458 l_accted_amt_idx NUMBER;
5459 l_acc_rev_flag VARCHAR2(1);
5460 l_accrual_line_num NUMBER;
5461 l_tmp_amt NUMBER;
5462 l_acc_rev_natural_side_code VARCHAR2(1);
5463
5464 l_num_entries NUMBER;
5465 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5466 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5467 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5468 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5469 l_recog_line_1 NUMBER;
5470 l_recog_line_2 NUMBER;
5471
5472 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5473 l_bflow_applied_to_amt NUMBER; -- 5132302
5474 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5475
5476 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5477
5478 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5479 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5480
5481 ---------------------------------------------------------------------------------------------------------------
5482
5483
5484 --
5485 -- bulk performance
5486 --
5487 l_balance_type_code VARCHAR2(1);
5488 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5489 l_log_module VARCHAR2(240);
5490
5491 --
5492 -- Upgrade strategy
5493 --
5494 l_actual_upg_option VARCHAR2(1);
5495 l_enc_upg_option VARCHAR2(1);
5496
5497 --
5498 BEGIN
5499 --
5500 IF g_log_enabled THEN
5501 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_37';
5502 END IF;
5503 --
5504 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5505
5506 trace
5507 (p_msg => 'BEGIN of AcctLineType_37'
5508 ,p_level => C_LEVEL_PROCEDURE
5509 ,p_module => l_log_module);
5510
5511 END IF;
5512 --
5513 l_component_type := 'AMB_JLT';
5514 l_component_code := 'ACCRUAL';
5515 l_component_type_code := 'S';
5516 l_component_appl_id := 707;
5517 l_amb_context_code := 'DEFAULT';
5518 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
5519 l_event_class_code := 'PERIOD_END_ACCRUAL';
5520 l_event_type_code := 'PERIOD_END_ACCRUAL_ALL';
5521 l_line_definition_owner_code := 'S';
5522 l_line_definition_code := 'PERIOD_END_ACCRUAL';
5523 --
5524 l_balance_type_code := 'A';
5525 l_segment := NULL;
5526 l_ccid := NULL;
5527 l_adr_transaction_coa_id := NULL;
5528 l_adr_accounting_coa_id := NULL;
5529 l_adr_flexfield_segment_code := NULL;
5530 l_adr_flex_value_set_id := NULL;
5531 l_adr_value_type_code := NULL;
5532 l_adr_value_combination_id := NULL;
5533 l_adr_value_segment_code := NULL;
5534
5535 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5536 l_bflow_class_code := ''; -- 4219869 Business Flow
5537 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5538 l_budgetary_control_flag := 'N';
5539
5540 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5541 l_bflow_applied_to_amt := NULL; -- 5132302
5542 l_entered_amt_idx := NULL; -- 4262811
5543 l_accted_amt_idx := NULL; -- 4262811
5544 l_acc_rev_flag := NULL; -- 4262811
5545 l_accrual_line_num := NULL; -- 4262811
5546 l_tmp_amt := NULL; -- 4262811
5547 --
5548
5549 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5550 l_balance_type_code <> 'B' THEN
5551 IF NVL(p_source_78,'
5552 ') = 'Accrual'
5553 THEN
5554
5555 --
5556 XLA_AE_LINES_PKG.SetNewLine;
5557
5558 p_balance_type_code := l_balance_type_code;
5559 -- set the flag so later we will know whether the gain loss line needs to be created
5560
5561 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5562 p_actual_flag :='A';
5563 END IF;
5564
5565 --
5566 -- bulk performance
5567 --
5568 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5569 p_header_num => 0); -- 4262811
5570 --
5571 -- set accounting line options
5572 --
5573 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5574 p_natural_side_code => 'D'
5575 , p_gain_or_loss_flag => 'N'
5576 , p_gl_transfer_mode_code => 'S'
5577 , p_acct_entry_type_code => 'A'
5578 , p_switch_side_flag => 'Y'
5579 , p_merge_duplicate_code => 'N'
5580 );
5581 --
5582 l_acc_rev_natural_side_code := 'C'; -- 4262811
5583 --
5584 --
5585 -- set accounting line type info
5586 --
5587 xla_ae_lines_pkg.SetAcctLineType
5588 (p_component_type => l_component_type
5589 ,p_event_type_code => l_event_type_code
5590 ,p_line_definition_owner_code => l_line_definition_owner_code
5591 ,p_line_definition_code => l_line_definition_code
5592 ,p_accounting_line_code => l_component_code
5593 ,p_accounting_line_type_code => l_component_type_code
5594 ,p_accounting_line_appl_id => l_component_appl_id
5595 ,p_amb_context_code => l_amb_context_code
5596 ,p_entity_code => l_entity_code
5597 ,p_event_class_code => l_event_class_code);
5598 --
5599 -- set accounting class
5600 --
5601 xla_ae_lines_pkg.SetAcctClass(
5602 p_accounting_class_code => 'ACCRUAL'
5603 , p_ae_header_id => l_ae_header_id
5604 );
5605
5606 --
5607 -- set rounding class
5608 --
5609 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5610 'ACCRUAL';
5611
5612 --
5613 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5614 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5615 --
5616 -- bulk performance
5617 --
5618 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5619
5620 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5621 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5622
5623 -- 4955764
5624 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5625 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5626
5627 -- 4458381 Public Sector Enh
5628
5629 --
5630 -- set accounting attributes for the line type
5631 --
5632 l_entered_amt_idx := 17;
5633 l_accted_amt_idx := 22;
5634 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5635 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
5636 l_rec_acct_attrs.array_num_value(1) := p_source_79;
5637 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
5638 l_rec_acct_attrs.array_char_value(2) := p_source_80;
5639 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
5640 l_rec_acct_attrs.array_char_value(3) := p_source_81;
5641 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
5642 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_82);
5643 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
5644 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
5645 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
5646 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
5647 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
5648 l_rec_acct_attrs.array_char_value(7) := p_source_85;
5649 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
5650 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
5651 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
5652 l_rec_acct_attrs.array_num_value(9) := p_source_87;
5653 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
5654 l_rec_acct_attrs.array_char_value(10) := p_source_88;
5655 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
5656 l_rec_acct_attrs.array_num_value(11) := p_source_89;
5657 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
5658 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
5659 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
5660 l_rec_acct_attrs.array_num_value(13) := p_source_87;
5661 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
5662 l_rec_acct_attrs.array_char_value(14) := p_source_88;
5663 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
5664 l_rec_acct_attrs.array_num_value(15) := p_source_89;
5665 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
5666 l_rec_acct_attrs.array_char_value(16) := p_source_90;
5667 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
5668 l_rec_acct_attrs.array_num_value(17) := p_source_91;
5669 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
5670 l_rec_acct_attrs.array_char_value(18) := p_source_88;
5671 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
5672 l_rec_acct_attrs.array_date_value(19) := p_source_92;
5673 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
5674 l_rec_acct_attrs.array_num_value(20) := p_source_93;
5675 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
5676 l_rec_acct_attrs.array_char_value(21) := p_source_94;
5677 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
5678 l_rec_acct_attrs.array_num_value(22) := p_source_95;
5679 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
5680 l_rec_acct_attrs.array_num_value(23) := p_source_96;
5681 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
5682 l_rec_acct_attrs.array_num_value(24) := p_source_96;
5683
5684 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5685 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5686
5687 ---------------------------------------------------------------------------------------------------------------
5688 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5689 ---------------------------------------------------------------------------------------------------------------
5690 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5691
5692 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5693 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5694
5695 IF xla_accounting_cache_pkg.GetValueChar
5696 (p_source_code => 'LEDGER_CATEGORY_CODE'
5697 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5698 AND l_bflow_method_code = 'PRIOR_ENTRY'
5699 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5700 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5701 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5702 )
5703 THEN
5704 xla_ae_lines_pkg.BflowUpgEntry
5705 (p_business_method_code => l_bflow_method_code
5706 ,p_business_class_code => l_bflow_class_code
5707 ,p_balance_type => l_balance_type_code);
5708 ELSE
5709 NULL;
5710 -- No business flow processing for business flow method of NONE.
5711 END IF;
5712
5713 --
5714 -- call analytical criteria
5715 --
5716
5717 --
5718 -- call description
5719 --
5720 -- No description or it is inherited.
5721 --
5722 -- call ADRs
5723 -- Bug 4922099
5724 --
5725 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5726 (NVL(l_actual_upg_option, 'N') = 'O') OR
5727 (NVL(l_enc_upg_option, 'N') = 'O')
5728 )
5729 THEN
5730 NULL;
5731 --
5732 --
5733
5734 l_ccid := AcctDerRule_6(
5735 p_application_id => p_application_id
5736 , p_ae_header_id => l_ae_header_id
5737 , p_source_11 => p_source_11
5738 , x_transaction_coa_id => l_adr_transaction_coa_id
5739 , x_accounting_coa_id => l_adr_accounting_coa_id
5740 , x_value_type_code => l_adr_value_type_code
5741 , p_side => 'NA'
5742 );
5743
5744 xla_ae_lines_pkg.set_ccid(
5745 p_code_combination_id => l_ccid
5746 , p_value_type_code => l_adr_value_type_code
5747 , p_transaction_coa_id => l_adr_transaction_coa_id
5748 , p_accounting_coa_id => l_adr_accounting_coa_id
5749 , p_adr_code => 'CST_DEFAULT'
5750 , p_adr_type_code => 'S'
5751 , p_component_type => l_component_type
5752 , p_component_code => l_component_code
5753 , p_component_type_code => l_component_type_code
5754 , p_component_appl_id => l_component_appl_id
5755 , p_amb_context_code => l_amb_context_code
5756 , p_side => 'NA'
5757 );
5758
5759
5760 --
5761 --
5762 END IF;
5763 --
5764 -- Bug 4922099
5765 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5766 (NVL(l_enc_upg_option, 'N') = 'O')
5767 ) AND
5768 (l_bflow_method_code = 'PRIOR_ENTRY')
5769 )
5770 THEN
5771 IF
5772 --
5773 1 = 2
5774 --
5775 THEN
5776 xla_accounting_err_pkg.build_message
5777 (p_appli_s_name => 'XLA'
5778 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5779 ,p_token_1 => 'LINE_NUMBER'
5780 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5781 ,p_token_2 => 'LINE_TYPE_NAME'
5782 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5783 l_component_type
5784 ,l_component_code
5785 ,l_component_type_code
5786 ,l_component_appl_id
5787 ,l_amb_context_code
5788 ,l_entity_code
5789 ,l_event_class_code
5790 )
5791 ,p_token_3 => 'OWNER'
5792 ,p_value_3 => xla_lookups_pkg.get_meaning(
5793 p_lookup_type => 'XLA_OWNER_TYPE'
5794 ,p_lookup_code => l_component_type_code
5795 )
5796 ,p_token_4 => 'PRODUCT_NAME'
5797 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5798 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5799 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5800 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5801 ,p_ae_header_id => NULL
5802 );
5803
5804 IF (C_LEVEL_ERROR>= g_log_level) THEN
5805 trace
5806 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5807 ,p_level => C_LEVEL_ERROR
5808 ,p_module => l_log_module);
5809 END IF;
5810 END IF;
5811 END IF;
5812 --
5813 --
5814 ------------------------------------------------------------------------------------------------
5815 -- 4219869 Business Flow
5816 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5817 -- Prior Entry. Currently, the following code is always generated.
5818 ------------------------------------------------------------------------------------------------
5819 XLA_AE_LINES_PKG.ValidateCurrentLine;
5820
5821 ------------------------------------------------------------------------------------
5822 -- 4219869 Business Flow
5823 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5824 ------------------------------------------------------------------------------------
5825 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5826
5827 ----------------------------------------------------------------------------------
5828 -- 4219869 Business Flow
5829 -- Update journal entry status -- Need to generate this within IF <condition>
5830 ----------------------------------------------------------------------------------
5831 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5832 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5833 ,p_balance_type_code => l_balance_type_code
5834 );
5835
5836 -------------------------------------------------------------------------------------------
5837 -- 4262811 - Generate the Accrual Reversal lines
5838 -------------------------------------------------------------------------------------------
5839 BEGIN
5840 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5841 (g_array_event(p_event_id).array_value_num('header_index'));
5842 IF l_acc_rev_flag IS NULL THEN
5843 l_acc_rev_flag := 'N';
5844 END IF;
5845 EXCEPTION
5846 WHEN OTHERS THEN
5847 l_acc_rev_flag := 'N';
5848 END;
5849 --
5850 IF (l_acc_rev_flag = 'Y') THEN
5851
5852 -- 4645092 ------------------------------------------------------------------------------
5853 -- To allow MPA report to determine if it should generate report process
5854 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5855 ------------------------------------------------------------------------------------------
5856
5857 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5858 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5859 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5860 -- call ADRs
5861 -- Bug 4922099
5862 --
5863 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5864 (NVL(l_actual_upg_option, 'N') = 'O') OR
5865 (NVL(l_enc_upg_option, 'N') = 'O')
5866 )
5867 THEN
5868 NULL;
5869 --
5870 --
5871
5872 l_ccid := AcctDerRule_6(
5873 p_application_id => p_application_id
5874 , p_ae_header_id => l_ae_header_id
5875 , p_source_11 => p_source_11
5876 , x_transaction_coa_id => l_adr_transaction_coa_id
5877 , x_accounting_coa_id => l_adr_accounting_coa_id
5878 , x_value_type_code => l_adr_value_type_code
5879 , p_side => 'NA'
5880 );
5881
5882 xla_ae_lines_pkg.set_ccid(
5883 p_code_combination_id => l_ccid
5884 , p_value_type_code => l_adr_value_type_code
5885 , p_transaction_coa_id => l_adr_transaction_coa_id
5886 , p_accounting_coa_id => l_adr_accounting_coa_id
5887 , p_adr_code => 'CST_DEFAULT'
5888 , p_adr_type_code => 'S'
5889 , p_component_type => l_component_type
5890 , p_component_code => l_component_code
5891 , p_component_type_code => l_component_type_code
5892 , p_component_appl_id => l_component_appl_id
5893 , p_amb_context_code => l_amb_context_code
5894 , p_side => 'NA'
5895 );
5896
5897
5898 --
5899 --
5900 END IF;
5901
5902 --
5903 -- Update the line information that should be overwritten
5904 --
5905 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5906 p_header_num => 1);
5907 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5908
5909 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5910
5911 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5912 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5913 END IF;
5914
5915 --
5916 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5917 --
5918 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5919 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5920 ELSE
5921 ---------------------------------------------------------------------------------------------------
5922 -- 4262811a Switch Sign
5923 ---------------------------------------------------------------------------------------------------
5924 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5925 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5926 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5927 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5928 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5929 -- 5132302
5930 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5931 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5932
5933 END IF;
5934
5935 -- 4955764
5936 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5937 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5938
5939
5940 XLA_AE_LINES_PKG.ValidateCurrentLine;
5941 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5942
5943 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5944 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5945 ,p_balance_type_code => l_balance_type_code);
5946
5947 END IF;
5948
5949 -----------------------------------------------------------------------------------------
5950 -- 4262811 Multiperiod Accounting
5951 -----------------------------------------------------------------------------------------
5952 -- No MPA option is assigned.
5953
5954
5955 END IF;
5956 END IF;
5957 --
5958
5959 --
5960 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5961 trace
5962 (p_msg => 'END of AcctLineType_37'
5963 ,p_level => C_LEVEL_PROCEDURE
5964 ,p_module => l_log_module);
5965 END IF;
5966 --
5967 EXCEPTION
5968 WHEN xla_exceptions_pkg.application_exception THEN
5969 RAISE;
5970 WHEN OTHERS THEN
5971 xla_exceptions_pkg.raise_message
5972 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_37');
5973 END AcctLineType_37;
5974 --
5975
5976 ---------------------------------------
5977 --
5978 -- PRIVATE FUNCTION
5979 -- AcctLineType_38
5980 --
5981 ---------------------------------------
5982 PROCEDURE AcctLineType_38 (
5983 p_application_id IN NUMBER
5984 ,p_event_id IN NUMBER
5985 ,p_calculate_acctd_flag IN VARCHAR2
5986 ,p_calculate_g_l_flag IN VARCHAR2
5987 ,p_actual_flag IN OUT VARCHAR2
5988 ,p_balance_type_code OUT VARCHAR2
5989 ,p_gain_or_loss_ref OUT VARCHAR2
5990
5991 --TRANSACTION_ID
5992 , p_source_1 IN NUMBER
5993 --Item Concatenated Segments
5994 , p_source_2 IN VARCHAR2
5995 --Transaction Quantity
5996 , p_source_3 IN NUMBER
5997 --Transaction Unit of Measure Code
5998 , p_source_4 IN VARCHAR2
5999 --Inventory Transaction Type Description
6000 , p_source_5 IN VARCHAR2
6001 --Transaction Distribution Account
6002 , p_source_20 IN NUMBER
6003 --DISTRIBUTION_IDENTIFIER
6004 , p_source_84 IN NUMBER
6005 --Distribution Type
6006 , p_source_85 IN VARCHAR2
6007 , p_source_85_meaning IN VARCHAR2
6008 --Entered Currency Code
6009 , p_source_88 IN VARCHAR2
6010 --Entered Amount
6011 , p_source_91 IN NUMBER
6012 --Currency Conversion Date
6013 , p_source_92 IN DATE
6014 --Currency Conversion Rate
6015 , p_source_93 IN NUMBER
6016 --Currency Conversion Type
6017 , p_source_94 IN VARCHAR2
6018 --Accounted Amount
6019 , p_source_95 IN NUMBER
6020 --Accounting Line Type
6021 , p_source_97 IN NUMBER
6022 )
6023 IS
6024
6025 l_component_type VARCHAR2(80);
6026 l_component_code VARCHAR2(30);
6027 l_component_type_code VARCHAR2(1);
6028 l_component_appl_id INTEGER;
6029 l_amb_context_code VARCHAR2(30);
6030 l_entity_code VARCHAR2(30);
6031 l_event_class_code VARCHAR2(30);
6032 l_ae_header_id NUMBER;
6033 l_event_type_code VARCHAR2(30);
6034 l_line_definition_code VARCHAR2(30);
6035 l_line_definition_owner_code VARCHAR2(1);
6036 --
6037 -- adr variables
6038 l_segment VARCHAR2(30);
6039 l_ccid NUMBER;
6040 l_adr_transaction_coa_id NUMBER;
6041 l_adr_accounting_coa_id NUMBER;
6042 l_adr_flexfield_segment_code VARCHAR2(30);
6043 l_adr_flex_value_set_id NUMBER;
6044 l_adr_value_type_code VARCHAR2(30);
6045 l_adr_value_combination_id NUMBER;
6046 l_adr_value_segment_code VARCHAR2(30);
6047
6048 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6049 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6050 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6051 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6052
6053 -- 4262811 Variables ------------------------------------------------------------------------------------------
6054 l_entered_amt_idx NUMBER;
6055 l_accted_amt_idx NUMBER;
6056 l_acc_rev_flag VARCHAR2(1);
6057 l_accrual_line_num NUMBER;
6058 l_tmp_amt NUMBER;
6059 l_acc_rev_natural_side_code VARCHAR2(1);
6060
6061 l_num_entries NUMBER;
6062 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6063 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6064 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6065 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6066 l_recog_line_1 NUMBER;
6067 l_recog_line_2 NUMBER;
6068
6069 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6070 l_bflow_applied_to_amt NUMBER; -- 5132302
6071 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6072
6073 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6074
6075 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6076 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6077
6078 ---------------------------------------------------------------------------------------------------------------
6079
6080
6081 --
6082 -- bulk performance
6083 --
6084 l_balance_type_code VARCHAR2(1);
6085 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6086 l_log_module VARCHAR2(240);
6087
6088 --
6089 -- Upgrade strategy
6090 --
6091 l_actual_upg_option VARCHAR2(1);
6092 l_enc_upg_option VARCHAR2(1);
6093
6094 --
6095 BEGIN
6096 --
6097 IF g_log_enabled THEN
6098 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_38';
6099 END IF;
6100 --
6101 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6102
6103 trace
6104 (p_msg => 'BEGIN of AcctLineType_38'
6105 ,p_level => C_LEVEL_PROCEDURE
6106 ,p_module => l_log_module);
6107
6108 END IF;
6109 --
6110 l_component_type := 'AMB_JLT';
6111 l_component_code := 'ACCRUAL';
6112 l_component_type_code := 'S';
6113 l_component_appl_id := 707;
6114 l_amb_context_code := 'DEFAULT';
6115 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
6116 l_event_class_code := 'CON_INV_OWNR_TXFR';
6117 l_event_type_code := 'CON_INV_OWNR_TXFR_ALL';
6118 l_line_definition_owner_code := 'S';
6119 l_line_definition_code := 'PI_CON_INV_OWNR_TRFR';
6120 --
6121 l_balance_type_code := 'A';
6122 l_segment := NULL;
6123 l_ccid := NULL;
6124 l_adr_transaction_coa_id := NULL;
6125 l_adr_accounting_coa_id := NULL;
6126 l_adr_flexfield_segment_code := NULL;
6127 l_adr_flex_value_set_id := NULL;
6128 l_adr_value_type_code := NULL;
6129 l_adr_value_combination_id := NULL;
6130 l_adr_value_segment_code := NULL;
6131
6132 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6133 l_bflow_class_code := ''; -- 4219869 Business Flow
6134 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6135 l_budgetary_control_flag := 'N';
6136
6137 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6138 l_bflow_applied_to_amt := NULL; -- 5132302
6139 l_entered_amt_idx := NULL; -- 4262811
6140 l_accted_amt_idx := NULL; -- 4262811
6141 l_acc_rev_flag := NULL; -- 4262811
6142 l_accrual_line_num := NULL; -- 4262811
6143 l_tmp_amt := NULL; -- 4262811
6144 --
6145
6146 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6147 l_balance_type_code <> 'B' THEN
6148 IF NVL(p_source_97,9E125) = 16
6149 THEN
6150
6151 --
6152 XLA_AE_LINES_PKG.SetNewLine;
6153
6154 p_balance_type_code := l_balance_type_code;
6155 -- set the flag so later we will know whether the gain loss line needs to be created
6156
6157 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6158 p_actual_flag :='A';
6159 END IF;
6160
6161 --
6162 -- bulk performance
6163 --
6164 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6165 p_header_num => 0); -- 4262811
6166 --
6167 -- set accounting line options
6168 --
6169 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6170 p_natural_side_code => 'D'
6171 , p_gain_or_loss_flag => 'N'
6172 , p_gl_transfer_mode_code => 'S'
6173 , p_acct_entry_type_code => 'A'
6174 , p_switch_side_flag => 'Y'
6175 , p_merge_duplicate_code => 'N'
6176 );
6177 --
6178 l_acc_rev_natural_side_code := 'C'; -- 4262811
6179 --
6180 --
6181 -- set accounting line type info
6182 --
6183 xla_ae_lines_pkg.SetAcctLineType
6184 (p_component_type => l_component_type
6185 ,p_event_type_code => l_event_type_code
6186 ,p_line_definition_owner_code => l_line_definition_owner_code
6187 ,p_line_definition_code => l_line_definition_code
6188 ,p_accounting_line_code => l_component_code
6189 ,p_accounting_line_type_code => l_component_type_code
6190 ,p_accounting_line_appl_id => l_component_appl_id
6191 ,p_amb_context_code => l_amb_context_code
6192 ,p_entity_code => l_entity_code
6193 ,p_event_class_code => l_event_class_code);
6194 --
6195 -- set accounting class
6196 --
6197 xla_ae_lines_pkg.SetAcctClass(
6198 p_accounting_class_code => 'ACCRUAL'
6199 , p_ae_header_id => l_ae_header_id
6200 );
6201
6202 --
6203 -- set rounding class
6204 --
6205 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6206 'ACCRUAL';
6207
6208 --
6209 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6210 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6211 --
6212 -- bulk performance
6213 --
6214 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6215
6216 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6217 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6218
6219 -- 4955764
6220 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6221 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6222
6223 -- 4458381 Public Sector Enh
6224
6225 --
6226 -- set accounting attributes for the line type
6227 --
6228 l_entered_amt_idx := 3;
6229 l_accted_amt_idx := 8;
6230 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6231 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6232 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
6233 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6234 l_rec_acct_attrs.array_char_value(2) := p_source_85;
6235 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6236 l_rec_acct_attrs.array_num_value(3) := p_source_91;
6237 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6238 l_rec_acct_attrs.array_char_value(4) := p_source_88;
6239 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6240 l_rec_acct_attrs.array_date_value(5) := p_source_92;
6241 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6242 l_rec_acct_attrs.array_num_value(6) := p_source_93;
6243 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6244 l_rec_acct_attrs.array_char_value(7) := p_source_94;
6245 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
6246 l_rec_acct_attrs.array_num_value(8) := p_source_95;
6247
6248 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6249 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6250
6251 ---------------------------------------------------------------------------------------------------------------
6252 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6253 ---------------------------------------------------------------------------------------------------------------
6254 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6255
6256 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6257 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6258
6259 IF xla_accounting_cache_pkg.GetValueChar
6260 (p_source_code => 'LEDGER_CATEGORY_CODE'
6261 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6262 AND l_bflow_method_code = 'PRIOR_ENTRY'
6263 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6264 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6265 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6266 )
6267 THEN
6268 xla_ae_lines_pkg.BflowUpgEntry
6269 (p_business_method_code => l_bflow_method_code
6270 ,p_business_class_code => l_bflow_class_code
6271 ,p_balance_type => l_balance_type_code);
6272 ELSE
6273 NULL;
6274 -- No business flow processing for business flow method of NONE.
6275 END IF;
6276
6277 --
6278 -- call analytical criteria
6279 --
6280
6281 --
6282 -- call description
6283 --
6284
6285 xla_ae_lines_pkg.SetLineDescription(
6286 p_ae_header_id => l_ae_header_id
6287 ,p_description => Description_1 (
6288 p_application_id => p_application_id
6289 , p_ae_header_id => l_ae_header_id
6290 , p_source_1 => p_source_1
6291 , p_source_2 => p_source_2
6292 , p_source_3 => p_source_3
6293 , p_source_4 => p_source_4
6294 , p_source_5 => p_source_5
6295 )
6296 );
6297
6298
6299 --
6300 -- call ADRs
6301 -- Bug 4922099
6302 --
6303 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6304 (NVL(l_actual_upg_option, 'N') = 'O') OR
6305 (NVL(l_enc_upg_option, 'N') = 'O')
6306 )
6307 THEN
6308 NULL;
6309 --
6310 --
6311
6312 l_ccid := AcctDerRule_16(
6313 p_application_id => p_application_id
6314 , p_ae_header_id => l_ae_header_id
6315 , p_source_20 => p_source_20
6316 , x_transaction_coa_id => l_adr_transaction_coa_id
6317 , x_accounting_coa_id => l_adr_accounting_coa_id
6318 , x_value_type_code => l_adr_value_type_code
6319 , p_side => 'NA'
6320 );
6321
6322 xla_ae_lines_pkg.set_ccid(
6323 p_code_combination_id => l_ccid
6324 , p_value_type_code => l_adr_value_type_code
6325 , p_transaction_coa_id => l_adr_transaction_coa_id
6326 , p_accounting_coa_id => l_adr_accounting_coa_id
6327 , p_adr_code => 'PI_DISTRIBUTION'
6328 , p_adr_type_code => 'S'
6329 , p_component_type => l_component_type
6330 , p_component_code => l_component_code
6331 , p_component_type_code => l_component_type_code
6332 , p_component_appl_id => l_component_appl_id
6333 , p_amb_context_code => l_amb_context_code
6334 , p_side => 'NA'
6335 );
6336
6337
6338 --
6339 --
6340 END IF;
6341 --
6342 -- Bug 4922099
6343 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6344 (NVL(l_enc_upg_option, 'N') = 'O')
6345 ) AND
6346 (l_bflow_method_code = 'PRIOR_ENTRY')
6347 )
6348 THEN
6349 IF
6350 --
6351 1 = 2
6352 --
6353 THEN
6354 xla_accounting_err_pkg.build_message
6355 (p_appli_s_name => 'XLA'
6356 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6357 ,p_token_1 => 'LINE_NUMBER'
6358 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6359 ,p_token_2 => 'LINE_TYPE_NAME'
6360 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6361 l_component_type
6362 ,l_component_code
6363 ,l_component_type_code
6364 ,l_component_appl_id
6365 ,l_amb_context_code
6366 ,l_entity_code
6367 ,l_event_class_code
6368 )
6369 ,p_token_3 => 'OWNER'
6370 ,p_value_3 => xla_lookups_pkg.get_meaning(
6371 p_lookup_type => 'XLA_OWNER_TYPE'
6372 ,p_lookup_code => l_component_type_code
6373 )
6374 ,p_token_4 => 'PRODUCT_NAME'
6375 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6376 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6377 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6378 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6379 ,p_ae_header_id => NULL
6380 );
6381
6382 IF (C_LEVEL_ERROR>= g_log_level) THEN
6383 trace
6384 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6385 ,p_level => C_LEVEL_ERROR
6386 ,p_module => l_log_module);
6387 END IF;
6388 END IF;
6389 END IF;
6390 --
6391 --
6392 ------------------------------------------------------------------------------------------------
6393 -- 4219869 Business Flow
6394 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6395 -- Prior Entry. Currently, the following code is always generated.
6396 ------------------------------------------------------------------------------------------------
6397 XLA_AE_LINES_PKG.ValidateCurrentLine;
6398
6399 ------------------------------------------------------------------------------------
6400 -- 4219869 Business Flow
6401 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6402 ------------------------------------------------------------------------------------
6403 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6404
6405 ----------------------------------------------------------------------------------
6406 -- 4219869 Business Flow
6407 -- Update journal entry status -- Need to generate this within IF <condition>
6408 ----------------------------------------------------------------------------------
6409 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6410 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6411 ,p_balance_type_code => l_balance_type_code
6412 );
6413
6414 -------------------------------------------------------------------------------------------
6415 -- 4262811 - Generate the Accrual Reversal lines
6416 -------------------------------------------------------------------------------------------
6417 BEGIN
6418 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6419 (g_array_event(p_event_id).array_value_num('header_index'));
6420 IF l_acc_rev_flag IS NULL THEN
6421 l_acc_rev_flag := 'N';
6422 END IF;
6423 EXCEPTION
6424 WHEN OTHERS THEN
6425 l_acc_rev_flag := 'N';
6426 END;
6427 --
6428 IF (l_acc_rev_flag = 'Y') THEN
6429
6430 -- 4645092 ------------------------------------------------------------------------------
6431 -- To allow MPA report to determine if it should generate report process
6432 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6433 ------------------------------------------------------------------------------------------
6434
6435 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6436 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6437 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6438 -- call ADRs
6439 -- Bug 4922099
6440 --
6441 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6442 (NVL(l_actual_upg_option, 'N') = 'O') OR
6443 (NVL(l_enc_upg_option, 'N') = 'O')
6444 )
6445 THEN
6446 NULL;
6447 --
6448 --
6449
6450 l_ccid := AcctDerRule_16(
6451 p_application_id => p_application_id
6452 , p_ae_header_id => l_ae_header_id
6453 , p_source_20 => p_source_20
6454 , x_transaction_coa_id => l_adr_transaction_coa_id
6455 , x_accounting_coa_id => l_adr_accounting_coa_id
6456 , x_value_type_code => l_adr_value_type_code
6457 , p_side => 'NA'
6458 );
6459
6460 xla_ae_lines_pkg.set_ccid(
6461 p_code_combination_id => l_ccid
6462 , p_value_type_code => l_adr_value_type_code
6463 , p_transaction_coa_id => l_adr_transaction_coa_id
6464 , p_accounting_coa_id => l_adr_accounting_coa_id
6465 , p_adr_code => 'PI_DISTRIBUTION'
6466 , p_adr_type_code => 'S'
6467 , p_component_type => l_component_type
6468 , p_component_code => l_component_code
6469 , p_component_type_code => l_component_type_code
6470 , p_component_appl_id => l_component_appl_id
6471 , p_amb_context_code => l_amb_context_code
6472 , p_side => 'NA'
6473 );
6474
6475
6476 --
6477 --
6478 END IF;
6479
6480 --
6481 -- Update the line information that should be overwritten
6482 --
6483 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6484 p_header_num => 1);
6485 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6486
6487 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6488
6489 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6490 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6491 END IF;
6492
6493 --
6494 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6495 --
6496 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6497 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6498 ELSE
6499 ---------------------------------------------------------------------------------------------------
6500 -- 4262811a Switch Sign
6501 ---------------------------------------------------------------------------------------------------
6502 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6503 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6504 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6505 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6506 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6507 -- 5132302
6508 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6509 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6510
6511 END IF;
6512
6513 -- 4955764
6514 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6515 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6516
6517
6518 XLA_AE_LINES_PKG.ValidateCurrentLine;
6519 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6520
6521 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6522 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6523 ,p_balance_type_code => l_balance_type_code);
6524
6525 END IF;
6526
6527 -----------------------------------------------------------------------------------------
6528 -- 4262811 Multiperiod Accounting
6529 -----------------------------------------------------------------------------------------
6530 -- No MPA option is assigned.
6531
6532
6533 END IF;
6534 END IF;
6535 --
6536
6537 --
6538 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6539 trace
6540 (p_msg => 'END of AcctLineType_38'
6541 ,p_level => C_LEVEL_PROCEDURE
6542 ,p_module => l_log_module);
6543 END IF;
6544 --
6545 EXCEPTION
6546 WHEN xla_exceptions_pkg.application_exception THEN
6547 RAISE;
6548 WHEN OTHERS THEN
6549 xla_exceptions_pkg.raise_message
6550 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_38');
6551 END AcctLineType_38;
6552 --
6553
6554 ---------------------------------------
6555 --
6556 -- PRIVATE FUNCTION
6557 -- AcctLineType_39
6558 --
6559 ---------------------------------------
6560 PROCEDURE AcctLineType_39 (
6561 p_application_id IN NUMBER
6562 ,p_event_id IN NUMBER
6563 ,p_calculate_acctd_flag IN VARCHAR2
6564 ,p_calculate_g_l_flag IN VARCHAR2
6565 ,p_actual_flag IN OUT VARCHAR2
6566 ,p_balance_type_code OUT VARCHAR2
6567 ,p_gain_or_loss_ref OUT VARCHAR2
6568
6569 --Accrual Account for the Write Off
6570 , p_source_8 IN NUMBER
6571 --Distribution Type
6572 , p_source_85 IN VARCHAR2
6573 , p_source_85_meaning IN VARCHAR2
6574 --Entered Currency Code
6575 , p_source_88 IN VARCHAR2
6576 --Entered Amount
6577 , p_source_91 IN NUMBER
6578 --Currency Conversion Date
6579 , p_source_92 IN DATE
6580 --Currency Conversion Rate
6581 , p_source_93 IN NUMBER
6582 --Currency Conversion Type
6583 , p_source_94 IN VARCHAR2
6584 --Accounted Amount
6585 , p_source_95 IN NUMBER
6586 --Line Number
6587 , p_source_98 IN NUMBER
6588 --WRITE_OFF_ID
6589 , p_source_99 IN NUMBER
6590 )
6591 IS
6592
6593 l_component_type VARCHAR2(80);
6594 l_component_code VARCHAR2(30);
6595 l_component_type_code VARCHAR2(1);
6596 l_component_appl_id INTEGER;
6597 l_amb_context_code VARCHAR2(30);
6598 l_entity_code VARCHAR2(30);
6599 l_event_class_code VARCHAR2(30);
6600 l_ae_header_id NUMBER;
6601 l_event_type_code VARCHAR2(30);
6602 l_line_definition_code VARCHAR2(30);
6603 l_line_definition_owner_code VARCHAR2(1);
6604 --
6605 -- adr variables
6606 l_segment VARCHAR2(30);
6607 l_ccid NUMBER;
6608 l_adr_transaction_coa_id NUMBER;
6609 l_adr_accounting_coa_id NUMBER;
6610 l_adr_flexfield_segment_code VARCHAR2(30);
6611 l_adr_flex_value_set_id NUMBER;
6612 l_adr_value_type_code VARCHAR2(30);
6613 l_adr_value_combination_id NUMBER;
6614 l_adr_value_segment_code VARCHAR2(30);
6615
6616 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6617 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6618 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6619 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6620
6621 -- 4262811 Variables ------------------------------------------------------------------------------------------
6622 l_entered_amt_idx NUMBER;
6623 l_accted_amt_idx NUMBER;
6624 l_acc_rev_flag VARCHAR2(1);
6625 l_accrual_line_num NUMBER;
6626 l_tmp_amt NUMBER;
6627 l_acc_rev_natural_side_code VARCHAR2(1);
6628
6629 l_num_entries NUMBER;
6630 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6631 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6632 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6633 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6634 l_recog_line_1 NUMBER;
6635 l_recog_line_2 NUMBER;
6636
6637 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6638 l_bflow_applied_to_amt NUMBER; -- 5132302
6639 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6640
6641 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6642
6643 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6644 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6645
6646 ---------------------------------------------------------------------------------------------------------------
6647
6648
6649 --
6650 -- bulk performance
6651 --
6652 l_balance_type_code VARCHAR2(1);
6653 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6654 l_log_module VARCHAR2(240);
6655
6656 --
6657 -- Upgrade strategy
6658 --
6659 l_actual_upg_option VARCHAR2(1);
6660 l_enc_upg_option VARCHAR2(1);
6661
6662 --
6663 BEGIN
6664 --
6665 IF g_log_enabled THEN
6666 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_39';
6667 END IF;
6668 --
6669 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6670
6671 trace
6672 (p_msg => 'BEGIN of AcctLineType_39'
6673 ,p_level => C_LEVEL_PROCEDURE
6674 ,p_module => l_log_module);
6675
6676 END IF;
6677 --
6678 l_component_type := 'AMB_JLT';
6679 l_component_code := 'ACCRUAL';
6680 l_component_type_code := 'S';
6681 l_component_appl_id := 707;
6682 l_amb_context_code := 'DEFAULT';
6683 l_entity_code := 'WO_ACCOUNTING_EVENTS';
6684 l_event_class_code := 'ACCRUAL_WRITE_OFF';
6685 l_event_type_code := 'ACCRUAL_WRITE_OFF_ALL';
6686 l_line_definition_owner_code := 'S';
6687 l_line_definition_code := 'ACCRUAL_WRITE_OFF';
6688 --
6689 l_balance_type_code := 'A';
6690 l_segment := NULL;
6691 l_ccid := NULL;
6692 l_adr_transaction_coa_id := NULL;
6693 l_adr_accounting_coa_id := NULL;
6694 l_adr_flexfield_segment_code := NULL;
6695 l_adr_flex_value_set_id := NULL;
6696 l_adr_value_type_code := NULL;
6697 l_adr_value_combination_id := NULL;
6698 l_adr_value_segment_code := NULL;
6699
6700 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6701 l_bflow_class_code := ''; -- 4219869 Business Flow
6702 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6703 l_budgetary_control_flag := 'N';
6704
6705 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6706 l_bflow_applied_to_amt := NULL; -- 5132302
6707 l_entered_amt_idx := NULL; -- 4262811
6708 l_accted_amt_idx := NULL; -- 4262811
6709 l_acc_rev_flag := NULL; -- 4262811
6710 l_accrual_line_num := NULL; -- 4262811
6711 l_tmp_amt := NULL; -- 4262811
6712 --
6713
6714 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6715 l_balance_type_code <> 'B' THEN
6716 IF NVL(p_source_98,9E125) = 1
6717 THEN
6718
6719 --
6720 XLA_AE_LINES_PKG.SetNewLine;
6721
6722 p_balance_type_code := l_balance_type_code;
6723 -- set the flag so later we will know whether the gain loss line needs to be created
6724
6725 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6726 p_actual_flag :='A';
6727 END IF;
6728
6729 --
6730 -- bulk performance
6731 --
6732 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6733 p_header_num => 0); -- 4262811
6734 --
6735 -- set accounting line options
6736 --
6737 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6738 p_natural_side_code => 'D'
6739 , p_gain_or_loss_flag => 'N'
6740 , p_gl_transfer_mode_code => 'S'
6741 , p_acct_entry_type_code => 'A'
6742 , p_switch_side_flag => 'Y'
6743 , p_merge_duplicate_code => 'N'
6744 );
6745 --
6746 l_acc_rev_natural_side_code := 'C'; -- 4262811
6747 --
6748 --
6749 -- set accounting line type info
6750 --
6751 xla_ae_lines_pkg.SetAcctLineType
6752 (p_component_type => l_component_type
6753 ,p_event_type_code => l_event_type_code
6754 ,p_line_definition_owner_code => l_line_definition_owner_code
6755 ,p_line_definition_code => l_line_definition_code
6756 ,p_accounting_line_code => l_component_code
6757 ,p_accounting_line_type_code => l_component_type_code
6758 ,p_accounting_line_appl_id => l_component_appl_id
6759 ,p_amb_context_code => l_amb_context_code
6760 ,p_entity_code => l_entity_code
6761 ,p_event_class_code => l_event_class_code);
6762 --
6763 -- set accounting class
6764 --
6765 xla_ae_lines_pkg.SetAcctClass(
6766 p_accounting_class_code => 'ACCRUAL'
6767 , p_ae_header_id => l_ae_header_id
6768 );
6769
6770 --
6771 -- set rounding class
6772 --
6773 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6774 'ACCRUAL';
6775
6776 --
6777 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6778 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6779 --
6780 -- bulk performance
6781 --
6782 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6783
6784 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6785 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6786
6787 -- 4955764
6788 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6789 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6790
6791 -- 4458381 Public Sector Enh
6792
6793 --
6794 -- set accounting attributes for the line type
6795 --
6796 l_entered_amt_idx := 3;
6797 l_accted_amt_idx := 8;
6798 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6799 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6800 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_99);
6801 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6802 l_rec_acct_attrs.array_char_value(2) := p_source_85;
6803 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6804 l_rec_acct_attrs.array_num_value(3) := p_source_91;
6805 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6806 l_rec_acct_attrs.array_char_value(4) := p_source_88;
6807 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6808 l_rec_acct_attrs.array_date_value(5) := p_source_92;
6809 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6810 l_rec_acct_attrs.array_num_value(6) := p_source_93;
6811 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6812 l_rec_acct_attrs.array_char_value(7) := p_source_94;
6813 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
6814 l_rec_acct_attrs.array_num_value(8) := p_source_95;
6815
6816 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6817 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6818
6819 ---------------------------------------------------------------------------------------------------------------
6820 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6821 ---------------------------------------------------------------------------------------------------------------
6822 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6823
6824 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6825 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6826
6827 IF xla_accounting_cache_pkg.GetValueChar
6828 (p_source_code => 'LEDGER_CATEGORY_CODE'
6829 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6830 AND l_bflow_method_code = 'PRIOR_ENTRY'
6831 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6832 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6833 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6834 )
6835 THEN
6836 xla_ae_lines_pkg.BflowUpgEntry
6837 (p_business_method_code => l_bflow_method_code
6838 ,p_business_class_code => l_bflow_class_code
6839 ,p_balance_type => l_balance_type_code);
6840 ELSE
6841 NULL;
6842 -- No business flow processing for business flow method of NONE.
6843 END IF;
6844
6845 --
6846 -- call analytical criteria
6847 --
6848
6849 --
6850 -- call description
6851 --
6852 -- No description or it is inherited.
6853 --
6854 -- call ADRs
6855 -- Bug 4922099
6856 --
6857 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6858 (NVL(l_actual_upg_option, 'N') = 'O') OR
6859 (NVL(l_enc_upg_option, 'N') = 'O')
6860 )
6861 THEN
6862 NULL;
6863 --
6864 --
6865
6866 l_ccid := AcctDerRule_3(
6867 p_application_id => p_application_id
6868 , p_ae_header_id => l_ae_header_id
6869 , p_source_8 => p_source_8
6870 , x_transaction_coa_id => l_adr_transaction_coa_id
6871 , x_accounting_coa_id => l_adr_accounting_coa_id
6872 , x_value_type_code => l_adr_value_type_code
6873 , p_side => 'NA'
6874 );
6875
6876 xla_ae_lines_pkg.set_ccid(
6877 p_code_combination_id => l_ccid
6878 , p_value_type_code => l_adr_value_type_code
6879 , p_transaction_coa_id => l_adr_transaction_coa_id
6880 , p_accounting_coa_id => l_adr_accounting_coa_id
6881 , p_adr_code => 'CST_AWO_ACCRUAL'
6882 , p_adr_type_code => 'S'
6883 , p_component_type => l_component_type
6884 , p_component_code => l_component_code
6885 , p_component_type_code => l_component_type_code
6886 , p_component_appl_id => l_component_appl_id
6887 , p_amb_context_code => l_amb_context_code
6888 , p_side => 'NA'
6889 );
6890
6891
6892 --
6893 --
6894 END IF;
6895 --
6896 -- Bug 4922099
6897 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6898 (NVL(l_enc_upg_option, 'N') = 'O')
6899 ) AND
6900 (l_bflow_method_code = 'PRIOR_ENTRY')
6901 )
6902 THEN
6903 IF
6904 --
6905 1 = 2
6906 --
6907 THEN
6908 xla_accounting_err_pkg.build_message
6909 (p_appli_s_name => 'XLA'
6910 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6911 ,p_token_1 => 'LINE_NUMBER'
6912 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6913 ,p_token_2 => 'LINE_TYPE_NAME'
6914 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6915 l_component_type
6916 ,l_component_code
6917 ,l_component_type_code
6918 ,l_component_appl_id
6919 ,l_amb_context_code
6920 ,l_entity_code
6921 ,l_event_class_code
6922 )
6923 ,p_token_3 => 'OWNER'
6924 ,p_value_3 => xla_lookups_pkg.get_meaning(
6925 p_lookup_type => 'XLA_OWNER_TYPE'
6926 ,p_lookup_code => l_component_type_code
6927 )
6928 ,p_token_4 => 'PRODUCT_NAME'
6929 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6930 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6931 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6932 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6933 ,p_ae_header_id => NULL
6934 );
6935
6936 IF (C_LEVEL_ERROR>= g_log_level) THEN
6937 trace
6938 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6939 ,p_level => C_LEVEL_ERROR
6940 ,p_module => l_log_module);
6941 END IF;
6942 END IF;
6943 END IF;
6944 --
6945 --
6946 ------------------------------------------------------------------------------------------------
6947 -- 4219869 Business Flow
6948 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6949 -- Prior Entry. Currently, the following code is always generated.
6950 ------------------------------------------------------------------------------------------------
6951 XLA_AE_LINES_PKG.ValidateCurrentLine;
6952
6953 ------------------------------------------------------------------------------------
6954 -- 4219869 Business Flow
6955 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6956 ------------------------------------------------------------------------------------
6957 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6958
6959 ----------------------------------------------------------------------------------
6960 -- 4219869 Business Flow
6961 -- Update journal entry status -- Need to generate this within IF <condition>
6962 ----------------------------------------------------------------------------------
6963 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6964 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6965 ,p_balance_type_code => l_balance_type_code
6966 );
6967
6968 -------------------------------------------------------------------------------------------
6969 -- 4262811 - Generate the Accrual Reversal lines
6970 -------------------------------------------------------------------------------------------
6971 BEGIN
6972 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6973 (g_array_event(p_event_id).array_value_num('header_index'));
6974 IF l_acc_rev_flag IS NULL THEN
6975 l_acc_rev_flag := 'N';
6976 END IF;
6977 EXCEPTION
6978 WHEN OTHERS THEN
6979 l_acc_rev_flag := 'N';
6980 END;
6981 --
6982 IF (l_acc_rev_flag = 'Y') THEN
6983
6984 -- 4645092 ------------------------------------------------------------------------------
6985 -- To allow MPA report to determine if it should generate report process
6986 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6987 ------------------------------------------------------------------------------------------
6988
6989 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6990 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6991 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6992 -- call ADRs
6993 -- Bug 4922099
6994 --
6995 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6996 (NVL(l_actual_upg_option, 'N') = 'O') OR
6997 (NVL(l_enc_upg_option, 'N') = 'O')
6998 )
6999 THEN
7000 NULL;
7001 --
7002 --
7003
7004 l_ccid := AcctDerRule_3(
7005 p_application_id => p_application_id
7006 , p_ae_header_id => l_ae_header_id
7007 , p_source_8 => p_source_8
7008 , x_transaction_coa_id => l_adr_transaction_coa_id
7009 , x_accounting_coa_id => l_adr_accounting_coa_id
7010 , x_value_type_code => l_adr_value_type_code
7011 , p_side => 'NA'
7012 );
7013
7014 xla_ae_lines_pkg.set_ccid(
7015 p_code_combination_id => l_ccid
7016 , p_value_type_code => l_adr_value_type_code
7017 , p_transaction_coa_id => l_adr_transaction_coa_id
7018 , p_accounting_coa_id => l_adr_accounting_coa_id
7019 , p_adr_code => 'CST_AWO_ACCRUAL'
7020 , p_adr_type_code => 'S'
7021 , p_component_type => l_component_type
7022 , p_component_code => l_component_code
7023 , p_component_type_code => l_component_type_code
7024 , p_component_appl_id => l_component_appl_id
7025 , p_amb_context_code => l_amb_context_code
7026 , p_side => 'NA'
7027 );
7028
7029
7030 --
7031 --
7032 END IF;
7033
7034 --
7035 -- Update the line information that should be overwritten
7036 --
7037 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7038 p_header_num => 1);
7039 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7040
7041 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7042
7043 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7044 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7045 END IF;
7046
7047 --
7048 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7049 --
7050 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7051 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7052 ELSE
7053 ---------------------------------------------------------------------------------------------------
7054 -- 4262811a Switch Sign
7055 ---------------------------------------------------------------------------------------------------
7056 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7057 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7058 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7059 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7060 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7061 -- 5132302
7062 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7063 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7064
7065 END IF;
7066
7067 -- 4955764
7068 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7069 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7070
7071
7072 XLA_AE_LINES_PKG.ValidateCurrentLine;
7073 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7074
7075 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7076 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7077 ,p_balance_type_code => l_balance_type_code);
7078
7079 END IF;
7080
7081 -----------------------------------------------------------------------------------------
7082 -- 4262811 Multiperiod Accounting
7083 -----------------------------------------------------------------------------------------
7084 -- No MPA option is assigned.
7085
7086
7087 END IF;
7088 END IF;
7089 --
7090
7091 --
7092 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7093 trace
7094 (p_msg => 'END of AcctLineType_39'
7095 ,p_level => C_LEVEL_PROCEDURE
7096 ,p_module => l_log_module);
7097 END IF;
7098 --
7099 EXCEPTION
7100 WHEN xla_exceptions_pkg.application_exception THEN
7101 RAISE;
7102 WHEN OTHERS THEN
7103 xla_exceptions_pkg.raise_message
7104 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_39');
7105 END AcctLineType_39;
7106 --
7107
7108 ---------------------------------------
7109 --
7110 -- PRIVATE FUNCTION
7111 -- AcctLineType_40
7112 --
7113 ---------------------------------------
7114 PROCEDURE AcctLineType_40 (
7115 p_application_id IN NUMBER
7116 ,p_event_id IN NUMBER
7117 ,p_calculate_acctd_flag IN VARCHAR2
7118 ,p_calculate_g_l_flag IN VARCHAR2
7119 ,p_actual_flag IN OUT VARCHAR2
7120 ,p_balance_type_code OUT VARCHAR2
7121 ,p_gain_or_loss_ref OUT VARCHAR2
7122
7123 --Cost Management Default Account
7124 , p_source_11 IN NUMBER
7125 --DISTRIBUTION_IDENTIFIER
7126 , p_source_84 IN NUMBER
7127 --Distribution Type
7128 , p_source_85 IN VARCHAR2
7129 , p_source_85_meaning IN VARCHAR2
7130 --Entered Currency Code
7131 , p_source_88 IN VARCHAR2
7132 --Entered Amount
7133 , p_source_91 IN NUMBER
7134 --Currency Conversion Date
7135 , p_source_92 IN DATE
7136 --Currency Conversion Rate
7137 , p_source_93 IN NUMBER
7138 --Currency Conversion Type
7139 , p_source_94 IN VARCHAR2
7140 --Accounted Amount
7141 , p_source_95 IN NUMBER
7142 --Accounting Line Type
7143 , p_source_97 IN NUMBER
7144 )
7145 IS
7146
7147 l_component_type VARCHAR2(80);
7148 l_component_code VARCHAR2(30);
7149 l_component_type_code VARCHAR2(1);
7150 l_component_appl_id INTEGER;
7151 l_amb_context_code VARCHAR2(30);
7152 l_entity_code VARCHAR2(30);
7153 l_event_class_code VARCHAR2(30);
7154 l_ae_header_id NUMBER;
7155 l_event_type_code VARCHAR2(30);
7156 l_line_definition_code VARCHAR2(30);
7157 l_line_definition_owner_code VARCHAR2(1);
7158 --
7159 -- adr variables
7160 l_segment VARCHAR2(30);
7161 l_ccid NUMBER;
7162 l_adr_transaction_coa_id NUMBER;
7163 l_adr_accounting_coa_id NUMBER;
7164 l_adr_flexfield_segment_code VARCHAR2(30);
7165 l_adr_flex_value_set_id NUMBER;
7166 l_adr_value_type_code VARCHAR2(30);
7167 l_adr_value_combination_id NUMBER;
7168 l_adr_value_segment_code VARCHAR2(30);
7169
7170 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7171 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7172 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7173 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7174
7175 -- 4262811 Variables ------------------------------------------------------------------------------------------
7176 l_entered_amt_idx NUMBER;
7177 l_accted_amt_idx NUMBER;
7178 l_acc_rev_flag VARCHAR2(1);
7179 l_accrual_line_num NUMBER;
7180 l_tmp_amt NUMBER;
7181 l_acc_rev_natural_side_code VARCHAR2(1);
7182
7183 l_num_entries NUMBER;
7184 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7185 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7186 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7187 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7188 l_recog_line_1 NUMBER;
7189 l_recog_line_2 NUMBER;
7190
7191 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7192 l_bflow_applied_to_amt NUMBER; -- 5132302
7193 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7194
7195 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7196
7197 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7198 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7199
7200 ---------------------------------------------------------------------------------------------------------------
7201
7202
7203 --
7204 -- bulk performance
7205 --
7206 l_balance_type_code VARCHAR2(1);
7207 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7208 l_log_module VARCHAR2(240);
7209
7210 --
7211 -- Upgrade strategy
7212 --
7213 l_actual_upg_option VARCHAR2(1);
7214 l_enc_upg_option VARCHAR2(1);
7215
7216 --
7217 BEGIN
7218 --
7219 IF g_log_enabled THEN
7220 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_40';
7221 END IF;
7222 --
7223 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7224
7225 trace
7226 (p_msg => 'BEGIN of AcctLineType_40'
7227 ,p_level => C_LEVEL_PROCEDURE
7228 ,p_module => l_log_module);
7229
7230 END IF;
7231 --
7232 l_component_type := 'AMB_JLT';
7233 l_component_code := 'ACCRUAL';
7234 l_component_type_code := 'S';
7235 l_component_appl_id := 707;
7236 l_amb_context_code := 'DEFAULT';
7237 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
7238 l_event_class_code := 'RETR_PRICE_ADJ';
7239 l_event_type_code := 'RETR_PRICE_ADJ_ALL';
7240 l_line_definition_owner_code := 'S';
7241 l_line_definition_code := 'RETR_PRICE_ADJ';
7242 --
7243 l_balance_type_code := 'A';
7244 l_segment := NULL;
7245 l_ccid := NULL;
7246 l_adr_transaction_coa_id := NULL;
7247 l_adr_accounting_coa_id := NULL;
7248 l_adr_flexfield_segment_code := NULL;
7249 l_adr_flex_value_set_id := NULL;
7250 l_adr_value_type_code := NULL;
7251 l_adr_value_combination_id := NULL;
7252 l_adr_value_segment_code := NULL;
7253
7254 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7255 l_bflow_class_code := ''; -- 4219869 Business Flow
7256 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7257 l_budgetary_control_flag := 'N';
7258
7259 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7260 l_bflow_applied_to_amt := NULL; -- 5132302
7261 l_entered_amt_idx := NULL; -- 4262811
7262 l_accted_amt_idx := NULL; -- 4262811
7263 l_acc_rev_flag := NULL; -- 4262811
7264 l_accrual_line_num := NULL; -- 4262811
7265 l_tmp_amt := NULL; -- 4262811
7266 --
7267
7268 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7269 l_balance_type_code <> 'B' THEN
7270 IF NVL(p_source_97,9E125) = 16
7271 THEN
7272
7273 --
7274 XLA_AE_LINES_PKG.SetNewLine;
7275
7276 p_balance_type_code := l_balance_type_code;
7277 -- set the flag so later we will know whether the gain loss line needs to be created
7278
7279 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7280 p_actual_flag :='A';
7281 END IF;
7282
7283 --
7284 -- bulk performance
7285 --
7286 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7287 p_header_num => 0); -- 4262811
7288 --
7289 -- set accounting line options
7290 --
7291 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7292 p_natural_side_code => 'D'
7293 , p_gain_or_loss_flag => 'N'
7294 , p_gl_transfer_mode_code => 'S'
7295 , p_acct_entry_type_code => 'A'
7296 , p_switch_side_flag => 'Y'
7297 , p_merge_duplicate_code => 'N'
7298 );
7299 --
7300 l_acc_rev_natural_side_code := 'C'; -- 4262811
7301 --
7302 --
7303 -- set accounting line type info
7304 --
7305 xla_ae_lines_pkg.SetAcctLineType
7306 (p_component_type => l_component_type
7307 ,p_event_type_code => l_event_type_code
7308 ,p_line_definition_owner_code => l_line_definition_owner_code
7309 ,p_line_definition_code => l_line_definition_code
7310 ,p_accounting_line_code => l_component_code
7311 ,p_accounting_line_type_code => l_component_type_code
7312 ,p_accounting_line_appl_id => l_component_appl_id
7313 ,p_amb_context_code => l_amb_context_code
7314 ,p_entity_code => l_entity_code
7315 ,p_event_class_code => l_event_class_code);
7316 --
7317 -- set accounting class
7318 --
7319 xla_ae_lines_pkg.SetAcctClass(
7320 p_accounting_class_code => 'ACCRUAL'
7321 , p_ae_header_id => l_ae_header_id
7322 );
7323
7324 --
7325 -- set rounding class
7326 --
7327 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7328 'ACCRUAL';
7329
7330 --
7331 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7332 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7333 --
7334 -- bulk performance
7335 --
7336 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7337
7338 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7339 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7340
7341 -- 4955764
7342 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7343 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7344
7345 -- 4458381 Public Sector Enh
7346
7347 --
7348 -- set accounting attributes for the line type
7349 --
7350 l_entered_amt_idx := 3;
7351 l_accted_amt_idx := 8;
7352 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7353 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7354 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
7355 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7356 l_rec_acct_attrs.array_char_value(2) := p_source_85;
7357 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7358 l_rec_acct_attrs.array_num_value(3) := p_source_91;
7359 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7360 l_rec_acct_attrs.array_char_value(4) := p_source_88;
7361 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7362 l_rec_acct_attrs.array_date_value(5) := p_source_92;
7363 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7364 l_rec_acct_attrs.array_num_value(6) := p_source_93;
7365 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7366 l_rec_acct_attrs.array_char_value(7) := p_source_94;
7367 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7368 l_rec_acct_attrs.array_num_value(8) := p_source_95;
7369
7370 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7371 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7372
7373 ---------------------------------------------------------------------------------------------------------------
7374 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7375 ---------------------------------------------------------------------------------------------------------------
7376 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7377
7378 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7379 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7380
7381 IF xla_accounting_cache_pkg.GetValueChar
7382 (p_source_code => 'LEDGER_CATEGORY_CODE'
7383 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7384 AND l_bflow_method_code = 'PRIOR_ENTRY'
7385 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7386 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7387 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7388 )
7389 THEN
7390 xla_ae_lines_pkg.BflowUpgEntry
7391 (p_business_method_code => l_bflow_method_code
7392 ,p_business_class_code => l_bflow_class_code
7393 ,p_balance_type => l_balance_type_code);
7394 ELSE
7395 NULL;
7396 -- No business flow processing for business flow method of NONE.
7397 END IF;
7398
7399 --
7400 -- call analytical criteria
7401 --
7402
7403 --
7404 -- call description
7405 --
7406 -- No description or it is inherited.
7407 --
7408 -- call ADRs
7409 -- Bug 4922099
7410 --
7411 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7412 (NVL(l_actual_upg_option, 'N') = 'O') OR
7413 (NVL(l_enc_upg_option, 'N') = 'O')
7414 )
7415 THEN
7416 NULL;
7417 --
7418 --
7419
7420 l_ccid := AcctDerRule_6(
7421 p_application_id => p_application_id
7422 , p_ae_header_id => l_ae_header_id
7423 , p_source_11 => p_source_11
7424 , x_transaction_coa_id => l_adr_transaction_coa_id
7425 , x_accounting_coa_id => l_adr_accounting_coa_id
7426 , x_value_type_code => l_adr_value_type_code
7427 , p_side => 'NA'
7428 );
7429
7430 xla_ae_lines_pkg.set_ccid(
7431 p_code_combination_id => l_ccid
7432 , p_value_type_code => l_adr_value_type_code
7433 , p_transaction_coa_id => l_adr_transaction_coa_id
7434 , p_accounting_coa_id => l_adr_accounting_coa_id
7435 , p_adr_code => 'CST_DEFAULT'
7436 , p_adr_type_code => 'S'
7437 , p_component_type => l_component_type
7438 , p_component_code => l_component_code
7439 , p_component_type_code => l_component_type_code
7440 , p_component_appl_id => l_component_appl_id
7441 , p_amb_context_code => l_amb_context_code
7442 , p_side => 'NA'
7443 );
7444
7445
7446 --
7447 --
7448 END IF;
7449 --
7450 -- Bug 4922099
7451 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7452 (NVL(l_enc_upg_option, 'N') = 'O')
7453 ) AND
7454 (l_bflow_method_code = 'PRIOR_ENTRY')
7455 )
7456 THEN
7457 IF
7458 --
7459 1 = 2
7460 --
7461 THEN
7462 xla_accounting_err_pkg.build_message
7463 (p_appli_s_name => 'XLA'
7464 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7465 ,p_token_1 => 'LINE_NUMBER'
7466 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7467 ,p_token_2 => 'LINE_TYPE_NAME'
7468 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7469 l_component_type
7470 ,l_component_code
7471 ,l_component_type_code
7472 ,l_component_appl_id
7473 ,l_amb_context_code
7474 ,l_entity_code
7475 ,l_event_class_code
7476 )
7477 ,p_token_3 => 'OWNER'
7478 ,p_value_3 => xla_lookups_pkg.get_meaning(
7479 p_lookup_type => 'XLA_OWNER_TYPE'
7480 ,p_lookup_code => l_component_type_code
7481 )
7482 ,p_token_4 => 'PRODUCT_NAME'
7483 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7484 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7485 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7486 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7487 ,p_ae_header_id => NULL
7488 );
7489
7490 IF (C_LEVEL_ERROR>= g_log_level) THEN
7491 trace
7492 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7493 ,p_level => C_LEVEL_ERROR
7494 ,p_module => l_log_module);
7495 END IF;
7496 END IF;
7497 END IF;
7498 --
7499 --
7500 ------------------------------------------------------------------------------------------------
7501 -- 4219869 Business Flow
7502 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7503 -- Prior Entry. Currently, the following code is always generated.
7504 ------------------------------------------------------------------------------------------------
7505 XLA_AE_LINES_PKG.ValidateCurrentLine;
7506
7507 ------------------------------------------------------------------------------------
7508 -- 4219869 Business Flow
7509 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7510 ------------------------------------------------------------------------------------
7511 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7512
7513 ----------------------------------------------------------------------------------
7514 -- 4219869 Business Flow
7515 -- Update journal entry status -- Need to generate this within IF <condition>
7516 ----------------------------------------------------------------------------------
7517 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7518 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7519 ,p_balance_type_code => l_balance_type_code
7520 );
7521
7522 -------------------------------------------------------------------------------------------
7523 -- 4262811 - Generate the Accrual Reversal lines
7524 -------------------------------------------------------------------------------------------
7525 BEGIN
7526 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7527 (g_array_event(p_event_id).array_value_num('header_index'));
7528 IF l_acc_rev_flag IS NULL THEN
7529 l_acc_rev_flag := 'N';
7530 END IF;
7531 EXCEPTION
7532 WHEN OTHERS THEN
7533 l_acc_rev_flag := 'N';
7534 END;
7535 --
7536 IF (l_acc_rev_flag = 'Y') THEN
7537
7538 -- 4645092 ------------------------------------------------------------------------------
7539 -- To allow MPA report to determine if it should generate report process
7540 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7541 ------------------------------------------------------------------------------------------
7542
7543 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7544 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7545 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7546 -- call ADRs
7547 -- Bug 4922099
7548 --
7549 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7550 (NVL(l_actual_upg_option, 'N') = 'O') OR
7551 (NVL(l_enc_upg_option, 'N') = 'O')
7552 )
7553 THEN
7554 NULL;
7555 --
7556 --
7557
7558 l_ccid := AcctDerRule_6(
7559 p_application_id => p_application_id
7560 , p_ae_header_id => l_ae_header_id
7561 , p_source_11 => p_source_11
7562 , x_transaction_coa_id => l_adr_transaction_coa_id
7563 , x_accounting_coa_id => l_adr_accounting_coa_id
7564 , x_value_type_code => l_adr_value_type_code
7565 , p_side => 'NA'
7566 );
7567
7568 xla_ae_lines_pkg.set_ccid(
7569 p_code_combination_id => l_ccid
7570 , p_value_type_code => l_adr_value_type_code
7571 , p_transaction_coa_id => l_adr_transaction_coa_id
7572 , p_accounting_coa_id => l_adr_accounting_coa_id
7573 , p_adr_code => 'CST_DEFAULT'
7574 , p_adr_type_code => 'S'
7575 , p_component_type => l_component_type
7576 , p_component_code => l_component_code
7577 , p_component_type_code => l_component_type_code
7578 , p_component_appl_id => l_component_appl_id
7579 , p_amb_context_code => l_amb_context_code
7580 , p_side => 'NA'
7581 );
7582
7583
7584 --
7585 --
7586 END IF;
7587
7588 --
7589 -- Update the line information that should be overwritten
7590 --
7591 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7592 p_header_num => 1);
7593 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7594
7595 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7596
7597 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7598 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7599 END IF;
7600
7601 --
7602 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7603 --
7604 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7605 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7606 ELSE
7607 ---------------------------------------------------------------------------------------------------
7608 -- 4262811a Switch Sign
7609 ---------------------------------------------------------------------------------------------------
7610 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7611 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7612 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7613 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7614 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7615 -- 5132302
7616 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7617 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7618
7619 END IF;
7620
7621 -- 4955764
7622 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7623 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7624
7625
7626 XLA_AE_LINES_PKG.ValidateCurrentLine;
7627 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7628
7629 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7630 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7631 ,p_balance_type_code => l_balance_type_code);
7632
7633 END IF;
7634
7635 -----------------------------------------------------------------------------------------
7636 -- 4262811 Multiperiod Accounting
7637 -----------------------------------------------------------------------------------------
7638 -- No MPA option is assigned.
7639
7640
7641 END IF;
7642 END IF;
7643 --
7644
7645 --
7646 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7647 trace
7648 (p_msg => 'END of AcctLineType_40'
7649 ,p_level => C_LEVEL_PROCEDURE
7650 ,p_module => l_log_module);
7651 END IF;
7652 --
7653 EXCEPTION
7654 WHEN xla_exceptions_pkg.application_exception THEN
7655 RAISE;
7656 WHEN OTHERS THEN
7657 xla_exceptions_pkg.raise_message
7658 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_40');
7659 END AcctLineType_40;
7660 --
7661
7662 ---------------------------------------
7663 --
7664 -- PRIVATE FUNCTION
7665 -- AcctLineType_41
7666 --
7667 ---------------------------------------
7668 PROCEDURE AcctLineType_41 (
7669 p_application_id IN NUMBER
7670 ,p_event_id IN NUMBER
7671 ,p_calculate_acctd_flag IN VARCHAR2
7672 ,p_calculate_g_l_flag IN VARCHAR2
7673 ,p_actual_flag IN OUT VARCHAR2
7674 ,p_balance_type_code OUT VARCHAR2
7675 ,p_gain_or_loss_ref OUT VARCHAR2
7676
7677 --Cost Management Default Account
7678 , p_source_11 IN NUMBER
7679 --Receiving Accounting Line Type
7680 , p_source_78 IN VARCHAR2
7681 --DISTRIBUTION_IDENTIFIER
7682 , p_source_84 IN NUMBER
7683 --Distribution Type
7684 , p_source_85 IN VARCHAR2
7685 , p_source_85_meaning IN VARCHAR2
7686 --Entered Currency Code
7687 , p_source_88 IN VARCHAR2
7688 --Entered Amount
7689 , p_source_91 IN NUMBER
7690 --Currency Conversion Date
7691 , p_source_92 IN DATE
7692 --Currency Conversion Rate
7693 , p_source_93 IN NUMBER
7694 --Currency Conversion Type
7695 , p_source_94 IN VARCHAR2
7696 --Accounted Amount
7697 , p_source_95 IN NUMBER
7698 )
7699 IS
7700
7701 l_component_type VARCHAR2(80);
7702 l_component_code VARCHAR2(30);
7703 l_component_type_code VARCHAR2(1);
7704 l_component_appl_id INTEGER;
7705 l_amb_context_code VARCHAR2(30);
7706 l_entity_code VARCHAR2(30);
7707 l_event_class_code VARCHAR2(30);
7708 l_ae_header_id NUMBER;
7709 l_event_type_code VARCHAR2(30);
7710 l_line_definition_code VARCHAR2(30);
7711 l_line_definition_owner_code VARCHAR2(1);
7712 --
7713 -- adr variables
7714 l_segment VARCHAR2(30);
7715 l_ccid NUMBER;
7716 l_adr_transaction_coa_id NUMBER;
7717 l_adr_accounting_coa_id NUMBER;
7718 l_adr_flexfield_segment_code VARCHAR2(30);
7719 l_adr_flex_value_set_id NUMBER;
7720 l_adr_value_type_code VARCHAR2(30);
7721 l_adr_value_combination_id NUMBER;
7722 l_adr_value_segment_code VARCHAR2(30);
7723
7724 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7725 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7726 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7727 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7728
7729 -- 4262811 Variables ------------------------------------------------------------------------------------------
7730 l_entered_amt_idx NUMBER;
7731 l_accted_amt_idx NUMBER;
7732 l_acc_rev_flag VARCHAR2(1);
7733 l_accrual_line_num NUMBER;
7734 l_tmp_amt NUMBER;
7735 l_acc_rev_natural_side_code VARCHAR2(1);
7736
7737 l_num_entries NUMBER;
7738 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7739 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7740 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7741 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7742 l_recog_line_1 NUMBER;
7743 l_recog_line_2 NUMBER;
7744
7745 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7746 l_bflow_applied_to_amt NUMBER; -- 5132302
7747 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7748
7749 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7750
7751 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7752 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7753
7754 ---------------------------------------------------------------------------------------------------------------
7755
7756
7757 --
7758 -- bulk performance
7759 --
7760 l_balance_type_code VARCHAR2(1);
7761 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7762 l_log_module VARCHAR2(240);
7763
7764 --
7765 -- Upgrade strategy
7766 --
7767 l_actual_upg_option VARCHAR2(1);
7768 l_enc_upg_option VARCHAR2(1);
7769
7770 --
7771 BEGIN
7772 --
7773 IF g_log_enabled THEN
7774 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_41';
7775 END IF;
7776 --
7777 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7778
7779 trace
7780 (p_msg => 'BEGIN of AcctLineType_41'
7781 ,p_level => C_LEVEL_PROCEDURE
7782 ,p_module => l_log_module);
7783
7784 END IF;
7785 --
7786 l_component_type := 'AMB_JLT';
7787 l_component_code := 'ACCRUAL';
7788 l_component_type_code := 'S';
7789 l_component_appl_id := 707;
7790 l_amb_context_code := 'DEFAULT';
7791 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
7792 l_event_class_code := 'RETR_PRICE_ADJ_RCV';
7793 l_event_type_code := 'RETR_PRICE_ADJ_RCV_ALL';
7794 l_line_definition_owner_code := 'S';
7795 l_line_definition_code := 'RETR_PRICE_ADJ_RCV';
7796 --
7797 l_balance_type_code := 'A';
7798 l_segment := NULL;
7799 l_ccid := NULL;
7800 l_adr_transaction_coa_id := NULL;
7801 l_adr_accounting_coa_id := NULL;
7802 l_adr_flexfield_segment_code := NULL;
7803 l_adr_flex_value_set_id := NULL;
7804 l_adr_value_type_code := NULL;
7805 l_adr_value_combination_id := NULL;
7806 l_adr_value_segment_code := NULL;
7807
7808 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7809 l_bflow_class_code := ''; -- 4219869 Business Flow
7810 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7811 l_budgetary_control_flag := 'N';
7812
7813 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7814 l_bflow_applied_to_amt := NULL; -- 5132302
7815 l_entered_amt_idx := NULL; -- 4262811
7816 l_accted_amt_idx := NULL; -- 4262811
7817 l_acc_rev_flag := NULL; -- 4262811
7818 l_accrual_line_num := NULL; -- 4262811
7819 l_tmp_amt := NULL; -- 4262811
7820 --
7821
7822 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7823 l_balance_type_code <> 'B' THEN
7824 IF NVL(p_source_78,'
7825 ') = 'Accrual'
7826 THEN
7827
7828 --
7829 XLA_AE_LINES_PKG.SetNewLine;
7830
7831 p_balance_type_code := l_balance_type_code;
7832 -- set the flag so later we will know whether the gain loss line needs to be created
7833
7834 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7835 p_actual_flag :='A';
7836 END IF;
7837
7838 --
7839 -- bulk performance
7840 --
7841 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7842 p_header_num => 0); -- 4262811
7843 --
7844 -- set accounting line options
7845 --
7846 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7847 p_natural_side_code => 'D'
7848 , p_gain_or_loss_flag => 'N'
7849 , p_gl_transfer_mode_code => 'S'
7850 , p_acct_entry_type_code => 'A'
7851 , p_switch_side_flag => 'Y'
7852 , p_merge_duplicate_code => 'N'
7853 );
7854 --
7855 l_acc_rev_natural_side_code := 'C'; -- 4262811
7856 --
7857 --
7858 -- set accounting line type info
7859 --
7860 xla_ae_lines_pkg.SetAcctLineType
7861 (p_component_type => l_component_type
7862 ,p_event_type_code => l_event_type_code
7863 ,p_line_definition_owner_code => l_line_definition_owner_code
7864 ,p_line_definition_code => l_line_definition_code
7865 ,p_accounting_line_code => l_component_code
7866 ,p_accounting_line_type_code => l_component_type_code
7867 ,p_accounting_line_appl_id => l_component_appl_id
7868 ,p_amb_context_code => l_amb_context_code
7869 ,p_entity_code => l_entity_code
7870 ,p_event_class_code => l_event_class_code);
7871 --
7872 -- set accounting class
7873 --
7874 xla_ae_lines_pkg.SetAcctClass(
7875 p_accounting_class_code => 'ACCRUAL'
7876 , p_ae_header_id => l_ae_header_id
7877 );
7878
7879 --
7880 -- set rounding class
7881 --
7882 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7883 'ACCRUAL';
7884
7885 --
7886 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7887 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7888 --
7889 -- bulk performance
7890 --
7891 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7892
7893 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7894 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7895
7896 -- 4955764
7897 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7898 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7899
7900 -- 4458381 Public Sector Enh
7901
7902 --
7903 -- set accounting attributes for the line type
7904 --
7905 l_entered_amt_idx := 3;
7906 l_accted_amt_idx := 8;
7907 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7908 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7909 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
7910 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7911 l_rec_acct_attrs.array_char_value(2) := p_source_85;
7912 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7913 l_rec_acct_attrs.array_num_value(3) := p_source_91;
7914 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7915 l_rec_acct_attrs.array_char_value(4) := p_source_88;
7916 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7917 l_rec_acct_attrs.array_date_value(5) := p_source_92;
7918 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7919 l_rec_acct_attrs.array_num_value(6) := p_source_93;
7920 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7921 l_rec_acct_attrs.array_char_value(7) := p_source_94;
7922 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7923 l_rec_acct_attrs.array_num_value(8) := p_source_95;
7924
7925 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7926 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7927
7928 ---------------------------------------------------------------------------------------------------------------
7929 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7930 ---------------------------------------------------------------------------------------------------------------
7931 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7932
7933 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7934 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7935
7936 IF xla_accounting_cache_pkg.GetValueChar
7937 (p_source_code => 'LEDGER_CATEGORY_CODE'
7938 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7939 AND l_bflow_method_code = 'PRIOR_ENTRY'
7940 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7941 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7942 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7943 )
7944 THEN
7945 xla_ae_lines_pkg.BflowUpgEntry
7946 (p_business_method_code => l_bflow_method_code
7947 ,p_business_class_code => l_bflow_class_code
7948 ,p_balance_type => l_balance_type_code);
7949 ELSE
7950 NULL;
7951 -- No business flow processing for business flow method of NONE.
7952 END IF;
7953
7954 --
7955 -- call analytical criteria
7956 --
7957
7958 --
7959 -- call description
7960 --
7961 -- No description or it is inherited.
7962 --
7963 -- call ADRs
7964 -- Bug 4922099
7965 --
7966 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7967 (NVL(l_actual_upg_option, 'N') = 'O') OR
7968 (NVL(l_enc_upg_option, 'N') = 'O')
7969 )
7970 THEN
7971 NULL;
7972 --
7973 --
7974
7975 l_ccid := AcctDerRule_6(
7976 p_application_id => p_application_id
7977 , p_ae_header_id => l_ae_header_id
7978 , p_source_11 => p_source_11
7979 , x_transaction_coa_id => l_adr_transaction_coa_id
7980 , x_accounting_coa_id => l_adr_accounting_coa_id
7981 , x_value_type_code => l_adr_value_type_code
7982 , p_side => 'NA'
7983 );
7984
7985 xla_ae_lines_pkg.set_ccid(
7986 p_code_combination_id => l_ccid
7987 , p_value_type_code => l_adr_value_type_code
7988 , p_transaction_coa_id => l_adr_transaction_coa_id
7989 , p_accounting_coa_id => l_adr_accounting_coa_id
7990 , p_adr_code => 'CST_DEFAULT'
7991 , p_adr_type_code => 'S'
7992 , p_component_type => l_component_type
7993 , p_component_code => l_component_code
7994 , p_component_type_code => l_component_type_code
7995 , p_component_appl_id => l_component_appl_id
7996 , p_amb_context_code => l_amb_context_code
7997 , p_side => 'NA'
7998 );
7999
8000
8001 --
8002 --
8003 END IF;
8004 --
8005 -- Bug 4922099
8006 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8007 (NVL(l_enc_upg_option, 'N') = 'O')
8008 ) AND
8009 (l_bflow_method_code = 'PRIOR_ENTRY')
8010 )
8011 THEN
8012 IF
8013 --
8014 1 = 2
8015 --
8016 THEN
8017 xla_accounting_err_pkg.build_message
8018 (p_appli_s_name => 'XLA'
8019 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8020 ,p_token_1 => 'LINE_NUMBER'
8021 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8022 ,p_token_2 => 'LINE_TYPE_NAME'
8023 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8024 l_component_type
8025 ,l_component_code
8026 ,l_component_type_code
8027 ,l_component_appl_id
8028 ,l_amb_context_code
8029 ,l_entity_code
8030 ,l_event_class_code
8031 )
8032 ,p_token_3 => 'OWNER'
8033 ,p_value_3 => xla_lookups_pkg.get_meaning(
8034 p_lookup_type => 'XLA_OWNER_TYPE'
8035 ,p_lookup_code => l_component_type_code
8036 )
8037 ,p_token_4 => 'PRODUCT_NAME'
8038 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8039 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8040 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8041 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8042 ,p_ae_header_id => NULL
8043 );
8044
8045 IF (C_LEVEL_ERROR>= g_log_level) THEN
8046 trace
8047 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8048 ,p_level => C_LEVEL_ERROR
8049 ,p_module => l_log_module);
8050 END IF;
8051 END IF;
8052 END IF;
8053 --
8054 --
8055 ------------------------------------------------------------------------------------------------
8056 -- 4219869 Business Flow
8057 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8058 -- Prior Entry. Currently, the following code is always generated.
8059 ------------------------------------------------------------------------------------------------
8060 XLA_AE_LINES_PKG.ValidateCurrentLine;
8061
8062 ------------------------------------------------------------------------------------
8063 -- 4219869 Business Flow
8064 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8065 ------------------------------------------------------------------------------------
8066 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8067
8068 ----------------------------------------------------------------------------------
8069 -- 4219869 Business Flow
8070 -- Update journal entry status -- Need to generate this within IF <condition>
8071 ----------------------------------------------------------------------------------
8072 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8073 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8074 ,p_balance_type_code => l_balance_type_code
8075 );
8076
8077 -------------------------------------------------------------------------------------------
8078 -- 4262811 - Generate the Accrual Reversal lines
8079 -------------------------------------------------------------------------------------------
8080 BEGIN
8081 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8082 (g_array_event(p_event_id).array_value_num('header_index'));
8083 IF l_acc_rev_flag IS NULL THEN
8084 l_acc_rev_flag := 'N';
8085 END IF;
8086 EXCEPTION
8087 WHEN OTHERS THEN
8088 l_acc_rev_flag := 'N';
8089 END;
8090 --
8091 IF (l_acc_rev_flag = 'Y') THEN
8092
8093 -- 4645092 ------------------------------------------------------------------------------
8094 -- To allow MPA report to determine if it should generate report process
8095 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8096 ------------------------------------------------------------------------------------------
8097
8098 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8099 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8100 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8101 -- call ADRs
8102 -- Bug 4922099
8103 --
8104 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8105 (NVL(l_actual_upg_option, 'N') = 'O') OR
8106 (NVL(l_enc_upg_option, 'N') = 'O')
8107 )
8108 THEN
8109 NULL;
8110 --
8111 --
8112
8113 l_ccid := AcctDerRule_6(
8114 p_application_id => p_application_id
8115 , p_ae_header_id => l_ae_header_id
8116 , p_source_11 => p_source_11
8117 , x_transaction_coa_id => l_adr_transaction_coa_id
8118 , x_accounting_coa_id => l_adr_accounting_coa_id
8119 , x_value_type_code => l_adr_value_type_code
8120 , p_side => 'NA'
8121 );
8122
8123 xla_ae_lines_pkg.set_ccid(
8124 p_code_combination_id => l_ccid
8125 , p_value_type_code => l_adr_value_type_code
8126 , p_transaction_coa_id => l_adr_transaction_coa_id
8127 , p_accounting_coa_id => l_adr_accounting_coa_id
8128 , p_adr_code => 'CST_DEFAULT'
8129 , p_adr_type_code => 'S'
8130 , p_component_type => l_component_type
8131 , p_component_code => l_component_code
8132 , p_component_type_code => l_component_type_code
8133 , p_component_appl_id => l_component_appl_id
8134 , p_amb_context_code => l_amb_context_code
8135 , p_side => 'NA'
8136 );
8137
8138
8139 --
8140 --
8141 END IF;
8142
8143 --
8144 -- Update the line information that should be overwritten
8145 --
8146 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8147 p_header_num => 1);
8148 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8149
8150 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8151
8152 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8153 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8154 END IF;
8155
8156 --
8157 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8158 --
8159 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8160 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8161 ELSE
8162 ---------------------------------------------------------------------------------------------------
8163 -- 4262811a Switch Sign
8164 ---------------------------------------------------------------------------------------------------
8165 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8166 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8167 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8168 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8169 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8170 -- 5132302
8171 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8172 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8173
8174 END IF;
8175
8176 -- 4955764
8177 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8178 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8179
8180
8181 XLA_AE_LINES_PKG.ValidateCurrentLine;
8182 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8183
8184 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8185 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8186 ,p_balance_type_code => l_balance_type_code);
8187
8188 END IF;
8189
8190 -----------------------------------------------------------------------------------------
8191 -- 4262811 Multiperiod Accounting
8192 -----------------------------------------------------------------------------------------
8193 -- No MPA option is assigned.
8194
8195
8196 END IF;
8197 END IF;
8198 --
8199
8200 --
8201 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8202 trace
8203 (p_msg => 'END of AcctLineType_41'
8204 ,p_level => C_LEVEL_PROCEDURE
8205 ,p_module => l_log_module);
8206 END IF;
8207 --
8208 EXCEPTION
8209 WHEN xla_exceptions_pkg.application_exception THEN
8210 RAISE;
8211 WHEN OTHERS THEN
8212 xla_exceptions_pkg.raise_message
8213 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_41');
8214 END AcctLineType_41;
8215 --
8216
8217 ---------------------------------------
8218 --
8219 -- PRIVATE FUNCTION
8220 -- AcctLineType_42
8221 --
8222 ---------------------------------------
8223 PROCEDURE AcctLineType_42 (
8224 p_application_id IN NUMBER
8225 ,p_event_id IN NUMBER
8226 ,p_calculate_acctd_flag IN VARCHAR2
8227 ,p_calculate_g_l_flag IN VARCHAR2
8228 ,p_actual_flag IN OUT VARCHAR2
8229 ,p_balance_type_code OUT VARCHAR2
8230 ,p_gain_or_loss_ref OUT VARCHAR2
8231
8232 --Cost Management Default Account
8233 , p_source_11 IN NUMBER
8234 --Receiving Accounting Line Type
8235 , p_source_78 IN VARCHAR2
8236 --DISTRIBUTION_IDENTIFIER
8237 , p_source_84 IN NUMBER
8238 --Distribution Type
8239 , p_source_85 IN VARCHAR2
8240 , p_source_85_meaning IN VARCHAR2
8241 --Entered Currency Code
8242 , p_source_88 IN VARCHAR2
8243 --Entered Amount
8244 , p_source_91 IN NUMBER
8245 --Currency Conversion Date
8246 , p_source_92 IN DATE
8247 --Currency Conversion Rate
8248 , p_source_93 IN NUMBER
8249 --Currency Conversion Type
8250 , p_source_94 IN VARCHAR2
8251 --Accounted Amount
8252 , p_source_95 IN NUMBER
8253 )
8254 IS
8255
8256 l_component_type VARCHAR2(80);
8257 l_component_code VARCHAR2(30);
8258 l_component_type_code VARCHAR2(1);
8259 l_component_appl_id INTEGER;
8260 l_amb_context_code VARCHAR2(30);
8261 l_entity_code VARCHAR2(30);
8262 l_event_class_code VARCHAR2(30);
8263 l_ae_header_id NUMBER;
8264 l_event_type_code VARCHAR2(30);
8265 l_line_definition_code VARCHAR2(30);
8266 l_line_definition_owner_code VARCHAR2(1);
8267 --
8268 -- adr variables
8269 l_segment VARCHAR2(30);
8270 l_ccid NUMBER;
8271 l_adr_transaction_coa_id NUMBER;
8272 l_adr_accounting_coa_id NUMBER;
8273 l_adr_flexfield_segment_code VARCHAR2(30);
8274 l_adr_flex_value_set_id NUMBER;
8275 l_adr_value_type_code VARCHAR2(30);
8276 l_adr_value_combination_id NUMBER;
8277 l_adr_value_segment_code VARCHAR2(30);
8278
8279 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8280 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8281 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8282 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8283
8284 -- 4262811 Variables ------------------------------------------------------------------------------------------
8285 l_entered_amt_idx NUMBER;
8286 l_accted_amt_idx NUMBER;
8287 l_acc_rev_flag VARCHAR2(1);
8288 l_accrual_line_num NUMBER;
8289 l_tmp_amt NUMBER;
8290 l_acc_rev_natural_side_code VARCHAR2(1);
8291
8292 l_num_entries NUMBER;
8293 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8294 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8295 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8296 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8297 l_recog_line_1 NUMBER;
8298 l_recog_line_2 NUMBER;
8299
8300 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8301 l_bflow_applied_to_amt NUMBER; -- 5132302
8302 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8303
8304 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8305
8306 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8307 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8308
8309 ---------------------------------------------------------------------------------------------------------------
8310
8311
8312 --
8313 -- bulk performance
8314 --
8315 l_balance_type_code VARCHAR2(1);
8316 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8317 l_log_module VARCHAR2(240);
8318
8319 --
8320 -- Upgrade strategy
8321 --
8322 l_actual_upg_option VARCHAR2(1);
8323 l_enc_upg_option VARCHAR2(1);
8324
8325 --
8326 BEGIN
8327 --
8328 IF g_log_enabled THEN
8329 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_42';
8330 END IF;
8331 --
8332 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8333
8334 trace
8335 (p_msg => 'BEGIN of AcctLineType_42'
8336 ,p_level => C_LEVEL_PROCEDURE
8337 ,p_module => l_log_module);
8338
8339 END IF;
8340 --
8341 l_component_type := 'AMB_JLT';
8342 l_component_code := 'ACCRUAL';
8343 l_component_type_code := 'S';
8344 l_component_appl_id := 707;
8345 l_amb_context_code := 'DEFAULT';
8346 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
8347 l_event_class_code := 'RCPT_REC_INSP';
8348 l_event_type_code := 'RCPT_REC_INSP_ALL';
8349 l_line_definition_owner_code := 'S';
8350 l_line_definition_code := 'RCPT_REC_INSP';
8351 --
8352 l_balance_type_code := 'A';
8353 l_segment := NULL;
8354 l_ccid := NULL;
8355 l_adr_transaction_coa_id := NULL;
8356 l_adr_accounting_coa_id := NULL;
8357 l_adr_flexfield_segment_code := NULL;
8358 l_adr_flex_value_set_id := NULL;
8359 l_adr_value_type_code := NULL;
8360 l_adr_value_combination_id := NULL;
8361 l_adr_value_segment_code := NULL;
8362
8363 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8364 l_bflow_class_code := ''; -- 4219869 Business Flow
8365 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8366 l_budgetary_control_flag := 'N';
8367
8368 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8369 l_bflow_applied_to_amt := NULL; -- 5132302
8370 l_entered_amt_idx := NULL; -- 4262811
8371 l_accted_amt_idx := NULL; -- 4262811
8372 l_acc_rev_flag := NULL; -- 4262811
8373 l_accrual_line_num := NULL; -- 4262811
8374 l_tmp_amt := NULL; -- 4262811
8375 --
8376
8377 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8378 l_balance_type_code <> 'B' THEN
8379 IF NVL(p_source_78,'
8380 ') = 'Accrual'
8381 THEN
8382
8383 --
8384 XLA_AE_LINES_PKG.SetNewLine;
8385
8386 p_balance_type_code := l_balance_type_code;
8387 -- set the flag so later we will know whether the gain loss line needs to be created
8388
8389 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8390 p_actual_flag :='A';
8391 END IF;
8392
8393 --
8394 -- bulk performance
8395 --
8396 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8397 p_header_num => 0); -- 4262811
8398 --
8399 -- set accounting line options
8400 --
8401 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8402 p_natural_side_code => 'D'
8403 , p_gain_or_loss_flag => 'N'
8404 , p_gl_transfer_mode_code => 'S'
8405 , p_acct_entry_type_code => 'A'
8406 , p_switch_side_flag => 'Y'
8407 , p_merge_duplicate_code => 'N'
8408 );
8409 --
8410 l_acc_rev_natural_side_code := 'C'; -- 4262811
8411 --
8412 --
8413 -- set accounting line type info
8414 --
8415 xla_ae_lines_pkg.SetAcctLineType
8416 (p_component_type => l_component_type
8417 ,p_event_type_code => l_event_type_code
8418 ,p_line_definition_owner_code => l_line_definition_owner_code
8419 ,p_line_definition_code => l_line_definition_code
8420 ,p_accounting_line_code => l_component_code
8421 ,p_accounting_line_type_code => l_component_type_code
8422 ,p_accounting_line_appl_id => l_component_appl_id
8423 ,p_amb_context_code => l_amb_context_code
8424 ,p_entity_code => l_entity_code
8425 ,p_event_class_code => l_event_class_code);
8426 --
8427 -- set accounting class
8428 --
8429 xla_ae_lines_pkg.SetAcctClass(
8430 p_accounting_class_code => 'ACCRUAL'
8431 , p_ae_header_id => l_ae_header_id
8432 );
8433
8434 --
8435 -- set rounding class
8436 --
8437 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8438 'ACCRUAL';
8439
8440 --
8441 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8442 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8443 --
8444 -- bulk performance
8445 --
8446 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8447
8448 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8449 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8450
8451 -- 4955764
8452 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8453 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8454
8455 -- 4458381 Public Sector Enh
8456
8457 --
8458 -- set accounting attributes for the line type
8459 --
8460 l_entered_amt_idx := 3;
8461 l_accted_amt_idx := 8;
8462 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8463 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8464 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
8465 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8466 l_rec_acct_attrs.array_char_value(2) := p_source_85;
8467 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8468 l_rec_acct_attrs.array_num_value(3) := p_source_91;
8469 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8470 l_rec_acct_attrs.array_char_value(4) := p_source_88;
8471 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8472 l_rec_acct_attrs.array_date_value(5) := p_source_92;
8473 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8474 l_rec_acct_attrs.array_num_value(6) := p_source_93;
8475 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8476 l_rec_acct_attrs.array_char_value(7) := p_source_94;
8477 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
8478 l_rec_acct_attrs.array_num_value(8) := p_source_95;
8479
8480 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8481 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8482
8483 ---------------------------------------------------------------------------------------------------------------
8484 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8485 ---------------------------------------------------------------------------------------------------------------
8486 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8487
8488 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8489 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8490
8491 IF xla_accounting_cache_pkg.GetValueChar
8492 (p_source_code => 'LEDGER_CATEGORY_CODE'
8493 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8494 AND l_bflow_method_code = 'PRIOR_ENTRY'
8495 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8496 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8497 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8498 )
8499 THEN
8500 xla_ae_lines_pkg.BflowUpgEntry
8501 (p_business_method_code => l_bflow_method_code
8502 ,p_business_class_code => l_bflow_class_code
8503 ,p_balance_type => l_balance_type_code);
8504 ELSE
8505 NULL;
8506 -- No business flow processing for business flow method of NONE.
8507 END IF;
8508
8509 --
8510 -- call analytical criteria
8511 --
8512
8513 --
8514 -- call description
8515 --
8516 -- No description or it is inherited.
8517 --
8518 -- call ADRs
8519 -- Bug 4922099
8520 --
8521 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8522 (NVL(l_actual_upg_option, 'N') = 'O') OR
8523 (NVL(l_enc_upg_option, 'N') = 'O')
8524 )
8525 THEN
8526 NULL;
8527 --
8528 --
8529
8530 l_ccid := AcctDerRule_6(
8531 p_application_id => p_application_id
8532 , p_ae_header_id => l_ae_header_id
8533 , p_source_11 => p_source_11
8534 , x_transaction_coa_id => l_adr_transaction_coa_id
8535 , x_accounting_coa_id => l_adr_accounting_coa_id
8536 , x_value_type_code => l_adr_value_type_code
8537 , p_side => 'NA'
8538 );
8539
8540 xla_ae_lines_pkg.set_ccid(
8541 p_code_combination_id => l_ccid
8542 , p_value_type_code => l_adr_value_type_code
8543 , p_transaction_coa_id => l_adr_transaction_coa_id
8544 , p_accounting_coa_id => l_adr_accounting_coa_id
8545 , p_adr_code => 'CST_DEFAULT'
8546 , p_adr_type_code => 'S'
8547 , p_component_type => l_component_type
8548 , p_component_code => l_component_code
8549 , p_component_type_code => l_component_type_code
8550 , p_component_appl_id => l_component_appl_id
8551 , p_amb_context_code => l_amb_context_code
8552 , p_side => 'NA'
8553 );
8554
8555
8556 --
8557 --
8558 END IF;
8559 --
8560 -- Bug 4922099
8561 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8562 (NVL(l_enc_upg_option, 'N') = 'O')
8563 ) AND
8564 (l_bflow_method_code = 'PRIOR_ENTRY')
8565 )
8566 THEN
8567 IF
8568 --
8569 1 = 2
8570 --
8571 THEN
8572 xla_accounting_err_pkg.build_message
8573 (p_appli_s_name => 'XLA'
8574 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8575 ,p_token_1 => 'LINE_NUMBER'
8576 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8577 ,p_token_2 => 'LINE_TYPE_NAME'
8578 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8579 l_component_type
8580 ,l_component_code
8581 ,l_component_type_code
8582 ,l_component_appl_id
8583 ,l_amb_context_code
8584 ,l_entity_code
8585 ,l_event_class_code
8586 )
8587 ,p_token_3 => 'OWNER'
8588 ,p_value_3 => xla_lookups_pkg.get_meaning(
8589 p_lookup_type => 'XLA_OWNER_TYPE'
8590 ,p_lookup_code => l_component_type_code
8591 )
8592 ,p_token_4 => 'PRODUCT_NAME'
8593 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8594 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8595 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8596 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8597 ,p_ae_header_id => NULL
8598 );
8599
8600 IF (C_LEVEL_ERROR>= g_log_level) THEN
8601 trace
8602 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8603 ,p_level => C_LEVEL_ERROR
8604 ,p_module => l_log_module);
8605 END IF;
8606 END IF;
8607 END IF;
8608 --
8609 --
8610 ------------------------------------------------------------------------------------------------
8611 -- 4219869 Business Flow
8612 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8613 -- Prior Entry. Currently, the following code is always generated.
8614 ------------------------------------------------------------------------------------------------
8615 XLA_AE_LINES_PKG.ValidateCurrentLine;
8616
8617 ------------------------------------------------------------------------------------
8618 -- 4219869 Business Flow
8619 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8620 ------------------------------------------------------------------------------------
8621 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8622
8623 ----------------------------------------------------------------------------------
8624 -- 4219869 Business Flow
8625 -- Update journal entry status -- Need to generate this within IF <condition>
8626 ----------------------------------------------------------------------------------
8627 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8628 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8629 ,p_balance_type_code => l_balance_type_code
8630 );
8631
8632 -------------------------------------------------------------------------------------------
8633 -- 4262811 - Generate the Accrual Reversal lines
8634 -------------------------------------------------------------------------------------------
8635 BEGIN
8636 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8637 (g_array_event(p_event_id).array_value_num('header_index'));
8638 IF l_acc_rev_flag IS NULL THEN
8639 l_acc_rev_flag := 'N';
8640 END IF;
8641 EXCEPTION
8642 WHEN OTHERS THEN
8643 l_acc_rev_flag := 'N';
8644 END;
8645 --
8646 IF (l_acc_rev_flag = 'Y') THEN
8647
8648 -- 4645092 ------------------------------------------------------------------------------
8649 -- To allow MPA report to determine if it should generate report process
8650 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8651 ------------------------------------------------------------------------------------------
8652
8653 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8654 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8655 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8656 -- call ADRs
8657 -- Bug 4922099
8658 --
8659 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8660 (NVL(l_actual_upg_option, 'N') = 'O') OR
8661 (NVL(l_enc_upg_option, 'N') = 'O')
8662 )
8663 THEN
8664 NULL;
8665 --
8666 --
8667
8668 l_ccid := AcctDerRule_6(
8669 p_application_id => p_application_id
8670 , p_ae_header_id => l_ae_header_id
8671 , p_source_11 => p_source_11
8672 , x_transaction_coa_id => l_adr_transaction_coa_id
8673 , x_accounting_coa_id => l_adr_accounting_coa_id
8674 , x_value_type_code => l_adr_value_type_code
8675 , p_side => 'NA'
8676 );
8677
8678 xla_ae_lines_pkg.set_ccid(
8679 p_code_combination_id => l_ccid
8680 , p_value_type_code => l_adr_value_type_code
8681 , p_transaction_coa_id => l_adr_transaction_coa_id
8682 , p_accounting_coa_id => l_adr_accounting_coa_id
8683 , p_adr_code => 'CST_DEFAULT'
8684 , p_adr_type_code => 'S'
8685 , p_component_type => l_component_type
8686 , p_component_code => l_component_code
8687 , p_component_type_code => l_component_type_code
8688 , p_component_appl_id => l_component_appl_id
8689 , p_amb_context_code => l_amb_context_code
8690 , p_side => 'NA'
8691 );
8692
8693
8694 --
8695 --
8696 END IF;
8697
8698 --
8699 -- Update the line information that should be overwritten
8700 --
8701 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8702 p_header_num => 1);
8703 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8704
8705 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8706
8707 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8708 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8709 END IF;
8710
8711 --
8712 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8713 --
8714 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8715 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8716 ELSE
8717 ---------------------------------------------------------------------------------------------------
8718 -- 4262811a Switch Sign
8719 ---------------------------------------------------------------------------------------------------
8720 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8721 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8722 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8723 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8724 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8725 -- 5132302
8726 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8727 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8728
8729 END IF;
8730
8731 -- 4955764
8732 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8733 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8734
8735
8736 XLA_AE_LINES_PKG.ValidateCurrentLine;
8737 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8738
8739 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8740 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8741 ,p_balance_type_code => l_balance_type_code);
8742
8743 END IF;
8744
8745 -----------------------------------------------------------------------------------------
8746 -- 4262811 Multiperiod Accounting
8747 -----------------------------------------------------------------------------------------
8748 -- No MPA option is assigned.
8749
8750
8751 END IF;
8752 END IF;
8753 --
8754
8755 --
8756 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8757 trace
8758 (p_msg => 'END of AcctLineType_42'
8759 ,p_level => C_LEVEL_PROCEDURE
8760 ,p_module => l_log_module);
8761 END IF;
8762 --
8763 EXCEPTION
8764 WHEN xla_exceptions_pkg.application_exception THEN
8765 RAISE;
8766 WHEN OTHERS THEN
8767 xla_exceptions_pkg.raise_message
8768 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_42');
8769 END AcctLineType_42;
8770 --
8771
8772 ---------------------------------------
8773 --
8774 -- PRIVATE FUNCTION
8775 -- AcctLineType_43
8776 --
8777 ---------------------------------------
8778 PROCEDURE AcctLineType_43 (
8779 p_application_id IN NUMBER
8780 ,p_event_id IN NUMBER
8781 ,p_calculate_acctd_flag IN VARCHAR2
8782 ,p_calculate_g_l_flag IN VARCHAR2
8783 ,p_actual_flag IN OUT VARCHAR2
8784 ,p_balance_type_code OUT VARCHAR2
8785 ,p_gain_or_loss_ref OUT VARCHAR2
8786
8787 --Cost Management Default Account
8788 , p_source_11 IN NUMBER
8789 --Receiving Accounting Line Type
8790 , p_source_78 IN VARCHAR2
8791 --Applied to Application ID
8792 , p_source_79 IN NUMBER
8793 --Applied to Distribution Link Type
8794 , p_source_80 IN VARCHAR2
8795 --Applied to Entity Code
8796 , p_source_81 IN VARCHAR2
8797 --PO_DISTRIBUTION_ID
8798 , p_source_82 IN NUMBER
8799 --Applied To Purchase Document Identifier
8800 , p_source_83 IN NUMBER
8801 --DISTRIBUTION_IDENTIFIER
8802 , p_source_84 IN NUMBER
8803 --Distribution Type
8804 , p_source_85 IN VARCHAR2
8805 , p_source_85_meaning IN VARCHAR2
8806 --PO Budget Account
8807 , p_source_86 IN NUMBER
8808 --Encumbrance Reversal Amount Entered
8809 , p_source_87 IN NUMBER
8810 --Entered Currency Code
8811 , p_source_88 IN VARCHAR2
8812 --Transaction Encumbrance Reversal Amount
8813 , p_source_89 IN NUMBER
8814 --Costing Period End Accrual Encumbrance Upgrade Option
8815 , p_source_90 IN VARCHAR2
8816 --Entered Amount
8817 , p_source_91 IN NUMBER
8818 --Currency Conversion Date
8819 , p_source_92 IN DATE
8820 --Currency Conversion Rate
8821 , p_source_93 IN NUMBER
8822 --Currency Conversion Type
8823 , p_source_94 IN VARCHAR2
8824 --Accounted Amount
8825 , p_source_95 IN NUMBER
8826 --Purchasing Encumbrance Type Identifier
8827 , p_source_96 IN NUMBER
8828 )
8829 IS
8830
8831 l_component_type VARCHAR2(80);
8832 l_component_code VARCHAR2(30);
8833 l_component_type_code VARCHAR2(1);
8834 l_component_appl_id INTEGER;
8835 l_amb_context_code VARCHAR2(30);
8836 l_entity_code VARCHAR2(30);
8837 l_event_class_code VARCHAR2(30);
8838 l_ae_header_id NUMBER;
8839 l_event_type_code VARCHAR2(30);
8840 l_line_definition_code VARCHAR2(30);
8841 l_line_definition_owner_code VARCHAR2(1);
8842 --
8843 -- adr variables
8844 l_segment VARCHAR2(30);
8845 l_ccid NUMBER;
8846 l_adr_transaction_coa_id NUMBER;
8847 l_adr_accounting_coa_id NUMBER;
8848 l_adr_flexfield_segment_code VARCHAR2(30);
8849 l_adr_flex_value_set_id NUMBER;
8850 l_adr_value_type_code VARCHAR2(30);
8851 l_adr_value_combination_id NUMBER;
8852 l_adr_value_segment_code VARCHAR2(30);
8853
8854 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8855 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8856 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8857 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8858
8859 -- 4262811 Variables ------------------------------------------------------------------------------------------
8860 l_entered_amt_idx NUMBER;
8861 l_accted_amt_idx NUMBER;
8862 l_acc_rev_flag VARCHAR2(1);
8863 l_accrual_line_num NUMBER;
8864 l_tmp_amt NUMBER;
8865 l_acc_rev_natural_side_code VARCHAR2(1);
8866
8867 l_num_entries NUMBER;
8868 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8869 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8870 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8871 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8872 l_recog_line_1 NUMBER;
8873 l_recog_line_2 NUMBER;
8874
8875 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8876 l_bflow_applied_to_amt NUMBER; -- 5132302
8877 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8878
8879 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8880
8881 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8882 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8883
8884 ---------------------------------------------------------------------------------------------------------------
8885
8886
8887 --
8888 -- bulk performance
8889 --
8890 l_balance_type_code VARCHAR2(1);
8891 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8892 l_log_module VARCHAR2(240);
8893
8894 --
8895 -- Upgrade strategy
8896 --
8897 l_actual_upg_option VARCHAR2(1);
8898 l_enc_upg_option VARCHAR2(1);
8899
8900 --
8901 BEGIN
8902 --
8903 IF g_log_enabled THEN
8904 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_43';
8905 END IF;
8906 --
8907 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8908
8909 trace
8910 (p_msg => 'BEGIN of AcctLineType_43'
8911 ,p_level => C_LEVEL_PROCEDURE
8912 ,p_module => l_log_module);
8913
8914 END IF;
8915 --
8916 l_component_type := 'AMB_JLT';
8917 l_component_code := 'CHARGE';
8918 l_component_type_code := 'S';
8919 l_component_appl_id := 707;
8920 l_amb_context_code := 'DEFAULT';
8921 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
8922 l_event_class_code := 'PERIOD_END_ACCRUAL';
8923 l_event_type_code := 'PERIOD_END_ACCRUAL_ALL';
8924 l_line_definition_owner_code := 'S';
8925 l_line_definition_code := 'PERIOD_END_ACCRUAL';
8926 --
8927 l_balance_type_code := 'A';
8928 l_segment := NULL;
8929 l_ccid := NULL;
8930 l_adr_transaction_coa_id := NULL;
8931 l_adr_accounting_coa_id := NULL;
8932 l_adr_flexfield_segment_code := NULL;
8933 l_adr_flex_value_set_id := NULL;
8934 l_adr_value_type_code := NULL;
8935 l_adr_value_combination_id := NULL;
8936 l_adr_value_segment_code := NULL;
8937
8938 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8939 l_bflow_class_code := ''; -- 4219869 Business Flow
8940 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8941 l_budgetary_control_flag := 'N';
8942
8943 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8944 l_bflow_applied_to_amt := NULL; -- 5132302
8945 l_entered_amt_idx := NULL; -- 4262811
8946 l_accted_amt_idx := NULL; -- 4262811
8947 l_acc_rev_flag := NULL; -- 4262811
8948 l_accrual_line_num := NULL; -- 4262811
8949 l_tmp_amt := NULL; -- 4262811
8950 --
8951
8952 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8953 l_balance_type_code <> 'B' THEN
8954 IF NVL(p_source_78,'
8955 ') = 'Charge'
8956 THEN
8957
8958 --
8959 XLA_AE_LINES_PKG.SetNewLine;
8960
8961 p_balance_type_code := l_balance_type_code;
8962 -- set the flag so later we will know whether the gain loss line needs to be created
8963
8964 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8965 p_actual_flag :='A';
8966 END IF;
8967
8968 --
8969 -- bulk performance
8970 --
8971 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8972 p_header_num => 0); -- 4262811
8973 --
8974 -- set accounting line options
8975 --
8976 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8977 p_natural_side_code => 'D'
8978 , p_gain_or_loss_flag => 'N'
8979 , p_gl_transfer_mode_code => 'S'
8980 , p_acct_entry_type_code => 'A'
8981 , p_switch_side_flag => 'Y'
8982 , p_merge_duplicate_code => 'N'
8983 );
8984 --
8985 l_acc_rev_natural_side_code := 'C'; -- 4262811
8986 --
8987 --
8988 -- set accounting line type info
8989 --
8990 xla_ae_lines_pkg.SetAcctLineType
8991 (p_component_type => l_component_type
8992 ,p_event_type_code => l_event_type_code
8993 ,p_line_definition_owner_code => l_line_definition_owner_code
8994 ,p_line_definition_code => l_line_definition_code
8995 ,p_accounting_line_code => l_component_code
8996 ,p_accounting_line_type_code => l_component_type_code
8997 ,p_accounting_line_appl_id => l_component_appl_id
8998 ,p_amb_context_code => l_amb_context_code
8999 ,p_entity_code => l_entity_code
9000 ,p_event_class_code => l_event_class_code);
9001 --
9002 -- set accounting class
9003 --
9004 xla_ae_lines_pkg.SetAcctClass(
9005 p_accounting_class_code => 'CHARGE'
9006 , p_ae_header_id => l_ae_header_id
9007 );
9008
9009 --
9010 -- set rounding class
9011 --
9012 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9013 'CHARGE';
9014
9015 --
9016 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9017 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9018 --
9019 -- bulk performance
9020 --
9021 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9022
9023 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9024 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9025
9026 -- 4955764
9027 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9028 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9029
9030 -- 4458381 Public Sector Enh
9031
9032 --
9033 -- set accounting attributes for the line type
9034 --
9035 l_entered_amt_idx := 17;
9036 l_accted_amt_idx := 22;
9037 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9038 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
9039 l_rec_acct_attrs.array_num_value(1) := p_source_79;
9040 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
9041 l_rec_acct_attrs.array_char_value(2) := p_source_80;
9042 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
9043 l_rec_acct_attrs.array_char_value(3) := p_source_81;
9044 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
9045 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_82);
9046 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
9047 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
9048 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
9049 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
9050 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
9051 l_rec_acct_attrs.array_char_value(7) := p_source_85;
9052 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
9053 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
9054 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
9055 l_rec_acct_attrs.array_num_value(9) := p_source_87;
9056 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
9057 l_rec_acct_attrs.array_char_value(10) := p_source_88;
9058 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
9059 l_rec_acct_attrs.array_num_value(11) := p_source_89;
9060 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
9061 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
9062 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
9063 l_rec_acct_attrs.array_num_value(13) := p_source_87;
9064 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
9065 l_rec_acct_attrs.array_char_value(14) := p_source_88;
9066 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
9067 l_rec_acct_attrs.array_num_value(15) := p_source_89;
9068 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
9069 l_rec_acct_attrs.array_char_value(16) := p_source_90;
9070 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
9071 l_rec_acct_attrs.array_num_value(17) := p_source_91;
9072 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
9073 l_rec_acct_attrs.array_char_value(18) := p_source_88;
9074 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
9075 l_rec_acct_attrs.array_date_value(19) := p_source_92;
9076 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
9077 l_rec_acct_attrs.array_num_value(20) := p_source_93;
9078 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
9079 l_rec_acct_attrs.array_char_value(21) := p_source_94;
9080 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
9081 l_rec_acct_attrs.array_num_value(22) := p_source_95;
9082 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
9083 l_rec_acct_attrs.array_num_value(23) := p_source_96;
9084 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
9085 l_rec_acct_attrs.array_num_value(24) := p_source_96;
9086
9087 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9088 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9089
9090 ---------------------------------------------------------------------------------------------------------------
9091 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9092 ---------------------------------------------------------------------------------------------------------------
9093 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9094
9095 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9096 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9097
9098 IF xla_accounting_cache_pkg.GetValueChar
9099 (p_source_code => 'LEDGER_CATEGORY_CODE'
9100 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9101 AND l_bflow_method_code = 'PRIOR_ENTRY'
9102 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9103 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9104 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9105 )
9106 THEN
9107 xla_ae_lines_pkg.BflowUpgEntry
9108 (p_business_method_code => l_bflow_method_code
9109 ,p_business_class_code => l_bflow_class_code
9110 ,p_balance_type => l_balance_type_code);
9111 ELSE
9112 NULL;
9113 -- No business flow processing for business flow method of NONE.
9114 END IF;
9115
9116 --
9117 -- call analytical criteria
9118 --
9119
9120 --
9121 -- call description
9122 --
9123 -- No description or it is inherited.
9124 --
9125 -- call ADRs
9126 -- Bug 4922099
9127 --
9128 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9129 (NVL(l_actual_upg_option, 'N') = 'O') OR
9130 (NVL(l_enc_upg_option, 'N') = 'O')
9131 )
9132 THEN
9133 NULL;
9134 --
9135 --
9136
9137 l_ccid := AcctDerRule_6(
9138 p_application_id => p_application_id
9139 , p_ae_header_id => l_ae_header_id
9140 , p_source_11 => p_source_11
9141 , x_transaction_coa_id => l_adr_transaction_coa_id
9142 , x_accounting_coa_id => l_adr_accounting_coa_id
9143 , x_value_type_code => l_adr_value_type_code
9144 , p_side => 'NA'
9145 );
9146
9147 xla_ae_lines_pkg.set_ccid(
9148 p_code_combination_id => l_ccid
9149 , p_value_type_code => l_adr_value_type_code
9150 , p_transaction_coa_id => l_adr_transaction_coa_id
9151 , p_accounting_coa_id => l_adr_accounting_coa_id
9152 , p_adr_code => 'CST_DEFAULT'
9153 , p_adr_type_code => 'S'
9154 , p_component_type => l_component_type
9155 , p_component_code => l_component_code
9156 , p_component_type_code => l_component_type_code
9157 , p_component_appl_id => l_component_appl_id
9158 , p_amb_context_code => l_amb_context_code
9159 , p_side => 'NA'
9160 );
9161
9162
9163 --
9164 --
9165 END IF;
9166 --
9167 -- Bug 4922099
9168 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9169 (NVL(l_enc_upg_option, 'N') = 'O')
9170 ) AND
9171 (l_bflow_method_code = 'PRIOR_ENTRY')
9172 )
9173 THEN
9174 IF
9175 --
9176 1 = 2
9177 --
9178 THEN
9179 xla_accounting_err_pkg.build_message
9180 (p_appli_s_name => 'XLA'
9181 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9182 ,p_token_1 => 'LINE_NUMBER'
9183 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9184 ,p_token_2 => 'LINE_TYPE_NAME'
9185 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9186 l_component_type
9187 ,l_component_code
9188 ,l_component_type_code
9189 ,l_component_appl_id
9190 ,l_amb_context_code
9191 ,l_entity_code
9192 ,l_event_class_code
9193 )
9194 ,p_token_3 => 'OWNER'
9195 ,p_value_3 => xla_lookups_pkg.get_meaning(
9196 p_lookup_type => 'XLA_OWNER_TYPE'
9197 ,p_lookup_code => l_component_type_code
9198 )
9199 ,p_token_4 => 'PRODUCT_NAME'
9200 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9201 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9202 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9203 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9204 ,p_ae_header_id => NULL
9205 );
9206
9207 IF (C_LEVEL_ERROR>= g_log_level) THEN
9208 trace
9209 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9210 ,p_level => C_LEVEL_ERROR
9211 ,p_module => l_log_module);
9212 END IF;
9213 END IF;
9214 END IF;
9215 --
9216 --
9217 ------------------------------------------------------------------------------------------------
9218 -- 4219869 Business Flow
9219 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9220 -- Prior Entry. Currently, the following code is always generated.
9221 ------------------------------------------------------------------------------------------------
9222 XLA_AE_LINES_PKG.ValidateCurrentLine;
9223
9224 ------------------------------------------------------------------------------------
9225 -- 4219869 Business Flow
9226 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9227 ------------------------------------------------------------------------------------
9228 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9229
9230 ----------------------------------------------------------------------------------
9231 -- 4219869 Business Flow
9232 -- Update journal entry status -- Need to generate this within IF <condition>
9233 ----------------------------------------------------------------------------------
9234 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9235 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9236 ,p_balance_type_code => l_balance_type_code
9237 );
9238
9239 -------------------------------------------------------------------------------------------
9240 -- 4262811 - Generate the Accrual Reversal lines
9241 -------------------------------------------------------------------------------------------
9242 BEGIN
9243 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9244 (g_array_event(p_event_id).array_value_num('header_index'));
9245 IF l_acc_rev_flag IS NULL THEN
9246 l_acc_rev_flag := 'N';
9247 END IF;
9248 EXCEPTION
9249 WHEN OTHERS THEN
9250 l_acc_rev_flag := 'N';
9251 END;
9252 --
9253 IF (l_acc_rev_flag = 'Y') THEN
9254
9255 -- 4645092 ------------------------------------------------------------------------------
9256 -- To allow MPA report to determine if it should generate report process
9257 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9258 ------------------------------------------------------------------------------------------
9259
9260 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9261 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9262 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9263 -- call ADRs
9264 -- Bug 4922099
9265 --
9266 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9267 (NVL(l_actual_upg_option, 'N') = 'O') OR
9268 (NVL(l_enc_upg_option, 'N') = 'O')
9269 )
9270 THEN
9271 NULL;
9272 --
9273 --
9274
9275 l_ccid := AcctDerRule_6(
9276 p_application_id => p_application_id
9277 , p_ae_header_id => l_ae_header_id
9278 , p_source_11 => p_source_11
9279 , x_transaction_coa_id => l_adr_transaction_coa_id
9280 , x_accounting_coa_id => l_adr_accounting_coa_id
9281 , x_value_type_code => l_adr_value_type_code
9282 , p_side => 'NA'
9283 );
9284
9285 xla_ae_lines_pkg.set_ccid(
9286 p_code_combination_id => l_ccid
9287 , p_value_type_code => l_adr_value_type_code
9288 , p_transaction_coa_id => l_adr_transaction_coa_id
9289 , p_accounting_coa_id => l_adr_accounting_coa_id
9290 , p_adr_code => 'CST_DEFAULT'
9291 , p_adr_type_code => 'S'
9292 , p_component_type => l_component_type
9293 , p_component_code => l_component_code
9294 , p_component_type_code => l_component_type_code
9295 , p_component_appl_id => l_component_appl_id
9296 , p_amb_context_code => l_amb_context_code
9297 , p_side => 'NA'
9298 );
9299
9300
9301 --
9302 --
9303 END IF;
9304
9305 --
9306 -- Update the line information that should be overwritten
9307 --
9308 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9309 p_header_num => 1);
9310 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9311
9312 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9313
9314 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9315 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9316 END IF;
9317
9318 --
9319 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9320 --
9321 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9322 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9323 ELSE
9324 ---------------------------------------------------------------------------------------------------
9325 -- 4262811a Switch Sign
9326 ---------------------------------------------------------------------------------------------------
9327 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9329 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9330 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9331 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9332 -- 5132302
9333 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9334 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9335
9336 END IF;
9337
9338 -- 4955764
9339 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9340 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9341
9342
9343 XLA_AE_LINES_PKG.ValidateCurrentLine;
9344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9345
9346 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9347 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9348 ,p_balance_type_code => l_balance_type_code);
9349
9350 END IF;
9351
9352 -----------------------------------------------------------------------------------------
9353 -- 4262811 Multiperiod Accounting
9354 -----------------------------------------------------------------------------------------
9355 -- No MPA option is assigned.
9356
9357
9358 END IF;
9359 END IF;
9360 --
9361
9362 --
9363 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9364 trace
9365 (p_msg => 'END of AcctLineType_43'
9366 ,p_level => C_LEVEL_PROCEDURE
9367 ,p_module => l_log_module);
9368 END IF;
9369 --
9370 EXCEPTION
9371 WHEN xla_exceptions_pkg.application_exception THEN
9372 RAISE;
9373 WHEN OTHERS THEN
9374 xla_exceptions_pkg.raise_message
9375 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_43');
9376 END AcctLineType_43;
9377 --
9378
9379 ---------------------------------------
9380 --
9381 -- PRIVATE FUNCTION
9382 -- AcctLineType_44
9383 --
9384 ---------------------------------------
9385 PROCEDURE AcctLineType_44 (
9386 p_application_id IN NUMBER
9387 ,p_event_id IN NUMBER
9388 ,p_calculate_acctd_flag IN VARCHAR2
9389 ,p_calculate_g_l_flag IN VARCHAR2
9390 ,p_actual_flag IN OUT VARCHAR2
9391 ,p_balance_type_code OUT VARCHAR2
9392 ,p_gain_or_loss_ref OUT VARCHAR2
9393
9394 --Cost Management Default Account
9395 , p_source_11 IN NUMBER
9396 --Receiving Accounting Line Type
9397 , p_source_78 IN VARCHAR2
9398 --Applied to Application ID
9399 , p_source_79 IN NUMBER
9400 --Applied to Distribution Link Type
9401 , p_source_80 IN VARCHAR2
9402 --Applied to Entity Code
9403 , p_source_81 IN VARCHAR2
9404 --PO_DISTRIBUTION_ID
9405 , p_source_82 IN NUMBER
9406 --Applied To Purchase Document Identifier
9407 , p_source_83 IN NUMBER
9408 --DISTRIBUTION_IDENTIFIER
9409 , p_source_84 IN NUMBER
9410 --Distribution Type
9411 , p_source_85 IN VARCHAR2
9412 , p_source_85_meaning IN VARCHAR2
9413 --PO Budget Account
9414 , p_source_86 IN NUMBER
9415 --Encumbrance Reversal Amount Entered
9416 , p_source_87 IN NUMBER
9417 --Entered Currency Code
9418 , p_source_88 IN VARCHAR2
9419 --Transaction Encumbrance Reversal Amount
9420 , p_source_89 IN NUMBER
9421 --Entered Amount
9422 , p_source_91 IN NUMBER
9423 --Currency Conversion Date
9424 , p_source_92 IN DATE
9425 --Currency Conversion Rate
9426 , p_source_93 IN NUMBER
9427 --Currency Conversion Type
9428 , p_source_94 IN VARCHAR2
9429 --Accounted Amount
9430 , p_source_95 IN NUMBER
9431 --Purchasing Encumbrance Type Identifier
9432 , p_source_96 IN NUMBER
9433 --Costing Encumbrance Upgrade Option
9434 , p_source_100 IN VARCHAR2
9435 )
9436 IS
9437
9438 l_component_type VARCHAR2(80);
9439 l_component_code VARCHAR2(30);
9440 l_component_type_code VARCHAR2(1);
9441 l_component_appl_id INTEGER;
9442 l_amb_context_code VARCHAR2(30);
9443 l_entity_code VARCHAR2(30);
9444 l_event_class_code VARCHAR2(30);
9445 l_ae_header_id NUMBER;
9446 l_event_type_code VARCHAR2(30);
9447 l_line_definition_code VARCHAR2(30);
9448 l_line_definition_owner_code VARCHAR2(1);
9449 --
9450 -- adr variables
9451 l_segment VARCHAR2(30);
9452 l_ccid NUMBER;
9453 l_adr_transaction_coa_id NUMBER;
9454 l_adr_accounting_coa_id NUMBER;
9455 l_adr_flexfield_segment_code VARCHAR2(30);
9456 l_adr_flex_value_set_id NUMBER;
9457 l_adr_value_type_code VARCHAR2(30);
9458 l_adr_value_combination_id NUMBER;
9459 l_adr_value_segment_code VARCHAR2(30);
9460
9461 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9462 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9463 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9464 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9465
9466 -- 4262811 Variables ------------------------------------------------------------------------------------------
9467 l_entered_amt_idx NUMBER;
9468 l_accted_amt_idx NUMBER;
9469 l_acc_rev_flag VARCHAR2(1);
9470 l_accrual_line_num NUMBER;
9471 l_tmp_amt NUMBER;
9472 l_acc_rev_natural_side_code VARCHAR2(1);
9473
9474 l_num_entries NUMBER;
9475 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9476 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9477 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9478 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9479 l_recog_line_1 NUMBER;
9480 l_recog_line_2 NUMBER;
9481
9482 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9483 l_bflow_applied_to_amt NUMBER; -- 5132302
9484 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9485
9486 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9487
9488 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9489 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9490
9491 ---------------------------------------------------------------------------------------------------------------
9492
9493
9494 --
9495 -- bulk performance
9496 --
9497 l_balance_type_code VARCHAR2(1);
9498 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9499 l_log_module VARCHAR2(240);
9500
9501 --
9502 -- Upgrade strategy
9503 --
9504 l_actual_upg_option VARCHAR2(1);
9505 l_enc_upg_option VARCHAR2(1);
9506
9507 --
9508 BEGIN
9509 --
9510 IF g_log_enabled THEN
9511 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_44';
9512 END IF;
9513 --
9514 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9515
9516 trace
9517 (p_msg => 'BEGIN of AcctLineType_44'
9518 ,p_level => C_LEVEL_PROCEDURE
9519 ,p_module => l_log_module);
9520
9521 END IF;
9522 --
9523 l_component_type := 'AMB_JLT';
9524 l_component_code := 'CHARGE';
9525 l_component_type_code := 'S';
9526 l_component_appl_id := 707;
9527 l_amb_context_code := 'DEFAULT';
9528 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
9529 l_event_class_code := 'DELIVER_EXPENSE';
9530 l_event_type_code := 'DELIVER_EXPENSE_ALL';
9531 l_line_definition_owner_code := 'S';
9532 l_line_definition_code := 'DELIVER_EXPENSE';
9533 --
9534 l_balance_type_code := 'A';
9535 l_segment := NULL;
9536 l_ccid := NULL;
9537 l_adr_transaction_coa_id := NULL;
9538 l_adr_accounting_coa_id := NULL;
9539 l_adr_flexfield_segment_code := NULL;
9540 l_adr_flex_value_set_id := NULL;
9541 l_adr_value_type_code := NULL;
9542 l_adr_value_combination_id := NULL;
9543 l_adr_value_segment_code := NULL;
9544
9545 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9546 l_bflow_class_code := ''; -- 4219869 Business Flow
9547 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9548 l_budgetary_control_flag := 'N';
9549
9550 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9551 l_bflow_applied_to_amt := NULL; -- 5132302
9552 l_entered_amt_idx := NULL; -- 4262811
9553 l_accted_amt_idx := NULL; -- 4262811
9554 l_acc_rev_flag := NULL; -- 4262811
9555 l_accrual_line_num := NULL; -- 4262811
9556 l_tmp_amt := NULL; -- 4262811
9557 --
9558
9559 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9560 l_balance_type_code <> 'B' THEN
9561 IF NVL(p_source_78,'
9562 ') = 'Charge'
9563 THEN
9564
9565 --
9566 XLA_AE_LINES_PKG.SetNewLine;
9567
9568 p_balance_type_code := l_balance_type_code;
9569 -- set the flag so later we will know whether the gain loss line needs to be created
9570
9571 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9572 p_actual_flag :='A';
9573 END IF;
9574
9575 --
9576 -- bulk performance
9577 --
9578 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9579 p_header_num => 0); -- 4262811
9580 --
9581 -- set accounting line options
9582 --
9583 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9584 p_natural_side_code => 'D'
9585 , p_gain_or_loss_flag => 'N'
9586 , p_gl_transfer_mode_code => 'S'
9587 , p_acct_entry_type_code => 'A'
9588 , p_switch_side_flag => 'Y'
9589 , p_merge_duplicate_code => 'N'
9590 );
9591 --
9592 l_acc_rev_natural_side_code := 'C'; -- 4262811
9593 --
9594 --
9595 -- set accounting line type info
9596 --
9597 xla_ae_lines_pkg.SetAcctLineType
9598 (p_component_type => l_component_type
9599 ,p_event_type_code => l_event_type_code
9600 ,p_line_definition_owner_code => l_line_definition_owner_code
9601 ,p_line_definition_code => l_line_definition_code
9602 ,p_accounting_line_code => l_component_code
9603 ,p_accounting_line_type_code => l_component_type_code
9604 ,p_accounting_line_appl_id => l_component_appl_id
9605 ,p_amb_context_code => l_amb_context_code
9606 ,p_entity_code => l_entity_code
9607 ,p_event_class_code => l_event_class_code);
9608 --
9609 -- set accounting class
9610 --
9611 xla_ae_lines_pkg.SetAcctClass(
9612 p_accounting_class_code => 'CHARGE'
9613 , p_ae_header_id => l_ae_header_id
9614 );
9615
9616 --
9617 -- set rounding class
9618 --
9619 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9620 'CHARGE';
9621
9622 --
9623 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9624 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9625 --
9626 -- bulk performance
9627 --
9628 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9629
9630 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9631 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9632
9633 -- 4955764
9634 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9635 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9636
9637 -- 4458381 Public Sector Enh
9638
9639 --
9640 -- set accounting attributes for the line type
9641 --
9642 l_entered_amt_idx := 17;
9643 l_accted_amt_idx := 22;
9644 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9645 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
9646 l_rec_acct_attrs.array_num_value(1) := p_source_79;
9647 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
9648 l_rec_acct_attrs.array_char_value(2) := p_source_80;
9649 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
9650 l_rec_acct_attrs.array_char_value(3) := p_source_81;
9651 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
9652 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_82);
9653 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
9654 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
9655 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
9656 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
9657 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
9658 l_rec_acct_attrs.array_char_value(7) := p_source_85;
9659 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
9660 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
9661 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
9662 l_rec_acct_attrs.array_num_value(9) := p_source_87;
9663 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
9664 l_rec_acct_attrs.array_char_value(10) := p_source_88;
9665 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
9666 l_rec_acct_attrs.array_num_value(11) := p_source_89;
9667 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
9668 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
9669 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
9670 l_rec_acct_attrs.array_num_value(13) := p_source_87;
9671 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
9672 l_rec_acct_attrs.array_char_value(14) := p_source_88;
9673 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
9674 l_rec_acct_attrs.array_num_value(15) := p_source_89;
9675 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
9676 l_rec_acct_attrs.array_char_value(16) := p_source_100;
9677 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
9678 l_rec_acct_attrs.array_num_value(17) := p_source_91;
9679 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
9680 l_rec_acct_attrs.array_char_value(18) := p_source_88;
9681 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
9682 l_rec_acct_attrs.array_date_value(19) := p_source_92;
9683 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
9684 l_rec_acct_attrs.array_num_value(20) := p_source_93;
9685 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
9686 l_rec_acct_attrs.array_char_value(21) := p_source_94;
9687 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
9688 l_rec_acct_attrs.array_num_value(22) := p_source_95;
9689 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
9690 l_rec_acct_attrs.array_num_value(23) := p_source_96;
9691 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
9692 l_rec_acct_attrs.array_num_value(24) := p_source_96;
9693
9694 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9695 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9696
9697 ---------------------------------------------------------------------------------------------------------------
9698 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9699 ---------------------------------------------------------------------------------------------------------------
9700 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9701
9702 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9703 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9704
9705 IF xla_accounting_cache_pkg.GetValueChar
9706 (p_source_code => 'LEDGER_CATEGORY_CODE'
9707 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9708 AND l_bflow_method_code = 'PRIOR_ENTRY'
9709 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9710 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9711 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9712 )
9713 THEN
9714 xla_ae_lines_pkg.BflowUpgEntry
9715 (p_business_method_code => l_bflow_method_code
9716 ,p_business_class_code => l_bflow_class_code
9717 ,p_balance_type => l_balance_type_code);
9718 ELSE
9719 NULL;
9720 -- No business flow processing for business flow method of NONE.
9721 END IF;
9722
9723 --
9724 -- call analytical criteria
9725 --
9726
9727 --
9728 -- call description
9729 --
9730 -- No description or it is inherited.
9731 --
9732 -- call ADRs
9733 -- Bug 4922099
9734 --
9735 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9736 (NVL(l_actual_upg_option, 'N') = 'O') OR
9737 (NVL(l_enc_upg_option, 'N') = 'O')
9738 )
9739 THEN
9740 NULL;
9741 --
9742 --
9743
9744 l_ccid := AcctDerRule_6(
9745 p_application_id => p_application_id
9746 , p_ae_header_id => l_ae_header_id
9747 , p_source_11 => p_source_11
9748 , x_transaction_coa_id => l_adr_transaction_coa_id
9749 , x_accounting_coa_id => l_adr_accounting_coa_id
9750 , x_value_type_code => l_adr_value_type_code
9751 , p_side => 'NA'
9752 );
9753
9754 xla_ae_lines_pkg.set_ccid(
9755 p_code_combination_id => l_ccid
9756 , p_value_type_code => l_adr_value_type_code
9757 , p_transaction_coa_id => l_adr_transaction_coa_id
9758 , p_accounting_coa_id => l_adr_accounting_coa_id
9759 , p_adr_code => 'CST_DEFAULT'
9760 , p_adr_type_code => 'S'
9761 , p_component_type => l_component_type
9762 , p_component_code => l_component_code
9763 , p_component_type_code => l_component_type_code
9764 , p_component_appl_id => l_component_appl_id
9765 , p_amb_context_code => l_amb_context_code
9766 , p_side => 'NA'
9767 );
9768
9769
9770 --
9771 --
9772 END IF;
9773 --
9774 -- Bug 4922099
9775 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9776 (NVL(l_enc_upg_option, 'N') = 'O')
9777 ) AND
9778 (l_bflow_method_code = 'PRIOR_ENTRY')
9779 )
9780 THEN
9781 IF
9782 --
9783 1 = 2
9784 --
9785 THEN
9786 xla_accounting_err_pkg.build_message
9787 (p_appli_s_name => 'XLA'
9788 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9789 ,p_token_1 => 'LINE_NUMBER'
9790 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9791 ,p_token_2 => 'LINE_TYPE_NAME'
9792 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9793 l_component_type
9794 ,l_component_code
9795 ,l_component_type_code
9796 ,l_component_appl_id
9797 ,l_amb_context_code
9798 ,l_entity_code
9799 ,l_event_class_code
9800 )
9801 ,p_token_3 => 'OWNER'
9802 ,p_value_3 => xla_lookups_pkg.get_meaning(
9803 p_lookup_type => 'XLA_OWNER_TYPE'
9804 ,p_lookup_code => l_component_type_code
9805 )
9806 ,p_token_4 => 'PRODUCT_NAME'
9807 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9808 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9809 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9810 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9811 ,p_ae_header_id => NULL
9812 );
9813
9814 IF (C_LEVEL_ERROR>= g_log_level) THEN
9815 trace
9816 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9817 ,p_level => C_LEVEL_ERROR
9818 ,p_module => l_log_module);
9819 END IF;
9820 END IF;
9821 END IF;
9822 --
9823 --
9824 ------------------------------------------------------------------------------------------------
9825 -- 4219869 Business Flow
9826 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9827 -- Prior Entry. Currently, the following code is always generated.
9828 ------------------------------------------------------------------------------------------------
9829 XLA_AE_LINES_PKG.ValidateCurrentLine;
9830
9831 ------------------------------------------------------------------------------------
9832 -- 4219869 Business Flow
9833 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9834 ------------------------------------------------------------------------------------
9835 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9836
9837 ----------------------------------------------------------------------------------
9838 -- 4219869 Business Flow
9839 -- Update journal entry status -- Need to generate this within IF <condition>
9840 ----------------------------------------------------------------------------------
9841 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9842 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9843 ,p_balance_type_code => l_balance_type_code
9844 );
9845
9846 -------------------------------------------------------------------------------------------
9847 -- 4262811 - Generate the Accrual Reversal lines
9848 -------------------------------------------------------------------------------------------
9849 BEGIN
9850 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9851 (g_array_event(p_event_id).array_value_num('header_index'));
9852 IF l_acc_rev_flag IS NULL THEN
9853 l_acc_rev_flag := 'N';
9854 END IF;
9855 EXCEPTION
9856 WHEN OTHERS THEN
9857 l_acc_rev_flag := 'N';
9858 END;
9859 --
9860 IF (l_acc_rev_flag = 'Y') THEN
9861
9862 -- 4645092 ------------------------------------------------------------------------------
9863 -- To allow MPA report to determine if it should generate report process
9864 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9865 ------------------------------------------------------------------------------------------
9866
9867 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9868 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9869 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9870 -- call ADRs
9871 -- Bug 4922099
9872 --
9873 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9874 (NVL(l_actual_upg_option, 'N') = 'O') OR
9875 (NVL(l_enc_upg_option, 'N') = 'O')
9876 )
9877 THEN
9878 NULL;
9879 --
9880 --
9881
9882 l_ccid := AcctDerRule_6(
9883 p_application_id => p_application_id
9884 , p_ae_header_id => l_ae_header_id
9885 , p_source_11 => p_source_11
9886 , x_transaction_coa_id => l_adr_transaction_coa_id
9887 , x_accounting_coa_id => l_adr_accounting_coa_id
9888 , x_value_type_code => l_adr_value_type_code
9889 , p_side => 'NA'
9890 );
9891
9892 xla_ae_lines_pkg.set_ccid(
9893 p_code_combination_id => l_ccid
9894 , p_value_type_code => l_adr_value_type_code
9895 , p_transaction_coa_id => l_adr_transaction_coa_id
9896 , p_accounting_coa_id => l_adr_accounting_coa_id
9897 , p_adr_code => 'CST_DEFAULT'
9898 , p_adr_type_code => 'S'
9899 , p_component_type => l_component_type
9900 , p_component_code => l_component_code
9901 , p_component_type_code => l_component_type_code
9902 , p_component_appl_id => l_component_appl_id
9903 , p_amb_context_code => l_amb_context_code
9904 , p_side => 'NA'
9905 );
9906
9907
9908 --
9909 --
9910 END IF;
9911
9912 --
9913 -- Update the line information that should be overwritten
9914 --
9915 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9916 p_header_num => 1);
9917 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9918
9919 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9920
9921 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9922 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9923 END IF;
9924
9925 --
9926 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9927 --
9928 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9929 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9930 ELSE
9931 ---------------------------------------------------------------------------------------------------
9932 -- 4262811a Switch Sign
9933 ---------------------------------------------------------------------------------------------------
9934 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9935 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9936 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9937 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9938 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9939 -- 5132302
9940 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9941 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9942
9943 END IF;
9944
9945 -- 4955764
9946 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9947 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9948
9949
9950 XLA_AE_LINES_PKG.ValidateCurrentLine;
9951 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9952
9953 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9954 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9955 ,p_balance_type_code => l_balance_type_code);
9956
9957 END IF;
9958
9959 -----------------------------------------------------------------------------------------
9960 -- 4262811 Multiperiod Accounting
9961 -----------------------------------------------------------------------------------------
9962 -- No MPA option is assigned.
9963
9964
9965 END IF;
9966 END IF;
9967 --
9968
9969 --
9970 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9971 trace
9972 (p_msg => 'END of AcctLineType_44'
9973 ,p_level => C_LEVEL_PROCEDURE
9974 ,p_module => l_log_module);
9975 END IF;
9976 --
9977 EXCEPTION
9978 WHEN xla_exceptions_pkg.application_exception THEN
9979 RAISE;
9980 WHEN OTHERS THEN
9981 xla_exceptions_pkg.raise_message
9982 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_44');
9983 END AcctLineType_44;
9984 --
9985
9986 ---------------------------------------
9987 --
9988 -- PRIVATE FUNCTION
9989 -- AcctLineType_45
9990 --
9991 ---------------------------------------
9992 PROCEDURE AcctLineType_45 (
9993 p_application_id IN NUMBER
9994 ,p_event_id IN NUMBER
9995 ,p_calculate_acctd_flag IN VARCHAR2
9996 ,p_calculate_g_l_flag IN VARCHAR2
9997 ,p_actual_flag IN OUT VARCHAR2
9998 ,p_balance_type_code OUT VARCHAR2
9999 ,p_gain_or_loss_ref OUT VARCHAR2
10000
10001 --Cost Management Default Account
10002 , p_source_11 IN NUMBER
10003 --Receiving Accounting Line Type
10004 , p_source_78 IN VARCHAR2
10005 --DISTRIBUTION_IDENTIFIER
10006 , p_source_84 IN NUMBER
10007 --Distribution Type
10008 , p_source_85 IN VARCHAR2
10009 , p_source_85_meaning IN VARCHAR2
10010 --Entered Currency Code
10011 , p_source_88 IN VARCHAR2
10012 --Entered Amount
10013 , p_source_91 IN NUMBER
10014 --Currency Conversion Date
10015 , p_source_92 IN DATE
10016 --Currency Conversion Rate
10017 , p_source_93 IN NUMBER
10018 --Accounted Amount
10019 , p_source_95 IN NUMBER
10020 )
10021 IS
10022
10023 l_component_type VARCHAR2(80);
10024 l_component_code VARCHAR2(30);
10025 l_component_type_code VARCHAR2(1);
10026 l_component_appl_id INTEGER;
10027 l_amb_context_code VARCHAR2(30);
10028 l_entity_code VARCHAR2(30);
10029 l_event_class_code VARCHAR2(30);
10030 l_ae_header_id NUMBER;
10031 l_event_type_code VARCHAR2(30);
10032 l_line_definition_code VARCHAR2(30);
10033 l_line_definition_owner_code VARCHAR2(1);
10034 --
10035 -- adr variables
10036 l_segment VARCHAR2(30);
10037 l_ccid NUMBER;
10038 l_adr_transaction_coa_id NUMBER;
10039 l_adr_accounting_coa_id NUMBER;
10040 l_adr_flexfield_segment_code VARCHAR2(30);
10041 l_adr_flex_value_set_id NUMBER;
10042 l_adr_value_type_code VARCHAR2(30);
10043 l_adr_value_combination_id NUMBER;
10044 l_adr_value_segment_code VARCHAR2(30);
10045
10046 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10047 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10048 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10049 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10050
10051 -- 4262811 Variables ------------------------------------------------------------------------------------------
10052 l_entered_amt_idx NUMBER;
10053 l_accted_amt_idx NUMBER;
10054 l_acc_rev_flag VARCHAR2(1);
10055 l_accrual_line_num NUMBER;
10056 l_tmp_amt NUMBER;
10057 l_acc_rev_natural_side_code VARCHAR2(1);
10058
10059 l_num_entries NUMBER;
10060 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10061 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10062 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10063 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10064 l_recog_line_1 NUMBER;
10065 l_recog_line_2 NUMBER;
10066
10067 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10068 l_bflow_applied_to_amt NUMBER; -- 5132302
10069 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10070
10071 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10072
10073 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10074 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10075
10076 ---------------------------------------------------------------------------------------------------------------
10077
10078
10079 --
10080 -- bulk performance
10081 --
10082 l_balance_type_code VARCHAR2(1);
10083 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10084 l_log_module VARCHAR2(240);
10085
10086 --
10087 -- Upgrade strategy
10088 --
10089 l_actual_upg_option VARCHAR2(1);
10090 l_enc_upg_option VARCHAR2(1);
10091
10092 --
10093 BEGIN
10094 --
10095 IF g_log_enabled THEN
10096 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_45';
10097 END IF;
10098 --
10099 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10100
10101 trace
10102 (p_msg => 'BEGIN of AcctLineType_45'
10103 ,p_level => C_LEVEL_PROCEDURE
10104 ,p_module => l_log_module);
10105
10106 END IF;
10107 --
10108 l_component_type := 'AMB_JLT';
10109 l_component_code := 'CHARGE';
10110 l_component_type_code := 'S';
10111 l_component_appl_id := 707;
10112 l_amb_context_code := 'DEFAULT';
10113 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
10114 l_event_class_code := 'RETR_PRICE_ADJ_DEL';
10115 l_event_type_code := 'RETR_PRICE_ADJ_DEL_ALL';
10116 l_line_definition_owner_code := 'S';
10117 l_line_definition_code := 'RETR_PRICE_ADJ_DEL';
10118 --
10119 l_balance_type_code := 'A';
10120 l_segment := NULL;
10121 l_ccid := NULL;
10122 l_adr_transaction_coa_id := NULL;
10123 l_adr_accounting_coa_id := NULL;
10124 l_adr_flexfield_segment_code := NULL;
10125 l_adr_flex_value_set_id := NULL;
10126 l_adr_value_type_code := NULL;
10127 l_adr_value_combination_id := NULL;
10128 l_adr_value_segment_code := NULL;
10129
10130 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10131 l_bflow_class_code := ''; -- 4219869 Business Flow
10132 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10133 l_budgetary_control_flag := 'N';
10134
10135 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10136 l_bflow_applied_to_amt := NULL; -- 5132302
10137 l_entered_amt_idx := NULL; -- 4262811
10138 l_accted_amt_idx := NULL; -- 4262811
10139 l_acc_rev_flag := NULL; -- 4262811
10140 l_accrual_line_num := NULL; -- 4262811
10141 l_tmp_amt := NULL; -- 4262811
10142 --
10143
10144 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10145 l_balance_type_code <> 'B' THEN
10146 IF NVL(p_source_78,'
10147 ') = 'Charge'
10148 THEN
10149
10150 --
10151 XLA_AE_LINES_PKG.SetNewLine;
10152
10153 p_balance_type_code := l_balance_type_code;
10154 -- set the flag so later we will know whether the gain loss line needs to be created
10155
10156 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10157 p_actual_flag :='A';
10158 END IF;
10159
10160 --
10161 -- bulk performance
10162 --
10163 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10164 p_header_num => 0); -- 4262811
10165 --
10166 -- set accounting line options
10167 --
10168 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10169 p_natural_side_code => 'D'
10170 , p_gain_or_loss_flag => 'N'
10171 , p_gl_transfer_mode_code => 'S'
10172 , p_acct_entry_type_code => 'A'
10173 , p_switch_side_flag => 'Y'
10174 , p_merge_duplicate_code => 'N'
10175 );
10176 --
10177 l_acc_rev_natural_side_code := 'C'; -- 4262811
10178 --
10179 --
10180 -- set accounting line type info
10181 --
10182 xla_ae_lines_pkg.SetAcctLineType
10183 (p_component_type => l_component_type
10184 ,p_event_type_code => l_event_type_code
10185 ,p_line_definition_owner_code => l_line_definition_owner_code
10186 ,p_line_definition_code => l_line_definition_code
10187 ,p_accounting_line_code => l_component_code
10188 ,p_accounting_line_type_code => l_component_type_code
10189 ,p_accounting_line_appl_id => l_component_appl_id
10190 ,p_amb_context_code => l_amb_context_code
10191 ,p_entity_code => l_entity_code
10192 ,p_event_class_code => l_event_class_code);
10193 --
10194 -- set accounting class
10195 --
10196 xla_ae_lines_pkg.SetAcctClass(
10197 p_accounting_class_code => 'CHARGE'
10198 , p_ae_header_id => l_ae_header_id
10199 );
10200
10201 --
10202 -- set rounding class
10203 --
10204 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10205 'CHARGE';
10206
10207 --
10208 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10209 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10210 --
10211 -- bulk performance
10212 --
10213 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10214
10215 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10216 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10217
10218 -- 4955764
10219 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10220 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10221
10222 -- 4458381 Public Sector Enh
10223
10224 --
10225 -- set accounting attributes for the line type
10226 --
10227 l_entered_amt_idx := 3;
10228 l_accted_amt_idx := 8;
10229 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10230 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10231 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
10232 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10233 l_rec_acct_attrs.array_char_value(2) := p_source_85;
10234 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10235 l_rec_acct_attrs.array_num_value(3) := p_source_91;
10236 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10237 l_rec_acct_attrs.array_char_value(4) := p_source_88;
10238 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10239 l_rec_acct_attrs.array_date_value(5) := p_source_92;
10240 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10241 l_rec_acct_attrs.array_num_value(6) := p_source_93;
10242 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10243 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
10244 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
10245 l_rec_acct_attrs.array_num_value(8) := p_source_95;
10246
10247 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10248 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10249
10250 ---------------------------------------------------------------------------------------------------------------
10251 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10252 ---------------------------------------------------------------------------------------------------------------
10253 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10254
10255 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10256 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10257
10258 IF xla_accounting_cache_pkg.GetValueChar
10259 (p_source_code => 'LEDGER_CATEGORY_CODE'
10260 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10261 AND l_bflow_method_code = 'PRIOR_ENTRY'
10262 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10263 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10264 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10265 )
10266 THEN
10267 xla_ae_lines_pkg.BflowUpgEntry
10268 (p_business_method_code => l_bflow_method_code
10269 ,p_business_class_code => l_bflow_class_code
10270 ,p_balance_type => l_balance_type_code);
10271 ELSE
10272 NULL;
10273 -- No business flow processing for business flow method of NONE.
10274 END IF;
10275
10276 --
10277 -- call analytical criteria
10278 --
10279
10280 --
10281 -- call description
10282 --
10283 -- No description or it is inherited.
10284 --
10285 -- call ADRs
10286 -- Bug 4922099
10287 --
10288 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10289 (NVL(l_actual_upg_option, 'N') = 'O') OR
10290 (NVL(l_enc_upg_option, 'N') = 'O')
10291 )
10292 THEN
10293 NULL;
10294 --
10295 --
10296
10297 l_ccid := AcctDerRule_6(
10298 p_application_id => p_application_id
10299 , p_ae_header_id => l_ae_header_id
10300 , p_source_11 => p_source_11
10301 , x_transaction_coa_id => l_adr_transaction_coa_id
10302 , x_accounting_coa_id => l_adr_accounting_coa_id
10303 , x_value_type_code => l_adr_value_type_code
10304 , p_side => 'NA'
10305 );
10306
10307 xla_ae_lines_pkg.set_ccid(
10308 p_code_combination_id => l_ccid
10309 , p_value_type_code => l_adr_value_type_code
10310 , p_transaction_coa_id => l_adr_transaction_coa_id
10311 , p_accounting_coa_id => l_adr_accounting_coa_id
10312 , p_adr_code => 'CST_DEFAULT'
10313 , p_adr_type_code => 'S'
10314 , p_component_type => l_component_type
10315 , p_component_code => l_component_code
10316 , p_component_type_code => l_component_type_code
10317 , p_component_appl_id => l_component_appl_id
10318 , p_amb_context_code => l_amb_context_code
10319 , p_side => 'NA'
10320 );
10321
10322
10323 --
10324 --
10325 END IF;
10326 --
10327 -- Bug 4922099
10328 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10329 (NVL(l_enc_upg_option, 'N') = 'O')
10330 ) AND
10331 (l_bflow_method_code = 'PRIOR_ENTRY')
10332 )
10333 THEN
10334 IF
10335 --
10336 1 = 2
10337 --
10338 THEN
10339 xla_accounting_err_pkg.build_message
10340 (p_appli_s_name => 'XLA'
10341 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10342 ,p_token_1 => 'LINE_NUMBER'
10343 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10344 ,p_token_2 => 'LINE_TYPE_NAME'
10345 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10346 l_component_type
10347 ,l_component_code
10348 ,l_component_type_code
10349 ,l_component_appl_id
10350 ,l_amb_context_code
10351 ,l_entity_code
10352 ,l_event_class_code
10353 )
10354 ,p_token_3 => 'OWNER'
10355 ,p_value_3 => xla_lookups_pkg.get_meaning(
10356 p_lookup_type => 'XLA_OWNER_TYPE'
10357 ,p_lookup_code => l_component_type_code
10358 )
10359 ,p_token_4 => 'PRODUCT_NAME'
10360 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10361 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10362 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10363 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10364 ,p_ae_header_id => NULL
10365 );
10366
10367 IF (C_LEVEL_ERROR>= g_log_level) THEN
10368 trace
10369 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10370 ,p_level => C_LEVEL_ERROR
10371 ,p_module => l_log_module);
10372 END IF;
10373 END IF;
10374 END IF;
10375 --
10376 --
10377 ------------------------------------------------------------------------------------------------
10378 -- 4219869 Business Flow
10379 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10380 -- Prior Entry. Currently, the following code is always generated.
10381 ------------------------------------------------------------------------------------------------
10382 XLA_AE_LINES_PKG.ValidateCurrentLine;
10383
10384 ------------------------------------------------------------------------------------
10385 -- 4219869 Business Flow
10386 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10387 ------------------------------------------------------------------------------------
10388 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10389
10390 ----------------------------------------------------------------------------------
10391 -- 4219869 Business Flow
10392 -- Update journal entry status -- Need to generate this within IF <condition>
10393 ----------------------------------------------------------------------------------
10394 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10395 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10396 ,p_balance_type_code => l_balance_type_code
10397 );
10398
10399 -------------------------------------------------------------------------------------------
10400 -- 4262811 - Generate the Accrual Reversal lines
10401 -------------------------------------------------------------------------------------------
10402 BEGIN
10403 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10404 (g_array_event(p_event_id).array_value_num('header_index'));
10405 IF l_acc_rev_flag IS NULL THEN
10406 l_acc_rev_flag := 'N';
10407 END IF;
10408 EXCEPTION
10409 WHEN OTHERS THEN
10410 l_acc_rev_flag := 'N';
10411 END;
10412 --
10413 IF (l_acc_rev_flag = 'Y') THEN
10414
10415 -- 4645092 ------------------------------------------------------------------------------
10416 -- To allow MPA report to determine if it should generate report process
10417 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10418 ------------------------------------------------------------------------------------------
10419
10420 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10421 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10422 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10423 -- call ADRs
10424 -- Bug 4922099
10425 --
10426 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10427 (NVL(l_actual_upg_option, 'N') = 'O') OR
10428 (NVL(l_enc_upg_option, 'N') = 'O')
10429 )
10430 THEN
10431 NULL;
10432 --
10433 --
10434
10435 l_ccid := AcctDerRule_6(
10436 p_application_id => p_application_id
10437 , p_ae_header_id => l_ae_header_id
10438 , p_source_11 => p_source_11
10439 , x_transaction_coa_id => l_adr_transaction_coa_id
10440 , x_accounting_coa_id => l_adr_accounting_coa_id
10441 , x_value_type_code => l_adr_value_type_code
10442 , p_side => 'NA'
10443 );
10444
10445 xla_ae_lines_pkg.set_ccid(
10446 p_code_combination_id => l_ccid
10447 , p_value_type_code => l_adr_value_type_code
10448 , p_transaction_coa_id => l_adr_transaction_coa_id
10449 , p_accounting_coa_id => l_adr_accounting_coa_id
10450 , p_adr_code => 'CST_DEFAULT'
10451 , p_adr_type_code => 'S'
10452 , p_component_type => l_component_type
10453 , p_component_code => l_component_code
10454 , p_component_type_code => l_component_type_code
10455 , p_component_appl_id => l_component_appl_id
10456 , p_amb_context_code => l_amb_context_code
10457 , p_side => 'NA'
10458 );
10459
10460
10461 --
10462 --
10463 END IF;
10464
10465 --
10466 -- Update the line information that should be overwritten
10467 --
10468 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10469 p_header_num => 1);
10470 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10471
10472 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10473
10474 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10475 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10476 END IF;
10477
10478 --
10479 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10480 --
10481 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10482 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10483 ELSE
10484 ---------------------------------------------------------------------------------------------------
10485 -- 4262811a Switch Sign
10486 ---------------------------------------------------------------------------------------------------
10487 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10489 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10490 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10491 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10492 -- 5132302
10493 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10494 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10495
10496 END IF;
10497
10498 -- 4955764
10499 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10500 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10501
10502
10503 XLA_AE_LINES_PKG.ValidateCurrentLine;
10504 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10505
10506 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10507 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10508 ,p_balance_type_code => l_balance_type_code);
10509
10510 END IF;
10511
10512 -----------------------------------------------------------------------------------------
10513 -- 4262811 Multiperiod Accounting
10514 -----------------------------------------------------------------------------------------
10515 -- No MPA option is assigned.
10516
10517
10518 END IF;
10519 END IF;
10520 --
10521
10522 --
10523 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10524 trace
10525 (p_msg => 'END of AcctLineType_45'
10526 ,p_level => C_LEVEL_PROCEDURE
10527 ,p_module => l_log_module);
10528 END IF;
10529 --
10530 EXCEPTION
10531 WHEN xla_exceptions_pkg.application_exception THEN
10532 RAISE;
10533 WHEN OTHERS THEN
10534 xla_exceptions_pkg.raise_message
10535 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_45');
10536 END AcctLineType_45;
10537 --
10538
10539 ---------------------------------------
10540 --
10541 -- PRIVATE FUNCTION
10542 -- AcctLineType_46
10543 --
10544 ---------------------------------------
10545 PROCEDURE AcctLineType_46 (
10546 p_application_id IN NUMBER
10547 ,p_event_id IN NUMBER
10548 ,p_calculate_acctd_flag IN VARCHAR2
10549 ,p_calculate_g_l_flag IN VARCHAR2
10550 ,p_actual_flag IN OUT VARCHAR2
10551 ,p_balance_type_code OUT VARCHAR2
10552 ,p_gain_or_loss_ref OUT VARCHAR2
10553
10554 --TRANSACTION_ID
10555 , p_source_1 IN NUMBER
10556 --Item Concatenated Segments
10557 , p_source_2 IN VARCHAR2
10558 --Transaction Quantity
10559 , p_source_3 IN NUMBER
10560 --Transaction Unit of Measure Code
10561 , p_source_4 IN VARCHAR2
10562 --Inventory Transaction Type Description
10563 , p_source_5 IN VARCHAR2
10564 --Cost Management Default Account
10565 , p_source_11 IN NUMBER
10566 --DISTRIBUTION_IDENTIFIER
10567 , p_source_84 IN NUMBER
10568 --Distribution Type
10569 , p_source_85 IN VARCHAR2
10570 , p_source_85_meaning IN VARCHAR2
10571 --Entered Currency Code
10572 , p_source_88 IN VARCHAR2
10573 --Entered Amount
10574 , p_source_91 IN NUMBER
10575 --Currency Conversion Date
10576 , p_source_92 IN DATE
10577 --Currency Conversion Rate
10578 , p_source_93 IN NUMBER
10579 --Currency Conversion Type
10580 , p_source_94 IN VARCHAR2
10581 --Accounted Amount
10582 , p_source_95 IN NUMBER
10583 --Accounting Line Type
10584 , p_source_97 IN NUMBER
10585 )
10586 IS
10587
10588 l_component_type VARCHAR2(80);
10589 l_component_code VARCHAR2(30);
10590 l_component_type_code VARCHAR2(1);
10591 l_component_appl_id INTEGER;
10592 l_amb_context_code VARCHAR2(30);
10593 l_entity_code VARCHAR2(30);
10594 l_event_class_code VARCHAR2(30);
10595 l_ae_header_id NUMBER;
10596 l_event_type_code VARCHAR2(30);
10597 l_line_definition_code VARCHAR2(30);
10598 l_line_definition_owner_code VARCHAR2(1);
10599 --
10600 -- adr variables
10601 l_segment VARCHAR2(30);
10602 l_ccid NUMBER;
10603 l_adr_transaction_coa_id NUMBER;
10604 l_adr_accounting_coa_id NUMBER;
10605 l_adr_flexfield_segment_code VARCHAR2(30);
10606 l_adr_flex_value_set_id NUMBER;
10607 l_adr_value_type_code VARCHAR2(30);
10608 l_adr_value_combination_id NUMBER;
10609 l_adr_value_segment_code VARCHAR2(30);
10610
10611 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10612 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10613 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10614 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10615
10616 -- 4262811 Variables ------------------------------------------------------------------------------------------
10617 l_entered_amt_idx NUMBER;
10618 l_accted_amt_idx NUMBER;
10619 l_acc_rev_flag VARCHAR2(1);
10620 l_accrual_line_num NUMBER;
10621 l_tmp_amt NUMBER;
10622 l_acc_rev_natural_side_code VARCHAR2(1);
10623
10624 l_num_entries NUMBER;
10625 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10626 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10627 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10628 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10629 l_recog_line_1 NUMBER;
10630 l_recog_line_2 NUMBER;
10631
10632 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10633 l_bflow_applied_to_amt NUMBER; -- 5132302
10634 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10635
10636 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10637
10638 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10639 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10640
10641 ---------------------------------------------------------------------------------------------------------------
10642
10643
10644 --
10645 -- bulk performance
10646 --
10647 l_balance_type_code VARCHAR2(1);
10648 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10649 l_log_module VARCHAR2(240);
10650
10651 --
10652 -- Upgrade strategy
10653 --
10654 l_actual_upg_option VARCHAR2(1);
10655 l_enc_upg_option VARCHAR2(1);
10656
10657 --
10658 BEGIN
10659 --
10660 IF g_log_enabled THEN
10661 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_46';
10662 END IF;
10663 --
10664 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10665
10666 trace
10667 (p_msg => 'BEGIN of AcctLineType_46'
10668 ,p_level => C_LEVEL_PROCEDURE
10669 ,p_module => l_log_module);
10670
10671 END IF;
10672 --
10673 l_component_type := 'AMB_JLT';
10674 l_component_code := 'CLEARING';
10675 l_component_type_code := 'S';
10676 l_component_appl_id := 707;
10677 l_amb_context_code := 'DEFAULT';
10678 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
10679 l_event_class_code := 'LOG_INTERCOMPANY';
10680 l_event_type_code := 'LOG_IC_SHIPMENT_RCPT';
10681 l_line_definition_owner_code := 'S';
10682 l_line_definition_code := 'PI_LOG_IC_SHIPMENT_RCPT';
10683 --
10684 l_balance_type_code := 'A';
10685 l_segment := NULL;
10686 l_ccid := NULL;
10687 l_adr_transaction_coa_id := NULL;
10688 l_adr_accounting_coa_id := NULL;
10689 l_adr_flexfield_segment_code := NULL;
10690 l_adr_flex_value_set_id := NULL;
10691 l_adr_value_type_code := NULL;
10692 l_adr_value_combination_id := NULL;
10693 l_adr_value_segment_code := NULL;
10694
10695 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10696 l_bflow_class_code := ''; -- 4219869 Business Flow
10697 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10698 l_budgetary_control_flag := 'N';
10699
10700 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10701 l_bflow_applied_to_amt := NULL; -- 5132302
10702 l_entered_amt_idx := NULL; -- 4262811
10703 l_accted_amt_idx := NULL; -- 4262811
10704 l_acc_rev_flag := NULL; -- 4262811
10705 l_accrual_line_num := NULL; -- 4262811
10706 l_tmp_amt := NULL; -- 4262811
10707 --
10708
10709 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10710 l_balance_type_code <> 'B' THEN
10711 IF NVL(p_source_97,9E125) = 31
10712 THEN
10713
10714 --
10715 XLA_AE_LINES_PKG.SetNewLine;
10716
10717 p_balance_type_code := l_balance_type_code;
10718 -- set the flag so later we will know whether the gain loss line needs to be created
10719
10720 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10721 p_actual_flag :='A';
10722 END IF;
10723
10724 --
10725 -- bulk performance
10726 --
10727 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10728 p_header_num => 0); -- 4262811
10729 --
10730 -- set accounting line options
10731 --
10732 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10733 p_natural_side_code => 'D'
10734 , p_gain_or_loss_flag => 'N'
10735 , p_gl_transfer_mode_code => 'S'
10736 , p_acct_entry_type_code => 'A'
10737 , p_switch_side_flag => 'Y'
10738 , p_merge_duplicate_code => 'N'
10739 );
10740 --
10741 l_acc_rev_natural_side_code := 'C'; -- 4262811
10742 --
10743 --
10744 -- set accounting line type info
10745 --
10746 xla_ae_lines_pkg.SetAcctLineType
10747 (p_component_type => l_component_type
10748 ,p_event_type_code => l_event_type_code
10749 ,p_line_definition_owner_code => l_line_definition_owner_code
10750 ,p_line_definition_code => l_line_definition_code
10751 ,p_accounting_line_code => l_component_code
10752 ,p_accounting_line_type_code => l_component_type_code
10753 ,p_accounting_line_appl_id => l_component_appl_id
10754 ,p_amb_context_code => l_amb_context_code
10755 ,p_entity_code => l_entity_code
10756 ,p_event_class_code => l_event_class_code);
10757 --
10758 -- set accounting class
10759 --
10760 xla_ae_lines_pkg.SetAcctClass(
10761 p_accounting_class_code => 'CLEARING'
10762 , p_ae_header_id => l_ae_header_id
10763 );
10764
10765 --
10766 -- set rounding class
10767 --
10768 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10769 'CLEARING';
10770
10771 --
10772 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10773 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10774 --
10775 -- bulk performance
10776 --
10777 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10778
10779 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10780 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10781
10782 -- 4955764
10783 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10784 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10785
10786 -- 4458381 Public Sector Enh
10787
10788 --
10789 -- set accounting attributes for the line type
10790 --
10791 l_entered_amt_idx := 3;
10792 l_accted_amt_idx := 8;
10793 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10794 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10795 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
10796 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10797 l_rec_acct_attrs.array_char_value(2) := p_source_85;
10798 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10799 l_rec_acct_attrs.array_num_value(3) := p_source_91;
10800 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10801 l_rec_acct_attrs.array_char_value(4) := p_source_88;
10802 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10803 l_rec_acct_attrs.array_date_value(5) := p_source_92;
10804 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10805 l_rec_acct_attrs.array_num_value(6) := p_source_93;
10806 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10807 l_rec_acct_attrs.array_char_value(7) := p_source_94;
10808 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
10809 l_rec_acct_attrs.array_num_value(8) := p_source_95;
10810
10811 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10812 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10813
10814 ---------------------------------------------------------------------------------------------------------------
10815 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10816 ---------------------------------------------------------------------------------------------------------------
10817 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10818
10819 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10820 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10821
10822 IF xla_accounting_cache_pkg.GetValueChar
10823 (p_source_code => 'LEDGER_CATEGORY_CODE'
10824 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10825 AND l_bflow_method_code = 'PRIOR_ENTRY'
10826 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10827 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10828 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10829 )
10830 THEN
10831 xla_ae_lines_pkg.BflowUpgEntry
10832 (p_business_method_code => l_bflow_method_code
10833 ,p_business_class_code => l_bflow_class_code
10834 ,p_balance_type => l_balance_type_code);
10835 ELSE
10836 NULL;
10837 -- No business flow processing for business flow method of NONE.
10838 END IF;
10839
10840 --
10841 -- call analytical criteria
10842 --
10843
10844 --
10845 -- call description
10846 --
10847
10848 xla_ae_lines_pkg.SetLineDescription(
10849 p_ae_header_id => l_ae_header_id
10850 ,p_description => Description_1 (
10851 p_application_id => p_application_id
10852 , p_ae_header_id => l_ae_header_id
10853 , p_source_1 => p_source_1
10854 , p_source_2 => p_source_2
10855 , p_source_3 => p_source_3
10856 , p_source_4 => p_source_4
10857 , p_source_5 => p_source_5
10858 )
10859 );
10860
10861
10862 --
10863 -- call ADRs
10864 -- Bug 4922099
10865 --
10866 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10867 (NVL(l_actual_upg_option, 'N') = 'O') OR
10868 (NVL(l_enc_upg_option, 'N') = 'O')
10869 )
10870 THEN
10871 NULL;
10872 --
10873 --
10874
10875 l_ccid := AcctDerRule_6(
10876 p_application_id => p_application_id
10877 , p_ae_header_id => l_ae_header_id
10878 , p_source_11 => p_source_11
10879 , x_transaction_coa_id => l_adr_transaction_coa_id
10880 , x_accounting_coa_id => l_adr_accounting_coa_id
10881 , x_value_type_code => l_adr_value_type_code
10882 , p_side => 'NA'
10883 );
10884
10885 xla_ae_lines_pkg.set_ccid(
10886 p_code_combination_id => l_ccid
10887 , p_value_type_code => l_adr_value_type_code
10888 , p_transaction_coa_id => l_adr_transaction_coa_id
10889 , p_accounting_coa_id => l_adr_accounting_coa_id
10890 , p_adr_code => 'CST_DEFAULT'
10891 , p_adr_type_code => 'S'
10892 , p_component_type => l_component_type
10893 , p_component_code => l_component_code
10894 , p_component_type_code => l_component_type_code
10895 , p_component_appl_id => l_component_appl_id
10896 , p_amb_context_code => l_amb_context_code
10897 , p_side => 'NA'
10898 );
10899
10900
10901 --
10902 --
10903 END IF;
10904 --
10905 -- Bug 4922099
10906 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10907 (NVL(l_enc_upg_option, 'N') = 'O')
10908 ) AND
10909 (l_bflow_method_code = 'PRIOR_ENTRY')
10910 )
10911 THEN
10912 IF
10913 --
10914 1 = 2
10915 --
10916 THEN
10917 xla_accounting_err_pkg.build_message
10918 (p_appli_s_name => 'XLA'
10919 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10920 ,p_token_1 => 'LINE_NUMBER'
10921 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10922 ,p_token_2 => 'LINE_TYPE_NAME'
10923 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10924 l_component_type
10925 ,l_component_code
10926 ,l_component_type_code
10927 ,l_component_appl_id
10928 ,l_amb_context_code
10929 ,l_entity_code
10930 ,l_event_class_code
10931 )
10932 ,p_token_3 => 'OWNER'
10933 ,p_value_3 => xla_lookups_pkg.get_meaning(
10934 p_lookup_type => 'XLA_OWNER_TYPE'
10935 ,p_lookup_code => l_component_type_code
10936 )
10937 ,p_token_4 => 'PRODUCT_NAME'
10938 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10939 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10940 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10941 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10942 ,p_ae_header_id => NULL
10943 );
10944
10945 IF (C_LEVEL_ERROR>= g_log_level) THEN
10946 trace
10947 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10948 ,p_level => C_LEVEL_ERROR
10949 ,p_module => l_log_module);
10950 END IF;
10951 END IF;
10952 END IF;
10953 --
10954 --
10955 ------------------------------------------------------------------------------------------------
10956 -- 4219869 Business Flow
10957 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10958 -- Prior Entry. Currently, the following code is always generated.
10959 ------------------------------------------------------------------------------------------------
10960 XLA_AE_LINES_PKG.ValidateCurrentLine;
10961
10962 ------------------------------------------------------------------------------------
10963 -- 4219869 Business Flow
10964 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10965 ------------------------------------------------------------------------------------
10966 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10967
10968 ----------------------------------------------------------------------------------
10969 -- 4219869 Business Flow
10970 -- Update journal entry status -- Need to generate this within IF <condition>
10971 ----------------------------------------------------------------------------------
10972 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10973 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10974 ,p_balance_type_code => l_balance_type_code
10975 );
10976
10977 -------------------------------------------------------------------------------------------
10978 -- 4262811 - Generate the Accrual Reversal lines
10979 -------------------------------------------------------------------------------------------
10980 BEGIN
10981 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10982 (g_array_event(p_event_id).array_value_num('header_index'));
10983 IF l_acc_rev_flag IS NULL THEN
10984 l_acc_rev_flag := 'N';
10985 END IF;
10986 EXCEPTION
10987 WHEN OTHERS THEN
10988 l_acc_rev_flag := 'N';
10989 END;
10990 --
10991 IF (l_acc_rev_flag = 'Y') THEN
10992
10993 -- 4645092 ------------------------------------------------------------------------------
10994 -- To allow MPA report to determine if it should generate report process
10995 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10996 ------------------------------------------------------------------------------------------
10997
10998 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10999 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11000 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11001 -- call ADRs
11002 -- Bug 4922099
11003 --
11004 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11005 (NVL(l_actual_upg_option, 'N') = 'O') OR
11006 (NVL(l_enc_upg_option, 'N') = 'O')
11007 )
11008 THEN
11009 NULL;
11010 --
11011 --
11012
11013 l_ccid := AcctDerRule_6(
11014 p_application_id => p_application_id
11015 , p_ae_header_id => l_ae_header_id
11016 , p_source_11 => p_source_11
11017 , x_transaction_coa_id => l_adr_transaction_coa_id
11018 , x_accounting_coa_id => l_adr_accounting_coa_id
11019 , x_value_type_code => l_adr_value_type_code
11020 , p_side => 'NA'
11021 );
11022
11023 xla_ae_lines_pkg.set_ccid(
11024 p_code_combination_id => l_ccid
11025 , p_value_type_code => l_adr_value_type_code
11026 , p_transaction_coa_id => l_adr_transaction_coa_id
11027 , p_accounting_coa_id => l_adr_accounting_coa_id
11028 , p_adr_code => 'CST_DEFAULT'
11029 , p_adr_type_code => 'S'
11030 , p_component_type => l_component_type
11031 , p_component_code => l_component_code
11032 , p_component_type_code => l_component_type_code
11033 , p_component_appl_id => l_component_appl_id
11034 , p_amb_context_code => l_amb_context_code
11035 , p_side => 'NA'
11036 );
11037
11038
11039 --
11040 --
11041 END IF;
11042
11043 --
11044 -- Update the line information that should be overwritten
11045 --
11046 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11047 p_header_num => 1);
11048 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11049
11050 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11051
11052 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11053 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11054 END IF;
11055
11056 --
11057 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11058 --
11059 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11060 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11061 ELSE
11062 ---------------------------------------------------------------------------------------------------
11063 -- 4262811a Switch Sign
11064 ---------------------------------------------------------------------------------------------------
11065 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11068 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11070 -- 5132302
11071 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11073
11074 END IF;
11075
11076 -- 4955764
11077 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11078 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11079
11080
11081 XLA_AE_LINES_PKG.ValidateCurrentLine;
11082 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11083
11084 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11085 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11086 ,p_balance_type_code => l_balance_type_code);
11087
11088 END IF;
11089
11090 -----------------------------------------------------------------------------------------
11091 -- 4262811 Multiperiod Accounting
11092 -----------------------------------------------------------------------------------------
11093 -- No MPA option is assigned.
11094
11095
11096 END IF;
11097 END IF;
11098 --
11099
11100 --
11101 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11102 trace
11103 (p_msg => 'END of AcctLineType_46'
11104 ,p_level => C_LEVEL_PROCEDURE
11105 ,p_module => l_log_module);
11106 END IF;
11107 --
11108 EXCEPTION
11109 WHEN xla_exceptions_pkg.application_exception THEN
11110 RAISE;
11111 WHEN OTHERS THEN
11112 xla_exceptions_pkg.raise_message
11113 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_46');
11114 END AcctLineType_46;
11115 --
11116
11117 ---------------------------------------
11118 --
11119 -- PRIVATE FUNCTION
11120 -- AcctLineType_47
11121 --
11122 ---------------------------------------
11123 PROCEDURE AcctLineType_47 (
11124 p_application_id IN NUMBER
11125 ,p_event_id IN NUMBER
11126 ,p_calculate_acctd_flag IN VARCHAR2
11127 ,p_calculate_g_l_flag IN VARCHAR2
11128 ,p_actual_flag IN OUT VARCHAR2
11129 ,p_balance_type_code OUT VARCHAR2
11130 ,p_gain_or_loss_ref OUT VARCHAR2
11131
11132 --TRANSACTION_ID
11133 , p_source_1 IN NUMBER
11134 --Item Concatenated Segments
11135 , p_source_2 IN VARCHAR2
11136 --Transaction Quantity
11137 , p_source_3 IN NUMBER
11138 --Transaction Unit of Measure Code
11139 , p_source_4 IN VARCHAR2
11140 --Inventory Transaction Type Description
11141 , p_source_5 IN VARCHAR2
11142 --Cost Management Default Account
11143 , p_source_11 IN NUMBER
11144 --Applied to Application ID
11145 , p_source_79 IN NUMBER
11146 --Applied to Distribution Link Type
11147 , p_source_80 IN VARCHAR2
11148 --Applied to Entity Code
11149 , p_source_81 IN VARCHAR2
11150 --Applied To Purchase Document Identifier
11151 , p_source_83 IN NUMBER
11152 --DISTRIBUTION_IDENTIFIER
11153 , p_source_84 IN NUMBER
11154 --Distribution Type
11155 , p_source_85 IN VARCHAR2
11156 , p_source_85_meaning IN VARCHAR2
11157 --PO Budget Account
11158 , p_source_86 IN NUMBER
11159 --Encumbrance Reversal Amount Entered
11160 , p_source_87 IN NUMBER
11161 --Entered Currency Code
11162 , p_source_88 IN VARCHAR2
11163 --Transaction Encumbrance Reversal Amount
11164 , p_source_89 IN NUMBER
11165 --Entered Amount
11166 , p_source_91 IN NUMBER
11167 --Currency Conversion Date
11168 , p_source_92 IN DATE
11169 --Currency Conversion Rate
11170 , p_source_93 IN NUMBER
11171 --Currency Conversion Type
11172 , p_source_94 IN VARCHAR2
11173 --Accounted Amount
11174 , p_source_95 IN NUMBER
11175 --Purchasing Encumbrance Type Identifier
11176 , p_source_96 IN NUMBER
11177 --Accounting Line Type
11178 , p_source_97 IN NUMBER
11179 --Costing Encumbrance Upgrade Option
11180 , p_source_100 IN VARCHAR2
11181 --TXN_PO_DISTRIBUTION_ID
11182 , p_source_101 IN NUMBER
11183 )
11184 IS
11185
11186 l_component_type VARCHAR2(80);
11187 l_component_code VARCHAR2(30);
11188 l_component_type_code VARCHAR2(1);
11189 l_component_appl_id INTEGER;
11190 l_amb_context_code VARCHAR2(30);
11191 l_entity_code VARCHAR2(30);
11192 l_event_class_code VARCHAR2(30);
11193 l_ae_header_id NUMBER;
11194 l_event_type_code VARCHAR2(30);
11195 l_line_definition_code VARCHAR2(30);
11196 l_line_definition_owner_code VARCHAR2(1);
11197 --
11198 -- adr variables
11199 l_segment VARCHAR2(30);
11200 l_ccid NUMBER;
11201 l_adr_transaction_coa_id NUMBER;
11202 l_adr_accounting_coa_id NUMBER;
11203 l_adr_flexfield_segment_code VARCHAR2(30);
11204 l_adr_flex_value_set_id NUMBER;
11205 l_adr_value_type_code VARCHAR2(30);
11206 l_adr_value_combination_id NUMBER;
11207 l_adr_value_segment_code VARCHAR2(30);
11208
11209 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11210 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11211 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11212 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11213
11214 -- 4262811 Variables ------------------------------------------------------------------------------------------
11215 l_entered_amt_idx NUMBER;
11216 l_accted_amt_idx NUMBER;
11217 l_acc_rev_flag VARCHAR2(1);
11218 l_accrual_line_num NUMBER;
11219 l_tmp_amt NUMBER;
11220 l_acc_rev_natural_side_code VARCHAR2(1);
11221
11222 l_num_entries NUMBER;
11223 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11224 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11225 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11226 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11227 l_recog_line_1 NUMBER;
11228 l_recog_line_2 NUMBER;
11229
11230 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11231 l_bflow_applied_to_amt NUMBER; -- 5132302
11232 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11233
11234 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11235
11236 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11237 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11238
11239 ---------------------------------------------------------------------------------------------------------------
11240
11241
11242 --
11243 -- bulk performance
11244 --
11245 l_balance_type_code VARCHAR2(1);
11246 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11247 l_log_module VARCHAR2(240);
11248
11249 --
11250 -- Upgrade strategy
11251 --
11252 l_actual_upg_option VARCHAR2(1);
11253 l_enc_upg_option VARCHAR2(1);
11254
11255 --
11256 BEGIN
11257 --
11258 IF g_log_enabled THEN
11259 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_47';
11260 END IF;
11261 --
11262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11263
11264 trace
11265 (p_msg => 'BEGIN of AcctLineType_47'
11266 ,p_level => C_LEVEL_PROCEDURE
11267 ,p_module => l_log_module);
11268
11269 END IF;
11270 --
11271 l_component_type := 'AMB_JLT';
11272 l_component_code := 'CLEARING';
11273 l_component_type_code := 'S';
11274 l_component_appl_id := 707;
11275 l_amb_context_code := 'DEFAULT';
11276 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
11277 l_event_class_code := 'PURCHASE_ORDER';
11278 l_event_type_code := 'LOG_RET_RI_INV';
11279 l_line_definition_owner_code := 'S';
11280 l_line_definition_code := 'PI_LOG_RET_RI_INV';
11281 --
11282 l_balance_type_code := 'A';
11283 l_segment := NULL;
11284 l_ccid := NULL;
11285 l_adr_transaction_coa_id := NULL;
11286 l_adr_accounting_coa_id := NULL;
11287 l_adr_flexfield_segment_code := NULL;
11288 l_adr_flex_value_set_id := NULL;
11289 l_adr_value_type_code := NULL;
11290 l_adr_value_combination_id := NULL;
11291 l_adr_value_segment_code := NULL;
11292
11293 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11294 l_bflow_class_code := ''; -- 4219869 Business Flow
11295 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11296 l_budgetary_control_flag := 'N';
11297
11298 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11299 l_bflow_applied_to_amt := NULL; -- 5132302
11300 l_entered_amt_idx := NULL; -- 4262811
11301 l_accted_amt_idx := NULL; -- 4262811
11302 l_acc_rev_flag := NULL; -- 4262811
11303 l_accrual_line_num := NULL; -- 4262811
11304 l_tmp_amt := NULL; -- 4262811
11305 --
11306
11307 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11308 l_balance_type_code <> 'B' THEN
11309 IF NVL(p_source_97,9E125) = 31
11310 THEN
11311
11312 --
11313 XLA_AE_LINES_PKG.SetNewLine;
11314
11315 p_balance_type_code := l_balance_type_code;
11316 -- set the flag so later we will know whether the gain loss line needs to be created
11317
11318 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11319 p_actual_flag :='A';
11320 END IF;
11321
11322 --
11323 -- bulk performance
11324 --
11325 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11326 p_header_num => 0); -- 4262811
11327 --
11328 -- set accounting line options
11329 --
11330 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11331 p_natural_side_code => 'D'
11332 , p_gain_or_loss_flag => 'N'
11333 , p_gl_transfer_mode_code => 'S'
11334 , p_acct_entry_type_code => 'A'
11335 , p_switch_side_flag => 'Y'
11336 , p_merge_duplicate_code => 'N'
11337 );
11338 --
11339 l_acc_rev_natural_side_code := 'C'; -- 4262811
11340 --
11341 --
11342 -- set accounting line type info
11343 --
11344 xla_ae_lines_pkg.SetAcctLineType
11345 (p_component_type => l_component_type
11346 ,p_event_type_code => l_event_type_code
11347 ,p_line_definition_owner_code => l_line_definition_owner_code
11348 ,p_line_definition_code => l_line_definition_code
11349 ,p_accounting_line_code => l_component_code
11350 ,p_accounting_line_type_code => l_component_type_code
11351 ,p_accounting_line_appl_id => l_component_appl_id
11352 ,p_amb_context_code => l_amb_context_code
11353 ,p_entity_code => l_entity_code
11354 ,p_event_class_code => l_event_class_code);
11355 --
11356 -- set accounting class
11357 --
11358 xla_ae_lines_pkg.SetAcctClass(
11359 p_accounting_class_code => 'CLEARING'
11360 , p_ae_header_id => l_ae_header_id
11361 );
11362
11363 --
11364 -- set rounding class
11365 --
11366 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11367 'CLEARING';
11368
11369 --
11370 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11371 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11372 --
11373 -- bulk performance
11374 --
11375 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11376
11377 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11378 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11379
11380 -- 4955764
11381 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11382 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11383
11384 -- 4458381 Public Sector Enh
11385
11386 --
11387 -- set accounting attributes for the line type
11388 --
11389 l_entered_amt_idx := 17;
11390 l_accted_amt_idx := 22;
11391 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11392 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
11393 l_rec_acct_attrs.array_num_value(1) := p_source_79;
11394 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
11395 l_rec_acct_attrs.array_char_value(2) := p_source_80;
11396 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
11397 l_rec_acct_attrs.array_char_value(3) := p_source_81;
11398 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
11399 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
11400 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
11401 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
11402 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
11403 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
11404 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
11405 l_rec_acct_attrs.array_char_value(7) := p_source_85;
11406 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
11407 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
11408 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
11409 l_rec_acct_attrs.array_num_value(9) := p_source_87;
11410 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
11411 l_rec_acct_attrs.array_char_value(10) := p_source_88;
11412 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
11413 l_rec_acct_attrs.array_num_value(11) := p_source_89;
11414 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
11415 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
11416 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
11417 l_rec_acct_attrs.array_num_value(13) := p_source_87;
11418 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
11419 l_rec_acct_attrs.array_char_value(14) := p_source_88;
11420 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
11421 l_rec_acct_attrs.array_num_value(15) := p_source_89;
11422 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
11423 l_rec_acct_attrs.array_char_value(16) := p_source_100;
11424 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
11425 l_rec_acct_attrs.array_num_value(17) := p_source_91;
11426 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
11427 l_rec_acct_attrs.array_char_value(18) := p_source_88;
11428 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
11429 l_rec_acct_attrs.array_date_value(19) := p_source_92;
11430 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
11431 l_rec_acct_attrs.array_num_value(20) := p_source_93;
11432 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
11433 l_rec_acct_attrs.array_char_value(21) := p_source_94;
11434 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
11435 l_rec_acct_attrs.array_num_value(22) := p_source_95;
11436 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
11437 l_rec_acct_attrs.array_num_value(23) := p_source_96;
11438 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
11439 l_rec_acct_attrs.array_num_value(24) := p_source_96;
11440
11441 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11442 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11443
11444 ---------------------------------------------------------------------------------------------------------------
11445 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11446 ---------------------------------------------------------------------------------------------------------------
11447 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11448
11449 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11450 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11451
11452 IF xla_accounting_cache_pkg.GetValueChar
11453 (p_source_code => 'LEDGER_CATEGORY_CODE'
11454 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11455 AND l_bflow_method_code = 'PRIOR_ENTRY'
11456 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11457 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11458 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11459 )
11460 THEN
11461 xla_ae_lines_pkg.BflowUpgEntry
11462 (p_business_method_code => l_bflow_method_code
11463 ,p_business_class_code => l_bflow_class_code
11464 ,p_balance_type => l_balance_type_code);
11465 ELSE
11466 NULL;
11467 -- No business flow processing for business flow method of NONE.
11468 END IF;
11469
11470 --
11471 -- call analytical criteria
11472 --
11473
11474 --
11475 -- call description
11476 --
11477
11478 xla_ae_lines_pkg.SetLineDescription(
11479 p_ae_header_id => l_ae_header_id
11480 ,p_description => Description_1 (
11481 p_application_id => p_application_id
11482 , p_ae_header_id => l_ae_header_id
11483 , p_source_1 => p_source_1
11484 , p_source_2 => p_source_2
11485 , p_source_3 => p_source_3
11486 , p_source_4 => p_source_4
11487 , p_source_5 => p_source_5
11488 )
11489 );
11490
11491
11492 --
11493 -- call ADRs
11494 -- Bug 4922099
11495 --
11496 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11497 (NVL(l_actual_upg_option, 'N') = 'O') OR
11498 (NVL(l_enc_upg_option, 'N') = 'O')
11499 )
11500 THEN
11501 NULL;
11502 --
11503 --
11504
11505 l_ccid := AcctDerRule_6(
11506 p_application_id => p_application_id
11507 , p_ae_header_id => l_ae_header_id
11508 , p_source_11 => p_source_11
11509 , x_transaction_coa_id => l_adr_transaction_coa_id
11510 , x_accounting_coa_id => l_adr_accounting_coa_id
11511 , x_value_type_code => l_adr_value_type_code
11512 , p_side => 'NA'
11513 );
11514
11515 xla_ae_lines_pkg.set_ccid(
11516 p_code_combination_id => l_ccid
11517 , p_value_type_code => l_adr_value_type_code
11518 , p_transaction_coa_id => l_adr_transaction_coa_id
11519 , p_accounting_coa_id => l_adr_accounting_coa_id
11520 , p_adr_code => 'CST_DEFAULT'
11521 , p_adr_type_code => 'S'
11522 , p_component_type => l_component_type
11523 , p_component_code => l_component_code
11524 , p_component_type_code => l_component_type_code
11525 , p_component_appl_id => l_component_appl_id
11526 , p_amb_context_code => l_amb_context_code
11527 , p_side => 'NA'
11528 );
11529
11530
11531 --
11532 --
11533 END IF;
11534 --
11535 -- Bug 4922099
11536 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11537 (NVL(l_enc_upg_option, 'N') = 'O')
11538 ) AND
11539 (l_bflow_method_code = 'PRIOR_ENTRY')
11540 )
11541 THEN
11542 IF
11543 --
11544 1 = 2
11545 --
11546 THEN
11547 xla_accounting_err_pkg.build_message
11548 (p_appli_s_name => 'XLA'
11549 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11550 ,p_token_1 => 'LINE_NUMBER'
11551 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11552 ,p_token_2 => 'LINE_TYPE_NAME'
11553 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11554 l_component_type
11555 ,l_component_code
11556 ,l_component_type_code
11557 ,l_component_appl_id
11558 ,l_amb_context_code
11559 ,l_entity_code
11560 ,l_event_class_code
11561 )
11562 ,p_token_3 => 'OWNER'
11563 ,p_value_3 => xla_lookups_pkg.get_meaning(
11564 p_lookup_type => 'XLA_OWNER_TYPE'
11565 ,p_lookup_code => l_component_type_code
11566 )
11567 ,p_token_4 => 'PRODUCT_NAME'
11568 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11569 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11570 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11571 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11572 ,p_ae_header_id => NULL
11573 );
11574
11575 IF (C_LEVEL_ERROR>= g_log_level) THEN
11576 trace
11577 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11578 ,p_level => C_LEVEL_ERROR
11579 ,p_module => l_log_module);
11580 END IF;
11581 END IF;
11582 END IF;
11583 --
11584 --
11585 ------------------------------------------------------------------------------------------------
11586 -- 4219869 Business Flow
11587 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11588 -- Prior Entry. Currently, the following code is always generated.
11589 ------------------------------------------------------------------------------------------------
11590 XLA_AE_LINES_PKG.ValidateCurrentLine;
11591
11592 ------------------------------------------------------------------------------------
11593 -- 4219869 Business Flow
11594 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11595 ------------------------------------------------------------------------------------
11596 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11597
11598 ----------------------------------------------------------------------------------
11599 -- 4219869 Business Flow
11600 -- Update journal entry status -- Need to generate this within IF <condition>
11601 ----------------------------------------------------------------------------------
11602 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11603 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11604 ,p_balance_type_code => l_balance_type_code
11605 );
11606
11607 -------------------------------------------------------------------------------------------
11608 -- 4262811 - Generate the Accrual Reversal lines
11609 -------------------------------------------------------------------------------------------
11610 BEGIN
11611 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11612 (g_array_event(p_event_id).array_value_num('header_index'));
11613 IF l_acc_rev_flag IS NULL THEN
11614 l_acc_rev_flag := 'N';
11615 END IF;
11616 EXCEPTION
11617 WHEN OTHERS THEN
11618 l_acc_rev_flag := 'N';
11619 END;
11620 --
11621 IF (l_acc_rev_flag = 'Y') THEN
11622
11623 -- 4645092 ------------------------------------------------------------------------------
11624 -- To allow MPA report to determine if it should generate report process
11625 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11626 ------------------------------------------------------------------------------------------
11627
11628 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11629 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11630 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11631 -- call ADRs
11632 -- Bug 4922099
11633 --
11634 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11635 (NVL(l_actual_upg_option, 'N') = 'O') OR
11636 (NVL(l_enc_upg_option, 'N') = 'O')
11637 )
11638 THEN
11639 NULL;
11640 --
11641 --
11642
11643 l_ccid := AcctDerRule_6(
11644 p_application_id => p_application_id
11645 , p_ae_header_id => l_ae_header_id
11646 , p_source_11 => p_source_11
11647 , x_transaction_coa_id => l_adr_transaction_coa_id
11648 , x_accounting_coa_id => l_adr_accounting_coa_id
11649 , x_value_type_code => l_adr_value_type_code
11650 , p_side => 'NA'
11651 );
11652
11653 xla_ae_lines_pkg.set_ccid(
11654 p_code_combination_id => l_ccid
11655 , p_value_type_code => l_adr_value_type_code
11656 , p_transaction_coa_id => l_adr_transaction_coa_id
11657 , p_accounting_coa_id => l_adr_accounting_coa_id
11658 , p_adr_code => 'CST_DEFAULT'
11659 , p_adr_type_code => 'S'
11660 , p_component_type => l_component_type
11661 , p_component_code => l_component_code
11662 , p_component_type_code => l_component_type_code
11663 , p_component_appl_id => l_component_appl_id
11664 , p_amb_context_code => l_amb_context_code
11665 , p_side => 'NA'
11666 );
11667
11668
11669 --
11670 --
11671 END IF;
11672
11673 --
11674 -- Update the line information that should be overwritten
11675 --
11676 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11677 p_header_num => 1);
11678 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11679
11680 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11681
11682 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11683 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11684 END IF;
11685
11686 --
11687 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11688 --
11689 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11690 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11691 ELSE
11692 ---------------------------------------------------------------------------------------------------
11693 -- 4262811a Switch Sign
11694 ---------------------------------------------------------------------------------------------------
11695 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11696 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11697 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11698 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11699 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11700 -- 5132302
11701 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11702 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11703
11704 END IF;
11705
11706 -- 4955764
11707 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11708 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11709
11710
11711 XLA_AE_LINES_PKG.ValidateCurrentLine;
11712 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11713
11714 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11715 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11716 ,p_balance_type_code => l_balance_type_code);
11717
11718 END IF;
11719
11720 -----------------------------------------------------------------------------------------
11721 -- 4262811 Multiperiod Accounting
11722 -----------------------------------------------------------------------------------------
11723 -- No MPA option is assigned.
11724
11725
11726 END IF;
11727 END IF;
11728 --
11729
11730 --
11731 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11732 trace
11733 (p_msg => 'END of AcctLineType_47'
11734 ,p_level => C_LEVEL_PROCEDURE
11735 ,p_module => l_log_module);
11736 END IF;
11737 --
11738 EXCEPTION
11739 WHEN xla_exceptions_pkg.application_exception THEN
11740 RAISE;
11741 WHEN OTHERS THEN
11742 xla_exceptions_pkg.raise_message
11743 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_47');
11744 END AcctLineType_47;
11745 --
11746
11747 ---------------------------------------
11748 --
11749 -- PRIVATE FUNCTION
11750 -- AcctLineType_48
11751 --
11752 ---------------------------------------
11753 PROCEDURE AcctLineType_48 (
11754 p_application_id IN NUMBER
11755 ,p_event_id IN NUMBER
11756 ,p_calculate_acctd_flag IN VARCHAR2
11757 ,p_calculate_g_l_flag IN VARCHAR2
11758 ,p_actual_flag IN OUT VARCHAR2
11759 ,p_balance_type_code OUT VARCHAR2
11760 ,p_gain_or_loss_ref OUT VARCHAR2
11761
11762 --TRANSACTION_ID
11763 , p_source_1 IN NUMBER
11764 --Item Concatenated Segments
11765 , p_source_2 IN VARCHAR2
11766 --Transaction Quantity
11767 , p_source_3 IN NUMBER
11768 --Transaction Unit of Measure Code
11769 , p_source_4 IN VARCHAR2
11770 --Inventory Transaction Type Description
11771 , p_source_5 IN VARCHAR2
11772 --Cost Management Default Account
11773 , p_source_11 IN NUMBER
11774 --Applied to Application ID
11775 , p_source_79 IN NUMBER
11776 --Applied to Distribution Link Type
11777 , p_source_80 IN VARCHAR2
11778 --Applied to Entity Code
11779 , p_source_81 IN VARCHAR2
11780 --Applied To Purchase Document Identifier
11781 , p_source_83 IN NUMBER
11782 --DISTRIBUTION_IDENTIFIER
11783 , p_source_84 IN NUMBER
11784 --Distribution Type
11785 , p_source_85 IN VARCHAR2
11786 , p_source_85_meaning IN VARCHAR2
11787 --PO Budget Account
11788 , p_source_86 IN NUMBER
11789 --Encumbrance Reversal Amount Entered
11790 , p_source_87 IN NUMBER
11791 --Entered Currency Code
11792 , p_source_88 IN VARCHAR2
11793 --Transaction Encumbrance Reversal Amount
11794 , p_source_89 IN NUMBER
11795 --Entered Amount
11796 , p_source_91 IN NUMBER
11797 --Currency Conversion Date
11798 , p_source_92 IN DATE
11799 --Currency Conversion Rate
11800 , p_source_93 IN NUMBER
11801 --Currency Conversion Type
11802 , p_source_94 IN VARCHAR2
11803 --Accounted Amount
11804 , p_source_95 IN NUMBER
11805 --Purchasing Encumbrance Type Identifier
11806 , p_source_96 IN NUMBER
11807 --Accounting Line Type
11808 , p_source_97 IN NUMBER
11809 --Costing Encumbrance Upgrade Option
11810 , p_source_100 IN VARCHAR2
11811 --TXN_PO_DISTRIBUTION_ID
11812 , p_source_101 IN NUMBER
11813 )
11814 IS
11815
11816 l_component_type VARCHAR2(80);
11817 l_component_code VARCHAR2(30);
11818 l_component_type_code VARCHAR2(1);
11819 l_component_appl_id INTEGER;
11820 l_amb_context_code VARCHAR2(30);
11821 l_entity_code VARCHAR2(30);
11822 l_event_class_code VARCHAR2(30);
11823 l_ae_header_id NUMBER;
11824 l_event_type_code VARCHAR2(30);
11825 l_line_definition_code VARCHAR2(30);
11826 l_line_definition_owner_code VARCHAR2(1);
11827 --
11828 -- adr variables
11829 l_segment VARCHAR2(30);
11830 l_ccid NUMBER;
11831 l_adr_transaction_coa_id NUMBER;
11832 l_adr_accounting_coa_id NUMBER;
11833 l_adr_flexfield_segment_code VARCHAR2(30);
11834 l_adr_flex_value_set_id NUMBER;
11835 l_adr_value_type_code VARCHAR2(30);
11836 l_adr_value_combination_id NUMBER;
11837 l_adr_value_segment_code VARCHAR2(30);
11838
11839 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11840 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11841 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11842 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11843
11844 -- 4262811 Variables ------------------------------------------------------------------------------------------
11845 l_entered_amt_idx NUMBER;
11846 l_accted_amt_idx NUMBER;
11847 l_acc_rev_flag VARCHAR2(1);
11848 l_accrual_line_num NUMBER;
11849 l_tmp_amt NUMBER;
11850 l_acc_rev_natural_side_code VARCHAR2(1);
11851
11852 l_num_entries NUMBER;
11853 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11854 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11855 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11856 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11857 l_recog_line_1 NUMBER;
11858 l_recog_line_2 NUMBER;
11859
11860 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11861 l_bflow_applied_to_amt NUMBER; -- 5132302
11862 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11863
11864 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11865
11866 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11867 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11868
11869 ---------------------------------------------------------------------------------------------------------------
11870
11871
11872 --
11873 -- bulk performance
11874 --
11875 l_balance_type_code VARCHAR2(1);
11876 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11877 l_log_module VARCHAR2(240);
11878
11879 --
11880 -- Upgrade strategy
11881 --
11882 l_actual_upg_option VARCHAR2(1);
11883 l_enc_upg_option VARCHAR2(1);
11884
11885 --
11886 BEGIN
11887 --
11888 IF g_log_enabled THEN
11889 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_48';
11890 END IF;
11891 --
11892 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11893
11894 trace
11895 (p_msg => 'BEGIN of AcctLineType_48'
11896 ,p_level => C_LEVEL_PROCEDURE
11897 ,p_module => l_log_module);
11898
11899 END IF;
11900 --
11901 l_component_type := 'AMB_JLT';
11902 l_component_code := 'CLEARING';
11903 l_component_type_code := 'S';
11904 l_component_appl_id := 707;
11905 l_amb_context_code := 'DEFAULT';
11906 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
11907 l_event_class_code := 'PURCHASE_ORDER';
11908 l_event_type_code := 'LOG_PO_DEL_INV';
11909 l_line_definition_owner_code := 'S';
11910 l_line_definition_code := 'PI_LOG_DEL_INV';
11911 --
11912 l_balance_type_code := 'A';
11913 l_segment := NULL;
11914 l_ccid := NULL;
11915 l_adr_transaction_coa_id := NULL;
11916 l_adr_accounting_coa_id := NULL;
11917 l_adr_flexfield_segment_code := NULL;
11918 l_adr_flex_value_set_id := NULL;
11919 l_adr_value_type_code := NULL;
11920 l_adr_value_combination_id := NULL;
11921 l_adr_value_segment_code := NULL;
11922
11923 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11924 l_bflow_class_code := ''; -- 4219869 Business Flow
11925 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11926 l_budgetary_control_flag := 'N';
11927
11928 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11929 l_bflow_applied_to_amt := NULL; -- 5132302
11930 l_entered_amt_idx := NULL; -- 4262811
11931 l_accted_amt_idx := NULL; -- 4262811
11932 l_acc_rev_flag := NULL; -- 4262811
11933 l_accrual_line_num := NULL; -- 4262811
11934 l_tmp_amt := NULL; -- 4262811
11935 --
11936
11937 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11938 l_balance_type_code <> 'B' THEN
11939 IF NVL(p_source_97,9E125) = 31
11940 THEN
11941
11942 --
11943 XLA_AE_LINES_PKG.SetNewLine;
11944
11945 p_balance_type_code := l_balance_type_code;
11946 -- set the flag so later we will know whether the gain loss line needs to be created
11947
11948 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11949 p_actual_flag :='A';
11950 END IF;
11951
11952 --
11953 -- bulk performance
11954 --
11955 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11956 p_header_num => 0); -- 4262811
11957 --
11958 -- set accounting line options
11959 --
11960 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11961 p_natural_side_code => 'D'
11962 , p_gain_or_loss_flag => 'N'
11963 , p_gl_transfer_mode_code => 'S'
11964 , p_acct_entry_type_code => 'A'
11965 , p_switch_side_flag => 'Y'
11966 , p_merge_duplicate_code => 'N'
11967 );
11968 --
11969 l_acc_rev_natural_side_code := 'C'; -- 4262811
11970 --
11971 --
11972 -- set accounting line type info
11973 --
11974 xla_ae_lines_pkg.SetAcctLineType
11975 (p_component_type => l_component_type
11976 ,p_event_type_code => l_event_type_code
11977 ,p_line_definition_owner_code => l_line_definition_owner_code
11978 ,p_line_definition_code => l_line_definition_code
11979 ,p_accounting_line_code => l_component_code
11980 ,p_accounting_line_type_code => l_component_type_code
11981 ,p_accounting_line_appl_id => l_component_appl_id
11982 ,p_amb_context_code => l_amb_context_code
11983 ,p_entity_code => l_entity_code
11984 ,p_event_class_code => l_event_class_code);
11985 --
11986 -- set accounting class
11987 --
11988 xla_ae_lines_pkg.SetAcctClass(
11989 p_accounting_class_code => 'CLEARING'
11990 , p_ae_header_id => l_ae_header_id
11991 );
11992
11993 --
11994 -- set rounding class
11995 --
11996 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11997 'CLEARING';
11998
11999 --
12000 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12001 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12002 --
12003 -- bulk performance
12004 --
12005 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12006
12007 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12008 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12009
12010 -- 4955764
12011 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12012 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12013
12014 -- 4458381 Public Sector Enh
12015
12016 --
12017 -- set accounting attributes for the line type
12018 --
12019 l_entered_amt_idx := 17;
12020 l_accted_amt_idx := 22;
12021 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12022 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
12023 l_rec_acct_attrs.array_num_value(1) := p_source_79;
12024 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
12025 l_rec_acct_attrs.array_char_value(2) := p_source_80;
12026 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
12027 l_rec_acct_attrs.array_char_value(3) := p_source_81;
12028 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
12029 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
12030 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
12031 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
12032 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
12033 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
12034 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
12035 l_rec_acct_attrs.array_char_value(7) := p_source_85;
12036 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
12037 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
12038 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
12039 l_rec_acct_attrs.array_num_value(9) := p_source_87;
12040 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
12041 l_rec_acct_attrs.array_char_value(10) := p_source_88;
12042 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
12043 l_rec_acct_attrs.array_num_value(11) := p_source_89;
12044 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
12045 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
12046 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
12047 l_rec_acct_attrs.array_num_value(13) := p_source_87;
12048 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
12049 l_rec_acct_attrs.array_char_value(14) := p_source_88;
12050 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
12051 l_rec_acct_attrs.array_num_value(15) := p_source_89;
12052 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
12053 l_rec_acct_attrs.array_char_value(16) := p_source_100;
12054 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
12055 l_rec_acct_attrs.array_num_value(17) := p_source_91;
12056 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
12057 l_rec_acct_attrs.array_char_value(18) := p_source_88;
12058 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
12059 l_rec_acct_attrs.array_date_value(19) := p_source_92;
12060 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
12061 l_rec_acct_attrs.array_num_value(20) := p_source_93;
12062 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
12063 l_rec_acct_attrs.array_char_value(21) := p_source_94;
12064 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
12065 l_rec_acct_attrs.array_num_value(22) := p_source_95;
12066 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
12067 l_rec_acct_attrs.array_num_value(23) := p_source_96;
12068 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
12069 l_rec_acct_attrs.array_num_value(24) := p_source_96;
12070
12071 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12072 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12073
12074 ---------------------------------------------------------------------------------------------------------------
12075 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12076 ---------------------------------------------------------------------------------------------------------------
12077 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12078
12079 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12080 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12081
12082 IF xla_accounting_cache_pkg.GetValueChar
12083 (p_source_code => 'LEDGER_CATEGORY_CODE'
12084 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12085 AND l_bflow_method_code = 'PRIOR_ENTRY'
12086 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12087 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12088 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12089 )
12090 THEN
12091 xla_ae_lines_pkg.BflowUpgEntry
12092 (p_business_method_code => l_bflow_method_code
12093 ,p_business_class_code => l_bflow_class_code
12094 ,p_balance_type => l_balance_type_code);
12095 ELSE
12096 NULL;
12097 -- No business flow processing for business flow method of NONE.
12098 END IF;
12099
12100 --
12101 -- call analytical criteria
12102 --
12103
12104 --
12105 -- call description
12106 --
12107
12108 xla_ae_lines_pkg.SetLineDescription(
12109 p_ae_header_id => l_ae_header_id
12110 ,p_description => Description_1 (
12111 p_application_id => p_application_id
12112 , p_ae_header_id => l_ae_header_id
12113 , p_source_1 => p_source_1
12114 , p_source_2 => p_source_2
12115 , p_source_3 => p_source_3
12116 , p_source_4 => p_source_4
12117 , p_source_5 => p_source_5
12118 )
12119 );
12120
12121
12122 --
12123 -- call ADRs
12124 -- Bug 4922099
12125 --
12126 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12127 (NVL(l_actual_upg_option, 'N') = 'O') OR
12128 (NVL(l_enc_upg_option, 'N') = 'O')
12129 )
12130 THEN
12131 NULL;
12132 --
12133 --
12134
12135 l_ccid := AcctDerRule_6(
12136 p_application_id => p_application_id
12137 , p_ae_header_id => l_ae_header_id
12138 , p_source_11 => p_source_11
12139 , x_transaction_coa_id => l_adr_transaction_coa_id
12140 , x_accounting_coa_id => l_adr_accounting_coa_id
12141 , x_value_type_code => l_adr_value_type_code
12142 , p_side => 'NA'
12143 );
12144
12145 xla_ae_lines_pkg.set_ccid(
12146 p_code_combination_id => l_ccid
12147 , p_value_type_code => l_adr_value_type_code
12148 , p_transaction_coa_id => l_adr_transaction_coa_id
12149 , p_accounting_coa_id => l_adr_accounting_coa_id
12150 , p_adr_code => 'CST_DEFAULT'
12151 , p_adr_type_code => 'S'
12152 , p_component_type => l_component_type
12153 , p_component_code => l_component_code
12154 , p_component_type_code => l_component_type_code
12155 , p_component_appl_id => l_component_appl_id
12156 , p_amb_context_code => l_amb_context_code
12157 , p_side => 'NA'
12158 );
12159
12160
12161 --
12162 --
12163 END IF;
12164 --
12165 -- Bug 4922099
12166 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12167 (NVL(l_enc_upg_option, 'N') = 'O')
12168 ) AND
12169 (l_bflow_method_code = 'PRIOR_ENTRY')
12170 )
12171 THEN
12172 IF
12173 --
12174 1 = 2
12175 --
12176 THEN
12177 xla_accounting_err_pkg.build_message
12178 (p_appli_s_name => 'XLA'
12179 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12180 ,p_token_1 => 'LINE_NUMBER'
12181 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12182 ,p_token_2 => 'LINE_TYPE_NAME'
12183 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12184 l_component_type
12185 ,l_component_code
12186 ,l_component_type_code
12187 ,l_component_appl_id
12188 ,l_amb_context_code
12189 ,l_entity_code
12190 ,l_event_class_code
12191 )
12192 ,p_token_3 => 'OWNER'
12193 ,p_value_3 => xla_lookups_pkg.get_meaning(
12194 p_lookup_type => 'XLA_OWNER_TYPE'
12195 ,p_lookup_code => l_component_type_code
12196 )
12197 ,p_token_4 => 'PRODUCT_NAME'
12198 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12199 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12200 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12201 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12202 ,p_ae_header_id => NULL
12203 );
12204
12205 IF (C_LEVEL_ERROR>= g_log_level) THEN
12206 trace
12207 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12208 ,p_level => C_LEVEL_ERROR
12209 ,p_module => l_log_module);
12210 END IF;
12211 END IF;
12212 END IF;
12213 --
12214 --
12215 ------------------------------------------------------------------------------------------------
12216 -- 4219869 Business Flow
12217 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12218 -- Prior Entry. Currently, the following code is always generated.
12219 ------------------------------------------------------------------------------------------------
12220 XLA_AE_LINES_PKG.ValidateCurrentLine;
12221
12222 ------------------------------------------------------------------------------------
12223 -- 4219869 Business Flow
12224 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12225 ------------------------------------------------------------------------------------
12226 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12227
12228 ----------------------------------------------------------------------------------
12229 -- 4219869 Business Flow
12230 -- Update journal entry status -- Need to generate this within IF <condition>
12231 ----------------------------------------------------------------------------------
12232 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12233 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12234 ,p_balance_type_code => l_balance_type_code
12235 );
12236
12237 -------------------------------------------------------------------------------------------
12238 -- 4262811 - Generate the Accrual Reversal lines
12239 -------------------------------------------------------------------------------------------
12240 BEGIN
12241 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12242 (g_array_event(p_event_id).array_value_num('header_index'));
12243 IF l_acc_rev_flag IS NULL THEN
12244 l_acc_rev_flag := 'N';
12245 END IF;
12246 EXCEPTION
12247 WHEN OTHERS THEN
12248 l_acc_rev_flag := 'N';
12249 END;
12250 --
12251 IF (l_acc_rev_flag = 'Y') THEN
12252
12253 -- 4645092 ------------------------------------------------------------------------------
12254 -- To allow MPA report to determine if it should generate report process
12255 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12256 ------------------------------------------------------------------------------------------
12257
12258 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12259 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12260 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12261 -- call ADRs
12262 -- Bug 4922099
12263 --
12264 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12265 (NVL(l_actual_upg_option, 'N') = 'O') OR
12266 (NVL(l_enc_upg_option, 'N') = 'O')
12267 )
12268 THEN
12269 NULL;
12270 --
12271 --
12272
12273 l_ccid := AcctDerRule_6(
12274 p_application_id => p_application_id
12275 , p_ae_header_id => l_ae_header_id
12276 , p_source_11 => p_source_11
12277 , x_transaction_coa_id => l_adr_transaction_coa_id
12278 , x_accounting_coa_id => l_adr_accounting_coa_id
12279 , x_value_type_code => l_adr_value_type_code
12280 , p_side => 'NA'
12281 );
12282
12283 xla_ae_lines_pkg.set_ccid(
12284 p_code_combination_id => l_ccid
12285 , p_value_type_code => l_adr_value_type_code
12286 , p_transaction_coa_id => l_adr_transaction_coa_id
12287 , p_accounting_coa_id => l_adr_accounting_coa_id
12288 , p_adr_code => 'CST_DEFAULT'
12289 , p_adr_type_code => 'S'
12290 , p_component_type => l_component_type
12291 , p_component_code => l_component_code
12292 , p_component_type_code => l_component_type_code
12293 , p_component_appl_id => l_component_appl_id
12294 , p_amb_context_code => l_amb_context_code
12295 , p_side => 'NA'
12296 );
12297
12298
12299 --
12300 --
12301 END IF;
12302
12303 --
12304 -- Update the line information that should be overwritten
12305 --
12306 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12307 p_header_num => 1);
12308 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12309
12310 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12311
12312 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12313 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12314 END IF;
12315
12316 --
12317 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12318 --
12319 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12320 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12321 ELSE
12322 ---------------------------------------------------------------------------------------------------
12323 -- 4262811a Switch Sign
12324 ---------------------------------------------------------------------------------------------------
12325 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12326 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12327 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12328 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12329 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12330 -- 5132302
12331 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12332 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12333
12334 END IF;
12335
12336 -- 4955764
12337 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12338 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12339
12340
12341 XLA_AE_LINES_PKG.ValidateCurrentLine;
12342 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12343
12344 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12345 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12346 ,p_balance_type_code => l_balance_type_code);
12347
12348 END IF;
12349
12350 -----------------------------------------------------------------------------------------
12351 -- 4262811 Multiperiod Accounting
12352 -----------------------------------------------------------------------------------------
12353 -- No MPA option is assigned.
12354
12355
12356 END IF;
12357 END IF;
12358 --
12359
12360 --
12361 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12362 trace
12363 (p_msg => 'END of AcctLineType_48'
12364 ,p_level => C_LEVEL_PROCEDURE
12365 ,p_module => l_log_module);
12366 END IF;
12367 --
12368 EXCEPTION
12369 WHEN xla_exceptions_pkg.application_exception THEN
12370 RAISE;
12371 WHEN OTHERS THEN
12372 xla_exceptions_pkg.raise_message
12373 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_48');
12374 END AcctLineType_48;
12375 --
12376
12377 ---------------------------------------
12378 --
12379 -- PRIVATE FUNCTION
12380 -- AcctLineType_49
12381 --
12382 ---------------------------------------
12383 PROCEDURE AcctLineType_49 (
12384 p_application_id IN NUMBER
12385 ,p_event_id IN NUMBER
12386 ,p_calculate_acctd_flag IN VARCHAR2
12387 ,p_calculate_g_l_flag IN VARCHAR2
12388 ,p_actual_flag IN OUT VARCHAR2
12389 ,p_balance_type_code OUT VARCHAR2
12390 ,p_gain_or_loss_ref OUT VARCHAR2
12391
12392 --TRANSACTION_ID
12393 , p_source_1 IN NUMBER
12394 --Item Concatenated Segments
12395 , p_source_2 IN VARCHAR2
12396 --Transaction Quantity
12397 , p_source_3 IN NUMBER
12398 --Transaction Unit of Measure Code
12399 , p_source_4 IN VARCHAR2
12400 --Inventory Transaction Type Description
12401 , p_source_5 IN VARCHAR2
12402 --Cost Management Default Account
12403 , p_source_11 IN NUMBER
12404 --Applied to Application ID
12405 , p_source_79 IN NUMBER
12406 --Applied to Distribution Link Type
12407 , p_source_80 IN VARCHAR2
12408 --Applied to Entity Code
12409 , p_source_81 IN VARCHAR2
12410 --Applied To Purchase Document Identifier
12411 , p_source_83 IN NUMBER
12412 --DISTRIBUTION_IDENTIFIER
12413 , p_source_84 IN NUMBER
12414 --Distribution Type
12415 , p_source_85 IN VARCHAR2
12416 , p_source_85_meaning IN VARCHAR2
12417 --PO Budget Account
12418 , p_source_86 IN NUMBER
12419 --Encumbrance Reversal Amount Entered
12420 , p_source_87 IN NUMBER
12421 --Entered Currency Code
12422 , p_source_88 IN VARCHAR2
12423 --Transaction Encumbrance Reversal Amount
12424 , p_source_89 IN NUMBER
12425 --Entered Amount
12426 , p_source_91 IN NUMBER
12427 --Currency Conversion Date
12428 , p_source_92 IN DATE
12429 --Currency Conversion Rate
12430 , p_source_93 IN NUMBER
12431 --Currency Conversion Type
12432 , p_source_94 IN VARCHAR2
12433 --Accounted Amount
12434 , p_source_95 IN NUMBER
12435 --Purchasing Encumbrance Type Identifier
12436 , p_source_96 IN NUMBER
12437 --Accounting Line Type
12438 , p_source_97 IN NUMBER
12439 --Costing Encumbrance Upgrade Option
12440 , p_source_100 IN VARCHAR2
12441 --TXN_PO_DISTRIBUTION_ID
12442 , p_source_101 IN NUMBER
12443 )
12444 IS
12445
12446 l_component_type VARCHAR2(80);
12447 l_component_code VARCHAR2(30);
12448 l_component_type_code VARCHAR2(1);
12449 l_component_appl_id INTEGER;
12450 l_amb_context_code VARCHAR2(30);
12451 l_entity_code VARCHAR2(30);
12452 l_event_class_code VARCHAR2(30);
12453 l_ae_header_id NUMBER;
12454 l_event_type_code VARCHAR2(30);
12455 l_line_definition_code VARCHAR2(30);
12456 l_line_definition_owner_code VARCHAR2(1);
12457 --
12458 -- adr variables
12459 l_segment VARCHAR2(30);
12460 l_ccid NUMBER;
12461 l_adr_transaction_coa_id NUMBER;
12462 l_adr_accounting_coa_id NUMBER;
12463 l_adr_flexfield_segment_code VARCHAR2(30);
12464 l_adr_flex_value_set_id NUMBER;
12465 l_adr_value_type_code VARCHAR2(30);
12466 l_adr_value_combination_id NUMBER;
12467 l_adr_value_segment_code VARCHAR2(30);
12468
12469 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12470 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12471 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12472 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12473
12474 -- 4262811 Variables ------------------------------------------------------------------------------------------
12475 l_entered_amt_idx NUMBER;
12476 l_accted_amt_idx NUMBER;
12477 l_acc_rev_flag VARCHAR2(1);
12478 l_accrual_line_num NUMBER;
12479 l_tmp_amt NUMBER;
12480 l_acc_rev_natural_side_code VARCHAR2(1);
12481
12482 l_num_entries NUMBER;
12483 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12484 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12485 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12486 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12487 l_recog_line_1 NUMBER;
12488 l_recog_line_2 NUMBER;
12489
12490 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12491 l_bflow_applied_to_amt NUMBER; -- 5132302
12492 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12493
12494 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12495
12496 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12497 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12498
12499 ---------------------------------------------------------------------------------------------------------------
12500
12501
12502 --
12503 -- bulk performance
12504 --
12505 l_balance_type_code VARCHAR2(1);
12506 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12507 l_log_module VARCHAR2(240);
12508
12509 --
12510 -- Upgrade strategy
12511 --
12512 l_actual_upg_option VARCHAR2(1);
12513 l_enc_upg_option VARCHAR2(1);
12514
12515 --
12516 BEGIN
12517 --
12518 IF g_log_enabled THEN
12519 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_49';
12520 END IF;
12521 --
12522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12523
12524 trace
12525 (p_msg => 'BEGIN of AcctLineType_49'
12526 ,p_level => C_LEVEL_PROCEDURE
12527 ,p_module => l_log_module);
12528
12529 END IF;
12530 --
12531 l_component_type := 'AMB_JLT';
12532 l_component_code := 'CLEARING';
12533 l_component_type_code := 'S';
12534 l_component_appl_id := 707;
12535 l_amb_context_code := 'DEFAULT';
12536 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
12537 l_event_class_code := 'PURCHASE_ORDER';
12538 l_event_type_code := 'RET_RI_INV';
12539 l_line_definition_owner_code := 'S';
12540 l_line_definition_code := 'PI_RET_RI_INV';
12541 --
12542 l_balance_type_code := 'A';
12543 l_segment := NULL;
12544 l_ccid := NULL;
12545 l_adr_transaction_coa_id := NULL;
12546 l_adr_accounting_coa_id := NULL;
12547 l_adr_flexfield_segment_code := NULL;
12548 l_adr_flex_value_set_id := NULL;
12549 l_adr_value_type_code := NULL;
12550 l_adr_value_combination_id := NULL;
12551 l_adr_value_segment_code := NULL;
12552
12553 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12554 l_bflow_class_code := ''; -- 4219869 Business Flow
12555 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12556 l_budgetary_control_flag := 'N';
12557
12558 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12559 l_bflow_applied_to_amt := NULL; -- 5132302
12560 l_entered_amt_idx := NULL; -- 4262811
12561 l_accted_amt_idx := NULL; -- 4262811
12562 l_acc_rev_flag := NULL; -- 4262811
12563 l_accrual_line_num := NULL; -- 4262811
12564 l_tmp_amt := NULL; -- 4262811
12565 --
12566
12567 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12568 l_balance_type_code <> 'B' THEN
12569 IF NVL(p_source_97,9E125) = 31
12570 THEN
12571
12572 --
12573 XLA_AE_LINES_PKG.SetNewLine;
12574
12575 p_balance_type_code := l_balance_type_code;
12576 -- set the flag so later we will know whether the gain loss line needs to be created
12577
12578 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12579 p_actual_flag :='A';
12580 END IF;
12581
12582 --
12583 -- bulk performance
12584 --
12585 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12586 p_header_num => 0); -- 4262811
12587 --
12588 -- set accounting line options
12589 --
12590 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12591 p_natural_side_code => 'D'
12592 , p_gain_or_loss_flag => 'N'
12593 , p_gl_transfer_mode_code => 'S'
12594 , p_acct_entry_type_code => 'A'
12595 , p_switch_side_flag => 'Y'
12596 , p_merge_duplicate_code => 'N'
12597 );
12598 --
12599 l_acc_rev_natural_side_code := 'C'; -- 4262811
12600 --
12601 --
12602 -- set accounting line type info
12603 --
12604 xla_ae_lines_pkg.SetAcctLineType
12605 (p_component_type => l_component_type
12606 ,p_event_type_code => l_event_type_code
12607 ,p_line_definition_owner_code => l_line_definition_owner_code
12608 ,p_line_definition_code => l_line_definition_code
12609 ,p_accounting_line_code => l_component_code
12610 ,p_accounting_line_type_code => l_component_type_code
12611 ,p_accounting_line_appl_id => l_component_appl_id
12612 ,p_amb_context_code => l_amb_context_code
12613 ,p_entity_code => l_entity_code
12614 ,p_event_class_code => l_event_class_code);
12615 --
12616 -- set accounting class
12617 --
12618 xla_ae_lines_pkg.SetAcctClass(
12619 p_accounting_class_code => 'CLEARING'
12620 , p_ae_header_id => l_ae_header_id
12621 );
12622
12623 --
12624 -- set rounding class
12625 --
12626 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12627 'CLEARING';
12628
12629 --
12630 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12631 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12632 --
12633 -- bulk performance
12634 --
12635 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12636
12637 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12638 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12639
12640 -- 4955764
12641 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12642 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12643
12644 -- 4458381 Public Sector Enh
12645
12646 --
12647 -- set accounting attributes for the line type
12648 --
12649 l_entered_amt_idx := 17;
12650 l_accted_amt_idx := 22;
12651 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12652 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
12653 l_rec_acct_attrs.array_num_value(1) := p_source_79;
12654 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
12655 l_rec_acct_attrs.array_char_value(2) := p_source_80;
12656 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
12657 l_rec_acct_attrs.array_char_value(3) := p_source_81;
12658 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
12659 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
12660 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
12661 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
12662 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
12663 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
12664 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
12665 l_rec_acct_attrs.array_char_value(7) := p_source_85;
12666 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
12667 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
12668 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
12669 l_rec_acct_attrs.array_num_value(9) := p_source_87;
12670 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
12671 l_rec_acct_attrs.array_char_value(10) := p_source_88;
12672 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
12673 l_rec_acct_attrs.array_num_value(11) := p_source_89;
12674 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
12675 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
12676 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
12677 l_rec_acct_attrs.array_num_value(13) := p_source_87;
12678 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
12679 l_rec_acct_attrs.array_char_value(14) := p_source_88;
12680 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
12681 l_rec_acct_attrs.array_num_value(15) := p_source_89;
12682 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
12683 l_rec_acct_attrs.array_char_value(16) := p_source_100;
12684 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
12685 l_rec_acct_attrs.array_num_value(17) := p_source_91;
12686 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
12687 l_rec_acct_attrs.array_char_value(18) := p_source_88;
12688 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
12689 l_rec_acct_attrs.array_date_value(19) := p_source_92;
12690 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
12691 l_rec_acct_attrs.array_num_value(20) := p_source_93;
12692 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
12693 l_rec_acct_attrs.array_char_value(21) := p_source_94;
12694 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
12695 l_rec_acct_attrs.array_num_value(22) := p_source_95;
12696 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
12697 l_rec_acct_attrs.array_num_value(23) := p_source_96;
12698 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
12699 l_rec_acct_attrs.array_num_value(24) := p_source_96;
12700
12701 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12702 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12703
12704 ---------------------------------------------------------------------------------------------------------------
12705 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12706 ---------------------------------------------------------------------------------------------------------------
12707 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12708
12709 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12710 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12711
12712 IF xla_accounting_cache_pkg.GetValueChar
12713 (p_source_code => 'LEDGER_CATEGORY_CODE'
12714 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12715 AND l_bflow_method_code = 'PRIOR_ENTRY'
12716 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12717 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12718 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12719 )
12720 THEN
12721 xla_ae_lines_pkg.BflowUpgEntry
12722 (p_business_method_code => l_bflow_method_code
12723 ,p_business_class_code => l_bflow_class_code
12724 ,p_balance_type => l_balance_type_code);
12725 ELSE
12726 NULL;
12727 -- No business flow processing for business flow method of NONE.
12728 END IF;
12729
12730 --
12731 -- call analytical criteria
12732 --
12733
12734 --
12735 -- call description
12736 --
12737
12738 xla_ae_lines_pkg.SetLineDescription(
12739 p_ae_header_id => l_ae_header_id
12740 ,p_description => Description_1 (
12741 p_application_id => p_application_id
12742 , p_ae_header_id => l_ae_header_id
12743 , p_source_1 => p_source_1
12744 , p_source_2 => p_source_2
12745 , p_source_3 => p_source_3
12746 , p_source_4 => p_source_4
12747 , p_source_5 => p_source_5
12748 )
12749 );
12750
12751
12752 --
12753 -- call ADRs
12754 -- Bug 4922099
12755 --
12756 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12757 (NVL(l_actual_upg_option, 'N') = 'O') OR
12758 (NVL(l_enc_upg_option, 'N') = 'O')
12759 )
12760 THEN
12761 NULL;
12762 --
12763 --
12764
12765 l_ccid := AcctDerRule_6(
12766 p_application_id => p_application_id
12767 , p_ae_header_id => l_ae_header_id
12768 , p_source_11 => p_source_11
12769 , x_transaction_coa_id => l_adr_transaction_coa_id
12770 , x_accounting_coa_id => l_adr_accounting_coa_id
12771 , x_value_type_code => l_adr_value_type_code
12772 , p_side => 'NA'
12773 );
12774
12775 xla_ae_lines_pkg.set_ccid(
12776 p_code_combination_id => l_ccid
12777 , p_value_type_code => l_adr_value_type_code
12778 , p_transaction_coa_id => l_adr_transaction_coa_id
12779 , p_accounting_coa_id => l_adr_accounting_coa_id
12780 , p_adr_code => 'CST_DEFAULT'
12781 , p_adr_type_code => 'S'
12782 , p_component_type => l_component_type
12783 , p_component_code => l_component_code
12784 , p_component_type_code => l_component_type_code
12785 , p_component_appl_id => l_component_appl_id
12786 , p_amb_context_code => l_amb_context_code
12787 , p_side => 'NA'
12788 );
12789
12790
12791 --
12792 --
12793 END IF;
12794 --
12795 -- Bug 4922099
12796 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12797 (NVL(l_enc_upg_option, 'N') = 'O')
12798 ) AND
12799 (l_bflow_method_code = 'PRIOR_ENTRY')
12800 )
12801 THEN
12802 IF
12803 --
12804 1 = 2
12805 --
12806 THEN
12807 xla_accounting_err_pkg.build_message
12808 (p_appli_s_name => 'XLA'
12809 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12810 ,p_token_1 => 'LINE_NUMBER'
12811 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12812 ,p_token_2 => 'LINE_TYPE_NAME'
12813 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12814 l_component_type
12815 ,l_component_code
12816 ,l_component_type_code
12817 ,l_component_appl_id
12818 ,l_amb_context_code
12819 ,l_entity_code
12820 ,l_event_class_code
12821 )
12822 ,p_token_3 => 'OWNER'
12823 ,p_value_3 => xla_lookups_pkg.get_meaning(
12824 p_lookup_type => 'XLA_OWNER_TYPE'
12825 ,p_lookup_code => l_component_type_code
12826 )
12827 ,p_token_4 => 'PRODUCT_NAME'
12828 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12829 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12830 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12831 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12832 ,p_ae_header_id => NULL
12833 );
12834
12835 IF (C_LEVEL_ERROR>= g_log_level) THEN
12836 trace
12837 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12838 ,p_level => C_LEVEL_ERROR
12839 ,p_module => l_log_module);
12840 END IF;
12841 END IF;
12842 END IF;
12843 --
12844 --
12845 ------------------------------------------------------------------------------------------------
12846 -- 4219869 Business Flow
12847 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12848 -- Prior Entry. Currently, the following code is always generated.
12849 ------------------------------------------------------------------------------------------------
12850 XLA_AE_LINES_PKG.ValidateCurrentLine;
12851
12852 ------------------------------------------------------------------------------------
12853 -- 4219869 Business Flow
12854 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12855 ------------------------------------------------------------------------------------
12856 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12857
12858 ----------------------------------------------------------------------------------
12859 -- 4219869 Business Flow
12860 -- Update journal entry status -- Need to generate this within IF <condition>
12861 ----------------------------------------------------------------------------------
12862 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12863 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12864 ,p_balance_type_code => l_balance_type_code
12865 );
12866
12867 -------------------------------------------------------------------------------------------
12868 -- 4262811 - Generate the Accrual Reversal lines
12869 -------------------------------------------------------------------------------------------
12870 BEGIN
12871 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12872 (g_array_event(p_event_id).array_value_num('header_index'));
12873 IF l_acc_rev_flag IS NULL THEN
12874 l_acc_rev_flag := 'N';
12875 END IF;
12876 EXCEPTION
12877 WHEN OTHERS THEN
12878 l_acc_rev_flag := 'N';
12879 END;
12880 --
12881 IF (l_acc_rev_flag = 'Y') THEN
12882
12883 -- 4645092 ------------------------------------------------------------------------------
12884 -- To allow MPA report to determine if it should generate report process
12885 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12886 ------------------------------------------------------------------------------------------
12887
12888 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12889 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12890 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12891 -- call ADRs
12892 -- Bug 4922099
12893 --
12894 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12895 (NVL(l_actual_upg_option, 'N') = 'O') OR
12896 (NVL(l_enc_upg_option, 'N') = 'O')
12897 )
12898 THEN
12899 NULL;
12900 --
12901 --
12902
12903 l_ccid := AcctDerRule_6(
12904 p_application_id => p_application_id
12905 , p_ae_header_id => l_ae_header_id
12906 , p_source_11 => p_source_11
12907 , x_transaction_coa_id => l_adr_transaction_coa_id
12908 , x_accounting_coa_id => l_adr_accounting_coa_id
12909 , x_value_type_code => l_adr_value_type_code
12910 , p_side => 'NA'
12911 );
12912
12913 xla_ae_lines_pkg.set_ccid(
12914 p_code_combination_id => l_ccid
12915 , p_value_type_code => l_adr_value_type_code
12916 , p_transaction_coa_id => l_adr_transaction_coa_id
12917 , p_accounting_coa_id => l_adr_accounting_coa_id
12918 , p_adr_code => 'CST_DEFAULT'
12919 , p_adr_type_code => 'S'
12920 , p_component_type => l_component_type
12921 , p_component_code => l_component_code
12922 , p_component_type_code => l_component_type_code
12923 , p_component_appl_id => l_component_appl_id
12924 , p_amb_context_code => l_amb_context_code
12925 , p_side => 'NA'
12926 );
12927
12928
12929 --
12930 --
12931 END IF;
12932
12933 --
12934 -- Update the line information that should be overwritten
12935 --
12936 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12937 p_header_num => 1);
12938 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12939
12940 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12941
12942 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12943 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12944 END IF;
12945
12946 --
12947 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12948 --
12949 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12950 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12951 ELSE
12952 ---------------------------------------------------------------------------------------------------
12953 -- 4262811a Switch Sign
12954 ---------------------------------------------------------------------------------------------------
12955 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12956 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12957 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12958 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12959 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12960 -- 5132302
12961 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12962 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12963
12964 END IF;
12965
12966 -- 4955764
12967 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12968 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12969
12970
12971 XLA_AE_LINES_PKG.ValidateCurrentLine;
12972 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12973
12974 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12975 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12976 ,p_balance_type_code => l_balance_type_code);
12977
12978 END IF;
12979
12980 -----------------------------------------------------------------------------------------
12981 -- 4262811 Multiperiod Accounting
12982 -----------------------------------------------------------------------------------------
12983 -- No MPA option is assigned.
12984
12985
12986 END IF;
12987 END IF;
12988 --
12989
12990 --
12991 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12992 trace
12993 (p_msg => 'END of AcctLineType_49'
12994 ,p_level => C_LEVEL_PROCEDURE
12995 ,p_module => l_log_module);
12996 END IF;
12997 --
12998 EXCEPTION
12999 WHEN xla_exceptions_pkg.application_exception THEN
13000 RAISE;
13001 WHEN OTHERS THEN
13002 xla_exceptions_pkg.raise_message
13003 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_49');
13004 END AcctLineType_49;
13005 --
13006
13007 ---------------------------------------
13008 --
13009 -- PRIVATE FUNCTION
13010 -- AcctLineType_50
13011 --
13012 ---------------------------------------
13013 PROCEDURE AcctLineType_50 (
13014 p_application_id IN NUMBER
13015 ,p_event_id IN NUMBER
13016 ,p_calculate_acctd_flag IN VARCHAR2
13017 ,p_calculate_g_l_flag IN VARCHAR2
13018 ,p_actual_flag IN OUT VARCHAR2
13019 ,p_balance_type_code OUT VARCHAR2
13020 ,p_gain_or_loss_ref OUT VARCHAR2
13021
13022 --TRANSACTION_ID
13023 , p_source_1 IN NUMBER
13024 --Item Concatenated Segments
13025 , p_source_2 IN VARCHAR2
13026 --Transaction Quantity
13027 , p_source_3 IN NUMBER
13028 --Transaction Unit of Measure Code
13029 , p_source_4 IN VARCHAR2
13030 --Inventory Transaction Type Description
13031 , p_source_5 IN VARCHAR2
13032 --Cost Management Default Account
13033 , p_source_11 IN NUMBER
13034 --Applied to Application ID
13035 , p_source_79 IN NUMBER
13036 --Applied to Distribution Link Type
13037 , p_source_80 IN VARCHAR2
13038 --Applied to Entity Code
13039 , p_source_81 IN VARCHAR2
13040 --Applied To Purchase Document Identifier
13041 , p_source_83 IN NUMBER
13042 --DISTRIBUTION_IDENTIFIER
13043 , p_source_84 IN NUMBER
13044 --Distribution Type
13045 , p_source_85 IN VARCHAR2
13046 , p_source_85_meaning IN VARCHAR2
13047 --PO Budget Account
13048 , p_source_86 IN NUMBER
13049 --Encumbrance Reversal Amount Entered
13050 , p_source_87 IN NUMBER
13051 --Entered Currency Code
13052 , p_source_88 IN VARCHAR2
13053 --Transaction Encumbrance Reversal Amount
13054 , p_source_89 IN NUMBER
13055 --Entered Amount
13056 , p_source_91 IN NUMBER
13057 --Currency Conversion Date
13058 , p_source_92 IN DATE
13059 --Currency Conversion Rate
13060 , p_source_93 IN NUMBER
13061 --Currency Conversion Type
13062 , p_source_94 IN VARCHAR2
13063 --Accounted Amount
13064 , p_source_95 IN NUMBER
13065 --Purchasing Encumbrance Type Identifier
13066 , p_source_96 IN NUMBER
13067 --Accounting Line Type
13068 , p_source_97 IN NUMBER
13069 --Costing Encumbrance Upgrade Option
13070 , p_source_100 IN VARCHAR2
13071 --TXN_PO_DISTRIBUTION_ID
13072 , p_source_101 IN NUMBER
13073 )
13074 IS
13075
13076 l_component_type VARCHAR2(80);
13077 l_component_code VARCHAR2(30);
13078 l_component_type_code VARCHAR2(1);
13079 l_component_appl_id INTEGER;
13080 l_amb_context_code VARCHAR2(30);
13081 l_entity_code VARCHAR2(30);
13082 l_event_class_code VARCHAR2(30);
13083 l_ae_header_id NUMBER;
13084 l_event_type_code VARCHAR2(30);
13085 l_line_definition_code VARCHAR2(30);
13086 l_line_definition_owner_code VARCHAR2(1);
13087 --
13088 -- adr variables
13089 l_segment VARCHAR2(30);
13090 l_ccid NUMBER;
13091 l_adr_transaction_coa_id NUMBER;
13092 l_adr_accounting_coa_id NUMBER;
13093 l_adr_flexfield_segment_code VARCHAR2(30);
13094 l_adr_flex_value_set_id NUMBER;
13095 l_adr_value_type_code VARCHAR2(30);
13096 l_adr_value_combination_id NUMBER;
13097 l_adr_value_segment_code VARCHAR2(30);
13098
13099 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13100 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13101 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13102 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13103
13104 -- 4262811 Variables ------------------------------------------------------------------------------------------
13105 l_entered_amt_idx NUMBER;
13106 l_accted_amt_idx NUMBER;
13107 l_acc_rev_flag VARCHAR2(1);
13108 l_accrual_line_num NUMBER;
13109 l_tmp_amt NUMBER;
13110 l_acc_rev_natural_side_code VARCHAR2(1);
13111
13112 l_num_entries NUMBER;
13113 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13114 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13115 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13116 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13117 l_recog_line_1 NUMBER;
13118 l_recog_line_2 NUMBER;
13119
13120 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13121 l_bflow_applied_to_amt NUMBER; -- 5132302
13122 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13123
13124 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13125
13126 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13127 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13128
13129 ---------------------------------------------------------------------------------------------------------------
13130
13131
13132 --
13133 -- bulk performance
13134 --
13135 l_balance_type_code VARCHAR2(1);
13136 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13137 l_log_module VARCHAR2(240);
13138
13139 --
13140 -- Upgrade strategy
13141 --
13142 l_actual_upg_option VARCHAR2(1);
13143 l_enc_upg_option VARCHAR2(1);
13144
13145 --
13146 BEGIN
13147 --
13148 IF g_log_enabled THEN
13149 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_50';
13150 END IF;
13151 --
13152 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13153
13154 trace
13155 (p_msg => 'BEGIN of AcctLineType_50'
13156 ,p_level => C_LEVEL_PROCEDURE
13157 ,p_module => l_log_module);
13158
13159 END IF;
13160 --
13161 l_component_type := 'AMB_JLT';
13162 l_component_code := 'CLEARING';
13163 l_component_type_code := 'S';
13164 l_component_appl_id := 707;
13165 l_amb_context_code := 'DEFAULT';
13166 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
13167 l_event_class_code := 'PURCHASE_ORDER';
13168 l_event_type_code := 'PO_DEL_INV';
13169 l_line_definition_owner_code := 'S';
13170 l_line_definition_code := 'PI_PO_DEL_INV';
13171 --
13172 l_balance_type_code := 'A';
13173 l_segment := NULL;
13174 l_ccid := NULL;
13175 l_adr_transaction_coa_id := NULL;
13176 l_adr_accounting_coa_id := NULL;
13177 l_adr_flexfield_segment_code := NULL;
13178 l_adr_flex_value_set_id := NULL;
13179 l_adr_value_type_code := NULL;
13180 l_adr_value_combination_id := NULL;
13181 l_adr_value_segment_code := NULL;
13182
13183 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13184 l_bflow_class_code := ''; -- 4219869 Business Flow
13185 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13186 l_budgetary_control_flag := 'N';
13187
13188 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13189 l_bflow_applied_to_amt := NULL; -- 5132302
13190 l_entered_amt_idx := NULL; -- 4262811
13191 l_accted_amt_idx := NULL; -- 4262811
13192 l_acc_rev_flag := NULL; -- 4262811
13193 l_accrual_line_num := NULL; -- 4262811
13194 l_tmp_amt := NULL; -- 4262811
13195 --
13196
13197 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13198 l_balance_type_code <> 'B' THEN
13199 IF NVL(p_source_97,9E125) = 31
13200 THEN
13201
13202 --
13203 XLA_AE_LINES_PKG.SetNewLine;
13204
13205 p_balance_type_code := l_balance_type_code;
13206 -- set the flag so later we will know whether the gain loss line needs to be created
13207
13208 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13209 p_actual_flag :='A';
13210 END IF;
13211
13212 --
13213 -- bulk performance
13214 --
13215 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13216 p_header_num => 0); -- 4262811
13217 --
13218 -- set accounting line options
13219 --
13220 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13221 p_natural_side_code => 'D'
13222 , p_gain_or_loss_flag => 'N'
13223 , p_gl_transfer_mode_code => 'S'
13224 , p_acct_entry_type_code => 'A'
13225 , p_switch_side_flag => 'Y'
13226 , p_merge_duplicate_code => 'N'
13227 );
13228 --
13229 l_acc_rev_natural_side_code := 'C'; -- 4262811
13230 --
13231 --
13232 -- set accounting line type info
13233 --
13234 xla_ae_lines_pkg.SetAcctLineType
13235 (p_component_type => l_component_type
13236 ,p_event_type_code => l_event_type_code
13237 ,p_line_definition_owner_code => l_line_definition_owner_code
13238 ,p_line_definition_code => l_line_definition_code
13239 ,p_accounting_line_code => l_component_code
13240 ,p_accounting_line_type_code => l_component_type_code
13241 ,p_accounting_line_appl_id => l_component_appl_id
13242 ,p_amb_context_code => l_amb_context_code
13243 ,p_entity_code => l_entity_code
13244 ,p_event_class_code => l_event_class_code);
13245 --
13246 -- set accounting class
13247 --
13248 xla_ae_lines_pkg.SetAcctClass(
13249 p_accounting_class_code => 'CLEARING'
13250 , p_ae_header_id => l_ae_header_id
13251 );
13252
13253 --
13254 -- set rounding class
13255 --
13256 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13257 'CLEARING';
13258
13259 --
13260 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13261 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13262 --
13263 -- bulk performance
13264 --
13265 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13266
13267 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13268 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13269
13270 -- 4955764
13271 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13272 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13273
13274 -- 4458381 Public Sector Enh
13275
13276 --
13277 -- set accounting attributes for the line type
13278 --
13279 l_entered_amt_idx := 17;
13280 l_accted_amt_idx := 22;
13281 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13282 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
13283 l_rec_acct_attrs.array_num_value(1) := p_source_79;
13284 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
13285 l_rec_acct_attrs.array_char_value(2) := p_source_80;
13286 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
13287 l_rec_acct_attrs.array_char_value(3) := p_source_81;
13288 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
13289 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
13290 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
13291 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
13292 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
13293 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
13294 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
13295 l_rec_acct_attrs.array_char_value(7) := p_source_85;
13296 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
13297 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
13298 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
13299 l_rec_acct_attrs.array_num_value(9) := p_source_87;
13300 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
13301 l_rec_acct_attrs.array_char_value(10) := p_source_88;
13302 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
13303 l_rec_acct_attrs.array_num_value(11) := p_source_89;
13304 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
13305 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
13306 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
13307 l_rec_acct_attrs.array_num_value(13) := p_source_87;
13308 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
13309 l_rec_acct_attrs.array_char_value(14) := p_source_88;
13310 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
13311 l_rec_acct_attrs.array_num_value(15) := p_source_89;
13312 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
13313 l_rec_acct_attrs.array_char_value(16) := p_source_100;
13314 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
13315 l_rec_acct_attrs.array_num_value(17) := p_source_91;
13316 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
13317 l_rec_acct_attrs.array_char_value(18) := p_source_88;
13318 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
13319 l_rec_acct_attrs.array_date_value(19) := p_source_92;
13320 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
13321 l_rec_acct_attrs.array_num_value(20) := p_source_93;
13322 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
13323 l_rec_acct_attrs.array_char_value(21) := p_source_94;
13324 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
13325 l_rec_acct_attrs.array_num_value(22) := p_source_95;
13326 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
13327 l_rec_acct_attrs.array_num_value(23) := p_source_96;
13328 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
13329 l_rec_acct_attrs.array_num_value(24) := p_source_96;
13330
13331 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13332 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13333
13334 ---------------------------------------------------------------------------------------------------------------
13335 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13336 ---------------------------------------------------------------------------------------------------------------
13337 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13338
13339 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13340 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13341
13342 IF xla_accounting_cache_pkg.GetValueChar
13343 (p_source_code => 'LEDGER_CATEGORY_CODE'
13344 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13345 AND l_bflow_method_code = 'PRIOR_ENTRY'
13346 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13347 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13348 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13349 )
13350 THEN
13351 xla_ae_lines_pkg.BflowUpgEntry
13352 (p_business_method_code => l_bflow_method_code
13353 ,p_business_class_code => l_bflow_class_code
13354 ,p_balance_type => l_balance_type_code);
13355 ELSE
13356 NULL;
13357 -- No business flow processing for business flow method of NONE.
13358 END IF;
13359
13360 --
13361 -- call analytical criteria
13362 --
13363
13364 --
13365 -- call description
13366 --
13367
13368 xla_ae_lines_pkg.SetLineDescription(
13369 p_ae_header_id => l_ae_header_id
13370 ,p_description => Description_1 (
13371 p_application_id => p_application_id
13372 , p_ae_header_id => l_ae_header_id
13373 , p_source_1 => p_source_1
13374 , p_source_2 => p_source_2
13375 , p_source_3 => p_source_3
13376 , p_source_4 => p_source_4
13377 , p_source_5 => p_source_5
13378 )
13379 );
13380
13381
13382 --
13383 -- call ADRs
13384 -- Bug 4922099
13385 --
13386 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13387 (NVL(l_actual_upg_option, 'N') = 'O') OR
13388 (NVL(l_enc_upg_option, 'N') = 'O')
13389 )
13390 THEN
13391 NULL;
13392 --
13393 --
13394
13395 l_ccid := AcctDerRule_6(
13396 p_application_id => p_application_id
13397 , p_ae_header_id => l_ae_header_id
13398 , p_source_11 => p_source_11
13399 , x_transaction_coa_id => l_adr_transaction_coa_id
13400 , x_accounting_coa_id => l_adr_accounting_coa_id
13401 , x_value_type_code => l_adr_value_type_code
13402 , p_side => 'NA'
13403 );
13404
13405 xla_ae_lines_pkg.set_ccid(
13406 p_code_combination_id => l_ccid
13407 , p_value_type_code => l_adr_value_type_code
13408 , p_transaction_coa_id => l_adr_transaction_coa_id
13409 , p_accounting_coa_id => l_adr_accounting_coa_id
13410 , p_adr_code => 'CST_DEFAULT'
13411 , p_adr_type_code => 'S'
13412 , p_component_type => l_component_type
13413 , p_component_code => l_component_code
13414 , p_component_type_code => l_component_type_code
13415 , p_component_appl_id => l_component_appl_id
13416 , p_amb_context_code => l_amb_context_code
13417 , p_side => 'NA'
13418 );
13419
13420
13421 --
13422 --
13423 END IF;
13424 --
13425 -- Bug 4922099
13426 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13427 (NVL(l_enc_upg_option, 'N') = 'O')
13428 ) AND
13429 (l_bflow_method_code = 'PRIOR_ENTRY')
13430 )
13431 THEN
13432 IF
13433 --
13434 1 = 2
13435 --
13436 THEN
13437 xla_accounting_err_pkg.build_message
13438 (p_appli_s_name => 'XLA'
13439 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13440 ,p_token_1 => 'LINE_NUMBER'
13441 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13442 ,p_token_2 => 'LINE_TYPE_NAME'
13443 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13444 l_component_type
13445 ,l_component_code
13446 ,l_component_type_code
13447 ,l_component_appl_id
13448 ,l_amb_context_code
13449 ,l_entity_code
13450 ,l_event_class_code
13451 )
13452 ,p_token_3 => 'OWNER'
13453 ,p_value_3 => xla_lookups_pkg.get_meaning(
13454 p_lookup_type => 'XLA_OWNER_TYPE'
13455 ,p_lookup_code => l_component_type_code
13456 )
13457 ,p_token_4 => 'PRODUCT_NAME'
13458 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13459 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13460 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13461 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13462 ,p_ae_header_id => NULL
13463 );
13464
13465 IF (C_LEVEL_ERROR>= g_log_level) THEN
13466 trace
13467 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13468 ,p_level => C_LEVEL_ERROR
13469 ,p_module => l_log_module);
13470 END IF;
13471 END IF;
13472 END IF;
13473 --
13474 --
13475 ------------------------------------------------------------------------------------------------
13476 -- 4219869 Business Flow
13477 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13478 -- Prior Entry. Currently, the following code is always generated.
13479 ------------------------------------------------------------------------------------------------
13480 XLA_AE_LINES_PKG.ValidateCurrentLine;
13481
13482 ------------------------------------------------------------------------------------
13483 -- 4219869 Business Flow
13484 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13485 ------------------------------------------------------------------------------------
13486 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13487
13488 ----------------------------------------------------------------------------------
13489 -- 4219869 Business Flow
13490 -- Update journal entry status -- Need to generate this within IF <condition>
13491 ----------------------------------------------------------------------------------
13492 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13493 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13494 ,p_balance_type_code => l_balance_type_code
13495 );
13496
13497 -------------------------------------------------------------------------------------------
13498 -- 4262811 - Generate the Accrual Reversal lines
13499 -------------------------------------------------------------------------------------------
13500 BEGIN
13501 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13502 (g_array_event(p_event_id).array_value_num('header_index'));
13503 IF l_acc_rev_flag IS NULL THEN
13504 l_acc_rev_flag := 'N';
13505 END IF;
13506 EXCEPTION
13507 WHEN OTHERS THEN
13508 l_acc_rev_flag := 'N';
13509 END;
13510 --
13511 IF (l_acc_rev_flag = 'Y') THEN
13512
13513 -- 4645092 ------------------------------------------------------------------------------
13514 -- To allow MPA report to determine if it should generate report process
13515 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13516 ------------------------------------------------------------------------------------------
13517
13518 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13519 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13520 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13521 -- call ADRs
13522 -- Bug 4922099
13523 --
13524 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13525 (NVL(l_actual_upg_option, 'N') = 'O') OR
13526 (NVL(l_enc_upg_option, 'N') = 'O')
13527 )
13528 THEN
13529 NULL;
13530 --
13531 --
13532
13533 l_ccid := AcctDerRule_6(
13534 p_application_id => p_application_id
13535 , p_ae_header_id => l_ae_header_id
13536 , p_source_11 => p_source_11
13537 , x_transaction_coa_id => l_adr_transaction_coa_id
13538 , x_accounting_coa_id => l_adr_accounting_coa_id
13539 , x_value_type_code => l_adr_value_type_code
13540 , p_side => 'NA'
13541 );
13542
13543 xla_ae_lines_pkg.set_ccid(
13544 p_code_combination_id => l_ccid
13545 , p_value_type_code => l_adr_value_type_code
13546 , p_transaction_coa_id => l_adr_transaction_coa_id
13547 , p_accounting_coa_id => l_adr_accounting_coa_id
13548 , p_adr_code => 'CST_DEFAULT'
13549 , p_adr_type_code => 'S'
13550 , p_component_type => l_component_type
13551 , p_component_code => l_component_code
13552 , p_component_type_code => l_component_type_code
13553 , p_component_appl_id => l_component_appl_id
13554 , p_amb_context_code => l_amb_context_code
13555 , p_side => 'NA'
13556 );
13557
13558
13559 --
13560 --
13561 END IF;
13562
13563 --
13564 -- Update the line information that should be overwritten
13565 --
13566 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13567 p_header_num => 1);
13568 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13569
13570 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13571
13572 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13573 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13574 END IF;
13575
13576 --
13577 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13578 --
13579 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13580 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13581 ELSE
13582 ---------------------------------------------------------------------------------------------------
13583 -- 4262811a Switch Sign
13584 ---------------------------------------------------------------------------------------------------
13585 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13586 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13587 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13588 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13589 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13590 -- 5132302
13591 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13592 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13593
13594 END IF;
13595
13596 -- 4955764
13597 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13598 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13599
13600
13601 XLA_AE_LINES_PKG.ValidateCurrentLine;
13602 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13603
13604 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13605 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13606 ,p_balance_type_code => l_balance_type_code);
13607
13608 END IF;
13609
13610 -----------------------------------------------------------------------------------------
13611 -- 4262811 Multiperiod Accounting
13612 -----------------------------------------------------------------------------------------
13613 -- No MPA option is assigned.
13614
13615
13616 END IF;
13617 END IF;
13618 --
13619
13620 --
13621 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13622 trace
13623 (p_msg => 'END of AcctLineType_50'
13624 ,p_level => C_LEVEL_PROCEDURE
13625 ,p_module => l_log_module);
13626 END IF;
13627 --
13628 EXCEPTION
13629 WHEN xla_exceptions_pkg.application_exception THEN
13630 RAISE;
13631 WHEN OTHERS THEN
13632 xla_exceptions_pkg.raise_message
13633 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_50');
13634 END AcctLineType_50;
13635 --
13636
13637 ---------------------------------------
13638 --
13639 -- PRIVATE FUNCTION
13640 -- AcctLineType_51
13641 --
13642 ---------------------------------------
13643 PROCEDURE AcctLineType_51 (
13644 p_application_id IN NUMBER
13645 ,p_event_id IN NUMBER
13646 ,p_calculate_acctd_flag IN VARCHAR2
13647 ,p_calculate_g_l_flag IN VARCHAR2
13648 ,p_actual_flag IN OUT VARCHAR2
13649 ,p_balance_type_code OUT VARCHAR2
13650 ,p_gain_or_loss_ref OUT VARCHAR2
13651
13652 --TRANSACTION_ID
13653 , p_source_1 IN NUMBER
13654 --Item Concatenated Segments
13655 , p_source_2 IN VARCHAR2
13656 --Transaction Quantity
13657 , p_source_3 IN NUMBER
13658 --Transaction Unit of Measure Code
13659 , p_source_4 IN VARCHAR2
13660 --Inventory Transaction Type Description
13661 , p_source_5 IN VARCHAR2
13662 --Cost Management Default Account
13663 , p_source_11 IN NUMBER
13664 --DISTRIBUTION_IDENTIFIER
13665 , p_source_84 IN NUMBER
13666 --Distribution Type
13667 , p_source_85 IN VARCHAR2
13668 , p_source_85_meaning IN VARCHAR2
13669 --Entered Currency Code
13670 , p_source_88 IN VARCHAR2
13671 --Entered Amount
13672 , p_source_91 IN NUMBER
13673 --Currency Conversion Date
13674 , p_source_92 IN DATE
13675 --Currency Conversion Rate
13676 , p_source_93 IN NUMBER
13677 --Currency Conversion Type
13678 , p_source_94 IN VARCHAR2
13679 --Accounted Amount
13680 , p_source_95 IN NUMBER
13681 --Accounting Line Type
13682 , p_source_97 IN NUMBER
13683 )
13684 IS
13685
13686 l_component_type VARCHAR2(80);
13687 l_component_code VARCHAR2(30);
13688 l_component_type_code VARCHAR2(1);
13689 l_component_appl_id INTEGER;
13690 l_amb_context_code VARCHAR2(30);
13691 l_entity_code VARCHAR2(30);
13692 l_event_class_code VARCHAR2(30);
13693 l_ae_header_id NUMBER;
13694 l_event_type_code VARCHAR2(30);
13695 l_line_definition_code VARCHAR2(30);
13696 l_line_definition_owner_code VARCHAR2(1);
13697 --
13698 -- adr variables
13699 l_segment VARCHAR2(30);
13700 l_ccid NUMBER;
13701 l_adr_transaction_coa_id NUMBER;
13702 l_adr_accounting_coa_id NUMBER;
13703 l_adr_flexfield_segment_code VARCHAR2(30);
13704 l_adr_flex_value_set_id NUMBER;
13705 l_adr_value_type_code VARCHAR2(30);
13706 l_adr_value_combination_id NUMBER;
13707 l_adr_value_segment_code VARCHAR2(30);
13708
13709 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13710 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13711 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13712 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13713
13714 -- 4262811 Variables ------------------------------------------------------------------------------------------
13715 l_entered_amt_idx NUMBER;
13716 l_accted_amt_idx NUMBER;
13717 l_acc_rev_flag VARCHAR2(1);
13718 l_accrual_line_num NUMBER;
13719 l_tmp_amt NUMBER;
13720 l_acc_rev_natural_side_code VARCHAR2(1);
13721
13722 l_num_entries NUMBER;
13723 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13724 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13725 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13726 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13727 l_recog_line_1 NUMBER;
13728 l_recog_line_2 NUMBER;
13729
13730 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13731 l_bflow_applied_to_amt NUMBER; -- 5132302
13732 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13733
13734 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13735
13736 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13737 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13738
13739 ---------------------------------------------------------------------------------------------------------------
13740
13741
13742 --
13743 -- bulk performance
13744 --
13745 l_balance_type_code VARCHAR2(1);
13746 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13747 l_log_module VARCHAR2(240);
13748
13749 --
13750 -- Upgrade strategy
13751 --
13752 l_actual_upg_option VARCHAR2(1);
13753 l_enc_upg_option VARCHAR2(1);
13754
13755 --
13756 BEGIN
13757 --
13758 IF g_log_enabled THEN
13759 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_51';
13760 END IF;
13761 --
13762 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13763
13764 trace
13765 (p_msg => 'BEGIN of AcctLineType_51'
13766 ,p_level => C_LEVEL_PROCEDURE
13767 ,p_module => l_log_module);
13768
13769 END IF;
13770 --
13771 l_component_type := 'AMB_JLT';
13772 l_component_code := 'CLEARING';
13773 l_component_type_code := 'S';
13774 l_component_appl_id := 707;
13775 l_amb_context_code := 'DEFAULT';
13776 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
13777 l_event_class_code := 'LOG_INTERCOMPANY';
13778 l_event_type_code := 'LOG_IC_RCPT_RETURN';
13779 l_line_definition_owner_code := 'S';
13780 l_line_definition_code := 'PI_LOG_IC_RCPT_RETURN';
13781 --
13782 l_balance_type_code := 'A';
13783 l_segment := NULL;
13784 l_ccid := NULL;
13785 l_adr_transaction_coa_id := NULL;
13786 l_adr_accounting_coa_id := NULL;
13787 l_adr_flexfield_segment_code := NULL;
13788 l_adr_flex_value_set_id := NULL;
13789 l_adr_value_type_code := NULL;
13790 l_adr_value_combination_id := NULL;
13791 l_adr_value_segment_code := NULL;
13792
13793 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13794 l_bflow_class_code := ''; -- 4219869 Business Flow
13795 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13796 l_budgetary_control_flag := 'N';
13797
13798 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13799 l_bflow_applied_to_amt := NULL; -- 5132302
13800 l_entered_amt_idx := NULL; -- 4262811
13801 l_accted_amt_idx := NULL; -- 4262811
13802 l_acc_rev_flag := NULL; -- 4262811
13803 l_accrual_line_num := NULL; -- 4262811
13804 l_tmp_amt := NULL; -- 4262811
13805 --
13806
13807 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13808 l_balance_type_code <> 'B' THEN
13809 IF NVL(p_source_97,9E125) = 31
13810 THEN
13811
13812 --
13813 XLA_AE_LINES_PKG.SetNewLine;
13814
13815 p_balance_type_code := l_balance_type_code;
13816 -- set the flag so later we will know whether the gain loss line needs to be created
13817
13818 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13819 p_actual_flag :='A';
13820 END IF;
13821
13822 --
13823 -- bulk performance
13824 --
13825 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13826 p_header_num => 0); -- 4262811
13827 --
13828 -- set accounting line options
13829 --
13830 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13831 p_natural_side_code => 'D'
13832 , p_gain_or_loss_flag => 'N'
13833 , p_gl_transfer_mode_code => 'S'
13834 , p_acct_entry_type_code => 'A'
13835 , p_switch_side_flag => 'Y'
13836 , p_merge_duplicate_code => 'N'
13837 );
13838 --
13839 l_acc_rev_natural_side_code := 'C'; -- 4262811
13840 --
13841 --
13842 -- set accounting line type info
13843 --
13844 xla_ae_lines_pkg.SetAcctLineType
13845 (p_component_type => l_component_type
13846 ,p_event_type_code => l_event_type_code
13847 ,p_line_definition_owner_code => l_line_definition_owner_code
13848 ,p_line_definition_code => l_line_definition_code
13849 ,p_accounting_line_code => l_component_code
13850 ,p_accounting_line_type_code => l_component_type_code
13851 ,p_accounting_line_appl_id => l_component_appl_id
13852 ,p_amb_context_code => l_amb_context_code
13853 ,p_entity_code => l_entity_code
13854 ,p_event_class_code => l_event_class_code);
13855 --
13856 -- set accounting class
13857 --
13858 xla_ae_lines_pkg.SetAcctClass(
13859 p_accounting_class_code => 'CLEARING'
13860 , p_ae_header_id => l_ae_header_id
13861 );
13862
13863 --
13864 -- set rounding class
13865 --
13866 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13867 'CLEARING';
13868
13869 --
13870 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13871 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13872 --
13873 -- bulk performance
13874 --
13875 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13876
13877 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13878 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13879
13880 -- 4955764
13881 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13882 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13883
13884 -- 4458381 Public Sector Enh
13885
13886 --
13887 -- set accounting attributes for the line type
13888 --
13889 l_entered_amt_idx := 3;
13890 l_accted_amt_idx := 8;
13891 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13892 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13893 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
13894 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13895 l_rec_acct_attrs.array_char_value(2) := p_source_85;
13896 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13897 l_rec_acct_attrs.array_num_value(3) := p_source_91;
13898 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13899 l_rec_acct_attrs.array_char_value(4) := p_source_88;
13900 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13901 l_rec_acct_attrs.array_date_value(5) := p_source_92;
13902 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13903 l_rec_acct_attrs.array_num_value(6) := p_source_93;
13904 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13905 l_rec_acct_attrs.array_char_value(7) := p_source_94;
13906 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
13907 l_rec_acct_attrs.array_num_value(8) := p_source_95;
13908
13909 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13910 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13911
13912 ---------------------------------------------------------------------------------------------------------------
13913 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13914 ---------------------------------------------------------------------------------------------------------------
13915 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13916
13917 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13918 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13919
13920 IF xla_accounting_cache_pkg.GetValueChar
13921 (p_source_code => 'LEDGER_CATEGORY_CODE'
13922 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13923 AND l_bflow_method_code = 'PRIOR_ENTRY'
13924 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13925 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13926 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13927 )
13928 THEN
13929 xla_ae_lines_pkg.BflowUpgEntry
13930 (p_business_method_code => l_bflow_method_code
13931 ,p_business_class_code => l_bflow_class_code
13932 ,p_balance_type => l_balance_type_code);
13933 ELSE
13934 NULL;
13935 -- No business flow processing for business flow method of NONE.
13936 END IF;
13937
13938 --
13939 -- call analytical criteria
13940 --
13941
13942 --
13943 -- call description
13944 --
13945
13946 xla_ae_lines_pkg.SetLineDescription(
13947 p_ae_header_id => l_ae_header_id
13948 ,p_description => Description_1 (
13949 p_application_id => p_application_id
13950 , p_ae_header_id => l_ae_header_id
13951 , p_source_1 => p_source_1
13952 , p_source_2 => p_source_2
13953 , p_source_3 => p_source_3
13954 , p_source_4 => p_source_4
13955 , p_source_5 => p_source_5
13956 )
13957 );
13958
13959
13960 --
13961 -- call ADRs
13962 -- Bug 4922099
13963 --
13964 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13965 (NVL(l_actual_upg_option, 'N') = 'O') OR
13966 (NVL(l_enc_upg_option, 'N') = 'O')
13967 )
13968 THEN
13969 NULL;
13970 --
13971 --
13972
13973 l_ccid := AcctDerRule_6(
13974 p_application_id => p_application_id
13975 , p_ae_header_id => l_ae_header_id
13976 , p_source_11 => p_source_11
13977 , x_transaction_coa_id => l_adr_transaction_coa_id
13978 , x_accounting_coa_id => l_adr_accounting_coa_id
13979 , x_value_type_code => l_adr_value_type_code
13980 , p_side => 'NA'
13981 );
13982
13983 xla_ae_lines_pkg.set_ccid(
13984 p_code_combination_id => l_ccid
13985 , p_value_type_code => l_adr_value_type_code
13986 , p_transaction_coa_id => l_adr_transaction_coa_id
13987 , p_accounting_coa_id => l_adr_accounting_coa_id
13988 , p_adr_code => 'CST_DEFAULT'
13989 , p_adr_type_code => 'S'
13990 , p_component_type => l_component_type
13991 , p_component_code => l_component_code
13992 , p_component_type_code => l_component_type_code
13993 , p_component_appl_id => l_component_appl_id
13994 , p_amb_context_code => l_amb_context_code
13995 , p_side => 'NA'
13996 );
13997
13998
13999 --
14000 --
14001 END IF;
14002 --
14003 -- Bug 4922099
14004 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14005 (NVL(l_enc_upg_option, 'N') = 'O')
14006 ) AND
14007 (l_bflow_method_code = 'PRIOR_ENTRY')
14008 )
14009 THEN
14010 IF
14011 --
14012 1 = 2
14013 --
14014 THEN
14015 xla_accounting_err_pkg.build_message
14016 (p_appli_s_name => 'XLA'
14017 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14018 ,p_token_1 => 'LINE_NUMBER'
14019 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14020 ,p_token_2 => 'LINE_TYPE_NAME'
14021 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14022 l_component_type
14023 ,l_component_code
14024 ,l_component_type_code
14025 ,l_component_appl_id
14026 ,l_amb_context_code
14027 ,l_entity_code
14028 ,l_event_class_code
14029 )
14030 ,p_token_3 => 'OWNER'
14031 ,p_value_3 => xla_lookups_pkg.get_meaning(
14032 p_lookup_type => 'XLA_OWNER_TYPE'
14033 ,p_lookup_code => l_component_type_code
14034 )
14035 ,p_token_4 => 'PRODUCT_NAME'
14036 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14037 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14038 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14039 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14040 ,p_ae_header_id => NULL
14041 );
14042
14043 IF (C_LEVEL_ERROR>= g_log_level) THEN
14044 trace
14045 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14046 ,p_level => C_LEVEL_ERROR
14047 ,p_module => l_log_module);
14048 END IF;
14049 END IF;
14050 END IF;
14051 --
14052 --
14053 ------------------------------------------------------------------------------------------------
14054 -- 4219869 Business Flow
14055 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14056 -- Prior Entry. Currently, the following code is always generated.
14057 ------------------------------------------------------------------------------------------------
14058 XLA_AE_LINES_PKG.ValidateCurrentLine;
14059
14060 ------------------------------------------------------------------------------------
14061 -- 4219869 Business Flow
14062 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14063 ------------------------------------------------------------------------------------
14064 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14065
14066 ----------------------------------------------------------------------------------
14067 -- 4219869 Business Flow
14068 -- Update journal entry status -- Need to generate this within IF <condition>
14069 ----------------------------------------------------------------------------------
14070 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14071 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14072 ,p_balance_type_code => l_balance_type_code
14073 );
14074
14075 -------------------------------------------------------------------------------------------
14076 -- 4262811 - Generate the Accrual Reversal lines
14077 -------------------------------------------------------------------------------------------
14078 BEGIN
14079 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14080 (g_array_event(p_event_id).array_value_num('header_index'));
14081 IF l_acc_rev_flag IS NULL THEN
14082 l_acc_rev_flag := 'N';
14083 END IF;
14084 EXCEPTION
14085 WHEN OTHERS THEN
14086 l_acc_rev_flag := 'N';
14087 END;
14088 --
14089 IF (l_acc_rev_flag = 'Y') THEN
14090
14091 -- 4645092 ------------------------------------------------------------------------------
14092 -- To allow MPA report to determine if it should generate report process
14093 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14094 ------------------------------------------------------------------------------------------
14095
14096 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14097 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14098 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14099 -- call ADRs
14100 -- Bug 4922099
14101 --
14102 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14103 (NVL(l_actual_upg_option, 'N') = 'O') OR
14104 (NVL(l_enc_upg_option, 'N') = 'O')
14105 )
14106 THEN
14107 NULL;
14108 --
14109 --
14110
14111 l_ccid := AcctDerRule_6(
14112 p_application_id => p_application_id
14113 , p_ae_header_id => l_ae_header_id
14114 , p_source_11 => p_source_11
14115 , x_transaction_coa_id => l_adr_transaction_coa_id
14116 , x_accounting_coa_id => l_adr_accounting_coa_id
14117 , x_value_type_code => l_adr_value_type_code
14118 , p_side => 'NA'
14119 );
14120
14121 xla_ae_lines_pkg.set_ccid(
14122 p_code_combination_id => l_ccid
14123 , p_value_type_code => l_adr_value_type_code
14124 , p_transaction_coa_id => l_adr_transaction_coa_id
14125 , p_accounting_coa_id => l_adr_accounting_coa_id
14126 , p_adr_code => 'CST_DEFAULT'
14127 , p_adr_type_code => 'S'
14128 , p_component_type => l_component_type
14129 , p_component_code => l_component_code
14130 , p_component_type_code => l_component_type_code
14131 , p_component_appl_id => l_component_appl_id
14132 , p_amb_context_code => l_amb_context_code
14133 , p_side => 'NA'
14134 );
14135
14136
14137 --
14138 --
14139 END IF;
14140
14141 --
14142 -- Update the line information that should be overwritten
14143 --
14144 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14145 p_header_num => 1);
14146 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14147
14148 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14149
14150 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14151 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14152 END IF;
14153
14154 --
14155 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14156 --
14157 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14158 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14159 ELSE
14160 ---------------------------------------------------------------------------------------------------
14161 -- 4262811a Switch Sign
14162 ---------------------------------------------------------------------------------------------------
14163 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14164 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14165 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14166 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14167 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14168 -- 5132302
14169 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14170 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14171
14172 END IF;
14173
14174 -- 4955764
14175 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14176 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14177
14178
14179 XLA_AE_LINES_PKG.ValidateCurrentLine;
14180 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14181
14182 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14183 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14184 ,p_balance_type_code => l_balance_type_code);
14185
14186 END IF;
14187
14188 -----------------------------------------------------------------------------------------
14189 -- 4262811 Multiperiod Accounting
14190 -----------------------------------------------------------------------------------------
14191 -- No MPA option is assigned.
14192
14193
14194 END IF;
14195 END IF;
14196 --
14197
14198 --
14199 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14200 trace
14201 (p_msg => 'END of AcctLineType_51'
14202 ,p_level => C_LEVEL_PROCEDURE
14203 ,p_module => l_log_module);
14204 END IF;
14205 --
14206 EXCEPTION
14207 WHEN xla_exceptions_pkg.application_exception THEN
14208 RAISE;
14209 WHEN OTHERS THEN
14210 xla_exceptions_pkg.raise_message
14211 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_51');
14212 END AcctLineType_51;
14213 --
14214
14215 ---------------------------------------
14216 --
14217 -- PRIVATE FUNCTION
14218 -- AcctLineType_52
14219 --
14220 ---------------------------------------
14221 PROCEDURE AcctLineType_52 (
14222 p_application_id IN NUMBER
14223 ,p_event_id IN NUMBER
14224 ,p_calculate_acctd_flag IN VARCHAR2
14225 ,p_calculate_g_l_flag IN VARCHAR2
14226 ,p_actual_flag IN OUT VARCHAR2
14227 ,p_balance_type_code OUT VARCHAR2
14228 ,p_gain_or_loss_ref OUT VARCHAR2
14229
14230 --TRANSACTION_ID
14231 , p_source_1 IN NUMBER
14232 --Item Concatenated Segments
14233 , p_source_2 IN VARCHAR2
14234 --Transaction Quantity
14235 , p_source_3 IN NUMBER
14236 --Transaction Unit of Measure Code
14237 , p_source_4 IN VARCHAR2
14238 --Inventory Transaction Type Description
14239 , p_source_5 IN VARCHAR2
14240 --Cost Management Default Account
14241 , p_source_11 IN NUMBER
14242 --Applied to Application ID
14243 , p_source_79 IN NUMBER
14244 --Applied to Distribution Link Type
14245 , p_source_80 IN VARCHAR2
14246 --Applied to Entity Code
14247 , p_source_81 IN VARCHAR2
14248 --Applied To Purchase Document Identifier
14249 , p_source_83 IN NUMBER
14250 --DISTRIBUTION_IDENTIFIER
14251 , p_source_84 IN NUMBER
14252 --Distribution Type
14253 , p_source_85 IN VARCHAR2
14254 , p_source_85_meaning IN VARCHAR2
14255 --PO Budget Account
14256 , p_source_86 IN NUMBER
14257 --Encumbrance Reversal Amount Entered
14258 , p_source_87 IN NUMBER
14259 --Entered Currency Code
14260 , p_source_88 IN VARCHAR2
14261 --Transaction Encumbrance Reversal Amount
14262 , p_source_89 IN NUMBER
14263 --Entered Amount
14264 , p_source_91 IN NUMBER
14265 --Currency Conversion Date
14266 , p_source_92 IN DATE
14267 --Currency Conversion Rate
14268 , p_source_93 IN NUMBER
14269 --Currency Conversion Type
14270 , p_source_94 IN VARCHAR2
14271 --Accounted Amount
14272 , p_source_95 IN NUMBER
14273 --Purchasing Encumbrance Type Identifier
14274 , p_source_96 IN NUMBER
14275 --Accounting Line Type
14276 , p_source_97 IN NUMBER
14277 --Costing Encumbrance Upgrade Option
14278 , p_source_100 IN VARCHAR2
14279 --TXN_PO_DISTRIBUTION_ID
14280 , p_source_101 IN NUMBER
14281 )
14282 IS
14283
14284 l_component_type VARCHAR2(80);
14285 l_component_code VARCHAR2(30);
14286 l_component_type_code VARCHAR2(1);
14287 l_component_appl_id INTEGER;
14288 l_amb_context_code VARCHAR2(30);
14289 l_entity_code VARCHAR2(30);
14290 l_event_class_code VARCHAR2(30);
14291 l_ae_header_id NUMBER;
14292 l_event_type_code VARCHAR2(30);
14293 l_line_definition_code VARCHAR2(30);
14294 l_line_definition_owner_code VARCHAR2(1);
14295 --
14296 -- adr variables
14297 l_segment VARCHAR2(30);
14298 l_ccid NUMBER;
14299 l_adr_transaction_coa_id NUMBER;
14300 l_adr_accounting_coa_id NUMBER;
14301 l_adr_flexfield_segment_code VARCHAR2(30);
14302 l_adr_flex_value_set_id NUMBER;
14303 l_adr_value_type_code VARCHAR2(30);
14304 l_adr_value_combination_id NUMBER;
14305 l_adr_value_segment_code VARCHAR2(30);
14306
14307 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14308 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14309 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14310 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14311
14312 -- 4262811 Variables ------------------------------------------------------------------------------------------
14313 l_entered_amt_idx NUMBER;
14314 l_accted_amt_idx NUMBER;
14315 l_acc_rev_flag VARCHAR2(1);
14316 l_accrual_line_num NUMBER;
14317 l_tmp_amt NUMBER;
14318 l_acc_rev_natural_side_code VARCHAR2(1);
14319
14320 l_num_entries NUMBER;
14321 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14322 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14323 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14324 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14325 l_recog_line_1 NUMBER;
14326 l_recog_line_2 NUMBER;
14327
14328 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14329 l_bflow_applied_to_amt NUMBER; -- 5132302
14330 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14331
14332 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14333
14334 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14335 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14336
14337 ---------------------------------------------------------------------------------------------------------------
14338
14339
14340 --
14341 -- bulk performance
14342 --
14343 l_balance_type_code VARCHAR2(1);
14344 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14345 l_log_module VARCHAR2(240);
14346
14347 --
14348 -- Upgrade strategy
14349 --
14350 l_actual_upg_option VARCHAR2(1);
14351 l_enc_upg_option VARCHAR2(1);
14352
14353 --
14354 BEGIN
14355 --
14356 IF g_log_enabled THEN
14357 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_52';
14358 END IF;
14359 --
14360 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14361
14362 trace
14363 (p_msg => 'BEGIN of AcctLineType_52'
14364 ,p_level => C_LEVEL_PROCEDURE
14365 ,p_module => l_log_module);
14366
14367 END IF;
14368 --
14369 l_component_type := 'AMB_JLT';
14370 l_component_code := 'CLEARING';
14371 l_component_type_code := 'S';
14372 l_component_appl_id := 707;
14373 l_amb_context_code := 'DEFAULT';
14374 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
14375 l_event_class_code := 'PURCHASE_ORDER';
14376 l_event_type_code := 'LOG_PO_DEL_ADJ';
14377 l_line_definition_owner_code := 'S';
14378 l_line_definition_code := 'PI_LOG_PO_DEL_ADJ';
14379 --
14380 l_balance_type_code := 'A';
14381 l_segment := NULL;
14382 l_ccid := NULL;
14383 l_adr_transaction_coa_id := NULL;
14384 l_adr_accounting_coa_id := NULL;
14385 l_adr_flexfield_segment_code := NULL;
14386 l_adr_flex_value_set_id := NULL;
14387 l_adr_value_type_code := NULL;
14388 l_adr_value_combination_id := NULL;
14389 l_adr_value_segment_code := NULL;
14390
14391 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14392 l_bflow_class_code := ''; -- 4219869 Business Flow
14393 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14394 l_budgetary_control_flag := 'N';
14395
14396 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14397 l_bflow_applied_to_amt := NULL; -- 5132302
14398 l_entered_amt_idx := NULL; -- 4262811
14399 l_accted_amt_idx := NULL; -- 4262811
14400 l_acc_rev_flag := NULL; -- 4262811
14401 l_accrual_line_num := NULL; -- 4262811
14402 l_tmp_amt := NULL; -- 4262811
14403 --
14404
14405 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14406 l_balance_type_code <> 'B' THEN
14407 IF NVL(p_source_97,9E125) = 31
14408 THEN
14409
14410 --
14411 XLA_AE_LINES_PKG.SetNewLine;
14412
14413 p_balance_type_code := l_balance_type_code;
14414 -- set the flag so later we will know whether the gain loss line needs to be created
14415
14416 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14417 p_actual_flag :='A';
14418 END IF;
14419
14420 --
14421 -- bulk performance
14422 --
14423 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14424 p_header_num => 0); -- 4262811
14425 --
14426 -- set accounting line options
14427 --
14428 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14429 p_natural_side_code => 'D'
14430 , p_gain_or_loss_flag => 'N'
14431 , p_gl_transfer_mode_code => 'S'
14432 , p_acct_entry_type_code => 'A'
14433 , p_switch_side_flag => 'Y'
14434 , p_merge_duplicate_code => 'N'
14435 );
14436 --
14437 l_acc_rev_natural_side_code := 'C'; -- 4262811
14438 --
14439 --
14440 -- set accounting line type info
14441 --
14442 xla_ae_lines_pkg.SetAcctLineType
14443 (p_component_type => l_component_type
14444 ,p_event_type_code => l_event_type_code
14445 ,p_line_definition_owner_code => l_line_definition_owner_code
14446 ,p_line_definition_code => l_line_definition_code
14447 ,p_accounting_line_code => l_component_code
14448 ,p_accounting_line_type_code => l_component_type_code
14449 ,p_accounting_line_appl_id => l_component_appl_id
14450 ,p_amb_context_code => l_amb_context_code
14451 ,p_entity_code => l_entity_code
14452 ,p_event_class_code => l_event_class_code);
14453 --
14454 -- set accounting class
14455 --
14456 xla_ae_lines_pkg.SetAcctClass(
14457 p_accounting_class_code => 'CLEARING'
14458 , p_ae_header_id => l_ae_header_id
14459 );
14460
14461 --
14462 -- set rounding class
14463 --
14464 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14465 'CLEARING';
14466
14467 --
14468 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14469 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14470 --
14471 -- bulk performance
14472 --
14473 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14474
14475 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14476 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14477
14478 -- 4955764
14479 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14480 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14481
14482 -- 4458381 Public Sector Enh
14483
14484 --
14485 -- set accounting attributes for the line type
14486 --
14487 l_entered_amt_idx := 17;
14488 l_accted_amt_idx := 22;
14489 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14490 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
14491 l_rec_acct_attrs.array_num_value(1) := p_source_79;
14492 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
14493 l_rec_acct_attrs.array_char_value(2) := p_source_80;
14494 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
14495 l_rec_acct_attrs.array_char_value(3) := p_source_81;
14496 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
14497 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
14498 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
14499 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
14500 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
14501 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
14502 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
14503 l_rec_acct_attrs.array_char_value(7) := p_source_85;
14504 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
14505 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
14506 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
14507 l_rec_acct_attrs.array_num_value(9) := p_source_87;
14508 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
14509 l_rec_acct_attrs.array_char_value(10) := p_source_88;
14510 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
14511 l_rec_acct_attrs.array_num_value(11) := p_source_89;
14512 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
14513 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
14514 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
14515 l_rec_acct_attrs.array_num_value(13) := p_source_87;
14516 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
14517 l_rec_acct_attrs.array_char_value(14) := p_source_88;
14518 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
14519 l_rec_acct_attrs.array_num_value(15) := p_source_89;
14520 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
14521 l_rec_acct_attrs.array_char_value(16) := p_source_100;
14522 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
14523 l_rec_acct_attrs.array_num_value(17) := p_source_91;
14524 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
14525 l_rec_acct_attrs.array_char_value(18) := p_source_88;
14526 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
14527 l_rec_acct_attrs.array_date_value(19) := p_source_92;
14528 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
14529 l_rec_acct_attrs.array_num_value(20) := p_source_93;
14530 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
14531 l_rec_acct_attrs.array_char_value(21) := p_source_94;
14532 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
14533 l_rec_acct_attrs.array_num_value(22) := p_source_95;
14534 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
14535 l_rec_acct_attrs.array_num_value(23) := p_source_96;
14536 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
14537 l_rec_acct_attrs.array_num_value(24) := p_source_96;
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
14576 xla_ae_lines_pkg.SetLineDescription(
14577 p_ae_header_id => l_ae_header_id
14578 ,p_description => Description_1 (
14579 p_application_id => p_application_id
14580 , p_ae_header_id => l_ae_header_id
14581 , p_source_1 => p_source_1
14582 , p_source_2 => p_source_2
14583 , p_source_3 => p_source_3
14584 , p_source_4 => p_source_4
14585 , p_source_5 => p_source_5
14586 )
14587 );
14588
14589
14590 --
14591 -- call ADRs
14592 -- Bug 4922099
14593 --
14594 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14595 (NVL(l_actual_upg_option, 'N') = 'O') OR
14596 (NVL(l_enc_upg_option, 'N') = 'O')
14597 )
14598 THEN
14599 NULL;
14600 --
14601 --
14602
14603 l_ccid := AcctDerRule_6(
14604 p_application_id => p_application_id
14605 , p_ae_header_id => l_ae_header_id
14606 , p_source_11 => p_source_11
14607 , x_transaction_coa_id => l_adr_transaction_coa_id
14608 , x_accounting_coa_id => l_adr_accounting_coa_id
14609 , x_value_type_code => l_adr_value_type_code
14610 , p_side => 'NA'
14611 );
14612
14613 xla_ae_lines_pkg.set_ccid(
14614 p_code_combination_id => l_ccid
14615 , p_value_type_code => l_adr_value_type_code
14616 , p_transaction_coa_id => l_adr_transaction_coa_id
14617 , p_accounting_coa_id => l_adr_accounting_coa_id
14618 , p_adr_code => 'CST_DEFAULT'
14619 , p_adr_type_code => 'S'
14620 , p_component_type => l_component_type
14621 , p_component_code => l_component_code
14622 , p_component_type_code => l_component_type_code
14623 , p_component_appl_id => l_component_appl_id
14624 , p_amb_context_code => l_amb_context_code
14625 , p_side => 'NA'
14626 );
14627
14628
14629 --
14630 --
14631 END IF;
14632 --
14633 -- Bug 4922099
14634 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14635 (NVL(l_enc_upg_option, 'N') = 'O')
14636 ) AND
14637 (l_bflow_method_code = 'PRIOR_ENTRY')
14638 )
14639 THEN
14640 IF
14641 --
14642 1 = 2
14643 --
14644 THEN
14645 xla_accounting_err_pkg.build_message
14646 (p_appli_s_name => 'XLA'
14647 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14648 ,p_token_1 => 'LINE_NUMBER'
14649 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14650 ,p_token_2 => 'LINE_TYPE_NAME'
14651 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14652 l_component_type
14653 ,l_component_code
14654 ,l_component_type_code
14655 ,l_component_appl_id
14656 ,l_amb_context_code
14657 ,l_entity_code
14658 ,l_event_class_code
14659 )
14660 ,p_token_3 => 'OWNER'
14661 ,p_value_3 => xla_lookups_pkg.get_meaning(
14662 p_lookup_type => 'XLA_OWNER_TYPE'
14663 ,p_lookup_code => l_component_type_code
14664 )
14665 ,p_token_4 => 'PRODUCT_NAME'
14666 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14667 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14668 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14669 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14670 ,p_ae_header_id => NULL
14671 );
14672
14673 IF (C_LEVEL_ERROR>= g_log_level) THEN
14674 trace
14675 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14676 ,p_level => C_LEVEL_ERROR
14677 ,p_module => l_log_module);
14678 END IF;
14679 END IF;
14680 END IF;
14681 --
14682 --
14683 ------------------------------------------------------------------------------------------------
14684 -- 4219869 Business Flow
14685 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14686 -- Prior Entry. Currently, the following code is always generated.
14687 ------------------------------------------------------------------------------------------------
14688 XLA_AE_LINES_PKG.ValidateCurrentLine;
14689
14690 ------------------------------------------------------------------------------------
14691 -- 4219869 Business Flow
14692 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14693 ------------------------------------------------------------------------------------
14694 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14695
14696 ----------------------------------------------------------------------------------
14697 -- 4219869 Business Flow
14698 -- Update journal entry status -- Need to generate this within IF <condition>
14699 ----------------------------------------------------------------------------------
14700 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14701 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14702 ,p_balance_type_code => l_balance_type_code
14703 );
14704
14705 -------------------------------------------------------------------------------------------
14706 -- 4262811 - Generate the Accrual Reversal lines
14707 -------------------------------------------------------------------------------------------
14708 BEGIN
14709 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14710 (g_array_event(p_event_id).array_value_num('header_index'));
14711 IF l_acc_rev_flag IS NULL THEN
14712 l_acc_rev_flag := 'N';
14713 END IF;
14714 EXCEPTION
14715 WHEN OTHERS THEN
14716 l_acc_rev_flag := 'N';
14717 END;
14718 --
14719 IF (l_acc_rev_flag = 'Y') THEN
14720
14721 -- 4645092 ------------------------------------------------------------------------------
14722 -- To allow MPA report to determine if it should generate report process
14723 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14724 ------------------------------------------------------------------------------------------
14725
14726 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14727 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14728 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14729 -- call ADRs
14730 -- Bug 4922099
14731 --
14732 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14733 (NVL(l_actual_upg_option, 'N') = 'O') OR
14734 (NVL(l_enc_upg_option, 'N') = 'O')
14735 )
14736 THEN
14737 NULL;
14738 --
14739 --
14740
14741 l_ccid := AcctDerRule_6(
14742 p_application_id => p_application_id
14743 , p_ae_header_id => l_ae_header_id
14744 , p_source_11 => p_source_11
14745 , x_transaction_coa_id => l_adr_transaction_coa_id
14746 , x_accounting_coa_id => l_adr_accounting_coa_id
14747 , x_value_type_code => l_adr_value_type_code
14748 , p_side => 'NA'
14749 );
14750
14751 xla_ae_lines_pkg.set_ccid(
14752 p_code_combination_id => l_ccid
14753 , p_value_type_code => l_adr_value_type_code
14754 , p_transaction_coa_id => l_adr_transaction_coa_id
14755 , p_accounting_coa_id => l_adr_accounting_coa_id
14756 , p_adr_code => 'CST_DEFAULT'
14757 , p_adr_type_code => 'S'
14758 , p_component_type => l_component_type
14759 , p_component_code => l_component_code
14760 , p_component_type_code => l_component_type_code
14761 , p_component_appl_id => l_component_appl_id
14762 , p_amb_context_code => l_amb_context_code
14763 , p_side => 'NA'
14764 );
14765
14766
14767 --
14768 --
14769 END IF;
14770
14771 --
14772 -- Update the line information that should be overwritten
14773 --
14774 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14775 p_header_num => 1);
14776 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14777
14778 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14779
14780 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14781 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14782 END IF;
14783
14784 --
14785 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14786 --
14787 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14788 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14789 ELSE
14790 ---------------------------------------------------------------------------------------------------
14791 -- 4262811a Switch Sign
14792 ---------------------------------------------------------------------------------------------------
14793 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14794 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14795 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14796 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14797 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14798 -- 5132302
14799 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14800 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14801
14802 END IF;
14803
14804 -- 4955764
14805 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14806 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14807
14808
14809 XLA_AE_LINES_PKG.ValidateCurrentLine;
14810 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14811
14812 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14813 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14814 ,p_balance_type_code => l_balance_type_code);
14815
14816 END IF;
14817
14818 -----------------------------------------------------------------------------------------
14819 -- 4262811 Multiperiod Accounting
14820 -----------------------------------------------------------------------------------------
14821 -- No MPA option is assigned.
14822
14823
14824 END IF;
14825 END IF;
14826 --
14827
14828 --
14829 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14830 trace
14831 (p_msg => 'END of AcctLineType_52'
14832 ,p_level => C_LEVEL_PROCEDURE
14833 ,p_module => l_log_module);
14834 END IF;
14835 --
14836 EXCEPTION
14837 WHEN xla_exceptions_pkg.application_exception THEN
14838 RAISE;
14839 WHEN OTHERS THEN
14840 xla_exceptions_pkg.raise_message
14841 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_52');
14842 END AcctLineType_52;
14843 --
14844
14845 ---------------------------------------
14846 --
14847 -- PRIVATE FUNCTION
14848 -- AcctLineType_53
14849 --
14850 ---------------------------------------
14851 PROCEDURE AcctLineType_53 (
14852 p_application_id IN NUMBER
14853 ,p_event_id IN NUMBER
14854 ,p_calculate_acctd_flag IN VARCHAR2
14855 ,p_calculate_g_l_flag IN VARCHAR2
14856 ,p_actual_flag IN OUT VARCHAR2
14857 ,p_balance_type_code OUT VARCHAR2
14858 ,p_gain_or_loss_ref OUT VARCHAR2
14859
14860 --TRANSACTION_ID
14861 , p_source_1 IN NUMBER
14862 --Item Concatenated Segments
14863 , p_source_2 IN VARCHAR2
14864 --Transaction Quantity
14865 , p_source_3 IN NUMBER
14866 --Transaction Unit of Measure Code
14867 , p_source_4 IN VARCHAR2
14868 --Inventory Transaction Type Description
14869 , p_source_5 IN VARCHAR2
14870 --Cost Management Default Account
14871 , p_source_11 IN NUMBER
14872 --Applied to Application ID
14873 , p_source_79 IN NUMBER
14874 --Applied to Distribution Link Type
14875 , p_source_80 IN VARCHAR2
14876 --Applied to Entity Code
14877 , p_source_81 IN VARCHAR2
14878 --Applied To Purchase Document Identifier
14879 , p_source_83 IN NUMBER
14880 --DISTRIBUTION_IDENTIFIER
14881 , p_source_84 IN NUMBER
14882 --Distribution Type
14883 , p_source_85 IN VARCHAR2
14884 , p_source_85_meaning IN VARCHAR2
14885 --PO Budget Account
14886 , p_source_86 IN NUMBER
14887 --Encumbrance Reversal Amount Entered
14888 , p_source_87 IN NUMBER
14889 --Entered Currency Code
14890 , p_source_88 IN VARCHAR2
14891 --Transaction Encumbrance Reversal Amount
14892 , p_source_89 IN NUMBER
14893 --Entered Amount
14894 , p_source_91 IN NUMBER
14895 --Currency Conversion Date
14896 , p_source_92 IN DATE
14897 --Currency Conversion Rate
14898 , p_source_93 IN NUMBER
14899 --Currency Conversion Type
14900 , p_source_94 IN VARCHAR2
14901 --Accounted Amount
14902 , p_source_95 IN NUMBER
14903 --Purchasing Encumbrance Type Identifier
14904 , p_source_96 IN NUMBER
14905 --Accounting Line Type
14906 , p_source_97 IN NUMBER
14907 --Costing Encumbrance Upgrade Option
14908 , p_source_100 IN VARCHAR2
14909 --TXN_PO_DISTRIBUTION_ID
14910 , p_source_101 IN NUMBER
14911 )
14912 IS
14913
14914 l_component_type VARCHAR2(80);
14915 l_component_code VARCHAR2(30);
14916 l_component_type_code VARCHAR2(1);
14917 l_component_appl_id INTEGER;
14918 l_amb_context_code VARCHAR2(30);
14919 l_entity_code VARCHAR2(30);
14920 l_event_class_code VARCHAR2(30);
14921 l_ae_header_id NUMBER;
14922 l_event_type_code VARCHAR2(30);
14923 l_line_definition_code VARCHAR2(30);
14924 l_line_definition_owner_code VARCHAR2(1);
14925 --
14926 -- adr variables
14927 l_segment VARCHAR2(30);
14928 l_ccid NUMBER;
14929 l_adr_transaction_coa_id NUMBER;
14930 l_adr_accounting_coa_id NUMBER;
14931 l_adr_flexfield_segment_code VARCHAR2(30);
14932 l_adr_flex_value_set_id NUMBER;
14933 l_adr_value_type_code VARCHAR2(30);
14934 l_adr_value_combination_id NUMBER;
14935 l_adr_value_segment_code VARCHAR2(30);
14936
14937 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14938 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14939 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14940 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14941
14942 -- 4262811 Variables ------------------------------------------------------------------------------------------
14943 l_entered_amt_idx NUMBER;
14944 l_accted_amt_idx NUMBER;
14945 l_acc_rev_flag VARCHAR2(1);
14946 l_accrual_line_num NUMBER;
14947 l_tmp_amt NUMBER;
14948 l_acc_rev_natural_side_code VARCHAR2(1);
14949
14950 l_num_entries NUMBER;
14951 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14952 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14953 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14954 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14955 l_recog_line_1 NUMBER;
14956 l_recog_line_2 NUMBER;
14957
14958 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14959 l_bflow_applied_to_amt NUMBER; -- 5132302
14960 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14961
14962 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14963
14964 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14965 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14966
14967 ---------------------------------------------------------------------------------------------------------------
14968
14969
14970 --
14971 -- bulk performance
14972 --
14973 l_balance_type_code VARCHAR2(1);
14974 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14975 l_log_module VARCHAR2(240);
14976
14977 --
14978 -- Upgrade strategy
14979 --
14980 l_actual_upg_option VARCHAR2(1);
14981 l_enc_upg_option VARCHAR2(1);
14982
14983 --
14984 BEGIN
14985 --
14986 IF g_log_enabled THEN
14987 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_53';
14988 END IF;
14989 --
14990 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14991
14992 trace
14993 (p_msg => 'BEGIN of AcctLineType_53'
14994 ,p_level => C_LEVEL_PROCEDURE
14995 ,p_module => l_log_module);
14996
14997 END IF;
14998 --
14999 l_component_type := 'AMB_JLT';
15000 l_component_code := 'CLEARING';
15001 l_component_type_code := 'S';
15002 l_component_appl_id := 707;
15003 l_amb_context_code := 'DEFAULT';
15004 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
15005 l_event_class_code := 'PURCHASE_ORDER';
15006 l_event_type_code := 'PO_DEL_ADJ';
15007 l_line_definition_owner_code := 'S';
15008 l_line_definition_code := 'PI_PO_DEL_ADJ';
15009 --
15010 l_balance_type_code := 'A';
15011 l_segment := NULL;
15012 l_ccid := NULL;
15013 l_adr_transaction_coa_id := NULL;
15014 l_adr_accounting_coa_id := NULL;
15015 l_adr_flexfield_segment_code := NULL;
15016 l_adr_flex_value_set_id := NULL;
15017 l_adr_value_type_code := NULL;
15018 l_adr_value_combination_id := NULL;
15019 l_adr_value_segment_code := NULL;
15020
15021 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15022 l_bflow_class_code := ''; -- 4219869 Business Flow
15023 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15024 l_budgetary_control_flag := 'N';
15025
15026 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15027 l_bflow_applied_to_amt := NULL; -- 5132302
15028 l_entered_amt_idx := NULL; -- 4262811
15029 l_accted_amt_idx := NULL; -- 4262811
15030 l_acc_rev_flag := NULL; -- 4262811
15031 l_accrual_line_num := NULL; -- 4262811
15032 l_tmp_amt := NULL; -- 4262811
15033 --
15034
15035 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15036 l_balance_type_code <> 'B' THEN
15037 IF NVL(p_source_97,9E125) = 31
15038 THEN
15039
15040 --
15041 XLA_AE_LINES_PKG.SetNewLine;
15042
15043 p_balance_type_code := l_balance_type_code;
15044 -- set the flag so later we will know whether the gain loss line needs to be created
15045
15046 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15047 p_actual_flag :='A';
15048 END IF;
15049
15050 --
15051 -- bulk performance
15052 --
15053 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15054 p_header_num => 0); -- 4262811
15055 --
15056 -- set accounting line options
15057 --
15058 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15059 p_natural_side_code => 'D'
15060 , p_gain_or_loss_flag => 'N'
15061 , p_gl_transfer_mode_code => 'S'
15062 , p_acct_entry_type_code => 'A'
15063 , p_switch_side_flag => 'Y'
15064 , p_merge_duplicate_code => 'N'
15065 );
15066 --
15067 l_acc_rev_natural_side_code := 'C'; -- 4262811
15068 --
15069 --
15070 -- set accounting line type info
15071 --
15072 xla_ae_lines_pkg.SetAcctLineType
15073 (p_component_type => l_component_type
15074 ,p_event_type_code => l_event_type_code
15075 ,p_line_definition_owner_code => l_line_definition_owner_code
15076 ,p_line_definition_code => l_line_definition_code
15077 ,p_accounting_line_code => l_component_code
15078 ,p_accounting_line_type_code => l_component_type_code
15079 ,p_accounting_line_appl_id => l_component_appl_id
15080 ,p_amb_context_code => l_amb_context_code
15081 ,p_entity_code => l_entity_code
15082 ,p_event_class_code => l_event_class_code);
15083 --
15084 -- set accounting class
15085 --
15086 xla_ae_lines_pkg.SetAcctClass(
15087 p_accounting_class_code => 'CLEARING'
15088 , p_ae_header_id => l_ae_header_id
15089 );
15090
15091 --
15092 -- set rounding class
15093 --
15094 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15095 'CLEARING';
15096
15097 --
15098 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15099 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15100 --
15101 -- bulk performance
15102 --
15103 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15104
15105 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15106 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15107
15108 -- 4955764
15109 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15110 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15111
15112 -- 4458381 Public Sector Enh
15113
15114 --
15115 -- set accounting attributes for the line type
15116 --
15117 l_entered_amt_idx := 17;
15118 l_accted_amt_idx := 22;
15119 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15120 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
15121 l_rec_acct_attrs.array_num_value(1) := p_source_79;
15122 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
15123 l_rec_acct_attrs.array_char_value(2) := p_source_80;
15124 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
15125 l_rec_acct_attrs.array_char_value(3) := p_source_81;
15126 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
15127 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
15128 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
15129 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
15130 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
15131 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
15132 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
15133 l_rec_acct_attrs.array_char_value(7) := p_source_85;
15134 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
15135 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
15136 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
15137 l_rec_acct_attrs.array_num_value(9) := p_source_87;
15138 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
15139 l_rec_acct_attrs.array_char_value(10) := p_source_88;
15140 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
15141 l_rec_acct_attrs.array_num_value(11) := p_source_89;
15142 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
15143 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
15144 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
15145 l_rec_acct_attrs.array_num_value(13) := p_source_87;
15146 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
15147 l_rec_acct_attrs.array_char_value(14) := p_source_88;
15148 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
15149 l_rec_acct_attrs.array_num_value(15) := p_source_89;
15150 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
15151 l_rec_acct_attrs.array_char_value(16) := p_source_100;
15152 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
15153 l_rec_acct_attrs.array_num_value(17) := p_source_91;
15154 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
15155 l_rec_acct_attrs.array_char_value(18) := p_source_88;
15156 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
15157 l_rec_acct_attrs.array_date_value(19) := p_source_92;
15158 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
15159 l_rec_acct_attrs.array_num_value(20) := p_source_93;
15160 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
15161 l_rec_acct_attrs.array_char_value(21) := p_source_94;
15162 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
15163 l_rec_acct_attrs.array_num_value(22) := p_source_95;
15164 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
15165 l_rec_acct_attrs.array_num_value(23) := p_source_96;
15166 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
15167 l_rec_acct_attrs.array_num_value(24) := p_source_96;
15168
15169 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15170 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15171
15172 ---------------------------------------------------------------------------------------------------------------
15173 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15174 ---------------------------------------------------------------------------------------------------------------
15175 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15176
15177 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15178 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15179
15180 IF xla_accounting_cache_pkg.GetValueChar
15181 (p_source_code => 'LEDGER_CATEGORY_CODE'
15182 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15183 AND l_bflow_method_code = 'PRIOR_ENTRY'
15184 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15185 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15186 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15187 )
15188 THEN
15189 xla_ae_lines_pkg.BflowUpgEntry
15190 (p_business_method_code => l_bflow_method_code
15191 ,p_business_class_code => l_bflow_class_code
15192 ,p_balance_type => l_balance_type_code);
15193 ELSE
15194 NULL;
15195 -- No business flow processing for business flow method of NONE.
15196 END IF;
15197
15198 --
15199 -- call analytical criteria
15200 --
15201
15202 --
15203 -- call description
15204 --
15205
15206 xla_ae_lines_pkg.SetLineDescription(
15207 p_ae_header_id => l_ae_header_id
15208 ,p_description => Description_1 (
15209 p_application_id => p_application_id
15210 , p_ae_header_id => l_ae_header_id
15211 , p_source_1 => p_source_1
15212 , p_source_2 => p_source_2
15213 , p_source_3 => p_source_3
15214 , p_source_4 => p_source_4
15215 , p_source_5 => p_source_5
15216 )
15217 );
15218
15219
15220 --
15221 -- call ADRs
15222 -- Bug 4922099
15223 --
15224 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15225 (NVL(l_actual_upg_option, 'N') = 'O') OR
15226 (NVL(l_enc_upg_option, 'N') = 'O')
15227 )
15228 THEN
15229 NULL;
15230 --
15231 --
15232
15233 l_ccid := AcctDerRule_6(
15234 p_application_id => p_application_id
15235 , p_ae_header_id => l_ae_header_id
15236 , p_source_11 => p_source_11
15237 , x_transaction_coa_id => l_adr_transaction_coa_id
15238 , x_accounting_coa_id => l_adr_accounting_coa_id
15239 , x_value_type_code => l_adr_value_type_code
15240 , p_side => 'NA'
15241 );
15242
15243 xla_ae_lines_pkg.set_ccid(
15244 p_code_combination_id => l_ccid
15245 , p_value_type_code => l_adr_value_type_code
15246 , p_transaction_coa_id => l_adr_transaction_coa_id
15247 , p_accounting_coa_id => l_adr_accounting_coa_id
15248 , p_adr_code => 'CST_DEFAULT'
15249 , p_adr_type_code => 'S'
15250 , p_component_type => l_component_type
15251 , p_component_code => l_component_code
15252 , p_component_type_code => l_component_type_code
15253 , p_component_appl_id => l_component_appl_id
15254 , p_amb_context_code => l_amb_context_code
15255 , p_side => 'NA'
15256 );
15257
15258
15259 --
15260 --
15261 END IF;
15262 --
15263 -- Bug 4922099
15264 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15265 (NVL(l_enc_upg_option, 'N') = 'O')
15266 ) AND
15267 (l_bflow_method_code = 'PRIOR_ENTRY')
15268 )
15269 THEN
15270 IF
15271 --
15272 1 = 2
15273 --
15274 THEN
15275 xla_accounting_err_pkg.build_message
15276 (p_appli_s_name => 'XLA'
15277 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15278 ,p_token_1 => 'LINE_NUMBER'
15279 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15280 ,p_token_2 => 'LINE_TYPE_NAME'
15281 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15282 l_component_type
15283 ,l_component_code
15284 ,l_component_type_code
15285 ,l_component_appl_id
15286 ,l_amb_context_code
15287 ,l_entity_code
15288 ,l_event_class_code
15289 )
15290 ,p_token_3 => 'OWNER'
15291 ,p_value_3 => xla_lookups_pkg.get_meaning(
15292 p_lookup_type => 'XLA_OWNER_TYPE'
15293 ,p_lookup_code => l_component_type_code
15294 )
15295 ,p_token_4 => 'PRODUCT_NAME'
15296 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15297 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15298 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15299 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15300 ,p_ae_header_id => NULL
15301 );
15302
15303 IF (C_LEVEL_ERROR>= g_log_level) THEN
15304 trace
15305 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15306 ,p_level => C_LEVEL_ERROR
15307 ,p_module => l_log_module);
15308 END IF;
15309 END IF;
15310 END IF;
15311 --
15312 --
15313 ------------------------------------------------------------------------------------------------
15314 -- 4219869 Business Flow
15315 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15316 -- Prior Entry. Currently, the following code is always generated.
15317 ------------------------------------------------------------------------------------------------
15318 XLA_AE_LINES_PKG.ValidateCurrentLine;
15319
15320 ------------------------------------------------------------------------------------
15321 -- 4219869 Business Flow
15322 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15323 ------------------------------------------------------------------------------------
15324 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15325
15326 ----------------------------------------------------------------------------------
15327 -- 4219869 Business Flow
15328 -- Update journal entry status -- Need to generate this within IF <condition>
15329 ----------------------------------------------------------------------------------
15330 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15331 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15332 ,p_balance_type_code => l_balance_type_code
15333 );
15334
15335 -------------------------------------------------------------------------------------------
15336 -- 4262811 - Generate the Accrual Reversal lines
15337 -------------------------------------------------------------------------------------------
15338 BEGIN
15339 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15340 (g_array_event(p_event_id).array_value_num('header_index'));
15341 IF l_acc_rev_flag IS NULL THEN
15342 l_acc_rev_flag := 'N';
15343 END IF;
15344 EXCEPTION
15345 WHEN OTHERS THEN
15346 l_acc_rev_flag := 'N';
15347 END;
15348 --
15349 IF (l_acc_rev_flag = 'Y') THEN
15350
15351 -- 4645092 ------------------------------------------------------------------------------
15352 -- To allow MPA report to determine if it should generate report process
15353 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15354 ------------------------------------------------------------------------------------------
15355
15356 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15357 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15358 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15359 -- call ADRs
15360 -- Bug 4922099
15361 --
15362 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15363 (NVL(l_actual_upg_option, 'N') = 'O') OR
15364 (NVL(l_enc_upg_option, 'N') = 'O')
15365 )
15366 THEN
15367 NULL;
15368 --
15369 --
15370
15371 l_ccid := AcctDerRule_6(
15372 p_application_id => p_application_id
15373 , p_ae_header_id => l_ae_header_id
15374 , p_source_11 => p_source_11
15375 , x_transaction_coa_id => l_adr_transaction_coa_id
15376 , x_accounting_coa_id => l_adr_accounting_coa_id
15377 , x_value_type_code => l_adr_value_type_code
15378 , p_side => 'NA'
15379 );
15380
15381 xla_ae_lines_pkg.set_ccid(
15382 p_code_combination_id => l_ccid
15383 , p_value_type_code => l_adr_value_type_code
15384 , p_transaction_coa_id => l_adr_transaction_coa_id
15385 , p_accounting_coa_id => l_adr_accounting_coa_id
15386 , p_adr_code => 'CST_DEFAULT'
15387 , p_adr_type_code => 'S'
15388 , p_component_type => l_component_type
15389 , p_component_code => l_component_code
15390 , p_component_type_code => l_component_type_code
15391 , p_component_appl_id => l_component_appl_id
15392 , p_amb_context_code => l_amb_context_code
15393 , p_side => 'NA'
15394 );
15395
15396
15397 --
15398 --
15399 END IF;
15400
15401 --
15402 -- Update the line information that should be overwritten
15403 --
15404 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15405 p_header_num => 1);
15406 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15407
15408 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15409
15410 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15411 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15412 END IF;
15413
15414 --
15415 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15416 --
15417 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15418 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15419 ELSE
15420 ---------------------------------------------------------------------------------------------------
15421 -- 4262811a Switch Sign
15422 ---------------------------------------------------------------------------------------------------
15423 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15424 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15425 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15426 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15427 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15428 -- 5132302
15429 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15430 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15431
15432 END IF;
15433
15434 -- 4955764
15435 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15436 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15437
15438
15439 XLA_AE_LINES_PKG.ValidateCurrentLine;
15440 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15441
15442 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15443 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15444 ,p_balance_type_code => l_balance_type_code);
15445
15446 END IF;
15447
15448 -----------------------------------------------------------------------------------------
15449 -- 4262811 Multiperiod Accounting
15450 -----------------------------------------------------------------------------------------
15451 -- No MPA option is assigned.
15452
15453
15454 END IF;
15455 END IF;
15456 --
15457
15458 --
15459 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15460 trace
15461 (p_msg => 'END of AcctLineType_53'
15462 ,p_level => C_LEVEL_PROCEDURE
15463 ,p_module => l_log_module);
15464 END IF;
15465 --
15466 EXCEPTION
15467 WHEN xla_exceptions_pkg.application_exception THEN
15468 RAISE;
15469 WHEN OTHERS THEN
15470 xla_exceptions_pkg.raise_message
15471 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_53');
15472 END AcctLineType_53;
15473 --
15474
15475 ---------------------------------------
15476 --
15477 -- PRIVATE FUNCTION
15478 -- AcctLineType_54
15479 --
15480 ---------------------------------------
15481 PROCEDURE AcctLineType_54 (
15482 p_application_id IN NUMBER
15483 ,p_event_id IN NUMBER
15484 ,p_calculate_acctd_flag IN VARCHAR2
15485 ,p_calculate_g_l_flag IN VARCHAR2
15486 ,p_actual_flag IN OUT VARCHAR2
15487 ,p_balance_type_code OUT VARCHAR2
15488 ,p_gain_or_loss_ref OUT VARCHAR2
15489
15490 --Cost Management Default Account
15491 , p_source_11 IN NUMBER
15492 --Receiving Accounting Line Type
15493 , p_source_78 IN VARCHAR2
15494 --DISTRIBUTION_IDENTIFIER
15495 , p_source_84 IN NUMBER
15496 --Distribution Type
15497 , p_source_85 IN VARCHAR2
15498 , p_source_85_meaning IN VARCHAR2
15499 --Entered Currency Code
15500 , p_source_88 IN VARCHAR2
15501 --Entered Amount
15502 , p_source_91 IN NUMBER
15503 --Currency Conversion Date
15504 , p_source_92 IN DATE
15505 --Currency Conversion Rate
15506 , p_source_93 IN NUMBER
15507 --Currency Conversion Type
15508 , p_source_94 IN VARCHAR2
15509 --Accounted Amount
15510 , p_source_95 IN NUMBER
15511 )
15512 IS
15513
15514 l_component_type VARCHAR2(80);
15515 l_component_code VARCHAR2(30);
15516 l_component_type_code VARCHAR2(1);
15517 l_component_appl_id INTEGER;
15518 l_amb_context_code VARCHAR2(30);
15519 l_entity_code VARCHAR2(30);
15520 l_event_class_code VARCHAR2(30);
15521 l_ae_header_id NUMBER;
15522 l_event_type_code VARCHAR2(30);
15523 l_line_definition_code VARCHAR2(30);
15524 l_line_definition_owner_code VARCHAR2(1);
15525 --
15526 -- adr variables
15527 l_segment VARCHAR2(30);
15528 l_ccid NUMBER;
15529 l_adr_transaction_coa_id NUMBER;
15530 l_adr_accounting_coa_id NUMBER;
15531 l_adr_flexfield_segment_code VARCHAR2(30);
15532 l_adr_flex_value_set_id NUMBER;
15533 l_adr_value_type_code VARCHAR2(30);
15534 l_adr_value_combination_id NUMBER;
15535 l_adr_value_segment_code VARCHAR2(30);
15536
15537 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15538 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15539 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15540 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15541
15542 -- 4262811 Variables ------------------------------------------------------------------------------------------
15543 l_entered_amt_idx NUMBER;
15544 l_accted_amt_idx NUMBER;
15545 l_acc_rev_flag VARCHAR2(1);
15546 l_accrual_line_num NUMBER;
15547 l_tmp_amt NUMBER;
15548 l_acc_rev_natural_side_code VARCHAR2(1);
15549
15550 l_num_entries NUMBER;
15551 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15552 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15553 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15554 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15555 l_recog_line_1 NUMBER;
15556 l_recog_line_2 NUMBER;
15557
15558 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15559 l_bflow_applied_to_amt NUMBER; -- 5132302
15560 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15561
15562 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15563
15564 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15565 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15566
15567 ---------------------------------------------------------------------------------------------------------------
15568
15569
15570 --
15571 -- bulk performance
15572 --
15573 l_balance_type_code VARCHAR2(1);
15574 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15575 l_log_module VARCHAR2(240);
15576
15577 --
15578 -- Upgrade strategy
15579 --
15580 l_actual_upg_option VARCHAR2(1);
15581 l_enc_upg_option VARCHAR2(1);
15582
15583 --
15584 BEGIN
15585 --
15586 IF g_log_enabled THEN
15587 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_54';
15588 END IF;
15589 --
15590 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15591
15592 trace
15593 (p_msg => 'BEGIN of AcctLineType_54'
15594 ,p_level => C_LEVEL_PROCEDURE
15595 ,p_module => l_log_module);
15596
15597 END IF;
15598 --
15599 l_component_type := 'AMB_JLT';
15600 l_component_code := 'CLEARING';
15601 l_component_type_code := 'S';
15602 l_component_appl_id := 707;
15603 l_amb_context_code := 'DEFAULT';
15604 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
15605 l_event_class_code := 'RCPT_REC_INSP';
15606 l_event_type_code := 'RCPT_REC_INSP_ALL';
15607 l_line_definition_owner_code := 'S';
15608 l_line_definition_code := 'RCPT_REC_INSP';
15609 --
15610 l_balance_type_code := 'A';
15611 l_segment := NULL;
15612 l_ccid := NULL;
15613 l_adr_transaction_coa_id := NULL;
15614 l_adr_accounting_coa_id := NULL;
15615 l_adr_flexfield_segment_code := NULL;
15616 l_adr_flex_value_set_id := NULL;
15617 l_adr_value_type_code := NULL;
15618 l_adr_value_combination_id := NULL;
15619 l_adr_value_segment_code := NULL;
15620
15621 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15622 l_bflow_class_code := ''; -- 4219869 Business Flow
15623 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15624 l_budgetary_control_flag := 'N';
15625
15626 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15627 l_bflow_applied_to_amt := NULL; -- 5132302
15628 l_entered_amt_idx := NULL; -- 4262811
15629 l_accted_amt_idx := NULL; -- 4262811
15630 l_acc_rev_flag := NULL; -- 4262811
15631 l_accrual_line_num := NULL; -- 4262811
15632 l_tmp_amt := NULL; -- 4262811
15633 --
15634
15635 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15636 l_balance_type_code <> 'B' THEN
15637 IF NVL(p_source_78,'
15638 ') = 'Clearing'
15639 THEN
15640
15641 --
15642 XLA_AE_LINES_PKG.SetNewLine;
15643
15644 p_balance_type_code := l_balance_type_code;
15645 -- set the flag so later we will know whether the gain loss line needs to be created
15646
15647 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15648 p_actual_flag :='A';
15649 END IF;
15650
15651 --
15652 -- bulk performance
15653 --
15654 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15655 p_header_num => 0); -- 4262811
15656 --
15657 -- set accounting line options
15658 --
15659 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15660 p_natural_side_code => 'D'
15661 , p_gain_or_loss_flag => 'N'
15662 , p_gl_transfer_mode_code => 'S'
15663 , p_acct_entry_type_code => 'A'
15664 , p_switch_side_flag => 'Y'
15665 , p_merge_duplicate_code => 'N'
15666 );
15667 --
15668 l_acc_rev_natural_side_code := 'C'; -- 4262811
15669 --
15670 --
15671 -- set accounting line type info
15672 --
15673 xla_ae_lines_pkg.SetAcctLineType
15674 (p_component_type => l_component_type
15675 ,p_event_type_code => l_event_type_code
15676 ,p_line_definition_owner_code => l_line_definition_owner_code
15677 ,p_line_definition_code => l_line_definition_code
15678 ,p_accounting_line_code => l_component_code
15679 ,p_accounting_line_type_code => l_component_type_code
15680 ,p_accounting_line_appl_id => l_component_appl_id
15681 ,p_amb_context_code => l_amb_context_code
15682 ,p_entity_code => l_entity_code
15683 ,p_event_class_code => l_event_class_code);
15684 --
15685 -- set accounting class
15686 --
15687 xla_ae_lines_pkg.SetAcctClass(
15688 p_accounting_class_code => 'CLEARING'
15689 , p_ae_header_id => l_ae_header_id
15690 );
15691
15692 --
15693 -- set rounding class
15694 --
15695 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15696 'CLEARING';
15697
15698 --
15699 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15700 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15701 --
15702 -- bulk performance
15703 --
15704 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15705
15706 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15707 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15708
15709 -- 4955764
15710 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15711 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15712
15713 -- 4458381 Public Sector Enh
15714
15715 --
15716 -- set accounting attributes for the line type
15717 --
15718 l_entered_amt_idx := 3;
15719 l_accted_amt_idx := 8;
15720 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15721 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15722 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
15723 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15724 l_rec_acct_attrs.array_char_value(2) := p_source_85;
15725 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15726 l_rec_acct_attrs.array_num_value(3) := p_source_91;
15727 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15728 l_rec_acct_attrs.array_char_value(4) := p_source_88;
15729 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15730 l_rec_acct_attrs.array_date_value(5) := p_source_92;
15731 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15732 l_rec_acct_attrs.array_num_value(6) := p_source_93;
15733 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15734 l_rec_acct_attrs.array_char_value(7) := p_source_94;
15735 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
15736 l_rec_acct_attrs.array_num_value(8) := p_source_95;
15737
15738 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15739 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15740
15741 ---------------------------------------------------------------------------------------------------------------
15742 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15743 ---------------------------------------------------------------------------------------------------------------
15744 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15745
15746 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15747 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15748
15749 IF xla_accounting_cache_pkg.GetValueChar
15750 (p_source_code => 'LEDGER_CATEGORY_CODE'
15751 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15752 AND l_bflow_method_code = 'PRIOR_ENTRY'
15753 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15754 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15755 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15756 )
15757 THEN
15758 xla_ae_lines_pkg.BflowUpgEntry
15759 (p_business_method_code => l_bflow_method_code
15760 ,p_business_class_code => l_bflow_class_code
15761 ,p_balance_type => l_balance_type_code);
15762 ELSE
15763 NULL;
15764 -- No business flow processing for business flow method of NONE.
15765 END IF;
15766
15767 --
15768 -- call analytical criteria
15769 --
15770
15771 --
15772 -- call description
15773 --
15774 -- No description or it is inherited.
15775 --
15776 -- call ADRs
15777 -- Bug 4922099
15778 --
15779 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15780 (NVL(l_actual_upg_option, 'N') = 'O') OR
15781 (NVL(l_enc_upg_option, 'N') = 'O')
15782 )
15783 THEN
15784 NULL;
15785 --
15786 --
15787
15788 l_ccid := AcctDerRule_6(
15789 p_application_id => p_application_id
15790 , p_ae_header_id => l_ae_header_id
15791 , p_source_11 => p_source_11
15792 , x_transaction_coa_id => l_adr_transaction_coa_id
15793 , x_accounting_coa_id => l_adr_accounting_coa_id
15794 , x_value_type_code => l_adr_value_type_code
15795 , p_side => 'NA'
15796 );
15797
15798 xla_ae_lines_pkg.set_ccid(
15799 p_code_combination_id => l_ccid
15800 , p_value_type_code => l_adr_value_type_code
15801 , p_transaction_coa_id => l_adr_transaction_coa_id
15802 , p_accounting_coa_id => l_adr_accounting_coa_id
15803 , p_adr_code => 'CST_DEFAULT'
15804 , p_adr_type_code => 'S'
15805 , p_component_type => l_component_type
15806 , p_component_code => l_component_code
15807 , p_component_type_code => l_component_type_code
15808 , p_component_appl_id => l_component_appl_id
15809 , p_amb_context_code => l_amb_context_code
15810 , p_side => 'NA'
15811 );
15812
15813
15814 --
15815 --
15816 END IF;
15817 --
15818 -- Bug 4922099
15819 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15820 (NVL(l_enc_upg_option, 'N') = 'O')
15821 ) AND
15822 (l_bflow_method_code = 'PRIOR_ENTRY')
15823 )
15824 THEN
15825 IF
15826 --
15827 1 = 2
15828 --
15829 THEN
15830 xla_accounting_err_pkg.build_message
15831 (p_appli_s_name => 'XLA'
15832 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15833 ,p_token_1 => 'LINE_NUMBER'
15834 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15835 ,p_token_2 => 'LINE_TYPE_NAME'
15836 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15837 l_component_type
15838 ,l_component_code
15839 ,l_component_type_code
15840 ,l_component_appl_id
15841 ,l_amb_context_code
15842 ,l_entity_code
15843 ,l_event_class_code
15844 )
15845 ,p_token_3 => 'OWNER'
15846 ,p_value_3 => xla_lookups_pkg.get_meaning(
15847 p_lookup_type => 'XLA_OWNER_TYPE'
15848 ,p_lookup_code => l_component_type_code
15849 )
15850 ,p_token_4 => 'PRODUCT_NAME'
15851 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15852 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15853 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15854 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15855 ,p_ae_header_id => NULL
15856 );
15857
15858 IF (C_LEVEL_ERROR>= g_log_level) THEN
15859 trace
15860 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15861 ,p_level => C_LEVEL_ERROR
15862 ,p_module => l_log_module);
15863 END IF;
15864 END IF;
15865 END IF;
15866 --
15867 --
15868 ------------------------------------------------------------------------------------------------
15869 -- 4219869 Business Flow
15870 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15871 -- Prior Entry. Currently, the following code is always generated.
15872 ------------------------------------------------------------------------------------------------
15873 XLA_AE_LINES_PKG.ValidateCurrentLine;
15874
15875 ------------------------------------------------------------------------------------
15876 -- 4219869 Business Flow
15877 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15878 ------------------------------------------------------------------------------------
15879 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15880
15881 ----------------------------------------------------------------------------------
15882 -- 4219869 Business Flow
15883 -- Update journal entry status -- Need to generate this within IF <condition>
15884 ----------------------------------------------------------------------------------
15885 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15886 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15887 ,p_balance_type_code => l_balance_type_code
15888 );
15889
15890 -------------------------------------------------------------------------------------------
15891 -- 4262811 - Generate the Accrual Reversal lines
15892 -------------------------------------------------------------------------------------------
15893 BEGIN
15894 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15895 (g_array_event(p_event_id).array_value_num('header_index'));
15896 IF l_acc_rev_flag IS NULL THEN
15897 l_acc_rev_flag := 'N';
15898 END IF;
15899 EXCEPTION
15900 WHEN OTHERS THEN
15901 l_acc_rev_flag := 'N';
15902 END;
15903 --
15904 IF (l_acc_rev_flag = 'Y') THEN
15905
15906 -- 4645092 ------------------------------------------------------------------------------
15907 -- To allow MPA report to determine if it should generate report process
15908 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15909 ------------------------------------------------------------------------------------------
15910
15911 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15912 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15913 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15914 -- call ADRs
15915 -- Bug 4922099
15916 --
15917 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15918 (NVL(l_actual_upg_option, 'N') = 'O') OR
15919 (NVL(l_enc_upg_option, 'N') = 'O')
15920 )
15921 THEN
15922 NULL;
15923 --
15924 --
15925
15926 l_ccid := AcctDerRule_6(
15927 p_application_id => p_application_id
15928 , p_ae_header_id => l_ae_header_id
15929 , p_source_11 => p_source_11
15930 , x_transaction_coa_id => l_adr_transaction_coa_id
15931 , x_accounting_coa_id => l_adr_accounting_coa_id
15932 , x_value_type_code => l_adr_value_type_code
15933 , p_side => 'NA'
15934 );
15935
15936 xla_ae_lines_pkg.set_ccid(
15937 p_code_combination_id => l_ccid
15938 , p_value_type_code => l_adr_value_type_code
15939 , p_transaction_coa_id => l_adr_transaction_coa_id
15940 , p_accounting_coa_id => l_adr_accounting_coa_id
15941 , p_adr_code => 'CST_DEFAULT'
15942 , p_adr_type_code => 'S'
15943 , p_component_type => l_component_type
15944 , p_component_code => l_component_code
15945 , p_component_type_code => l_component_type_code
15946 , p_component_appl_id => l_component_appl_id
15947 , p_amb_context_code => l_amb_context_code
15948 , p_side => 'NA'
15949 );
15950
15951
15952 --
15953 --
15954 END IF;
15955
15956 --
15957 -- Update the line information that should be overwritten
15958 --
15959 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15960 p_header_num => 1);
15961 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15962
15963 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15964
15965 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15966 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15967 END IF;
15968
15969 --
15970 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15971 --
15972 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15973 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15974 ELSE
15975 ---------------------------------------------------------------------------------------------------
15976 -- 4262811a Switch Sign
15977 ---------------------------------------------------------------------------------------------------
15978 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15979 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15981 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15982 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15983 -- 5132302
15984 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15985 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15986
15987 END IF;
15988
15989 -- 4955764
15990 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15991 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15992
15993
15994 XLA_AE_LINES_PKG.ValidateCurrentLine;
15995 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15996
15997 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15998 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15999 ,p_balance_type_code => l_balance_type_code);
16000
16001 END IF;
16002
16003 -----------------------------------------------------------------------------------------
16004 -- 4262811 Multiperiod Accounting
16005 -----------------------------------------------------------------------------------------
16006 -- No MPA option is assigned.
16007
16008
16009 END IF;
16010 END IF;
16011 --
16012
16013 --
16014 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16015 trace
16016 (p_msg => 'END of AcctLineType_54'
16017 ,p_level => C_LEVEL_PROCEDURE
16018 ,p_module => l_log_module);
16019 END IF;
16020 --
16021 EXCEPTION
16022 WHEN xla_exceptions_pkg.application_exception THEN
16023 RAISE;
16024 WHEN OTHERS THEN
16025 xla_exceptions_pkg.raise_message
16026 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_54');
16027 END AcctLineType_54;
16028 --
16029
16030 ---------------------------------------
16031 --
16032 -- PRIVATE FUNCTION
16033 -- AcctLineType_55
16034 --
16035 ---------------------------------------
16036 PROCEDURE AcctLineType_55 (
16037 p_application_id IN NUMBER
16038 ,p_event_id IN NUMBER
16039 ,p_calculate_acctd_flag IN VARCHAR2
16040 ,p_calculate_g_l_flag IN VARCHAR2
16041 ,p_actual_flag IN OUT VARCHAR2
16042 ,p_balance_type_code OUT VARCHAR2
16043 ,p_gain_or_loss_ref OUT VARCHAR2
16044
16045 --Cost Management Default Account
16046 , p_source_11 IN NUMBER
16047 --DISTRIBUTION_IDENTIFIER
16048 , p_source_84 IN NUMBER
16049 --Distribution Type
16050 , p_source_85 IN VARCHAR2
16051 , p_source_85_meaning IN VARCHAR2
16052 --Entered Currency Code
16053 , p_source_88 IN VARCHAR2
16054 --Entered Amount
16055 , p_source_91 IN NUMBER
16056 --Currency Conversion Date
16057 , p_source_92 IN DATE
16058 --Currency Conversion Rate
16059 , p_source_93 IN NUMBER
16060 --Currency Conversion Type
16061 , p_source_94 IN VARCHAR2
16062 --Accounted Amount
16063 , p_source_95 IN NUMBER
16064 --Accounting Line Type
16065 , p_source_97 IN NUMBER
16066 )
16067 IS
16068
16069 l_component_type VARCHAR2(80);
16070 l_component_code VARCHAR2(30);
16071 l_component_type_code VARCHAR2(1);
16072 l_component_appl_id INTEGER;
16073 l_amb_context_code VARCHAR2(30);
16074 l_entity_code VARCHAR2(30);
16075 l_event_class_code VARCHAR2(30);
16076 l_ae_header_id NUMBER;
16077 l_event_type_code VARCHAR2(30);
16078 l_line_definition_code VARCHAR2(30);
16079 l_line_definition_owner_code VARCHAR2(1);
16080 --
16081 -- adr variables
16082 l_segment VARCHAR2(30);
16083 l_ccid NUMBER;
16084 l_adr_transaction_coa_id NUMBER;
16085 l_adr_accounting_coa_id NUMBER;
16086 l_adr_flexfield_segment_code VARCHAR2(30);
16087 l_adr_flex_value_set_id NUMBER;
16088 l_adr_value_type_code VARCHAR2(30);
16089 l_adr_value_combination_id NUMBER;
16090 l_adr_value_segment_code VARCHAR2(30);
16091
16092 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16093 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16094 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16095 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16096
16097 -- 4262811 Variables ------------------------------------------------------------------------------------------
16098 l_entered_amt_idx NUMBER;
16099 l_accted_amt_idx NUMBER;
16100 l_acc_rev_flag VARCHAR2(1);
16101 l_accrual_line_num NUMBER;
16102 l_tmp_amt NUMBER;
16103 l_acc_rev_natural_side_code VARCHAR2(1);
16104
16105 l_num_entries NUMBER;
16106 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16107 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16108 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16109 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16110 l_recog_line_1 NUMBER;
16111 l_recog_line_2 NUMBER;
16112
16113 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16114 l_bflow_applied_to_amt NUMBER; -- 5132302
16115 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16116
16117 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16118
16119 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16120 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16121
16122 ---------------------------------------------------------------------------------------------------------------
16123
16124
16125 --
16126 -- bulk performance
16127 --
16128 l_balance_type_code VARCHAR2(1);
16129 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16130 l_log_module VARCHAR2(240);
16131
16132 --
16133 -- Upgrade strategy
16134 --
16135 l_actual_upg_option VARCHAR2(1);
16136 l_enc_upg_option VARCHAR2(1);
16137
16138 --
16139 BEGIN
16140 --
16141 IF g_log_enabled THEN
16142 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_55';
16143 END IF;
16144 --
16145 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16146
16147 trace
16148 (p_msg => 'BEGIN of AcctLineType_55'
16149 ,p_level => C_LEVEL_PROCEDURE
16150 ,p_module => l_log_module);
16151
16152 END IF;
16153 --
16154 l_component_type := 'AMB_JLT';
16155 l_component_code := 'COST_OF_GOODS_SOLD';
16156 l_component_type_code := 'S';
16157 l_component_appl_id := 707;
16158 l_amb_context_code := 'DEFAULT';
16159 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
16160 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
16161 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
16162 l_line_definition_owner_code := 'S';
16163 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
16164 --
16165 l_balance_type_code := 'A';
16166 l_segment := NULL;
16167 l_ccid := NULL;
16168 l_adr_transaction_coa_id := NULL;
16169 l_adr_accounting_coa_id := NULL;
16170 l_adr_flexfield_segment_code := NULL;
16171 l_adr_flex_value_set_id := NULL;
16172 l_adr_value_type_code := NULL;
16173 l_adr_value_combination_id := NULL;
16174 l_adr_value_segment_code := NULL;
16175
16176 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16177 l_bflow_class_code := ''; -- 4219869 Business Flow
16178 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16179 l_budgetary_control_flag := 'N';
16180
16181 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16182 l_bflow_applied_to_amt := NULL; -- 5132302
16183 l_entered_amt_idx := NULL; -- 4262811
16184 l_accted_amt_idx := NULL; -- 4262811
16185 l_acc_rev_flag := NULL; -- 4262811
16186 l_accrual_line_num := NULL; -- 4262811
16187 l_tmp_amt := NULL; -- 4262811
16188 --
16189
16190 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16191 l_balance_type_code <> 'B' THEN
16192 IF NVL(p_source_97,9E125) = 2 AND
16193 p_source_95 > 0
16194 THEN
16195
16196 --
16197 XLA_AE_LINES_PKG.SetNewLine;
16198
16199 p_balance_type_code := l_balance_type_code;
16200 -- set the flag so later we will know whether the gain loss line needs to be created
16201
16202 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16203 p_actual_flag :='A';
16204 END IF;
16205
16206 --
16207 -- bulk performance
16208 --
16209 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16210 p_header_num => 0); -- 4262811
16211 --
16212 -- set accounting line options
16213 --
16214 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16215 p_natural_side_code => 'D'
16216 , p_gain_or_loss_flag => 'N'
16217 , p_gl_transfer_mode_code => 'S'
16218 , p_acct_entry_type_code => 'A'
16219 , p_switch_side_flag => 'Y'
16220 , p_merge_duplicate_code => 'N'
16221 );
16222 --
16223 l_acc_rev_natural_side_code := 'C'; -- 4262811
16224 --
16225 --
16226 -- set accounting line type info
16227 --
16228 xla_ae_lines_pkg.SetAcctLineType
16229 (p_component_type => l_component_type
16230 ,p_event_type_code => l_event_type_code
16231 ,p_line_definition_owner_code => l_line_definition_owner_code
16232 ,p_line_definition_code => l_line_definition_code
16233 ,p_accounting_line_code => l_component_code
16234 ,p_accounting_line_type_code => l_component_type_code
16235 ,p_accounting_line_appl_id => l_component_appl_id
16236 ,p_amb_context_code => l_amb_context_code
16237 ,p_entity_code => l_entity_code
16238 ,p_event_class_code => l_event_class_code);
16239 --
16240 -- set accounting class
16241 --
16242 xla_ae_lines_pkg.SetAcctClass(
16243 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
16244 , p_ae_header_id => l_ae_header_id
16245 );
16246
16247 --
16248 -- set rounding class
16249 --
16250 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16251 'COST_OF_GOODS_SOLD';
16252
16253 --
16254 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16255 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16256 --
16257 -- bulk performance
16258 --
16259 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16260
16261 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16262 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16263
16264 -- 4955764
16265 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16266 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16267
16268 -- 4458381 Public Sector Enh
16269
16270 --
16271 -- set accounting attributes for the line type
16272 --
16273 l_entered_amt_idx := 3;
16274 l_accted_amt_idx := 8;
16275 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16276 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16277 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
16278 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16279 l_rec_acct_attrs.array_char_value(2) := p_source_85;
16280 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16281 l_rec_acct_attrs.array_num_value(3) := p_source_91;
16282 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16283 l_rec_acct_attrs.array_char_value(4) := p_source_88;
16284 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16285 l_rec_acct_attrs.array_date_value(5) := p_source_92;
16286 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16287 l_rec_acct_attrs.array_num_value(6) := p_source_93;
16288 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16289 l_rec_acct_attrs.array_char_value(7) := p_source_94;
16290 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16291 l_rec_acct_attrs.array_num_value(8) := p_source_95;
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_6(
16344 p_application_id => p_application_id
16345 , p_ae_header_id => l_ae_header_id
16346 , p_source_11 => p_source_11
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 => 'CST_DEFAULT'
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_6(
16482 p_application_id => p_application_id
16483 , p_ae_header_id => l_ae_header_id
16484 , p_source_11 => p_source_11
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 => 'CST_DEFAULT'
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_55'
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_00707_AAD_S_000020_PKG.AcctLineType_55');
16582 END AcctLineType_55;
16583 --
16584
16585 ---------------------------------------
16586 --
16587 -- PRIVATE FUNCTION
16588 -- AcctLineType_56
16589 --
16590 ---------------------------------------
16591 PROCEDURE AcctLineType_56 (
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 --TRANSACTION_ID
16601 , p_source_1 IN NUMBER
16602 --Item Concatenated Segments
16603 , p_source_2 IN VARCHAR2
16604 --Transaction Quantity
16605 , p_source_3 IN NUMBER
16606 --Transaction Unit of Measure Code
16607 , p_source_4 IN VARCHAR2
16608 --Inventory Transaction Type Description
16609 , p_source_5 IN VARCHAR2
16610 --Cost Management Default Account
16611 , p_source_11 IN NUMBER
16612 --DISTRIBUTION_IDENTIFIER
16613 , p_source_84 IN NUMBER
16614 --Distribution Type
16615 , p_source_85 IN VARCHAR2
16616 , p_source_85_meaning IN VARCHAR2
16617 --Entered Currency Code
16618 , p_source_88 IN VARCHAR2
16619 --Entered Amount
16620 , p_source_91 IN NUMBER
16621 --Currency Conversion Date
16622 , p_source_92 IN DATE
16623 --Currency Conversion Rate
16624 , p_source_93 IN NUMBER
16625 --Currency Conversion Type
16626 , p_source_94 IN VARCHAR2
16627 --Accounted Amount
16628 , p_source_95 IN NUMBER
16629 --Accounting Line Type
16630 , p_source_97 IN NUMBER
16631 )
16632 IS
16633
16634 l_component_type VARCHAR2(80);
16635 l_component_code VARCHAR2(30);
16636 l_component_type_code VARCHAR2(1);
16637 l_component_appl_id INTEGER;
16638 l_amb_context_code VARCHAR2(30);
16639 l_entity_code VARCHAR2(30);
16640 l_event_class_code VARCHAR2(30);
16641 l_ae_header_id NUMBER;
16642 l_event_type_code VARCHAR2(30);
16643 l_line_definition_code VARCHAR2(30);
16644 l_line_definition_owner_code VARCHAR2(1);
16645 --
16646 -- adr variables
16647 l_segment VARCHAR2(30);
16648 l_ccid NUMBER;
16649 l_adr_transaction_coa_id NUMBER;
16650 l_adr_accounting_coa_id NUMBER;
16651 l_adr_flexfield_segment_code VARCHAR2(30);
16652 l_adr_flex_value_set_id NUMBER;
16653 l_adr_value_type_code VARCHAR2(30);
16654 l_adr_value_combination_id NUMBER;
16655 l_adr_value_segment_code VARCHAR2(30);
16656
16657 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16658 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16659 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16660 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16661
16662 -- 4262811 Variables ------------------------------------------------------------------------------------------
16663 l_entered_amt_idx NUMBER;
16664 l_accted_amt_idx NUMBER;
16665 l_acc_rev_flag VARCHAR2(1);
16666 l_accrual_line_num NUMBER;
16667 l_tmp_amt NUMBER;
16668 l_acc_rev_natural_side_code VARCHAR2(1);
16669
16670 l_num_entries NUMBER;
16671 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16672 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16673 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16674 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16675 l_recog_line_1 NUMBER;
16676 l_recog_line_2 NUMBER;
16677
16678 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16679 l_bflow_applied_to_amt NUMBER; -- 5132302
16680 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16681
16682 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16683
16684 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16685 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16686
16687 ---------------------------------------------------------------------------------------------------------------
16688
16689
16690 --
16691 -- bulk performance
16692 --
16693 l_balance_type_code VARCHAR2(1);
16694 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16695 l_log_module VARCHAR2(240);
16696
16697 --
16698 -- Upgrade strategy
16699 --
16700 l_actual_upg_option VARCHAR2(1);
16701 l_enc_upg_option VARCHAR2(1);
16702
16703 --
16704 BEGIN
16705 --
16706 IF g_log_enabled THEN
16707 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_56';
16708 END IF;
16709 --
16710 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16711
16712 trace
16713 (p_msg => 'BEGIN of AcctLineType_56'
16714 ,p_level => C_LEVEL_PROCEDURE
16715 ,p_module => l_log_module);
16716
16717 END IF;
16718 --
16719 l_component_type := 'AMB_JLT';
16720 l_component_code := 'COST_OF_GOODS_SOLD';
16721 l_component_type_code := 'S';
16722 l_component_appl_id := 707;
16723 l_amb_context_code := 'DEFAULT';
16724 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
16725 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
16726 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
16727 l_line_definition_owner_code := 'S';
16728 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
16729 --
16730 l_balance_type_code := 'A';
16731 l_segment := NULL;
16732 l_ccid := NULL;
16733 l_adr_transaction_coa_id := NULL;
16734 l_adr_accounting_coa_id := NULL;
16735 l_adr_flexfield_segment_code := NULL;
16736 l_adr_flex_value_set_id := NULL;
16737 l_adr_value_type_code := NULL;
16738 l_adr_value_combination_id := NULL;
16739 l_adr_value_segment_code := NULL;
16740
16741 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16742 l_bflow_class_code := ''; -- 4219869 Business Flow
16743 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16744 l_budgetary_control_flag := 'N';
16745
16746 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16747 l_bflow_applied_to_amt := NULL; -- 5132302
16748 l_entered_amt_idx := NULL; -- 4262811
16749 l_accted_amt_idx := NULL; -- 4262811
16750 l_acc_rev_flag := NULL; -- 4262811
16751 l_accrual_line_num := NULL; -- 4262811
16752 l_tmp_amt := NULL; -- 4262811
16753 --
16754
16755 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16756 l_balance_type_code <> 'B' THEN
16757 IF NVL(p_source_97,9E125) = 2 AND
16758 p_source_95 > 0
16759 THEN
16760
16761 --
16762 XLA_AE_LINES_PKG.SetNewLine;
16763
16764 p_balance_type_code := l_balance_type_code;
16765 -- set the flag so later we will know whether the gain loss line needs to be created
16766
16767 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16768 p_actual_flag :='A';
16769 END IF;
16770
16771 --
16772 -- bulk performance
16773 --
16774 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16775 p_header_num => 0); -- 4262811
16776 --
16777 -- set accounting line options
16778 --
16779 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16780 p_natural_side_code => 'D'
16781 , p_gain_or_loss_flag => 'N'
16782 , p_gl_transfer_mode_code => 'S'
16783 , p_acct_entry_type_code => 'A'
16784 , p_switch_side_flag => 'Y'
16785 , p_merge_duplicate_code => 'N'
16786 );
16787 --
16788 l_acc_rev_natural_side_code := 'C'; -- 4262811
16789 --
16790 --
16791 -- set accounting line type info
16792 --
16793 xla_ae_lines_pkg.SetAcctLineType
16794 (p_component_type => l_component_type
16795 ,p_event_type_code => l_event_type_code
16796 ,p_line_definition_owner_code => l_line_definition_owner_code
16797 ,p_line_definition_code => l_line_definition_code
16798 ,p_accounting_line_code => l_component_code
16799 ,p_accounting_line_type_code => l_component_type_code
16800 ,p_accounting_line_appl_id => l_component_appl_id
16801 ,p_amb_context_code => l_amb_context_code
16802 ,p_entity_code => l_entity_code
16803 ,p_event_class_code => l_event_class_code);
16804 --
16805 -- set accounting class
16806 --
16807 xla_ae_lines_pkg.SetAcctClass(
16808 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
16809 , p_ae_header_id => l_ae_header_id
16810 );
16811
16812 --
16813 -- set rounding class
16814 --
16815 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16816 'COST_OF_GOODS_SOLD';
16817
16818 --
16819 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16820 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16821 --
16822 -- bulk performance
16823 --
16824 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16825
16826 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16827 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16828
16829 -- 4955764
16830 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16831 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16832
16833 -- 4458381 Public Sector Enh
16834
16835 --
16836 -- set accounting attributes for the line type
16837 --
16838 l_entered_amt_idx := 3;
16839 l_accted_amt_idx := 8;
16840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16841 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16842 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
16843 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16844 l_rec_acct_attrs.array_char_value(2) := p_source_85;
16845 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16846 l_rec_acct_attrs.array_num_value(3) := p_source_91;
16847 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16848 l_rec_acct_attrs.array_char_value(4) := p_source_88;
16849 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16850 l_rec_acct_attrs.array_date_value(5) := p_source_92;
16851 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16852 l_rec_acct_attrs.array_num_value(6) := p_source_93;
16853 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16854 l_rec_acct_attrs.array_char_value(7) := p_source_94;
16855 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16856 l_rec_acct_attrs.array_num_value(8) := p_source_95;
16857
16858 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16859 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16860
16861 ---------------------------------------------------------------------------------------------------------------
16862 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16863 ---------------------------------------------------------------------------------------------------------------
16864 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16865
16866 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16867 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16868
16869 IF xla_accounting_cache_pkg.GetValueChar
16870 (p_source_code => 'LEDGER_CATEGORY_CODE'
16871 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16872 AND l_bflow_method_code = 'PRIOR_ENTRY'
16873 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16874 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16875 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16876 )
16877 THEN
16878 xla_ae_lines_pkg.BflowUpgEntry
16879 (p_business_method_code => l_bflow_method_code
16880 ,p_business_class_code => l_bflow_class_code
16881 ,p_balance_type => l_balance_type_code);
16882 ELSE
16883 NULL;
16884 -- No business flow processing for business flow method of NONE.
16885 END IF;
16886
16887 --
16888 -- call analytical criteria
16889 --
16890
16891 --
16892 -- call description
16893 --
16894
16895 xla_ae_lines_pkg.SetLineDescription(
16896 p_ae_header_id => l_ae_header_id
16897 ,p_description => Description_1 (
16898 p_application_id => p_application_id
16899 , p_ae_header_id => l_ae_header_id
16900 , p_source_1 => p_source_1
16901 , p_source_2 => p_source_2
16902 , p_source_3 => p_source_3
16903 , p_source_4 => p_source_4
16904 , p_source_5 => p_source_5
16905 )
16906 );
16907
16908
16909 --
16910 -- call ADRs
16911 -- Bug 4922099
16912 --
16913 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16914 (NVL(l_actual_upg_option, 'N') = 'O') OR
16915 (NVL(l_enc_upg_option, 'N') = 'O')
16916 )
16917 THEN
16918 NULL;
16919 --
16920 --
16921
16922 l_ccid := AcctDerRule_6(
16923 p_application_id => p_application_id
16924 , p_ae_header_id => l_ae_header_id
16925 , p_source_11 => p_source_11
16926 , x_transaction_coa_id => l_adr_transaction_coa_id
16927 , x_accounting_coa_id => l_adr_accounting_coa_id
16928 , x_value_type_code => l_adr_value_type_code
16929 , p_side => 'NA'
16930 );
16931
16932 xla_ae_lines_pkg.set_ccid(
16933 p_code_combination_id => l_ccid
16934 , p_value_type_code => l_adr_value_type_code
16935 , p_transaction_coa_id => l_adr_transaction_coa_id
16936 , p_accounting_coa_id => l_adr_accounting_coa_id
16937 , p_adr_code => 'CST_DEFAULT'
16938 , p_adr_type_code => 'S'
16939 , p_component_type => l_component_type
16940 , p_component_code => l_component_code
16941 , p_component_type_code => l_component_type_code
16942 , p_component_appl_id => l_component_appl_id
16943 , p_amb_context_code => l_amb_context_code
16944 , p_side => 'NA'
16945 );
16946
16947
16948 --
16949 --
16950 END IF;
16951 --
16952 -- Bug 4922099
16953 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16954 (NVL(l_enc_upg_option, 'N') = 'O')
16955 ) AND
16956 (l_bflow_method_code = 'PRIOR_ENTRY')
16957 )
16958 THEN
16959 IF
16960 --
16961 1 = 2
16962 --
16963 THEN
16964 xla_accounting_err_pkg.build_message
16965 (p_appli_s_name => 'XLA'
16966 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16967 ,p_token_1 => 'LINE_NUMBER'
16968 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16969 ,p_token_2 => 'LINE_TYPE_NAME'
16970 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16971 l_component_type
16972 ,l_component_code
16973 ,l_component_type_code
16974 ,l_component_appl_id
16975 ,l_amb_context_code
16976 ,l_entity_code
16977 ,l_event_class_code
16978 )
16979 ,p_token_3 => 'OWNER'
16980 ,p_value_3 => xla_lookups_pkg.get_meaning(
16981 p_lookup_type => 'XLA_OWNER_TYPE'
16982 ,p_lookup_code => l_component_type_code
16983 )
16984 ,p_token_4 => 'PRODUCT_NAME'
16985 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16986 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16987 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16988 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16989 ,p_ae_header_id => NULL
16990 );
16991
16992 IF (C_LEVEL_ERROR>= g_log_level) THEN
16993 trace
16994 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16995 ,p_level => C_LEVEL_ERROR
16996 ,p_module => l_log_module);
16997 END IF;
16998 END IF;
16999 END IF;
17000 --
17001 --
17002 ------------------------------------------------------------------------------------------------
17003 -- 4219869 Business Flow
17004 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17005 -- Prior Entry. Currently, the following code is always generated.
17006 ------------------------------------------------------------------------------------------------
17007 XLA_AE_LINES_PKG.ValidateCurrentLine;
17008
17009 ------------------------------------------------------------------------------------
17010 -- 4219869 Business Flow
17011 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17012 ------------------------------------------------------------------------------------
17013 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17014
17015 ----------------------------------------------------------------------------------
17016 -- 4219869 Business Flow
17017 -- Update journal entry status -- Need to generate this within IF <condition>
17018 ----------------------------------------------------------------------------------
17019 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17020 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17021 ,p_balance_type_code => l_balance_type_code
17022 );
17023
17024 -------------------------------------------------------------------------------------------
17025 -- 4262811 - Generate the Accrual Reversal lines
17026 -------------------------------------------------------------------------------------------
17027 BEGIN
17028 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17029 (g_array_event(p_event_id).array_value_num('header_index'));
17030 IF l_acc_rev_flag IS NULL THEN
17031 l_acc_rev_flag := 'N';
17032 END IF;
17033 EXCEPTION
17034 WHEN OTHERS THEN
17035 l_acc_rev_flag := 'N';
17036 END;
17037 --
17038 IF (l_acc_rev_flag = 'Y') THEN
17039
17040 -- 4645092 ------------------------------------------------------------------------------
17041 -- To allow MPA report to determine if it should generate report process
17042 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17043 ------------------------------------------------------------------------------------------
17044
17045 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17046 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17047 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17048 -- call ADRs
17049 -- Bug 4922099
17050 --
17051 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17052 (NVL(l_actual_upg_option, 'N') = 'O') OR
17053 (NVL(l_enc_upg_option, 'N') = 'O')
17054 )
17055 THEN
17056 NULL;
17057 --
17058 --
17059
17060 l_ccid := AcctDerRule_6(
17061 p_application_id => p_application_id
17062 , p_ae_header_id => l_ae_header_id
17063 , p_source_11 => p_source_11
17064 , x_transaction_coa_id => l_adr_transaction_coa_id
17065 , x_accounting_coa_id => l_adr_accounting_coa_id
17066 , x_value_type_code => l_adr_value_type_code
17067 , p_side => 'NA'
17068 );
17069
17070 xla_ae_lines_pkg.set_ccid(
17071 p_code_combination_id => l_ccid
17072 , p_value_type_code => l_adr_value_type_code
17073 , p_transaction_coa_id => l_adr_transaction_coa_id
17074 , p_accounting_coa_id => l_adr_accounting_coa_id
17075 , p_adr_code => 'CST_DEFAULT'
17076 , p_adr_type_code => 'S'
17077 , p_component_type => l_component_type
17078 , p_component_code => l_component_code
17079 , p_component_type_code => l_component_type_code
17080 , p_component_appl_id => l_component_appl_id
17081 , p_amb_context_code => l_amb_context_code
17082 , p_side => 'NA'
17083 );
17084
17085
17086 --
17087 --
17088 END IF;
17089
17090 --
17091 -- Update the line information that should be overwritten
17092 --
17093 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17094 p_header_num => 1);
17095 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17096
17097 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17098
17099 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17100 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17101 END IF;
17102
17103 --
17104 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17105 --
17106 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17107 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17108 ELSE
17109 ---------------------------------------------------------------------------------------------------
17110 -- 4262811a Switch Sign
17111 ---------------------------------------------------------------------------------------------------
17112 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17113 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17114 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17115 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17116 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17117 -- 5132302
17118 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17119 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17120
17121 END IF;
17122
17123 -- 4955764
17124 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17125 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17126
17127
17128 XLA_AE_LINES_PKG.ValidateCurrentLine;
17129 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17130
17131 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17132 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17133 ,p_balance_type_code => l_balance_type_code);
17134
17135 END IF;
17136
17137 -----------------------------------------------------------------------------------------
17138 -- 4262811 Multiperiod Accounting
17139 -----------------------------------------------------------------------------------------
17140 -- No MPA option is assigned.
17141
17142
17143 END IF;
17144 END IF;
17145 --
17146
17147 --
17148 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17149 trace
17150 (p_msg => 'END of AcctLineType_56'
17151 ,p_level => C_LEVEL_PROCEDURE
17152 ,p_module => l_log_module);
17153 END IF;
17154 --
17155 EXCEPTION
17156 WHEN xla_exceptions_pkg.application_exception THEN
17157 RAISE;
17158 WHEN OTHERS THEN
17159 xla_exceptions_pkg.raise_message
17160 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_56');
17161 END AcctLineType_56;
17162 --
17163
17164 ---------------------------------------
17165 --
17166 -- PRIVATE FUNCTION
17167 -- AcctLineType_57
17168 --
17169 ---------------------------------------
17170 PROCEDURE AcctLineType_57 (
17171 p_application_id IN NUMBER
17172 ,p_event_id IN NUMBER
17173 ,p_calculate_acctd_flag IN VARCHAR2
17174 ,p_calculate_g_l_flag IN VARCHAR2
17175 ,p_actual_flag IN OUT VARCHAR2
17176 ,p_balance_type_code OUT VARCHAR2
17177 ,p_gain_or_loss_ref OUT VARCHAR2
17178
17179 --Cost Management Default Account
17180 , p_source_11 IN NUMBER
17181 --DISTRIBUTION_IDENTIFIER
17182 , p_source_84 IN NUMBER
17183 --Distribution Type
17184 , p_source_85 IN VARCHAR2
17185 , p_source_85_meaning IN VARCHAR2
17186 --Entered Currency Code
17187 , p_source_88 IN VARCHAR2
17188 --Entered Amount
17189 , p_source_91 IN NUMBER
17190 --Currency Conversion Date
17191 , p_source_92 IN DATE
17192 --Currency Conversion Rate
17193 , p_source_93 IN NUMBER
17194 --Currency Conversion Type
17195 , p_source_94 IN VARCHAR2
17196 --Accounted Amount
17197 , p_source_95 IN NUMBER
17198 --Accounting Line Type
17199 , p_source_97 IN NUMBER
17200 )
17201 IS
17202
17203 l_component_type VARCHAR2(80);
17204 l_component_code VARCHAR2(30);
17205 l_component_type_code VARCHAR2(1);
17206 l_component_appl_id INTEGER;
17207 l_amb_context_code VARCHAR2(30);
17208 l_entity_code VARCHAR2(30);
17209 l_event_class_code VARCHAR2(30);
17210 l_ae_header_id NUMBER;
17211 l_event_type_code VARCHAR2(30);
17212 l_line_definition_code VARCHAR2(30);
17213 l_line_definition_owner_code VARCHAR2(1);
17214 --
17215 -- adr variables
17216 l_segment VARCHAR2(30);
17217 l_ccid NUMBER;
17218 l_adr_transaction_coa_id NUMBER;
17219 l_adr_accounting_coa_id NUMBER;
17220 l_adr_flexfield_segment_code VARCHAR2(30);
17221 l_adr_flex_value_set_id NUMBER;
17222 l_adr_value_type_code VARCHAR2(30);
17223 l_adr_value_combination_id NUMBER;
17224 l_adr_value_segment_code VARCHAR2(30);
17225
17226 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17227 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17228 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17229 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17230
17231 -- 4262811 Variables ------------------------------------------------------------------------------------------
17232 l_entered_amt_idx NUMBER;
17233 l_accted_amt_idx NUMBER;
17234 l_acc_rev_flag VARCHAR2(1);
17235 l_accrual_line_num NUMBER;
17236 l_tmp_amt NUMBER;
17237 l_acc_rev_natural_side_code VARCHAR2(1);
17238
17239 l_num_entries NUMBER;
17240 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17241 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17242 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17243 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17244 l_recog_line_1 NUMBER;
17245 l_recog_line_2 NUMBER;
17246
17247 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17248 l_bflow_applied_to_amt NUMBER; -- 5132302
17249 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17250
17251 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17252
17253 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17254 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17255
17256 ---------------------------------------------------------------------------------------------------------------
17257
17258
17259 --
17260 -- bulk performance
17261 --
17262 l_balance_type_code VARCHAR2(1);
17263 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17264 l_log_module VARCHAR2(240);
17265
17266 --
17267 -- Upgrade strategy
17268 --
17269 l_actual_upg_option VARCHAR2(1);
17270 l_enc_upg_option VARCHAR2(1);
17271
17272 --
17273 BEGIN
17274 --
17275 IF g_log_enabled THEN
17276 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_57';
17277 END IF;
17278 --
17279 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17280
17281 trace
17282 (p_msg => 'BEGIN of AcctLineType_57'
17283 ,p_level => C_LEVEL_PROCEDURE
17284 ,p_module => l_log_module);
17285
17286 END IF;
17287 --
17288 l_component_type := 'AMB_JLT';
17289 l_component_code := 'COST_OF_GOODS_SOLD';
17290 l_component_type_code := 'S';
17291 l_component_appl_id := 707;
17292 l_amb_context_code := 'DEFAULT';
17293 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
17294 l_event_class_code := 'SALES_ORDER';
17295 l_event_type_code := 'COGS_RECOGNITION_ADJ';
17296 l_line_definition_owner_code := 'S';
17297 l_line_definition_code := 'PI_COGS_RECOGNITION_ADJ';
17298 --
17299 l_balance_type_code := 'A';
17300 l_segment := NULL;
17301 l_ccid := NULL;
17302 l_adr_transaction_coa_id := NULL;
17303 l_adr_accounting_coa_id := NULL;
17304 l_adr_flexfield_segment_code := NULL;
17305 l_adr_flex_value_set_id := NULL;
17306 l_adr_value_type_code := NULL;
17307 l_adr_value_combination_id := NULL;
17308 l_adr_value_segment_code := NULL;
17309
17310 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17311 l_bflow_class_code := ''; -- 4219869 Business Flow
17312 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17313 l_budgetary_control_flag := 'N';
17314
17315 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17316 l_bflow_applied_to_amt := NULL; -- 5132302
17317 l_entered_amt_idx := NULL; -- 4262811
17318 l_accted_amt_idx := NULL; -- 4262811
17319 l_acc_rev_flag := NULL; -- 4262811
17320 l_accrual_line_num := NULL; -- 4262811
17321 l_tmp_amt := NULL; -- 4262811
17322 --
17323
17324 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17325 l_balance_type_code <> 'B' THEN
17326 IF NVL(p_source_97,9E125) = 35
17327 THEN
17328
17329 --
17330 XLA_AE_LINES_PKG.SetNewLine;
17331
17332 p_balance_type_code := l_balance_type_code;
17333 -- set the flag so later we will know whether the gain loss line needs to be created
17334
17335 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17336 p_actual_flag :='A';
17337 END IF;
17338
17339 --
17340 -- bulk performance
17341 --
17342 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17343 p_header_num => 0); -- 4262811
17344 --
17345 -- set accounting line options
17346 --
17347 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17348 p_natural_side_code => 'D'
17349 , p_gain_or_loss_flag => 'N'
17350 , p_gl_transfer_mode_code => 'S'
17351 , p_acct_entry_type_code => 'A'
17352 , p_switch_side_flag => 'Y'
17353 , p_merge_duplicate_code => 'N'
17354 );
17355 --
17356 l_acc_rev_natural_side_code := 'C'; -- 4262811
17357 --
17358 --
17359 -- set accounting line type info
17360 --
17361 xla_ae_lines_pkg.SetAcctLineType
17362 (p_component_type => l_component_type
17363 ,p_event_type_code => l_event_type_code
17364 ,p_line_definition_owner_code => l_line_definition_owner_code
17365 ,p_line_definition_code => l_line_definition_code
17366 ,p_accounting_line_code => l_component_code
17367 ,p_accounting_line_type_code => l_component_type_code
17368 ,p_accounting_line_appl_id => l_component_appl_id
17369 ,p_amb_context_code => l_amb_context_code
17370 ,p_entity_code => l_entity_code
17371 ,p_event_class_code => l_event_class_code);
17372 --
17373 -- set accounting class
17374 --
17375 xla_ae_lines_pkg.SetAcctClass(
17376 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
17377 , p_ae_header_id => l_ae_header_id
17378 );
17379
17380 --
17381 -- set rounding class
17382 --
17383 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17384 'COST_OF_GOODS_SOLD';
17385
17386 --
17387 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17388 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17389 --
17390 -- bulk performance
17391 --
17392 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17393
17394 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17395 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17396
17397 -- 4955764
17398 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17399 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17400
17401 -- 4458381 Public Sector Enh
17402
17403 --
17404 -- set accounting attributes for the line type
17405 --
17406 l_entered_amt_idx := 3;
17407 l_accted_amt_idx := 8;
17408 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17409 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17410 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
17411 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17412 l_rec_acct_attrs.array_char_value(2) := p_source_85;
17413 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17414 l_rec_acct_attrs.array_num_value(3) := p_source_91;
17415 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17416 l_rec_acct_attrs.array_char_value(4) := p_source_88;
17417 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17418 l_rec_acct_attrs.array_date_value(5) := p_source_92;
17419 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17420 l_rec_acct_attrs.array_num_value(6) := p_source_93;
17421 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17422 l_rec_acct_attrs.array_char_value(7) := p_source_94;
17423 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17424 l_rec_acct_attrs.array_num_value(8) := p_source_95;
17425
17426 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17427 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17428
17429 ---------------------------------------------------------------------------------------------------------------
17430 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17431 ---------------------------------------------------------------------------------------------------------------
17432 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17433
17434 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17435 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17436
17437 IF xla_accounting_cache_pkg.GetValueChar
17438 (p_source_code => 'LEDGER_CATEGORY_CODE'
17439 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17440 AND l_bflow_method_code = 'PRIOR_ENTRY'
17441 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17442 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17443 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17444 )
17445 THEN
17446 xla_ae_lines_pkg.BflowUpgEntry
17447 (p_business_method_code => l_bflow_method_code
17448 ,p_business_class_code => l_bflow_class_code
17449 ,p_balance_type => l_balance_type_code);
17450 ELSE
17451 NULL;
17452 -- No business flow processing for business flow method of NONE.
17453 END IF;
17454
17455 --
17456 -- call analytical criteria
17457 --
17458
17459 --
17460 -- call description
17461 --
17462 -- No description or it is inherited.
17463 --
17464 -- call ADRs
17465 -- Bug 4922099
17466 --
17467 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17468 (NVL(l_actual_upg_option, 'N') = 'O') OR
17469 (NVL(l_enc_upg_option, 'N') = 'O')
17470 )
17471 THEN
17472 NULL;
17473 --
17474 --
17475
17476 l_ccid := AcctDerRule_6(
17477 p_application_id => p_application_id
17478 , p_ae_header_id => l_ae_header_id
17479 , p_source_11 => p_source_11
17480 , x_transaction_coa_id => l_adr_transaction_coa_id
17481 , x_accounting_coa_id => l_adr_accounting_coa_id
17482 , x_value_type_code => l_adr_value_type_code
17483 , p_side => 'NA'
17484 );
17485
17486 xla_ae_lines_pkg.set_ccid(
17487 p_code_combination_id => l_ccid
17488 , p_value_type_code => l_adr_value_type_code
17489 , p_transaction_coa_id => l_adr_transaction_coa_id
17490 , p_accounting_coa_id => l_adr_accounting_coa_id
17491 , p_adr_code => 'CST_DEFAULT'
17492 , p_adr_type_code => 'S'
17493 , p_component_type => l_component_type
17494 , p_component_code => l_component_code
17495 , p_component_type_code => l_component_type_code
17496 , p_component_appl_id => l_component_appl_id
17497 , p_amb_context_code => l_amb_context_code
17498 , p_side => 'NA'
17499 );
17500
17501
17502 --
17503 --
17504 END IF;
17505 --
17506 -- Bug 4922099
17507 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17508 (NVL(l_enc_upg_option, 'N') = 'O')
17509 ) AND
17510 (l_bflow_method_code = 'PRIOR_ENTRY')
17511 )
17512 THEN
17513 IF
17514 --
17515 1 = 2
17516 --
17517 THEN
17518 xla_accounting_err_pkg.build_message
17519 (p_appli_s_name => 'XLA'
17520 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17521 ,p_token_1 => 'LINE_NUMBER'
17522 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17523 ,p_token_2 => 'LINE_TYPE_NAME'
17524 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17525 l_component_type
17526 ,l_component_code
17527 ,l_component_type_code
17528 ,l_component_appl_id
17529 ,l_amb_context_code
17530 ,l_entity_code
17531 ,l_event_class_code
17532 )
17533 ,p_token_3 => 'OWNER'
17534 ,p_value_3 => xla_lookups_pkg.get_meaning(
17535 p_lookup_type => 'XLA_OWNER_TYPE'
17536 ,p_lookup_code => l_component_type_code
17537 )
17538 ,p_token_4 => 'PRODUCT_NAME'
17539 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17540 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17541 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17542 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17543 ,p_ae_header_id => NULL
17544 );
17545
17546 IF (C_LEVEL_ERROR>= g_log_level) THEN
17547 trace
17548 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17549 ,p_level => C_LEVEL_ERROR
17550 ,p_module => l_log_module);
17551 END IF;
17552 END IF;
17553 END IF;
17554 --
17555 --
17556 ------------------------------------------------------------------------------------------------
17557 -- 4219869 Business Flow
17558 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17559 -- Prior Entry. Currently, the following code is always generated.
17560 ------------------------------------------------------------------------------------------------
17561 XLA_AE_LINES_PKG.ValidateCurrentLine;
17562
17563 ------------------------------------------------------------------------------------
17564 -- 4219869 Business Flow
17565 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17566 ------------------------------------------------------------------------------------
17567 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17568
17569 ----------------------------------------------------------------------------------
17570 -- 4219869 Business Flow
17571 -- Update journal entry status -- Need to generate this within IF <condition>
17572 ----------------------------------------------------------------------------------
17573 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17574 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17575 ,p_balance_type_code => l_balance_type_code
17576 );
17577
17578 -------------------------------------------------------------------------------------------
17579 -- 4262811 - Generate the Accrual Reversal lines
17580 -------------------------------------------------------------------------------------------
17581 BEGIN
17582 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17583 (g_array_event(p_event_id).array_value_num('header_index'));
17584 IF l_acc_rev_flag IS NULL THEN
17585 l_acc_rev_flag := 'N';
17586 END IF;
17587 EXCEPTION
17588 WHEN OTHERS THEN
17589 l_acc_rev_flag := 'N';
17590 END;
17591 --
17592 IF (l_acc_rev_flag = 'Y') THEN
17593
17594 -- 4645092 ------------------------------------------------------------------------------
17595 -- To allow MPA report to determine if it should generate report process
17596 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17597 ------------------------------------------------------------------------------------------
17598
17599 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17600 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17601 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17602 -- call ADRs
17603 -- Bug 4922099
17604 --
17605 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17606 (NVL(l_actual_upg_option, 'N') = 'O') OR
17607 (NVL(l_enc_upg_option, 'N') = 'O')
17608 )
17609 THEN
17610 NULL;
17611 --
17612 --
17613
17614 l_ccid := AcctDerRule_6(
17615 p_application_id => p_application_id
17616 , p_ae_header_id => l_ae_header_id
17617 , p_source_11 => p_source_11
17618 , x_transaction_coa_id => l_adr_transaction_coa_id
17619 , x_accounting_coa_id => l_adr_accounting_coa_id
17620 , x_value_type_code => l_adr_value_type_code
17621 , p_side => 'NA'
17622 );
17623
17624 xla_ae_lines_pkg.set_ccid(
17625 p_code_combination_id => l_ccid
17626 , p_value_type_code => l_adr_value_type_code
17627 , p_transaction_coa_id => l_adr_transaction_coa_id
17628 , p_accounting_coa_id => l_adr_accounting_coa_id
17629 , p_adr_code => 'CST_DEFAULT'
17630 , p_adr_type_code => 'S'
17631 , p_component_type => l_component_type
17632 , p_component_code => l_component_code
17633 , p_component_type_code => l_component_type_code
17634 , p_component_appl_id => l_component_appl_id
17635 , p_amb_context_code => l_amb_context_code
17636 , p_side => 'NA'
17637 );
17638
17639
17640 --
17641 --
17642 END IF;
17643
17644 --
17645 -- Update the line information that should be overwritten
17646 --
17647 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17648 p_header_num => 1);
17649 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17650
17651 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17652
17653 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17654 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17655 END IF;
17656
17657 --
17658 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17659 --
17660 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17661 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17662 ELSE
17663 ---------------------------------------------------------------------------------------------------
17664 -- 4262811a Switch Sign
17665 ---------------------------------------------------------------------------------------------------
17666 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17667 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17668 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17669 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17670 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17671 -- 5132302
17672 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17673 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17674
17675 END IF;
17676
17677 -- 4955764
17678 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17679 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17680
17681
17682 XLA_AE_LINES_PKG.ValidateCurrentLine;
17683 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17684
17685 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17686 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17687 ,p_balance_type_code => l_balance_type_code);
17688
17689 END IF;
17690
17691 -----------------------------------------------------------------------------------------
17692 -- 4262811 Multiperiod Accounting
17693 -----------------------------------------------------------------------------------------
17694 -- No MPA option is assigned.
17695
17696
17697 END IF;
17698 END IF;
17699 --
17700
17701 --
17702 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17703 trace
17704 (p_msg => 'END of AcctLineType_57'
17705 ,p_level => C_LEVEL_PROCEDURE
17706 ,p_module => l_log_module);
17707 END IF;
17708 --
17709 EXCEPTION
17710 WHEN xla_exceptions_pkg.application_exception THEN
17711 RAISE;
17712 WHEN OTHERS THEN
17713 xla_exceptions_pkg.raise_message
17714 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_57');
17715 END AcctLineType_57;
17716 --
17717
17718 ---------------------------------------
17719 --
17720 -- PRIVATE FUNCTION
17721 -- AcctLineType_58
17722 --
17723 ---------------------------------------
17724 PROCEDURE AcctLineType_58 (
17725 p_application_id IN NUMBER
17726 ,p_event_id IN NUMBER
17727 ,p_calculate_acctd_flag IN VARCHAR2
17728 ,p_calculate_g_l_flag IN VARCHAR2
17729 ,p_actual_flag IN OUT VARCHAR2
17730 ,p_balance_type_code OUT VARCHAR2
17731 ,p_gain_or_loss_ref OUT VARCHAR2
17732
17733 --TRANSACTION_ID
17734 , p_source_1 IN NUMBER
17735 --Item Concatenated Segments
17736 , p_source_2 IN VARCHAR2
17737 --Transaction Quantity
17738 , p_source_3 IN NUMBER
17739 --Transaction Unit of Measure Code
17740 , p_source_4 IN VARCHAR2
17741 --Inventory Transaction Type Description
17742 , p_source_5 IN VARCHAR2
17743 --Cost Management Default Account
17744 , p_source_11 IN NUMBER
17745 --DISTRIBUTION_IDENTIFIER
17746 , p_source_84 IN NUMBER
17747 --Distribution Type
17748 , p_source_85 IN VARCHAR2
17749 , p_source_85_meaning IN VARCHAR2
17750 --Entered Currency Code
17751 , p_source_88 IN VARCHAR2
17752 --Entered Amount
17753 , p_source_91 IN NUMBER
17754 --Currency Conversion Date
17755 , p_source_92 IN DATE
17756 --Currency Conversion Rate
17757 , p_source_93 IN NUMBER
17758 --Currency Conversion Type
17759 , p_source_94 IN VARCHAR2
17760 --Accounted Amount
17761 , p_source_95 IN NUMBER
17762 --Accounting Line Type
17763 , p_source_97 IN NUMBER
17764 )
17765 IS
17766
17767 l_component_type VARCHAR2(80);
17768 l_component_code VARCHAR2(30);
17769 l_component_type_code VARCHAR2(1);
17770 l_component_appl_id INTEGER;
17771 l_amb_context_code VARCHAR2(30);
17772 l_entity_code VARCHAR2(30);
17773 l_event_class_code VARCHAR2(30);
17774 l_ae_header_id NUMBER;
17775 l_event_type_code VARCHAR2(30);
17776 l_line_definition_code VARCHAR2(30);
17777 l_line_definition_owner_code VARCHAR2(1);
17778 --
17779 -- adr variables
17780 l_segment VARCHAR2(30);
17781 l_ccid NUMBER;
17782 l_adr_transaction_coa_id NUMBER;
17783 l_adr_accounting_coa_id NUMBER;
17784 l_adr_flexfield_segment_code VARCHAR2(30);
17785 l_adr_flex_value_set_id NUMBER;
17786 l_adr_value_type_code VARCHAR2(30);
17787 l_adr_value_combination_id NUMBER;
17788 l_adr_value_segment_code VARCHAR2(30);
17789
17790 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17791 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17792 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17793 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17794
17795 -- 4262811 Variables ------------------------------------------------------------------------------------------
17796 l_entered_amt_idx NUMBER;
17797 l_accted_amt_idx NUMBER;
17798 l_acc_rev_flag VARCHAR2(1);
17799 l_accrual_line_num NUMBER;
17800 l_tmp_amt NUMBER;
17801 l_acc_rev_natural_side_code VARCHAR2(1);
17802
17803 l_num_entries NUMBER;
17804 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17805 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17806 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17807 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17808 l_recog_line_1 NUMBER;
17809 l_recog_line_2 NUMBER;
17810
17811 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17812 l_bflow_applied_to_amt NUMBER; -- 5132302
17813 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17814
17815 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17816
17817 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17818 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17819
17820 ---------------------------------------------------------------------------------------------------------------
17821
17822
17823 --
17824 -- bulk performance
17825 --
17826 l_balance_type_code VARCHAR2(1);
17827 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17828 l_log_module VARCHAR2(240);
17829
17830 --
17831 -- Upgrade strategy
17832 --
17833 l_actual_upg_option VARCHAR2(1);
17834 l_enc_upg_option VARCHAR2(1);
17835
17836 --
17837 BEGIN
17838 --
17839 IF g_log_enabled THEN
17840 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_58';
17841 END IF;
17842 --
17843 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17844
17845 trace
17846 (p_msg => 'BEGIN of AcctLineType_58'
17847 ,p_level => C_LEVEL_PROCEDURE
17848 ,p_module => l_log_module);
17849
17850 END IF;
17851 --
17852 l_component_type := 'AMB_JLT';
17853 l_component_code := 'COST_OF_GOODS_SOLD';
17854 l_component_type_code := 'S';
17855 l_component_appl_id := 707;
17856 l_amb_context_code := 'DEFAULT';
17857 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
17858 l_event_class_code := 'SALES_ORDER';
17859 l_event_type_code := 'RMA_RETURN';
17860 l_line_definition_owner_code := 'S';
17861 l_line_definition_code := 'PI_RMA_RETURN';
17862 --
17863 l_balance_type_code := 'A';
17864 l_segment := NULL;
17865 l_ccid := NULL;
17866 l_adr_transaction_coa_id := NULL;
17867 l_adr_accounting_coa_id := NULL;
17868 l_adr_flexfield_segment_code := NULL;
17869 l_adr_flex_value_set_id := NULL;
17870 l_adr_value_type_code := NULL;
17871 l_adr_value_combination_id := NULL;
17872 l_adr_value_segment_code := NULL;
17873
17874 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17875 l_bflow_class_code := ''; -- 4219869 Business Flow
17876 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17877 l_budgetary_control_flag := 'N';
17878
17879 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17880 l_bflow_applied_to_amt := NULL; -- 5132302
17881 l_entered_amt_idx := NULL; -- 4262811
17882 l_accted_amt_idx := NULL; -- 4262811
17883 l_acc_rev_flag := NULL; -- 4262811
17884 l_accrual_line_num := NULL; -- 4262811
17885 l_tmp_amt := NULL; -- 4262811
17886 --
17887
17888 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17889 l_balance_type_code <> 'B' THEN
17890 IF NVL(p_source_97,9E125) = 35
17891 THEN
17892
17893 --
17894 XLA_AE_LINES_PKG.SetNewLine;
17895
17896 p_balance_type_code := l_balance_type_code;
17897 -- set the flag so later we will know whether the gain loss line needs to be created
17898
17899 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17900 p_actual_flag :='A';
17901 END IF;
17902
17903 --
17904 -- bulk performance
17905 --
17906 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17907 p_header_num => 0); -- 4262811
17908 --
17909 -- set accounting line options
17910 --
17911 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17912 p_natural_side_code => 'D'
17913 , p_gain_or_loss_flag => 'N'
17914 , p_gl_transfer_mode_code => 'S'
17915 , p_acct_entry_type_code => 'A'
17916 , p_switch_side_flag => 'Y'
17917 , p_merge_duplicate_code => 'N'
17918 );
17919 --
17920 l_acc_rev_natural_side_code := 'C'; -- 4262811
17921 --
17922 --
17923 -- set accounting line type info
17924 --
17925 xla_ae_lines_pkg.SetAcctLineType
17926 (p_component_type => l_component_type
17927 ,p_event_type_code => l_event_type_code
17928 ,p_line_definition_owner_code => l_line_definition_owner_code
17929 ,p_line_definition_code => l_line_definition_code
17930 ,p_accounting_line_code => l_component_code
17931 ,p_accounting_line_type_code => l_component_type_code
17932 ,p_accounting_line_appl_id => l_component_appl_id
17933 ,p_amb_context_code => l_amb_context_code
17934 ,p_entity_code => l_entity_code
17935 ,p_event_class_code => l_event_class_code);
17936 --
17937 -- set accounting class
17938 --
17939 xla_ae_lines_pkg.SetAcctClass(
17940 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
17941 , p_ae_header_id => l_ae_header_id
17942 );
17943
17944 --
17945 -- set rounding class
17946 --
17947 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17948 'COST_OF_GOODS_SOLD';
17949
17950 --
17951 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17952 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17953 --
17954 -- bulk performance
17955 --
17956 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17957
17958 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17959 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17960
17961 -- 4955764
17962 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17963 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17964
17965 -- 4458381 Public Sector Enh
17966
17967 --
17968 -- set accounting attributes for the line type
17969 --
17970 l_entered_amt_idx := 3;
17971 l_accted_amt_idx := 8;
17972 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17973 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17974 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
17975 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17976 l_rec_acct_attrs.array_char_value(2) := p_source_85;
17977 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17978 l_rec_acct_attrs.array_num_value(3) := p_source_91;
17979 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17980 l_rec_acct_attrs.array_char_value(4) := p_source_88;
17981 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17982 l_rec_acct_attrs.array_date_value(5) := p_source_92;
17983 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17984 l_rec_acct_attrs.array_num_value(6) := p_source_93;
17985 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17986 l_rec_acct_attrs.array_char_value(7) := p_source_94;
17987 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17988 l_rec_acct_attrs.array_num_value(8) := p_source_95;
17989
17990 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17991 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17992
17993 ---------------------------------------------------------------------------------------------------------------
17994 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17995 ---------------------------------------------------------------------------------------------------------------
17996 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17997
17998 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17999 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18000
18001 IF xla_accounting_cache_pkg.GetValueChar
18002 (p_source_code => 'LEDGER_CATEGORY_CODE'
18003 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18004 AND l_bflow_method_code = 'PRIOR_ENTRY'
18005 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18006 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18007 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18008 )
18009 THEN
18010 xla_ae_lines_pkg.BflowUpgEntry
18011 (p_business_method_code => l_bflow_method_code
18012 ,p_business_class_code => l_bflow_class_code
18013 ,p_balance_type => l_balance_type_code);
18014 ELSE
18015 NULL;
18016 -- No business flow processing for business flow method of NONE.
18017 END IF;
18018
18019 --
18020 -- call analytical criteria
18021 --
18022
18023 --
18024 -- call description
18025 --
18026
18027 xla_ae_lines_pkg.SetLineDescription(
18028 p_ae_header_id => l_ae_header_id
18029 ,p_description => Description_1 (
18030 p_application_id => p_application_id
18031 , p_ae_header_id => l_ae_header_id
18032 , p_source_1 => p_source_1
18033 , p_source_2 => p_source_2
18034 , p_source_3 => p_source_3
18035 , p_source_4 => p_source_4
18036 , p_source_5 => p_source_5
18037 )
18038 );
18039
18040
18041 --
18042 -- call ADRs
18043 -- Bug 4922099
18044 --
18045 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18046 (NVL(l_actual_upg_option, 'N') = 'O') OR
18047 (NVL(l_enc_upg_option, 'N') = 'O')
18048 )
18049 THEN
18050 NULL;
18051 --
18052 --
18053
18054 l_ccid := AcctDerRule_6(
18055 p_application_id => p_application_id
18056 , p_ae_header_id => l_ae_header_id
18057 , p_source_11 => p_source_11
18058 , x_transaction_coa_id => l_adr_transaction_coa_id
18059 , x_accounting_coa_id => l_adr_accounting_coa_id
18060 , x_value_type_code => l_adr_value_type_code
18061 , p_side => 'NA'
18062 );
18063
18064 xla_ae_lines_pkg.set_ccid(
18065 p_code_combination_id => l_ccid
18066 , p_value_type_code => l_adr_value_type_code
18067 , p_transaction_coa_id => l_adr_transaction_coa_id
18068 , p_accounting_coa_id => l_adr_accounting_coa_id
18069 , p_adr_code => 'CST_DEFAULT'
18070 , p_adr_type_code => 'S'
18071 , p_component_type => l_component_type
18072 , p_component_code => l_component_code
18073 , p_component_type_code => l_component_type_code
18074 , p_component_appl_id => l_component_appl_id
18075 , p_amb_context_code => l_amb_context_code
18076 , p_side => 'NA'
18077 );
18078
18079
18080 --
18081 --
18082 END IF;
18083 --
18084 -- Bug 4922099
18085 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18086 (NVL(l_enc_upg_option, 'N') = 'O')
18087 ) AND
18088 (l_bflow_method_code = 'PRIOR_ENTRY')
18089 )
18090 THEN
18091 IF
18092 --
18093 1 = 2
18094 --
18095 THEN
18096 xla_accounting_err_pkg.build_message
18097 (p_appli_s_name => 'XLA'
18098 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18099 ,p_token_1 => 'LINE_NUMBER'
18100 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18101 ,p_token_2 => 'LINE_TYPE_NAME'
18102 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18103 l_component_type
18104 ,l_component_code
18105 ,l_component_type_code
18106 ,l_component_appl_id
18107 ,l_amb_context_code
18108 ,l_entity_code
18109 ,l_event_class_code
18110 )
18111 ,p_token_3 => 'OWNER'
18112 ,p_value_3 => xla_lookups_pkg.get_meaning(
18113 p_lookup_type => 'XLA_OWNER_TYPE'
18114 ,p_lookup_code => l_component_type_code
18115 )
18116 ,p_token_4 => 'PRODUCT_NAME'
18117 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18118 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18119 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18120 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18121 ,p_ae_header_id => NULL
18122 );
18123
18124 IF (C_LEVEL_ERROR>= g_log_level) THEN
18125 trace
18126 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18127 ,p_level => C_LEVEL_ERROR
18128 ,p_module => l_log_module);
18129 END IF;
18130 END IF;
18131 END IF;
18132 --
18133 --
18134 ------------------------------------------------------------------------------------------------
18135 -- 4219869 Business Flow
18136 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18137 -- Prior Entry. Currently, the following code is always generated.
18138 ------------------------------------------------------------------------------------------------
18139 XLA_AE_LINES_PKG.ValidateCurrentLine;
18140
18141 ------------------------------------------------------------------------------------
18142 -- 4219869 Business Flow
18143 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18144 ------------------------------------------------------------------------------------
18145 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18146
18147 ----------------------------------------------------------------------------------
18148 -- 4219869 Business Flow
18149 -- Update journal entry status -- Need to generate this within IF <condition>
18150 ----------------------------------------------------------------------------------
18151 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18152 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18153 ,p_balance_type_code => l_balance_type_code
18154 );
18155
18156 -------------------------------------------------------------------------------------------
18157 -- 4262811 - Generate the Accrual Reversal lines
18158 -------------------------------------------------------------------------------------------
18159 BEGIN
18160 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18161 (g_array_event(p_event_id).array_value_num('header_index'));
18162 IF l_acc_rev_flag IS NULL THEN
18163 l_acc_rev_flag := 'N';
18164 END IF;
18165 EXCEPTION
18166 WHEN OTHERS THEN
18167 l_acc_rev_flag := 'N';
18168 END;
18169 --
18170 IF (l_acc_rev_flag = 'Y') THEN
18171
18172 -- 4645092 ------------------------------------------------------------------------------
18173 -- To allow MPA report to determine if it should generate report process
18174 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18175 ------------------------------------------------------------------------------------------
18176
18177 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18178 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18179 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18180 -- call ADRs
18181 -- Bug 4922099
18182 --
18183 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18184 (NVL(l_actual_upg_option, 'N') = 'O') OR
18185 (NVL(l_enc_upg_option, 'N') = 'O')
18186 )
18187 THEN
18188 NULL;
18189 --
18190 --
18191
18192 l_ccid := AcctDerRule_6(
18193 p_application_id => p_application_id
18194 , p_ae_header_id => l_ae_header_id
18195 , p_source_11 => p_source_11
18196 , x_transaction_coa_id => l_adr_transaction_coa_id
18197 , x_accounting_coa_id => l_adr_accounting_coa_id
18198 , x_value_type_code => l_adr_value_type_code
18199 , p_side => 'NA'
18200 );
18201
18202 xla_ae_lines_pkg.set_ccid(
18203 p_code_combination_id => l_ccid
18204 , p_value_type_code => l_adr_value_type_code
18205 , p_transaction_coa_id => l_adr_transaction_coa_id
18206 , p_accounting_coa_id => l_adr_accounting_coa_id
18207 , p_adr_code => 'CST_DEFAULT'
18208 , p_adr_type_code => 'S'
18209 , p_component_type => l_component_type
18210 , p_component_code => l_component_code
18211 , p_component_type_code => l_component_type_code
18212 , p_component_appl_id => l_component_appl_id
18213 , p_amb_context_code => l_amb_context_code
18214 , p_side => 'NA'
18215 );
18216
18217
18218 --
18219 --
18220 END IF;
18221
18222 --
18223 -- Update the line information that should be overwritten
18224 --
18225 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18226 p_header_num => 1);
18227 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18228
18229 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18230
18231 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18232 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18233 END IF;
18234
18235 --
18236 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18237 --
18238 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18239 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18240 ELSE
18241 ---------------------------------------------------------------------------------------------------
18242 -- 4262811a Switch Sign
18243 ---------------------------------------------------------------------------------------------------
18244 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18245 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18246 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18247 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18248 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18249 -- 5132302
18250 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18251 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18252
18253 END IF;
18254
18255 -- 4955764
18256 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18257 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18258
18259
18260 XLA_AE_LINES_PKG.ValidateCurrentLine;
18261 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18262
18263 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18264 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18265 ,p_balance_type_code => l_balance_type_code);
18266
18267 END IF;
18268
18269 -----------------------------------------------------------------------------------------
18270 -- 4262811 Multiperiod Accounting
18271 -----------------------------------------------------------------------------------------
18272 -- No MPA option is assigned.
18273
18274
18275 END IF;
18276 END IF;
18277 --
18278
18279 --
18280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18281 trace
18282 (p_msg => 'END of AcctLineType_58'
18283 ,p_level => C_LEVEL_PROCEDURE
18284 ,p_module => l_log_module);
18285 END IF;
18286 --
18287 EXCEPTION
18288 WHEN xla_exceptions_pkg.application_exception THEN
18289 RAISE;
18290 WHEN OTHERS THEN
18291 xla_exceptions_pkg.raise_message
18292 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_58');
18293 END AcctLineType_58;
18294 --
18295
18296 ---------------------------------------
18297 --
18298 -- PRIVATE FUNCTION
18299 -- AcctLineType_59
18300 --
18301 ---------------------------------------
18302 PROCEDURE AcctLineType_59 (
18303 p_application_id IN NUMBER
18304 ,p_event_id IN NUMBER
18305 ,p_calculate_acctd_flag IN VARCHAR2
18306 ,p_calculate_g_l_flag IN VARCHAR2
18307 ,p_actual_flag IN OUT VARCHAR2
18308 ,p_balance_type_code OUT VARCHAR2
18309 ,p_gain_or_loss_ref OUT VARCHAR2
18310
18311 --TRANSACTION_ID
18312 , p_source_1 IN NUMBER
18313 --Item Concatenated Segments
18314 , p_source_2 IN VARCHAR2
18315 --Transaction Quantity
18316 , p_source_3 IN NUMBER
18317 --Transaction Unit of Measure Code
18318 , p_source_4 IN VARCHAR2
18319 --Inventory Transaction Type Description
18320 , p_source_5 IN VARCHAR2
18321 --Cost Management Default Account
18322 , p_source_11 IN NUMBER
18323 --DISTRIBUTION_IDENTIFIER
18324 , p_source_84 IN NUMBER
18325 --Distribution Type
18326 , p_source_85 IN VARCHAR2
18327 , p_source_85_meaning IN VARCHAR2
18328 --Entered Currency Code
18329 , p_source_88 IN VARCHAR2
18330 --Entered Amount
18331 , p_source_91 IN NUMBER
18332 --Currency Conversion Date
18333 , p_source_92 IN DATE
18334 --Currency Conversion Rate
18335 , p_source_93 IN NUMBER
18336 --Currency Conversion Type
18337 , p_source_94 IN VARCHAR2
18338 --Accounted Amount
18339 , p_source_95 IN NUMBER
18340 --Accounting Line Type
18341 , p_source_97 IN NUMBER
18342 )
18343 IS
18344
18345 l_component_type VARCHAR2(80);
18346 l_component_code VARCHAR2(30);
18347 l_component_type_code VARCHAR2(1);
18348 l_component_appl_id INTEGER;
18349 l_amb_context_code VARCHAR2(30);
18350 l_entity_code VARCHAR2(30);
18351 l_event_class_code VARCHAR2(30);
18352 l_ae_header_id NUMBER;
18353 l_event_type_code VARCHAR2(30);
18354 l_line_definition_code VARCHAR2(30);
18355 l_line_definition_owner_code VARCHAR2(1);
18356 --
18357 -- adr variables
18358 l_segment VARCHAR2(30);
18359 l_ccid NUMBER;
18360 l_adr_transaction_coa_id NUMBER;
18361 l_adr_accounting_coa_id NUMBER;
18362 l_adr_flexfield_segment_code VARCHAR2(30);
18363 l_adr_flex_value_set_id NUMBER;
18364 l_adr_value_type_code VARCHAR2(30);
18365 l_adr_value_combination_id NUMBER;
18366 l_adr_value_segment_code VARCHAR2(30);
18367
18368 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18369 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18370 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18371 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18372
18373 -- 4262811 Variables ------------------------------------------------------------------------------------------
18374 l_entered_amt_idx NUMBER;
18375 l_accted_amt_idx NUMBER;
18376 l_acc_rev_flag VARCHAR2(1);
18377 l_accrual_line_num NUMBER;
18378 l_tmp_amt NUMBER;
18379 l_acc_rev_natural_side_code VARCHAR2(1);
18380
18381 l_num_entries NUMBER;
18382 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18383 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18384 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18385 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18386 l_recog_line_1 NUMBER;
18387 l_recog_line_2 NUMBER;
18388
18389 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18390 l_bflow_applied_to_amt NUMBER; -- 5132302
18391 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18392
18393 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18394
18395 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18396 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18397
18398 ---------------------------------------------------------------------------------------------------------------
18399
18400
18401 --
18402 -- bulk performance
18403 --
18404 l_balance_type_code VARCHAR2(1);
18405 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18406 l_log_module VARCHAR2(240);
18407
18408 --
18409 -- Upgrade strategy
18410 --
18411 l_actual_upg_option VARCHAR2(1);
18412 l_enc_upg_option VARCHAR2(1);
18413
18414 --
18415 BEGIN
18416 --
18417 IF g_log_enabled THEN
18418 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_59';
18419 END IF;
18420 --
18421 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18422
18423 trace
18424 (p_msg => 'BEGIN of AcctLineType_59'
18425 ,p_level => C_LEVEL_PROCEDURE
18426 ,p_module => l_log_module);
18427
18428 END IF;
18429 --
18430 l_component_type := 'AMB_JLT';
18431 l_component_code := 'COST_OF_GOODS_SOLD';
18432 l_component_type_code := 'S';
18433 l_component_appl_id := 707;
18434 l_amb_context_code := 'DEFAULT';
18435 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
18436 l_event_class_code := 'USER_DEFINE';
18437 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
18438 l_line_definition_owner_code := 'S';
18439 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
18440 --
18441 l_balance_type_code := 'A';
18442 l_segment := NULL;
18443 l_ccid := NULL;
18444 l_adr_transaction_coa_id := NULL;
18445 l_adr_accounting_coa_id := NULL;
18446 l_adr_flexfield_segment_code := NULL;
18447 l_adr_flex_value_set_id := NULL;
18448 l_adr_value_type_code := NULL;
18449 l_adr_value_combination_id := NULL;
18450 l_adr_value_segment_code := NULL;
18451
18452 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
18453 l_bflow_class_code := ''; -- 4219869 Business Flow
18454 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18455 l_budgetary_control_flag := 'N';
18456
18457 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18458 l_bflow_applied_to_amt := NULL; -- 5132302
18459 l_entered_amt_idx := NULL; -- 4262811
18460 l_accted_amt_idx := NULL; -- 4262811
18461 l_acc_rev_flag := NULL; -- 4262811
18462 l_accrual_line_num := NULL; -- 4262811
18463 l_tmp_amt := NULL; -- 4262811
18464 --
18465
18466 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18467 l_balance_type_code <> 'B' THEN
18468 IF NVL(p_source_97,9E125) = 2 AND
18469 p_source_95 > 0
18470 THEN
18471
18472 --
18473 XLA_AE_LINES_PKG.SetNewLine;
18474
18475 p_balance_type_code := l_balance_type_code;
18476 -- set the flag so later we will know whether the gain loss line needs to be created
18477
18478 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18479 p_actual_flag :='A';
18480 END IF;
18481
18482 --
18483 -- bulk performance
18484 --
18485 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18486 p_header_num => 0); -- 4262811
18487 --
18488 -- set accounting line options
18489 --
18490 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18491 p_natural_side_code => 'D'
18492 , p_gain_or_loss_flag => 'N'
18493 , p_gl_transfer_mode_code => 'S'
18494 , p_acct_entry_type_code => 'A'
18495 , p_switch_side_flag => 'Y'
18496 , p_merge_duplicate_code => 'N'
18497 );
18498 --
18499 l_acc_rev_natural_side_code := 'C'; -- 4262811
18500 --
18501 --
18502 -- set accounting line type info
18503 --
18504 xla_ae_lines_pkg.SetAcctLineType
18505 (p_component_type => l_component_type
18506 ,p_event_type_code => l_event_type_code
18507 ,p_line_definition_owner_code => l_line_definition_owner_code
18508 ,p_line_definition_code => l_line_definition_code
18509 ,p_accounting_line_code => l_component_code
18510 ,p_accounting_line_type_code => l_component_type_code
18511 ,p_accounting_line_appl_id => l_component_appl_id
18512 ,p_amb_context_code => l_amb_context_code
18513 ,p_entity_code => l_entity_code
18514 ,p_event_class_code => l_event_class_code);
18515 --
18516 -- set accounting class
18517 --
18518 xla_ae_lines_pkg.SetAcctClass(
18519 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
18520 , p_ae_header_id => l_ae_header_id
18521 );
18522
18523 --
18524 -- set rounding class
18525 --
18526 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18527 'COST_OF_GOODS_SOLD';
18528
18529 --
18530 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18531 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18532 --
18533 -- bulk performance
18534 --
18535 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18536
18537 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18538 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18539
18540 -- 4955764
18541 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18542 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18543
18544 -- 4458381 Public Sector Enh
18545
18546 --
18547 -- set accounting attributes for the line type
18548 --
18549 l_entered_amt_idx := 3;
18550 l_accted_amt_idx := 8;
18551 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18552 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
18553 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
18554 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
18555 l_rec_acct_attrs.array_char_value(2) := p_source_85;
18556 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
18557 l_rec_acct_attrs.array_num_value(3) := p_source_91;
18558 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
18559 l_rec_acct_attrs.array_char_value(4) := p_source_88;
18560 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
18561 l_rec_acct_attrs.array_date_value(5) := p_source_92;
18562 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
18563 l_rec_acct_attrs.array_num_value(6) := p_source_93;
18564 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
18565 l_rec_acct_attrs.array_char_value(7) := p_source_94;
18566 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
18567 l_rec_acct_attrs.array_num_value(8) := p_source_95;
18568
18569 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18570 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18571
18572 ---------------------------------------------------------------------------------------------------------------
18573 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18574 ---------------------------------------------------------------------------------------------------------------
18575 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18576
18577 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18578 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18579
18580 IF xla_accounting_cache_pkg.GetValueChar
18581 (p_source_code => 'LEDGER_CATEGORY_CODE'
18582 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18583 AND l_bflow_method_code = 'PRIOR_ENTRY'
18584 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18585 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18586 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18587 )
18588 THEN
18589 xla_ae_lines_pkg.BflowUpgEntry
18590 (p_business_method_code => l_bflow_method_code
18591 ,p_business_class_code => l_bflow_class_code
18592 ,p_balance_type => l_balance_type_code);
18593 ELSE
18594 NULL;
18595 -- No business flow processing for business flow method of NONE.
18596 END IF;
18597
18598 --
18599 -- call analytical criteria
18600 --
18601
18602 --
18603 -- call description
18604 --
18605
18606 xla_ae_lines_pkg.SetLineDescription(
18607 p_ae_header_id => l_ae_header_id
18608 ,p_description => Description_1 (
18609 p_application_id => p_application_id
18610 , p_ae_header_id => l_ae_header_id
18611 , p_source_1 => p_source_1
18612 , p_source_2 => p_source_2
18613 , p_source_3 => p_source_3
18614 , p_source_4 => p_source_4
18615 , p_source_5 => p_source_5
18616 )
18617 );
18618
18619
18620 --
18621 -- call ADRs
18622 -- Bug 4922099
18623 --
18624 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18625 (NVL(l_actual_upg_option, 'N') = 'O') OR
18626 (NVL(l_enc_upg_option, 'N') = 'O')
18627 )
18628 THEN
18629 NULL;
18630 --
18631 --
18632
18633 l_ccid := AcctDerRule_6(
18634 p_application_id => p_application_id
18635 , p_ae_header_id => l_ae_header_id
18636 , p_source_11 => p_source_11
18637 , x_transaction_coa_id => l_adr_transaction_coa_id
18638 , x_accounting_coa_id => l_adr_accounting_coa_id
18639 , x_value_type_code => l_adr_value_type_code
18640 , p_side => 'NA'
18641 );
18642
18643 xla_ae_lines_pkg.set_ccid(
18644 p_code_combination_id => l_ccid
18645 , p_value_type_code => l_adr_value_type_code
18646 , p_transaction_coa_id => l_adr_transaction_coa_id
18647 , p_accounting_coa_id => l_adr_accounting_coa_id
18648 , p_adr_code => 'CST_DEFAULT'
18649 , p_adr_type_code => 'S'
18650 , p_component_type => l_component_type
18651 , p_component_code => l_component_code
18652 , p_component_type_code => l_component_type_code
18653 , p_component_appl_id => l_component_appl_id
18654 , p_amb_context_code => l_amb_context_code
18655 , p_side => 'NA'
18656 );
18657
18658
18659 --
18660 --
18661 END IF;
18662 --
18663 -- Bug 4922099
18664 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18665 (NVL(l_enc_upg_option, 'N') = 'O')
18666 ) AND
18667 (l_bflow_method_code = 'PRIOR_ENTRY')
18668 )
18669 THEN
18670 IF
18671 --
18672 1 = 2
18673 --
18674 THEN
18675 xla_accounting_err_pkg.build_message
18676 (p_appli_s_name => 'XLA'
18677 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18678 ,p_token_1 => 'LINE_NUMBER'
18679 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18680 ,p_token_2 => 'LINE_TYPE_NAME'
18681 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18682 l_component_type
18683 ,l_component_code
18684 ,l_component_type_code
18685 ,l_component_appl_id
18686 ,l_amb_context_code
18687 ,l_entity_code
18688 ,l_event_class_code
18689 )
18690 ,p_token_3 => 'OWNER'
18691 ,p_value_3 => xla_lookups_pkg.get_meaning(
18692 p_lookup_type => 'XLA_OWNER_TYPE'
18693 ,p_lookup_code => l_component_type_code
18694 )
18695 ,p_token_4 => 'PRODUCT_NAME'
18696 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18697 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18698 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18699 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18700 ,p_ae_header_id => NULL
18701 );
18702
18703 IF (C_LEVEL_ERROR>= g_log_level) THEN
18704 trace
18705 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18706 ,p_level => C_LEVEL_ERROR
18707 ,p_module => l_log_module);
18708 END IF;
18709 END IF;
18710 END IF;
18711 --
18712 --
18713 ------------------------------------------------------------------------------------------------
18714 -- 4219869 Business Flow
18715 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18716 -- Prior Entry. Currently, the following code is always generated.
18717 ------------------------------------------------------------------------------------------------
18718 XLA_AE_LINES_PKG.ValidateCurrentLine;
18719
18720 ------------------------------------------------------------------------------------
18721 -- 4219869 Business Flow
18722 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18723 ------------------------------------------------------------------------------------
18724 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18725
18726 ----------------------------------------------------------------------------------
18727 -- 4219869 Business Flow
18728 -- Update journal entry status -- Need to generate this within IF <condition>
18729 ----------------------------------------------------------------------------------
18730 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18731 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18732 ,p_balance_type_code => l_balance_type_code
18733 );
18734
18735 -------------------------------------------------------------------------------------------
18736 -- 4262811 - Generate the Accrual Reversal lines
18737 -------------------------------------------------------------------------------------------
18738 BEGIN
18739 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18740 (g_array_event(p_event_id).array_value_num('header_index'));
18741 IF l_acc_rev_flag IS NULL THEN
18742 l_acc_rev_flag := 'N';
18743 END IF;
18744 EXCEPTION
18745 WHEN OTHERS THEN
18746 l_acc_rev_flag := 'N';
18747 END;
18748 --
18749 IF (l_acc_rev_flag = 'Y') THEN
18750
18751 -- 4645092 ------------------------------------------------------------------------------
18752 -- To allow MPA report to determine if it should generate report process
18753 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18754 ------------------------------------------------------------------------------------------
18755
18756 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18757 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18758 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18759 -- call ADRs
18760 -- Bug 4922099
18761 --
18762 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18763 (NVL(l_actual_upg_option, 'N') = 'O') OR
18764 (NVL(l_enc_upg_option, 'N') = 'O')
18765 )
18766 THEN
18767 NULL;
18768 --
18769 --
18770
18771 l_ccid := AcctDerRule_6(
18772 p_application_id => p_application_id
18773 , p_ae_header_id => l_ae_header_id
18774 , p_source_11 => p_source_11
18775 , x_transaction_coa_id => l_adr_transaction_coa_id
18776 , x_accounting_coa_id => l_adr_accounting_coa_id
18777 , x_value_type_code => l_adr_value_type_code
18778 , p_side => 'NA'
18779 );
18780
18781 xla_ae_lines_pkg.set_ccid(
18782 p_code_combination_id => l_ccid
18783 , p_value_type_code => l_adr_value_type_code
18784 , p_transaction_coa_id => l_adr_transaction_coa_id
18785 , p_accounting_coa_id => l_adr_accounting_coa_id
18786 , p_adr_code => 'CST_DEFAULT'
18787 , p_adr_type_code => 'S'
18788 , p_component_type => l_component_type
18789 , p_component_code => l_component_code
18790 , p_component_type_code => l_component_type_code
18791 , p_component_appl_id => l_component_appl_id
18792 , p_amb_context_code => l_amb_context_code
18793 , p_side => 'NA'
18794 );
18795
18796
18797 --
18798 --
18799 END IF;
18800
18801 --
18802 -- Update the line information that should be overwritten
18803 --
18804 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18805 p_header_num => 1);
18806 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18807
18808 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18809
18810 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18811 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18812 END IF;
18813
18814 --
18815 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18816 --
18817 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18818 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18819 ELSE
18820 ---------------------------------------------------------------------------------------------------
18821 -- 4262811a Switch Sign
18822 ---------------------------------------------------------------------------------------------------
18823 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18824 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18825 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18826 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18827 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18828 -- 5132302
18829 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18830 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18831
18832 END IF;
18833
18834 -- 4955764
18835 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18836 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18837
18838
18839 XLA_AE_LINES_PKG.ValidateCurrentLine;
18840 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18841
18842 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18843 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18844 ,p_balance_type_code => l_balance_type_code);
18845
18846 END IF;
18847
18848 -----------------------------------------------------------------------------------------
18849 -- 4262811 Multiperiod Accounting
18850 -----------------------------------------------------------------------------------------
18851 -- No MPA option is assigned.
18852
18853
18854 END IF;
18855 END IF;
18856 --
18857
18858 --
18859 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18860 trace
18861 (p_msg => 'END of AcctLineType_59'
18862 ,p_level => C_LEVEL_PROCEDURE
18863 ,p_module => l_log_module);
18864 END IF;
18865 --
18866 EXCEPTION
18867 WHEN xla_exceptions_pkg.application_exception THEN
18868 RAISE;
18869 WHEN OTHERS THEN
18870 xla_exceptions_pkg.raise_message
18871 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_59');
18872 END AcctLineType_59;
18873 --
18874
18875 ---------------------------------------
18876 --
18877 -- PRIVATE FUNCTION
18878 -- AcctLineType_60
18879 --
18880 ---------------------------------------
18881 PROCEDURE AcctLineType_60 (
18882 p_application_id IN NUMBER
18883 ,p_event_id IN NUMBER
18884 ,p_calculate_acctd_flag IN VARCHAR2
18885 ,p_calculate_g_l_flag IN VARCHAR2
18886 ,p_actual_flag IN OUT VARCHAR2
18887 ,p_balance_type_code OUT VARCHAR2
18888 ,p_gain_or_loss_ref OUT VARCHAR2
18889
18890 --TRANSACTION_ID
18891 , p_source_1 IN NUMBER
18892 --Item Concatenated Segments
18893 , p_source_2 IN VARCHAR2
18894 --Transaction Quantity
18895 , p_source_3 IN NUMBER
18896 --Transaction Unit of Measure Code
18897 , p_source_4 IN VARCHAR2
18898 --Inventory Transaction Type Description
18899 , p_source_5 IN VARCHAR2
18900 --Cost Management Default Account
18901 , p_source_11 IN NUMBER
18902 --DISTRIBUTION_IDENTIFIER
18903 , p_source_84 IN NUMBER
18904 --Distribution Type
18905 , p_source_85 IN VARCHAR2
18906 , p_source_85_meaning IN VARCHAR2
18907 --Entered Currency Code
18908 , p_source_88 IN VARCHAR2
18909 --Entered Amount
18910 , p_source_91 IN NUMBER
18911 --Currency Conversion Date
18912 , p_source_92 IN DATE
18913 --Currency Conversion Rate
18914 , p_source_93 IN NUMBER
18915 --Currency Conversion Type
18916 , p_source_94 IN VARCHAR2
18917 --Accounted Amount
18918 , p_source_95 IN NUMBER
18919 --Accounting Line Type
18920 , p_source_97 IN NUMBER
18921 )
18922 IS
18923
18924 l_component_type VARCHAR2(80);
18925 l_component_code VARCHAR2(30);
18926 l_component_type_code VARCHAR2(1);
18927 l_component_appl_id INTEGER;
18928 l_amb_context_code VARCHAR2(30);
18929 l_entity_code VARCHAR2(30);
18930 l_event_class_code VARCHAR2(30);
18931 l_ae_header_id NUMBER;
18932 l_event_type_code VARCHAR2(30);
18933 l_line_definition_code VARCHAR2(30);
18934 l_line_definition_owner_code VARCHAR2(1);
18935 --
18936 -- adr variables
18937 l_segment VARCHAR2(30);
18938 l_ccid NUMBER;
18939 l_adr_transaction_coa_id NUMBER;
18940 l_adr_accounting_coa_id NUMBER;
18941 l_adr_flexfield_segment_code VARCHAR2(30);
18942 l_adr_flex_value_set_id NUMBER;
18943 l_adr_value_type_code VARCHAR2(30);
18944 l_adr_value_combination_id NUMBER;
18945 l_adr_value_segment_code VARCHAR2(30);
18946
18947 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18948 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18949 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18950 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18951
18952 -- 4262811 Variables ------------------------------------------------------------------------------------------
18953 l_entered_amt_idx NUMBER;
18954 l_accted_amt_idx NUMBER;
18955 l_acc_rev_flag VARCHAR2(1);
18956 l_accrual_line_num NUMBER;
18957 l_tmp_amt NUMBER;
18958 l_acc_rev_natural_side_code VARCHAR2(1);
18959
18960 l_num_entries NUMBER;
18961 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18962 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18963 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18964 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18965 l_recog_line_1 NUMBER;
18966 l_recog_line_2 NUMBER;
18967
18968 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18969 l_bflow_applied_to_amt NUMBER; -- 5132302
18970 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18971
18972 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18973
18974 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18975 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18976
18977 ---------------------------------------------------------------------------------------------------------------
18978
18979
18980 --
18981 -- bulk performance
18982 --
18983 l_balance_type_code VARCHAR2(1);
18984 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18985 l_log_module VARCHAR2(240);
18986
18987 --
18988 -- Upgrade strategy
18989 --
18990 l_actual_upg_option VARCHAR2(1);
18991 l_enc_upg_option VARCHAR2(1);
18992
18993 --
18994 BEGIN
18995 --
18996 IF g_log_enabled THEN
18997 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_60';
18998 END IF;
18999 --
19000 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19001
19002 trace
19003 (p_msg => 'BEGIN of AcctLineType_60'
19004 ,p_level => C_LEVEL_PROCEDURE
19005 ,p_module => l_log_module);
19006
19007 END IF;
19008 --
19009 l_component_type := 'AMB_JLT';
19010 l_component_code := 'COST_OF_GOODS_SOLD';
19011 l_component_type_code := 'S';
19012 l_component_appl_id := 707;
19013 l_amb_context_code := 'DEFAULT';
19014 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
19015 l_event_class_code := 'SALES_ORDER';
19016 l_event_type_code := 'RMA_RCPT';
19017 l_line_definition_owner_code := 'S';
19018 l_line_definition_code := 'PI_RMA_RCPT';
19019 --
19020 l_balance_type_code := 'A';
19021 l_segment := NULL;
19022 l_ccid := NULL;
19023 l_adr_transaction_coa_id := NULL;
19024 l_adr_accounting_coa_id := NULL;
19025 l_adr_flexfield_segment_code := NULL;
19026 l_adr_flex_value_set_id := NULL;
19027 l_adr_value_type_code := NULL;
19028 l_adr_value_combination_id := NULL;
19029 l_adr_value_segment_code := NULL;
19030
19031 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19032 l_bflow_class_code := ''; -- 4219869 Business Flow
19033 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19034 l_budgetary_control_flag := 'N';
19035
19036 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19037 l_bflow_applied_to_amt := NULL; -- 5132302
19038 l_entered_amt_idx := NULL; -- 4262811
19039 l_accted_amt_idx := NULL; -- 4262811
19040 l_acc_rev_flag := NULL; -- 4262811
19041 l_accrual_line_num := NULL; -- 4262811
19042 l_tmp_amt := NULL; -- 4262811
19043 --
19044
19045 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19046 l_balance_type_code <> 'B' THEN
19047 IF NVL(p_source_97,9E125) = 35
19048 THEN
19049
19050 --
19051 XLA_AE_LINES_PKG.SetNewLine;
19052
19053 p_balance_type_code := l_balance_type_code;
19054 -- set the flag so later we will know whether the gain loss line needs to be created
19055
19056 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19057 p_actual_flag :='A';
19058 END IF;
19059
19060 --
19061 -- bulk performance
19062 --
19063 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19064 p_header_num => 0); -- 4262811
19065 --
19066 -- set accounting line options
19067 --
19068 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19069 p_natural_side_code => 'D'
19070 , p_gain_or_loss_flag => 'N'
19071 , p_gl_transfer_mode_code => 'S'
19072 , p_acct_entry_type_code => 'A'
19073 , p_switch_side_flag => 'Y'
19074 , p_merge_duplicate_code => 'N'
19075 );
19076 --
19077 l_acc_rev_natural_side_code := 'C'; -- 4262811
19078 --
19079 --
19080 -- set accounting line type info
19081 --
19082 xla_ae_lines_pkg.SetAcctLineType
19083 (p_component_type => l_component_type
19084 ,p_event_type_code => l_event_type_code
19085 ,p_line_definition_owner_code => l_line_definition_owner_code
19086 ,p_line_definition_code => l_line_definition_code
19087 ,p_accounting_line_code => l_component_code
19088 ,p_accounting_line_type_code => l_component_type_code
19089 ,p_accounting_line_appl_id => l_component_appl_id
19090 ,p_amb_context_code => l_amb_context_code
19091 ,p_entity_code => l_entity_code
19092 ,p_event_class_code => l_event_class_code);
19093 --
19094 -- set accounting class
19095 --
19096 xla_ae_lines_pkg.SetAcctClass(
19097 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
19098 , p_ae_header_id => l_ae_header_id
19099 );
19100
19101 --
19102 -- set rounding class
19103 --
19104 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19105 'COST_OF_GOODS_SOLD';
19106
19107 --
19108 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19109 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19110 --
19111 -- bulk performance
19112 --
19113 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19114
19115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19116 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19117
19118 -- 4955764
19119 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19120 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19121
19122 -- 4458381 Public Sector Enh
19123
19124 --
19125 -- set accounting attributes for the line type
19126 --
19127 l_entered_amt_idx := 3;
19128 l_accted_amt_idx := 8;
19129 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19130 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19131 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
19132 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19133 l_rec_acct_attrs.array_char_value(2) := p_source_85;
19134 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19135 l_rec_acct_attrs.array_num_value(3) := p_source_91;
19136 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19137 l_rec_acct_attrs.array_char_value(4) := p_source_88;
19138 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19139 l_rec_acct_attrs.array_date_value(5) := p_source_92;
19140 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19141 l_rec_acct_attrs.array_num_value(6) := p_source_93;
19142 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19143 l_rec_acct_attrs.array_char_value(7) := p_source_94;
19144 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19145 l_rec_acct_attrs.array_num_value(8) := p_source_95;
19146
19147 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19148 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19149
19150 ---------------------------------------------------------------------------------------------------------------
19151 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19152 ---------------------------------------------------------------------------------------------------------------
19153 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19154
19155 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19156 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19157
19158 IF xla_accounting_cache_pkg.GetValueChar
19159 (p_source_code => 'LEDGER_CATEGORY_CODE'
19160 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19161 AND l_bflow_method_code = 'PRIOR_ENTRY'
19162 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19163 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19164 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19165 )
19166 THEN
19167 xla_ae_lines_pkg.BflowUpgEntry
19168 (p_business_method_code => l_bflow_method_code
19169 ,p_business_class_code => l_bflow_class_code
19170 ,p_balance_type => l_balance_type_code);
19171 ELSE
19172 NULL;
19173 -- No business flow processing for business flow method of NONE.
19174 END IF;
19175
19176 --
19177 -- call analytical criteria
19178 --
19179
19180 --
19181 -- call description
19182 --
19183
19184 xla_ae_lines_pkg.SetLineDescription(
19185 p_ae_header_id => l_ae_header_id
19186 ,p_description => Description_1 (
19187 p_application_id => p_application_id
19188 , p_ae_header_id => l_ae_header_id
19189 , p_source_1 => p_source_1
19190 , p_source_2 => p_source_2
19191 , p_source_3 => p_source_3
19192 , p_source_4 => p_source_4
19193 , p_source_5 => p_source_5
19194 )
19195 );
19196
19197
19198 --
19199 -- call ADRs
19200 -- Bug 4922099
19201 --
19202 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19203 (NVL(l_actual_upg_option, 'N') = 'O') OR
19204 (NVL(l_enc_upg_option, 'N') = 'O')
19205 )
19206 THEN
19207 NULL;
19208 --
19209 --
19210
19211 l_ccid := AcctDerRule_6(
19212 p_application_id => p_application_id
19213 , p_ae_header_id => l_ae_header_id
19214 , p_source_11 => p_source_11
19215 , x_transaction_coa_id => l_adr_transaction_coa_id
19216 , x_accounting_coa_id => l_adr_accounting_coa_id
19217 , x_value_type_code => l_adr_value_type_code
19218 , p_side => 'NA'
19219 );
19220
19221 xla_ae_lines_pkg.set_ccid(
19222 p_code_combination_id => l_ccid
19223 , p_value_type_code => l_adr_value_type_code
19224 , p_transaction_coa_id => l_adr_transaction_coa_id
19225 , p_accounting_coa_id => l_adr_accounting_coa_id
19226 , p_adr_code => 'CST_DEFAULT'
19227 , p_adr_type_code => 'S'
19228 , p_component_type => l_component_type
19229 , p_component_code => l_component_code
19230 , p_component_type_code => l_component_type_code
19231 , p_component_appl_id => l_component_appl_id
19232 , p_amb_context_code => l_amb_context_code
19233 , p_side => 'NA'
19234 );
19235
19236
19237 --
19238 --
19239 END IF;
19240 --
19241 -- Bug 4922099
19242 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19243 (NVL(l_enc_upg_option, 'N') = 'O')
19244 ) AND
19245 (l_bflow_method_code = 'PRIOR_ENTRY')
19246 )
19247 THEN
19248 IF
19249 --
19250 1 = 2
19251 --
19252 THEN
19253 xla_accounting_err_pkg.build_message
19254 (p_appli_s_name => 'XLA'
19255 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19256 ,p_token_1 => 'LINE_NUMBER'
19257 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19258 ,p_token_2 => 'LINE_TYPE_NAME'
19259 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19260 l_component_type
19261 ,l_component_code
19262 ,l_component_type_code
19263 ,l_component_appl_id
19264 ,l_amb_context_code
19265 ,l_entity_code
19266 ,l_event_class_code
19267 )
19268 ,p_token_3 => 'OWNER'
19269 ,p_value_3 => xla_lookups_pkg.get_meaning(
19270 p_lookup_type => 'XLA_OWNER_TYPE'
19271 ,p_lookup_code => l_component_type_code
19272 )
19273 ,p_token_4 => 'PRODUCT_NAME'
19274 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19275 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19276 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19277 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19278 ,p_ae_header_id => NULL
19279 );
19280
19281 IF (C_LEVEL_ERROR>= g_log_level) THEN
19282 trace
19283 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19284 ,p_level => C_LEVEL_ERROR
19285 ,p_module => l_log_module);
19286 END IF;
19287 END IF;
19288 END IF;
19289 --
19290 --
19291 ------------------------------------------------------------------------------------------------
19292 -- 4219869 Business Flow
19293 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19294 -- Prior Entry. Currently, the following code is always generated.
19295 ------------------------------------------------------------------------------------------------
19296 XLA_AE_LINES_PKG.ValidateCurrentLine;
19297
19298 ------------------------------------------------------------------------------------
19299 -- 4219869 Business Flow
19300 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19301 ------------------------------------------------------------------------------------
19302 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19303
19304 ----------------------------------------------------------------------------------
19305 -- 4219869 Business Flow
19306 -- Update journal entry status -- Need to generate this within IF <condition>
19307 ----------------------------------------------------------------------------------
19308 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19309 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19310 ,p_balance_type_code => l_balance_type_code
19311 );
19312
19313 -------------------------------------------------------------------------------------------
19314 -- 4262811 - Generate the Accrual Reversal lines
19315 -------------------------------------------------------------------------------------------
19316 BEGIN
19317 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19318 (g_array_event(p_event_id).array_value_num('header_index'));
19319 IF l_acc_rev_flag IS NULL THEN
19320 l_acc_rev_flag := 'N';
19321 END IF;
19322 EXCEPTION
19323 WHEN OTHERS THEN
19324 l_acc_rev_flag := 'N';
19325 END;
19326 --
19327 IF (l_acc_rev_flag = 'Y') THEN
19328
19329 -- 4645092 ------------------------------------------------------------------------------
19330 -- To allow MPA report to determine if it should generate report process
19331 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19332 ------------------------------------------------------------------------------------------
19333
19334 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19335 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19336 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19337 -- call ADRs
19338 -- Bug 4922099
19339 --
19340 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19341 (NVL(l_actual_upg_option, 'N') = 'O') OR
19342 (NVL(l_enc_upg_option, 'N') = 'O')
19343 )
19344 THEN
19345 NULL;
19346 --
19347 --
19348
19349 l_ccid := AcctDerRule_6(
19350 p_application_id => p_application_id
19351 , p_ae_header_id => l_ae_header_id
19352 , p_source_11 => p_source_11
19353 , x_transaction_coa_id => l_adr_transaction_coa_id
19354 , x_accounting_coa_id => l_adr_accounting_coa_id
19355 , x_value_type_code => l_adr_value_type_code
19356 , p_side => 'NA'
19357 );
19358
19359 xla_ae_lines_pkg.set_ccid(
19360 p_code_combination_id => l_ccid
19361 , p_value_type_code => l_adr_value_type_code
19362 , p_transaction_coa_id => l_adr_transaction_coa_id
19363 , p_accounting_coa_id => l_adr_accounting_coa_id
19364 , p_adr_code => 'CST_DEFAULT'
19365 , p_adr_type_code => 'S'
19366 , p_component_type => l_component_type
19367 , p_component_code => l_component_code
19368 , p_component_type_code => l_component_type_code
19369 , p_component_appl_id => l_component_appl_id
19370 , p_amb_context_code => l_amb_context_code
19371 , p_side => 'NA'
19372 );
19373
19374
19375 --
19376 --
19377 END IF;
19378
19379 --
19380 -- Update the line information that should be overwritten
19381 --
19382 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19383 p_header_num => 1);
19384 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19385
19386 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19387
19388 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19389 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19390 END IF;
19391
19392 --
19393 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19394 --
19395 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19396 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19397 ELSE
19398 ---------------------------------------------------------------------------------------------------
19399 -- 4262811a Switch Sign
19400 ---------------------------------------------------------------------------------------------------
19401 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19402 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19403 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19404 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19405 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19406 -- 5132302
19407 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19408 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19409
19410 END IF;
19411
19412 -- 4955764
19413 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19414 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19415
19416
19417 XLA_AE_LINES_PKG.ValidateCurrentLine;
19418 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19419
19420 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19421 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19422 ,p_balance_type_code => l_balance_type_code);
19423
19424 END IF;
19425
19426 -----------------------------------------------------------------------------------------
19427 -- 4262811 Multiperiod Accounting
19428 -----------------------------------------------------------------------------------------
19429 -- No MPA option is assigned.
19430
19431
19432 END IF;
19433 END IF;
19434 --
19435
19436 --
19437 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19438 trace
19439 (p_msg => 'END of AcctLineType_60'
19440 ,p_level => C_LEVEL_PROCEDURE
19441 ,p_module => l_log_module);
19442 END IF;
19443 --
19444 EXCEPTION
19445 WHEN xla_exceptions_pkg.application_exception THEN
19446 RAISE;
19447 WHEN OTHERS THEN
19448 xla_exceptions_pkg.raise_message
19449 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_60');
19450 END AcctLineType_60;
19451 --
19452
19453 ---------------------------------------
19454 --
19455 -- PRIVATE FUNCTION
19456 -- AcctLineType_61
19457 --
19458 ---------------------------------------
19459 PROCEDURE AcctLineType_61 (
19460 p_application_id IN NUMBER
19461 ,p_event_id IN NUMBER
19462 ,p_calculate_acctd_flag IN VARCHAR2
19463 ,p_calculate_g_l_flag IN VARCHAR2
19464 ,p_actual_flag IN OUT VARCHAR2
19465 ,p_balance_type_code OUT VARCHAR2
19466 ,p_gain_or_loss_ref OUT VARCHAR2
19467
19468 --TRANSACTION_ID
19469 , p_source_1 IN NUMBER
19470 --Item Concatenated Segments
19471 , p_source_2 IN VARCHAR2
19472 --Transaction Quantity
19473 , p_source_3 IN NUMBER
19474 --Transaction Unit of Measure Code
19475 , p_source_4 IN VARCHAR2
19476 --Inventory Transaction Type Description
19477 , p_source_5 IN VARCHAR2
19478 --Cost Management Default Account
19479 , p_source_11 IN NUMBER
19480 --DISTRIBUTION_IDENTIFIER
19481 , p_source_84 IN NUMBER
19482 --Distribution Type
19483 , p_source_85 IN VARCHAR2
19484 , p_source_85_meaning IN VARCHAR2
19485 --Entered Currency Code
19486 , p_source_88 IN VARCHAR2
19487 --Entered Amount
19488 , p_source_91 IN NUMBER
19489 --Currency Conversion Date
19490 , p_source_92 IN DATE
19491 --Currency Conversion Rate
19492 , p_source_93 IN NUMBER
19493 --Currency Conversion Type
19494 , p_source_94 IN VARCHAR2
19495 --Accounted Amount
19496 , p_source_95 IN NUMBER
19497 --Accounting Line Type
19498 , p_source_97 IN NUMBER
19499 )
19500 IS
19501
19502 l_component_type VARCHAR2(80);
19503 l_component_code VARCHAR2(30);
19504 l_component_type_code VARCHAR2(1);
19505 l_component_appl_id INTEGER;
19506 l_amb_context_code VARCHAR2(30);
19507 l_entity_code VARCHAR2(30);
19508 l_event_class_code VARCHAR2(30);
19509 l_ae_header_id NUMBER;
19510 l_event_type_code VARCHAR2(30);
19511 l_line_definition_code VARCHAR2(30);
19512 l_line_definition_owner_code VARCHAR2(1);
19513 --
19514 -- adr variables
19515 l_segment VARCHAR2(30);
19516 l_ccid NUMBER;
19517 l_adr_transaction_coa_id NUMBER;
19518 l_adr_accounting_coa_id NUMBER;
19519 l_adr_flexfield_segment_code VARCHAR2(30);
19520 l_adr_flex_value_set_id NUMBER;
19521 l_adr_value_type_code VARCHAR2(30);
19522 l_adr_value_combination_id NUMBER;
19523 l_adr_value_segment_code VARCHAR2(30);
19524
19525 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19526 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19527 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19528 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19529
19530 -- 4262811 Variables ------------------------------------------------------------------------------------------
19531 l_entered_amt_idx NUMBER;
19532 l_accted_amt_idx NUMBER;
19533 l_acc_rev_flag VARCHAR2(1);
19534 l_accrual_line_num NUMBER;
19535 l_tmp_amt NUMBER;
19536 l_acc_rev_natural_side_code VARCHAR2(1);
19537
19538 l_num_entries NUMBER;
19539 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19540 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19541 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19542 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19543 l_recog_line_1 NUMBER;
19544 l_recog_line_2 NUMBER;
19545
19546 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19547 l_bflow_applied_to_amt NUMBER; -- 5132302
19548 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19549
19550 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19551
19552 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19553 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19554
19555 ---------------------------------------------------------------------------------------------------------------
19556
19557
19558 --
19559 -- bulk performance
19560 --
19561 l_balance_type_code VARCHAR2(1);
19562 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19563 l_log_module VARCHAR2(240);
19564
19565 --
19566 -- Upgrade strategy
19567 --
19568 l_actual_upg_option VARCHAR2(1);
19569 l_enc_upg_option VARCHAR2(1);
19570
19571 --
19572 BEGIN
19573 --
19574 IF g_log_enabled THEN
19575 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_61';
19576 END IF;
19577 --
19578 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19579
19580 trace
19581 (p_msg => 'BEGIN of AcctLineType_61'
19582 ,p_level => C_LEVEL_PROCEDURE
19583 ,p_module => l_log_module);
19584
19585 END IF;
19586 --
19587 l_component_type := 'AMB_JLT';
19588 l_component_code := 'COST_OF_GOODS_SOLD';
19589 l_component_type_code := 'S';
19590 l_component_appl_id := 707;
19591 l_amb_context_code := 'DEFAULT';
19592 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
19593 l_event_class_code := 'SALES_ORDER';
19594 l_event_type_code := 'LOG_RMA_RCPT';
19595 l_line_definition_owner_code := 'S';
19596 l_line_definition_code := 'PI_LOG_RMA_RCPT';
19597 --
19598 l_balance_type_code := 'A';
19599 l_segment := NULL;
19600 l_ccid := NULL;
19601 l_adr_transaction_coa_id := NULL;
19602 l_adr_accounting_coa_id := NULL;
19603 l_adr_flexfield_segment_code := NULL;
19604 l_adr_flex_value_set_id := NULL;
19605 l_adr_value_type_code := NULL;
19606 l_adr_value_combination_id := NULL;
19607 l_adr_value_segment_code := NULL;
19608
19609 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19610 l_bflow_class_code := ''; -- 4219869 Business Flow
19611 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19612 l_budgetary_control_flag := 'N';
19613
19614 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19615 l_bflow_applied_to_amt := NULL; -- 5132302
19616 l_entered_amt_idx := NULL; -- 4262811
19617 l_accted_amt_idx := NULL; -- 4262811
19618 l_acc_rev_flag := NULL; -- 4262811
19619 l_accrual_line_num := NULL; -- 4262811
19620 l_tmp_amt := NULL; -- 4262811
19621 --
19622
19623 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19624 l_balance_type_code <> 'B' THEN
19625 IF NVL(p_source_97,9E125) = 35
19626 THEN
19627
19628 --
19629 XLA_AE_LINES_PKG.SetNewLine;
19630
19631 p_balance_type_code := l_balance_type_code;
19632 -- set the flag so later we will know whether the gain loss line needs to be created
19633
19634 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19635 p_actual_flag :='A';
19636 END IF;
19637
19638 --
19639 -- bulk performance
19640 --
19641 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19642 p_header_num => 0); -- 4262811
19643 --
19644 -- set accounting line options
19645 --
19646 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19647 p_natural_side_code => 'D'
19648 , p_gain_or_loss_flag => 'N'
19649 , p_gl_transfer_mode_code => 'S'
19650 , p_acct_entry_type_code => 'A'
19651 , p_switch_side_flag => 'Y'
19652 , p_merge_duplicate_code => 'N'
19653 );
19654 --
19655 l_acc_rev_natural_side_code := 'C'; -- 4262811
19656 --
19657 --
19658 -- set accounting line type info
19659 --
19660 xla_ae_lines_pkg.SetAcctLineType
19661 (p_component_type => l_component_type
19662 ,p_event_type_code => l_event_type_code
19663 ,p_line_definition_owner_code => l_line_definition_owner_code
19664 ,p_line_definition_code => l_line_definition_code
19665 ,p_accounting_line_code => l_component_code
19666 ,p_accounting_line_type_code => l_component_type_code
19667 ,p_accounting_line_appl_id => l_component_appl_id
19668 ,p_amb_context_code => l_amb_context_code
19669 ,p_entity_code => l_entity_code
19670 ,p_event_class_code => l_event_class_code);
19671 --
19672 -- set accounting class
19673 --
19674 xla_ae_lines_pkg.SetAcctClass(
19675 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
19676 , p_ae_header_id => l_ae_header_id
19677 );
19678
19679 --
19680 -- set rounding class
19681 --
19682 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19683 'COST_OF_GOODS_SOLD';
19684
19685 --
19686 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19687 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19688 --
19689 -- bulk performance
19690 --
19691 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19692
19693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19694 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19695
19696 -- 4955764
19697 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19698 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19699
19700 -- 4458381 Public Sector Enh
19701
19702 --
19703 -- set accounting attributes for the line type
19704 --
19705 l_entered_amt_idx := 3;
19706 l_accted_amt_idx := 8;
19707 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19708 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19709 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
19710 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19711 l_rec_acct_attrs.array_char_value(2) := p_source_85;
19712 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19713 l_rec_acct_attrs.array_num_value(3) := p_source_91;
19714 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19715 l_rec_acct_attrs.array_char_value(4) := p_source_88;
19716 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19717 l_rec_acct_attrs.array_date_value(5) := p_source_92;
19718 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19719 l_rec_acct_attrs.array_num_value(6) := p_source_93;
19720 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19721 l_rec_acct_attrs.array_char_value(7) := p_source_94;
19722 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19723 l_rec_acct_attrs.array_num_value(8) := p_source_95;
19724
19725 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19726 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19727
19728 ---------------------------------------------------------------------------------------------------------------
19729 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19730 ---------------------------------------------------------------------------------------------------------------
19731 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19732
19733 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19734 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19735
19736 IF xla_accounting_cache_pkg.GetValueChar
19737 (p_source_code => 'LEDGER_CATEGORY_CODE'
19738 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19739 AND l_bflow_method_code = 'PRIOR_ENTRY'
19740 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19741 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19742 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19743 )
19744 THEN
19745 xla_ae_lines_pkg.BflowUpgEntry
19746 (p_business_method_code => l_bflow_method_code
19747 ,p_business_class_code => l_bflow_class_code
19748 ,p_balance_type => l_balance_type_code);
19749 ELSE
19750 NULL;
19751 -- No business flow processing for business flow method of NONE.
19752 END IF;
19753
19754 --
19755 -- call analytical criteria
19756 --
19757
19758 --
19759 -- call description
19760 --
19761
19762 xla_ae_lines_pkg.SetLineDescription(
19763 p_ae_header_id => l_ae_header_id
19764 ,p_description => Description_1 (
19765 p_application_id => p_application_id
19766 , p_ae_header_id => l_ae_header_id
19767 , p_source_1 => p_source_1
19768 , p_source_2 => p_source_2
19769 , p_source_3 => p_source_3
19770 , p_source_4 => p_source_4
19771 , p_source_5 => p_source_5
19772 )
19773 );
19774
19775
19776 --
19777 -- call ADRs
19778 -- Bug 4922099
19779 --
19780 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19781 (NVL(l_actual_upg_option, 'N') = 'O') OR
19782 (NVL(l_enc_upg_option, 'N') = 'O')
19783 )
19784 THEN
19785 NULL;
19786 --
19787 --
19788
19789 l_ccid := AcctDerRule_6(
19790 p_application_id => p_application_id
19791 , p_ae_header_id => l_ae_header_id
19792 , p_source_11 => p_source_11
19793 , x_transaction_coa_id => l_adr_transaction_coa_id
19794 , x_accounting_coa_id => l_adr_accounting_coa_id
19795 , x_value_type_code => l_adr_value_type_code
19796 , p_side => 'NA'
19797 );
19798
19799 xla_ae_lines_pkg.set_ccid(
19800 p_code_combination_id => l_ccid
19801 , p_value_type_code => l_adr_value_type_code
19802 , p_transaction_coa_id => l_adr_transaction_coa_id
19803 , p_accounting_coa_id => l_adr_accounting_coa_id
19804 , p_adr_code => 'CST_DEFAULT'
19805 , p_adr_type_code => 'S'
19806 , p_component_type => l_component_type
19807 , p_component_code => l_component_code
19808 , p_component_type_code => l_component_type_code
19809 , p_component_appl_id => l_component_appl_id
19810 , p_amb_context_code => l_amb_context_code
19811 , p_side => 'NA'
19812 );
19813
19814
19815 --
19816 --
19817 END IF;
19818 --
19819 -- Bug 4922099
19820 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19821 (NVL(l_enc_upg_option, 'N') = 'O')
19822 ) AND
19823 (l_bflow_method_code = 'PRIOR_ENTRY')
19824 )
19825 THEN
19826 IF
19827 --
19828 1 = 2
19829 --
19830 THEN
19831 xla_accounting_err_pkg.build_message
19832 (p_appli_s_name => 'XLA'
19833 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19834 ,p_token_1 => 'LINE_NUMBER'
19835 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19836 ,p_token_2 => 'LINE_TYPE_NAME'
19837 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19838 l_component_type
19839 ,l_component_code
19840 ,l_component_type_code
19841 ,l_component_appl_id
19842 ,l_amb_context_code
19843 ,l_entity_code
19844 ,l_event_class_code
19845 )
19846 ,p_token_3 => 'OWNER'
19847 ,p_value_3 => xla_lookups_pkg.get_meaning(
19848 p_lookup_type => 'XLA_OWNER_TYPE'
19849 ,p_lookup_code => l_component_type_code
19850 )
19851 ,p_token_4 => 'PRODUCT_NAME'
19852 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19853 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19854 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19855 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19856 ,p_ae_header_id => NULL
19857 );
19858
19859 IF (C_LEVEL_ERROR>= g_log_level) THEN
19860 trace
19861 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19862 ,p_level => C_LEVEL_ERROR
19863 ,p_module => l_log_module);
19864 END IF;
19865 END IF;
19866 END IF;
19867 --
19868 --
19869 ------------------------------------------------------------------------------------------------
19870 -- 4219869 Business Flow
19871 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19872 -- Prior Entry. Currently, the following code is always generated.
19873 ------------------------------------------------------------------------------------------------
19874 XLA_AE_LINES_PKG.ValidateCurrentLine;
19875
19876 ------------------------------------------------------------------------------------
19877 -- 4219869 Business Flow
19878 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19879 ------------------------------------------------------------------------------------
19880 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19881
19882 ----------------------------------------------------------------------------------
19883 -- 4219869 Business Flow
19884 -- Update journal entry status -- Need to generate this within IF <condition>
19885 ----------------------------------------------------------------------------------
19886 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19887 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19888 ,p_balance_type_code => l_balance_type_code
19889 );
19890
19891 -------------------------------------------------------------------------------------------
19892 -- 4262811 - Generate the Accrual Reversal lines
19893 -------------------------------------------------------------------------------------------
19894 BEGIN
19895 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19896 (g_array_event(p_event_id).array_value_num('header_index'));
19897 IF l_acc_rev_flag IS NULL THEN
19898 l_acc_rev_flag := 'N';
19899 END IF;
19900 EXCEPTION
19901 WHEN OTHERS THEN
19902 l_acc_rev_flag := 'N';
19903 END;
19904 --
19905 IF (l_acc_rev_flag = 'Y') THEN
19906
19907 -- 4645092 ------------------------------------------------------------------------------
19908 -- To allow MPA report to determine if it should generate report process
19909 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19910 ------------------------------------------------------------------------------------------
19911
19912 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19913 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19914 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19915 -- call ADRs
19916 -- Bug 4922099
19917 --
19918 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19919 (NVL(l_actual_upg_option, 'N') = 'O') OR
19920 (NVL(l_enc_upg_option, 'N') = 'O')
19921 )
19922 THEN
19923 NULL;
19924 --
19925 --
19926
19927 l_ccid := AcctDerRule_6(
19928 p_application_id => p_application_id
19929 , p_ae_header_id => l_ae_header_id
19930 , p_source_11 => p_source_11
19931 , x_transaction_coa_id => l_adr_transaction_coa_id
19932 , x_accounting_coa_id => l_adr_accounting_coa_id
19933 , x_value_type_code => l_adr_value_type_code
19934 , p_side => 'NA'
19935 );
19936
19937 xla_ae_lines_pkg.set_ccid(
19938 p_code_combination_id => l_ccid
19939 , p_value_type_code => l_adr_value_type_code
19940 , p_transaction_coa_id => l_adr_transaction_coa_id
19941 , p_accounting_coa_id => l_adr_accounting_coa_id
19942 , p_adr_code => 'CST_DEFAULT'
19943 , p_adr_type_code => 'S'
19944 , p_component_type => l_component_type
19945 , p_component_code => l_component_code
19946 , p_component_type_code => l_component_type_code
19947 , p_component_appl_id => l_component_appl_id
19948 , p_amb_context_code => l_amb_context_code
19949 , p_side => 'NA'
19950 );
19951
19952
19953 --
19954 --
19955 END IF;
19956
19957 --
19958 -- Update the line information that should be overwritten
19959 --
19960 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19961 p_header_num => 1);
19962 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19963
19964 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19965
19966 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19967 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19968 END IF;
19969
19970 --
19971 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19972 --
19973 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19974 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19975 ELSE
19976 ---------------------------------------------------------------------------------------------------
19977 -- 4262811a Switch Sign
19978 ---------------------------------------------------------------------------------------------------
19979 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19982 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19983 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19984 -- 5132302
19985 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19986 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19987
19988 END IF;
19989
19990 -- 4955764
19991 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19992 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19993
19994
19995 XLA_AE_LINES_PKG.ValidateCurrentLine;
19996 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19997
19998 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19999 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20000 ,p_balance_type_code => l_balance_type_code);
20001
20002 END IF;
20003
20004 -----------------------------------------------------------------------------------------
20005 -- 4262811 Multiperiod Accounting
20006 -----------------------------------------------------------------------------------------
20007 -- No MPA option is assigned.
20008
20009
20010 END IF;
20011 END IF;
20012 --
20013
20014 --
20015 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20016 trace
20017 (p_msg => 'END of AcctLineType_61'
20018 ,p_level => C_LEVEL_PROCEDURE
20019 ,p_module => l_log_module);
20020 END IF;
20021 --
20022 EXCEPTION
20023 WHEN xla_exceptions_pkg.application_exception THEN
20024 RAISE;
20025 WHEN OTHERS THEN
20026 xla_exceptions_pkg.raise_message
20027 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_61');
20028 END AcctLineType_61;
20029 --
20030
20031 ---------------------------------------
20032 --
20033 -- PRIVATE FUNCTION
20034 -- AcctLineType_62
20035 --
20036 ---------------------------------------
20037 PROCEDURE AcctLineType_62 (
20038 p_application_id IN NUMBER
20039 ,p_event_id IN NUMBER
20040 ,p_calculate_acctd_flag IN VARCHAR2
20041 ,p_calculate_g_l_flag IN VARCHAR2
20042 ,p_actual_flag IN OUT VARCHAR2
20043 ,p_balance_type_code OUT VARCHAR2
20044 ,p_gain_or_loss_ref OUT VARCHAR2
20045
20046 --TRANSACTION_ID
20047 , p_source_1 IN NUMBER
20048 --Item Concatenated Segments
20049 , p_source_2 IN VARCHAR2
20050 --Transaction Quantity
20051 , p_source_3 IN NUMBER
20052 --Transaction Unit of Measure Code
20053 , p_source_4 IN VARCHAR2
20054 --Inventory Transaction Type Description
20055 , p_source_5 IN VARCHAR2
20056 --Cost Management Default Account
20057 , p_source_11 IN NUMBER
20058 --DISTRIBUTION_IDENTIFIER
20059 , p_source_84 IN NUMBER
20060 --Distribution Type
20061 , p_source_85 IN VARCHAR2
20062 , p_source_85_meaning IN VARCHAR2
20063 --Entered Currency Code
20064 , p_source_88 IN VARCHAR2
20065 --Entered Amount
20066 , p_source_91 IN NUMBER
20067 --Currency Conversion Date
20068 , p_source_92 IN DATE
20069 --Currency Conversion Rate
20070 , p_source_93 IN NUMBER
20071 --Currency Conversion Type
20072 , p_source_94 IN VARCHAR2
20073 --Accounted Amount
20074 , p_source_95 IN NUMBER
20075 --Accounting Line Type
20076 , p_source_97 IN NUMBER
20077 )
20078 IS
20079
20080 l_component_type VARCHAR2(80);
20081 l_component_code VARCHAR2(30);
20082 l_component_type_code VARCHAR2(1);
20083 l_component_appl_id INTEGER;
20084 l_amb_context_code VARCHAR2(30);
20085 l_entity_code VARCHAR2(30);
20086 l_event_class_code VARCHAR2(30);
20087 l_ae_header_id NUMBER;
20088 l_event_type_code VARCHAR2(30);
20089 l_line_definition_code VARCHAR2(30);
20090 l_line_definition_owner_code VARCHAR2(1);
20091 --
20092 -- adr variables
20093 l_segment VARCHAR2(30);
20094 l_ccid NUMBER;
20095 l_adr_transaction_coa_id NUMBER;
20096 l_adr_accounting_coa_id NUMBER;
20097 l_adr_flexfield_segment_code VARCHAR2(30);
20098 l_adr_flex_value_set_id NUMBER;
20099 l_adr_value_type_code VARCHAR2(30);
20100 l_adr_value_combination_id NUMBER;
20101 l_adr_value_segment_code VARCHAR2(30);
20102
20103 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20104 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20105 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20106 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20107
20108 -- 4262811 Variables ------------------------------------------------------------------------------------------
20109 l_entered_amt_idx NUMBER;
20110 l_accted_amt_idx NUMBER;
20111 l_acc_rev_flag VARCHAR2(1);
20112 l_accrual_line_num NUMBER;
20113 l_tmp_amt NUMBER;
20114 l_acc_rev_natural_side_code VARCHAR2(1);
20115
20116 l_num_entries NUMBER;
20117 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20118 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20119 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20120 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20121 l_recog_line_1 NUMBER;
20122 l_recog_line_2 NUMBER;
20123
20124 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20125 l_bflow_applied_to_amt NUMBER; -- 5132302
20126 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20127
20128 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20129
20130 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20131 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20132
20133 ---------------------------------------------------------------------------------------------------------------
20134
20135
20136 --
20137 -- bulk performance
20138 --
20139 l_balance_type_code VARCHAR2(1);
20140 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20141 l_log_module VARCHAR2(240);
20142
20143 --
20144 -- Upgrade strategy
20145 --
20146 l_actual_upg_option VARCHAR2(1);
20147 l_enc_upg_option VARCHAR2(1);
20148
20149 --
20150 BEGIN
20151 --
20152 IF g_log_enabled THEN
20153 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_62';
20154 END IF;
20155 --
20156 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20157
20158 trace
20159 (p_msg => 'BEGIN of AcctLineType_62'
20160 ,p_level => C_LEVEL_PROCEDURE
20161 ,p_module => l_log_module);
20162
20163 END IF;
20164 --
20165 l_component_type := 'AMB_JLT';
20166 l_component_code := 'COST_OF_GOODS_SOLD';
20167 l_component_type_code := 'S';
20168 l_component_appl_id := 707;
20169 l_amb_context_code := 'DEFAULT';
20170 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
20171 l_event_class_code := 'SALES_ORDER';
20172 l_event_type_code := 'SO_ISSUE';
20173 l_line_definition_owner_code := 'S';
20174 l_line_definition_code := 'PI_SO_ISSUE';
20175 --
20176 l_balance_type_code := 'A';
20177 l_segment := NULL;
20178 l_ccid := NULL;
20179 l_adr_transaction_coa_id := NULL;
20180 l_adr_accounting_coa_id := NULL;
20181 l_adr_flexfield_segment_code := NULL;
20182 l_adr_flex_value_set_id := NULL;
20183 l_adr_value_type_code := NULL;
20184 l_adr_value_combination_id := NULL;
20185 l_adr_value_segment_code := NULL;
20186
20187 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20188 l_bflow_class_code := ''; -- 4219869 Business Flow
20189 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20190 l_budgetary_control_flag := 'N';
20191
20192 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20193 l_bflow_applied_to_amt := NULL; -- 5132302
20194 l_entered_amt_idx := NULL; -- 4262811
20195 l_accted_amt_idx := NULL; -- 4262811
20196 l_acc_rev_flag := NULL; -- 4262811
20197 l_accrual_line_num := NULL; -- 4262811
20198 l_tmp_amt := NULL; -- 4262811
20199 --
20200
20201 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20202 l_balance_type_code <> 'B' THEN
20203 IF NVL(p_source_97,9E125) = 35
20204 THEN
20205
20206 --
20207 XLA_AE_LINES_PKG.SetNewLine;
20208
20209 p_balance_type_code := l_balance_type_code;
20210 -- set the flag so later we will know whether the gain loss line needs to be created
20211
20212 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20213 p_actual_flag :='A';
20214 END IF;
20215
20216 --
20217 -- bulk performance
20218 --
20219 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20220 p_header_num => 0); -- 4262811
20221 --
20222 -- set accounting line options
20223 --
20224 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20225 p_natural_side_code => 'D'
20226 , p_gain_or_loss_flag => 'N'
20227 , p_gl_transfer_mode_code => 'S'
20228 , p_acct_entry_type_code => 'A'
20229 , p_switch_side_flag => 'Y'
20230 , p_merge_duplicate_code => 'N'
20231 );
20232 --
20233 l_acc_rev_natural_side_code := 'C'; -- 4262811
20234 --
20235 --
20236 -- set accounting line type info
20237 --
20238 xla_ae_lines_pkg.SetAcctLineType
20239 (p_component_type => l_component_type
20240 ,p_event_type_code => l_event_type_code
20241 ,p_line_definition_owner_code => l_line_definition_owner_code
20242 ,p_line_definition_code => l_line_definition_code
20243 ,p_accounting_line_code => l_component_code
20244 ,p_accounting_line_type_code => l_component_type_code
20245 ,p_accounting_line_appl_id => l_component_appl_id
20246 ,p_amb_context_code => l_amb_context_code
20247 ,p_entity_code => l_entity_code
20248 ,p_event_class_code => l_event_class_code);
20249 --
20250 -- set accounting class
20251 --
20252 xla_ae_lines_pkg.SetAcctClass(
20253 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
20254 , p_ae_header_id => l_ae_header_id
20255 );
20256
20257 --
20258 -- set rounding class
20259 --
20260 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20261 'COST_OF_GOODS_SOLD';
20262
20263 --
20264 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20265 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20266 --
20267 -- bulk performance
20268 --
20269 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20270
20271 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20272 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20273
20274 -- 4955764
20275 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20276 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20277
20278 -- 4458381 Public Sector Enh
20279
20280 --
20281 -- set accounting attributes for the line type
20282 --
20283 l_entered_amt_idx := 3;
20284 l_accted_amt_idx := 8;
20285 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20286 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20287 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
20288 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20289 l_rec_acct_attrs.array_char_value(2) := p_source_85;
20290 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20291 l_rec_acct_attrs.array_num_value(3) := p_source_91;
20292 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20293 l_rec_acct_attrs.array_char_value(4) := p_source_88;
20294 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20295 l_rec_acct_attrs.array_date_value(5) := p_source_92;
20296 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20297 l_rec_acct_attrs.array_num_value(6) := p_source_93;
20298 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20299 l_rec_acct_attrs.array_char_value(7) := p_source_94;
20300 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20301 l_rec_acct_attrs.array_num_value(8) := p_source_95;
20302
20303 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20304 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20305
20306 ---------------------------------------------------------------------------------------------------------------
20307 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20308 ---------------------------------------------------------------------------------------------------------------
20309 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20310
20311 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20312 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20313
20314 IF xla_accounting_cache_pkg.GetValueChar
20315 (p_source_code => 'LEDGER_CATEGORY_CODE'
20316 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20317 AND l_bflow_method_code = 'PRIOR_ENTRY'
20318 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20319 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20320 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20321 )
20322 THEN
20323 xla_ae_lines_pkg.BflowUpgEntry
20324 (p_business_method_code => l_bflow_method_code
20325 ,p_business_class_code => l_bflow_class_code
20326 ,p_balance_type => l_balance_type_code);
20327 ELSE
20328 NULL;
20329 -- No business flow processing for business flow method of NONE.
20330 END IF;
20331
20332 --
20333 -- call analytical criteria
20334 --
20335
20336 --
20337 -- call description
20338 --
20339
20340 xla_ae_lines_pkg.SetLineDescription(
20341 p_ae_header_id => l_ae_header_id
20342 ,p_description => Description_1 (
20343 p_application_id => p_application_id
20344 , p_ae_header_id => l_ae_header_id
20345 , p_source_1 => p_source_1
20346 , p_source_2 => p_source_2
20347 , p_source_3 => p_source_3
20348 , p_source_4 => p_source_4
20349 , p_source_5 => p_source_5
20350 )
20351 );
20352
20353
20354 --
20355 -- call ADRs
20356 -- Bug 4922099
20357 --
20358 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20359 (NVL(l_actual_upg_option, 'N') = 'O') OR
20360 (NVL(l_enc_upg_option, 'N') = 'O')
20361 )
20362 THEN
20363 NULL;
20364 --
20365 --
20366
20367 l_ccid := AcctDerRule_6(
20368 p_application_id => p_application_id
20369 , p_ae_header_id => l_ae_header_id
20370 , p_source_11 => p_source_11
20371 , x_transaction_coa_id => l_adr_transaction_coa_id
20372 , x_accounting_coa_id => l_adr_accounting_coa_id
20373 , x_value_type_code => l_adr_value_type_code
20374 , p_side => 'NA'
20375 );
20376
20377 xla_ae_lines_pkg.set_ccid(
20378 p_code_combination_id => l_ccid
20379 , p_value_type_code => l_adr_value_type_code
20380 , p_transaction_coa_id => l_adr_transaction_coa_id
20381 , p_accounting_coa_id => l_adr_accounting_coa_id
20382 , p_adr_code => 'CST_DEFAULT'
20383 , p_adr_type_code => 'S'
20384 , p_component_type => l_component_type
20385 , p_component_code => l_component_code
20386 , p_component_type_code => l_component_type_code
20387 , p_component_appl_id => l_component_appl_id
20388 , p_amb_context_code => l_amb_context_code
20389 , p_side => 'NA'
20390 );
20391
20392
20393 --
20394 --
20395 END IF;
20396 --
20397 -- Bug 4922099
20398 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20399 (NVL(l_enc_upg_option, 'N') = 'O')
20400 ) AND
20401 (l_bflow_method_code = 'PRIOR_ENTRY')
20402 )
20403 THEN
20404 IF
20405 --
20406 1 = 2
20407 --
20408 THEN
20409 xla_accounting_err_pkg.build_message
20410 (p_appli_s_name => 'XLA'
20411 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20412 ,p_token_1 => 'LINE_NUMBER'
20413 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20414 ,p_token_2 => 'LINE_TYPE_NAME'
20415 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20416 l_component_type
20417 ,l_component_code
20418 ,l_component_type_code
20419 ,l_component_appl_id
20420 ,l_amb_context_code
20421 ,l_entity_code
20422 ,l_event_class_code
20423 )
20424 ,p_token_3 => 'OWNER'
20425 ,p_value_3 => xla_lookups_pkg.get_meaning(
20426 p_lookup_type => 'XLA_OWNER_TYPE'
20427 ,p_lookup_code => l_component_type_code
20428 )
20429 ,p_token_4 => 'PRODUCT_NAME'
20430 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20431 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20432 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20433 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20434 ,p_ae_header_id => NULL
20435 );
20436
20437 IF (C_LEVEL_ERROR>= g_log_level) THEN
20438 trace
20439 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20440 ,p_level => C_LEVEL_ERROR
20441 ,p_module => l_log_module);
20442 END IF;
20443 END IF;
20444 END IF;
20445 --
20446 --
20447 ------------------------------------------------------------------------------------------------
20448 -- 4219869 Business Flow
20449 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20450 -- Prior Entry. Currently, the following code is always generated.
20451 ------------------------------------------------------------------------------------------------
20452 XLA_AE_LINES_PKG.ValidateCurrentLine;
20453
20454 ------------------------------------------------------------------------------------
20455 -- 4219869 Business Flow
20456 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20457 ------------------------------------------------------------------------------------
20458 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20459
20460 ----------------------------------------------------------------------------------
20461 -- 4219869 Business Flow
20462 -- Update journal entry status -- Need to generate this within IF <condition>
20463 ----------------------------------------------------------------------------------
20464 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20465 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20466 ,p_balance_type_code => l_balance_type_code
20467 );
20468
20469 -------------------------------------------------------------------------------------------
20470 -- 4262811 - Generate the Accrual Reversal lines
20471 -------------------------------------------------------------------------------------------
20472 BEGIN
20473 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20474 (g_array_event(p_event_id).array_value_num('header_index'));
20475 IF l_acc_rev_flag IS NULL THEN
20476 l_acc_rev_flag := 'N';
20477 END IF;
20478 EXCEPTION
20479 WHEN OTHERS THEN
20480 l_acc_rev_flag := 'N';
20481 END;
20482 --
20483 IF (l_acc_rev_flag = 'Y') THEN
20484
20485 -- 4645092 ------------------------------------------------------------------------------
20486 -- To allow MPA report to determine if it should generate report process
20487 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20488 ------------------------------------------------------------------------------------------
20489
20490 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20491 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20492 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20493 -- call ADRs
20494 -- Bug 4922099
20495 --
20496 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20497 (NVL(l_actual_upg_option, 'N') = 'O') OR
20498 (NVL(l_enc_upg_option, 'N') = 'O')
20499 )
20500 THEN
20501 NULL;
20502 --
20503 --
20504
20505 l_ccid := AcctDerRule_6(
20506 p_application_id => p_application_id
20507 , p_ae_header_id => l_ae_header_id
20508 , p_source_11 => p_source_11
20509 , x_transaction_coa_id => l_adr_transaction_coa_id
20510 , x_accounting_coa_id => l_adr_accounting_coa_id
20511 , x_value_type_code => l_adr_value_type_code
20512 , p_side => 'NA'
20513 );
20514
20515 xla_ae_lines_pkg.set_ccid(
20516 p_code_combination_id => l_ccid
20517 , p_value_type_code => l_adr_value_type_code
20518 , p_transaction_coa_id => l_adr_transaction_coa_id
20519 , p_accounting_coa_id => l_adr_accounting_coa_id
20520 , p_adr_code => 'CST_DEFAULT'
20521 , p_adr_type_code => 'S'
20522 , p_component_type => l_component_type
20523 , p_component_code => l_component_code
20524 , p_component_type_code => l_component_type_code
20525 , p_component_appl_id => l_component_appl_id
20526 , p_amb_context_code => l_amb_context_code
20527 , p_side => 'NA'
20528 );
20529
20530
20531 --
20532 --
20533 END IF;
20534
20535 --
20536 -- Update the line information that should be overwritten
20537 --
20538 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20539 p_header_num => 1);
20540 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20541
20542 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20543
20544 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20545 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20546 END IF;
20547
20548 --
20549 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20550 --
20551 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20552 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20553 ELSE
20554 ---------------------------------------------------------------------------------------------------
20555 -- 4262811a Switch Sign
20556 ---------------------------------------------------------------------------------------------------
20557 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20558 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20559 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20560 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20561 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20562 -- 5132302
20563 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20564 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20565
20566 END IF;
20567
20568 -- 4955764
20569 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20570 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20571
20572
20573 XLA_AE_LINES_PKG.ValidateCurrentLine;
20574 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20575
20576 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20577 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20578 ,p_balance_type_code => l_balance_type_code);
20579
20580 END IF;
20581
20582 -----------------------------------------------------------------------------------------
20583 -- 4262811 Multiperiod Accounting
20584 -----------------------------------------------------------------------------------------
20585 -- No MPA option is assigned.
20586
20587
20588 END IF;
20589 END IF;
20590 --
20591
20592 --
20593 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20594 trace
20595 (p_msg => 'END of AcctLineType_62'
20596 ,p_level => C_LEVEL_PROCEDURE
20597 ,p_module => l_log_module);
20598 END IF;
20599 --
20600 EXCEPTION
20601 WHEN xla_exceptions_pkg.application_exception THEN
20602 RAISE;
20603 WHEN OTHERS THEN
20604 xla_exceptions_pkg.raise_message
20605 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_62');
20606 END AcctLineType_62;
20607 --
20608
20609 ---------------------------------------
20610 --
20611 -- PRIVATE FUNCTION
20612 -- AcctLineType_63
20613 --
20614 ---------------------------------------
20615 PROCEDURE AcctLineType_63 (
20616 p_application_id IN NUMBER
20617 ,p_event_id IN NUMBER
20618 ,p_calculate_acctd_flag IN VARCHAR2
20619 ,p_calculate_g_l_flag IN VARCHAR2
20620 ,p_actual_flag IN OUT VARCHAR2
20621 ,p_balance_type_code OUT VARCHAR2
20622 ,p_gain_or_loss_ref OUT VARCHAR2
20623
20624 --Cost Management Default Account
20625 , p_source_11 IN NUMBER
20626 --DISTRIBUTION_IDENTIFIER
20627 , p_source_84 IN NUMBER
20628 --Distribution Type
20629 , p_source_85 IN VARCHAR2
20630 , p_source_85_meaning IN VARCHAR2
20631 --Entered Currency Code
20632 , p_source_88 IN VARCHAR2
20633 --Entered Amount
20634 , p_source_91 IN NUMBER
20635 --Currency Conversion Date
20636 , p_source_92 IN DATE
20637 --Currency Conversion Rate
20638 , p_source_93 IN NUMBER
20639 --Currency Conversion Type
20640 , p_source_94 IN VARCHAR2
20641 --Accounted Amount
20642 , p_source_95 IN NUMBER
20643 --Accounting Line Type
20644 , p_source_97 IN NUMBER
20645 )
20646 IS
20647
20648 l_component_type VARCHAR2(80);
20649 l_component_code VARCHAR2(30);
20650 l_component_type_code VARCHAR2(1);
20651 l_component_appl_id INTEGER;
20652 l_amb_context_code VARCHAR2(30);
20653 l_entity_code VARCHAR2(30);
20654 l_event_class_code VARCHAR2(30);
20655 l_ae_header_id NUMBER;
20656 l_event_type_code VARCHAR2(30);
20657 l_line_definition_code VARCHAR2(30);
20658 l_line_definition_owner_code VARCHAR2(1);
20659 --
20660 -- adr variables
20661 l_segment VARCHAR2(30);
20662 l_ccid NUMBER;
20663 l_adr_transaction_coa_id NUMBER;
20664 l_adr_accounting_coa_id NUMBER;
20665 l_adr_flexfield_segment_code VARCHAR2(30);
20666 l_adr_flex_value_set_id NUMBER;
20667 l_adr_value_type_code VARCHAR2(30);
20668 l_adr_value_combination_id NUMBER;
20669 l_adr_value_segment_code VARCHAR2(30);
20670
20671 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20672 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20673 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20674 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20675
20676 -- 4262811 Variables ------------------------------------------------------------------------------------------
20677 l_entered_amt_idx NUMBER;
20678 l_accted_amt_idx NUMBER;
20679 l_acc_rev_flag VARCHAR2(1);
20680 l_accrual_line_num NUMBER;
20681 l_tmp_amt NUMBER;
20682 l_acc_rev_natural_side_code VARCHAR2(1);
20683
20684 l_num_entries NUMBER;
20685 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20686 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20687 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20688 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20689 l_recog_line_1 NUMBER;
20690 l_recog_line_2 NUMBER;
20691
20692 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20693 l_bflow_applied_to_amt NUMBER; -- 5132302
20694 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20695
20696 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20697
20698 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20699 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20700
20701 ---------------------------------------------------------------------------------------------------------------
20702
20703
20704 --
20705 -- bulk performance
20706 --
20707 l_balance_type_code VARCHAR2(1);
20708 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20709 l_log_module VARCHAR2(240);
20710
20711 --
20712 -- Upgrade strategy
20713 --
20714 l_actual_upg_option VARCHAR2(1);
20715 l_enc_upg_option VARCHAR2(1);
20716
20717 --
20718 BEGIN
20719 --
20720 IF g_log_enabled THEN
20721 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_63';
20722 END IF;
20723 --
20724 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20725
20726 trace
20727 (p_msg => 'BEGIN of AcctLineType_63'
20728 ,p_level => C_LEVEL_PROCEDURE
20729 ,p_module => l_log_module);
20730
20731 END IF;
20732 --
20733 l_component_type := 'AMB_JLT';
20734 l_component_code := 'COST_OF_GOODS_SOLD';
20735 l_component_type_code := 'S';
20736 l_component_appl_id := 707;
20737 l_amb_context_code := 'DEFAULT';
20738 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
20739 l_event_class_code := 'SALES_ORDER';
20740 l_event_type_code := 'COGS_RECOGNITION';
20741 l_line_definition_owner_code := 'S';
20742 l_line_definition_code := 'PI_COGS_RECOGNITION';
20743 --
20744 l_balance_type_code := 'A';
20745 l_segment := NULL;
20746 l_ccid := NULL;
20747 l_adr_transaction_coa_id := NULL;
20748 l_adr_accounting_coa_id := NULL;
20749 l_adr_flexfield_segment_code := NULL;
20750 l_adr_flex_value_set_id := NULL;
20751 l_adr_value_type_code := NULL;
20752 l_adr_value_combination_id := NULL;
20753 l_adr_value_segment_code := NULL;
20754
20755 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20756 l_bflow_class_code := ''; -- 4219869 Business Flow
20757 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20758 l_budgetary_control_flag := 'N';
20759
20760 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20761 l_bflow_applied_to_amt := NULL; -- 5132302
20762 l_entered_amt_idx := NULL; -- 4262811
20763 l_accted_amt_idx := NULL; -- 4262811
20764 l_acc_rev_flag := NULL; -- 4262811
20765 l_accrual_line_num := NULL; -- 4262811
20766 l_tmp_amt := NULL; -- 4262811
20767 --
20768
20769 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20770 l_balance_type_code <> 'B' THEN
20771 IF NVL(p_source_97,9E125) = 35
20772 THEN
20773
20774 --
20775 XLA_AE_LINES_PKG.SetNewLine;
20776
20777 p_balance_type_code := l_balance_type_code;
20778 -- set the flag so later we will know whether the gain loss line needs to be created
20779
20780 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20781 p_actual_flag :='A';
20782 END IF;
20783
20784 --
20785 -- bulk performance
20786 --
20787 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20788 p_header_num => 0); -- 4262811
20789 --
20790 -- set accounting line options
20791 --
20792 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20793 p_natural_side_code => 'D'
20794 , p_gain_or_loss_flag => 'N'
20795 , p_gl_transfer_mode_code => 'S'
20796 , p_acct_entry_type_code => 'A'
20797 , p_switch_side_flag => 'Y'
20798 , p_merge_duplicate_code => 'N'
20799 );
20800 --
20801 l_acc_rev_natural_side_code := 'C'; -- 4262811
20802 --
20803 --
20804 -- set accounting line type info
20805 --
20806 xla_ae_lines_pkg.SetAcctLineType
20807 (p_component_type => l_component_type
20808 ,p_event_type_code => l_event_type_code
20809 ,p_line_definition_owner_code => l_line_definition_owner_code
20810 ,p_line_definition_code => l_line_definition_code
20811 ,p_accounting_line_code => l_component_code
20812 ,p_accounting_line_type_code => l_component_type_code
20813 ,p_accounting_line_appl_id => l_component_appl_id
20814 ,p_amb_context_code => l_amb_context_code
20815 ,p_entity_code => l_entity_code
20816 ,p_event_class_code => l_event_class_code);
20817 --
20818 -- set accounting class
20819 --
20820 xla_ae_lines_pkg.SetAcctClass(
20821 p_accounting_class_code => 'COST_OF_GOODS_SOLD'
20822 , p_ae_header_id => l_ae_header_id
20823 );
20824
20825 --
20826 -- set rounding class
20827 --
20828 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20829 'COST_OF_GOODS_SOLD';
20830
20831 --
20832 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20833 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20834 --
20835 -- bulk performance
20836 --
20837 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20838
20839 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20840 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20841
20842 -- 4955764
20843 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20844 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20845
20846 -- 4458381 Public Sector Enh
20847
20848 --
20849 -- set accounting attributes for the line type
20850 --
20851 l_entered_amt_idx := 3;
20852 l_accted_amt_idx := 8;
20853 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20854 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20855 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
20856 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20857 l_rec_acct_attrs.array_char_value(2) := p_source_85;
20858 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20859 l_rec_acct_attrs.array_num_value(3) := p_source_91;
20860 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20861 l_rec_acct_attrs.array_char_value(4) := p_source_88;
20862 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20863 l_rec_acct_attrs.array_date_value(5) := p_source_92;
20864 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20865 l_rec_acct_attrs.array_num_value(6) := p_source_93;
20866 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20867 l_rec_acct_attrs.array_char_value(7) := p_source_94;
20868 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20869 l_rec_acct_attrs.array_num_value(8) := p_source_95;
20870
20871 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20872 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20873
20874 ---------------------------------------------------------------------------------------------------------------
20875 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20876 ---------------------------------------------------------------------------------------------------------------
20877 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20878
20879 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20880 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20881
20882 IF xla_accounting_cache_pkg.GetValueChar
20883 (p_source_code => 'LEDGER_CATEGORY_CODE'
20884 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20885 AND l_bflow_method_code = 'PRIOR_ENTRY'
20886 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20887 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20888 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20889 )
20890 THEN
20891 xla_ae_lines_pkg.BflowUpgEntry
20892 (p_business_method_code => l_bflow_method_code
20893 ,p_business_class_code => l_bflow_class_code
20894 ,p_balance_type => l_balance_type_code);
20895 ELSE
20896 NULL;
20897 -- No business flow processing for business flow method of NONE.
20898 END IF;
20899
20900 --
20901 -- call analytical criteria
20902 --
20903
20904 --
20905 -- call description
20906 --
20907 -- No description or it is inherited.
20908 --
20909 -- call ADRs
20910 -- Bug 4922099
20911 --
20912 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20913 (NVL(l_actual_upg_option, 'N') = 'O') OR
20914 (NVL(l_enc_upg_option, 'N') = 'O')
20915 )
20916 THEN
20917 NULL;
20918 --
20919 --
20920
20921 l_ccid := AcctDerRule_6(
20922 p_application_id => p_application_id
20923 , p_ae_header_id => l_ae_header_id
20924 , p_source_11 => p_source_11
20925 , x_transaction_coa_id => l_adr_transaction_coa_id
20926 , x_accounting_coa_id => l_adr_accounting_coa_id
20927 , x_value_type_code => l_adr_value_type_code
20928 , p_side => 'NA'
20929 );
20930
20931 xla_ae_lines_pkg.set_ccid(
20932 p_code_combination_id => l_ccid
20933 , p_value_type_code => l_adr_value_type_code
20934 , p_transaction_coa_id => l_adr_transaction_coa_id
20935 , p_accounting_coa_id => l_adr_accounting_coa_id
20936 , p_adr_code => 'CST_DEFAULT'
20937 , p_adr_type_code => 'S'
20938 , p_component_type => l_component_type
20939 , p_component_code => l_component_code
20940 , p_component_type_code => l_component_type_code
20941 , p_component_appl_id => l_component_appl_id
20942 , p_amb_context_code => l_amb_context_code
20943 , p_side => 'NA'
20944 );
20945
20946
20947 --
20948 --
20949 END IF;
20950 --
20951 -- Bug 4922099
20952 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20953 (NVL(l_enc_upg_option, 'N') = 'O')
20954 ) AND
20955 (l_bflow_method_code = 'PRIOR_ENTRY')
20956 )
20957 THEN
20958 IF
20959 --
20960 1 = 2
20961 --
20962 THEN
20963 xla_accounting_err_pkg.build_message
20964 (p_appli_s_name => 'XLA'
20965 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20966 ,p_token_1 => 'LINE_NUMBER'
20967 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20968 ,p_token_2 => 'LINE_TYPE_NAME'
20969 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20970 l_component_type
20971 ,l_component_code
20972 ,l_component_type_code
20973 ,l_component_appl_id
20974 ,l_amb_context_code
20975 ,l_entity_code
20976 ,l_event_class_code
20977 )
20978 ,p_token_3 => 'OWNER'
20979 ,p_value_3 => xla_lookups_pkg.get_meaning(
20980 p_lookup_type => 'XLA_OWNER_TYPE'
20981 ,p_lookup_code => l_component_type_code
20982 )
20983 ,p_token_4 => 'PRODUCT_NAME'
20984 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20985 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20986 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20987 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20988 ,p_ae_header_id => NULL
20989 );
20990
20991 IF (C_LEVEL_ERROR>= g_log_level) THEN
20992 trace
20993 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20994 ,p_level => C_LEVEL_ERROR
20995 ,p_module => l_log_module);
20996 END IF;
20997 END IF;
20998 END IF;
20999 --
21000 --
21001 ------------------------------------------------------------------------------------------------
21002 -- 4219869 Business Flow
21003 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21004 -- Prior Entry. Currently, the following code is always generated.
21005 ------------------------------------------------------------------------------------------------
21006 XLA_AE_LINES_PKG.ValidateCurrentLine;
21007
21008 ------------------------------------------------------------------------------------
21009 -- 4219869 Business Flow
21010 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21011 ------------------------------------------------------------------------------------
21012 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21013
21014 ----------------------------------------------------------------------------------
21015 -- 4219869 Business Flow
21016 -- Update journal entry status -- Need to generate this within IF <condition>
21017 ----------------------------------------------------------------------------------
21018 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21019 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21020 ,p_balance_type_code => l_balance_type_code
21021 );
21022
21023 -------------------------------------------------------------------------------------------
21024 -- 4262811 - Generate the Accrual Reversal lines
21025 -------------------------------------------------------------------------------------------
21026 BEGIN
21027 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21028 (g_array_event(p_event_id).array_value_num('header_index'));
21029 IF l_acc_rev_flag IS NULL THEN
21030 l_acc_rev_flag := 'N';
21031 END IF;
21032 EXCEPTION
21033 WHEN OTHERS THEN
21034 l_acc_rev_flag := 'N';
21035 END;
21036 --
21037 IF (l_acc_rev_flag = 'Y') THEN
21038
21039 -- 4645092 ------------------------------------------------------------------------------
21040 -- To allow MPA report to determine if it should generate report process
21041 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21042 ------------------------------------------------------------------------------------------
21043
21044 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21045 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21046 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21047 -- call ADRs
21048 -- Bug 4922099
21049 --
21050 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21051 (NVL(l_actual_upg_option, 'N') = 'O') OR
21052 (NVL(l_enc_upg_option, 'N') = 'O')
21053 )
21054 THEN
21055 NULL;
21056 --
21057 --
21058
21059 l_ccid := AcctDerRule_6(
21060 p_application_id => p_application_id
21061 , p_ae_header_id => l_ae_header_id
21062 , p_source_11 => p_source_11
21063 , x_transaction_coa_id => l_adr_transaction_coa_id
21064 , x_accounting_coa_id => l_adr_accounting_coa_id
21065 , x_value_type_code => l_adr_value_type_code
21066 , p_side => 'NA'
21067 );
21068
21069 xla_ae_lines_pkg.set_ccid(
21070 p_code_combination_id => l_ccid
21071 , p_value_type_code => l_adr_value_type_code
21072 , p_transaction_coa_id => l_adr_transaction_coa_id
21073 , p_accounting_coa_id => l_adr_accounting_coa_id
21074 , p_adr_code => 'CST_DEFAULT'
21075 , p_adr_type_code => 'S'
21076 , p_component_type => l_component_type
21077 , p_component_code => l_component_code
21078 , p_component_type_code => l_component_type_code
21079 , p_component_appl_id => l_component_appl_id
21080 , p_amb_context_code => l_amb_context_code
21081 , p_side => 'NA'
21082 );
21083
21084
21085 --
21086 --
21087 END IF;
21088
21089 --
21090 -- Update the line information that should be overwritten
21091 --
21092 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21093 p_header_num => 1);
21094 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21095
21096 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21097
21098 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21099 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21100 END IF;
21101
21102 --
21103 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21104 --
21105 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21106 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21107 ELSE
21108 ---------------------------------------------------------------------------------------------------
21109 -- 4262811a Switch Sign
21110 ---------------------------------------------------------------------------------------------------
21111 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21112 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21113 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21114 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21115 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21116 -- 5132302
21117 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21118 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21119
21120 END IF;
21121
21122 -- 4955764
21123 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21124 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21125
21126
21127 XLA_AE_LINES_PKG.ValidateCurrentLine;
21128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21129
21130 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21131 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21132 ,p_balance_type_code => l_balance_type_code);
21133
21134 END IF;
21135
21136 -----------------------------------------------------------------------------------------
21137 -- 4262811 Multiperiod Accounting
21138 -----------------------------------------------------------------------------------------
21139 -- No MPA option is assigned.
21140
21141
21142 END IF;
21143 END IF;
21144 --
21145
21146 --
21147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21148 trace
21149 (p_msg => 'END of AcctLineType_63'
21150 ,p_level => C_LEVEL_PROCEDURE
21151 ,p_module => l_log_module);
21152 END IF;
21153 --
21154 EXCEPTION
21155 WHEN xla_exceptions_pkg.application_exception THEN
21156 RAISE;
21157 WHEN OTHERS THEN
21158 xla_exceptions_pkg.raise_message
21159 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_63');
21160 END AcctLineType_63;
21161 --
21162
21163 ---------------------------------------
21164 --
21165 -- PRIVATE FUNCTION
21166 -- AcctLineType_64
21167 --
21168 ---------------------------------------
21169 PROCEDURE AcctLineType_64 (
21170 p_application_id IN NUMBER
21171 ,p_event_id IN NUMBER
21172 ,p_calculate_acctd_flag IN VARCHAR2
21173 ,p_calculate_g_l_flag IN VARCHAR2
21174 ,p_actual_flag IN OUT VARCHAR2
21175 ,p_balance_type_code OUT VARCHAR2
21176 ,p_gain_or_loss_ref OUT VARCHAR2
21177
21178 --TRANSACTION_ID
21179 , p_source_1 IN NUMBER
21180 --Item Concatenated Segments
21181 , p_source_2 IN VARCHAR2
21182 --Transaction Quantity
21183 , p_source_3 IN NUMBER
21184 --Transaction Unit of Measure Code
21185 , p_source_4 IN VARCHAR2
21186 --Inventory Transaction Type Description
21187 , p_source_5 IN VARCHAR2
21188 --Cost Management Default Account
21189 , p_source_11 IN NUMBER
21190 --DISTRIBUTION_IDENTIFIER
21191 , p_source_84 IN NUMBER
21192 --Distribution Type
21193 , p_source_85 IN VARCHAR2
21194 , p_source_85_meaning IN VARCHAR2
21195 --Entered Currency Code
21196 , p_source_88 IN VARCHAR2
21197 --Entered Amount
21198 , p_source_91 IN NUMBER
21199 --Currency Conversion Date
21200 , p_source_92 IN DATE
21201 --Currency Conversion Rate
21202 , p_source_93 IN NUMBER
21203 --Currency Conversion Type
21204 , p_source_94 IN VARCHAR2
21205 --Accounted Amount
21206 , p_source_95 IN NUMBER
21207 --Accounting Line Type
21208 , p_source_97 IN NUMBER
21209 )
21210 IS
21211
21212 l_component_type VARCHAR2(80);
21213 l_component_code VARCHAR2(30);
21214 l_component_type_code VARCHAR2(1);
21215 l_component_appl_id INTEGER;
21216 l_amb_context_code VARCHAR2(30);
21217 l_entity_code VARCHAR2(30);
21218 l_event_class_code VARCHAR2(30);
21219 l_ae_header_id NUMBER;
21220 l_event_type_code VARCHAR2(30);
21221 l_line_definition_code VARCHAR2(30);
21222 l_line_definition_owner_code VARCHAR2(1);
21223 --
21224 -- adr variables
21225 l_segment VARCHAR2(30);
21226 l_ccid NUMBER;
21227 l_adr_transaction_coa_id NUMBER;
21228 l_adr_accounting_coa_id NUMBER;
21229 l_adr_flexfield_segment_code VARCHAR2(30);
21230 l_adr_flex_value_set_id NUMBER;
21231 l_adr_value_type_code VARCHAR2(30);
21232 l_adr_value_combination_id NUMBER;
21233 l_adr_value_segment_code VARCHAR2(30);
21234
21235 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21236 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21237 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21238 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21239
21240 -- 4262811 Variables ------------------------------------------------------------------------------------------
21241 l_entered_amt_idx NUMBER;
21242 l_accted_amt_idx NUMBER;
21243 l_acc_rev_flag VARCHAR2(1);
21244 l_accrual_line_num NUMBER;
21245 l_tmp_amt NUMBER;
21246 l_acc_rev_natural_side_code VARCHAR2(1);
21247
21248 l_num_entries NUMBER;
21249 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21250 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21251 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21252 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21253 l_recog_line_1 NUMBER;
21254 l_recog_line_2 NUMBER;
21255
21256 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21257 l_bflow_applied_to_amt NUMBER; -- 5132302
21258 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21259
21260 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21261
21262 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21263 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21264
21265 ---------------------------------------------------------------------------------------------------------------
21266
21267
21268 --
21269 -- bulk performance
21270 --
21271 l_balance_type_code VARCHAR2(1);
21272 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21273 l_log_module VARCHAR2(240);
21274
21275 --
21276 -- Upgrade strategy
21277 --
21278 l_actual_upg_option VARCHAR2(1);
21279 l_enc_upg_option VARCHAR2(1);
21280
21281 --
21282 BEGIN
21283 --
21284 IF g_log_enabled THEN
21285 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_64';
21286 END IF;
21287 --
21288 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21289
21290 trace
21291 (p_msg => 'BEGIN of AcctLineType_64'
21292 ,p_level => C_LEVEL_PROCEDURE
21293 ,p_module => l_log_module);
21294
21295 END IF;
21296 --
21297 l_component_type := 'AMB_JLT';
21298 l_component_code := 'COST_UPDATE_ADJUSTMENT';
21299 l_component_type_code := 'S';
21300 l_component_appl_id := 707;
21301 l_amb_context_code := 'DEFAULT';
21302 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
21303 l_event_class_code := 'MTL_COST_UPD';
21304 l_event_type_code := 'LAYER_COST_UPD';
21305 l_line_definition_owner_code := 'S';
21306 l_line_definition_code := 'PI_LAYER_COST_UPDATE';
21307 --
21308 l_balance_type_code := 'A';
21309 l_segment := NULL;
21310 l_ccid := NULL;
21311 l_adr_transaction_coa_id := NULL;
21312 l_adr_accounting_coa_id := NULL;
21313 l_adr_flexfield_segment_code := NULL;
21314 l_adr_flex_value_set_id := NULL;
21315 l_adr_value_type_code := NULL;
21316 l_adr_value_combination_id := NULL;
21317 l_adr_value_segment_code := NULL;
21318
21319 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21320 l_bflow_class_code := ''; -- 4219869 Business Flow
21321 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21322 l_budgetary_control_flag := 'N';
21323
21324 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21325 l_bflow_applied_to_amt := NULL; -- 5132302
21326 l_entered_amt_idx := NULL; -- 4262811
21327 l_accted_amt_idx := NULL; -- 4262811
21328 l_acc_rev_flag := NULL; -- 4262811
21329 l_accrual_line_num := NULL; -- 4262811
21330 l_tmp_amt := NULL; -- 4262811
21331 --
21332
21333 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21334 l_balance_type_code <> 'B' THEN
21335 IF NVL(p_source_97,9E125) = 2
21336 THEN
21337
21338 --
21339 XLA_AE_LINES_PKG.SetNewLine;
21340
21341 p_balance_type_code := l_balance_type_code;
21342 -- set the flag so later we will know whether the gain loss line needs to be created
21343
21344 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21345 p_actual_flag :='A';
21346 END IF;
21347
21348 --
21349 -- bulk performance
21350 --
21351 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21352 p_header_num => 0); -- 4262811
21353 --
21354 -- set accounting line options
21355 --
21356 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21357 p_natural_side_code => 'D'
21358 , p_gain_or_loss_flag => 'N'
21359 , p_gl_transfer_mode_code => 'S'
21360 , p_acct_entry_type_code => 'A'
21361 , p_switch_side_flag => 'Y'
21362 , p_merge_duplicate_code => 'N'
21363 );
21364 --
21365 l_acc_rev_natural_side_code := 'C'; -- 4262811
21366 --
21367 --
21368 -- set accounting line type info
21369 --
21370 xla_ae_lines_pkg.SetAcctLineType
21371 (p_component_type => l_component_type
21372 ,p_event_type_code => l_event_type_code
21373 ,p_line_definition_owner_code => l_line_definition_owner_code
21374 ,p_line_definition_code => l_line_definition_code
21375 ,p_accounting_line_code => l_component_code
21376 ,p_accounting_line_type_code => l_component_type_code
21377 ,p_accounting_line_appl_id => l_component_appl_id
21378 ,p_amb_context_code => l_amb_context_code
21379 ,p_entity_code => l_entity_code
21380 ,p_event_class_code => l_event_class_code);
21381 --
21382 -- set accounting class
21383 --
21384 xla_ae_lines_pkg.SetAcctClass(
21385 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
21386 , p_ae_header_id => l_ae_header_id
21387 );
21388
21389 --
21390 -- set rounding class
21391 --
21392 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21393 'COST_UPDATE_ADJUSTMENT';
21394
21395 --
21396 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21397 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21398 --
21399 -- bulk performance
21400 --
21401 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21402
21403 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21404 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21405
21406 -- 4955764
21407 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21408 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21409
21410 -- 4458381 Public Sector Enh
21411
21412 --
21413 -- set accounting attributes for the line type
21414 --
21415 l_entered_amt_idx := 3;
21416 l_accted_amt_idx := 8;
21417 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21418 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21419 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
21420 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21421 l_rec_acct_attrs.array_char_value(2) := p_source_85;
21422 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21423 l_rec_acct_attrs.array_num_value(3) := p_source_91;
21424 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21425 l_rec_acct_attrs.array_char_value(4) := p_source_88;
21426 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21427 l_rec_acct_attrs.array_date_value(5) := p_source_92;
21428 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21429 l_rec_acct_attrs.array_num_value(6) := p_source_93;
21430 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21431 l_rec_acct_attrs.array_char_value(7) := p_source_94;
21432 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21433 l_rec_acct_attrs.array_num_value(8) := p_source_95;
21434
21435 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21436 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21437
21438 ---------------------------------------------------------------------------------------------------------------
21439 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21440 ---------------------------------------------------------------------------------------------------------------
21441 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21442
21443 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21444 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21445
21446 IF xla_accounting_cache_pkg.GetValueChar
21447 (p_source_code => 'LEDGER_CATEGORY_CODE'
21448 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21449 AND l_bflow_method_code = 'PRIOR_ENTRY'
21450 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21451 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21452 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21453 )
21454 THEN
21455 xla_ae_lines_pkg.BflowUpgEntry
21456 (p_business_method_code => l_bflow_method_code
21457 ,p_business_class_code => l_bflow_class_code
21458 ,p_balance_type => l_balance_type_code);
21459 ELSE
21460 NULL;
21461 -- No business flow processing for business flow method of NONE.
21462 END IF;
21463
21464 --
21465 -- call analytical criteria
21466 --
21467
21468 --
21469 -- call description
21470 --
21471
21472 xla_ae_lines_pkg.SetLineDescription(
21473 p_ae_header_id => l_ae_header_id
21474 ,p_description => Description_1 (
21475 p_application_id => p_application_id
21476 , p_ae_header_id => l_ae_header_id
21477 , p_source_1 => p_source_1
21478 , p_source_2 => p_source_2
21479 , p_source_3 => p_source_3
21480 , p_source_4 => p_source_4
21481 , p_source_5 => p_source_5
21482 )
21483 );
21484
21485
21486 --
21487 -- call ADRs
21488 -- Bug 4922099
21489 --
21490 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21491 (NVL(l_actual_upg_option, 'N') = 'O') OR
21492 (NVL(l_enc_upg_option, 'N') = 'O')
21493 )
21494 THEN
21495 NULL;
21496 --
21497 --
21498
21499 l_ccid := AcctDerRule_6(
21500 p_application_id => p_application_id
21501 , p_ae_header_id => l_ae_header_id
21502 , p_source_11 => p_source_11
21503 , x_transaction_coa_id => l_adr_transaction_coa_id
21504 , x_accounting_coa_id => l_adr_accounting_coa_id
21505 , x_value_type_code => l_adr_value_type_code
21506 , p_side => 'NA'
21507 );
21508
21509 xla_ae_lines_pkg.set_ccid(
21510 p_code_combination_id => l_ccid
21511 , p_value_type_code => l_adr_value_type_code
21512 , p_transaction_coa_id => l_adr_transaction_coa_id
21513 , p_accounting_coa_id => l_adr_accounting_coa_id
21514 , p_adr_code => 'CST_DEFAULT'
21515 , p_adr_type_code => 'S'
21516 , p_component_type => l_component_type
21517 , p_component_code => l_component_code
21518 , p_component_type_code => l_component_type_code
21519 , p_component_appl_id => l_component_appl_id
21520 , p_amb_context_code => l_amb_context_code
21521 , p_side => 'NA'
21522 );
21523
21524
21525 --
21526 --
21527 END IF;
21528 --
21529 -- Bug 4922099
21530 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
21531 (NVL(l_enc_upg_option, 'N') = 'O')
21532 ) AND
21533 (l_bflow_method_code = 'PRIOR_ENTRY')
21534 )
21535 THEN
21536 IF
21537 --
21538 1 = 2
21539 --
21540 THEN
21541 xla_accounting_err_pkg.build_message
21542 (p_appli_s_name => 'XLA'
21543 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21544 ,p_token_1 => 'LINE_NUMBER'
21545 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
21546 ,p_token_2 => 'LINE_TYPE_NAME'
21547 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
21548 l_component_type
21549 ,l_component_code
21550 ,l_component_type_code
21551 ,l_component_appl_id
21552 ,l_amb_context_code
21553 ,l_entity_code
21554 ,l_event_class_code
21555 )
21556 ,p_token_3 => 'OWNER'
21557 ,p_value_3 => xla_lookups_pkg.get_meaning(
21558 p_lookup_type => 'XLA_OWNER_TYPE'
21559 ,p_lookup_code => l_component_type_code
21560 )
21561 ,p_token_4 => 'PRODUCT_NAME'
21562 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
21563 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
21564 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
21565 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
21566 ,p_ae_header_id => NULL
21567 );
21568
21569 IF (C_LEVEL_ERROR>= g_log_level) THEN
21570 trace
21571 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21572 ,p_level => C_LEVEL_ERROR
21573 ,p_module => l_log_module);
21574 END IF;
21575 END IF;
21576 END IF;
21577 --
21578 --
21579 ------------------------------------------------------------------------------------------------
21580 -- 4219869 Business Flow
21581 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21582 -- Prior Entry. Currently, the following code is always generated.
21583 ------------------------------------------------------------------------------------------------
21584 XLA_AE_LINES_PKG.ValidateCurrentLine;
21585
21586 ------------------------------------------------------------------------------------
21587 -- 4219869 Business Flow
21588 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21589 ------------------------------------------------------------------------------------
21590 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21591
21592 ----------------------------------------------------------------------------------
21593 -- 4219869 Business Flow
21594 -- Update journal entry status -- Need to generate this within IF <condition>
21595 ----------------------------------------------------------------------------------
21596 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21597 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21598 ,p_balance_type_code => l_balance_type_code
21599 );
21600
21601 -------------------------------------------------------------------------------------------
21602 -- 4262811 - Generate the Accrual Reversal lines
21603 -------------------------------------------------------------------------------------------
21604 BEGIN
21605 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21606 (g_array_event(p_event_id).array_value_num('header_index'));
21607 IF l_acc_rev_flag IS NULL THEN
21608 l_acc_rev_flag := 'N';
21609 END IF;
21610 EXCEPTION
21611 WHEN OTHERS THEN
21612 l_acc_rev_flag := 'N';
21613 END;
21614 --
21615 IF (l_acc_rev_flag = 'Y') THEN
21616
21617 -- 4645092 ------------------------------------------------------------------------------
21618 -- To allow MPA report to determine if it should generate report process
21619 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21620 ------------------------------------------------------------------------------------------
21621
21622 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21623 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21624 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21625 -- call ADRs
21626 -- Bug 4922099
21627 --
21628 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21629 (NVL(l_actual_upg_option, 'N') = 'O') OR
21630 (NVL(l_enc_upg_option, 'N') = 'O')
21631 )
21632 THEN
21633 NULL;
21634 --
21635 --
21636
21637 l_ccid := AcctDerRule_6(
21638 p_application_id => p_application_id
21639 , p_ae_header_id => l_ae_header_id
21640 , p_source_11 => p_source_11
21641 , x_transaction_coa_id => l_adr_transaction_coa_id
21642 , x_accounting_coa_id => l_adr_accounting_coa_id
21643 , x_value_type_code => l_adr_value_type_code
21644 , p_side => 'NA'
21645 );
21646
21647 xla_ae_lines_pkg.set_ccid(
21648 p_code_combination_id => l_ccid
21649 , p_value_type_code => l_adr_value_type_code
21650 , p_transaction_coa_id => l_adr_transaction_coa_id
21651 , p_accounting_coa_id => l_adr_accounting_coa_id
21652 , p_adr_code => 'CST_DEFAULT'
21653 , p_adr_type_code => 'S'
21654 , p_component_type => l_component_type
21655 , p_component_code => l_component_code
21656 , p_component_type_code => l_component_type_code
21657 , p_component_appl_id => l_component_appl_id
21658 , p_amb_context_code => l_amb_context_code
21659 , p_side => 'NA'
21660 );
21661
21662
21663 --
21664 --
21665 END IF;
21666
21667 --
21668 -- Update the line information that should be overwritten
21669 --
21670 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21671 p_header_num => 1);
21672 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21673
21674 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21675
21676 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21677 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21678 END IF;
21679
21680 --
21681 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21682 --
21683 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21684 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21685 ELSE
21686 ---------------------------------------------------------------------------------------------------
21687 -- 4262811a Switch Sign
21688 ---------------------------------------------------------------------------------------------------
21689 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21690 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21691 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21692 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21693 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21694 -- 5132302
21695 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21696 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21697
21698 END IF;
21699
21700 -- 4955764
21701 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21702 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21703
21704
21705 XLA_AE_LINES_PKG.ValidateCurrentLine;
21706 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21707
21708 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21709 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21710 ,p_balance_type_code => l_balance_type_code);
21711
21712 END IF;
21713
21714 -----------------------------------------------------------------------------------------
21715 -- 4262811 Multiperiod Accounting
21716 -----------------------------------------------------------------------------------------
21717 -- No MPA option is assigned.
21718
21719
21720 END IF;
21721 END IF;
21722 --
21723
21724 --
21725 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21726 trace
21727 (p_msg => 'END of AcctLineType_64'
21728 ,p_level => C_LEVEL_PROCEDURE
21729 ,p_module => l_log_module);
21730 END IF;
21731 --
21732 EXCEPTION
21733 WHEN xla_exceptions_pkg.application_exception THEN
21734 RAISE;
21735 WHEN OTHERS THEN
21736 xla_exceptions_pkg.raise_message
21737 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_64');
21738 END AcctLineType_64;
21739 --
21740
21741 ---------------------------------------
21742 --
21743 -- PRIVATE FUNCTION
21744 -- AcctLineType_65
21745 --
21746 ---------------------------------------
21747 PROCEDURE AcctLineType_65 (
21748 p_application_id IN NUMBER
21749 ,p_event_id IN NUMBER
21750 ,p_calculate_acctd_flag IN VARCHAR2
21751 ,p_calculate_g_l_flag IN VARCHAR2
21752 ,p_actual_flag IN OUT VARCHAR2
21753 ,p_balance_type_code OUT VARCHAR2
21754 ,p_gain_or_loss_ref OUT VARCHAR2
21755
21756 --TRANSACTION_ID
21757 , p_source_1 IN NUMBER
21758 --Item Concatenated Segments
21759 , p_source_2 IN VARCHAR2
21760 --Transaction Quantity
21761 , p_source_3 IN NUMBER
21762 --Transaction Unit of Measure Code
21763 , p_source_4 IN VARCHAR2
21764 --Inventory Transaction Type Description
21765 , p_source_5 IN VARCHAR2
21766 --Cost Management Default Account
21767 , p_source_11 IN NUMBER
21768 --DISTRIBUTION_IDENTIFIER
21769 , p_source_84 IN NUMBER
21770 --Distribution Type
21771 , p_source_85 IN VARCHAR2
21772 , p_source_85_meaning IN VARCHAR2
21773 --Entered Currency Code
21774 , p_source_88 IN VARCHAR2
21775 --Entered Amount
21776 , p_source_91 IN NUMBER
21777 --Currency Conversion Date
21778 , p_source_92 IN DATE
21779 --Currency Conversion Rate
21780 , p_source_93 IN NUMBER
21781 --Currency Conversion Type
21782 , p_source_94 IN VARCHAR2
21783 --Accounted Amount
21784 , p_source_95 IN NUMBER
21785 --Accounting Line Type
21786 , p_source_97 IN NUMBER
21787 )
21788 IS
21789
21790 l_component_type VARCHAR2(80);
21791 l_component_code VARCHAR2(30);
21792 l_component_type_code VARCHAR2(1);
21793 l_component_appl_id INTEGER;
21794 l_amb_context_code VARCHAR2(30);
21795 l_entity_code VARCHAR2(30);
21796 l_event_class_code VARCHAR2(30);
21797 l_ae_header_id NUMBER;
21798 l_event_type_code VARCHAR2(30);
21799 l_line_definition_code VARCHAR2(30);
21800 l_line_definition_owner_code VARCHAR2(1);
21801 --
21802 -- adr variables
21803 l_segment VARCHAR2(30);
21804 l_ccid NUMBER;
21805 l_adr_transaction_coa_id NUMBER;
21806 l_adr_accounting_coa_id NUMBER;
21807 l_adr_flexfield_segment_code VARCHAR2(30);
21808 l_adr_flex_value_set_id NUMBER;
21809 l_adr_value_type_code VARCHAR2(30);
21810 l_adr_value_combination_id NUMBER;
21811 l_adr_value_segment_code VARCHAR2(30);
21812
21813 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21814 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21815 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21816 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21817
21818 -- 4262811 Variables ------------------------------------------------------------------------------------------
21819 l_entered_amt_idx NUMBER;
21820 l_accted_amt_idx NUMBER;
21821 l_acc_rev_flag VARCHAR2(1);
21822 l_accrual_line_num NUMBER;
21823 l_tmp_amt NUMBER;
21824 l_acc_rev_natural_side_code VARCHAR2(1);
21825
21826 l_num_entries NUMBER;
21827 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21828 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21829 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21830 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21831 l_recog_line_1 NUMBER;
21832 l_recog_line_2 NUMBER;
21833
21834 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21835 l_bflow_applied_to_amt NUMBER; -- 5132302
21836 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21837
21838 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21839
21840 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21841 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21842
21843 ---------------------------------------------------------------------------------------------------------------
21844
21845
21846 --
21847 -- bulk performance
21848 --
21849 l_balance_type_code VARCHAR2(1);
21850 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21851 l_log_module VARCHAR2(240);
21852
21853 --
21854 -- Upgrade strategy
21855 --
21856 l_actual_upg_option VARCHAR2(1);
21857 l_enc_upg_option VARCHAR2(1);
21858
21859 --
21860 BEGIN
21861 --
21862 IF g_log_enabled THEN
21863 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_65';
21864 END IF;
21865 --
21866 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21867
21868 trace
21869 (p_msg => 'BEGIN of AcctLineType_65'
21870 ,p_level => C_LEVEL_PROCEDURE
21871 ,p_module => l_log_module);
21872
21873 END IF;
21874 --
21875 l_component_type := 'AMB_JLT';
21876 l_component_code := 'COST_UPDATE_ADJUSTMENT';
21877 l_component_type_code := 'S';
21878 l_component_appl_id := 707;
21879 l_amb_context_code := 'DEFAULT';
21880 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
21881 l_event_class_code := 'SALES_ORDER';
21882 l_event_type_code := 'LOG_RMA_RCPT';
21883 l_line_definition_owner_code := 'S';
21884 l_line_definition_code := 'PI_LOG_RMA_RCPT';
21885 --
21886 l_balance_type_code := 'A';
21887 l_segment := NULL;
21888 l_ccid := NULL;
21889 l_adr_transaction_coa_id := NULL;
21890 l_adr_accounting_coa_id := NULL;
21891 l_adr_flexfield_segment_code := NULL;
21892 l_adr_flex_value_set_id := NULL;
21893 l_adr_value_type_code := NULL;
21894 l_adr_value_combination_id := NULL;
21895 l_adr_value_segment_code := NULL;
21896
21897 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21898 l_bflow_class_code := ''; -- 4219869 Business Flow
21899 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21900 l_budgetary_control_flag := 'N';
21901
21902 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21903 l_bflow_applied_to_amt := NULL; -- 5132302
21904 l_entered_amt_idx := NULL; -- 4262811
21905 l_accted_amt_idx := NULL; -- 4262811
21906 l_acc_rev_flag := NULL; -- 4262811
21907 l_accrual_line_num := NULL; -- 4262811
21908 l_tmp_amt := NULL; -- 4262811
21909 --
21910
21911 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21912 l_balance_type_code <> 'B' THEN
21913 IF NVL(p_source_97,9E125) = 37
21914 THEN
21915
21916 --
21917 XLA_AE_LINES_PKG.SetNewLine;
21918
21919 p_balance_type_code := l_balance_type_code;
21920 -- set the flag so later we will know whether the gain loss line needs to be created
21921
21922 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21923 p_actual_flag :='A';
21924 END IF;
21925
21926 --
21927 -- bulk performance
21928 --
21929 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21930 p_header_num => 0); -- 4262811
21931 --
21932 -- set accounting line options
21933 --
21934 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21935 p_natural_side_code => 'D'
21936 , p_gain_or_loss_flag => 'N'
21937 , p_gl_transfer_mode_code => 'S'
21938 , p_acct_entry_type_code => 'A'
21939 , p_switch_side_flag => 'Y'
21940 , p_merge_duplicate_code => 'N'
21941 );
21942 --
21943 l_acc_rev_natural_side_code := 'C'; -- 4262811
21944 --
21945 --
21946 -- set accounting line type info
21947 --
21948 xla_ae_lines_pkg.SetAcctLineType
21949 (p_component_type => l_component_type
21950 ,p_event_type_code => l_event_type_code
21951 ,p_line_definition_owner_code => l_line_definition_owner_code
21952 ,p_line_definition_code => l_line_definition_code
21953 ,p_accounting_line_code => l_component_code
21954 ,p_accounting_line_type_code => l_component_type_code
21955 ,p_accounting_line_appl_id => l_component_appl_id
21956 ,p_amb_context_code => l_amb_context_code
21957 ,p_entity_code => l_entity_code
21958 ,p_event_class_code => l_event_class_code);
21959 --
21960 -- set accounting class
21961 --
21962 xla_ae_lines_pkg.SetAcctClass(
21963 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
21964 , p_ae_header_id => l_ae_header_id
21965 );
21966
21967 --
21968 -- set rounding class
21969 --
21970 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21971 'COST_UPDATE_ADJUSTMENT';
21972
21973 --
21974 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21975 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21976 --
21977 -- bulk performance
21978 --
21979 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21980
21981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21982 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21983
21984 -- 4955764
21985 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21986 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21987
21988 -- 4458381 Public Sector Enh
21989
21990 --
21991 -- set accounting attributes for the line type
21992 --
21993 l_entered_amt_idx := 3;
21994 l_accted_amt_idx := 8;
21995 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21996 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21997 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
21998 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21999 l_rec_acct_attrs.array_char_value(2) := p_source_85;
22000 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
22001 l_rec_acct_attrs.array_num_value(3) := p_source_91;
22002 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
22003 l_rec_acct_attrs.array_char_value(4) := p_source_88;
22004 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
22005 l_rec_acct_attrs.array_date_value(5) := p_source_92;
22006 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
22007 l_rec_acct_attrs.array_num_value(6) := p_source_93;
22008 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
22009 l_rec_acct_attrs.array_char_value(7) := p_source_94;
22010 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
22011 l_rec_acct_attrs.array_num_value(8) := p_source_95;
22012
22013 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22014 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22015
22016 ---------------------------------------------------------------------------------------------------------------
22017 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22018 ---------------------------------------------------------------------------------------------------------------
22019 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22020
22021 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22022 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22023
22024 IF xla_accounting_cache_pkg.GetValueChar
22025 (p_source_code => 'LEDGER_CATEGORY_CODE'
22026 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22027 AND l_bflow_method_code = 'PRIOR_ENTRY'
22028 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22029 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22030 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22031 )
22032 THEN
22033 xla_ae_lines_pkg.BflowUpgEntry
22034 (p_business_method_code => l_bflow_method_code
22035 ,p_business_class_code => l_bflow_class_code
22036 ,p_balance_type => l_balance_type_code);
22037 ELSE
22038 NULL;
22039 -- No business flow processing for business flow method of NONE.
22040 END IF;
22041
22042 --
22043 -- call analytical criteria
22044 --
22045
22046 --
22047 -- call description
22048 --
22049
22050 xla_ae_lines_pkg.SetLineDescription(
22051 p_ae_header_id => l_ae_header_id
22052 ,p_description => Description_1 (
22053 p_application_id => p_application_id
22054 , p_ae_header_id => l_ae_header_id
22055 , p_source_1 => p_source_1
22056 , p_source_2 => p_source_2
22057 , p_source_3 => p_source_3
22058 , p_source_4 => p_source_4
22059 , p_source_5 => p_source_5
22060 )
22061 );
22062
22063
22064 --
22065 -- call ADRs
22066 -- Bug 4922099
22067 --
22068 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22069 (NVL(l_actual_upg_option, 'N') = 'O') OR
22070 (NVL(l_enc_upg_option, 'N') = 'O')
22071 )
22072 THEN
22073 NULL;
22074 --
22075 --
22076
22077 l_ccid := AcctDerRule_6(
22078 p_application_id => p_application_id
22079 , p_ae_header_id => l_ae_header_id
22080 , p_source_11 => p_source_11
22081 , x_transaction_coa_id => l_adr_transaction_coa_id
22082 , x_accounting_coa_id => l_adr_accounting_coa_id
22083 , x_value_type_code => l_adr_value_type_code
22084 , p_side => 'NA'
22085 );
22086
22087 xla_ae_lines_pkg.set_ccid(
22088 p_code_combination_id => l_ccid
22089 , p_value_type_code => l_adr_value_type_code
22090 , p_transaction_coa_id => l_adr_transaction_coa_id
22091 , p_accounting_coa_id => l_adr_accounting_coa_id
22092 , p_adr_code => 'CST_DEFAULT'
22093 , p_adr_type_code => 'S'
22094 , p_component_type => l_component_type
22095 , p_component_code => l_component_code
22096 , p_component_type_code => l_component_type_code
22097 , p_component_appl_id => l_component_appl_id
22098 , p_amb_context_code => l_amb_context_code
22099 , p_side => 'NA'
22100 );
22101
22102
22103 --
22104 --
22105 END IF;
22106 --
22107 -- Bug 4922099
22108 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22109 (NVL(l_enc_upg_option, 'N') = 'O')
22110 ) AND
22111 (l_bflow_method_code = 'PRIOR_ENTRY')
22112 )
22113 THEN
22114 IF
22115 --
22116 1 = 2
22117 --
22118 THEN
22119 xla_accounting_err_pkg.build_message
22120 (p_appli_s_name => 'XLA'
22121 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22122 ,p_token_1 => 'LINE_NUMBER'
22123 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22124 ,p_token_2 => 'LINE_TYPE_NAME'
22125 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22126 l_component_type
22127 ,l_component_code
22128 ,l_component_type_code
22129 ,l_component_appl_id
22130 ,l_amb_context_code
22131 ,l_entity_code
22132 ,l_event_class_code
22133 )
22134 ,p_token_3 => 'OWNER'
22135 ,p_value_3 => xla_lookups_pkg.get_meaning(
22136 p_lookup_type => 'XLA_OWNER_TYPE'
22137 ,p_lookup_code => l_component_type_code
22138 )
22139 ,p_token_4 => 'PRODUCT_NAME'
22140 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22141 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22142 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22143 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22144 ,p_ae_header_id => NULL
22145 );
22146
22147 IF (C_LEVEL_ERROR>= g_log_level) THEN
22148 trace
22149 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22150 ,p_level => C_LEVEL_ERROR
22151 ,p_module => l_log_module);
22152 END IF;
22153 END IF;
22154 END IF;
22155 --
22156 --
22157 ------------------------------------------------------------------------------------------------
22158 -- 4219869 Business Flow
22159 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22160 -- Prior Entry. Currently, the following code is always generated.
22161 ------------------------------------------------------------------------------------------------
22162 XLA_AE_LINES_PKG.ValidateCurrentLine;
22163
22164 ------------------------------------------------------------------------------------
22165 -- 4219869 Business Flow
22166 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22167 ------------------------------------------------------------------------------------
22168 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22169
22170 ----------------------------------------------------------------------------------
22171 -- 4219869 Business Flow
22172 -- Update journal entry status -- Need to generate this within IF <condition>
22173 ----------------------------------------------------------------------------------
22174 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22175 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22176 ,p_balance_type_code => l_balance_type_code
22177 );
22178
22179 -------------------------------------------------------------------------------------------
22180 -- 4262811 - Generate the Accrual Reversal lines
22181 -------------------------------------------------------------------------------------------
22182 BEGIN
22183 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22184 (g_array_event(p_event_id).array_value_num('header_index'));
22185 IF l_acc_rev_flag IS NULL THEN
22186 l_acc_rev_flag := 'N';
22187 END IF;
22188 EXCEPTION
22189 WHEN OTHERS THEN
22190 l_acc_rev_flag := 'N';
22191 END;
22192 --
22193 IF (l_acc_rev_flag = 'Y') THEN
22194
22195 -- 4645092 ------------------------------------------------------------------------------
22196 -- To allow MPA report to determine if it should generate report process
22197 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22198 ------------------------------------------------------------------------------------------
22199
22200 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22201 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22202 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22203 -- call ADRs
22204 -- Bug 4922099
22205 --
22206 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22207 (NVL(l_actual_upg_option, 'N') = 'O') OR
22208 (NVL(l_enc_upg_option, 'N') = 'O')
22209 )
22210 THEN
22211 NULL;
22212 --
22213 --
22214
22215 l_ccid := AcctDerRule_6(
22216 p_application_id => p_application_id
22217 , p_ae_header_id => l_ae_header_id
22218 , p_source_11 => p_source_11
22219 , x_transaction_coa_id => l_adr_transaction_coa_id
22220 , x_accounting_coa_id => l_adr_accounting_coa_id
22221 , x_value_type_code => l_adr_value_type_code
22222 , p_side => 'NA'
22223 );
22224
22225 xla_ae_lines_pkg.set_ccid(
22226 p_code_combination_id => l_ccid
22227 , p_value_type_code => l_adr_value_type_code
22228 , p_transaction_coa_id => l_adr_transaction_coa_id
22229 , p_accounting_coa_id => l_adr_accounting_coa_id
22230 , p_adr_code => 'CST_DEFAULT'
22231 , p_adr_type_code => 'S'
22232 , p_component_type => l_component_type
22233 , p_component_code => l_component_code
22234 , p_component_type_code => l_component_type_code
22235 , p_component_appl_id => l_component_appl_id
22236 , p_amb_context_code => l_amb_context_code
22237 , p_side => 'NA'
22238 );
22239
22240
22241 --
22242 --
22243 END IF;
22244
22245 --
22246 -- Update the line information that should be overwritten
22247 --
22248 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22249 p_header_num => 1);
22250 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22251
22252 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22253
22254 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22255 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22256 END IF;
22257
22258 --
22259 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22260 --
22261 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22262 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22263 ELSE
22264 ---------------------------------------------------------------------------------------------------
22265 -- 4262811a Switch Sign
22266 ---------------------------------------------------------------------------------------------------
22267 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22268 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22269 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22270 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22271 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22272 -- 5132302
22273 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22274 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22275
22276 END IF;
22277
22278 -- 4955764
22279 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22280 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22281
22282
22283 XLA_AE_LINES_PKG.ValidateCurrentLine;
22284 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22285
22286 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22287 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22288 ,p_balance_type_code => l_balance_type_code);
22289
22290 END IF;
22291
22292 -----------------------------------------------------------------------------------------
22293 -- 4262811 Multiperiod Accounting
22294 -----------------------------------------------------------------------------------------
22295 -- No MPA option is assigned.
22296
22297
22298 END IF;
22299 END IF;
22300 --
22301
22302 --
22303 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22304 trace
22305 (p_msg => 'END of AcctLineType_65'
22306 ,p_level => C_LEVEL_PROCEDURE
22307 ,p_module => l_log_module);
22308 END IF;
22309 --
22310 EXCEPTION
22311 WHEN xla_exceptions_pkg.application_exception THEN
22312 RAISE;
22313 WHEN OTHERS THEN
22314 xla_exceptions_pkg.raise_message
22315 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_65');
22316 END AcctLineType_65;
22317 --
22318
22319 ---------------------------------------
22320 --
22321 -- PRIVATE FUNCTION
22322 -- AcctLineType_66
22323 --
22324 ---------------------------------------
22325 PROCEDURE AcctLineType_66 (
22326 p_application_id IN NUMBER
22327 ,p_event_id IN NUMBER
22328 ,p_calculate_acctd_flag IN VARCHAR2
22329 ,p_calculate_g_l_flag IN VARCHAR2
22330 ,p_actual_flag IN OUT VARCHAR2
22331 ,p_balance_type_code OUT VARCHAR2
22332 ,p_gain_or_loss_ref OUT VARCHAR2
22333
22334 --Cost Management Default Account
22335 , p_source_11 IN NUMBER
22336 --DISTRIBUTION_IDENTIFIER
22337 , p_source_84 IN NUMBER
22338 --Distribution Type
22339 , p_source_85 IN VARCHAR2
22340 , p_source_85_meaning IN VARCHAR2
22341 --Entered Currency Code
22342 , p_source_88 IN VARCHAR2
22343 --Entered Amount
22344 , p_source_91 IN NUMBER
22345 --Currency Conversion Date
22346 , p_source_92 IN DATE
22347 --Currency Conversion Rate
22348 , p_source_93 IN NUMBER
22349 --Currency Conversion Type
22350 , p_source_94 IN VARCHAR2
22351 --Accounted Amount
22352 , p_source_95 IN NUMBER
22353 --Accounting Line Type
22354 , p_source_97 IN NUMBER
22355 )
22356 IS
22357
22358 l_component_type VARCHAR2(80);
22359 l_component_code VARCHAR2(30);
22360 l_component_type_code VARCHAR2(1);
22361 l_component_appl_id INTEGER;
22362 l_amb_context_code VARCHAR2(30);
22363 l_entity_code VARCHAR2(30);
22364 l_event_class_code VARCHAR2(30);
22365 l_ae_header_id NUMBER;
22366 l_event_type_code VARCHAR2(30);
22367 l_line_definition_code VARCHAR2(30);
22368 l_line_definition_owner_code VARCHAR2(1);
22369 --
22370 -- adr variables
22371 l_segment VARCHAR2(30);
22372 l_ccid NUMBER;
22373 l_adr_transaction_coa_id NUMBER;
22374 l_adr_accounting_coa_id NUMBER;
22375 l_adr_flexfield_segment_code VARCHAR2(30);
22376 l_adr_flex_value_set_id NUMBER;
22377 l_adr_value_type_code VARCHAR2(30);
22378 l_adr_value_combination_id NUMBER;
22379 l_adr_value_segment_code VARCHAR2(30);
22380
22381 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22382 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22383 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22384 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22385
22386 -- 4262811 Variables ------------------------------------------------------------------------------------------
22387 l_entered_amt_idx NUMBER;
22388 l_accted_amt_idx NUMBER;
22389 l_acc_rev_flag VARCHAR2(1);
22390 l_accrual_line_num NUMBER;
22391 l_tmp_amt NUMBER;
22392 l_acc_rev_natural_side_code VARCHAR2(1);
22393
22394 l_num_entries NUMBER;
22395 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22396 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22397 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22398 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22399 l_recog_line_1 NUMBER;
22400 l_recog_line_2 NUMBER;
22401
22402 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22403 l_bflow_applied_to_amt NUMBER; -- 5132302
22404 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22405
22406 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22407
22408 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22409 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22410
22411 ---------------------------------------------------------------------------------------------------------------
22412
22413
22414 --
22415 -- bulk performance
22416 --
22417 l_balance_type_code VARCHAR2(1);
22418 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22419 l_log_module VARCHAR2(240);
22420
22421 --
22422 -- Upgrade strategy
22423 --
22424 l_actual_upg_option VARCHAR2(1);
22425 l_enc_upg_option VARCHAR2(1);
22426
22427 --
22428 BEGIN
22429 --
22430 IF g_log_enabled THEN
22431 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_66';
22432 END IF;
22433 --
22434 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22435
22436 trace
22437 (p_msg => 'BEGIN of AcctLineType_66'
22438 ,p_level => C_LEVEL_PROCEDURE
22439 ,p_module => l_log_module);
22440
22441 END IF;
22442 --
22443 l_component_type := 'AMB_JLT';
22444 l_component_code := 'COST_UPDATE_ADJUSTMENT';
22445 l_component_type_code := 'S';
22446 l_component_appl_id := 707;
22447 l_amb_context_code := 'DEFAULT';
22448 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
22449 l_event_class_code := 'WIP_COST_UPD';
22450 l_event_type_code := 'WIP_COST_UPD_ALL';
22451 l_line_definition_owner_code := 'S';
22452 l_line_definition_code := 'COST_UPDATE';
22453 --
22454 l_balance_type_code := 'A';
22455 l_segment := NULL;
22456 l_ccid := NULL;
22457 l_adr_transaction_coa_id := NULL;
22458 l_adr_accounting_coa_id := NULL;
22459 l_adr_flexfield_segment_code := NULL;
22460 l_adr_flex_value_set_id := NULL;
22461 l_adr_value_type_code := NULL;
22462 l_adr_value_combination_id := NULL;
22463 l_adr_value_segment_code := NULL;
22464
22465 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22466 l_bflow_class_code := ''; -- 4219869 Business Flow
22467 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22468 l_budgetary_control_flag := 'N';
22469
22470 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22471 l_bflow_applied_to_amt := NULL; -- 5132302
22472 l_entered_amt_idx := NULL; -- 4262811
22473 l_accted_amt_idx := NULL; -- 4262811
22474 l_acc_rev_flag := NULL; -- 4262811
22475 l_accrual_line_num := NULL; -- 4262811
22476 l_tmp_amt := NULL; -- 4262811
22477 --
22478
22479 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22480 l_balance_type_code <> 'B' THEN
22481 IF NVL(p_source_97,9E125) = 2
22482 THEN
22483
22484 --
22485 XLA_AE_LINES_PKG.SetNewLine;
22486
22487 p_balance_type_code := l_balance_type_code;
22488 -- set the flag so later we will know whether the gain loss line needs to be created
22489
22490 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22491 p_actual_flag :='A';
22492 END IF;
22493
22494 --
22495 -- bulk performance
22496 --
22497 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22498 p_header_num => 0); -- 4262811
22499 --
22500 -- set accounting line options
22501 --
22502 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22503 p_natural_side_code => 'D'
22504 , p_gain_or_loss_flag => 'N'
22505 , p_gl_transfer_mode_code => 'S'
22506 , p_acct_entry_type_code => 'A'
22507 , p_switch_side_flag => 'Y'
22508 , p_merge_duplicate_code => 'N'
22509 );
22510 --
22511 l_acc_rev_natural_side_code := 'C'; -- 4262811
22512 --
22513 --
22514 -- set accounting line type info
22515 --
22516 xla_ae_lines_pkg.SetAcctLineType
22517 (p_component_type => l_component_type
22518 ,p_event_type_code => l_event_type_code
22519 ,p_line_definition_owner_code => l_line_definition_owner_code
22520 ,p_line_definition_code => l_line_definition_code
22521 ,p_accounting_line_code => l_component_code
22522 ,p_accounting_line_type_code => l_component_type_code
22523 ,p_accounting_line_appl_id => l_component_appl_id
22524 ,p_amb_context_code => l_amb_context_code
22525 ,p_entity_code => l_entity_code
22526 ,p_event_class_code => l_event_class_code);
22527 --
22528 -- set accounting class
22529 --
22530 xla_ae_lines_pkg.SetAcctClass(
22531 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
22532 , p_ae_header_id => l_ae_header_id
22533 );
22534
22535 --
22536 -- set rounding class
22537 --
22538 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22539 'COST_UPDATE_ADJUSTMENT';
22540
22541 --
22542 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22543 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22544 --
22545 -- bulk performance
22546 --
22547 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22548
22549 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22550 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22551
22552 -- 4955764
22553 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22554 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22555
22556 -- 4458381 Public Sector Enh
22557
22558 --
22559 -- set accounting attributes for the line type
22560 --
22561 l_entered_amt_idx := 3;
22562 l_accted_amt_idx := 8;
22563 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22564 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
22565 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
22566 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
22567 l_rec_acct_attrs.array_char_value(2) := p_source_85;
22568 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
22569 l_rec_acct_attrs.array_num_value(3) := p_source_91;
22570 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
22571 l_rec_acct_attrs.array_char_value(4) := p_source_88;
22572 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
22573 l_rec_acct_attrs.array_date_value(5) := p_source_92;
22574 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
22575 l_rec_acct_attrs.array_num_value(6) := p_source_93;
22576 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
22577 l_rec_acct_attrs.array_char_value(7) := p_source_94;
22578 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
22579 l_rec_acct_attrs.array_num_value(8) := p_source_95;
22580
22581 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22582 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22583
22584 ---------------------------------------------------------------------------------------------------------------
22585 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22586 ---------------------------------------------------------------------------------------------------------------
22587 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22588
22589 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22590 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22591
22592 IF xla_accounting_cache_pkg.GetValueChar
22593 (p_source_code => 'LEDGER_CATEGORY_CODE'
22594 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22595 AND l_bflow_method_code = 'PRIOR_ENTRY'
22596 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22597 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22598 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22599 )
22600 THEN
22601 xla_ae_lines_pkg.BflowUpgEntry
22602 (p_business_method_code => l_bflow_method_code
22603 ,p_business_class_code => l_bflow_class_code
22604 ,p_balance_type => l_balance_type_code);
22605 ELSE
22606 NULL;
22607 -- No business flow processing for business flow method of NONE.
22608 END IF;
22609
22610 --
22611 -- call analytical criteria
22612 --
22613
22614 --
22615 -- call description
22616 --
22617 -- No description or it is inherited.
22618 --
22619 -- call ADRs
22620 -- Bug 4922099
22621 --
22622 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22623 (NVL(l_actual_upg_option, 'N') = 'O') OR
22624 (NVL(l_enc_upg_option, 'N') = 'O')
22625 )
22626 THEN
22627 NULL;
22628 --
22629 --
22630
22631 l_ccid := AcctDerRule_6(
22632 p_application_id => p_application_id
22633 , p_ae_header_id => l_ae_header_id
22634 , p_source_11 => p_source_11
22635 , x_transaction_coa_id => l_adr_transaction_coa_id
22636 , x_accounting_coa_id => l_adr_accounting_coa_id
22637 , x_value_type_code => l_adr_value_type_code
22638 , p_side => 'NA'
22639 );
22640
22641 xla_ae_lines_pkg.set_ccid(
22642 p_code_combination_id => l_ccid
22643 , p_value_type_code => l_adr_value_type_code
22644 , p_transaction_coa_id => l_adr_transaction_coa_id
22645 , p_accounting_coa_id => l_adr_accounting_coa_id
22646 , p_adr_code => 'CST_DEFAULT'
22647 , p_adr_type_code => 'S'
22648 , p_component_type => l_component_type
22649 , p_component_code => l_component_code
22650 , p_component_type_code => l_component_type_code
22651 , p_component_appl_id => l_component_appl_id
22652 , p_amb_context_code => l_amb_context_code
22653 , p_side => 'NA'
22654 );
22655
22656
22657 --
22658 --
22659 END IF;
22660 --
22661 -- Bug 4922099
22662 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22663 (NVL(l_enc_upg_option, 'N') = 'O')
22664 ) AND
22665 (l_bflow_method_code = 'PRIOR_ENTRY')
22666 )
22667 THEN
22668 IF
22669 --
22670 1 = 2
22671 --
22672 THEN
22673 xla_accounting_err_pkg.build_message
22674 (p_appli_s_name => 'XLA'
22675 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22676 ,p_token_1 => 'LINE_NUMBER'
22677 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22678 ,p_token_2 => 'LINE_TYPE_NAME'
22679 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22680 l_component_type
22681 ,l_component_code
22682 ,l_component_type_code
22683 ,l_component_appl_id
22684 ,l_amb_context_code
22685 ,l_entity_code
22686 ,l_event_class_code
22687 )
22688 ,p_token_3 => 'OWNER'
22689 ,p_value_3 => xla_lookups_pkg.get_meaning(
22690 p_lookup_type => 'XLA_OWNER_TYPE'
22691 ,p_lookup_code => l_component_type_code
22692 )
22693 ,p_token_4 => 'PRODUCT_NAME'
22694 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22695 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22696 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22697 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22698 ,p_ae_header_id => NULL
22699 );
22700
22701 IF (C_LEVEL_ERROR>= g_log_level) THEN
22702 trace
22703 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22704 ,p_level => C_LEVEL_ERROR
22705 ,p_module => l_log_module);
22706 END IF;
22707 END IF;
22708 END IF;
22709 --
22710 --
22711 ------------------------------------------------------------------------------------------------
22712 -- 4219869 Business Flow
22713 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22714 -- Prior Entry. Currently, the following code is always generated.
22715 ------------------------------------------------------------------------------------------------
22716 XLA_AE_LINES_PKG.ValidateCurrentLine;
22717
22718 ------------------------------------------------------------------------------------
22719 -- 4219869 Business Flow
22720 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22721 ------------------------------------------------------------------------------------
22722 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22723
22724 ----------------------------------------------------------------------------------
22725 -- 4219869 Business Flow
22726 -- Update journal entry status -- Need to generate this within IF <condition>
22727 ----------------------------------------------------------------------------------
22728 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22729 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22730 ,p_balance_type_code => l_balance_type_code
22731 );
22732
22733 -------------------------------------------------------------------------------------------
22734 -- 4262811 - Generate the Accrual Reversal lines
22735 -------------------------------------------------------------------------------------------
22736 BEGIN
22737 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22738 (g_array_event(p_event_id).array_value_num('header_index'));
22739 IF l_acc_rev_flag IS NULL THEN
22740 l_acc_rev_flag := 'N';
22741 END IF;
22742 EXCEPTION
22743 WHEN OTHERS THEN
22744 l_acc_rev_flag := 'N';
22745 END;
22746 --
22747 IF (l_acc_rev_flag = 'Y') THEN
22748
22749 -- 4645092 ------------------------------------------------------------------------------
22750 -- To allow MPA report to determine if it should generate report process
22751 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22752 ------------------------------------------------------------------------------------------
22753
22754 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22755 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22756 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22757 -- call ADRs
22758 -- Bug 4922099
22759 --
22760 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22761 (NVL(l_actual_upg_option, 'N') = 'O') OR
22762 (NVL(l_enc_upg_option, 'N') = 'O')
22763 )
22764 THEN
22765 NULL;
22766 --
22767 --
22768
22769 l_ccid := AcctDerRule_6(
22770 p_application_id => p_application_id
22771 , p_ae_header_id => l_ae_header_id
22772 , p_source_11 => p_source_11
22773 , x_transaction_coa_id => l_adr_transaction_coa_id
22774 , x_accounting_coa_id => l_adr_accounting_coa_id
22775 , x_value_type_code => l_adr_value_type_code
22776 , p_side => 'NA'
22777 );
22778
22779 xla_ae_lines_pkg.set_ccid(
22780 p_code_combination_id => l_ccid
22781 , p_value_type_code => l_adr_value_type_code
22782 , p_transaction_coa_id => l_adr_transaction_coa_id
22783 , p_accounting_coa_id => l_adr_accounting_coa_id
22784 , p_adr_code => 'CST_DEFAULT'
22785 , p_adr_type_code => 'S'
22786 , p_component_type => l_component_type
22787 , p_component_code => l_component_code
22788 , p_component_type_code => l_component_type_code
22789 , p_component_appl_id => l_component_appl_id
22790 , p_amb_context_code => l_amb_context_code
22791 , p_side => 'NA'
22792 );
22793
22794
22795 --
22796 --
22797 END IF;
22798
22799 --
22800 -- Update the line information that should be overwritten
22801 --
22802 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22803 p_header_num => 1);
22804 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22805
22806 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22807
22808 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22809 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22810 END IF;
22811
22812 --
22813 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22814 --
22815 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22816 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22817 ELSE
22818 ---------------------------------------------------------------------------------------------------
22819 -- 4262811a Switch Sign
22820 ---------------------------------------------------------------------------------------------------
22821 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22822 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22823 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22824 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22825 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22826 -- 5132302
22827 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22828 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22829
22830 END IF;
22831
22832 -- 4955764
22833 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22834 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22835
22836
22837 XLA_AE_LINES_PKG.ValidateCurrentLine;
22838 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22839
22840 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22841 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22842 ,p_balance_type_code => l_balance_type_code);
22843
22844 END IF;
22845
22846 -----------------------------------------------------------------------------------------
22847 -- 4262811 Multiperiod Accounting
22848 -----------------------------------------------------------------------------------------
22849 -- No MPA option is assigned.
22850
22851
22852 END IF;
22853 END IF;
22854 --
22855
22856 --
22857 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22858 trace
22859 (p_msg => 'END of AcctLineType_66'
22860 ,p_level => C_LEVEL_PROCEDURE
22861 ,p_module => l_log_module);
22862 END IF;
22863 --
22864 EXCEPTION
22865 WHEN xla_exceptions_pkg.application_exception THEN
22866 RAISE;
22867 WHEN OTHERS THEN
22868 xla_exceptions_pkg.raise_message
22869 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_66');
22870 END AcctLineType_66;
22871 --
22872
22873 ---------------------------------------
22874 --
22875 -- PRIVATE FUNCTION
22876 -- AcctLineType_67
22877 --
22878 ---------------------------------------
22879 PROCEDURE AcctLineType_67 (
22880 p_application_id IN NUMBER
22881 ,p_event_id IN NUMBER
22882 ,p_calculate_acctd_flag IN VARCHAR2
22883 ,p_calculate_g_l_flag IN VARCHAR2
22884 ,p_actual_flag IN OUT VARCHAR2
22885 ,p_balance_type_code OUT VARCHAR2
22886 ,p_gain_or_loss_ref OUT VARCHAR2
22887
22888 --Cost Management Default Account
22889 , p_source_11 IN NUMBER
22890 --DISTRIBUTION_IDENTIFIER
22891 , p_source_84 IN NUMBER
22892 --Distribution Type
22893 , p_source_85 IN VARCHAR2
22894 , p_source_85_meaning IN VARCHAR2
22895 --Entered Currency Code
22896 , p_source_88 IN VARCHAR2
22897 --Entered Amount
22898 , p_source_91 IN NUMBER
22899 --Currency Conversion Date
22900 , p_source_92 IN DATE
22901 --Currency Conversion Rate
22902 , p_source_93 IN NUMBER
22903 --Currency Conversion Type
22904 , p_source_94 IN VARCHAR2
22905 --Accounted Amount
22906 , p_source_95 IN NUMBER
22907 --Accounting Line Type
22908 , p_source_97 IN NUMBER
22909 )
22910 IS
22911
22912 l_component_type VARCHAR2(80);
22913 l_component_code VARCHAR2(30);
22914 l_component_type_code VARCHAR2(1);
22915 l_component_appl_id INTEGER;
22916 l_amb_context_code VARCHAR2(30);
22917 l_entity_code VARCHAR2(30);
22918 l_event_class_code VARCHAR2(30);
22919 l_ae_header_id NUMBER;
22920 l_event_type_code VARCHAR2(30);
22921 l_line_definition_code VARCHAR2(30);
22922 l_line_definition_owner_code VARCHAR2(1);
22923 --
22924 -- adr variables
22925 l_segment VARCHAR2(30);
22926 l_ccid NUMBER;
22927 l_adr_transaction_coa_id NUMBER;
22928 l_adr_accounting_coa_id NUMBER;
22929 l_adr_flexfield_segment_code VARCHAR2(30);
22930 l_adr_flex_value_set_id NUMBER;
22931 l_adr_value_type_code VARCHAR2(30);
22932 l_adr_value_combination_id NUMBER;
22933 l_adr_value_segment_code VARCHAR2(30);
22934
22935 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22936 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22937 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22938 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22939
22940 -- 4262811 Variables ------------------------------------------------------------------------------------------
22941 l_entered_amt_idx NUMBER;
22942 l_accted_amt_idx NUMBER;
22943 l_acc_rev_flag VARCHAR2(1);
22944 l_accrual_line_num NUMBER;
22945 l_tmp_amt NUMBER;
22946 l_acc_rev_natural_side_code VARCHAR2(1);
22947
22948 l_num_entries NUMBER;
22949 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22950 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22951 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22952 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22953 l_recog_line_1 NUMBER;
22954 l_recog_line_2 NUMBER;
22955
22956 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22957 l_bflow_applied_to_amt NUMBER; -- 5132302
22958 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22959
22960 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22961
22962 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22963 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22964
22965 ---------------------------------------------------------------------------------------------------------------
22966
22967
22968 --
22969 -- bulk performance
22970 --
22971 l_balance_type_code VARCHAR2(1);
22972 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22973 l_log_module VARCHAR2(240);
22974
22975 --
22976 -- Upgrade strategy
22977 --
22978 l_actual_upg_option VARCHAR2(1);
22979 l_enc_upg_option VARCHAR2(1);
22980
22981 --
22982 BEGIN
22983 --
22984 IF g_log_enabled THEN
22985 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_67';
22986 END IF;
22987 --
22988 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22989
22990 trace
22991 (p_msg => 'BEGIN of AcctLineType_67'
22992 ,p_level => C_LEVEL_PROCEDURE
22993 ,p_module => l_log_module);
22994
22995 END IF;
22996 --
22997 l_component_type := 'AMB_JLT';
22998 l_component_code := 'COST_UPDATE_ADJUSTMENT';
22999 l_component_type_code := 'S';
23000 l_component_appl_id := 707;
23001 l_amb_context_code := 'DEFAULT';
23002 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
23003 l_event_class_code := 'SALES_ORDER';
23004 l_event_type_code := 'COGS_RECOGNITION';
23005 l_line_definition_owner_code := 'S';
23006 l_line_definition_code := 'PI_COGS_RECOGNITION';
23007 --
23008 l_balance_type_code := 'A';
23009 l_segment := NULL;
23010 l_ccid := NULL;
23011 l_adr_transaction_coa_id := NULL;
23012 l_adr_accounting_coa_id := NULL;
23013 l_adr_flexfield_segment_code := NULL;
23014 l_adr_flex_value_set_id := NULL;
23015 l_adr_value_type_code := NULL;
23016 l_adr_value_combination_id := NULL;
23017 l_adr_value_segment_code := NULL;
23018
23019 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23020 l_bflow_class_code := ''; -- 4219869 Business Flow
23021 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23022 l_budgetary_control_flag := 'N';
23023
23024 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23025 l_bflow_applied_to_amt := NULL; -- 5132302
23026 l_entered_amt_idx := NULL; -- 4262811
23027 l_accted_amt_idx := NULL; -- 4262811
23028 l_acc_rev_flag := NULL; -- 4262811
23029 l_accrual_line_num := NULL; -- 4262811
23030 l_tmp_amt := NULL; -- 4262811
23031 --
23032
23033 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23034 l_balance_type_code <> 'B' THEN
23035 IF NVL(p_source_97,9E125) = 37
23036 THEN
23037
23038 --
23039 XLA_AE_LINES_PKG.SetNewLine;
23040
23041 p_balance_type_code := l_balance_type_code;
23042 -- set the flag so later we will know whether the gain loss line needs to be created
23043
23044 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23045 p_actual_flag :='A';
23046 END IF;
23047
23048 --
23049 -- bulk performance
23050 --
23051 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23052 p_header_num => 0); -- 4262811
23053 --
23054 -- set accounting line options
23055 --
23056 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23057 p_natural_side_code => 'D'
23058 , p_gain_or_loss_flag => 'N'
23059 , p_gl_transfer_mode_code => 'S'
23060 , p_acct_entry_type_code => 'A'
23061 , p_switch_side_flag => 'Y'
23062 , p_merge_duplicate_code => 'N'
23063 );
23064 --
23065 l_acc_rev_natural_side_code := 'C'; -- 4262811
23066 --
23067 --
23068 -- set accounting line type info
23069 --
23070 xla_ae_lines_pkg.SetAcctLineType
23071 (p_component_type => l_component_type
23072 ,p_event_type_code => l_event_type_code
23073 ,p_line_definition_owner_code => l_line_definition_owner_code
23074 ,p_line_definition_code => l_line_definition_code
23075 ,p_accounting_line_code => l_component_code
23076 ,p_accounting_line_type_code => l_component_type_code
23077 ,p_accounting_line_appl_id => l_component_appl_id
23078 ,p_amb_context_code => l_amb_context_code
23079 ,p_entity_code => l_entity_code
23080 ,p_event_class_code => l_event_class_code);
23081 --
23082 -- set accounting class
23083 --
23084 xla_ae_lines_pkg.SetAcctClass(
23085 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
23086 , p_ae_header_id => l_ae_header_id
23087 );
23088
23089 --
23090 -- set rounding class
23091 --
23092 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23093 'COST_UPDATE_ADJUSTMENT';
23094
23095 --
23096 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23097 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23098 --
23099 -- bulk performance
23100 --
23101 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23102
23103 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23104 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23105
23106 -- 4955764
23107 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23108 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23109
23110 -- 4458381 Public Sector Enh
23111
23112 --
23113 -- set accounting attributes for the line type
23114 --
23115 l_entered_amt_idx := 3;
23116 l_accted_amt_idx := 8;
23117 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23118 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23119 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
23120 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23121 l_rec_acct_attrs.array_char_value(2) := p_source_85;
23122 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23123 l_rec_acct_attrs.array_num_value(3) := p_source_91;
23124 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23125 l_rec_acct_attrs.array_char_value(4) := p_source_88;
23126 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23127 l_rec_acct_attrs.array_date_value(5) := p_source_92;
23128 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23129 l_rec_acct_attrs.array_num_value(6) := p_source_93;
23130 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23131 l_rec_acct_attrs.array_char_value(7) := p_source_94;
23132 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23133 l_rec_acct_attrs.array_num_value(8) := p_source_95;
23134
23135 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23136 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23137
23138 ---------------------------------------------------------------------------------------------------------------
23139 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23140 ---------------------------------------------------------------------------------------------------------------
23141 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23142
23143 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23144 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23145
23146 IF xla_accounting_cache_pkg.GetValueChar
23147 (p_source_code => 'LEDGER_CATEGORY_CODE'
23148 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23149 AND l_bflow_method_code = 'PRIOR_ENTRY'
23150 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23151 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23152 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23153 )
23154 THEN
23155 xla_ae_lines_pkg.BflowUpgEntry
23156 (p_business_method_code => l_bflow_method_code
23157 ,p_business_class_code => l_bflow_class_code
23158 ,p_balance_type => l_balance_type_code);
23159 ELSE
23160 NULL;
23161 -- No business flow processing for business flow method of NONE.
23162 END IF;
23163
23164 --
23165 -- call analytical criteria
23166 --
23167
23168 --
23169 -- call description
23170 --
23171 -- No description or it is inherited.
23172 --
23173 -- call ADRs
23174 -- Bug 4922099
23175 --
23176 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23177 (NVL(l_actual_upg_option, 'N') = 'O') OR
23178 (NVL(l_enc_upg_option, 'N') = 'O')
23179 )
23180 THEN
23181 NULL;
23182 --
23183 --
23184
23185 l_ccid := AcctDerRule_6(
23186 p_application_id => p_application_id
23187 , p_ae_header_id => l_ae_header_id
23188 , p_source_11 => p_source_11
23189 , x_transaction_coa_id => l_adr_transaction_coa_id
23190 , x_accounting_coa_id => l_adr_accounting_coa_id
23191 , x_value_type_code => l_adr_value_type_code
23192 , p_side => 'NA'
23193 );
23194
23195 xla_ae_lines_pkg.set_ccid(
23196 p_code_combination_id => l_ccid
23197 , p_value_type_code => l_adr_value_type_code
23198 , p_transaction_coa_id => l_adr_transaction_coa_id
23199 , p_accounting_coa_id => l_adr_accounting_coa_id
23200 , p_adr_code => 'CST_DEFAULT'
23201 , p_adr_type_code => 'S'
23202 , p_component_type => l_component_type
23203 , p_component_code => l_component_code
23204 , p_component_type_code => l_component_type_code
23205 , p_component_appl_id => l_component_appl_id
23206 , p_amb_context_code => l_amb_context_code
23207 , p_side => 'NA'
23208 );
23209
23210
23211 --
23212 --
23213 END IF;
23214 --
23215 -- Bug 4922099
23216 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23217 (NVL(l_enc_upg_option, 'N') = 'O')
23218 ) AND
23219 (l_bflow_method_code = 'PRIOR_ENTRY')
23220 )
23221 THEN
23222 IF
23223 --
23224 1 = 2
23225 --
23226 THEN
23227 xla_accounting_err_pkg.build_message
23228 (p_appli_s_name => 'XLA'
23229 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23230 ,p_token_1 => 'LINE_NUMBER'
23231 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23232 ,p_token_2 => 'LINE_TYPE_NAME'
23233 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23234 l_component_type
23235 ,l_component_code
23236 ,l_component_type_code
23237 ,l_component_appl_id
23238 ,l_amb_context_code
23239 ,l_entity_code
23240 ,l_event_class_code
23241 )
23242 ,p_token_3 => 'OWNER'
23243 ,p_value_3 => xla_lookups_pkg.get_meaning(
23244 p_lookup_type => 'XLA_OWNER_TYPE'
23245 ,p_lookup_code => l_component_type_code
23246 )
23247 ,p_token_4 => 'PRODUCT_NAME'
23248 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23249 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23250 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23251 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23252 ,p_ae_header_id => NULL
23253 );
23254
23255 IF (C_LEVEL_ERROR>= g_log_level) THEN
23256 trace
23257 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23258 ,p_level => C_LEVEL_ERROR
23259 ,p_module => l_log_module);
23260 END IF;
23261 END IF;
23262 END IF;
23263 --
23264 --
23265 ------------------------------------------------------------------------------------------------
23266 -- 4219869 Business Flow
23267 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23268 -- Prior Entry. Currently, the following code is always generated.
23269 ------------------------------------------------------------------------------------------------
23270 XLA_AE_LINES_PKG.ValidateCurrentLine;
23271
23272 ------------------------------------------------------------------------------------
23273 -- 4219869 Business Flow
23274 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23275 ------------------------------------------------------------------------------------
23276 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23277
23278 ----------------------------------------------------------------------------------
23279 -- 4219869 Business Flow
23280 -- Update journal entry status -- Need to generate this within IF <condition>
23281 ----------------------------------------------------------------------------------
23282 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23283 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23284 ,p_balance_type_code => l_balance_type_code
23285 );
23286
23287 -------------------------------------------------------------------------------------------
23288 -- 4262811 - Generate the Accrual Reversal lines
23289 -------------------------------------------------------------------------------------------
23290 BEGIN
23291 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23292 (g_array_event(p_event_id).array_value_num('header_index'));
23293 IF l_acc_rev_flag IS NULL THEN
23294 l_acc_rev_flag := 'N';
23295 END IF;
23296 EXCEPTION
23297 WHEN OTHERS THEN
23298 l_acc_rev_flag := 'N';
23299 END;
23300 --
23301 IF (l_acc_rev_flag = 'Y') THEN
23302
23303 -- 4645092 ------------------------------------------------------------------------------
23304 -- To allow MPA report to determine if it should generate report process
23305 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23306 ------------------------------------------------------------------------------------------
23307
23308 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23309 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23310 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23311 -- call ADRs
23312 -- Bug 4922099
23313 --
23314 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23315 (NVL(l_actual_upg_option, 'N') = 'O') OR
23316 (NVL(l_enc_upg_option, 'N') = 'O')
23317 )
23318 THEN
23319 NULL;
23320 --
23321 --
23322
23323 l_ccid := AcctDerRule_6(
23324 p_application_id => p_application_id
23325 , p_ae_header_id => l_ae_header_id
23326 , p_source_11 => p_source_11
23327 , x_transaction_coa_id => l_adr_transaction_coa_id
23328 , x_accounting_coa_id => l_adr_accounting_coa_id
23329 , x_value_type_code => l_adr_value_type_code
23330 , p_side => 'NA'
23331 );
23332
23333 xla_ae_lines_pkg.set_ccid(
23334 p_code_combination_id => l_ccid
23335 , p_value_type_code => l_adr_value_type_code
23336 , p_transaction_coa_id => l_adr_transaction_coa_id
23337 , p_accounting_coa_id => l_adr_accounting_coa_id
23338 , p_adr_code => 'CST_DEFAULT'
23339 , p_adr_type_code => 'S'
23340 , p_component_type => l_component_type
23341 , p_component_code => l_component_code
23342 , p_component_type_code => l_component_type_code
23343 , p_component_appl_id => l_component_appl_id
23344 , p_amb_context_code => l_amb_context_code
23345 , p_side => 'NA'
23346 );
23347
23348
23349 --
23350 --
23351 END IF;
23352
23353 --
23354 -- Update the line information that should be overwritten
23355 --
23356 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23357 p_header_num => 1);
23358 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23359
23360 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23361
23362 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23363 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23364 END IF;
23365
23366 --
23367 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23368 --
23369 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23370 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23371 ELSE
23372 ---------------------------------------------------------------------------------------------------
23373 -- 4262811a Switch Sign
23374 ---------------------------------------------------------------------------------------------------
23375 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23376 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23377 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23378 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23379 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23380 -- 5132302
23381 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23382 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23383
23384 END IF;
23385
23386 -- 4955764
23387 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23388 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23389
23390
23391 XLA_AE_LINES_PKG.ValidateCurrentLine;
23392 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23393
23394 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23395 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23396 ,p_balance_type_code => l_balance_type_code);
23397
23398 END IF;
23399
23400 -----------------------------------------------------------------------------------------
23401 -- 4262811 Multiperiod Accounting
23402 -----------------------------------------------------------------------------------------
23403 -- No MPA option is assigned.
23404
23405
23406 END IF;
23407 END IF;
23408 --
23409
23410 --
23411 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23412 trace
23413 (p_msg => 'END of AcctLineType_67'
23414 ,p_level => C_LEVEL_PROCEDURE
23415 ,p_module => l_log_module);
23416 END IF;
23417 --
23418 EXCEPTION
23419 WHEN xla_exceptions_pkg.application_exception THEN
23420 RAISE;
23421 WHEN OTHERS THEN
23422 xla_exceptions_pkg.raise_message
23423 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_67');
23424 END AcctLineType_67;
23425 --
23426
23427 ---------------------------------------
23428 --
23429 -- PRIVATE FUNCTION
23430 -- AcctLineType_68
23431 --
23432 ---------------------------------------
23433 PROCEDURE AcctLineType_68 (
23434 p_application_id IN NUMBER
23435 ,p_event_id IN NUMBER
23436 ,p_calculate_acctd_flag IN VARCHAR2
23437 ,p_calculate_g_l_flag IN VARCHAR2
23438 ,p_actual_flag IN OUT VARCHAR2
23439 ,p_balance_type_code OUT VARCHAR2
23440 ,p_gain_or_loss_ref OUT VARCHAR2
23441
23442 --Cost Management Default Account
23443 , p_source_11 IN NUMBER
23444 --DISTRIBUTION_IDENTIFIER
23445 , p_source_84 IN NUMBER
23446 --Distribution Type
23447 , p_source_85 IN VARCHAR2
23448 , p_source_85_meaning IN VARCHAR2
23449 --Entered Currency Code
23450 , p_source_88 IN VARCHAR2
23451 --Entered Amount
23452 , p_source_91 IN NUMBER
23453 --Currency Conversion Date
23454 , p_source_92 IN DATE
23455 --Currency Conversion Rate
23456 , p_source_93 IN NUMBER
23457 --Currency Conversion Type
23458 , p_source_94 IN VARCHAR2
23459 --Accounted Amount
23460 , p_source_95 IN NUMBER
23461 --Accounting Line Type
23462 , p_source_97 IN NUMBER
23463 )
23464 IS
23465
23466 l_component_type VARCHAR2(80);
23467 l_component_code VARCHAR2(30);
23468 l_component_type_code VARCHAR2(1);
23469 l_component_appl_id INTEGER;
23470 l_amb_context_code VARCHAR2(30);
23471 l_entity_code VARCHAR2(30);
23472 l_event_class_code VARCHAR2(30);
23473 l_ae_header_id NUMBER;
23474 l_event_type_code VARCHAR2(30);
23475 l_line_definition_code VARCHAR2(30);
23476 l_line_definition_owner_code VARCHAR2(1);
23477 --
23478 -- adr variables
23479 l_segment VARCHAR2(30);
23480 l_ccid NUMBER;
23481 l_adr_transaction_coa_id NUMBER;
23482 l_adr_accounting_coa_id NUMBER;
23483 l_adr_flexfield_segment_code VARCHAR2(30);
23484 l_adr_flex_value_set_id NUMBER;
23485 l_adr_value_type_code VARCHAR2(30);
23486 l_adr_value_combination_id NUMBER;
23487 l_adr_value_segment_code VARCHAR2(30);
23488
23489 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23490 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23491 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23492 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23493
23494 -- 4262811 Variables ------------------------------------------------------------------------------------------
23495 l_entered_amt_idx NUMBER;
23496 l_accted_amt_idx NUMBER;
23497 l_acc_rev_flag VARCHAR2(1);
23498 l_accrual_line_num NUMBER;
23499 l_tmp_amt NUMBER;
23500 l_acc_rev_natural_side_code VARCHAR2(1);
23501
23502 l_num_entries NUMBER;
23503 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23504 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23505 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23506 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23507 l_recog_line_1 NUMBER;
23508 l_recog_line_2 NUMBER;
23509
23510 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23511 l_bflow_applied_to_amt NUMBER; -- 5132302
23512 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23513
23514 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23515
23516 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23517 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23518
23519 ---------------------------------------------------------------------------------------------------------------
23520
23521
23522 --
23523 -- bulk performance
23524 --
23525 l_balance_type_code VARCHAR2(1);
23526 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23527 l_log_module VARCHAR2(240);
23528
23529 --
23530 -- Upgrade strategy
23531 --
23532 l_actual_upg_option VARCHAR2(1);
23533 l_enc_upg_option VARCHAR2(1);
23534
23535 --
23536 BEGIN
23537 --
23538 IF g_log_enabled THEN
23539 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_68';
23540 END IF;
23541 --
23542 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23543
23544 trace
23545 (p_msg => 'BEGIN of AcctLineType_68'
23546 ,p_level => C_LEVEL_PROCEDURE
23547 ,p_module => l_log_module);
23548
23549 END IF;
23550 --
23551 l_component_type := 'AMB_JLT';
23552 l_component_code := 'COST_UPDATE_ADJUSTMENT';
23553 l_component_type_code := 'S';
23554 l_component_appl_id := 707;
23555 l_amb_context_code := 'DEFAULT';
23556 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
23557 l_event_class_code := 'SALES_ORDER';
23558 l_event_type_code := 'COGS_RECOGNITION_ADJ';
23559 l_line_definition_owner_code := 'S';
23560 l_line_definition_code := 'PI_COGS_RECOGNITION_ADJ';
23561 --
23562 l_balance_type_code := 'A';
23563 l_segment := NULL;
23564 l_ccid := NULL;
23565 l_adr_transaction_coa_id := NULL;
23566 l_adr_accounting_coa_id := NULL;
23567 l_adr_flexfield_segment_code := NULL;
23568 l_adr_flex_value_set_id := NULL;
23569 l_adr_value_type_code := NULL;
23570 l_adr_value_combination_id := NULL;
23571 l_adr_value_segment_code := NULL;
23572
23573 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23574 l_bflow_class_code := ''; -- 4219869 Business Flow
23575 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23576 l_budgetary_control_flag := 'N';
23577
23578 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23579 l_bflow_applied_to_amt := NULL; -- 5132302
23580 l_entered_amt_idx := NULL; -- 4262811
23581 l_accted_amt_idx := NULL; -- 4262811
23582 l_acc_rev_flag := NULL; -- 4262811
23583 l_accrual_line_num := NULL; -- 4262811
23584 l_tmp_amt := NULL; -- 4262811
23585 --
23586
23587 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23588 l_balance_type_code <> 'B' THEN
23589 IF NVL(p_source_97,9E125) = 37
23590 THEN
23591
23592 --
23593 XLA_AE_LINES_PKG.SetNewLine;
23594
23595 p_balance_type_code := l_balance_type_code;
23596 -- set the flag so later we will know whether the gain loss line needs to be created
23597
23598 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23599 p_actual_flag :='A';
23600 END IF;
23601
23602 --
23603 -- bulk performance
23604 --
23605 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23606 p_header_num => 0); -- 4262811
23607 --
23608 -- set accounting line options
23609 --
23610 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23611 p_natural_side_code => 'D'
23612 , p_gain_or_loss_flag => 'N'
23613 , p_gl_transfer_mode_code => 'S'
23614 , p_acct_entry_type_code => 'A'
23615 , p_switch_side_flag => 'Y'
23616 , p_merge_duplicate_code => 'N'
23617 );
23618 --
23619 l_acc_rev_natural_side_code := 'C'; -- 4262811
23620 --
23621 --
23622 -- set accounting line type info
23623 --
23624 xla_ae_lines_pkg.SetAcctLineType
23625 (p_component_type => l_component_type
23626 ,p_event_type_code => l_event_type_code
23627 ,p_line_definition_owner_code => l_line_definition_owner_code
23628 ,p_line_definition_code => l_line_definition_code
23629 ,p_accounting_line_code => l_component_code
23630 ,p_accounting_line_type_code => l_component_type_code
23631 ,p_accounting_line_appl_id => l_component_appl_id
23632 ,p_amb_context_code => l_amb_context_code
23633 ,p_entity_code => l_entity_code
23634 ,p_event_class_code => l_event_class_code);
23635 --
23636 -- set accounting class
23637 --
23638 xla_ae_lines_pkg.SetAcctClass(
23639 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
23640 , p_ae_header_id => l_ae_header_id
23641 );
23642
23643 --
23644 -- set rounding class
23645 --
23646 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23647 'COST_UPDATE_ADJUSTMENT';
23648
23649 --
23650 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23651 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23652 --
23653 -- bulk performance
23654 --
23655 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23656
23657 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23658 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23659
23660 -- 4955764
23661 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23662 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23663
23664 -- 4458381 Public Sector Enh
23665
23666 --
23667 -- set accounting attributes for the line type
23668 --
23669 l_entered_amt_idx := 3;
23670 l_accted_amt_idx := 8;
23671 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23672 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23673 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
23674 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23675 l_rec_acct_attrs.array_char_value(2) := p_source_85;
23676 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23677 l_rec_acct_attrs.array_num_value(3) := p_source_91;
23678 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23679 l_rec_acct_attrs.array_char_value(4) := p_source_88;
23680 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23681 l_rec_acct_attrs.array_date_value(5) := p_source_92;
23682 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23683 l_rec_acct_attrs.array_num_value(6) := p_source_93;
23684 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23685 l_rec_acct_attrs.array_char_value(7) := p_source_94;
23686 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23687 l_rec_acct_attrs.array_num_value(8) := p_source_95;
23688
23689 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23690 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23691
23692 ---------------------------------------------------------------------------------------------------------------
23693 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23694 ---------------------------------------------------------------------------------------------------------------
23695 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23696
23697 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23698 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23699
23700 IF xla_accounting_cache_pkg.GetValueChar
23701 (p_source_code => 'LEDGER_CATEGORY_CODE'
23702 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23703 AND l_bflow_method_code = 'PRIOR_ENTRY'
23704 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23705 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23706 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23707 )
23708 THEN
23709 xla_ae_lines_pkg.BflowUpgEntry
23710 (p_business_method_code => l_bflow_method_code
23711 ,p_business_class_code => l_bflow_class_code
23712 ,p_balance_type => l_balance_type_code);
23713 ELSE
23714 NULL;
23715 -- No business flow processing for business flow method of NONE.
23716 END IF;
23717
23718 --
23719 -- call analytical criteria
23720 --
23721
23722 --
23723 -- call description
23724 --
23725 -- No description or it is inherited.
23726 --
23727 -- call ADRs
23728 -- Bug 4922099
23729 --
23730 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23731 (NVL(l_actual_upg_option, 'N') = 'O') OR
23732 (NVL(l_enc_upg_option, 'N') = 'O')
23733 )
23734 THEN
23735 NULL;
23736 --
23737 --
23738
23739 l_ccid := AcctDerRule_6(
23740 p_application_id => p_application_id
23741 , p_ae_header_id => l_ae_header_id
23742 , p_source_11 => p_source_11
23743 , x_transaction_coa_id => l_adr_transaction_coa_id
23744 , x_accounting_coa_id => l_adr_accounting_coa_id
23745 , x_value_type_code => l_adr_value_type_code
23746 , p_side => 'NA'
23747 );
23748
23749 xla_ae_lines_pkg.set_ccid(
23750 p_code_combination_id => l_ccid
23751 , p_value_type_code => l_adr_value_type_code
23752 , p_transaction_coa_id => l_adr_transaction_coa_id
23753 , p_accounting_coa_id => l_adr_accounting_coa_id
23754 , p_adr_code => 'CST_DEFAULT'
23755 , p_adr_type_code => 'S'
23756 , p_component_type => l_component_type
23757 , p_component_code => l_component_code
23758 , p_component_type_code => l_component_type_code
23759 , p_component_appl_id => l_component_appl_id
23760 , p_amb_context_code => l_amb_context_code
23761 , p_side => 'NA'
23762 );
23763
23764
23765 --
23766 --
23767 END IF;
23768 --
23769 -- Bug 4922099
23770 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23771 (NVL(l_enc_upg_option, 'N') = 'O')
23772 ) AND
23773 (l_bflow_method_code = 'PRIOR_ENTRY')
23774 )
23775 THEN
23776 IF
23777 --
23778 1 = 2
23779 --
23780 THEN
23781 xla_accounting_err_pkg.build_message
23782 (p_appli_s_name => 'XLA'
23783 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23784 ,p_token_1 => 'LINE_NUMBER'
23785 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23786 ,p_token_2 => 'LINE_TYPE_NAME'
23787 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23788 l_component_type
23789 ,l_component_code
23790 ,l_component_type_code
23791 ,l_component_appl_id
23792 ,l_amb_context_code
23793 ,l_entity_code
23794 ,l_event_class_code
23795 )
23796 ,p_token_3 => 'OWNER'
23797 ,p_value_3 => xla_lookups_pkg.get_meaning(
23798 p_lookup_type => 'XLA_OWNER_TYPE'
23799 ,p_lookup_code => l_component_type_code
23800 )
23801 ,p_token_4 => 'PRODUCT_NAME'
23802 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23803 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23804 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23805 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23806 ,p_ae_header_id => NULL
23807 );
23808
23809 IF (C_LEVEL_ERROR>= g_log_level) THEN
23810 trace
23811 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23812 ,p_level => C_LEVEL_ERROR
23813 ,p_module => l_log_module);
23814 END IF;
23815 END IF;
23816 END IF;
23817 --
23818 --
23819 ------------------------------------------------------------------------------------------------
23820 -- 4219869 Business Flow
23821 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23822 -- Prior Entry. Currently, the following code is always generated.
23823 ------------------------------------------------------------------------------------------------
23824 XLA_AE_LINES_PKG.ValidateCurrentLine;
23825
23826 ------------------------------------------------------------------------------------
23827 -- 4219869 Business Flow
23828 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23829 ------------------------------------------------------------------------------------
23830 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23831
23832 ----------------------------------------------------------------------------------
23833 -- 4219869 Business Flow
23834 -- Update journal entry status -- Need to generate this within IF <condition>
23835 ----------------------------------------------------------------------------------
23836 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23837 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23838 ,p_balance_type_code => l_balance_type_code
23839 );
23840
23841 -------------------------------------------------------------------------------------------
23842 -- 4262811 - Generate the Accrual Reversal lines
23843 -------------------------------------------------------------------------------------------
23844 BEGIN
23845 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23846 (g_array_event(p_event_id).array_value_num('header_index'));
23847 IF l_acc_rev_flag IS NULL THEN
23848 l_acc_rev_flag := 'N';
23849 END IF;
23850 EXCEPTION
23851 WHEN OTHERS THEN
23852 l_acc_rev_flag := 'N';
23853 END;
23854 --
23855 IF (l_acc_rev_flag = 'Y') THEN
23856
23857 -- 4645092 ------------------------------------------------------------------------------
23858 -- To allow MPA report to determine if it should generate report process
23859 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23860 ------------------------------------------------------------------------------------------
23861
23862 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23863 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23864 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23865 -- call ADRs
23866 -- Bug 4922099
23867 --
23868 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23869 (NVL(l_actual_upg_option, 'N') = 'O') OR
23870 (NVL(l_enc_upg_option, 'N') = 'O')
23871 )
23872 THEN
23873 NULL;
23874 --
23875 --
23876
23877 l_ccid := AcctDerRule_6(
23878 p_application_id => p_application_id
23879 , p_ae_header_id => l_ae_header_id
23880 , p_source_11 => p_source_11
23881 , x_transaction_coa_id => l_adr_transaction_coa_id
23882 , x_accounting_coa_id => l_adr_accounting_coa_id
23883 , x_value_type_code => l_adr_value_type_code
23884 , p_side => 'NA'
23885 );
23886
23887 xla_ae_lines_pkg.set_ccid(
23888 p_code_combination_id => l_ccid
23889 , p_value_type_code => l_adr_value_type_code
23890 , p_transaction_coa_id => l_adr_transaction_coa_id
23891 , p_accounting_coa_id => l_adr_accounting_coa_id
23892 , p_adr_code => 'CST_DEFAULT'
23893 , p_adr_type_code => 'S'
23894 , p_component_type => l_component_type
23895 , p_component_code => l_component_code
23896 , p_component_type_code => l_component_type_code
23897 , p_component_appl_id => l_component_appl_id
23898 , p_amb_context_code => l_amb_context_code
23899 , p_side => 'NA'
23900 );
23901
23902
23903 --
23904 --
23905 END IF;
23906
23907 --
23908 -- Update the line information that should be overwritten
23909 --
23910 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23911 p_header_num => 1);
23912 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23913
23914 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23915
23916 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23917 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23918 END IF;
23919
23920 --
23921 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23922 --
23923 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23924 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23925 ELSE
23926 ---------------------------------------------------------------------------------------------------
23927 -- 4262811a Switch Sign
23928 ---------------------------------------------------------------------------------------------------
23929 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23930 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23931 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23932 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23933 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23934 -- 5132302
23935 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23936 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23937
23938 END IF;
23939
23940 -- 4955764
23941 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23942 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23943
23944
23945 XLA_AE_LINES_PKG.ValidateCurrentLine;
23946 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23947
23948 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23949 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23950 ,p_balance_type_code => l_balance_type_code);
23951
23952 END IF;
23953
23954 -----------------------------------------------------------------------------------------
23955 -- 4262811 Multiperiod Accounting
23956 -----------------------------------------------------------------------------------------
23957 -- No MPA option is assigned.
23958
23959
23960 END IF;
23961 END IF;
23962 --
23963
23964 --
23965 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23966 trace
23967 (p_msg => 'END of AcctLineType_68'
23968 ,p_level => C_LEVEL_PROCEDURE
23969 ,p_module => l_log_module);
23970 END IF;
23971 --
23972 EXCEPTION
23973 WHEN xla_exceptions_pkg.application_exception THEN
23974 RAISE;
23975 WHEN OTHERS THEN
23976 xla_exceptions_pkg.raise_message
23977 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_68');
23978 END AcctLineType_68;
23979 --
23980
23981 ---------------------------------------
23982 --
23983 -- PRIVATE FUNCTION
23984 -- AcctLineType_69
23985 --
23986 ---------------------------------------
23987 PROCEDURE AcctLineType_69 (
23988 p_application_id IN NUMBER
23989 ,p_event_id IN NUMBER
23990 ,p_calculate_acctd_flag IN VARCHAR2
23991 ,p_calculate_g_l_flag IN VARCHAR2
23992 ,p_actual_flag IN OUT VARCHAR2
23993 ,p_balance_type_code OUT VARCHAR2
23994 ,p_gain_or_loss_ref OUT VARCHAR2
23995
23996 --TRANSACTION_ID
23997 , p_source_1 IN NUMBER
23998 --Item Concatenated Segments
23999 , p_source_2 IN VARCHAR2
24000 --Transaction Quantity
24001 , p_source_3 IN NUMBER
24002 --Transaction Unit of Measure Code
24003 , p_source_4 IN VARCHAR2
24004 --Inventory Transaction Type Description
24005 , p_source_5 IN VARCHAR2
24006 --Transaction Material Account
24007 , p_source_14 IN NUMBER
24008 --Cost Element Name
24009 , p_source_15 IN NUMBER
24010 --Transaction Material Overhead Account
24011 , p_source_16 IN NUMBER
24012 --Transaction Resource Account
24013 , p_source_17 IN NUMBER
24014 --Transaction Outside Processing Account
24015 , p_source_18 IN NUMBER
24016 --Transaction Overhead Account
24017 , p_source_19 IN NUMBER
24018 --Transaction Distribution Account
24019 , p_source_20 IN NUMBER
24020 --DISTRIBUTION_IDENTIFIER
24021 , p_source_84 IN NUMBER
24022 --Distribution Type
24023 , p_source_85 IN VARCHAR2
24024 , p_source_85_meaning IN VARCHAR2
24025 --Entered Currency Code
24026 , p_source_88 IN VARCHAR2
24027 --Entered Amount
24028 , p_source_91 IN NUMBER
24029 --Currency Conversion Date
24030 , p_source_92 IN DATE
24031 --Currency Conversion Rate
24032 , p_source_93 IN NUMBER
24033 --Currency Conversion Type
24034 , p_source_94 IN VARCHAR2
24035 --Accounted Amount
24036 , p_source_95 IN NUMBER
24037 --Accounting Line Type
24038 , p_source_97 IN NUMBER
24039 )
24040 IS
24041
24042 l_component_type VARCHAR2(80);
24043 l_component_code VARCHAR2(30);
24044 l_component_type_code VARCHAR2(1);
24045 l_component_appl_id INTEGER;
24046 l_amb_context_code VARCHAR2(30);
24047 l_entity_code VARCHAR2(30);
24048 l_event_class_code VARCHAR2(30);
24049 l_ae_header_id NUMBER;
24050 l_event_type_code VARCHAR2(30);
24051 l_line_definition_code VARCHAR2(30);
24052 l_line_definition_owner_code VARCHAR2(1);
24053 --
24054 -- adr variables
24055 l_segment VARCHAR2(30);
24056 l_ccid NUMBER;
24057 l_adr_transaction_coa_id NUMBER;
24058 l_adr_accounting_coa_id NUMBER;
24059 l_adr_flexfield_segment_code VARCHAR2(30);
24060 l_adr_flex_value_set_id NUMBER;
24061 l_adr_value_type_code VARCHAR2(30);
24062 l_adr_value_combination_id NUMBER;
24063 l_adr_value_segment_code VARCHAR2(30);
24064
24065 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24066 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24067 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24068 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24069
24070 -- 4262811 Variables ------------------------------------------------------------------------------------------
24071 l_entered_amt_idx NUMBER;
24072 l_accted_amt_idx NUMBER;
24073 l_acc_rev_flag VARCHAR2(1);
24074 l_accrual_line_num NUMBER;
24075 l_tmp_amt NUMBER;
24076 l_acc_rev_natural_side_code VARCHAR2(1);
24077
24078 l_num_entries NUMBER;
24079 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24080 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24081 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24082 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24083 l_recog_line_1 NUMBER;
24084 l_recog_line_2 NUMBER;
24085
24086 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24087 l_bflow_applied_to_amt NUMBER; -- 5132302
24088 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24089
24090 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24091
24092 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24093 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24094
24095 ---------------------------------------------------------------------------------------------------------------
24096
24097
24098 --
24099 -- bulk performance
24100 --
24101 l_balance_type_code VARCHAR2(1);
24102 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24103 l_log_module VARCHAR2(240);
24104
24105 --
24106 -- Upgrade strategy
24107 --
24108 l_actual_upg_option VARCHAR2(1);
24109 l_enc_upg_option VARCHAR2(1);
24110
24111 --
24112 BEGIN
24113 --
24114 IF g_log_enabled THEN
24115 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_69';
24116 END IF;
24117 --
24118 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24119
24120 trace
24121 (p_msg => 'BEGIN of AcctLineType_69'
24122 ,p_level => C_LEVEL_PROCEDURE
24123 ,p_module => l_log_module);
24124
24125 END IF;
24126 --
24127 l_component_type := 'AMB_JLT';
24128 l_component_code := 'COST_UPDATE_ADJUSTMENT';
24129 l_component_type_code := 'S';
24130 l_component_appl_id := 707;
24131 l_amb_context_code := 'DEFAULT';
24132 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
24133 l_event_class_code := 'USER_DEFINE';
24134 l_event_type_code := 'UAVG_COST_UPD';
24135 l_line_definition_owner_code := 'S';
24136 l_line_definition_code := 'PI_COST_UPD';
24137 --
24138 l_balance_type_code := 'A';
24139 l_segment := NULL;
24140 l_ccid := NULL;
24141 l_adr_transaction_coa_id := NULL;
24142 l_adr_accounting_coa_id := NULL;
24143 l_adr_flexfield_segment_code := NULL;
24144 l_adr_flex_value_set_id := NULL;
24145 l_adr_value_type_code := NULL;
24146 l_adr_value_combination_id := NULL;
24147 l_adr_value_segment_code := NULL;
24148
24149 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24150 l_bflow_class_code := ''; -- 4219869 Business Flow
24151 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24152 l_budgetary_control_flag := 'N';
24153
24154 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24155 l_bflow_applied_to_amt := NULL; -- 5132302
24156 l_entered_amt_idx := NULL; -- 4262811
24157 l_accted_amt_idx := NULL; -- 4262811
24158 l_acc_rev_flag := NULL; -- 4262811
24159 l_accrual_line_num := NULL; -- 4262811
24160 l_tmp_amt := NULL; -- 4262811
24161 --
24162
24163 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24164 l_balance_type_code <> 'B' THEN
24165 IF NVL(p_source_97,9E125) = 2
24166 THEN
24167
24168 --
24169 XLA_AE_LINES_PKG.SetNewLine;
24170
24171 p_balance_type_code := l_balance_type_code;
24172 -- set the flag so later we will know whether the gain loss line needs to be created
24173
24174 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24175 p_actual_flag :='A';
24176 END IF;
24177
24178 --
24179 -- bulk performance
24180 --
24181 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24182 p_header_num => 0); -- 4262811
24183 --
24184 -- set accounting line options
24185 --
24186 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24187 p_natural_side_code => 'D'
24188 , p_gain_or_loss_flag => 'N'
24189 , p_gl_transfer_mode_code => 'S'
24190 , p_acct_entry_type_code => 'A'
24191 , p_switch_side_flag => 'Y'
24192 , p_merge_duplicate_code => 'N'
24193 );
24194 --
24195 l_acc_rev_natural_side_code := 'C'; -- 4262811
24196 --
24197 --
24198 -- set accounting line type info
24199 --
24200 xla_ae_lines_pkg.SetAcctLineType
24201 (p_component_type => l_component_type
24202 ,p_event_type_code => l_event_type_code
24203 ,p_line_definition_owner_code => l_line_definition_owner_code
24204 ,p_line_definition_code => l_line_definition_code
24205 ,p_accounting_line_code => l_component_code
24206 ,p_accounting_line_type_code => l_component_type_code
24207 ,p_accounting_line_appl_id => l_component_appl_id
24208 ,p_amb_context_code => l_amb_context_code
24209 ,p_entity_code => l_entity_code
24210 ,p_event_class_code => l_event_class_code);
24211 --
24212 -- set accounting class
24213 --
24214 xla_ae_lines_pkg.SetAcctClass(
24215 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
24216 , p_ae_header_id => l_ae_header_id
24217 );
24218
24219 --
24220 -- set rounding class
24221 --
24222 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24223 'COST_UPDATE_ADJUSTMENT';
24224
24225 --
24226 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24227 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24228 --
24229 -- bulk performance
24230 --
24231 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24232
24233 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24234 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24235
24236 -- 4955764
24237 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24238 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24239
24240 -- 4458381 Public Sector Enh
24241
24242 --
24243 -- set accounting attributes for the line type
24244 --
24245 l_entered_amt_idx := 3;
24246 l_accted_amt_idx := 8;
24247 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24248 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24249 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
24250 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24251 l_rec_acct_attrs.array_char_value(2) := p_source_85;
24252 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24253 l_rec_acct_attrs.array_num_value(3) := p_source_91;
24254 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24255 l_rec_acct_attrs.array_char_value(4) := p_source_88;
24256 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24257 l_rec_acct_attrs.array_date_value(5) := p_source_92;
24258 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24259 l_rec_acct_attrs.array_num_value(6) := p_source_93;
24260 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24261 l_rec_acct_attrs.array_char_value(7) := p_source_94;
24262 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24263 l_rec_acct_attrs.array_num_value(8) := p_source_95;
24264
24265 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24266 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24267
24268 ---------------------------------------------------------------------------------------------------------------
24269 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24270 ---------------------------------------------------------------------------------------------------------------
24271 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24272
24273 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24274 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24275
24276 IF xla_accounting_cache_pkg.GetValueChar
24277 (p_source_code => 'LEDGER_CATEGORY_CODE'
24278 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24279 AND l_bflow_method_code = 'PRIOR_ENTRY'
24280 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24281 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24282 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24283 )
24284 THEN
24285 xla_ae_lines_pkg.BflowUpgEntry
24286 (p_business_method_code => l_bflow_method_code
24287 ,p_business_class_code => l_bflow_class_code
24288 ,p_balance_type => l_balance_type_code);
24289 ELSE
24290 NULL;
24291 -- No business flow processing for business flow method of NONE.
24292 END IF;
24293
24294 --
24295 -- call analytical criteria
24296 --
24297
24298 --
24299 -- call description
24300 --
24301
24302 xla_ae_lines_pkg.SetLineDescription(
24303 p_ae_header_id => l_ae_header_id
24304 ,p_description => Description_1 (
24305 p_application_id => p_application_id
24306 , p_ae_header_id => l_ae_header_id
24307 , p_source_1 => p_source_1
24308 , p_source_2 => p_source_2
24309 , p_source_3 => p_source_3
24310 , p_source_4 => p_source_4
24311 , p_source_5 => p_source_5
24312 )
24313 );
24314
24315
24316 --
24317 -- call ADRs
24318 -- Bug 4922099
24319 --
24320 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24321 (NVL(l_actual_upg_option, 'N') = 'O') OR
24322 (NVL(l_enc_upg_option, 'N') = 'O')
24323 )
24324 THEN
24325 NULL;
24326 --
24327 --
24328
24329 l_ccid := AcctDerRule_9(
24330 p_application_id => p_application_id
24331 , p_ae_header_id => l_ae_header_id
24332 , p_source_14 => p_source_14
24333 , p_source_15 => p_source_15
24334 , p_source_16 => p_source_16
24335 , p_source_17 => p_source_17
24336 , p_source_18 => p_source_18
24337 , p_source_19 => p_source_19
24338 , p_source_20 => p_source_20
24339 , x_transaction_coa_id => l_adr_transaction_coa_id
24340 , x_accounting_coa_id => l_adr_accounting_coa_id
24341 , x_value_type_code => l_adr_value_type_code
24342 , p_side => 'NA'
24343 );
24344
24345 xla_ae_lines_pkg.set_ccid(
24346 p_code_combination_id => l_ccid
24347 , p_value_type_code => l_adr_value_type_code
24348 , p_transaction_coa_id => l_adr_transaction_coa_id
24349 , p_accounting_coa_id => l_adr_accounting_coa_id
24350 , p_adr_code => 'PI_AVG_COST_UPT_OFFSET'
24351 , p_adr_type_code => 'S'
24352 , p_component_type => l_component_type
24353 , p_component_code => l_component_code
24354 , p_component_type_code => l_component_type_code
24355 , p_component_appl_id => l_component_appl_id
24356 , p_amb_context_code => l_amb_context_code
24357 , p_side => 'NA'
24358 );
24359
24360
24361 --
24362 --
24363 END IF;
24364 --
24365 -- Bug 4922099
24366 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24367 (NVL(l_enc_upg_option, 'N') = 'O')
24368 ) AND
24369 (l_bflow_method_code = 'PRIOR_ENTRY')
24370 )
24371 THEN
24372 IF
24373 --
24374 1 = 2
24375 --
24376 THEN
24377 xla_accounting_err_pkg.build_message
24378 (p_appli_s_name => 'XLA'
24379 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24380 ,p_token_1 => 'LINE_NUMBER'
24381 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24382 ,p_token_2 => 'LINE_TYPE_NAME'
24383 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24384 l_component_type
24385 ,l_component_code
24386 ,l_component_type_code
24387 ,l_component_appl_id
24388 ,l_amb_context_code
24389 ,l_entity_code
24390 ,l_event_class_code
24391 )
24392 ,p_token_3 => 'OWNER'
24393 ,p_value_3 => xla_lookups_pkg.get_meaning(
24394 p_lookup_type => 'XLA_OWNER_TYPE'
24395 ,p_lookup_code => l_component_type_code
24396 )
24397 ,p_token_4 => 'PRODUCT_NAME'
24398 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24399 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24400 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24401 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24402 ,p_ae_header_id => NULL
24403 );
24404
24405 IF (C_LEVEL_ERROR>= g_log_level) THEN
24406 trace
24407 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24408 ,p_level => C_LEVEL_ERROR
24409 ,p_module => l_log_module);
24410 END IF;
24411 END IF;
24412 END IF;
24413 --
24414 --
24415 ------------------------------------------------------------------------------------------------
24416 -- 4219869 Business Flow
24417 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24418 -- Prior Entry. Currently, the following code is always generated.
24419 ------------------------------------------------------------------------------------------------
24420 XLA_AE_LINES_PKG.ValidateCurrentLine;
24421
24422 ------------------------------------------------------------------------------------
24423 -- 4219869 Business Flow
24424 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24425 ------------------------------------------------------------------------------------
24426 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24427
24428 ----------------------------------------------------------------------------------
24429 -- 4219869 Business Flow
24430 -- Update journal entry status -- Need to generate this within IF <condition>
24431 ----------------------------------------------------------------------------------
24432 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24433 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24434 ,p_balance_type_code => l_balance_type_code
24435 );
24436
24437 -------------------------------------------------------------------------------------------
24438 -- 4262811 - Generate the Accrual Reversal lines
24439 -------------------------------------------------------------------------------------------
24440 BEGIN
24441 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24442 (g_array_event(p_event_id).array_value_num('header_index'));
24443 IF l_acc_rev_flag IS NULL THEN
24444 l_acc_rev_flag := 'N';
24445 END IF;
24446 EXCEPTION
24447 WHEN OTHERS THEN
24448 l_acc_rev_flag := 'N';
24449 END;
24450 --
24451 IF (l_acc_rev_flag = 'Y') THEN
24452
24453 -- 4645092 ------------------------------------------------------------------------------
24454 -- To allow MPA report to determine if it should generate report process
24455 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24456 ------------------------------------------------------------------------------------------
24457
24458 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24459 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24460 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24461 -- call ADRs
24462 -- Bug 4922099
24463 --
24464 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24465 (NVL(l_actual_upg_option, 'N') = 'O') OR
24466 (NVL(l_enc_upg_option, 'N') = 'O')
24467 )
24468 THEN
24469 NULL;
24470 --
24471 --
24472
24473 l_ccid := AcctDerRule_9(
24474 p_application_id => p_application_id
24475 , p_ae_header_id => l_ae_header_id
24476 , p_source_14 => p_source_14
24477 , p_source_15 => p_source_15
24478 , p_source_16 => p_source_16
24479 , p_source_17 => p_source_17
24480 , p_source_18 => p_source_18
24481 , p_source_19 => p_source_19
24482 , p_source_20 => p_source_20
24483 , x_transaction_coa_id => l_adr_transaction_coa_id
24484 , x_accounting_coa_id => l_adr_accounting_coa_id
24485 , x_value_type_code => l_adr_value_type_code
24486 , p_side => 'NA'
24487 );
24488
24489 xla_ae_lines_pkg.set_ccid(
24490 p_code_combination_id => l_ccid
24491 , p_value_type_code => l_adr_value_type_code
24492 , p_transaction_coa_id => l_adr_transaction_coa_id
24493 , p_accounting_coa_id => l_adr_accounting_coa_id
24494 , p_adr_code => 'PI_AVG_COST_UPT_OFFSET'
24495 , p_adr_type_code => 'S'
24496 , p_component_type => l_component_type
24497 , p_component_code => l_component_code
24498 , p_component_type_code => l_component_type_code
24499 , p_component_appl_id => l_component_appl_id
24500 , p_amb_context_code => l_amb_context_code
24501 , p_side => 'NA'
24502 );
24503
24504
24505 --
24506 --
24507 END IF;
24508
24509 --
24510 -- Update the line information that should be overwritten
24511 --
24512 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24513 p_header_num => 1);
24514 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24515
24516 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24517
24518 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24519 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24520 END IF;
24521
24522 --
24523 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24524 --
24525 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24526 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24527 ELSE
24528 ---------------------------------------------------------------------------------------------------
24529 -- 4262811a Switch Sign
24530 ---------------------------------------------------------------------------------------------------
24531 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24532 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24533 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24534 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24535 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24536 -- 5132302
24537 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24538 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24539
24540 END IF;
24541
24542 -- 4955764
24543 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24544 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24545
24546
24547 XLA_AE_LINES_PKG.ValidateCurrentLine;
24548 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24549
24550 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24551 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24552 ,p_balance_type_code => l_balance_type_code);
24553
24554 END IF;
24555
24556 -----------------------------------------------------------------------------------------
24557 -- 4262811 Multiperiod Accounting
24558 -----------------------------------------------------------------------------------------
24559 -- No MPA option is assigned.
24560
24561
24562 END IF;
24563 END IF;
24564 --
24565
24566 --
24567 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24568 trace
24569 (p_msg => 'END of AcctLineType_69'
24570 ,p_level => C_LEVEL_PROCEDURE
24571 ,p_module => l_log_module);
24572 END IF;
24573 --
24574 EXCEPTION
24575 WHEN xla_exceptions_pkg.application_exception THEN
24576 RAISE;
24577 WHEN OTHERS THEN
24578 xla_exceptions_pkg.raise_message
24579 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_69');
24580 END AcctLineType_69;
24581 --
24582
24583 ---------------------------------------
24584 --
24585 -- PRIVATE FUNCTION
24586 -- AcctLineType_70
24587 --
24588 ---------------------------------------
24589 PROCEDURE AcctLineType_70 (
24590 p_application_id IN NUMBER
24591 ,p_event_id IN NUMBER
24592 ,p_calculate_acctd_flag IN VARCHAR2
24593 ,p_calculate_g_l_flag IN VARCHAR2
24594 ,p_actual_flag IN OUT VARCHAR2
24595 ,p_balance_type_code OUT VARCHAR2
24596 ,p_gain_or_loss_ref OUT VARCHAR2
24597
24598 --TRANSACTION_ID
24599 , p_source_1 IN NUMBER
24600 --Item Concatenated Segments
24601 , p_source_2 IN VARCHAR2
24602 --Transaction Quantity
24603 , p_source_3 IN NUMBER
24604 --Transaction Unit of Measure Code
24605 , p_source_4 IN VARCHAR2
24606 --Inventory Transaction Type Description
24607 , p_source_5 IN VARCHAR2
24608 --Cost Management Default Account
24609 , p_source_11 IN NUMBER
24610 --DISTRIBUTION_IDENTIFIER
24611 , p_source_84 IN NUMBER
24612 --Distribution Type
24613 , p_source_85 IN VARCHAR2
24614 , p_source_85_meaning IN VARCHAR2
24615 --Entered Currency Code
24616 , p_source_88 IN VARCHAR2
24617 --Entered Amount
24618 , p_source_91 IN NUMBER
24619 --Currency Conversion Date
24620 , p_source_92 IN DATE
24621 --Currency Conversion Rate
24622 , p_source_93 IN NUMBER
24623 --Currency Conversion Type
24624 , p_source_94 IN VARCHAR2
24625 --Accounted Amount
24626 , p_source_95 IN NUMBER
24627 --Accounting Line Type
24628 , p_source_97 IN NUMBER
24629 )
24630 IS
24631
24632 l_component_type VARCHAR2(80);
24633 l_component_code VARCHAR2(30);
24634 l_component_type_code VARCHAR2(1);
24635 l_component_appl_id INTEGER;
24636 l_amb_context_code VARCHAR2(30);
24637 l_entity_code VARCHAR2(30);
24638 l_event_class_code VARCHAR2(30);
24639 l_ae_header_id NUMBER;
24640 l_event_type_code VARCHAR2(30);
24641 l_line_definition_code VARCHAR2(30);
24642 l_line_definition_owner_code VARCHAR2(1);
24643 --
24644 -- adr variables
24645 l_segment VARCHAR2(30);
24646 l_ccid NUMBER;
24647 l_adr_transaction_coa_id NUMBER;
24648 l_adr_accounting_coa_id NUMBER;
24649 l_adr_flexfield_segment_code VARCHAR2(30);
24650 l_adr_flex_value_set_id NUMBER;
24651 l_adr_value_type_code VARCHAR2(30);
24652 l_adr_value_combination_id NUMBER;
24653 l_adr_value_segment_code VARCHAR2(30);
24654
24655 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24656 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24657 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24658 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24659
24660 -- 4262811 Variables ------------------------------------------------------------------------------------------
24661 l_entered_amt_idx NUMBER;
24662 l_accted_amt_idx NUMBER;
24663 l_acc_rev_flag VARCHAR2(1);
24664 l_accrual_line_num NUMBER;
24665 l_tmp_amt NUMBER;
24666 l_acc_rev_natural_side_code VARCHAR2(1);
24667
24668 l_num_entries NUMBER;
24669 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24670 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24671 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24672 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24673 l_recog_line_1 NUMBER;
24674 l_recog_line_2 NUMBER;
24675
24676 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24677 l_bflow_applied_to_amt NUMBER; -- 5132302
24678 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24679
24680 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24681
24682 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24683 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24684
24685 ---------------------------------------------------------------------------------------------------------------
24686
24687
24688 --
24689 -- bulk performance
24690 --
24691 l_balance_type_code VARCHAR2(1);
24692 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24693 l_log_module VARCHAR2(240);
24694
24695 --
24696 -- Upgrade strategy
24697 --
24698 l_actual_upg_option VARCHAR2(1);
24699 l_enc_upg_option VARCHAR2(1);
24700
24701 --
24702 BEGIN
24703 --
24704 IF g_log_enabled THEN
24705 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_70';
24706 END IF;
24707 --
24708 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24709
24710 trace
24711 (p_msg => 'BEGIN of AcctLineType_70'
24712 ,p_level => C_LEVEL_PROCEDURE
24713 ,p_module => l_log_module);
24714
24715 END IF;
24716 --
24717 l_component_type := 'AMB_JLT';
24718 l_component_code := 'COST_UPDATE_ADJUSTMENT';
24719 l_component_type_code := 'S';
24720 l_component_appl_id := 707;
24721 l_amb_context_code := 'DEFAULT';
24722 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
24723 l_event_class_code := 'MTL_COST_UPD';
24724 l_event_type_code := 'AVG_COST_UPD';
24725 l_line_definition_owner_code := 'S';
24726 l_line_definition_code := 'PI_AVG_COST_UPD';
24727 --
24728 l_balance_type_code := 'A';
24729 l_segment := NULL;
24730 l_ccid := NULL;
24731 l_adr_transaction_coa_id := NULL;
24732 l_adr_accounting_coa_id := NULL;
24733 l_adr_flexfield_segment_code := NULL;
24734 l_adr_flex_value_set_id := NULL;
24735 l_adr_value_type_code := NULL;
24736 l_adr_value_combination_id := NULL;
24737 l_adr_value_segment_code := NULL;
24738
24739 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24740 l_bflow_class_code := ''; -- 4219869 Business Flow
24741 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24742 l_budgetary_control_flag := 'N';
24743
24744 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24745 l_bflow_applied_to_amt := NULL; -- 5132302
24746 l_entered_amt_idx := NULL; -- 4262811
24747 l_accted_amt_idx := NULL; -- 4262811
24748 l_acc_rev_flag := NULL; -- 4262811
24749 l_accrual_line_num := NULL; -- 4262811
24750 l_tmp_amt := NULL; -- 4262811
24751 --
24752
24753 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24754 l_balance_type_code <> 'B' THEN
24755 IF NVL(p_source_97,9E125) = 2
24756 THEN
24757
24758 --
24759 XLA_AE_LINES_PKG.SetNewLine;
24760
24761 p_balance_type_code := l_balance_type_code;
24762 -- set the flag so later we will know whether the gain loss line needs to be created
24763
24764 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24765 p_actual_flag :='A';
24766 END IF;
24767
24768 --
24769 -- bulk performance
24770 --
24771 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24772 p_header_num => 0); -- 4262811
24773 --
24774 -- set accounting line options
24775 --
24776 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24777 p_natural_side_code => 'D'
24778 , p_gain_or_loss_flag => 'N'
24779 , p_gl_transfer_mode_code => 'S'
24780 , p_acct_entry_type_code => 'A'
24781 , p_switch_side_flag => 'Y'
24782 , p_merge_duplicate_code => 'N'
24783 );
24784 --
24785 l_acc_rev_natural_side_code := 'C'; -- 4262811
24786 --
24787 --
24788 -- set accounting line type info
24789 --
24790 xla_ae_lines_pkg.SetAcctLineType
24791 (p_component_type => l_component_type
24792 ,p_event_type_code => l_event_type_code
24793 ,p_line_definition_owner_code => l_line_definition_owner_code
24794 ,p_line_definition_code => l_line_definition_code
24795 ,p_accounting_line_code => l_component_code
24796 ,p_accounting_line_type_code => l_component_type_code
24797 ,p_accounting_line_appl_id => l_component_appl_id
24798 ,p_amb_context_code => l_amb_context_code
24799 ,p_entity_code => l_entity_code
24800 ,p_event_class_code => l_event_class_code);
24801 --
24802 -- set accounting class
24803 --
24804 xla_ae_lines_pkg.SetAcctClass(
24805 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
24806 , p_ae_header_id => l_ae_header_id
24807 );
24808
24809 --
24810 -- set rounding class
24811 --
24812 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24813 'COST_UPDATE_ADJUSTMENT';
24814
24815 --
24816 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24817 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24818 --
24819 -- bulk performance
24820 --
24821 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24822
24823 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24824 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24825
24826 -- 4955764
24827 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24828 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24829
24830 -- 4458381 Public Sector Enh
24831
24832 --
24833 -- set accounting attributes for the line type
24834 --
24835 l_entered_amt_idx := 3;
24836 l_accted_amt_idx := 8;
24837 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24838 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24839 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
24840 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24841 l_rec_acct_attrs.array_char_value(2) := p_source_85;
24842 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24843 l_rec_acct_attrs.array_num_value(3) := p_source_91;
24844 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24845 l_rec_acct_attrs.array_char_value(4) := p_source_88;
24846 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24847 l_rec_acct_attrs.array_date_value(5) := p_source_92;
24848 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24849 l_rec_acct_attrs.array_num_value(6) := p_source_93;
24850 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24851 l_rec_acct_attrs.array_char_value(7) := p_source_94;
24852 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24853 l_rec_acct_attrs.array_num_value(8) := p_source_95;
24854
24855 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24856 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24857
24858 ---------------------------------------------------------------------------------------------------------------
24859 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24860 ---------------------------------------------------------------------------------------------------------------
24861 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24862
24863 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24864 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24865
24866 IF xla_accounting_cache_pkg.GetValueChar
24867 (p_source_code => 'LEDGER_CATEGORY_CODE'
24868 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24869 AND l_bflow_method_code = 'PRIOR_ENTRY'
24870 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24871 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24872 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24873 )
24874 THEN
24875 xla_ae_lines_pkg.BflowUpgEntry
24876 (p_business_method_code => l_bflow_method_code
24877 ,p_business_class_code => l_bflow_class_code
24878 ,p_balance_type => l_balance_type_code);
24879 ELSE
24880 NULL;
24881 -- No business flow processing for business flow method of NONE.
24882 END IF;
24883
24884 --
24885 -- call analytical criteria
24886 --
24887
24888 --
24889 -- call description
24890 --
24891
24892 xla_ae_lines_pkg.SetLineDescription(
24893 p_ae_header_id => l_ae_header_id
24894 ,p_description => Description_1 (
24895 p_application_id => p_application_id
24896 , p_ae_header_id => l_ae_header_id
24897 , p_source_1 => p_source_1
24898 , p_source_2 => p_source_2
24899 , p_source_3 => p_source_3
24900 , p_source_4 => p_source_4
24901 , p_source_5 => p_source_5
24902 )
24903 );
24904
24905
24906 --
24907 -- call ADRs
24908 -- Bug 4922099
24909 --
24910 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24911 (NVL(l_actual_upg_option, 'N') = 'O') OR
24912 (NVL(l_enc_upg_option, 'N') = 'O')
24913 )
24914 THEN
24915 NULL;
24916 --
24917 --
24918
24919 l_ccid := AcctDerRule_6(
24920 p_application_id => p_application_id
24921 , p_ae_header_id => l_ae_header_id
24922 , p_source_11 => p_source_11
24923 , x_transaction_coa_id => l_adr_transaction_coa_id
24924 , x_accounting_coa_id => l_adr_accounting_coa_id
24925 , x_value_type_code => l_adr_value_type_code
24926 , p_side => 'NA'
24927 );
24928
24929 xla_ae_lines_pkg.set_ccid(
24930 p_code_combination_id => l_ccid
24931 , p_value_type_code => l_adr_value_type_code
24932 , p_transaction_coa_id => l_adr_transaction_coa_id
24933 , p_accounting_coa_id => l_adr_accounting_coa_id
24934 , p_adr_code => 'CST_DEFAULT'
24935 , p_adr_type_code => 'S'
24936 , p_component_type => l_component_type
24937 , p_component_code => l_component_code
24938 , p_component_type_code => l_component_type_code
24939 , p_component_appl_id => l_component_appl_id
24940 , p_amb_context_code => l_amb_context_code
24941 , p_side => 'NA'
24942 );
24943
24944
24945 --
24946 --
24947 END IF;
24948 --
24949 -- Bug 4922099
24950 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24951 (NVL(l_enc_upg_option, 'N') = 'O')
24952 ) AND
24953 (l_bflow_method_code = 'PRIOR_ENTRY')
24954 )
24955 THEN
24956 IF
24957 --
24958 1 = 2
24959 --
24960 THEN
24961 xla_accounting_err_pkg.build_message
24962 (p_appli_s_name => 'XLA'
24963 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24964 ,p_token_1 => 'LINE_NUMBER'
24965 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24966 ,p_token_2 => 'LINE_TYPE_NAME'
24967 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24968 l_component_type
24969 ,l_component_code
24970 ,l_component_type_code
24971 ,l_component_appl_id
24972 ,l_amb_context_code
24973 ,l_entity_code
24974 ,l_event_class_code
24975 )
24976 ,p_token_3 => 'OWNER'
24977 ,p_value_3 => xla_lookups_pkg.get_meaning(
24978 p_lookup_type => 'XLA_OWNER_TYPE'
24979 ,p_lookup_code => l_component_type_code
24980 )
24981 ,p_token_4 => 'PRODUCT_NAME'
24982 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24983 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24984 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24985 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24986 ,p_ae_header_id => NULL
24987 );
24988
24989 IF (C_LEVEL_ERROR>= g_log_level) THEN
24990 trace
24991 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24992 ,p_level => C_LEVEL_ERROR
24993 ,p_module => l_log_module);
24994 END IF;
24995 END IF;
24996 END IF;
24997 --
24998 --
24999 ------------------------------------------------------------------------------------------------
25000 -- 4219869 Business Flow
25001 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25002 -- Prior Entry. Currently, the following code is always generated.
25003 ------------------------------------------------------------------------------------------------
25004 XLA_AE_LINES_PKG.ValidateCurrentLine;
25005
25006 ------------------------------------------------------------------------------------
25007 -- 4219869 Business Flow
25008 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25009 ------------------------------------------------------------------------------------
25010 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25011
25012 ----------------------------------------------------------------------------------
25013 -- 4219869 Business Flow
25014 -- Update journal entry status -- Need to generate this within IF <condition>
25015 ----------------------------------------------------------------------------------
25016 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25017 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25018 ,p_balance_type_code => l_balance_type_code
25019 );
25020
25021 -------------------------------------------------------------------------------------------
25022 -- 4262811 - Generate the Accrual Reversal lines
25023 -------------------------------------------------------------------------------------------
25024 BEGIN
25025 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25026 (g_array_event(p_event_id).array_value_num('header_index'));
25027 IF l_acc_rev_flag IS NULL THEN
25028 l_acc_rev_flag := 'N';
25029 END IF;
25030 EXCEPTION
25031 WHEN OTHERS THEN
25032 l_acc_rev_flag := 'N';
25033 END;
25034 --
25035 IF (l_acc_rev_flag = 'Y') THEN
25036
25037 -- 4645092 ------------------------------------------------------------------------------
25038 -- To allow MPA report to determine if it should generate report process
25039 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25040 ------------------------------------------------------------------------------------------
25041
25042 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25043 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25044 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25045 -- call ADRs
25046 -- Bug 4922099
25047 --
25048 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25049 (NVL(l_actual_upg_option, 'N') = 'O') OR
25050 (NVL(l_enc_upg_option, 'N') = 'O')
25051 )
25052 THEN
25053 NULL;
25054 --
25055 --
25056
25057 l_ccid := AcctDerRule_6(
25058 p_application_id => p_application_id
25059 , p_ae_header_id => l_ae_header_id
25060 , p_source_11 => p_source_11
25061 , x_transaction_coa_id => l_adr_transaction_coa_id
25062 , x_accounting_coa_id => l_adr_accounting_coa_id
25063 , x_value_type_code => l_adr_value_type_code
25064 , p_side => 'NA'
25065 );
25066
25067 xla_ae_lines_pkg.set_ccid(
25068 p_code_combination_id => l_ccid
25069 , p_value_type_code => l_adr_value_type_code
25070 , p_transaction_coa_id => l_adr_transaction_coa_id
25071 , p_accounting_coa_id => l_adr_accounting_coa_id
25072 , p_adr_code => 'CST_DEFAULT'
25073 , p_adr_type_code => 'S'
25074 , p_component_type => l_component_type
25075 , p_component_code => l_component_code
25076 , p_component_type_code => l_component_type_code
25077 , p_component_appl_id => l_component_appl_id
25078 , p_amb_context_code => l_amb_context_code
25079 , p_side => 'NA'
25080 );
25081
25082
25083 --
25084 --
25085 END IF;
25086
25087 --
25088 -- Update the line information that should be overwritten
25089 --
25090 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25091 p_header_num => 1);
25092 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25093
25094 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25095
25096 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25097 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25098 END IF;
25099
25100 --
25101 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25102 --
25103 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25104 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25105 ELSE
25106 ---------------------------------------------------------------------------------------------------
25107 -- 4262811a Switch Sign
25108 ---------------------------------------------------------------------------------------------------
25109 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25110 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25111 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25112 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25113 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25114 -- 5132302
25115 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25116 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25117
25118 END IF;
25119
25120 -- 4955764
25121 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25122 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25123
25124
25125 XLA_AE_LINES_PKG.ValidateCurrentLine;
25126 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25127
25128 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25129 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25130 ,p_balance_type_code => l_balance_type_code);
25131
25132 END IF;
25133
25134 -----------------------------------------------------------------------------------------
25135 -- 4262811 Multiperiod Accounting
25136 -----------------------------------------------------------------------------------------
25137 -- No MPA option is assigned.
25138
25139
25140 END IF;
25141 END IF;
25142 --
25143
25144 --
25145 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25146 trace
25147 (p_msg => 'END of AcctLineType_70'
25148 ,p_level => C_LEVEL_PROCEDURE
25149 ,p_module => l_log_module);
25150 END IF;
25151 --
25152 EXCEPTION
25153 WHEN xla_exceptions_pkg.application_exception THEN
25154 RAISE;
25155 WHEN OTHERS THEN
25156 xla_exceptions_pkg.raise_message
25157 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_70');
25158 END AcctLineType_70;
25159 --
25160
25161 ---------------------------------------
25162 --
25163 -- PRIVATE FUNCTION
25164 -- AcctLineType_71
25165 --
25166 ---------------------------------------
25167 PROCEDURE AcctLineType_71 (
25168 p_application_id IN NUMBER
25169 ,p_event_id IN NUMBER
25170 ,p_calculate_acctd_flag IN VARCHAR2
25171 ,p_calculate_g_l_flag IN VARCHAR2
25172 ,p_actual_flag IN OUT VARCHAR2
25173 ,p_balance_type_code OUT VARCHAR2
25174 ,p_gain_or_loss_ref OUT VARCHAR2
25175
25176 --TRANSACTION_ID
25177 , p_source_1 IN NUMBER
25178 --Item Concatenated Segments
25179 , p_source_2 IN VARCHAR2
25180 --Transaction Quantity
25181 , p_source_3 IN NUMBER
25182 --Transaction Unit of Measure Code
25183 , p_source_4 IN VARCHAR2
25184 --Inventory Transaction Type Description
25185 , p_source_5 IN VARCHAR2
25186 --Cost Management Default Account
25187 , p_source_11 IN NUMBER
25188 --DISTRIBUTION_IDENTIFIER
25189 , p_source_84 IN NUMBER
25190 --Distribution Type
25191 , p_source_85 IN VARCHAR2
25192 , p_source_85_meaning IN VARCHAR2
25193 --Entered Currency Code
25194 , p_source_88 IN VARCHAR2
25195 --Entered Amount
25196 , p_source_91 IN NUMBER
25197 --Currency Conversion Date
25198 , p_source_92 IN DATE
25199 --Currency Conversion Rate
25200 , p_source_93 IN NUMBER
25201 --Currency Conversion Type
25202 , p_source_94 IN VARCHAR2
25203 --Accounted Amount
25204 , p_source_95 IN NUMBER
25205 --Accounting Line Type
25206 , p_source_97 IN NUMBER
25207 )
25208 IS
25209
25210 l_component_type VARCHAR2(80);
25211 l_component_code VARCHAR2(30);
25212 l_component_type_code VARCHAR2(1);
25213 l_component_appl_id INTEGER;
25214 l_amb_context_code VARCHAR2(30);
25215 l_entity_code VARCHAR2(30);
25216 l_event_class_code VARCHAR2(30);
25217 l_ae_header_id NUMBER;
25218 l_event_type_code VARCHAR2(30);
25219 l_line_definition_code VARCHAR2(30);
25220 l_line_definition_owner_code VARCHAR2(1);
25221 --
25222 -- adr variables
25223 l_segment VARCHAR2(30);
25224 l_ccid NUMBER;
25225 l_adr_transaction_coa_id NUMBER;
25226 l_adr_accounting_coa_id NUMBER;
25227 l_adr_flexfield_segment_code VARCHAR2(30);
25228 l_adr_flex_value_set_id NUMBER;
25229 l_adr_value_type_code VARCHAR2(30);
25230 l_adr_value_combination_id NUMBER;
25231 l_adr_value_segment_code VARCHAR2(30);
25232
25233 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25234 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25235 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25236 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25237
25238 -- 4262811 Variables ------------------------------------------------------------------------------------------
25239 l_entered_amt_idx NUMBER;
25240 l_accted_amt_idx NUMBER;
25241 l_acc_rev_flag VARCHAR2(1);
25242 l_accrual_line_num NUMBER;
25243 l_tmp_amt NUMBER;
25244 l_acc_rev_natural_side_code VARCHAR2(1);
25245
25246 l_num_entries NUMBER;
25247 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25248 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25249 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25250 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25251 l_recog_line_1 NUMBER;
25252 l_recog_line_2 NUMBER;
25253
25254 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25255 l_bflow_applied_to_amt NUMBER; -- 5132302
25256 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25257
25258 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25259
25260 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25261 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25262
25263 ---------------------------------------------------------------------------------------------------------------
25264
25265
25266 --
25267 -- bulk performance
25268 --
25269 l_balance_type_code VARCHAR2(1);
25270 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25271 l_log_module VARCHAR2(240);
25272
25273 --
25274 -- Upgrade strategy
25275 --
25276 l_actual_upg_option VARCHAR2(1);
25277 l_enc_upg_option VARCHAR2(1);
25278
25279 --
25280 BEGIN
25281 --
25282 IF g_log_enabled THEN
25283 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_71';
25284 END IF;
25285 --
25286 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25287
25288 trace
25289 (p_msg => 'BEGIN of AcctLineType_71'
25290 ,p_level => C_LEVEL_PROCEDURE
25291 ,p_module => l_log_module);
25292
25293 END IF;
25294 --
25295 l_component_type := 'AMB_JLT';
25296 l_component_code := 'COST_UPDATE_ADJUSTMENT';
25297 l_component_type_code := 'S';
25298 l_component_appl_id := 707;
25299 l_amb_context_code := 'DEFAULT';
25300 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
25301 l_event_class_code := 'SALES_ORDER';
25302 l_event_type_code := 'RMA_RCPT';
25303 l_line_definition_owner_code := 'S';
25304 l_line_definition_code := 'PI_RMA_RCPT';
25305 --
25306 l_balance_type_code := 'A';
25307 l_segment := NULL;
25308 l_ccid := NULL;
25309 l_adr_transaction_coa_id := NULL;
25310 l_adr_accounting_coa_id := NULL;
25311 l_adr_flexfield_segment_code := NULL;
25312 l_adr_flex_value_set_id := NULL;
25313 l_adr_value_type_code := NULL;
25314 l_adr_value_combination_id := NULL;
25315 l_adr_value_segment_code := NULL;
25316
25317 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25318 l_bflow_class_code := ''; -- 4219869 Business Flow
25319 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25320 l_budgetary_control_flag := 'N';
25321
25322 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25323 l_bflow_applied_to_amt := NULL; -- 5132302
25324 l_entered_amt_idx := NULL; -- 4262811
25325 l_accted_amt_idx := NULL; -- 4262811
25326 l_acc_rev_flag := NULL; -- 4262811
25327 l_accrual_line_num := NULL; -- 4262811
25328 l_tmp_amt := NULL; -- 4262811
25329 --
25330
25331 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25332 l_balance_type_code <> 'B' THEN
25333 IF NVL(p_source_97,9E125) = 37
25334 THEN
25335
25336 --
25337 XLA_AE_LINES_PKG.SetNewLine;
25338
25339 p_balance_type_code := l_balance_type_code;
25340 -- set the flag so later we will know whether the gain loss line needs to be created
25341
25342 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25343 p_actual_flag :='A';
25344 END IF;
25345
25346 --
25347 -- bulk performance
25348 --
25349 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25350 p_header_num => 0); -- 4262811
25351 --
25352 -- set accounting line options
25353 --
25354 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25355 p_natural_side_code => 'D'
25356 , p_gain_or_loss_flag => 'N'
25357 , p_gl_transfer_mode_code => 'S'
25358 , p_acct_entry_type_code => 'A'
25359 , p_switch_side_flag => 'Y'
25360 , p_merge_duplicate_code => 'N'
25361 );
25362 --
25363 l_acc_rev_natural_side_code := 'C'; -- 4262811
25364 --
25365 --
25366 -- set accounting line type info
25367 --
25368 xla_ae_lines_pkg.SetAcctLineType
25369 (p_component_type => l_component_type
25370 ,p_event_type_code => l_event_type_code
25371 ,p_line_definition_owner_code => l_line_definition_owner_code
25372 ,p_line_definition_code => l_line_definition_code
25373 ,p_accounting_line_code => l_component_code
25374 ,p_accounting_line_type_code => l_component_type_code
25375 ,p_accounting_line_appl_id => l_component_appl_id
25376 ,p_amb_context_code => l_amb_context_code
25377 ,p_entity_code => l_entity_code
25378 ,p_event_class_code => l_event_class_code);
25379 --
25380 -- set accounting class
25381 --
25382 xla_ae_lines_pkg.SetAcctClass(
25383 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
25384 , p_ae_header_id => l_ae_header_id
25385 );
25386
25387 --
25388 -- set rounding class
25389 --
25390 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25391 'COST_UPDATE_ADJUSTMENT';
25392
25393 --
25394 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25395 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25396 --
25397 -- bulk performance
25398 --
25399 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25400
25401 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25402 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25403
25404 -- 4955764
25405 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25406 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25407
25408 -- 4458381 Public Sector Enh
25409
25410 --
25411 -- set accounting attributes for the line type
25412 --
25413 l_entered_amt_idx := 3;
25414 l_accted_amt_idx := 8;
25415 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25416 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25417 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
25418 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25419 l_rec_acct_attrs.array_char_value(2) := p_source_85;
25420 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25421 l_rec_acct_attrs.array_num_value(3) := p_source_91;
25422 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
25423 l_rec_acct_attrs.array_char_value(4) := p_source_88;
25424 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
25425 l_rec_acct_attrs.array_date_value(5) := p_source_92;
25426 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
25427 l_rec_acct_attrs.array_num_value(6) := p_source_93;
25428 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
25429 l_rec_acct_attrs.array_char_value(7) := p_source_94;
25430 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
25431 l_rec_acct_attrs.array_num_value(8) := p_source_95;
25432
25433 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25434 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25435
25436 ---------------------------------------------------------------------------------------------------------------
25437 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25438 ---------------------------------------------------------------------------------------------------------------
25439 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25440
25441 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25442 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25443
25444 IF xla_accounting_cache_pkg.GetValueChar
25445 (p_source_code => 'LEDGER_CATEGORY_CODE'
25446 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25447 AND l_bflow_method_code = 'PRIOR_ENTRY'
25448 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25449 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25450 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25451 )
25452 THEN
25453 xla_ae_lines_pkg.BflowUpgEntry
25454 (p_business_method_code => l_bflow_method_code
25455 ,p_business_class_code => l_bflow_class_code
25456 ,p_balance_type => l_balance_type_code);
25457 ELSE
25458 NULL;
25459 -- No business flow processing for business flow method of NONE.
25460 END IF;
25461
25462 --
25463 -- call analytical criteria
25464 --
25465
25466 --
25467 -- call description
25468 --
25469
25470 xla_ae_lines_pkg.SetLineDescription(
25471 p_ae_header_id => l_ae_header_id
25472 ,p_description => Description_1 (
25473 p_application_id => p_application_id
25474 , p_ae_header_id => l_ae_header_id
25475 , p_source_1 => p_source_1
25476 , p_source_2 => p_source_2
25477 , p_source_3 => p_source_3
25478 , p_source_4 => p_source_4
25479 , p_source_5 => p_source_5
25480 )
25481 );
25482
25483
25484 --
25485 -- call ADRs
25486 -- Bug 4922099
25487 --
25488 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25489 (NVL(l_actual_upg_option, 'N') = 'O') OR
25490 (NVL(l_enc_upg_option, 'N') = 'O')
25491 )
25492 THEN
25493 NULL;
25494 --
25495 --
25496
25497 l_ccid := AcctDerRule_6(
25498 p_application_id => p_application_id
25499 , p_ae_header_id => l_ae_header_id
25500 , p_source_11 => p_source_11
25501 , x_transaction_coa_id => l_adr_transaction_coa_id
25502 , x_accounting_coa_id => l_adr_accounting_coa_id
25503 , x_value_type_code => l_adr_value_type_code
25504 , p_side => 'NA'
25505 );
25506
25507 xla_ae_lines_pkg.set_ccid(
25508 p_code_combination_id => l_ccid
25509 , p_value_type_code => l_adr_value_type_code
25510 , p_transaction_coa_id => l_adr_transaction_coa_id
25511 , p_accounting_coa_id => l_adr_accounting_coa_id
25512 , p_adr_code => 'CST_DEFAULT'
25513 , p_adr_type_code => 'S'
25514 , p_component_type => l_component_type
25515 , p_component_code => l_component_code
25516 , p_component_type_code => l_component_type_code
25517 , p_component_appl_id => l_component_appl_id
25518 , p_amb_context_code => l_amb_context_code
25519 , p_side => 'NA'
25520 );
25521
25522
25523 --
25524 --
25525 END IF;
25526 --
25527 -- Bug 4922099
25528 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25529 (NVL(l_enc_upg_option, 'N') = 'O')
25530 ) AND
25531 (l_bflow_method_code = 'PRIOR_ENTRY')
25532 )
25533 THEN
25534 IF
25535 --
25536 1 = 2
25537 --
25538 THEN
25539 xla_accounting_err_pkg.build_message
25540 (p_appli_s_name => 'XLA'
25541 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25542 ,p_token_1 => 'LINE_NUMBER'
25543 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25544 ,p_token_2 => 'LINE_TYPE_NAME'
25545 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25546 l_component_type
25547 ,l_component_code
25548 ,l_component_type_code
25549 ,l_component_appl_id
25550 ,l_amb_context_code
25551 ,l_entity_code
25552 ,l_event_class_code
25553 )
25554 ,p_token_3 => 'OWNER'
25555 ,p_value_3 => xla_lookups_pkg.get_meaning(
25556 p_lookup_type => 'XLA_OWNER_TYPE'
25557 ,p_lookup_code => l_component_type_code
25558 )
25559 ,p_token_4 => 'PRODUCT_NAME'
25560 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25561 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25562 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25563 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25564 ,p_ae_header_id => NULL
25565 );
25566
25567 IF (C_LEVEL_ERROR>= g_log_level) THEN
25568 trace
25569 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25570 ,p_level => C_LEVEL_ERROR
25571 ,p_module => l_log_module);
25572 END IF;
25573 END IF;
25574 END IF;
25575 --
25576 --
25577 ------------------------------------------------------------------------------------------------
25578 -- 4219869 Business Flow
25579 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25580 -- Prior Entry. Currently, the following code is always generated.
25581 ------------------------------------------------------------------------------------------------
25582 XLA_AE_LINES_PKG.ValidateCurrentLine;
25583
25584 ------------------------------------------------------------------------------------
25585 -- 4219869 Business Flow
25586 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25587 ------------------------------------------------------------------------------------
25588 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25589
25590 ----------------------------------------------------------------------------------
25591 -- 4219869 Business Flow
25592 -- Update journal entry status -- Need to generate this within IF <condition>
25593 ----------------------------------------------------------------------------------
25594 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25595 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25596 ,p_balance_type_code => l_balance_type_code
25597 );
25598
25599 -------------------------------------------------------------------------------------------
25600 -- 4262811 - Generate the Accrual Reversal lines
25601 -------------------------------------------------------------------------------------------
25602 BEGIN
25603 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25604 (g_array_event(p_event_id).array_value_num('header_index'));
25605 IF l_acc_rev_flag IS NULL THEN
25606 l_acc_rev_flag := 'N';
25607 END IF;
25608 EXCEPTION
25609 WHEN OTHERS THEN
25610 l_acc_rev_flag := 'N';
25611 END;
25612 --
25613 IF (l_acc_rev_flag = 'Y') THEN
25614
25615 -- 4645092 ------------------------------------------------------------------------------
25616 -- To allow MPA report to determine if it should generate report process
25617 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25618 ------------------------------------------------------------------------------------------
25619
25620 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25621 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25622 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25623 -- call ADRs
25624 -- Bug 4922099
25625 --
25626 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25627 (NVL(l_actual_upg_option, 'N') = 'O') OR
25628 (NVL(l_enc_upg_option, 'N') = 'O')
25629 )
25630 THEN
25631 NULL;
25632 --
25633 --
25634
25635 l_ccid := AcctDerRule_6(
25636 p_application_id => p_application_id
25637 , p_ae_header_id => l_ae_header_id
25638 , p_source_11 => p_source_11
25639 , x_transaction_coa_id => l_adr_transaction_coa_id
25640 , x_accounting_coa_id => l_adr_accounting_coa_id
25641 , x_value_type_code => l_adr_value_type_code
25642 , p_side => 'NA'
25643 );
25644
25645 xla_ae_lines_pkg.set_ccid(
25646 p_code_combination_id => l_ccid
25647 , p_value_type_code => l_adr_value_type_code
25648 , p_transaction_coa_id => l_adr_transaction_coa_id
25649 , p_accounting_coa_id => l_adr_accounting_coa_id
25650 , p_adr_code => 'CST_DEFAULT'
25651 , p_adr_type_code => 'S'
25652 , p_component_type => l_component_type
25653 , p_component_code => l_component_code
25654 , p_component_type_code => l_component_type_code
25655 , p_component_appl_id => l_component_appl_id
25656 , p_amb_context_code => l_amb_context_code
25657 , p_side => 'NA'
25658 );
25659
25660
25661 --
25662 --
25663 END IF;
25664
25665 --
25666 -- Update the line information that should be overwritten
25667 --
25668 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25669 p_header_num => 1);
25670 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25671
25672 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25673
25674 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25675 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25676 END IF;
25677
25678 --
25679 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25680 --
25681 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25682 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25683 ELSE
25684 ---------------------------------------------------------------------------------------------------
25685 -- 4262811a Switch Sign
25686 ---------------------------------------------------------------------------------------------------
25687 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25688 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25689 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25690 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25691 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25692 -- 5132302
25693 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25694 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25695
25696 END IF;
25697
25698 -- 4955764
25699 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25700 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25701
25702
25703 XLA_AE_LINES_PKG.ValidateCurrentLine;
25704 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25705
25706 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25707 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25708 ,p_balance_type_code => l_balance_type_code);
25709
25710 END IF;
25711
25712 -----------------------------------------------------------------------------------------
25713 -- 4262811 Multiperiod Accounting
25714 -----------------------------------------------------------------------------------------
25715 -- No MPA option is assigned.
25716
25717
25718 END IF;
25719 END IF;
25720 --
25721
25722 --
25723 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25724 trace
25725 (p_msg => 'END of AcctLineType_71'
25726 ,p_level => C_LEVEL_PROCEDURE
25727 ,p_module => l_log_module);
25728 END IF;
25729 --
25730 EXCEPTION
25731 WHEN xla_exceptions_pkg.application_exception THEN
25732 RAISE;
25733 WHEN OTHERS THEN
25734 xla_exceptions_pkg.raise_message
25735 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_71');
25736 END AcctLineType_71;
25737 --
25738
25739 ---------------------------------------
25740 --
25741 -- PRIVATE FUNCTION
25742 -- AcctLineType_72
25743 --
25744 ---------------------------------------
25745 PROCEDURE AcctLineType_72 (
25746 p_application_id IN NUMBER
25747 ,p_event_id IN NUMBER
25748 ,p_calculate_acctd_flag IN VARCHAR2
25749 ,p_calculate_g_l_flag IN VARCHAR2
25750 ,p_actual_flag IN OUT VARCHAR2
25751 ,p_balance_type_code OUT VARCHAR2
25752 ,p_gain_or_loss_ref OUT VARCHAR2
25753
25754 --TRANSACTION_ID
25755 , p_source_1 IN NUMBER
25756 --Item Concatenated Segments
25757 , p_source_2 IN VARCHAR2
25758 --Transaction Quantity
25759 , p_source_3 IN NUMBER
25760 --Transaction Unit of Measure Code
25761 , p_source_4 IN VARCHAR2
25762 --Inventory Transaction Type Description
25763 , p_source_5 IN VARCHAR2
25764 --Cost Management Default Account
25765 , p_source_11 IN NUMBER
25766 --DISTRIBUTION_IDENTIFIER
25767 , p_source_84 IN NUMBER
25768 --Distribution Type
25769 , p_source_85 IN VARCHAR2
25770 , p_source_85_meaning IN VARCHAR2
25771 --Entered Currency Code
25772 , p_source_88 IN VARCHAR2
25773 --Entered Amount
25774 , p_source_91 IN NUMBER
25775 --Currency Conversion Date
25776 , p_source_92 IN DATE
25777 --Currency Conversion Rate
25778 , p_source_93 IN NUMBER
25779 --Currency Conversion Type
25780 , p_source_94 IN VARCHAR2
25781 --Accounted Amount
25782 , p_source_95 IN NUMBER
25783 --Accounting Line Type
25784 , p_source_97 IN NUMBER
25785 )
25786 IS
25787
25788 l_component_type VARCHAR2(80);
25789 l_component_code VARCHAR2(30);
25790 l_component_type_code VARCHAR2(1);
25791 l_component_appl_id INTEGER;
25792 l_amb_context_code VARCHAR2(30);
25793 l_entity_code VARCHAR2(30);
25794 l_event_class_code VARCHAR2(30);
25795 l_ae_header_id NUMBER;
25796 l_event_type_code VARCHAR2(30);
25797 l_line_definition_code VARCHAR2(30);
25798 l_line_definition_owner_code VARCHAR2(1);
25799 --
25800 -- adr variables
25801 l_segment VARCHAR2(30);
25802 l_ccid NUMBER;
25803 l_adr_transaction_coa_id NUMBER;
25804 l_adr_accounting_coa_id NUMBER;
25805 l_adr_flexfield_segment_code VARCHAR2(30);
25806 l_adr_flex_value_set_id NUMBER;
25807 l_adr_value_type_code VARCHAR2(30);
25808 l_adr_value_combination_id NUMBER;
25809 l_adr_value_segment_code VARCHAR2(30);
25810
25811 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25812 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25813 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25814 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25815
25816 -- 4262811 Variables ------------------------------------------------------------------------------------------
25817 l_entered_amt_idx NUMBER;
25818 l_accted_amt_idx NUMBER;
25819 l_acc_rev_flag VARCHAR2(1);
25820 l_accrual_line_num NUMBER;
25821 l_tmp_amt NUMBER;
25822 l_acc_rev_natural_side_code VARCHAR2(1);
25823
25824 l_num_entries NUMBER;
25825 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25826 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25827 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25828 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25829 l_recog_line_1 NUMBER;
25830 l_recog_line_2 NUMBER;
25831
25832 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25833 l_bflow_applied_to_amt NUMBER; -- 5132302
25834 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25835
25836 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25837
25838 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25839 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25840
25841 ---------------------------------------------------------------------------------------------------------------
25842
25843
25844 --
25845 -- bulk performance
25846 --
25847 l_balance_type_code VARCHAR2(1);
25848 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25849 l_log_module VARCHAR2(240);
25850
25851 --
25852 -- Upgrade strategy
25853 --
25854 l_actual_upg_option VARCHAR2(1);
25855 l_enc_upg_option VARCHAR2(1);
25856
25857 --
25858 BEGIN
25859 --
25860 IF g_log_enabled THEN
25861 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_72';
25862 END IF;
25863 --
25864 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25865
25866 trace
25867 (p_msg => 'BEGIN of AcctLineType_72'
25868 ,p_level => C_LEVEL_PROCEDURE
25869 ,p_module => l_log_module);
25870
25871 END IF;
25872 --
25873 l_component_type := 'AMB_JLT';
25874 l_component_code := 'COST_UPDATE_ADJUSTMENT';
25875 l_component_type_code := 'S';
25876 l_component_appl_id := 707;
25877 l_amb_context_code := 'DEFAULT';
25878 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
25879 l_event_class_code := 'SALES_ORDER';
25880 l_event_type_code := 'RMA_RETURN';
25881 l_line_definition_owner_code := 'S';
25882 l_line_definition_code := 'PI_RMA_RETURN';
25883 --
25884 l_balance_type_code := 'A';
25885 l_segment := NULL;
25886 l_ccid := NULL;
25887 l_adr_transaction_coa_id := NULL;
25888 l_adr_accounting_coa_id := NULL;
25889 l_adr_flexfield_segment_code := NULL;
25890 l_adr_flex_value_set_id := NULL;
25891 l_adr_value_type_code := NULL;
25892 l_adr_value_combination_id := NULL;
25893 l_adr_value_segment_code := NULL;
25894
25895 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25896 l_bflow_class_code := ''; -- 4219869 Business Flow
25897 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25898 l_budgetary_control_flag := 'N';
25899
25900 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25901 l_bflow_applied_to_amt := NULL; -- 5132302
25902 l_entered_amt_idx := NULL; -- 4262811
25903 l_accted_amt_idx := NULL; -- 4262811
25904 l_acc_rev_flag := NULL; -- 4262811
25905 l_accrual_line_num := NULL; -- 4262811
25906 l_tmp_amt := NULL; -- 4262811
25907 --
25908
25909 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25910 l_balance_type_code <> 'B' THEN
25911 IF NVL(p_source_97,9E125) = 37
25912 THEN
25913
25914 --
25915 XLA_AE_LINES_PKG.SetNewLine;
25916
25917 p_balance_type_code := l_balance_type_code;
25918 -- set the flag so later we will know whether the gain loss line needs to be created
25919
25920 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25921 p_actual_flag :='A';
25922 END IF;
25923
25924 --
25925 -- bulk performance
25926 --
25927 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25928 p_header_num => 0); -- 4262811
25929 --
25930 -- set accounting line options
25931 --
25932 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25933 p_natural_side_code => 'D'
25934 , p_gain_or_loss_flag => 'N'
25935 , p_gl_transfer_mode_code => 'S'
25936 , p_acct_entry_type_code => 'A'
25937 , p_switch_side_flag => 'Y'
25938 , p_merge_duplicate_code => 'N'
25939 );
25940 --
25941 l_acc_rev_natural_side_code := 'C'; -- 4262811
25942 --
25943 --
25944 -- set accounting line type info
25945 --
25946 xla_ae_lines_pkg.SetAcctLineType
25947 (p_component_type => l_component_type
25948 ,p_event_type_code => l_event_type_code
25949 ,p_line_definition_owner_code => l_line_definition_owner_code
25950 ,p_line_definition_code => l_line_definition_code
25951 ,p_accounting_line_code => l_component_code
25952 ,p_accounting_line_type_code => l_component_type_code
25953 ,p_accounting_line_appl_id => l_component_appl_id
25954 ,p_amb_context_code => l_amb_context_code
25955 ,p_entity_code => l_entity_code
25956 ,p_event_class_code => l_event_class_code);
25957 --
25958 -- set accounting class
25959 --
25960 xla_ae_lines_pkg.SetAcctClass(
25961 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
25962 , p_ae_header_id => l_ae_header_id
25963 );
25964
25965 --
25966 -- set rounding class
25967 --
25968 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25969 'COST_UPDATE_ADJUSTMENT';
25970
25971 --
25972 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25973 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25974 --
25975 -- bulk performance
25976 --
25977 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25978
25979 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25980 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25981
25982 -- 4955764
25983 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25984 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25985
25986 -- 4458381 Public Sector Enh
25987
25988 --
25989 -- set accounting attributes for the line type
25990 --
25991 l_entered_amt_idx := 3;
25992 l_accted_amt_idx := 8;
25993 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25994 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25995 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
25996 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25997 l_rec_acct_attrs.array_char_value(2) := p_source_85;
25998 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25999 l_rec_acct_attrs.array_num_value(3) := p_source_91;
26000 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
26001 l_rec_acct_attrs.array_char_value(4) := p_source_88;
26002 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
26003 l_rec_acct_attrs.array_date_value(5) := p_source_92;
26004 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
26005 l_rec_acct_attrs.array_num_value(6) := p_source_93;
26006 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
26007 l_rec_acct_attrs.array_char_value(7) := p_source_94;
26008 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
26009 l_rec_acct_attrs.array_num_value(8) := p_source_95;
26010
26011 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26012 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26013
26014 ---------------------------------------------------------------------------------------------------------------
26015 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26016 ---------------------------------------------------------------------------------------------------------------
26017 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26018
26019 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26020 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26021
26022 IF xla_accounting_cache_pkg.GetValueChar
26023 (p_source_code => 'LEDGER_CATEGORY_CODE'
26024 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26025 AND l_bflow_method_code = 'PRIOR_ENTRY'
26026 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26027 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26028 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26029 )
26030 THEN
26031 xla_ae_lines_pkg.BflowUpgEntry
26032 (p_business_method_code => l_bflow_method_code
26033 ,p_business_class_code => l_bflow_class_code
26034 ,p_balance_type => l_balance_type_code);
26035 ELSE
26036 NULL;
26037 -- No business flow processing for business flow method of NONE.
26038 END IF;
26039
26040 --
26041 -- call analytical criteria
26042 --
26043
26044 --
26045 -- call description
26046 --
26047
26048 xla_ae_lines_pkg.SetLineDescription(
26049 p_ae_header_id => l_ae_header_id
26050 ,p_description => Description_1 (
26051 p_application_id => p_application_id
26052 , p_ae_header_id => l_ae_header_id
26053 , p_source_1 => p_source_1
26054 , p_source_2 => p_source_2
26055 , p_source_3 => p_source_3
26056 , p_source_4 => p_source_4
26057 , p_source_5 => p_source_5
26058 )
26059 );
26060
26061
26062 --
26063 -- call ADRs
26064 -- Bug 4922099
26065 --
26066 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26067 (NVL(l_actual_upg_option, 'N') = 'O') OR
26068 (NVL(l_enc_upg_option, 'N') = 'O')
26069 )
26070 THEN
26071 NULL;
26072 --
26073 --
26074
26075 l_ccid := AcctDerRule_6(
26076 p_application_id => p_application_id
26077 , p_ae_header_id => l_ae_header_id
26078 , p_source_11 => p_source_11
26079 , x_transaction_coa_id => l_adr_transaction_coa_id
26080 , x_accounting_coa_id => l_adr_accounting_coa_id
26081 , x_value_type_code => l_adr_value_type_code
26082 , p_side => 'NA'
26083 );
26084
26085 xla_ae_lines_pkg.set_ccid(
26086 p_code_combination_id => l_ccid
26087 , p_value_type_code => l_adr_value_type_code
26088 , p_transaction_coa_id => l_adr_transaction_coa_id
26089 , p_accounting_coa_id => l_adr_accounting_coa_id
26090 , p_adr_code => 'CST_DEFAULT'
26091 , p_adr_type_code => 'S'
26092 , p_component_type => l_component_type
26093 , p_component_code => l_component_code
26094 , p_component_type_code => l_component_type_code
26095 , p_component_appl_id => l_component_appl_id
26096 , p_amb_context_code => l_amb_context_code
26097 , p_side => 'NA'
26098 );
26099
26100
26101 --
26102 --
26103 END IF;
26104 --
26105 -- Bug 4922099
26106 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26107 (NVL(l_enc_upg_option, 'N') = 'O')
26108 ) AND
26109 (l_bflow_method_code = 'PRIOR_ENTRY')
26110 )
26111 THEN
26112 IF
26113 --
26114 1 = 2
26115 --
26116 THEN
26117 xla_accounting_err_pkg.build_message
26118 (p_appli_s_name => 'XLA'
26119 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26120 ,p_token_1 => 'LINE_NUMBER'
26121 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26122 ,p_token_2 => 'LINE_TYPE_NAME'
26123 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26124 l_component_type
26125 ,l_component_code
26126 ,l_component_type_code
26127 ,l_component_appl_id
26128 ,l_amb_context_code
26129 ,l_entity_code
26130 ,l_event_class_code
26131 )
26132 ,p_token_3 => 'OWNER'
26133 ,p_value_3 => xla_lookups_pkg.get_meaning(
26134 p_lookup_type => 'XLA_OWNER_TYPE'
26135 ,p_lookup_code => l_component_type_code
26136 )
26137 ,p_token_4 => 'PRODUCT_NAME'
26138 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26139 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26140 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26141 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26142 ,p_ae_header_id => NULL
26143 );
26144
26145 IF (C_LEVEL_ERROR>= g_log_level) THEN
26146 trace
26147 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26148 ,p_level => C_LEVEL_ERROR
26149 ,p_module => l_log_module);
26150 END IF;
26151 END IF;
26152 END IF;
26153 --
26154 --
26155 ------------------------------------------------------------------------------------------------
26156 -- 4219869 Business Flow
26157 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26158 -- Prior Entry. Currently, the following code is always generated.
26159 ------------------------------------------------------------------------------------------------
26160 XLA_AE_LINES_PKG.ValidateCurrentLine;
26161
26162 ------------------------------------------------------------------------------------
26163 -- 4219869 Business Flow
26164 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26165 ------------------------------------------------------------------------------------
26166 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26167
26168 ----------------------------------------------------------------------------------
26169 -- 4219869 Business Flow
26170 -- Update journal entry status -- Need to generate this within IF <condition>
26171 ----------------------------------------------------------------------------------
26172 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26173 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26174 ,p_balance_type_code => l_balance_type_code
26175 );
26176
26177 -------------------------------------------------------------------------------------------
26178 -- 4262811 - Generate the Accrual Reversal lines
26179 -------------------------------------------------------------------------------------------
26180 BEGIN
26181 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26182 (g_array_event(p_event_id).array_value_num('header_index'));
26183 IF l_acc_rev_flag IS NULL THEN
26184 l_acc_rev_flag := 'N';
26185 END IF;
26186 EXCEPTION
26187 WHEN OTHERS THEN
26188 l_acc_rev_flag := 'N';
26189 END;
26190 --
26191 IF (l_acc_rev_flag = 'Y') THEN
26192
26193 -- 4645092 ------------------------------------------------------------------------------
26194 -- To allow MPA report to determine if it should generate report process
26195 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26196 ------------------------------------------------------------------------------------------
26197
26198 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26199 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26200 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26201 -- call ADRs
26202 -- Bug 4922099
26203 --
26204 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26205 (NVL(l_actual_upg_option, 'N') = 'O') OR
26206 (NVL(l_enc_upg_option, 'N') = 'O')
26207 )
26208 THEN
26209 NULL;
26210 --
26211 --
26212
26213 l_ccid := AcctDerRule_6(
26214 p_application_id => p_application_id
26215 , p_ae_header_id => l_ae_header_id
26216 , p_source_11 => p_source_11
26217 , x_transaction_coa_id => l_adr_transaction_coa_id
26218 , x_accounting_coa_id => l_adr_accounting_coa_id
26219 , x_value_type_code => l_adr_value_type_code
26220 , p_side => 'NA'
26221 );
26222
26223 xla_ae_lines_pkg.set_ccid(
26224 p_code_combination_id => l_ccid
26225 , p_value_type_code => l_adr_value_type_code
26226 , p_transaction_coa_id => l_adr_transaction_coa_id
26227 , p_accounting_coa_id => l_adr_accounting_coa_id
26228 , p_adr_code => 'CST_DEFAULT'
26229 , p_adr_type_code => 'S'
26230 , p_component_type => l_component_type
26231 , p_component_code => l_component_code
26232 , p_component_type_code => l_component_type_code
26233 , p_component_appl_id => l_component_appl_id
26234 , p_amb_context_code => l_amb_context_code
26235 , p_side => 'NA'
26236 );
26237
26238
26239 --
26240 --
26241 END IF;
26242
26243 --
26244 -- Update the line information that should be overwritten
26245 --
26246 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26247 p_header_num => 1);
26248 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26249
26250 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26251
26252 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26253 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26254 END IF;
26255
26256 --
26257 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26258 --
26259 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26260 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26261 ELSE
26262 ---------------------------------------------------------------------------------------------------
26263 -- 4262811a Switch Sign
26264 ---------------------------------------------------------------------------------------------------
26265 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26266 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26267 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26268 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26269 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26270 -- 5132302
26271 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26272 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26273
26274 END IF;
26275
26276 -- 4955764
26277 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26278 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26279
26280
26281 XLA_AE_LINES_PKG.ValidateCurrentLine;
26282 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26283
26284 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26285 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26286 ,p_balance_type_code => l_balance_type_code);
26287
26288 END IF;
26289
26290 -----------------------------------------------------------------------------------------
26291 -- 4262811 Multiperiod Accounting
26292 -----------------------------------------------------------------------------------------
26293 -- No MPA option is assigned.
26294
26295
26296 END IF;
26297 END IF;
26298 --
26299
26300 --
26301 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26302 trace
26303 (p_msg => 'END of AcctLineType_72'
26304 ,p_level => C_LEVEL_PROCEDURE
26305 ,p_module => l_log_module);
26306 END IF;
26307 --
26308 EXCEPTION
26309 WHEN xla_exceptions_pkg.application_exception THEN
26310 RAISE;
26311 WHEN OTHERS THEN
26312 xla_exceptions_pkg.raise_message
26313 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_72');
26314 END AcctLineType_72;
26315 --
26316
26317 ---------------------------------------
26318 --
26319 -- PRIVATE FUNCTION
26320 -- AcctLineType_73
26321 --
26322 ---------------------------------------
26323 PROCEDURE AcctLineType_73 (
26324 p_application_id IN NUMBER
26325 ,p_event_id IN NUMBER
26326 ,p_calculate_acctd_flag IN VARCHAR2
26327 ,p_calculate_g_l_flag IN VARCHAR2
26328 ,p_actual_flag IN OUT VARCHAR2
26329 ,p_balance_type_code OUT VARCHAR2
26330 ,p_gain_or_loss_ref OUT VARCHAR2
26331
26332 --TRANSACTION_ID
26333 , p_source_1 IN NUMBER
26334 --Item Concatenated Segments
26335 , p_source_2 IN VARCHAR2
26336 --Transaction Quantity
26337 , p_source_3 IN NUMBER
26338 --Transaction Unit of Measure Code
26339 , p_source_4 IN VARCHAR2
26340 --Inventory Transaction Type Description
26341 , p_source_5 IN VARCHAR2
26342 --Cost Management Default Account
26343 , p_source_11 IN NUMBER
26344 --DISTRIBUTION_IDENTIFIER
26345 , p_source_84 IN NUMBER
26346 --Distribution Type
26347 , p_source_85 IN VARCHAR2
26348 , p_source_85_meaning IN VARCHAR2
26349 --Entered Currency Code
26350 , p_source_88 IN VARCHAR2
26351 --Entered Amount
26352 , p_source_91 IN NUMBER
26353 --Currency Conversion Date
26354 , p_source_92 IN DATE
26355 --Currency Conversion Rate
26356 , p_source_93 IN NUMBER
26357 --Currency Conversion Type
26358 , p_source_94 IN VARCHAR2
26359 --Accounted Amount
26360 , p_source_95 IN NUMBER
26361 --Accounting Line Type
26362 , p_source_97 IN NUMBER
26363 )
26364 IS
26365
26366 l_component_type VARCHAR2(80);
26367 l_component_code VARCHAR2(30);
26368 l_component_type_code VARCHAR2(1);
26369 l_component_appl_id INTEGER;
26370 l_amb_context_code VARCHAR2(30);
26371 l_entity_code VARCHAR2(30);
26372 l_event_class_code VARCHAR2(30);
26373 l_ae_header_id NUMBER;
26374 l_event_type_code VARCHAR2(30);
26375 l_line_definition_code VARCHAR2(30);
26376 l_line_definition_owner_code VARCHAR2(1);
26377 --
26378 -- adr variables
26379 l_segment VARCHAR2(30);
26380 l_ccid NUMBER;
26381 l_adr_transaction_coa_id NUMBER;
26382 l_adr_accounting_coa_id NUMBER;
26383 l_adr_flexfield_segment_code VARCHAR2(30);
26384 l_adr_flex_value_set_id NUMBER;
26385 l_adr_value_type_code VARCHAR2(30);
26386 l_adr_value_combination_id NUMBER;
26387 l_adr_value_segment_code VARCHAR2(30);
26388
26389 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26390 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26391 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26392 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26393
26394 -- 4262811 Variables ------------------------------------------------------------------------------------------
26395 l_entered_amt_idx NUMBER;
26396 l_accted_amt_idx NUMBER;
26397 l_acc_rev_flag VARCHAR2(1);
26398 l_accrual_line_num NUMBER;
26399 l_tmp_amt NUMBER;
26400 l_acc_rev_natural_side_code VARCHAR2(1);
26401
26402 l_num_entries NUMBER;
26403 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26404 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26405 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26406 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26407 l_recog_line_1 NUMBER;
26408 l_recog_line_2 NUMBER;
26409
26410 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26411 l_bflow_applied_to_amt NUMBER; -- 5132302
26412 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26413
26414 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26415
26416 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26417 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26418
26419 ---------------------------------------------------------------------------------------------------------------
26420
26421
26422 --
26423 -- bulk performance
26424 --
26425 l_balance_type_code VARCHAR2(1);
26426 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26427 l_log_module VARCHAR2(240);
26428
26429 --
26430 -- Upgrade strategy
26431 --
26432 l_actual_upg_option VARCHAR2(1);
26433 l_enc_upg_option VARCHAR2(1);
26434
26435 --
26436 BEGIN
26437 --
26438 IF g_log_enabled THEN
26439 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_73';
26440 END IF;
26441 --
26442 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26443
26444 trace
26445 (p_msg => 'BEGIN of AcctLineType_73'
26446 ,p_level => C_LEVEL_PROCEDURE
26447 ,p_module => l_log_module);
26448
26449 END IF;
26450 --
26451 l_component_type := 'AMB_JLT';
26452 l_component_code := 'COST_UPDATE_ADJUSTMENT';
26453 l_component_type_code := 'S';
26454 l_component_appl_id := 707;
26455 l_amb_context_code := 'DEFAULT';
26456 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
26457 l_event_class_code := 'MTL_COST_UPD';
26458 l_event_type_code := 'STD_COST_UPD';
26459 l_line_definition_owner_code := 'S';
26460 l_line_definition_code := 'PI_STD_COST_UPD';
26461 --
26462 l_balance_type_code := 'A';
26463 l_segment := NULL;
26464 l_ccid := NULL;
26465 l_adr_transaction_coa_id := NULL;
26466 l_adr_accounting_coa_id := NULL;
26467 l_adr_flexfield_segment_code := NULL;
26468 l_adr_flex_value_set_id := NULL;
26469 l_adr_value_type_code := NULL;
26470 l_adr_value_combination_id := NULL;
26471 l_adr_value_segment_code := NULL;
26472
26473 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26474 l_bflow_class_code := ''; -- 4219869 Business Flow
26475 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26476 l_budgetary_control_flag := 'N';
26477
26478 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26479 l_bflow_applied_to_amt := NULL; -- 5132302
26480 l_entered_amt_idx := NULL; -- 4262811
26481 l_accted_amt_idx := NULL; -- 4262811
26482 l_acc_rev_flag := NULL; -- 4262811
26483 l_accrual_line_num := NULL; -- 4262811
26484 l_tmp_amt := NULL; -- 4262811
26485 --
26486
26487 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26488 l_balance_type_code <> 'B' THEN
26489 IF NVL(p_source_97,9E125) = 2
26490 THEN
26491
26492 --
26493 XLA_AE_LINES_PKG.SetNewLine;
26494
26495 p_balance_type_code := l_balance_type_code;
26496 -- set the flag so later we will know whether the gain loss line needs to be created
26497
26498 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26499 p_actual_flag :='A';
26500 END IF;
26501
26502 --
26503 -- bulk performance
26504 --
26505 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26506 p_header_num => 0); -- 4262811
26507 --
26508 -- set accounting line options
26509 --
26510 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26511 p_natural_side_code => 'D'
26512 , p_gain_or_loss_flag => 'N'
26513 , p_gl_transfer_mode_code => 'S'
26514 , p_acct_entry_type_code => 'A'
26515 , p_switch_side_flag => 'Y'
26516 , p_merge_duplicate_code => 'N'
26517 );
26518 --
26519 l_acc_rev_natural_side_code := 'C'; -- 4262811
26520 --
26521 --
26522 -- set accounting line type info
26523 --
26524 xla_ae_lines_pkg.SetAcctLineType
26525 (p_component_type => l_component_type
26526 ,p_event_type_code => l_event_type_code
26527 ,p_line_definition_owner_code => l_line_definition_owner_code
26528 ,p_line_definition_code => l_line_definition_code
26529 ,p_accounting_line_code => l_component_code
26530 ,p_accounting_line_type_code => l_component_type_code
26531 ,p_accounting_line_appl_id => l_component_appl_id
26532 ,p_amb_context_code => l_amb_context_code
26533 ,p_entity_code => l_entity_code
26534 ,p_event_class_code => l_event_class_code);
26535 --
26536 -- set accounting class
26537 --
26538 xla_ae_lines_pkg.SetAcctClass(
26539 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
26540 , p_ae_header_id => l_ae_header_id
26541 );
26542
26543 --
26544 -- set rounding class
26545 --
26546 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26547 'COST_UPDATE_ADJUSTMENT';
26548
26549 --
26550 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26551 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26552 --
26553 -- bulk performance
26554 --
26555 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26556
26557 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26558 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26559
26560 -- 4955764
26561 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26562 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26563
26564 -- 4458381 Public Sector Enh
26565
26566 --
26567 -- set accounting attributes for the line type
26568 --
26569 l_entered_amt_idx := 3;
26570 l_accted_amt_idx := 8;
26571 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26572 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
26573 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
26574 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
26575 l_rec_acct_attrs.array_char_value(2) := p_source_85;
26576 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
26577 l_rec_acct_attrs.array_num_value(3) := p_source_91;
26578 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
26579 l_rec_acct_attrs.array_char_value(4) := p_source_88;
26580 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
26581 l_rec_acct_attrs.array_date_value(5) := p_source_92;
26582 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
26583 l_rec_acct_attrs.array_num_value(6) := p_source_93;
26584 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
26585 l_rec_acct_attrs.array_char_value(7) := p_source_94;
26586 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
26587 l_rec_acct_attrs.array_num_value(8) := p_source_95;
26588
26589 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26590 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26591
26592 ---------------------------------------------------------------------------------------------------------------
26593 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26594 ---------------------------------------------------------------------------------------------------------------
26595 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26596
26597 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26598 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26599
26600 IF xla_accounting_cache_pkg.GetValueChar
26601 (p_source_code => 'LEDGER_CATEGORY_CODE'
26602 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26603 AND l_bflow_method_code = 'PRIOR_ENTRY'
26604 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26605 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26606 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26607 )
26608 THEN
26609 xla_ae_lines_pkg.BflowUpgEntry
26610 (p_business_method_code => l_bflow_method_code
26611 ,p_business_class_code => l_bflow_class_code
26612 ,p_balance_type => l_balance_type_code);
26613 ELSE
26614 NULL;
26615 -- No business flow processing for business flow method of NONE.
26616 END IF;
26617
26618 --
26619 -- call analytical criteria
26620 --
26621
26622 --
26623 -- call description
26624 --
26625
26626 xla_ae_lines_pkg.SetLineDescription(
26627 p_ae_header_id => l_ae_header_id
26628 ,p_description => Description_1 (
26629 p_application_id => p_application_id
26630 , p_ae_header_id => l_ae_header_id
26631 , p_source_1 => p_source_1
26632 , p_source_2 => p_source_2
26633 , p_source_3 => p_source_3
26634 , p_source_4 => p_source_4
26635 , p_source_5 => p_source_5
26636 )
26637 );
26638
26639
26640 --
26641 -- call ADRs
26642 -- Bug 4922099
26643 --
26644 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26645 (NVL(l_actual_upg_option, 'N') = 'O') OR
26646 (NVL(l_enc_upg_option, 'N') = 'O')
26647 )
26648 THEN
26649 NULL;
26650 --
26651 --
26652
26653 l_ccid := AcctDerRule_6(
26654 p_application_id => p_application_id
26655 , p_ae_header_id => l_ae_header_id
26656 , p_source_11 => p_source_11
26657 , x_transaction_coa_id => l_adr_transaction_coa_id
26658 , x_accounting_coa_id => l_adr_accounting_coa_id
26659 , x_value_type_code => l_adr_value_type_code
26660 , p_side => 'NA'
26661 );
26662
26663 xla_ae_lines_pkg.set_ccid(
26664 p_code_combination_id => l_ccid
26665 , p_value_type_code => l_adr_value_type_code
26666 , p_transaction_coa_id => l_adr_transaction_coa_id
26667 , p_accounting_coa_id => l_adr_accounting_coa_id
26668 , p_adr_code => 'CST_DEFAULT'
26669 , p_adr_type_code => 'S'
26670 , p_component_type => l_component_type
26671 , p_component_code => l_component_code
26672 , p_component_type_code => l_component_type_code
26673 , p_component_appl_id => l_component_appl_id
26674 , p_amb_context_code => l_amb_context_code
26675 , p_side => 'NA'
26676 );
26677
26678
26679 --
26680 --
26681 END IF;
26682 --
26683 -- Bug 4922099
26684 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26685 (NVL(l_enc_upg_option, 'N') = 'O')
26686 ) AND
26687 (l_bflow_method_code = 'PRIOR_ENTRY')
26688 )
26689 THEN
26690 IF
26691 --
26692 1 = 2
26693 --
26694 THEN
26695 xla_accounting_err_pkg.build_message
26696 (p_appli_s_name => 'XLA'
26697 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26698 ,p_token_1 => 'LINE_NUMBER'
26699 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26700 ,p_token_2 => 'LINE_TYPE_NAME'
26701 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26702 l_component_type
26703 ,l_component_code
26704 ,l_component_type_code
26705 ,l_component_appl_id
26706 ,l_amb_context_code
26707 ,l_entity_code
26708 ,l_event_class_code
26709 )
26710 ,p_token_3 => 'OWNER'
26711 ,p_value_3 => xla_lookups_pkg.get_meaning(
26712 p_lookup_type => 'XLA_OWNER_TYPE'
26713 ,p_lookup_code => l_component_type_code
26714 )
26715 ,p_token_4 => 'PRODUCT_NAME'
26716 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26717 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26718 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26719 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26720 ,p_ae_header_id => NULL
26721 );
26722
26723 IF (C_LEVEL_ERROR>= g_log_level) THEN
26724 trace
26725 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26726 ,p_level => C_LEVEL_ERROR
26727 ,p_module => l_log_module);
26728 END IF;
26729 END IF;
26730 END IF;
26731 --
26732 --
26733 ------------------------------------------------------------------------------------------------
26734 -- 4219869 Business Flow
26735 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26736 -- Prior Entry. Currently, the following code is always generated.
26737 ------------------------------------------------------------------------------------------------
26738 XLA_AE_LINES_PKG.ValidateCurrentLine;
26739
26740 ------------------------------------------------------------------------------------
26741 -- 4219869 Business Flow
26742 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26743 ------------------------------------------------------------------------------------
26744 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26745
26746 ----------------------------------------------------------------------------------
26747 -- 4219869 Business Flow
26748 -- Update journal entry status -- Need to generate this within IF <condition>
26749 ----------------------------------------------------------------------------------
26750 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26751 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26752 ,p_balance_type_code => l_balance_type_code
26753 );
26754
26755 -------------------------------------------------------------------------------------------
26756 -- 4262811 - Generate the Accrual Reversal lines
26757 -------------------------------------------------------------------------------------------
26758 BEGIN
26759 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26760 (g_array_event(p_event_id).array_value_num('header_index'));
26761 IF l_acc_rev_flag IS NULL THEN
26762 l_acc_rev_flag := 'N';
26763 END IF;
26764 EXCEPTION
26765 WHEN OTHERS THEN
26766 l_acc_rev_flag := 'N';
26767 END;
26768 --
26769 IF (l_acc_rev_flag = 'Y') THEN
26770
26771 -- 4645092 ------------------------------------------------------------------------------
26772 -- To allow MPA report to determine if it should generate report process
26773 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26774 ------------------------------------------------------------------------------------------
26775
26776 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26777 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26778 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26779 -- call ADRs
26780 -- Bug 4922099
26781 --
26782 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26783 (NVL(l_actual_upg_option, 'N') = 'O') OR
26784 (NVL(l_enc_upg_option, 'N') = 'O')
26785 )
26786 THEN
26787 NULL;
26788 --
26789 --
26790
26791 l_ccid := AcctDerRule_6(
26792 p_application_id => p_application_id
26793 , p_ae_header_id => l_ae_header_id
26794 , p_source_11 => p_source_11
26795 , x_transaction_coa_id => l_adr_transaction_coa_id
26796 , x_accounting_coa_id => l_adr_accounting_coa_id
26797 , x_value_type_code => l_adr_value_type_code
26798 , p_side => 'NA'
26799 );
26800
26801 xla_ae_lines_pkg.set_ccid(
26802 p_code_combination_id => l_ccid
26803 , p_value_type_code => l_adr_value_type_code
26804 , p_transaction_coa_id => l_adr_transaction_coa_id
26805 , p_accounting_coa_id => l_adr_accounting_coa_id
26806 , p_adr_code => 'CST_DEFAULT'
26807 , p_adr_type_code => 'S'
26808 , p_component_type => l_component_type
26809 , p_component_code => l_component_code
26810 , p_component_type_code => l_component_type_code
26811 , p_component_appl_id => l_component_appl_id
26812 , p_amb_context_code => l_amb_context_code
26813 , p_side => 'NA'
26814 );
26815
26816
26817 --
26818 --
26819 END IF;
26820
26821 --
26822 -- Update the line information that should be overwritten
26823 --
26824 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26825 p_header_num => 1);
26826 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26827
26828 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26829
26830 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26831 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26832 END IF;
26833
26834 --
26835 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26836 --
26837 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26838 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26839 ELSE
26840 ---------------------------------------------------------------------------------------------------
26841 -- 4262811a Switch Sign
26842 ---------------------------------------------------------------------------------------------------
26843 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26844 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26845 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26846 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26847 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26848 -- 5132302
26849 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26850 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26851
26852 END IF;
26853
26854 -- 4955764
26855 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26856 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26857
26858
26859 XLA_AE_LINES_PKG.ValidateCurrentLine;
26860 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26861
26862 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26863 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26864 ,p_balance_type_code => l_balance_type_code);
26865
26866 END IF;
26867
26868 -----------------------------------------------------------------------------------------
26869 -- 4262811 Multiperiod Accounting
26870 -----------------------------------------------------------------------------------------
26871 -- No MPA option is assigned.
26872
26873
26874 END IF;
26875 END IF;
26876 --
26877
26878 --
26879 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26880 trace
26881 (p_msg => 'END of AcctLineType_73'
26882 ,p_level => C_LEVEL_PROCEDURE
26883 ,p_module => l_log_module);
26884 END IF;
26885 --
26886 EXCEPTION
26887 WHEN xla_exceptions_pkg.application_exception THEN
26888 RAISE;
26889 WHEN OTHERS THEN
26890 xla_exceptions_pkg.raise_message
26891 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_73');
26892 END AcctLineType_73;
26893 --
26894
26895 ---------------------------------------
26896 --
26897 -- PRIVATE FUNCTION
26898 -- AcctLineType_74
26899 --
26900 ---------------------------------------
26901 PROCEDURE AcctLineType_74 (
26902 p_application_id IN NUMBER
26903 ,p_event_id IN NUMBER
26904 ,p_calculate_acctd_flag IN VARCHAR2
26905 ,p_calculate_g_l_flag IN VARCHAR2
26906 ,p_actual_flag IN OUT VARCHAR2
26907 ,p_balance_type_code OUT VARCHAR2
26908 ,p_gain_or_loss_ref OUT VARCHAR2
26909
26910 --TRANSACTION_ID
26911 , p_source_1 IN NUMBER
26912 --Item Concatenated Segments
26913 , p_source_2 IN VARCHAR2
26914 --Transaction Quantity
26915 , p_source_3 IN NUMBER
26916 --Transaction Unit of Measure Code
26917 , p_source_4 IN VARCHAR2
26918 --Inventory Transaction Type Description
26919 , p_source_5 IN VARCHAR2
26920 --Cost Management Default Account
26921 , p_source_11 IN NUMBER
26922 --DISTRIBUTION_IDENTIFIER
26923 , p_source_84 IN NUMBER
26924 --Distribution Type
26925 , p_source_85 IN VARCHAR2
26926 , p_source_85_meaning IN VARCHAR2
26927 --Entered Currency Code
26928 , p_source_88 IN VARCHAR2
26929 --Entered Amount
26930 , p_source_91 IN NUMBER
26931 --Currency Conversion Date
26932 , p_source_92 IN DATE
26933 --Currency Conversion Rate
26934 , p_source_93 IN NUMBER
26935 --Currency Conversion Type
26936 , p_source_94 IN VARCHAR2
26937 --Accounted Amount
26938 , p_source_95 IN NUMBER
26939 --Accounting Line Type
26940 , p_source_97 IN NUMBER
26941 )
26942 IS
26943
26944 l_component_type VARCHAR2(80);
26945 l_component_code VARCHAR2(30);
26946 l_component_type_code VARCHAR2(1);
26947 l_component_appl_id INTEGER;
26948 l_amb_context_code VARCHAR2(30);
26949 l_entity_code VARCHAR2(30);
26950 l_event_class_code VARCHAR2(30);
26951 l_ae_header_id NUMBER;
26952 l_event_type_code VARCHAR2(30);
26953 l_line_definition_code VARCHAR2(30);
26954 l_line_definition_owner_code VARCHAR2(1);
26955 --
26956 -- adr variables
26957 l_segment VARCHAR2(30);
26958 l_ccid NUMBER;
26959 l_adr_transaction_coa_id NUMBER;
26960 l_adr_accounting_coa_id NUMBER;
26961 l_adr_flexfield_segment_code VARCHAR2(30);
26962 l_adr_flex_value_set_id NUMBER;
26963 l_adr_value_type_code VARCHAR2(30);
26964 l_adr_value_combination_id NUMBER;
26965 l_adr_value_segment_code VARCHAR2(30);
26966
26967 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26968 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26969 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26970 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26971
26972 -- 4262811 Variables ------------------------------------------------------------------------------------------
26973 l_entered_amt_idx NUMBER;
26974 l_accted_amt_idx NUMBER;
26975 l_acc_rev_flag VARCHAR2(1);
26976 l_accrual_line_num NUMBER;
26977 l_tmp_amt NUMBER;
26978 l_acc_rev_natural_side_code VARCHAR2(1);
26979
26980 l_num_entries NUMBER;
26981 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26982 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26983 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26984 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26985 l_recog_line_1 NUMBER;
26986 l_recog_line_2 NUMBER;
26987
26988 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26989 l_bflow_applied_to_amt NUMBER; -- 5132302
26990 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26991
26992 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26993
26994 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26995 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26996
26997 ---------------------------------------------------------------------------------------------------------------
26998
26999
27000 --
27001 -- bulk performance
27002 --
27003 l_balance_type_code VARCHAR2(1);
27004 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27005 l_log_module VARCHAR2(240);
27006
27007 --
27008 -- Upgrade strategy
27009 --
27010 l_actual_upg_option VARCHAR2(1);
27011 l_enc_upg_option VARCHAR2(1);
27012
27013 --
27014 BEGIN
27015 --
27016 IF g_log_enabled THEN
27017 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_74';
27018 END IF;
27019 --
27020 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27021
27022 trace
27023 (p_msg => 'BEGIN of AcctLineType_74'
27024 ,p_level => C_LEVEL_PROCEDURE
27025 ,p_module => l_log_module);
27026
27027 END IF;
27028 --
27029 l_component_type := 'AMB_JLT';
27030 l_component_code := 'COST_UPDATE_ADJUSTMENT';
27031 l_component_type_code := 'S';
27032 l_component_appl_id := 707;
27033 l_amb_context_code := 'DEFAULT';
27034 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
27035 l_event_class_code := 'SALES_ORDER';
27036 l_event_type_code := 'SO_ISSUE';
27037 l_line_definition_owner_code := 'S';
27038 l_line_definition_code := 'PI_SO_ISSUE';
27039 --
27040 l_balance_type_code := 'A';
27041 l_segment := NULL;
27042 l_ccid := NULL;
27043 l_adr_transaction_coa_id := NULL;
27044 l_adr_accounting_coa_id := NULL;
27045 l_adr_flexfield_segment_code := NULL;
27046 l_adr_flex_value_set_id := NULL;
27047 l_adr_value_type_code := NULL;
27048 l_adr_value_combination_id := NULL;
27049 l_adr_value_segment_code := NULL;
27050
27051 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27052 l_bflow_class_code := ''; -- 4219869 Business Flow
27053 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27054 l_budgetary_control_flag := 'N';
27055
27056 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27057 l_bflow_applied_to_amt := NULL; -- 5132302
27058 l_entered_amt_idx := NULL; -- 4262811
27059 l_accted_amt_idx := NULL; -- 4262811
27060 l_acc_rev_flag := NULL; -- 4262811
27061 l_accrual_line_num := NULL; -- 4262811
27062 l_tmp_amt := NULL; -- 4262811
27063 --
27064
27065 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27066 l_balance_type_code <> 'B' THEN
27067 IF NVL(p_source_97,9E125) = 37
27068 THEN
27069
27070 --
27071 XLA_AE_LINES_PKG.SetNewLine;
27072
27073 p_balance_type_code := l_balance_type_code;
27074 -- set the flag so later we will know whether the gain loss line needs to be created
27075
27076 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27077 p_actual_flag :='A';
27078 END IF;
27079
27080 --
27081 -- bulk performance
27082 --
27083 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27084 p_header_num => 0); -- 4262811
27085 --
27086 -- set accounting line options
27087 --
27088 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27089 p_natural_side_code => 'D'
27090 , p_gain_or_loss_flag => 'N'
27091 , p_gl_transfer_mode_code => 'S'
27092 , p_acct_entry_type_code => 'A'
27093 , p_switch_side_flag => 'Y'
27094 , p_merge_duplicate_code => 'N'
27095 );
27096 --
27097 l_acc_rev_natural_side_code := 'C'; -- 4262811
27098 --
27099 --
27100 -- set accounting line type info
27101 --
27102 xla_ae_lines_pkg.SetAcctLineType
27103 (p_component_type => l_component_type
27104 ,p_event_type_code => l_event_type_code
27105 ,p_line_definition_owner_code => l_line_definition_owner_code
27106 ,p_line_definition_code => l_line_definition_code
27107 ,p_accounting_line_code => l_component_code
27108 ,p_accounting_line_type_code => l_component_type_code
27109 ,p_accounting_line_appl_id => l_component_appl_id
27110 ,p_amb_context_code => l_amb_context_code
27111 ,p_entity_code => l_entity_code
27112 ,p_event_class_code => l_event_class_code);
27113 --
27114 -- set accounting class
27115 --
27116 xla_ae_lines_pkg.SetAcctClass(
27117 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
27118 , p_ae_header_id => l_ae_header_id
27119 );
27120
27121 --
27122 -- set rounding class
27123 --
27124 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27125 'COST_UPDATE_ADJUSTMENT';
27126
27127 --
27128 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27129 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27130 --
27131 -- bulk performance
27132 --
27133 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27134
27135 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27136 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27137
27138 -- 4955764
27139 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27140 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27141
27142 -- 4458381 Public Sector Enh
27143
27144 --
27145 -- set accounting attributes for the line type
27146 --
27147 l_entered_amt_idx := 3;
27148 l_accted_amt_idx := 8;
27149 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27150 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
27151 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
27152 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
27153 l_rec_acct_attrs.array_char_value(2) := p_source_85;
27154 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
27155 l_rec_acct_attrs.array_num_value(3) := p_source_91;
27156 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
27157 l_rec_acct_attrs.array_char_value(4) := p_source_88;
27158 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
27159 l_rec_acct_attrs.array_date_value(5) := p_source_92;
27160 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
27161 l_rec_acct_attrs.array_num_value(6) := p_source_93;
27162 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
27163 l_rec_acct_attrs.array_char_value(7) := p_source_94;
27164 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
27165 l_rec_acct_attrs.array_num_value(8) := p_source_95;
27166
27167 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27168 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27169
27170 ---------------------------------------------------------------------------------------------------------------
27171 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27172 ---------------------------------------------------------------------------------------------------------------
27173 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27174
27175 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27176 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27177
27178 IF xla_accounting_cache_pkg.GetValueChar
27179 (p_source_code => 'LEDGER_CATEGORY_CODE'
27180 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27181 AND l_bflow_method_code = 'PRIOR_ENTRY'
27182 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27183 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27184 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27185 )
27186 THEN
27187 xla_ae_lines_pkg.BflowUpgEntry
27188 (p_business_method_code => l_bflow_method_code
27189 ,p_business_class_code => l_bflow_class_code
27190 ,p_balance_type => l_balance_type_code);
27191 ELSE
27192 NULL;
27193 -- No business flow processing for business flow method of NONE.
27194 END IF;
27195
27196 --
27197 -- call analytical criteria
27198 --
27199
27200 --
27201 -- call description
27202 --
27203
27204 xla_ae_lines_pkg.SetLineDescription(
27205 p_ae_header_id => l_ae_header_id
27206 ,p_description => Description_1 (
27207 p_application_id => p_application_id
27208 , p_ae_header_id => l_ae_header_id
27209 , p_source_1 => p_source_1
27210 , p_source_2 => p_source_2
27211 , p_source_3 => p_source_3
27212 , p_source_4 => p_source_4
27213 , p_source_5 => p_source_5
27214 )
27215 );
27216
27217
27218 --
27219 -- call ADRs
27220 -- Bug 4922099
27221 --
27222 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27223 (NVL(l_actual_upg_option, 'N') = 'O') OR
27224 (NVL(l_enc_upg_option, 'N') = 'O')
27225 )
27226 THEN
27227 NULL;
27228 --
27229 --
27230
27231 l_ccid := AcctDerRule_6(
27232 p_application_id => p_application_id
27233 , p_ae_header_id => l_ae_header_id
27234 , p_source_11 => p_source_11
27235 , x_transaction_coa_id => l_adr_transaction_coa_id
27236 , x_accounting_coa_id => l_adr_accounting_coa_id
27237 , x_value_type_code => l_adr_value_type_code
27238 , p_side => 'NA'
27239 );
27240
27241 xla_ae_lines_pkg.set_ccid(
27242 p_code_combination_id => l_ccid
27243 , p_value_type_code => l_adr_value_type_code
27244 , p_transaction_coa_id => l_adr_transaction_coa_id
27245 , p_accounting_coa_id => l_adr_accounting_coa_id
27246 , p_adr_code => 'CST_DEFAULT'
27247 , p_adr_type_code => 'S'
27248 , p_component_type => l_component_type
27249 , p_component_code => l_component_code
27250 , p_component_type_code => l_component_type_code
27251 , p_component_appl_id => l_component_appl_id
27252 , p_amb_context_code => l_amb_context_code
27253 , p_side => 'NA'
27254 );
27255
27256
27257 --
27258 --
27259 END IF;
27260 --
27261 -- Bug 4922099
27262 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27263 (NVL(l_enc_upg_option, 'N') = 'O')
27264 ) AND
27265 (l_bflow_method_code = 'PRIOR_ENTRY')
27266 )
27267 THEN
27268 IF
27269 --
27270 1 = 2
27271 --
27272 THEN
27273 xla_accounting_err_pkg.build_message
27274 (p_appli_s_name => 'XLA'
27275 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27276 ,p_token_1 => 'LINE_NUMBER'
27277 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27278 ,p_token_2 => 'LINE_TYPE_NAME'
27279 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27280 l_component_type
27281 ,l_component_code
27282 ,l_component_type_code
27283 ,l_component_appl_id
27284 ,l_amb_context_code
27285 ,l_entity_code
27286 ,l_event_class_code
27287 )
27288 ,p_token_3 => 'OWNER'
27289 ,p_value_3 => xla_lookups_pkg.get_meaning(
27290 p_lookup_type => 'XLA_OWNER_TYPE'
27291 ,p_lookup_code => l_component_type_code
27292 )
27293 ,p_token_4 => 'PRODUCT_NAME'
27294 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27295 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27296 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27297 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27298 ,p_ae_header_id => NULL
27299 );
27300
27301 IF (C_LEVEL_ERROR>= g_log_level) THEN
27302 trace
27303 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27304 ,p_level => C_LEVEL_ERROR
27305 ,p_module => l_log_module);
27306 END IF;
27307 END IF;
27308 END IF;
27309 --
27310 --
27311 ------------------------------------------------------------------------------------------------
27312 -- 4219869 Business Flow
27313 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27314 -- Prior Entry. Currently, the following code is always generated.
27315 ------------------------------------------------------------------------------------------------
27316 XLA_AE_LINES_PKG.ValidateCurrentLine;
27317
27318 ------------------------------------------------------------------------------------
27319 -- 4219869 Business Flow
27320 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27321 ------------------------------------------------------------------------------------
27322 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27323
27324 ----------------------------------------------------------------------------------
27325 -- 4219869 Business Flow
27326 -- Update journal entry status -- Need to generate this within IF <condition>
27327 ----------------------------------------------------------------------------------
27328 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27329 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27330 ,p_balance_type_code => l_balance_type_code
27331 );
27332
27333 -------------------------------------------------------------------------------------------
27334 -- 4262811 - Generate the Accrual Reversal lines
27335 -------------------------------------------------------------------------------------------
27336 BEGIN
27337 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27338 (g_array_event(p_event_id).array_value_num('header_index'));
27339 IF l_acc_rev_flag IS NULL THEN
27340 l_acc_rev_flag := 'N';
27341 END IF;
27342 EXCEPTION
27343 WHEN OTHERS THEN
27344 l_acc_rev_flag := 'N';
27345 END;
27346 --
27347 IF (l_acc_rev_flag = 'Y') THEN
27348
27349 -- 4645092 ------------------------------------------------------------------------------
27350 -- To allow MPA report to determine if it should generate report process
27351 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27352 ------------------------------------------------------------------------------------------
27353
27354 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27355 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27356 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27357 -- call ADRs
27358 -- Bug 4922099
27359 --
27360 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27361 (NVL(l_actual_upg_option, 'N') = 'O') OR
27362 (NVL(l_enc_upg_option, 'N') = 'O')
27363 )
27364 THEN
27365 NULL;
27366 --
27367 --
27368
27369 l_ccid := AcctDerRule_6(
27370 p_application_id => p_application_id
27371 , p_ae_header_id => l_ae_header_id
27372 , p_source_11 => p_source_11
27373 , x_transaction_coa_id => l_adr_transaction_coa_id
27374 , x_accounting_coa_id => l_adr_accounting_coa_id
27375 , x_value_type_code => l_adr_value_type_code
27376 , p_side => 'NA'
27377 );
27378
27379 xla_ae_lines_pkg.set_ccid(
27380 p_code_combination_id => l_ccid
27381 , p_value_type_code => l_adr_value_type_code
27382 , p_transaction_coa_id => l_adr_transaction_coa_id
27383 , p_accounting_coa_id => l_adr_accounting_coa_id
27384 , p_adr_code => 'CST_DEFAULT'
27385 , p_adr_type_code => 'S'
27386 , p_component_type => l_component_type
27387 , p_component_code => l_component_code
27388 , p_component_type_code => l_component_type_code
27389 , p_component_appl_id => l_component_appl_id
27390 , p_amb_context_code => l_amb_context_code
27391 , p_side => 'NA'
27392 );
27393
27394
27395 --
27396 --
27397 END IF;
27398
27399 --
27400 -- Update the line information that should be overwritten
27401 --
27402 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27403 p_header_num => 1);
27404 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27405
27406 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27407
27408 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27409 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27410 END IF;
27411
27412 --
27413 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27414 --
27415 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27416 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27417 ELSE
27418 ---------------------------------------------------------------------------------------------------
27419 -- 4262811a Switch Sign
27420 ---------------------------------------------------------------------------------------------------
27421 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27422 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27423 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27424 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27425 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27426 -- 5132302
27427 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27428 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27429
27430 END IF;
27431
27432 -- 4955764
27433 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27434 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27435
27436
27437 XLA_AE_LINES_PKG.ValidateCurrentLine;
27438 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27439
27440 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27441 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27442 ,p_balance_type_code => l_balance_type_code);
27443
27444 END IF;
27445
27446 -----------------------------------------------------------------------------------------
27447 -- 4262811 Multiperiod Accounting
27448 -----------------------------------------------------------------------------------------
27449 -- No MPA option is assigned.
27450
27451
27452 END IF;
27453 END IF;
27454 --
27455
27456 --
27457 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27458 trace
27459 (p_msg => 'END of AcctLineType_74'
27460 ,p_level => C_LEVEL_PROCEDURE
27461 ,p_module => l_log_module);
27462 END IF;
27463 --
27464 EXCEPTION
27465 WHEN xla_exceptions_pkg.application_exception THEN
27466 RAISE;
27467 WHEN OTHERS THEN
27468 xla_exceptions_pkg.raise_message
27469 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_74');
27470 END AcctLineType_74;
27471 --
27472
27473 ---------------------------------------
27474 --
27475 -- PRIVATE FUNCTION
27476 -- AcctLineType_75
27477 --
27478 ---------------------------------------
27479 PROCEDURE AcctLineType_75 (
27480 p_application_id IN NUMBER
27481 ,p_event_id IN NUMBER
27482 ,p_calculate_acctd_flag IN VARCHAR2
27483 ,p_calculate_g_l_flag IN VARCHAR2
27484 ,p_actual_flag IN OUT VARCHAR2
27485 ,p_balance_type_code OUT VARCHAR2
27486 ,p_gain_or_loss_ref OUT VARCHAR2
27487
27488 --TRANSACTION_ID
27489 , p_source_1 IN NUMBER
27490 --Item Concatenated Segments
27491 , p_source_2 IN VARCHAR2
27492 --Transaction Quantity
27493 , p_source_3 IN NUMBER
27494 --Transaction Unit of Measure Code
27495 , p_source_4 IN VARCHAR2
27496 --Inventory Transaction Type Description
27497 , p_source_5 IN VARCHAR2
27498 --Cost Management Default Account
27499 , p_source_11 IN NUMBER
27500 --DISTRIBUTION_IDENTIFIER
27501 , p_source_84 IN NUMBER
27502 --Distribution Type
27503 , p_source_85 IN VARCHAR2
27504 , p_source_85_meaning IN VARCHAR2
27505 --Entered Currency Code
27506 , p_source_88 IN VARCHAR2
27507 --Entered Amount
27508 , p_source_91 IN NUMBER
27509 --Currency Conversion Date
27510 , p_source_92 IN DATE
27511 --Currency Conversion Rate
27512 , p_source_93 IN NUMBER
27513 --Currency Conversion Type
27514 , p_source_94 IN VARCHAR2
27515 --Accounted Amount
27516 , p_source_95 IN NUMBER
27517 --Accounting Line Type
27518 , p_source_97 IN NUMBER
27519 )
27520 IS
27521
27522 l_component_type VARCHAR2(80);
27523 l_component_code VARCHAR2(30);
27524 l_component_type_code VARCHAR2(1);
27525 l_component_appl_id INTEGER;
27526 l_amb_context_code VARCHAR2(30);
27527 l_entity_code VARCHAR2(30);
27528 l_event_class_code VARCHAR2(30);
27529 l_ae_header_id NUMBER;
27530 l_event_type_code VARCHAR2(30);
27531 l_line_definition_code VARCHAR2(30);
27532 l_line_definition_owner_code VARCHAR2(1);
27533 --
27534 -- adr variables
27535 l_segment VARCHAR2(30);
27536 l_ccid NUMBER;
27537 l_adr_transaction_coa_id NUMBER;
27538 l_adr_accounting_coa_id NUMBER;
27539 l_adr_flexfield_segment_code VARCHAR2(30);
27540 l_adr_flex_value_set_id NUMBER;
27541 l_adr_value_type_code VARCHAR2(30);
27542 l_adr_value_combination_id NUMBER;
27543 l_adr_value_segment_code VARCHAR2(30);
27544
27545 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27546 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27547 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27548 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27549
27550 -- 4262811 Variables ------------------------------------------------------------------------------------------
27551 l_entered_amt_idx NUMBER;
27552 l_accted_amt_idx NUMBER;
27553 l_acc_rev_flag VARCHAR2(1);
27554 l_accrual_line_num NUMBER;
27555 l_tmp_amt NUMBER;
27556 l_acc_rev_natural_side_code VARCHAR2(1);
27557
27558 l_num_entries NUMBER;
27559 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27560 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27561 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27562 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27563 l_recog_line_1 NUMBER;
27564 l_recog_line_2 NUMBER;
27565
27566 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27567 l_bflow_applied_to_amt NUMBER; -- 5132302
27568 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27569
27570 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27571
27572 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27573 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27574
27575 ---------------------------------------------------------------------------------------------------------------
27576
27577
27578 --
27579 -- bulk performance
27580 --
27581 l_balance_type_code VARCHAR2(1);
27582 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27583 l_log_module VARCHAR2(240);
27584
27585 --
27586 -- Upgrade strategy
27587 --
27588 l_actual_upg_option VARCHAR2(1);
27589 l_enc_upg_option VARCHAR2(1);
27590
27591 --
27592 BEGIN
27593 --
27594 IF g_log_enabled THEN
27595 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_75';
27596 END IF;
27597 --
27598 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27599
27600 trace
27601 (p_msg => 'BEGIN of AcctLineType_75'
27602 ,p_level => C_LEVEL_PROCEDURE
27603 ,p_module => l_log_module);
27604
27605 END IF;
27606 --
27607 l_component_type := 'AMB_JLT';
27608 l_component_code := 'COST_UPDATE_ADJUSTMENT';
27609 l_component_type_code := 'S';
27610 l_component_appl_id := 707;
27611 l_amb_context_code := 'DEFAULT';
27612 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
27613 l_event_class_code := 'MTL_COST_UPD';
27614 l_event_type_code := 'IPV_TXFR';
27615 l_line_definition_owner_code := 'S';
27616 l_line_definition_code := 'PI_IPV_TXFR';
27617 --
27618 l_balance_type_code := 'A';
27619 l_segment := NULL;
27620 l_ccid := NULL;
27621 l_adr_transaction_coa_id := NULL;
27622 l_adr_accounting_coa_id := NULL;
27623 l_adr_flexfield_segment_code := NULL;
27624 l_adr_flex_value_set_id := NULL;
27625 l_adr_value_type_code := NULL;
27626 l_adr_value_combination_id := NULL;
27627 l_adr_value_segment_code := NULL;
27628
27629 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27630 l_bflow_class_code := ''; -- 4219869 Business Flow
27631 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27632 l_budgetary_control_flag := 'N';
27633
27634 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27635 l_bflow_applied_to_amt := NULL; -- 5132302
27636 l_entered_amt_idx := NULL; -- 4262811
27637 l_accted_amt_idx := NULL; -- 4262811
27638 l_acc_rev_flag := NULL; -- 4262811
27639 l_accrual_line_num := NULL; -- 4262811
27640 l_tmp_amt := NULL; -- 4262811
27641 --
27642
27643 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27644 l_balance_type_code <> 'B' THEN
27645 IF NVL(p_source_97,9E125) = 2
27646 THEN
27647
27648 --
27649 XLA_AE_LINES_PKG.SetNewLine;
27650
27651 p_balance_type_code := l_balance_type_code;
27652 -- set the flag so later we will know whether the gain loss line needs to be created
27653
27654 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27655 p_actual_flag :='A';
27656 END IF;
27657
27658 --
27659 -- bulk performance
27660 --
27661 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27662 p_header_num => 0); -- 4262811
27663 --
27664 -- set accounting line options
27665 --
27666 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27667 p_natural_side_code => 'D'
27668 , p_gain_or_loss_flag => 'N'
27669 , p_gl_transfer_mode_code => 'S'
27670 , p_acct_entry_type_code => 'A'
27671 , p_switch_side_flag => 'Y'
27672 , p_merge_duplicate_code => 'N'
27673 );
27674 --
27675 l_acc_rev_natural_side_code := 'C'; -- 4262811
27676 --
27677 --
27678 -- set accounting line type info
27679 --
27680 xla_ae_lines_pkg.SetAcctLineType
27681 (p_component_type => l_component_type
27682 ,p_event_type_code => l_event_type_code
27683 ,p_line_definition_owner_code => l_line_definition_owner_code
27684 ,p_line_definition_code => l_line_definition_code
27685 ,p_accounting_line_code => l_component_code
27686 ,p_accounting_line_type_code => l_component_type_code
27687 ,p_accounting_line_appl_id => l_component_appl_id
27688 ,p_amb_context_code => l_amb_context_code
27689 ,p_entity_code => l_entity_code
27690 ,p_event_class_code => l_event_class_code);
27691 --
27692 -- set accounting class
27693 --
27694 xla_ae_lines_pkg.SetAcctClass(
27695 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
27696 , p_ae_header_id => l_ae_header_id
27697 );
27698
27699 --
27700 -- set rounding class
27701 --
27702 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27703 'COST_UPDATE_ADJUSTMENT';
27704
27705 --
27706 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27707 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27708 --
27709 -- bulk performance
27710 --
27711 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27712
27713 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27714 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27715
27716 -- 4955764
27717 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27718 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27719
27720 -- 4458381 Public Sector Enh
27721
27722 --
27723 -- set accounting attributes for the line type
27724 --
27725 l_entered_amt_idx := 3;
27726 l_accted_amt_idx := 8;
27727 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27728 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
27729 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
27730 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
27731 l_rec_acct_attrs.array_char_value(2) := p_source_85;
27732 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
27733 l_rec_acct_attrs.array_num_value(3) := p_source_91;
27734 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
27735 l_rec_acct_attrs.array_char_value(4) := p_source_88;
27736 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
27737 l_rec_acct_attrs.array_date_value(5) := p_source_92;
27738 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
27739 l_rec_acct_attrs.array_num_value(6) := p_source_93;
27740 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
27741 l_rec_acct_attrs.array_char_value(7) := p_source_94;
27742 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
27743 l_rec_acct_attrs.array_num_value(8) := p_source_95;
27744
27745 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27746 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27747
27748 ---------------------------------------------------------------------------------------------------------------
27749 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27750 ---------------------------------------------------------------------------------------------------------------
27751 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27752
27753 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27754 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27755
27756 IF xla_accounting_cache_pkg.GetValueChar
27757 (p_source_code => 'LEDGER_CATEGORY_CODE'
27758 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27759 AND l_bflow_method_code = 'PRIOR_ENTRY'
27760 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27761 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27762 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27763 )
27764 THEN
27765 xla_ae_lines_pkg.BflowUpgEntry
27766 (p_business_method_code => l_bflow_method_code
27767 ,p_business_class_code => l_bflow_class_code
27768 ,p_balance_type => l_balance_type_code);
27769 ELSE
27770 NULL;
27771 -- No business flow processing for business flow method of NONE.
27772 END IF;
27773
27774 --
27775 -- call analytical criteria
27776 --
27777
27778 --
27779 -- call description
27780 --
27781
27782 xla_ae_lines_pkg.SetLineDescription(
27783 p_ae_header_id => l_ae_header_id
27784 ,p_description => Description_1 (
27785 p_application_id => p_application_id
27786 , p_ae_header_id => l_ae_header_id
27787 , p_source_1 => p_source_1
27788 , p_source_2 => p_source_2
27789 , p_source_3 => p_source_3
27790 , p_source_4 => p_source_4
27791 , p_source_5 => p_source_5
27792 )
27793 );
27794
27795
27796 --
27797 -- call ADRs
27798 -- Bug 4922099
27799 --
27800 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27801 (NVL(l_actual_upg_option, 'N') = 'O') OR
27802 (NVL(l_enc_upg_option, 'N') = 'O')
27803 )
27804 THEN
27805 NULL;
27806 --
27807 --
27808
27809 l_ccid := AcctDerRule_6(
27810 p_application_id => p_application_id
27811 , p_ae_header_id => l_ae_header_id
27812 , p_source_11 => p_source_11
27813 , x_transaction_coa_id => l_adr_transaction_coa_id
27814 , x_accounting_coa_id => l_adr_accounting_coa_id
27815 , x_value_type_code => l_adr_value_type_code
27816 , p_side => 'NA'
27817 );
27818
27819 xla_ae_lines_pkg.set_ccid(
27820 p_code_combination_id => l_ccid
27821 , p_value_type_code => l_adr_value_type_code
27822 , p_transaction_coa_id => l_adr_transaction_coa_id
27823 , p_accounting_coa_id => l_adr_accounting_coa_id
27824 , p_adr_code => 'CST_DEFAULT'
27825 , p_adr_type_code => 'S'
27826 , p_component_type => l_component_type
27827 , p_component_code => l_component_code
27828 , p_component_type_code => l_component_type_code
27829 , p_component_appl_id => l_component_appl_id
27830 , p_amb_context_code => l_amb_context_code
27831 , p_side => 'NA'
27832 );
27833
27834
27835 --
27836 --
27837 END IF;
27838 --
27839 -- Bug 4922099
27840 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27841 (NVL(l_enc_upg_option, 'N') = 'O')
27842 ) AND
27843 (l_bflow_method_code = 'PRIOR_ENTRY')
27844 )
27845 THEN
27846 IF
27847 --
27848 1 = 2
27849 --
27850 THEN
27851 xla_accounting_err_pkg.build_message
27852 (p_appli_s_name => 'XLA'
27853 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27854 ,p_token_1 => 'LINE_NUMBER'
27855 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27856 ,p_token_2 => 'LINE_TYPE_NAME'
27857 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27858 l_component_type
27859 ,l_component_code
27860 ,l_component_type_code
27861 ,l_component_appl_id
27862 ,l_amb_context_code
27863 ,l_entity_code
27864 ,l_event_class_code
27865 )
27866 ,p_token_3 => 'OWNER'
27867 ,p_value_3 => xla_lookups_pkg.get_meaning(
27868 p_lookup_type => 'XLA_OWNER_TYPE'
27869 ,p_lookup_code => l_component_type_code
27870 )
27871 ,p_token_4 => 'PRODUCT_NAME'
27872 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27873 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27874 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27875 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27876 ,p_ae_header_id => NULL
27877 );
27878
27879 IF (C_LEVEL_ERROR>= g_log_level) THEN
27880 trace
27881 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27882 ,p_level => C_LEVEL_ERROR
27883 ,p_module => l_log_module);
27884 END IF;
27885 END IF;
27886 END IF;
27887 --
27888 --
27889 ------------------------------------------------------------------------------------------------
27890 -- 4219869 Business Flow
27891 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27892 -- Prior Entry. Currently, the following code is always generated.
27893 ------------------------------------------------------------------------------------------------
27894 XLA_AE_LINES_PKG.ValidateCurrentLine;
27895
27896 ------------------------------------------------------------------------------------
27897 -- 4219869 Business Flow
27898 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27899 ------------------------------------------------------------------------------------
27900 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27901
27902 ----------------------------------------------------------------------------------
27903 -- 4219869 Business Flow
27904 -- Update journal entry status -- Need to generate this within IF <condition>
27905 ----------------------------------------------------------------------------------
27906 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27907 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27908 ,p_balance_type_code => l_balance_type_code
27909 );
27910
27911 -------------------------------------------------------------------------------------------
27912 -- 4262811 - Generate the Accrual Reversal lines
27913 -------------------------------------------------------------------------------------------
27914 BEGIN
27915 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27916 (g_array_event(p_event_id).array_value_num('header_index'));
27917 IF l_acc_rev_flag IS NULL THEN
27918 l_acc_rev_flag := 'N';
27919 END IF;
27920 EXCEPTION
27921 WHEN OTHERS THEN
27922 l_acc_rev_flag := 'N';
27923 END;
27924 --
27925 IF (l_acc_rev_flag = 'Y') THEN
27926
27927 -- 4645092 ------------------------------------------------------------------------------
27928 -- To allow MPA report to determine if it should generate report process
27929 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27930 ------------------------------------------------------------------------------------------
27931
27932 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27933 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27934 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27935 -- call ADRs
27936 -- Bug 4922099
27937 --
27938 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27939 (NVL(l_actual_upg_option, 'N') = 'O') OR
27940 (NVL(l_enc_upg_option, 'N') = 'O')
27941 )
27942 THEN
27943 NULL;
27944 --
27945 --
27946
27947 l_ccid := AcctDerRule_6(
27948 p_application_id => p_application_id
27949 , p_ae_header_id => l_ae_header_id
27950 , p_source_11 => p_source_11
27951 , x_transaction_coa_id => l_adr_transaction_coa_id
27952 , x_accounting_coa_id => l_adr_accounting_coa_id
27953 , x_value_type_code => l_adr_value_type_code
27954 , p_side => 'NA'
27955 );
27956
27957 xla_ae_lines_pkg.set_ccid(
27958 p_code_combination_id => l_ccid
27959 , p_value_type_code => l_adr_value_type_code
27960 , p_transaction_coa_id => l_adr_transaction_coa_id
27961 , p_accounting_coa_id => l_adr_accounting_coa_id
27962 , p_adr_code => 'CST_DEFAULT'
27963 , p_adr_type_code => 'S'
27964 , p_component_type => l_component_type
27965 , p_component_code => l_component_code
27966 , p_component_type_code => l_component_type_code
27967 , p_component_appl_id => l_component_appl_id
27968 , p_amb_context_code => l_amb_context_code
27969 , p_side => 'NA'
27970 );
27971
27972
27973 --
27974 --
27975 END IF;
27976
27977 --
27978 -- Update the line information that should be overwritten
27979 --
27980 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27981 p_header_num => 1);
27982 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27983
27984 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27985
27986 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27987 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27988 END IF;
27989
27990 --
27991 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27992 --
27993 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27994 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27995 ELSE
27996 ---------------------------------------------------------------------------------------------------
27997 -- 4262811a Switch Sign
27998 ---------------------------------------------------------------------------------------------------
27999 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28000 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28001 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28002 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28003 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28004 -- 5132302
28005 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28006 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28007
28008 END IF;
28009
28010 -- 4955764
28011 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28012 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28013
28014
28015 XLA_AE_LINES_PKG.ValidateCurrentLine;
28016 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28017
28018 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28019 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28020 ,p_balance_type_code => l_balance_type_code);
28021
28022 END IF;
28023
28024 -----------------------------------------------------------------------------------------
28025 -- 4262811 Multiperiod Accounting
28026 -----------------------------------------------------------------------------------------
28027 -- No MPA option is assigned.
28028
28029
28030 END IF;
28031 END IF;
28032 --
28033
28034 --
28035 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28036 trace
28037 (p_msg => 'END of AcctLineType_75'
28038 ,p_level => C_LEVEL_PROCEDURE
28039 ,p_module => l_log_module);
28040 END IF;
28041 --
28042 EXCEPTION
28043 WHEN xla_exceptions_pkg.application_exception THEN
28044 RAISE;
28045 WHEN OTHERS THEN
28046 xla_exceptions_pkg.raise_message
28047 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_75');
28048 END AcctLineType_75;
28049 --
28050
28051 ---------------------------------------
28052 --
28053 -- PRIVATE FUNCTION
28054 -- AcctLineType_76
28055 --
28056 ---------------------------------------
28057 PROCEDURE AcctLineType_76 (
28058 p_application_id IN NUMBER
28059 ,p_event_id IN NUMBER
28060 ,p_calculate_acctd_flag IN VARCHAR2
28061 ,p_calculate_g_l_flag IN VARCHAR2
28062 ,p_actual_flag IN OUT VARCHAR2
28063 ,p_balance_type_code OUT VARCHAR2
28064 ,p_gain_or_loss_ref OUT VARCHAR2
28065
28066 --TRANSACTION_ID
28067 , p_source_1 IN NUMBER
28068 --Item Concatenated Segments
28069 , p_source_2 IN VARCHAR2
28070 --Transaction Quantity
28071 , p_source_3 IN NUMBER
28072 --Transaction Unit of Measure Code
28073 , p_source_4 IN VARCHAR2
28074 --Inventory Transaction Type Description
28075 , p_source_5 IN VARCHAR2
28076 --Transaction Material Account
28077 , p_source_14 IN NUMBER
28078 --Cost Element Name
28079 , p_source_15 IN NUMBER
28080 --Transaction Material Overhead Account
28081 , p_source_16 IN NUMBER
28082 --Transaction Resource Account
28083 , p_source_17 IN NUMBER
28084 --Transaction Outside Processing Account
28085 , p_source_18 IN NUMBER
28086 --Transaction Overhead Account
28087 , p_source_19 IN NUMBER
28088 --Transaction Distribution Account
28089 , p_source_20 IN NUMBER
28090 --DISTRIBUTION_IDENTIFIER
28091 , p_source_84 IN NUMBER
28092 --Distribution Type
28093 , p_source_85 IN VARCHAR2
28094 , p_source_85_meaning IN VARCHAR2
28095 --Entered Currency Code
28096 , p_source_88 IN VARCHAR2
28097 --Entered Amount
28098 , p_source_91 IN NUMBER
28099 --Currency Conversion Date
28100 , p_source_92 IN DATE
28101 --Currency Conversion Rate
28102 , p_source_93 IN NUMBER
28103 --Currency Conversion Type
28104 , p_source_94 IN VARCHAR2
28105 --Accounted Amount
28106 , p_source_95 IN NUMBER
28107 --Accounting Line Type
28108 , p_source_97 IN NUMBER
28109 )
28110 IS
28111
28112 l_component_type VARCHAR2(80);
28113 l_component_code VARCHAR2(30);
28114 l_component_type_code VARCHAR2(1);
28115 l_component_appl_id INTEGER;
28116 l_amb_context_code VARCHAR2(30);
28117 l_entity_code VARCHAR2(30);
28118 l_event_class_code VARCHAR2(30);
28119 l_ae_header_id NUMBER;
28120 l_event_type_code VARCHAR2(30);
28121 l_line_definition_code VARCHAR2(30);
28122 l_line_definition_owner_code VARCHAR2(1);
28123 --
28124 -- adr variables
28125 l_segment VARCHAR2(30);
28126 l_ccid NUMBER;
28127 l_adr_transaction_coa_id NUMBER;
28128 l_adr_accounting_coa_id NUMBER;
28129 l_adr_flexfield_segment_code VARCHAR2(30);
28130 l_adr_flex_value_set_id NUMBER;
28131 l_adr_value_type_code VARCHAR2(30);
28132 l_adr_value_combination_id NUMBER;
28133 l_adr_value_segment_code VARCHAR2(30);
28134
28135 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28136 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28137 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28138 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28139
28140 -- 4262811 Variables ------------------------------------------------------------------------------------------
28141 l_entered_amt_idx NUMBER;
28142 l_accted_amt_idx NUMBER;
28143 l_acc_rev_flag VARCHAR2(1);
28144 l_accrual_line_num NUMBER;
28145 l_tmp_amt NUMBER;
28146 l_acc_rev_natural_side_code VARCHAR2(1);
28147
28148 l_num_entries NUMBER;
28149 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28150 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28151 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28152 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28153 l_recog_line_1 NUMBER;
28154 l_recog_line_2 NUMBER;
28155
28156 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28157 l_bflow_applied_to_amt NUMBER; -- 5132302
28158 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28159
28160 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28161
28162 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28163 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28164
28165 ---------------------------------------------------------------------------------------------------------------
28166
28167
28168 --
28169 -- bulk performance
28170 --
28171 l_balance_type_code VARCHAR2(1);
28172 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28173 l_log_module VARCHAR2(240);
28174
28175 --
28176 -- Upgrade strategy
28177 --
28178 l_actual_upg_option VARCHAR2(1);
28179 l_enc_upg_option VARCHAR2(1);
28180
28181 --
28182 BEGIN
28183 --
28184 IF g_log_enabled THEN
28185 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_76';
28186 END IF;
28187 --
28188 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28189
28190 trace
28191 (p_msg => 'BEGIN of AcctLineType_76'
28192 ,p_level => C_LEVEL_PROCEDURE
28193 ,p_module => l_log_module);
28194
28195 END IF;
28196 --
28197 l_component_type := 'AMB_JLT';
28198 l_component_code := 'COST_UPDATE_ADJUSTMENT';
28199 l_component_type_code := 'S';
28200 l_component_appl_id := 707;
28201 l_amb_context_code := 'DEFAULT';
28202 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
28203 l_event_class_code := 'USER_DEFINE';
28204 l_event_type_code := 'UIPV_TXFR';
28205 l_line_definition_owner_code := 'S';
28206 l_line_definition_code := 'PI_IPV_TXFR';
28207 --
28208 l_balance_type_code := 'A';
28209 l_segment := NULL;
28210 l_ccid := NULL;
28211 l_adr_transaction_coa_id := NULL;
28212 l_adr_accounting_coa_id := NULL;
28213 l_adr_flexfield_segment_code := NULL;
28214 l_adr_flex_value_set_id := NULL;
28215 l_adr_value_type_code := NULL;
28216 l_adr_value_combination_id := NULL;
28217 l_adr_value_segment_code := NULL;
28218
28219 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28220 l_bflow_class_code := ''; -- 4219869 Business Flow
28221 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28222 l_budgetary_control_flag := 'N';
28223
28224 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28225 l_bflow_applied_to_amt := NULL; -- 5132302
28226 l_entered_amt_idx := NULL; -- 4262811
28227 l_accted_amt_idx := NULL; -- 4262811
28228 l_acc_rev_flag := NULL; -- 4262811
28229 l_accrual_line_num := NULL; -- 4262811
28230 l_tmp_amt := NULL; -- 4262811
28231 --
28232
28233 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28234 l_balance_type_code <> 'B' THEN
28235 IF NVL(p_source_97,9E125) = 2
28236 THEN
28237
28238 --
28239 XLA_AE_LINES_PKG.SetNewLine;
28240
28241 p_balance_type_code := l_balance_type_code;
28242 -- set the flag so later we will know whether the gain loss line needs to be created
28243
28244 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28245 p_actual_flag :='A';
28246 END IF;
28247
28248 --
28249 -- bulk performance
28250 --
28251 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28252 p_header_num => 0); -- 4262811
28253 --
28254 -- set accounting line options
28255 --
28256 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28257 p_natural_side_code => 'D'
28258 , p_gain_or_loss_flag => 'N'
28259 , p_gl_transfer_mode_code => 'S'
28260 , p_acct_entry_type_code => 'A'
28261 , p_switch_side_flag => 'Y'
28262 , p_merge_duplicate_code => 'N'
28263 );
28264 --
28265 l_acc_rev_natural_side_code := 'C'; -- 4262811
28266 --
28267 --
28268 -- set accounting line type info
28269 --
28270 xla_ae_lines_pkg.SetAcctLineType
28271 (p_component_type => l_component_type
28272 ,p_event_type_code => l_event_type_code
28273 ,p_line_definition_owner_code => l_line_definition_owner_code
28274 ,p_line_definition_code => l_line_definition_code
28275 ,p_accounting_line_code => l_component_code
28276 ,p_accounting_line_type_code => l_component_type_code
28277 ,p_accounting_line_appl_id => l_component_appl_id
28278 ,p_amb_context_code => l_amb_context_code
28279 ,p_entity_code => l_entity_code
28280 ,p_event_class_code => l_event_class_code);
28281 --
28282 -- set accounting class
28283 --
28284 xla_ae_lines_pkg.SetAcctClass(
28285 p_accounting_class_code => 'COST_UPDATE_ADJUSTMENT'
28286 , p_ae_header_id => l_ae_header_id
28287 );
28288
28289 --
28290 -- set rounding class
28291 --
28292 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28293 'COST_UPDATE_ADJUSTMENT';
28294
28295 --
28296 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28297 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28298 --
28299 -- bulk performance
28300 --
28301 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28302
28303 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28304 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28305
28306 -- 4955764
28307 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28308 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28309
28310 -- 4458381 Public Sector Enh
28311
28312 --
28313 -- set accounting attributes for the line type
28314 --
28315 l_entered_amt_idx := 3;
28316 l_accted_amt_idx := 8;
28317 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28318 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
28319 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
28320 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
28321 l_rec_acct_attrs.array_char_value(2) := p_source_85;
28322 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
28323 l_rec_acct_attrs.array_num_value(3) := p_source_91;
28324 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
28325 l_rec_acct_attrs.array_char_value(4) := p_source_88;
28326 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
28327 l_rec_acct_attrs.array_date_value(5) := p_source_92;
28328 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
28329 l_rec_acct_attrs.array_num_value(6) := p_source_93;
28330 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
28331 l_rec_acct_attrs.array_char_value(7) := p_source_94;
28332 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
28333 l_rec_acct_attrs.array_num_value(8) := p_source_95;
28334
28335 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28336 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28337
28338 ---------------------------------------------------------------------------------------------------------------
28339 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28340 ---------------------------------------------------------------------------------------------------------------
28341 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28342
28343 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28344 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28345
28346 IF xla_accounting_cache_pkg.GetValueChar
28347 (p_source_code => 'LEDGER_CATEGORY_CODE'
28348 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28349 AND l_bflow_method_code = 'PRIOR_ENTRY'
28350 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28351 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28352 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28353 )
28354 THEN
28355 xla_ae_lines_pkg.BflowUpgEntry
28356 (p_business_method_code => l_bflow_method_code
28357 ,p_business_class_code => l_bflow_class_code
28358 ,p_balance_type => l_balance_type_code);
28359 ELSE
28360 NULL;
28361 -- No business flow processing for business flow method of NONE.
28362 END IF;
28363
28364 --
28365 -- call analytical criteria
28366 --
28367
28368 --
28369 -- call description
28370 --
28371
28372 xla_ae_lines_pkg.SetLineDescription(
28373 p_ae_header_id => l_ae_header_id
28374 ,p_description => Description_1 (
28375 p_application_id => p_application_id
28376 , p_ae_header_id => l_ae_header_id
28377 , p_source_1 => p_source_1
28378 , p_source_2 => p_source_2
28379 , p_source_3 => p_source_3
28380 , p_source_4 => p_source_4
28381 , p_source_5 => p_source_5
28382 )
28383 );
28384
28385
28386 --
28387 -- call ADRs
28388 -- Bug 4922099
28389 --
28390 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28391 (NVL(l_actual_upg_option, 'N') = 'O') OR
28392 (NVL(l_enc_upg_option, 'N') = 'O')
28393 )
28394 THEN
28395 NULL;
28396 --
28397 --
28398
28399 l_ccid := AcctDerRule_9(
28400 p_application_id => p_application_id
28401 , p_ae_header_id => l_ae_header_id
28402 , p_source_14 => p_source_14
28403 , p_source_15 => p_source_15
28404 , p_source_16 => p_source_16
28405 , p_source_17 => p_source_17
28406 , p_source_18 => p_source_18
28407 , p_source_19 => p_source_19
28408 , p_source_20 => p_source_20
28409 , x_transaction_coa_id => l_adr_transaction_coa_id
28410 , x_accounting_coa_id => l_adr_accounting_coa_id
28411 , x_value_type_code => l_adr_value_type_code
28412 , p_side => 'NA'
28413 );
28414
28415 xla_ae_lines_pkg.set_ccid(
28416 p_code_combination_id => l_ccid
28417 , p_value_type_code => l_adr_value_type_code
28418 , p_transaction_coa_id => l_adr_transaction_coa_id
28419 , p_accounting_coa_id => l_adr_accounting_coa_id
28420 , p_adr_code => 'PI_AVG_COST_UPT_OFFSET'
28421 , p_adr_type_code => 'S'
28422 , p_component_type => l_component_type
28423 , p_component_code => l_component_code
28424 , p_component_type_code => l_component_type_code
28425 , p_component_appl_id => l_component_appl_id
28426 , p_amb_context_code => l_amb_context_code
28427 , p_side => 'NA'
28428 );
28429
28430
28431 --
28432 --
28433 END IF;
28434 --
28435 -- Bug 4922099
28436 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28437 (NVL(l_enc_upg_option, 'N') = 'O')
28438 ) AND
28439 (l_bflow_method_code = 'PRIOR_ENTRY')
28440 )
28441 THEN
28442 IF
28443 --
28444 1 = 2
28445 --
28446 THEN
28447 xla_accounting_err_pkg.build_message
28448 (p_appli_s_name => 'XLA'
28449 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28450 ,p_token_1 => 'LINE_NUMBER'
28451 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28452 ,p_token_2 => 'LINE_TYPE_NAME'
28453 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28454 l_component_type
28455 ,l_component_code
28456 ,l_component_type_code
28457 ,l_component_appl_id
28458 ,l_amb_context_code
28459 ,l_entity_code
28460 ,l_event_class_code
28461 )
28462 ,p_token_3 => 'OWNER'
28463 ,p_value_3 => xla_lookups_pkg.get_meaning(
28464 p_lookup_type => 'XLA_OWNER_TYPE'
28465 ,p_lookup_code => l_component_type_code
28466 )
28467 ,p_token_4 => 'PRODUCT_NAME'
28468 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28469 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28470 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28471 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28472 ,p_ae_header_id => NULL
28473 );
28474
28475 IF (C_LEVEL_ERROR>= g_log_level) THEN
28476 trace
28477 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28478 ,p_level => C_LEVEL_ERROR
28479 ,p_module => l_log_module);
28480 END IF;
28481 END IF;
28482 END IF;
28483 --
28484 --
28485 ------------------------------------------------------------------------------------------------
28486 -- 4219869 Business Flow
28487 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28488 -- Prior Entry. Currently, the following code is always generated.
28489 ------------------------------------------------------------------------------------------------
28490 XLA_AE_LINES_PKG.ValidateCurrentLine;
28491
28492 ------------------------------------------------------------------------------------
28493 -- 4219869 Business Flow
28494 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28495 ------------------------------------------------------------------------------------
28496 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28497
28498 ----------------------------------------------------------------------------------
28499 -- 4219869 Business Flow
28500 -- Update journal entry status -- Need to generate this within IF <condition>
28501 ----------------------------------------------------------------------------------
28502 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28503 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28504 ,p_balance_type_code => l_balance_type_code
28505 );
28506
28507 -------------------------------------------------------------------------------------------
28508 -- 4262811 - Generate the Accrual Reversal lines
28509 -------------------------------------------------------------------------------------------
28510 BEGIN
28511 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28512 (g_array_event(p_event_id).array_value_num('header_index'));
28513 IF l_acc_rev_flag IS NULL THEN
28514 l_acc_rev_flag := 'N';
28515 END IF;
28516 EXCEPTION
28517 WHEN OTHERS THEN
28518 l_acc_rev_flag := 'N';
28519 END;
28520 --
28521 IF (l_acc_rev_flag = 'Y') THEN
28522
28523 -- 4645092 ------------------------------------------------------------------------------
28524 -- To allow MPA report to determine if it should generate report process
28525 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28526 ------------------------------------------------------------------------------------------
28527
28528 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28529 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28530 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28531 -- call ADRs
28532 -- Bug 4922099
28533 --
28534 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28535 (NVL(l_actual_upg_option, 'N') = 'O') OR
28536 (NVL(l_enc_upg_option, 'N') = 'O')
28537 )
28538 THEN
28539 NULL;
28540 --
28541 --
28542
28543 l_ccid := AcctDerRule_9(
28544 p_application_id => p_application_id
28545 , p_ae_header_id => l_ae_header_id
28546 , p_source_14 => p_source_14
28547 , p_source_15 => p_source_15
28548 , p_source_16 => p_source_16
28549 , p_source_17 => p_source_17
28550 , p_source_18 => p_source_18
28551 , p_source_19 => p_source_19
28552 , p_source_20 => p_source_20
28553 , x_transaction_coa_id => l_adr_transaction_coa_id
28554 , x_accounting_coa_id => l_adr_accounting_coa_id
28555 , x_value_type_code => l_adr_value_type_code
28556 , p_side => 'NA'
28557 );
28558
28559 xla_ae_lines_pkg.set_ccid(
28560 p_code_combination_id => l_ccid
28561 , p_value_type_code => l_adr_value_type_code
28562 , p_transaction_coa_id => l_adr_transaction_coa_id
28563 , p_accounting_coa_id => l_adr_accounting_coa_id
28564 , p_adr_code => 'PI_AVG_COST_UPT_OFFSET'
28565 , p_adr_type_code => 'S'
28566 , p_component_type => l_component_type
28567 , p_component_code => l_component_code
28568 , p_component_type_code => l_component_type_code
28569 , p_component_appl_id => l_component_appl_id
28570 , p_amb_context_code => l_amb_context_code
28571 , p_side => 'NA'
28572 );
28573
28574
28575 --
28576 --
28577 END IF;
28578
28579 --
28580 -- Update the line information that should be overwritten
28581 --
28582 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28583 p_header_num => 1);
28584 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28585
28586 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28587
28588 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28589 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28590 END IF;
28591
28592 --
28593 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28594 --
28595 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28596 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28597 ELSE
28598 ---------------------------------------------------------------------------------------------------
28599 -- 4262811a Switch Sign
28600 ---------------------------------------------------------------------------------------------------
28601 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28602 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28603 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28604 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28605 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28606 -- 5132302
28607 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28608 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28609
28610 END IF;
28611
28612 -- 4955764
28613 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28614 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28615
28616
28617 XLA_AE_LINES_PKG.ValidateCurrentLine;
28618 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28619
28620 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28621 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28622 ,p_balance_type_code => l_balance_type_code);
28623
28624 END IF;
28625
28626 -----------------------------------------------------------------------------------------
28627 -- 4262811 Multiperiod Accounting
28628 -----------------------------------------------------------------------------------------
28629 -- No MPA option is assigned.
28630
28631
28632 END IF;
28633 END IF;
28634 --
28635
28636 --
28637 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28638 trace
28639 (p_msg => 'END of AcctLineType_76'
28640 ,p_level => C_LEVEL_PROCEDURE
28641 ,p_module => l_log_module);
28642 END IF;
28643 --
28644 EXCEPTION
28645 WHEN xla_exceptions_pkg.application_exception THEN
28646 RAISE;
28647 WHEN OTHERS THEN
28648 xla_exceptions_pkg.raise_message
28649 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_76');
28650 END AcctLineType_76;
28651 --
28652
28653 ---------------------------------------
28654 --
28655 -- PRIVATE FUNCTION
28656 -- AcctLineType_77
28657 --
28658 ---------------------------------------
28659 PROCEDURE AcctLineType_77 (
28660 p_application_id IN NUMBER
28661 ,p_event_id IN NUMBER
28662 ,p_calculate_acctd_flag IN VARCHAR2
28663 ,p_calculate_g_l_flag IN VARCHAR2
28664 ,p_actual_flag IN OUT VARCHAR2
28665 ,p_balance_type_code OUT VARCHAR2
28666 ,p_gain_or_loss_ref OUT VARCHAR2
28667
28668 --TRANSACTION_ID
28669 , p_source_1 IN NUMBER
28670 --Item Concatenated Segments
28671 , p_source_2 IN VARCHAR2
28672 --Transaction Quantity
28673 , p_source_3 IN NUMBER
28674 --Transaction Unit of Measure Code
28675 , p_source_4 IN VARCHAR2
28676 --Inventory Transaction Type Description
28677 , p_source_5 IN VARCHAR2
28678 --Cost Management Default Account
28679 , p_source_11 IN NUMBER
28680 --Applied to Application ID
28681 , p_source_79 IN NUMBER
28682 --Applied to Distribution Link Type
28683 , p_source_80 IN VARCHAR2
28684 --Applied to Entity Code
28685 , p_source_81 IN VARCHAR2
28686 --DISTRIBUTION_IDENTIFIER
28687 , p_source_84 IN NUMBER
28688 --Distribution Type
28689 , p_source_85 IN VARCHAR2
28690 , p_source_85_meaning IN VARCHAR2
28691 --Encumbrance Reversal Amount Entered
28692 , p_source_87 IN NUMBER
28693 --Entered Currency Code
28694 , p_source_88 IN VARCHAR2
28695 --Transaction Encumbrance Reversal Amount
28696 , p_source_89 IN NUMBER
28697 --Entered Amount
28698 , p_source_91 IN NUMBER
28699 --Currency Conversion Date
28700 , p_source_92 IN DATE
28701 --Currency Conversion Rate
28702 , p_source_93 IN NUMBER
28703 --Currency Conversion Type
28704 , p_source_94 IN VARCHAR2
28705 --Accounted Amount
28706 , p_source_95 IN NUMBER
28707 --Accounting Line Type
28708 , p_source_97 IN NUMBER
28709 --Costing Encumbrance Upgrade Option
28710 , p_source_100 IN VARCHAR2
28711 --TXN_PO_DISTRIBUTION_ID
28712 , p_source_101 IN NUMBER
28713 --TXN_PO_HEADER_ID
28714 , p_source_102 IN NUMBER
28715 --Requisition Budget Account
28716 , p_source_103 IN NUMBER
28717 --Requisition Encumbrance Type Identifier
28718 , p_source_104 IN NUMBER
28719 )
28720 IS
28721
28722 l_component_type VARCHAR2(80);
28723 l_component_code VARCHAR2(30);
28724 l_component_type_code VARCHAR2(1);
28725 l_component_appl_id INTEGER;
28726 l_amb_context_code VARCHAR2(30);
28727 l_entity_code VARCHAR2(30);
28728 l_event_class_code VARCHAR2(30);
28729 l_ae_header_id NUMBER;
28730 l_event_type_code VARCHAR2(30);
28731 l_line_definition_code VARCHAR2(30);
28732 l_line_definition_owner_code VARCHAR2(1);
28733 --
28734 -- adr variables
28735 l_segment VARCHAR2(30);
28736 l_ccid NUMBER;
28737 l_adr_transaction_coa_id NUMBER;
28738 l_adr_accounting_coa_id NUMBER;
28739 l_adr_flexfield_segment_code VARCHAR2(30);
28740 l_adr_flex_value_set_id NUMBER;
28741 l_adr_value_type_code VARCHAR2(30);
28742 l_adr_value_combination_id NUMBER;
28743 l_adr_value_segment_code VARCHAR2(30);
28744
28745 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28746 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28747 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28748 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28749
28750 -- 4262811 Variables ------------------------------------------------------------------------------------------
28751 l_entered_amt_idx NUMBER;
28752 l_accted_amt_idx NUMBER;
28753 l_acc_rev_flag VARCHAR2(1);
28754 l_accrual_line_num NUMBER;
28755 l_tmp_amt NUMBER;
28756 l_acc_rev_natural_side_code VARCHAR2(1);
28757
28758 l_num_entries NUMBER;
28759 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28760 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28761 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28762 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28763 l_recog_line_1 NUMBER;
28764 l_recog_line_2 NUMBER;
28765
28766 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28767 l_bflow_applied_to_amt NUMBER; -- 5132302
28768 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28769
28770 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28771
28772 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28773 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28774
28775 ---------------------------------------------------------------------------------------------------------------
28776
28777
28778 --
28779 -- bulk performance
28780 --
28781 l_balance_type_code VARCHAR2(1);
28782 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28783 l_log_module VARCHAR2(240);
28784
28785 --
28786 -- Upgrade strategy
28787 --
28788 l_actual_upg_option VARCHAR2(1);
28789 l_enc_upg_option VARCHAR2(1);
28790
28791 --
28792 BEGIN
28793 --
28794 IF g_log_enabled THEN
28795 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_77';
28796 END IF;
28797 --
28798 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28799
28800 trace
28801 (p_msg => 'BEGIN of AcctLineType_77'
28802 ,p_level => C_LEVEL_PROCEDURE
28803 ,p_module => l_log_module);
28804
28805 END IF;
28806 --
28807 l_component_type := 'AMB_JLT';
28808 l_component_code := 'COST_VARIANCE';
28809 l_component_type_code := 'S';
28810 l_component_appl_id := 707;
28811 l_amb_context_code := 'DEFAULT';
28812 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
28813 l_event_class_code := 'DIR_INTERORG_RCPT';
28814 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
28815 l_line_definition_owner_code := 'S';
28816 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
28817 --
28818 l_balance_type_code := 'A';
28819 l_segment := NULL;
28820 l_ccid := NULL;
28821 l_adr_transaction_coa_id := NULL;
28822 l_adr_accounting_coa_id := NULL;
28823 l_adr_flexfield_segment_code := NULL;
28824 l_adr_flex_value_set_id := NULL;
28825 l_adr_value_type_code := NULL;
28826 l_adr_value_combination_id := NULL;
28827 l_adr_value_segment_code := NULL;
28828
28829 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28830 l_bflow_class_code := ''; -- 4219869 Business Flow
28831 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28832 l_budgetary_control_flag := 'N';
28833
28834 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28835 l_bflow_applied_to_amt := NULL; -- 5132302
28836 l_entered_amt_idx := NULL; -- 4262811
28837 l_accted_amt_idx := NULL; -- 4262811
28838 l_acc_rev_flag := NULL; -- 4262811
28839 l_accrual_line_num := NULL; -- 4262811
28840 l_tmp_amt := NULL; -- 4262811
28841 --
28842
28843 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28844 l_balance_type_code <> 'B' THEN
28845 IF NVL(p_source_97,9E125) = 13
28846 THEN
28847
28848 --
28849 XLA_AE_LINES_PKG.SetNewLine;
28850
28851 p_balance_type_code := l_balance_type_code;
28852 -- set the flag so later we will know whether the gain loss line needs to be created
28853
28854 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28855 p_actual_flag :='A';
28856 END IF;
28857
28858 --
28859 -- bulk performance
28860 --
28861 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28862 p_header_num => 0); -- 4262811
28863 --
28864 -- set accounting line options
28865 --
28866 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28867 p_natural_side_code => 'D'
28868 , p_gain_or_loss_flag => 'N'
28869 , p_gl_transfer_mode_code => 'S'
28870 , p_acct_entry_type_code => 'A'
28871 , p_switch_side_flag => 'Y'
28872 , p_merge_duplicate_code => 'N'
28873 );
28874 --
28875 l_acc_rev_natural_side_code := 'C'; -- 4262811
28876 --
28877 --
28878 -- set accounting line type info
28879 --
28880 xla_ae_lines_pkg.SetAcctLineType
28881 (p_component_type => l_component_type
28882 ,p_event_type_code => l_event_type_code
28883 ,p_line_definition_owner_code => l_line_definition_owner_code
28884 ,p_line_definition_code => l_line_definition_code
28885 ,p_accounting_line_code => l_component_code
28886 ,p_accounting_line_type_code => l_component_type_code
28887 ,p_accounting_line_appl_id => l_component_appl_id
28888 ,p_amb_context_code => l_amb_context_code
28889 ,p_entity_code => l_entity_code
28890 ,p_event_class_code => l_event_class_code);
28891 --
28892 -- set accounting class
28893 --
28894 xla_ae_lines_pkg.SetAcctClass(
28895 p_accounting_class_code => 'COST_VARIANCE'
28896 , p_ae_header_id => l_ae_header_id
28897 );
28898
28899 --
28900 -- set rounding class
28901 --
28902 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28903 'COST_VARIANCE';
28904
28905 --
28906 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28907 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28908 --
28909 -- bulk performance
28910 --
28911 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28912
28913 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28914 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28915
28916 -- 4955764
28917 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28918 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28919
28920 -- 4458381 Public Sector Enh
28921
28922 --
28923 -- set accounting attributes for the line type
28924 --
28925 l_entered_amt_idx := 17;
28926 l_accted_amt_idx := 22;
28927 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28928 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
28929 l_rec_acct_attrs.array_num_value(1) := p_source_79;
28930 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
28931 l_rec_acct_attrs.array_char_value(2) := p_source_80;
28932 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
28933 l_rec_acct_attrs.array_char_value(3) := p_source_81;
28934 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
28935 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
28936 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
28937 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
28938 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
28939 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
28940 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
28941 l_rec_acct_attrs.array_char_value(7) := p_source_85;
28942 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
28943 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
28944 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
28945 l_rec_acct_attrs.array_num_value(9) := p_source_87;
28946 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
28947 l_rec_acct_attrs.array_char_value(10) := p_source_88;
28948 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
28949 l_rec_acct_attrs.array_num_value(11) := p_source_89;
28950 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
28951 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
28952 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
28953 l_rec_acct_attrs.array_num_value(13) := p_source_87;
28954 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
28955 l_rec_acct_attrs.array_char_value(14) := p_source_88;
28956 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
28957 l_rec_acct_attrs.array_num_value(15) := p_source_89;
28958 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
28959 l_rec_acct_attrs.array_char_value(16) := p_source_100;
28960 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
28961 l_rec_acct_attrs.array_num_value(17) := p_source_91;
28962 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
28963 l_rec_acct_attrs.array_char_value(18) := p_source_88;
28964 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
28965 l_rec_acct_attrs.array_date_value(19) := p_source_92;
28966 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
28967 l_rec_acct_attrs.array_num_value(20) := p_source_93;
28968 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
28969 l_rec_acct_attrs.array_char_value(21) := p_source_94;
28970 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
28971 l_rec_acct_attrs.array_num_value(22) := p_source_95;
28972 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
28973 l_rec_acct_attrs.array_num_value(23) := p_source_104;
28974 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
28975 l_rec_acct_attrs.array_num_value(24) := p_source_104;
28976
28977 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28978 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28979
28980 ---------------------------------------------------------------------------------------------------------------
28981 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28982 ---------------------------------------------------------------------------------------------------------------
28983 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28984
28985 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28986 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28987
28988 IF xla_accounting_cache_pkg.GetValueChar
28989 (p_source_code => 'LEDGER_CATEGORY_CODE'
28990 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28991 AND l_bflow_method_code = 'PRIOR_ENTRY'
28992 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28993 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28994 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28995 )
28996 THEN
28997 xla_ae_lines_pkg.BflowUpgEntry
28998 (p_business_method_code => l_bflow_method_code
28999 ,p_business_class_code => l_bflow_class_code
29000 ,p_balance_type => l_balance_type_code);
29001 ELSE
29002 NULL;
29003 -- No business flow processing for business flow method of NONE.
29004 END IF;
29005
29006 --
29007 -- call analytical criteria
29008 --
29009
29010 --
29011 -- call description
29012 --
29013
29014 xla_ae_lines_pkg.SetLineDescription(
29015 p_ae_header_id => l_ae_header_id
29016 ,p_description => Description_1 (
29017 p_application_id => p_application_id
29018 , p_ae_header_id => l_ae_header_id
29019 , p_source_1 => p_source_1
29020 , p_source_2 => p_source_2
29021 , p_source_3 => p_source_3
29022 , p_source_4 => p_source_4
29023 , p_source_5 => p_source_5
29024 )
29025 );
29026
29027
29028 --
29029 -- call ADRs
29030 -- Bug 4922099
29031 --
29032 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29033 (NVL(l_actual_upg_option, 'N') = 'O') OR
29034 (NVL(l_enc_upg_option, 'N') = 'O')
29035 )
29036 THEN
29037 NULL;
29038 --
29039 --
29040
29041 l_ccid := AcctDerRule_6(
29042 p_application_id => p_application_id
29043 , p_ae_header_id => l_ae_header_id
29044 , p_source_11 => p_source_11
29045 , x_transaction_coa_id => l_adr_transaction_coa_id
29046 , x_accounting_coa_id => l_adr_accounting_coa_id
29047 , x_value_type_code => l_adr_value_type_code
29048 , p_side => 'NA'
29049 );
29050
29051 xla_ae_lines_pkg.set_ccid(
29052 p_code_combination_id => l_ccid
29053 , p_value_type_code => l_adr_value_type_code
29054 , p_transaction_coa_id => l_adr_transaction_coa_id
29055 , p_accounting_coa_id => l_adr_accounting_coa_id
29056 , p_adr_code => 'CST_DEFAULT'
29057 , p_adr_type_code => 'S'
29058 , p_component_type => l_component_type
29059 , p_component_code => l_component_code
29060 , p_component_type_code => l_component_type_code
29061 , p_component_appl_id => l_component_appl_id
29062 , p_amb_context_code => l_amb_context_code
29063 , p_side => 'NA'
29064 );
29065
29066
29067 --
29068 --
29069 END IF;
29070 --
29071 -- Bug 4922099
29072 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29073 (NVL(l_enc_upg_option, 'N') = 'O')
29074 ) AND
29075 (l_bflow_method_code = 'PRIOR_ENTRY')
29076 )
29077 THEN
29078 IF
29079 --
29080 1 = 2
29081 --
29082 THEN
29083 xla_accounting_err_pkg.build_message
29084 (p_appli_s_name => 'XLA'
29085 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29086 ,p_token_1 => 'LINE_NUMBER'
29087 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29088 ,p_token_2 => 'LINE_TYPE_NAME'
29089 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29090 l_component_type
29091 ,l_component_code
29092 ,l_component_type_code
29093 ,l_component_appl_id
29094 ,l_amb_context_code
29095 ,l_entity_code
29096 ,l_event_class_code
29097 )
29098 ,p_token_3 => 'OWNER'
29099 ,p_value_3 => xla_lookups_pkg.get_meaning(
29100 p_lookup_type => 'XLA_OWNER_TYPE'
29101 ,p_lookup_code => l_component_type_code
29102 )
29103 ,p_token_4 => 'PRODUCT_NAME'
29104 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29105 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29106 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29107 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29108 ,p_ae_header_id => NULL
29109 );
29110
29111 IF (C_LEVEL_ERROR>= g_log_level) THEN
29112 trace
29113 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29114 ,p_level => C_LEVEL_ERROR
29115 ,p_module => l_log_module);
29116 END IF;
29117 END IF;
29118 END IF;
29119 --
29120 --
29121 ------------------------------------------------------------------------------------------------
29122 -- 4219869 Business Flow
29123 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29124 -- Prior Entry. Currently, the following code is always generated.
29125 ------------------------------------------------------------------------------------------------
29126 XLA_AE_LINES_PKG.ValidateCurrentLine;
29127
29128 ------------------------------------------------------------------------------------
29129 -- 4219869 Business Flow
29130 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29131 ------------------------------------------------------------------------------------
29132 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29133
29134 ----------------------------------------------------------------------------------
29135 -- 4219869 Business Flow
29136 -- Update journal entry status -- Need to generate this within IF <condition>
29137 ----------------------------------------------------------------------------------
29138 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29139 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29140 ,p_balance_type_code => l_balance_type_code
29141 );
29142
29143 -------------------------------------------------------------------------------------------
29144 -- 4262811 - Generate the Accrual Reversal lines
29145 -------------------------------------------------------------------------------------------
29146 BEGIN
29147 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29148 (g_array_event(p_event_id).array_value_num('header_index'));
29149 IF l_acc_rev_flag IS NULL THEN
29150 l_acc_rev_flag := 'N';
29151 END IF;
29152 EXCEPTION
29153 WHEN OTHERS THEN
29154 l_acc_rev_flag := 'N';
29155 END;
29156 --
29157 IF (l_acc_rev_flag = 'Y') THEN
29158
29159 -- 4645092 ------------------------------------------------------------------------------
29160 -- To allow MPA report to determine if it should generate report process
29161 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29162 ------------------------------------------------------------------------------------------
29163
29164 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29165 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29166 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29167 -- call ADRs
29168 -- Bug 4922099
29169 --
29170 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29171 (NVL(l_actual_upg_option, 'N') = 'O') OR
29172 (NVL(l_enc_upg_option, 'N') = 'O')
29173 )
29174 THEN
29175 NULL;
29176 --
29177 --
29178
29179 l_ccid := AcctDerRule_6(
29180 p_application_id => p_application_id
29181 , p_ae_header_id => l_ae_header_id
29182 , p_source_11 => p_source_11
29183 , x_transaction_coa_id => l_adr_transaction_coa_id
29184 , x_accounting_coa_id => l_adr_accounting_coa_id
29185 , x_value_type_code => l_adr_value_type_code
29186 , p_side => 'NA'
29187 );
29188
29189 xla_ae_lines_pkg.set_ccid(
29190 p_code_combination_id => l_ccid
29191 , p_value_type_code => l_adr_value_type_code
29192 , p_transaction_coa_id => l_adr_transaction_coa_id
29193 , p_accounting_coa_id => l_adr_accounting_coa_id
29194 , p_adr_code => 'CST_DEFAULT'
29195 , p_adr_type_code => 'S'
29196 , p_component_type => l_component_type
29197 , p_component_code => l_component_code
29198 , p_component_type_code => l_component_type_code
29199 , p_component_appl_id => l_component_appl_id
29200 , p_amb_context_code => l_amb_context_code
29201 , p_side => 'NA'
29202 );
29203
29204
29205 --
29206 --
29207 END IF;
29208
29209 --
29210 -- Update the line information that should be overwritten
29211 --
29212 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29213 p_header_num => 1);
29214 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29215
29216 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29217
29218 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29219 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29220 END IF;
29221
29222 --
29223 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29224 --
29225 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29226 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29227 ELSE
29228 ---------------------------------------------------------------------------------------------------
29229 -- 4262811a Switch Sign
29230 ---------------------------------------------------------------------------------------------------
29231 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29232 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29233 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29234 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29235 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29236 -- 5132302
29237 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29238 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29239
29240 END IF;
29241
29242 -- 4955764
29243 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29244 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29245
29246
29247 XLA_AE_LINES_PKG.ValidateCurrentLine;
29248 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29249
29250 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29251 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29252 ,p_balance_type_code => l_balance_type_code);
29253
29254 END IF;
29255
29256 -----------------------------------------------------------------------------------------
29257 -- 4262811 Multiperiod Accounting
29258 -----------------------------------------------------------------------------------------
29259 -- No MPA option is assigned.
29260
29261
29262 END IF;
29263 END IF;
29264 --
29265
29266 --
29267 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29268 trace
29269 (p_msg => 'END of AcctLineType_77'
29270 ,p_level => C_LEVEL_PROCEDURE
29271 ,p_module => l_log_module);
29272 END IF;
29273 --
29274 EXCEPTION
29275 WHEN xla_exceptions_pkg.application_exception THEN
29276 RAISE;
29277 WHEN OTHERS THEN
29278 xla_exceptions_pkg.raise_message
29279 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_77');
29280 END AcctLineType_77;
29281 --
29282
29283 ---------------------------------------
29284 --
29285 -- PRIVATE FUNCTION
29286 -- AcctLineType_78
29287 --
29288 ---------------------------------------
29289 PROCEDURE AcctLineType_78 (
29290 p_application_id IN NUMBER
29291 ,p_event_id IN NUMBER
29292 ,p_calculate_acctd_flag IN VARCHAR2
29293 ,p_calculate_g_l_flag IN VARCHAR2
29294 ,p_actual_flag IN OUT VARCHAR2
29295 ,p_balance_type_code OUT VARCHAR2
29296 ,p_gain_or_loss_ref OUT VARCHAR2
29297
29298 --TRANSACTION_ID
29299 , p_source_1 IN NUMBER
29300 --Item Concatenated Segments
29301 , p_source_2 IN VARCHAR2
29302 --Transaction Quantity
29303 , p_source_3 IN NUMBER
29304 --Transaction Unit of Measure Code
29305 , p_source_4 IN VARCHAR2
29306 --Inventory Transaction Type Description
29307 , p_source_5 IN VARCHAR2
29308 --Cost Management Default Account
29309 , p_source_11 IN NUMBER
29310 --Applied to Application ID
29311 , p_source_79 IN NUMBER
29312 --Applied to Distribution Link Type
29313 , p_source_80 IN VARCHAR2
29314 --Applied to Entity Code
29315 , p_source_81 IN VARCHAR2
29316 --DISTRIBUTION_IDENTIFIER
29317 , p_source_84 IN NUMBER
29318 --Distribution Type
29319 , p_source_85 IN VARCHAR2
29320 , p_source_85_meaning IN VARCHAR2
29321 --Encumbrance Reversal Amount Entered
29322 , p_source_87 IN NUMBER
29323 --Entered Currency Code
29324 , p_source_88 IN VARCHAR2
29325 --Transaction Encumbrance Reversal Amount
29326 , p_source_89 IN NUMBER
29327 --Entered Amount
29328 , p_source_91 IN NUMBER
29329 --Currency Conversion Date
29330 , p_source_92 IN DATE
29331 --Currency Conversion Rate
29332 , p_source_93 IN NUMBER
29333 --Currency Conversion Type
29334 , p_source_94 IN VARCHAR2
29335 --Accounted Amount
29336 , p_source_95 IN NUMBER
29337 --Accounting Line Type
29338 , p_source_97 IN NUMBER
29339 --Costing Encumbrance Upgrade Option
29340 , p_source_100 IN VARCHAR2
29341 --TXN_PO_DISTRIBUTION_ID
29342 , p_source_101 IN NUMBER
29343 --TXN_PO_HEADER_ID
29344 , p_source_102 IN NUMBER
29345 --Requisition Budget Account
29346 , p_source_103 IN NUMBER
29347 --Requisition Encumbrance Type Identifier
29348 , p_source_104 IN NUMBER
29349 )
29350 IS
29351
29352 l_component_type VARCHAR2(80);
29353 l_component_code VARCHAR2(30);
29354 l_component_type_code VARCHAR2(1);
29355 l_component_appl_id INTEGER;
29356 l_amb_context_code VARCHAR2(30);
29357 l_entity_code VARCHAR2(30);
29358 l_event_class_code VARCHAR2(30);
29359 l_ae_header_id NUMBER;
29360 l_event_type_code VARCHAR2(30);
29361 l_line_definition_code VARCHAR2(30);
29362 l_line_definition_owner_code VARCHAR2(1);
29363 --
29364 -- adr variables
29365 l_segment VARCHAR2(30);
29366 l_ccid NUMBER;
29367 l_adr_transaction_coa_id NUMBER;
29368 l_adr_accounting_coa_id NUMBER;
29369 l_adr_flexfield_segment_code VARCHAR2(30);
29370 l_adr_flex_value_set_id NUMBER;
29371 l_adr_value_type_code VARCHAR2(30);
29372 l_adr_value_combination_id NUMBER;
29373 l_adr_value_segment_code VARCHAR2(30);
29374
29375 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29376 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29377 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29378 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29379
29380 -- 4262811 Variables ------------------------------------------------------------------------------------------
29381 l_entered_amt_idx NUMBER;
29382 l_accted_amt_idx NUMBER;
29383 l_acc_rev_flag VARCHAR2(1);
29384 l_accrual_line_num NUMBER;
29385 l_tmp_amt NUMBER;
29386 l_acc_rev_natural_side_code VARCHAR2(1);
29387
29388 l_num_entries NUMBER;
29389 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29390 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29391 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29392 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29393 l_recog_line_1 NUMBER;
29394 l_recog_line_2 NUMBER;
29395
29396 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29397 l_bflow_applied_to_amt NUMBER; -- 5132302
29398 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29399
29400 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29401
29402 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29403 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29404
29405 ---------------------------------------------------------------------------------------------------------------
29406
29407
29408 --
29409 -- bulk performance
29410 --
29411 l_balance_type_code VARCHAR2(1);
29412 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29413 l_log_module VARCHAR2(240);
29414
29415 --
29416 -- Upgrade strategy
29417 --
29418 l_actual_upg_option VARCHAR2(1);
29419 l_enc_upg_option VARCHAR2(1);
29420
29421 --
29422 BEGIN
29423 --
29424 IF g_log_enabled THEN
29425 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_78';
29426 END IF;
29427 --
29428 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29429
29430 trace
29431 (p_msg => 'BEGIN of AcctLineType_78'
29432 ,p_level => C_LEVEL_PROCEDURE
29433 ,p_module => l_log_module);
29434
29435 END IF;
29436 --
29437 l_component_type := 'AMB_JLT';
29438 l_component_code := 'COST_VARIANCE';
29439 l_component_type_code := 'S';
29440 l_component_appl_id := 707;
29441 l_amb_context_code := 'DEFAULT';
29442 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
29443 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
29444 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
29445 l_line_definition_owner_code := 'S';
29446 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
29447 --
29448 l_balance_type_code := 'A';
29449 l_segment := NULL;
29450 l_ccid := NULL;
29451 l_adr_transaction_coa_id := NULL;
29452 l_adr_accounting_coa_id := NULL;
29453 l_adr_flexfield_segment_code := NULL;
29454 l_adr_flex_value_set_id := NULL;
29455 l_adr_value_type_code := NULL;
29456 l_adr_value_combination_id := NULL;
29457 l_adr_value_segment_code := NULL;
29458
29459 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29460 l_bflow_class_code := ''; -- 4219869 Business Flow
29461 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29462 l_budgetary_control_flag := 'N';
29463
29464 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29465 l_bflow_applied_to_amt := NULL; -- 5132302
29466 l_entered_amt_idx := NULL; -- 4262811
29467 l_accted_amt_idx := NULL; -- 4262811
29468 l_acc_rev_flag := NULL; -- 4262811
29469 l_accrual_line_num := NULL; -- 4262811
29470 l_tmp_amt := NULL; -- 4262811
29471 --
29472
29473 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29474 l_balance_type_code <> 'B' THEN
29475 IF NVL(p_source_97,9E125) = 13
29476 THEN
29477
29478 --
29479 XLA_AE_LINES_PKG.SetNewLine;
29480
29481 p_balance_type_code := l_balance_type_code;
29482 -- set the flag so later we will know whether the gain loss line needs to be created
29483
29484 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29485 p_actual_flag :='A';
29486 END IF;
29487
29488 --
29489 -- bulk performance
29490 --
29491 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29492 p_header_num => 0); -- 4262811
29493 --
29494 -- set accounting line options
29495 --
29496 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
29497 p_natural_side_code => 'D'
29498 , p_gain_or_loss_flag => 'N'
29499 , p_gl_transfer_mode_code => 'S'
29500 , p_acct_entry_type_code => 'A'
29501 , p_switch_side_flag => 'Y'
29502 , p_merge_duplicate_code => 'N'
29503 );
29504 --
29505 l_acc_rev_natural_side_code := 'C'; -- 4262811
29506 --
29507 --
29508 -- set accounting line type info
29509 --
29510 xla_ae_lines_pkg.SetAcctLineType
29511 (p_component_type => l_component_type
29512 ,p_event_type_code => l_event_type_code
29513 ,p_line_definition_owner_code => l_line_definition_owner_code
29514 ,p_line_definition_code => l_line_definition_code
29515 ,p_accounting_line_code => l_component_code
29516 ,p_accounting_line_type_code => l_component_type_code
29517 ,p_accounting_line_appl_id => l_component_appl_id
29518 ,p_amb_context_code => l_amb_context_code
29519 ,p_entity_code => l_entity_code
29520 ,p_event_class_code => l_event_class_code);
29521 --
29522 -- set accounting class
29523 --
29524 xla_ae_lines_pkg.SetAcctClass(
29525 p_accounting_class_code => 'COST_VARIANCE'
29526 , p_ae_header_id => l_ae_header_id
29527 );
29528
29529 --
29530 -- set rounding class
29531 --
29532 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
29533 'COST_VARIANCE';
29534
29535 --
29536 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
29537 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
29538 --
29539 -- bulk performance
29540 --
29541 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
29542
29543 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
29544 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
29545
29546 -- 4955764
29547 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29548 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
29549
29550 -- 4458381 Public Sector Enh
29551
29552 --
29553 -- set accounting attributes for the line type
29554 --
29555 l_entered_amt_idx := 17;
29556 l_accted_amt_idx := 22;
29557 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29558 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
29559 l_rec_acct_attrs.array_num_value(1) := p_source_79;
29560 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
29561 l_rec_acct_attrs.array_char_value(2) := p_source_80;
29562 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
29563 l_rec_acct_attrs.array_char_value(3) := p_source_81;
29564 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
29565 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
29566 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
29567 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
29568 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
29569 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
29570 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
29571 l_rec_acct_attrs.array_char_value(7) := p_source_85;
29572 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
29573 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
29574 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
29575 l_rec_acct_attrs.array_num_value(9) := p_source_87;
29576 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
29577 l_rec_acct_attrs.array_char_value(10) := p_source_88;
29578 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
29579 l_rec_acct_attrs.array_num_value(11) := p_source_89;
29580 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
29581 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
29582 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
29583 l_rec_acct_attrs.array_num_value(13) := p_source_87;
29584 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
29585 l_rec_acct_attrs.array_char_value(14) := p_source_88;
29586 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
29587 l_rec_acct_attrs.array_num_value(15) := p_source_89;
29588 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
29589 l_rec_acct_attrs.array_char_value(16) := p_source_100;
29590 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
29591 l_rec_acct_attrs.array_num_value(17) := p_source_91;
29592 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
29593 l_rec_acct_attrs.array_char_value(18) := p_source_88;
29594 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
29595 l_rec_acct_attrs.array_date_value(19) := p_source_92;
29596 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
29597 l_rec_acct_attrs.array_num_value(20) := p_source_93;
29598 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
29599 l_rec_acct_attrs.array_char_value(21) := p_source_94;
29600 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
29601 l_rec_acct_attrs.array_num_value(22) := p_source_95;
29602 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
29603 l_rec_acct_attrs.array_num_value(23) := p_source_104;
29604 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
29605 l_rec_acct_attrs.array_num_value(24) := p_source_104;
29606
29607 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
29608 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
29609
29610 ---------------------------------------------------------------------------------------------------------------
29611 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
29612 ---------------------------------------------------------------------------------------------------------------
29613 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
29614
29615 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29616 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29617
29618 IF xla_accounting_cache_pkg.GetValueChar
29619 (p_source_code => 'LEDGER_CATEGORY_CODE'
29620 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
29621 AND l_bflow_method_code = 'PRIOR_ENTRY'
29622 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
29623 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
29624 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
29625 )
29626 THEN
29627 xla_ae_lines_pkg.BflowUpgEntry
29628 (p_business_method_code => l_bflow_method_code
29629 ,p_business_class_code => l_bflow_class_code
29630 ,p_balance_type => l_balance_type_code);
29631 ELSE
29632 NULL;
29633 -- No business flow processing for business flow method of NONE.
29634 END IF;
29635
29636 --
29637 -- call analytical criteria
29638 --
29639
29640 --
29641 -- call description
29642 --
29643
29644 xla_ae_lines_pkg.SetLineDescription(
29645 p_ae_header_id => l_ae_header_id
29646 ,p_description => Description_1 (
29647 p_application_id => p_application_id
29648 , p_ae_header_id => l_ae_header_id
29649 , p_source_1 => p_source_1
29650 , p_source_2 => p_source_2
29651 , p_source_3 => p_source_3
29652 , p_source_4 => p_source_4
29653 , p_source_5 => p_source_5
29654 )
29655 );
29656
29657
29658 --
29659 -- call ADRs
29660 -- Bug 4922099
29661 --
29662 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29663 (NVL(l_actual_upg_option, 'N') = 'O') OR
29664 (NVL(l_enc_upg_option, 'N') = 'O')
29665 )
29666 THEN
29667 NULL;
29668 --
29669 --
29670
29671 l_ccid := AcctDerRule_6(
29672 p_application_id => p_application_id
29673 , p_ae_header_id => l_ae_header_id
29674 , p_source_11 => p_source_11
29675 , x_transaction_coa_id => l_adr_transaction_coa_id
29676 , x_accounting_coa_id => l_adr_accounting_coa_id
29677 , x_value_type_code => l_adr_value_type_code
29678 , p_side => 'NA'
29679 );
29680
29681 xla_ae_lines_pkg.set_ccid(
29682 p_code_combination_id => l_ccid
29683 , p_value_type_code => l_adr_value_type_code
29684 , p_transaction_coa_id => l_adr_transaction_coa_id
29685 , p_accounting_coa_id => l_adr_accounting_coa_id
29686 , p_adr_code => 'CST_DEFAULT'
29687 , p_adr_type_code => 'S'
29688 , p_component_type => l_component_type
29689 , p_component_code => l_component_code
29690 , p_component_type_code => l_component_type_code
29691 , p_component_appl_id => l_component_appl_id
29692 , p_amb_context_code => l_amb_context_code
29693 , p_side => 'NA'
29694 );
29695
29696
29697 --
29698 --
29699 END IF;
29700 --
29701 -- Bug 4922099
29702 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29703 (NVL(l_enc_upg_option, 'N') = 'O')
29704 ) AND
29705 (l_bflow_method_code = 'PRIOR_ENTRY')
29706 )
29707 THEN
29708 IF
29709 --
29710 1 = 2
29711 --
29712 THEN
29713 xla_accounting_err_pkg.build_message
29714 (p_appli_s_name => 'XLA'
29715 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29716 ,p_token_1 => 'LINE_NUMBER'
29717 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29718 ,p_token_2 => 'LINE_TYPE_NAME'
29719 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29720 l_component_type
29721 ,l_component_code
29722 ,l_component_type_code
29723 ,l_component_appl_id
29724 ,l_amb_context_code
29725 ,l_entity_code
29726 ,l_event_class_code
29727 )
29728 ,p_token_3 => 'OWNER'
29729 ,p_value_3 => xla_lookups_pkg.get_meaning(
29730 p_lookup_type => 'XLA_OWNER_TYPE'
29731 ,p_lookup_code => l_component_type_code
29732 )
29733 ,p_token_4 => 'PRODUCT_NAME'
29734 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29735 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29736 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29737 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29738 ,p_ae_header_id => NULL
29739 );
29740
29741 IF (C_LEVEL_ERROR>= g_log_level) THEN
29742 trace
29743 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29744 ,p_level => C_LEVEL_ERROR
29745 ,p_module => l_log_module);
29746 END IF;
29747 END IF;
29748 END IF;
29749 --
29750 --
29751 ------------------------------------------------------------------------------------------------
29752 -- 4219869 Business Flow
29753 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29754 -- Prior Entry. Currently, the following code is always generated.
29755 ------------------------------------------------------------------------------------------------
29756 XLA_AE_LINES_PKG.ValidateCurrentLine;
29757
29758 ------------------------------------------------------------------------------------
29759 -- 4219869 Business Flow
29760 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29761 ------------------------------------------------------------------------------------
29762 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29763
29764 ----------------------------------------------------------------------------------
29765 -- 4219869 Business Flow
29766 -- Update journal entry status -- Need to generate this within IF <condition>
29767 ----------------------------------------------------------------------------------
29768 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29769 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29770 ,p_balance_type_code => l_balance_type_code
29771 );
29772
29773 -------------------------------------------------------------------------------------------
29774 -- 4262811 - Generate the Accrual Reversal lines
29775 -------------------------------------------------------------------------------------------
29776 BEGIN
29777 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29778 (g_array_event(p_event_id).array_value_num('header_index'));
29779 IF l_acc_rev_flag IS NULL THEN
29780 l_acc_rev_flag := 'N';
29781 END IF;
29782 EXCEPTION
29783 WHEN OTHERS THEN
29784 l_acc_rev_flag := 'N';
29785 END;
29786 --
29787 IF (l_acc_rev_flag = 'Y') THEN
29788
29789 -- 4645092 ------------------------------------------------------------------------------
29790 -- To allow MPA report to determine if it should generate report process
29791 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29792 ------------------------------------------------------------------------------------------
29793
29794 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29795 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29796 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29797 -- call ADRs
29798 -- Bug 4922099
29799 --
29800 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29801 (NVL(l_actual_upg_option, 'N') = 'O') OR
29802 (NVL(l_enc_upg_option, 'N') = 'O')
29803 )
29804 THEN
29805 NULL;
29806 --
29807 --
29808
29809 l_ccid := AcctDerRule_6(
29810 p_application_id => p_application_id
29811 , p_ae_header_id => l_ae_header_id
29812 , p_source_11 => p_source_11
29813 , x_transaction_coa_id => l_adr_transaction_coa_id
29814 , x_accounting_coa_id => l_adr_accounting_coa_id
29815 , x_value_type_code => l_adr_value_type_code
29816 , p_side => 'NA'
29817 );
29818
29819 xla_ae_lines_pkg.set_ccid(
29820 p_code_combination_id => l_ccid
29821 , p_value_type_code => l_adr_value_type_code
29822 , p_transaction_coa_id => l_adr_transaction_coa_id
29823 , p_accounting_coa_id => l_adr_accounting_coa_id
29824 , p_adr_code => 'CST_DEFAULT'
29825 , p_adr_type_code => 'S'
29826 , p_component_type => l_component_type
29827 , p_component_code => l_component_code
29828 , p_component_type_code => l_component_type_code
29829 , p_component_appl_id => l_component_appl_id
29830 , p_amb_context_code => l_amb_context_code
29831 , p_side => 'NA'
29832 );
29833
29834
29835 --
29836 --
29837 END IF;
29838
29839 --
29840 -- Update the line information that should be overwritten
29841 --
29842 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29843 p_header_num => 1);
29844 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29845
29846 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29847
29848 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29849 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29850 END IF;
29851
29852 --
29853 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29854 --
29855 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29856 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29857 ELSE
29858 ---------------------------------------------------------------------------------------------------
29859 -- 4262811a Switch Sign
29860 ---------------------------------------------------------------------------------------------------
29861 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29862 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29863 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29864 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29865 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29866 -- 5132302
29867 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29868 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29869
29870 END IF;
29871
29872 -- 4955764
29873 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29874 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29875
29876
29877 XLA_AE_LINES_PKG.ValidateCurrentLine;
29878 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29879
29880 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29881 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29882 ,p_balance_type_code => l_balance_type_code);
29883
29884 END IF;
29885
29886 -----------------------------------------------------------------------------------------
29887 -- 4262811 Multiperiod Accounting
29888 -----------------------------------------------------------------------------------------
29889 -- No MPA option is assigned.
29890
29891
29892 END IF;
29893 END IF;
29894 --
29895
29896 --
29897 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29898 trace
29899 (p_msg => 'END of AcctLineType_78'
29900 ,p_level => C_LEVEL_PROCEDURE
29901 ,p_module => l_log_module);
29902 END IF;
29903 --
29904 EXCEPTION
29905 WHEN xla_exceptions_pkg.application_exception THEN
29906 RAISE;
29907 WHEN OTHERS THEN
29908 xla_exceptions_pkg.raise_message
29909 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_78');
29910 END AcctLineType_78;
29911 --
29912
29913 ---------------------------------------
29914 --
29915 -- PRIVATE FUNCTION
29916 -- AcctLineType_79
29917 --
29918 ---------------------------------------
29919 PROCEDURE AcctLineType_79 (
29920 p_application_id IN NUMBER
29921 ,p_event_id IN NUMBER
29922 ,p_calculate_acctd_flag IN VARCHAR2
29923 ,p_calculate_g_l_flag IN VARCHAR2
29924 ,p_actual_flag IN OUT VARCHAR2
29925 ,p_balance_type_code OUT VARCHAR2
29926 ,p_gain_or_loss_ref OUT VARCHAR2
29927
29928 --Cost Management Default Account
29929 , p_source_11 IN NUMBER
29930 --DISTRIBUTION_IDENTIFIER
29931 , p_source_84 IN NUMBER
29932 --Distribution Type
29933 , p_source_85 IN VARCHAR2
29934 , p_source_85_meaning IN VARCHAR2
29935 --Entered Currency Code
29936 , p_source_88 IN VARCHAR2
29937 --Entered Amount
29938 , p_source_91 IN NUMBER
29939 --Currency Conversion Date
29940 , p_source_92 IN DATE
29941 --Currency Conversion Rate
29942 , p_source_93 IN NUMBER
29943 --Currency Conversion Type
29944 , p_source_94 IN VARCHAR2
29945 --Accounted Amount
29946 , p_source_95 IN NUMBER
29947 --Accounting Line Type
29948 , p_source_97 IN NUMBER
29949 )
29950 IS
29951
29952 l_component_type VARCHAR2(80);
29953 l_component_code VARCHAR2(30);
29954 l_component_type_code VARCHAR2(1);
29955 l_component_appl_id INTEGER;
29956 l_amb_context_code VARCHAR2(30);
29957 l_entity_code VARCHAR2(30);
29958 l_event_class_code VARCHAR2(30);
29959 l_ae_header_id NUMBER;
29960 l_event_type_code VARCHAR2(30);
29961 l_line_definition_code VARCHAR2(30);
29962 l_line_definition_owner_code VARCHAR2(1);
29963 --
29964 -- adr variables
29965 l_segment VARCHAR2(30);
29966 l_ccid NUMBER;
29967 l_adr_transaction_coa_id NUMBER;
29968 l_adr_accounting_coa_id NUMBER;
29969 l_adr_flexfield_segment_code VARCHAR2(30);
29970 l_adr_flex_value_set_id NUMBER;
29971 l_adr_value_type_code VARCHAR2(30);
29972 l_adr_value_combination_id NUMBER;
29973 l_adr_value_segment_code VARCHAR2(30);
29974
29975 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29976 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29977 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29978 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29979
29980 -- 4262811 Variables ------------------------------------------------------------------------------------------
29981 l_entered_amt_idx NUMBER;
29982 l_accted_amt_idx NUMBER;
29983 l_acc_rev_flag VARCHAR2(1);
29984 l_accrual_line_num NUMBER;
29985 l_tmp_amt NUMBER;
29986 l_acc_rev_natural_side_code VARCHAR2(1);
29987
29988 l_num_entries NUMBER;
29989 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29990 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29991 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29992 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29993 l_recog_line_1 NUMBER;
29994 l_recog_line_2 NUMBER;
29995
29996 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29997 l_bflow_applied_to_amt NUMBER; -- 5132302
29998 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29999
30000 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30001
30002 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30003 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30004
30005 ---------------------------------------------------------------------------------------------------------------
30006
30007
30008 --
30009 -- bulk performance
30010 --
30011 l_balance_type_code VARCHAR2(1);
30012 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30013 l_log_module VARCHAR2(240);
30014
30015 --
30016 -- Upgrade strategy
30017 --
30018 l_actual_upg_option VARCHAR2(1);
30019 l_enc_upg_option VARCHAR2(1);
30020
30021 --
30022 BEGIN
30023 --
30024 IF g_log_enabled THEN
30025 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_79';
30026 END IF;
30027 --
30028 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30029
30030 trace
30031 (p_msg => 'BEGIN of AcctLineType_79'
30032 ,p_level => C_LEVEL_PROCEDURE
30033 ,p_module => l_log_module);
30034
30035 END IF;
30036 --
30037 l_component_type := 'AMB_JLT';
30038 l_component_code := 'COST_VARIANCE';
30039 l_component_type_code := 'S';
30040 l_component_appl_id := 707;
30041 l_amb_context_code := 'DEFAULT';
30042 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
30043 l_event_class_code := 'SALES_ORDER';
30044 l_event_type_code := 'COGS_RECOGNITION_ADJ';
30045 l_line_definition_owner_code := 'S';
30046 l_line_definition_code := 'PI_COGS_RECOGNITION_ADJ';
30047 --
30048 l_balance_type_code := 'A';
30049 l_segment := NULL;
30050 l_ccid := NULL;
30051 l_adr_transaction_coa_id := NULL;
30052 l_adr_accounting_coa_id := NULL;
30053 l_adr_flexfield_segment_code := NULL;
30054 l_adr_flex_value_set_id := NULL;
30055 l_adr_value_type_code := NULL;
30056 l_adr_value_combination_id := NULL;
30057 l_adr_value_segment_code := NULL;
30058
30059 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30060 l_bflow_class_code := ''; -- 4219869 Business Flow
30061 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30062 l_budgetary_control_flag := 'N';
30063
30064 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30065 l_bflow_applied_to_amt := NULL; -- 5132302
30066 l_entered_amt_idx := NULL; -- 4262811
30067 l_accted_amt_idx := NULL; -- 4262811
30068 l_acc_rev_flag := NULL; -- 4262811
30069 l_accrual_line_num := NULL; -- 4262811
30070 l_tmp_amt := NULL; -- 4262811
30071 --
30072
30073 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30074 l_balance_type_code <> 'B' THEN
30075 IF NVL(p_source_97,9E125) = 13
30076 THEN
30077
30078 --
30079 XLA_AE_LINES_PKG.SetNewLine;
30080
30081 p_balance_type_code := l_balance_type_code;
30082 -- set the flag so later we will know whether the gain loss line needs to be created
30083
30084 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30085 p_actual_flag :='A';
30086 END IF;
30087
30088 --
30089 -- bulk performance
30090 --
30091 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30092 p_header_num => 0); -- 4262811
30093 --
30094 -- set accounting line options
30095 --
30096 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30097 p_natural_side_code => 'D'
30098 , p_gain_or_loss_flag => 'N'
30099 , p_gl_transfer_mode_code => 'S'
30100 , p_acct_entry_type_code => 'A'
30101 , p_switch_side_flag => 'Y'
30102 , p_merge_duplicate_code => 'N'
30103 );
30104 --
30105 l_acc_rev_natural_side_code := 'C'; -- 4262811
30106 --
30107 --
30108 -- set accounting line type info
30109 --
30110 xla_ae_lines_pkg.SetAcctLineType
30111 (p_component_type => l_component_type
30112 ,p_event_type_code => l_event_type_code
30113 ,p_line_definition_owner_code => l_line_definition_owner_code
30114 ,p_line_definition_code => l_line_definition_code
30115 ,p_accounting_line_code => l_component_code
30116 ,p_accounting_line_type_code => l_component_type_code
30117 ,p_accounting_line_appl_id => l_component_appl_id
30118 ,p_amb_context_code => l_amb_context_code
30119 ,p_entity_code => l_entity_code
30120 ,p_event_class_code => l_event_class_code);
30121 --
30122 -- set accounting class
30123 --
30124 xla_ae_lines_pkg.SetAcctClass(
30125 p_accounting_class_code => 'COST_VARIANCE'
30126 , p_ae_header_id => l_ae_header_id
30127 );
30128
30129 --
30130 -- set rounding class
30131 --
30132 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30133 'COST_VARIANCE';
30134
30135 --
30136 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30137 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30138 --
30139 -- bulk performance
30140 --
30141 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30142
30143 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30144 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30145
30146 -- 4955764
30147 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30148 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30149
30150 -- 4458381 Public Sector Enh
30151
30152 --
30153 -- set accounting attributes for the line type
30154 --
30155 l_entered_amt_idx := 3;
30156 l_accted_amt_idx := 8;
30157 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30158 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
30159 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
30160 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
30161 l_rec_acct_attrs.array_char_value(2) := p_source_85;
30162 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
30163 l_rec_acct_attrs.array_num_value(3) := p_source_91;
30164 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
30165 l_rec_acct_attrs.array_char_value(4) := p_source_88;
30166 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
30167 l_rec_acct_attrs.array_date_value(5) := p_source_92;
30168 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
30169 l_rec_acct_attrs.array_num_value(6) := p_source_93;
30170 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
30171 l_rec_acct_attrs.array_char_value(7) := p_source_94;
30172 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
30173 l_rec_acct_attrs.array_num_value(8) := p_source_95;
30174
30175 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30176 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30177
30178 ---------------------------------------------------------------------------------------------------------------
30179 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30180 ---------------------------------------------------------------------------------------------------------------
30181 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30182
30183 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30184 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30185
30186 IF xla_accounting_cache_pkg.GetValueChar
30187 (p_source_code => 'LEDGER_CATEGORY_CODE'
30188 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30189 AND l_bflow_method_code = 'PRIOR_ENTRY'
30190 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30191 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30192 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30193 )
30194 THEN
30195 xla_ae_lines_pkg.BflowUpgEntry
30196 (p_business_method_code => l_bflow_method_code
30197 ,p_business_class_code => l_bflow_class_code
30198 ,p_balance_type => l_balance_type_code);
30199 ELSE
30200 NULL;
30201 -- No business flow processing for business flow method of NONE.
30202 END IF;
30203
30204 --
30205 -- call analytical criteria
30206 --
30207
30208 --
30209 -- call description
30210 --
30211 -- No description or it is inherited.
30212 --
30213 -- call ADRs
30214 -- Bug 4922099
30215 --
30216 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30217 (NVL(l_actual_upg_option, 'N') = 'O') OR
30218 (NVL(l_enc_upg_option, 'N') = 'O')
30219 )
30220 THEN
30221 NULL;
30222 --
30223 --
30224
30225 l_ccid := AcctDerRule_6(
30226 p_application_id => p_application_id
30227 , p_ae_header_id => l_ae_header_id
30228 , p_source_11 => p_source_11
30229 , x_transaction_coa_id => l_adr_transaction_coa_id
30230 , x_accounting_coa_id => l_adr_accounting_coa_id
30231 , x_value_type_code => l_adr_value_type_code
30232 , p_side => 'NA'
30233 );
30234
30235 xla_ae_lines_pkg.set_ccid(
30236 p_code_combination_id => l_ccid
30237 , p_value_type_code => l_adr_value_type_code
30238 , p_transaction_coa_id => l_adr_transaction_coa_id
30239 , p_accounting_coa_id => l_adr_accounting_coa_id
30240 , p_adr_code => 'CST_DEFAULT'
30241 , p_adr_type_code => 'S'
30242 , p_component_type => l_component_type
30243 , p_component_code => l_component_code
30244 , p_component_type_code => l_component_type_code
30245 , p_component_appl_id => l_component_appl_id
30246 , p_amb_context_code => l_amb_context_code
30247 , p_side => 'NA'
30248 );
30249
30250
30251 --
30252 --
30253 END IF;
30254 --
30255 -- Bug 4922099
30256 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30257 (NVL(l_enc_upg_option, 'N') = 'O')
30258 ) AND
30259 (l_bflow_method_code = 'PRIOR_ENTRY')
30260 )
30261 THEN
30262 IF
30263 --
30264 1 = 2
30265 --
30266 THEN
30267 xla_accounting_err_pkg.build_message
30268 (p_appli_s_name => 'XLA'
30269 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30270 ,p_token_1 => 'LINE_NUMBER'
30271 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30272 ,p_token_2 => 'LINE_TYPE_NAME'
30273 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30274 l_component_type
30275 ,l_component_code
30276 ,l_component_type_code
30277 ,l_component_appl_id
30278 ,l_amb_context_code
30279 ,l_entity_code
30280 ,l_event_class_code
30281 )
30282 ,p_token_3 => 'OWNER'
30283 ,p_value_3 => xla_lookups_pkg.get_meaning(
30284 p_lookup_type => 'XLA_OWNER_TYPE'
30285 ,p_lookup_code => l_component_type_code
30286 )
30287 ,p_token_4 => 'PRODUCT_NAME'
30288 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30289 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30290 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30291 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30292 ,p_ae_header_id => NULL
30293 );
30294
30295 IF (C_LEVEL_ERROR>= g_log_level) THEN
30296 trace
30297 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30298 ,p_level => C_LEVEL_ERROR
30299 ,p_module => l_log_module);
30300 END IF;
30301 END IF;
30302 END IF;
30303 --
30304 --
30305 ------------------------------------------------------------------------------------------------
30306 -- 4219869 Business Flow
30307 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30308 -- Prior Entry. Currently, the following code is always generated.
30309 ------------------------------------------------------------------------------------------------
30310 XLA_AE_LINES_PKG.ValidateCurrentLine;
30311
30312 ------------------------------------------------------------------------------------
30313 -- 4219869 Business Flow
30314 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30315 ------------------------------------------------------------------------------------
30316 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30317
30318 ----------------------------------------------------------------------------------
30319 -- 4219869 Business Flow
30320 -- Update journal entry status -- Need to generate this within IF <condition>
30321 ----------------------------------------------------------------------------------
30322 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30323 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30324 ,p_balance_type_code => l_balance_type_code
30325 );
30326
30327 -------------------------------------------------------------------------------------------
30328 -- 4262811 - Generate the Accrual Reversal lines
30329 -------------------------------------------------------------------------------------------
30330 BEGIN
30331 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30332 (g_array_event(p_event_id).array_value_num('header_index'));
30333 IF l_acc_rev_flag IS NULL THEN
30334 l_acc_rev_flag := 'N';
30335 END IF;
30336 EXCEPTION
30337 WHEN OTHERS THEN
30338 l_acc_rev_flag := 'N';
30339 END;
30340 --
30341 IF (l_acc_rev_flag = 'Y') THEN
30342
30343 -- 4645092 ------------------------------------------------------------------------------
30344 -- To allow MPA report to determine if it should generate report process
30345 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30346 ------------------------------------------------------------------------------------------
30347
30348 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30349 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30350 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30351 -- call ADRs
30352 -- Bug 4922099
30353 --
30354 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30355 (NVL(l_actual_upg_option, 'N') = 'O') OR
30356 (NVL(l_enc_upg_option, 'N') = 'O')
30357 )
30358 THEN
30359 NULL;
30360 --
30361 --
30362
30363 l_ccid := AcctDerRule_6(
30364 p_application_id => p_application_id
30365 , p_ae_header_id => l_ae_header_id
30366 , p_source_11 => p_source_11
30367 , x_transaction_coa_id => l_adr_transaction_coa_id
30368 , x_accounting_coa_id => l_adr_accounting_coa_id
30369 , x_value_type_code => l_adr_value_type_code
30370 , p_side => 'NA'
30371 );
30372
30373 xla_ae_lines_pkg.set_ccid(
30374 p_code_combination_id => l_ccid
30375 , p_value_type_code => l_adr_value_type_code
30376 , p_transaction_coa_id => l_adr_transaction_coa_id
30377 , p_accounting_coa_id => l_adr_accounting_coa_id
30378 , p_adr_code => 'CST_DEFAULT'
30379 , p_adr_type_code => 'S'
30380 , p_component_type => l_component_type
30381 , p_component_code => l_component_code
30382 , p_component_type_code => l_component_type_code
30383 , p_component_appl_id => l_component_appl_id
30384 , p_amb_context_code => l_amb_context_code
30385 , p_side => 'NA'
30386 );
30387
30388
30389 --
30390 --
30391 END IF;
30392
30393 --
30394 -- Update the line information that should be overwritten
30395 --
30396 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30397 p_header_num => 1);
30398 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30399
30400 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30401
30402 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30403 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30404 END IF;
30405
30406 --
30407 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30408 --
30409 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30410 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30411 ELSE
30412 ---------------------------------------------------------------------------------------------------
30413 -- 4262811a Switch Sign
30414 ---------------------------------------------------------------------------------------------------
30415 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30416 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30417 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30418 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30419 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30420 -- 5132302
30421 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
30422 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30423
30424 END IF;
30425
30426 -- 4955764
30427 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30428 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
30429
30430
30431 XLA_AE_LINES_PKG.ValidateCurrentLine;
30432 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30433
30434 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30435 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
30436 ,p_balance_type_code => l_balance_type_code);
30437
30438 END IF;
30439
30440 -----------------------------------------------------------------------------------------
30441 -- 4262811 Multiperiod Accounting
30442 -----------------------------------------------------------------------------------------
30443 -- No MPA option is assigned.
30444
30445
30446 END IF;
30447 END IF;
30448 --
30449
30450 --
30451 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30452 trace
30453 (p_msg => 'END of AcctLineType_79'
30454 ,p_level => C_LEVEL_PROCEDURE
30455 ,p_module => l_log_module);
30456 END IF;
30457 --
30458 EXCEPTION
30459 WHEN xla_exceptions_pkg.application_exception THEN
30460 RAISE;
30461 WHEN OTHERS THEN
30462 xla_exceptions_pkg.raise_message
30463 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_79');
30464 END AcctLineType_79;
30465 --
30466
30467 ---------------------------------------
30468 --
30469 -- PRIVATE FUNCTION
30470 -- AcctLineType_80
30471 --
30472 ---------------------------------------
30473 PROCEDURE AcctLineType_80 (
30474 p_application_id IN NUMBER
30475 ,p_event_id IN NUMBER
30476 ,p_calculate_acctd_flag IN VARCHAR2
30477 ,p_calculate_g_l_flag IN VARCHAR2
30478 ,p_actual_flag IN OUT VARCHAR2
30479 ,p_balance_type_code OUT VARCHAR2
30480 ,p_gain_or_loss_ref OUT VARCHAR2
30481
30482 --TRANSACTION_ID
30483 , p_source_1 IN NUMBER
30484 --Item Concatenated Segments
30485 , p_source_2 IN VARCHAR2
30486 --Transaction Quantity
30487 , p_source_3 IN NUMBER
30488 --Transaction Unit of Measure Code
30489 , p_source_4 IN VARCHAR2
30490 --Inventory Transaction Type Description
30491 , p_source_5 IN VARCHAR2
30492 --Cost Management Default Account
30493 , p_source_11 IN NUMBER
30494 --DISTRIBUTION_IDENTIFIER
30495 , p_source_84 IN NUMBER
30496 --Distribution Type
30497 , p_source_85 IN VARCHAR2
30498 , p_source_85_meaning IN VARCHAR2
30499 --Entered Currency Code
30500 , p_source_88 IN VARCHAR2
30501 --Entered Amount
30502 , p_source_91 IN NUMBER
30503 --Currency Conversion Date
30504 , p_source_92 IN DATE
30505 --Currency Conversion Rate
30506 , p_source_93 IN NUMBER
30507 --Currency Conversion Type
30508 , p_source_94 IN VARCHAR2
30509 --Accounted Amount
30510 , p_source_95 IN NUMBER
30511 --Accounting Line Type
30512 , p_source_97 IN NUMBER
30513 )
30514 IS
30515
30516 l_component_type VARCHAR2(80);
30517 l_component_code VARCHAR2(30);
30518 l_component_type_code VARCHAR2(1);
30519 l_component_appl_id INTEGER;
30520 l_amb_context_code VARCHAR2(30);
30521 l_entity_code VARCHAR2(30);
30522 l_event_class_code VARCHAR2(30);
30523 l_ae_header_id NUMBER;
30524 l_event_type_code VARCHAR2(30);
30525 l_line_definition_code VARCHAR2(30);
30526 l_line_definition_owner_code VARCHAR2(1);
30527 --
30528 -- adr variables
30529 l_segment VARCHAR2(30);
30530 l_ccid NUMBER;
30531 l_adr_transaction_coa_id NUMBER;
30532 l_adr_accounting_coa_id NUMBER;
30533 l_adr_flexfield_segment_code VARCHAR2(30);
30534 l_adr_flex_value_set_id NUMBER;
30535 l_adr_value_type_code VARCHAR2(30);
30536 l_adr_value_combination_id NUMBER;
30537 l_adr_value_segment_code VARCHAR2(30);
30538
30539 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30540 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30541 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30542 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30543
30544 -- 4262811 Variables ------------------------------------------------------------------------------------------
30545 l_entered_amt_idx NUMBER;
30546 l_accted_amt_idx NUMBER;
30547 l_acc_rev_flag VARCHAR2(1);
30548 l_accrual_line_num NUMBER;
30549 l_tmp_amt NUMBER;
30550 l_acc_rev_natural_side_code VARCHAR2(1);
30551
30552 l_num_entries NUMBER;
30553 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30554 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30555 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30556 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30557 l_recog_line_1 NUMBER;
30558 l_recog_line_2 NUMBER;
30559
30560 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30561 l_bflow_applied_to_amt NUMBER; -- 5132302
30562 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30563
30564 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30565
30566 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30567 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30568
30569 ---------------------------------------------------------------------------------------------------------------
30570
30571
30572 --
30573 -- bulk performance
30574 --
30575 l_balance_type_code VARCHAR2(1);
30576 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30577 l_log_module VARCHAR2(240);
30578
30579 --
30580 -- Upgrade strategy
30581 --
30582 l_actual_upg_option VARCHAR2(1);
30583 l_enc_upg_option VARCHAR2(1);
30584
30585 --
30586 BEGIN
30587 --
30588 IF g_log_enabled THEN
30589 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_80';
30590 END IF;
30591 --
30592 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30593
30594 trace
30595 (p_msg => 'BEGIN of AcctLineType_80'
30596 ,p_level => C_LEVEL_PROCEDURE
30597 ,p_module => l_log_module);
30598
30599 END IF;
30600 --
30601 l_component_type := 'AMB_JLT';
30602 l_component_code := 'COST_VARIANCE';
30603 l_component_type_code := 'S';
30604 l_component_appl_id := 707;
30605 l_amb_context_code := 'DEFAULT';
30606 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
30607 l_event_class_code := 'USER_DEFINE';
30608 l_event_type_code := 'UDIR_INTERORG_RCPT';
30609 l_line_definition_owner_code := 'S';
30610 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
30611 --
30612 l_balance_type_code := 'A';
30613 l_segment := NULL;
30614 l_ccid := NULL;
30615 l_adr_transaction_coa_id := NULL;
30616 l_adr_accounting_coa_id := NULL;
30617 l_adr_flexfield_segment_code := NULL;
30618 l_adr_flex_value_set_id := NULL;
30619 l_adr_value_type_code := NULL;
30620 l_adr_value_combination_id := NULL;
30621 l_adr_value_segment_code := NULL;
30622
30623 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30624 l_bflow_class_code := ''; -- 4219869 Business Flow
30625 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30626 l_budgetary_control_flag := 'N';
30627
30628 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30629 l_bflow_applied_to_amt := NULL; -- 5132302
30630 l_entered_amt_idx := NULL; -- 4262811
30631 l_accted_amt_idx := NULL; -- 4262811
30632 l_acc_rev_flag := NULL; -- 4262811
30633 l_accrual_line_num := NULL; -- 4262811
30634 l_tmp_amt := NULL; -- 4262811
30635 --
30636
30637 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30638 l_balance_type_code <> 'B' THEN
30639 IF NVL(p_source_97,9E125) = 13
30640 THEN
30641
30642 --
30643 XLA_AE_LINES_PKG.SetNewLine;
30644
30645 p_balance_type_code := l_balance_type_code;
30646 -- set the flag so later we will know whether the gain loss line needs to be created
30647
30648 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30649 p_actual_flag :='A';
30650 END IF;
30651
30652 --
30653 -- bulk performance
30654 --
30655 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30656 p_header_num => 0); -- 4262811
30657 --
30658 -- set accounting line options
30659 --
30660 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30661 p_natural_side_code => 'D'
30662 , p_gain_or_loss_flag => 'N'
30663 , p_gl_transfer_mode_code => 'S'
30664 , p_acct_entry_type_code => 'A'
30665 , p_switch_side_flag => 'Y'
30666 , p_merge_duplicate_code => 'N'
30667 );
30668 --
30669 l_acc_rev_natural_side_code := 'C'; -- 4262811
30670 --
30671 --
30672 -- set accounting line type info
30673 --
30674 xla_ae_lines_pkg.SetAcctLineType
30675 (p_component_type => l_component_type
30676 ,p_event_type_code => l_event_type_code
30677 ,p_line_definition_owner_code => l_line_definition_owner_code
30678 ,p_line_definition_code => l_line_definition_code
30679 ,p_accounting_line_code => l_component_code
30680 ,p_accounting_line_type_code => l_component_type_code
30681 ,p_accounting_line_appl_id => l_component_appl_id
30682 ,p_amb_context_code => l_amb_context_code
30683 ,p_entity_code => l_entity_code
30684 ,p_event_class_code => l_event_class_code);
30685 --
30686 -- set accounting class
30687 --
30688 xla_ae_lines_pkg.SetAcctClass(
30689 p_accounting_class_code => 'COST_VARIANCE'
30690 , p_ae_header_id => l_ae_header_id
30691 );
30692
30693 --
30694 -- set rounding class
30695 --
30696 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30697 'COST_VARIANCE';
30698
30699 --
30700 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30701 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30702 --
30703 -- bulk performance
30704 --
30705 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30706
30707 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30708 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30709
30710 -- 4955764
30711 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30712 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30713
30714 -- 4458381 Public Sector Enh
30715
30716 --
30717 -- set accounting attributes for the line type
30718 --
30719 l_entered_amt_idx := 3;
30720 l_accted_amt_idx := 8;
30721 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30722 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
30723 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
30724 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
30725 l_rec_acct_attrs.array_char_value(2) := p_source_85;
30726 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
30727 l_rec_acct_attrs.array_num_value(3) := p_source_91;
30728 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
30729 l_rec_acct_attrs.array_char_value(4) := p_source_88;
30730 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
30731 l_rec_acct_attrs.array_date_value(5) := p_source_92;
30732 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
30733 l_rec_acct_attrs.array_num_value(6) := p_source_93;
30734 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
30735 l_rec_acct_attrs.array_char_value(7) := p_source_94;
30736 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
30737 l_rec_acct_attrs.array_num_value(8) := p_source_95;
30738
30739 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30740 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30741
30742 ---------------------------------------------------------------------------------------------------------------
30743 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30744 ---------------------------------------------------------------------------------------------------------------
30745 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30746
30747 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30748 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30749
30750 IF xla_accounting_cache_pkg.GetValueChar
30751 (p_source_code => 'LEDGER_CATEGORY_CODE'
30752 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30753 AND l_bflow_method_code = 'PRIOR_ENTRY'
30754 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30755 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30756 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30757 )
30758 THEN
30759 xla_ae_lines_pkg.BflowUpgEntry
30760 (p_business_method_code => l_bflow_method_code
30761 ,p_business_class_code => l_bflow_class_code
30762 ,p_balance_type => l_balance_type_code);
30763 ELSE
30764 NULL;
30765 -- No business flow processing for business flow method of NONE.
30766 END IF;
30767
30768 --
30769 -- call analytical criteria
30770 --
30771
30772 --
30773 -- call description
30774 --
30775
30776 xla_ae_lines_pkg.SetLineDescription(
30777 p_ae_header_id => l_ae_header_id
30778 ,p_description => Description_1 (
30779 p_application_id => p_application_id
30780 , p_ae_header_id => l_ae_header_id
30781 , p_source_1 => p_source_1
30782 , p_source_2 => p_source_2
30783 , p_source_3 => p_source_3
30784 , p_source_4 => p_source_4
30785 , p_source_5 => p_source_5
30786 )
30787 );
30788
30789
30790 --
30791 -- call ADRs
30792 -- Bug 4922099
30793 --
30794 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30795 (NVL(l_actual_upg_option, 'N') = 'O') OR
30796 (NVL(l_enc_upg_option, 'N') = 'O')
30797 )
30798 THEN
30799 NULL;
30800 --
30801 --
30802
30803 l_ccid := AcctDerRule_6(
30804 p_application_id => p_application_id
30805 , p_ae_header_id => l_ae_header_id
30806 , p_source_11 => p_source_11
30807 , x_transaction_coa_id => l_adr_transaction_coa_id
30808 , x_accounting_coa_id => l_adr_accounting_coa_id
30809 , x_value_type_code => l_adr_value_type_code
30810 , p_side => 'NA'
30811 );
30812
30813 xla_ae_lines_pkg.set_ccid(
30814 p_code_combination_id => l_ccid
30815 , p_value_type_code => l_adr_value_type_code
30816 , p_transaction_coa_id => l_adr_transaction_coa_id
30817 , p_accounting_coa_id => l_adr_accounting_coa_id
30818 , p_adr_code => 'CST_DEFAULT'
30819 , p_adr_type_code => 'S'
30820 , p_component_type => l_component_type
30821 , p_component_code => l_component_code
30822 , p_component_type_code => l_component_type_code
30823 , p_component_appl_id => l_component_appl_id
30824 , p_amb_context_code => l_amb_context_code
30825 , p_side => 'NA'
30826 );
30827
30828
30829 --
30830 --
30831 END IF;
30832 --
30833 -- Bug 4922099
30834 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30835 (NVL(l_enc_upg_option, 'N') = 'O')
30836 ) AND
30837 (l_bflow_method_code = 'PRIOR_ENTRY')
30838 )
30839 THEN
30840 IF
30841 --
30842 1 = 2
30843 --
30844 THEN
30845 xla_accounting_err_pkg.build_message
30846 (p_appli_s_name => 'XLA'
30847 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30848 ,p_token_1 => 'LINE_NUMBER'
30849 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30850 ,p_token_2 => 'LINE_TYPE_NAME'
30851 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30852 l_component_type
30853 ,l_component_code
30854 ,l_component_type_code
30855 ,l_component_appl_id
30856 ,l_amb_context_code
30857 ,l_entity_code
30858 ,l_event_class_code
30859 )
30860 ,p_token_3 => 'OWNER'
30861 ,p_value_3 => xla_lookups_pkg.get_meaning(
30862 p_lookup_type => 'XLA_OWNER_TYPE'
30863 ,p_lookup_code => l_component_type_code
30864 )
30865 ,p_token_4 => 'PRODUCT_NAME'
30866 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30867 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30868 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30869 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30870 ,p_ae_header_id => NULL
30871 );
30872
30873 IF (C_LEVEL_ERROR>= g_log_level) THEN
30874 trace
30875 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30876 ,p_level => C_LEVEL_ERROR
30877 ,p_module => l_log_module);
30878 END IF;
30879 END IF;
30880 END IF;
30881 --
30882 --
30883 ------------------------------------------------------------------------------------------------
30884 -- 4219869 Business Flow
30885 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30886 -- Prior Entry. Currently, the following code is always generated.
30887 ------------------------------------------------------------------------------------------------
30888 XLA_AE_LINES_PKG.ValidateCurrentLine;
30889
30890 ------------------------------------------------------------------------------------
30891 -- 4219869 Business Flow
30892 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30893 ------------------------------------------------------------------------------------
30894 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30895
30896 ----------------------------------------------------------------------------------
30897 -- 4219869 Business Flow
30898 -- Update journal entry status -- Need to generate this within IF <condition>
30899 ----------------------------------------------------------------------------------
30900 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30901 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30902 ,p_balance_type_code => l_balance_type_code
30903 );
30904
30905 -------------------------------------------------------------------------------------------
30906 -- 4262811 - Generate the Accrual Reversal lines
30907 -------------------------------------------------------------------------------------------
30908 BEGIN
30909 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30910 (g_array_event(p_event_id).array_value_num('header_index'));
30911 IF l_acc_rev_flag IS NULL THEN
30912 l_acc_rev_flag := 'N';
30913 END IF;
30914 EXCEPTION
30915 WHEN OTHERS THEN
30916 l_acc_rev_flag := 'N';
30917 END;
30918 --
30919 IF (l_acc_rev_flag = 'Y') THEN
30920
30921 -- 4645092 ------------------------------------------------------------------------------
30922 -- To allow MPA report to determine if it should generate report process
30923 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30924 ------------------------------------------------------------------------------------------
30925
30926 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30927 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30928 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30929 -- call ADRs
30930 -- Bug 4922099
30931 --
30932 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30933 (NVL(l_actual_upg_option, 'N') = 'O') OR
30934 (NVL(l_enc_upg_option, 'N') = 'O')
30935 )
30936 THEN
30937 NULL;
30938 --
30939 --
30940
30941 l_ccid := AcctDerRule_6(
30942 p_application_id => p_application_id
30943 , p_ae_header_id => l_ae_header_id
30944 , p_source_11 => p_source_11
30945 , x_transaction_coa_id => l_adr_transaction_coa_id
30946 , x_accounting_coa_id => l_adr_accounting_coa_id
30947 , x_value_type_code => l_adr_value_type_code
30948 , p_side => 'NA'
30949 );
30950
30951 xla_ae_lines_pkg.set_ccid(
30952 p_code_combination_id => l_ccid
30953 , p_value_type_code => l_adr_value_type_code
30954 , p_transaction_coa_id => l_adr_transaction_coa_id
30955 , p_accounting_coa_id => l_adr_accounting_coa_id
30956 , p_adr_code => 'CST_DEFAULT'
30957 , p_adr_type_code => 'S'
30958 , p_component_type => l_component_type
30959 , p_component_code => l_component_code
30960 , p_component_type_code => l_component_type_code
30961 , p_component_appl_id => l_component_appl_id
30962 , p_amb_context_code => l_amb_context_code
30963 , p_side => 'NA'
30964 );
30965
30966
30967 --
30968 --
30969 END IF;
30970
30971 --
30972 -- Update the line information that should be overwritten
30973 --
30974 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30975 p_header_num => 1);
30976 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30977
30978 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30979
30980 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30981 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30982 END IF;
30983
30984 --
30985 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30986 --
30987 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30988 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30989 ELSE
30990 ---------------------------------------------------------------------------------------------------
30991 -- 4262811a Switch Sign
30992 ---------------------------------------------------------------------------------------------------
30993 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30994 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30995 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30996 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30997 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30998 -- 5132302
30999 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31000 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31001
31002 END IF;
31003
31004 -- 4955764
31005 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31006 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31007
31008
31009 XLA_AE_LINES_PKG.ValidateCurrentLine;
31010 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31011
31012 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31013 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31014 ,p_balance_type_code => l_balance_type_code);
31015
31016 END IF;
31017
31018 -----------------------------------------------------------------------------------------
31019 -- 4262811 Multiperiod Accounting
31020 -----------------------------------------------------------------------------------------
31021 -- No MPA option is assigned.
31022
31023
31024 END IF;
31025 END IF;
31026 --
31027
31028 --
31029 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31030 trace
31031 (p_msg => 'END of AcctLineType_80'
31032 ,p_level => C_LEVEL_PROCEDURE
31033 ,p_module => l_log_module);
31034 END IF;
31035 --
31036 EXCEPTION
31037 WHEN xla_exceptions_pkg.application_exception THEN
31038 RAISE;
31039 WHEN OTHERS THEN
31040 xla_exceptions_pkg.raise_message
31041 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_80');
31042 END AcctLineType_80;
31043 --
31044
31045 ---------------------------------------
31046 --
31047 -- PRIVATE FUNCTION
31048 -- AcctLineType_81
31049 --
31050 ---------------------------------------
31051 PROCEDURE AcctLineType_81 (
31052 p_application_id IN NUMBER
31053 ,p_event_id IN NUMBER
31054 ,p_calculate_acctd_flag IN VARCHAR2
31055 ,p_calculate_g_l_flag IN VARCHAR2
31056 ,p_actual_flag IN OUT VARCHAR2
31057 ,p_balance_type_code OUT VARCHAR2
31058 ,p_gain_or_loss_ref OUT VARCHAR2
31059
31060 --TRANSACTION_ID
31061 , p_source_1 IN NUMBER
31062 --Item Concatenated Segments
31063 , p_source_2 IN VARCHAR2
31064 --Transaction Quantity
31065 , p_source_3 IN NUMBER
31066 --Transaction Unit of Measure Code
31067 , p_source_4 IN VARCHAR2
31068 --Inventory Transaction Type Description
31069 , p_source_5 IN VARCHAR2
31070 --Cost Management Default Account
31071 , p_source_11 IN NUMBER
31072 --DISTRIBUTION_IDENTIFIER
31073 , p_source_84 IN NUMBER
31074 --Distribution Type
31075 , p_source_85 IN VARCHAR2
31076 , p_source_85_meaning IN VARCHAR2
31077 --Entered Currency Code
31078 , p_source_88 IN VARCHAR2
31079 --Entered Amount
31080 , p_source_91 IN NUMBER
31081 --Currency Conversion Date
31082 , p_source_92 IN DATE
31083 --Currency Conversion Rate
31084 , p_source_93 IN NUMBER
31085 --Currency Conversion Type
31086 , p_source_94 IN VARCHAR2
31087 --Accounted Amount
31088 , p_source_95 IN NUMBER
31089 --Accounting Line Type
31090 , p_source_97 IN NUMBER
31091 )
31092 IS
31093
31094 l_component_type VARCHAR2(80);
31095 l_component_code VARCHAR2(30);
31096 l_component_type_code VARCHAR2(1);
31097 l_component_appl_id INTEGER;
31098 l_amb_context_code VARCHAR2(30);
31099 l_entity_code VARCHAR2(30);
31100 l_event_class_code VARCHAR2(30);
31101 l_ae_header_id NUMBER;
31102 l_event_type_code VARCHAR2(30);
31103 l_line_definition_code VARCHAR2(30);
31104 l_line_definition_owner_code VARCHAR2(1);
31105 --
31106 -- adr variables
31107 l_segment VARCHAR2(30);
31108 l_ccid NUMBER;
31109 l_adr_transaction_coa_id NUMBER;
31110 l_adr_accounting_coa_id NUMBER;
31111 l_adr_flexfield_segment_code VARCHAR2(30);
31112 l_adr_flex_value_set_id NUMBER;
31113 l_adr_value_type_code VARCHAR2(30);
31114 l_adr_value_combination_id NUMBER;
31115 l_adr_value_segment_code VARCHAR2(30);
31116
31117 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31118 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31119 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31120 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31121
31122 -- 4262811 Variables ------------------------------------------------------------------------------------------
31123 l_entered_amt_idx NUMBER;
31124 l_accted_amt_idx NUMBER;
31125 l_acc_rev_flag VARCHAR2(1);
31126 l_accrual_line_num NUMBER;
31127 l_tmp_amt NUMBER;
31128 l_acc_rev_natural_side_code VARCHAR2(1);
31129
31130 l_num_entries NUMBER;
31131 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31132 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31133 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31134 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31135 l_recog_line_1 NUMBER;
31136 l_recog_line_2 NUMBER;
31137
31138 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31139 l_bflow_applied_to_amt NUMBER; -- 5132302
31140 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31141
31142 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31143
31144 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31145 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31146
31147 ---------------------------------------------------------------------------------------------------------------
31148
31149
31150 --
31151 -- bulk performance
31152 --
31153 l_balance_type_code VARCHAR2(1);
31154 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31155 l_log_module VARCHAR2(240);
31156
31157 --
31158 -- Upgrade strategy
31159 --
31160 l_actual_upg_option VARCHAR2(1);
31161 l_enc_upg_option VARCHAR2(1);
31162
31163 --
31164 BEGIN
31165 --
31166 IF g_log_enabled THEN
31167 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_81';
31168 END IF;
31169 --
31170 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31171
31172 trace
31173 (p_msg => 'BEGIN of AcctLineType_81'
31174 ,p_level => C_LEVEL_PROCEDURE
31175 ,p_module => l_log_module);
31176
31177 END IF;
31178 --
31179 l_component_type := 'AMB_JLT';
31180 l_component_code := 'COST_VARIANCE';
31181 l_component_type_code := 'S';
31182 l_component_appl_id := 707;
31183 l_amb_context_code := 'DEFAULT';
31184 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
31185 l_event_class_code := 'WIP_MTL';
31186 l_event_type_code := 'WIP_NEG_COMP_ISSUE';
31187 l_line_definition_owner_code := 'S';
31188 l_line_definition_code := 'PI_WIP_NEG_COMP_ISSUE';
31189 --
31190 l_balance_type_code := 'A';
31191 l_segment := NULL;
31192 l_ccid := NULL;
31193 l_adr_transaction_coa_id := NULL;
31194 l_adr_accounting_coa_id := NULL;
31195 l_adr_flexfield_segment_code := NULL;
31196 l_adr_flex_value_set_id := NULL;
31197 l_adr_value_type_code := NULL;
31198 l_adr_value_combination_id := NULL;
31199 l_adr_value_segment_code := NULL;
31200
31201 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31202 l_bflow_class_code := ''; -- 4219869 Business Flow
31203 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31204 l_budgetary_control_flag := 'N';
31205
31206 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31207 l_bflow_applied_to_amt := NULL; -- 5132302
31208 l_entered_amt_idx := NULL; -- 4262811
31209 l_accted_amt_idx := NULL; -- 4262811
31210 l_acc_rev_flag := NULL; -- 4262811
31211 l_accrual_line_num := NULL; -- 4262811
31212 l_tmp_amt := NULL; -- 4262811
31213 --
31214
31215 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31216 l_balance_type_code <> 'B' THEN
31217 IF NVL(p_source_97,9E125) = 13
31218 THEN
31219
31220 --
31221 XLA_AE_LINES_PKG.SetNewLine;
31222
31223 p_balance_type_code := l_balance_type_code;
31224 -- set the flag so later we will know whether the gain loss line needs to be created
31225
31226 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31227 p_actual_flag :='A';
31228 END IF;
31229
31230 --
31231 -- bulk performance
31232 --
31233 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31234 p_header_num => 0); -- 4262811
31235 --
31236 -- set accounting line options
31237 --
31238 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31239 p_natural_side_code => 'D'
31240 , p_gain_or_loss_flag => 'N'
31241 , p_gl_transfer_mode_code => 'S'
31242 , p_acct_entry_type_code => 'A'
31243 , p_switch_side_flag => 'Y'
31244 , p_merge_duplicate_code => 'N'
31245 );
31246 --
31247 l_acc_rev_natural_side_code := 'C'; -- 4262811
31248 --
31249 --
31250 -- set accounting line type info
31251 --
31252 xla_ae_lines_pkg.SetAcctLineType
31253 (p_component_type => l_component_type
31254 ,p_event_type_code => l_event_type_code
31255 ,p_line_definition_owner_code => l_line_definition_owner_code
31256 ,p_line_definition_code => l_line_definition_code
31257 ,p_accounting_line_code => l_component_code
31258 ,p_accounting_line_type_code => l_component_type_code
31259 ,p_accounting_line_appl_id => l_component_appl_id
31260 ,p_amb_context_code => l_amb_context_code
31261 ,p_entity_code => l_entity_code
31262 ,p_event_class_code => l_event_class_code);
31263 --
31264 -- set accounting class
31265 --
31266 xla_ae_lines_pkg.SetAcctClass(
31267 p_accounting_class_code => 'COST_VARIANCE'
31268 , p_ae_header_id => l_ae_header_id
31269 );
31270
31271 --
31272 -- set rounding class
31273 --
31274 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31275 'COST_VARIANCE';
31276
31277 --
31278 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31279 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31280 --
31281 -- bulk performance
31282 --
31283 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31284
31285 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31286 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31287
31288 -- 4955764
31289 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31290 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31291
31292 -- 4458381 Public Sector Enh
31293
31294 --
31295 -- set accounting attributes for the line type
31296 --
31297 l_entered_amt_idx := 3;
31298 l_accted_amt_idx := 8;
31299 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31300 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
31301 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
31302 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
31303 l_rec_acct_attrs.array_char_value(2) := p_source_85;
31304 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
31305 l_rec_acct_attrs.array_num_value(3) := p_source_91;
31306 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
31307 l_rec_acct_attrs.array_char_value(4) := p_source_88;
31308 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
31309 l_rec_acct_attrs.array_date_value(5) := p_source_92;
31310 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
31311 l_rec_acct_attrs.array_num_value(6) := p_source_93;
31312 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
31313 l_rec_acct_attrs.array_char_value(7) := p_source_94;
31314 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
31315 l_rec_acct_attrs.array_num_value(8) := p_source_95;
31316
31317 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31318 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31319
31320 ---------------------------------------------------------------------------------------------------------------
31321 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31322 ---------------------------------------------------------------------------------------------------------------
31323 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
31324
31325 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31326 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31327
31328 IF xla_accounting_cache_pkg.GetValueChar
31329 (p_source_code => 'LEDGER_CATEGORY_CODE'
31330 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
31331 AND l_bflow_method_code = 'PRIOR_ENTRY'
31332 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
31333 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
31334 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
31335 )
31336 THEN
31337 xla_ae_lines_pkg.BflowUpgEntry
31338 (p_business_method_code => l_bflow_method_code
31339 ,p_business_class_code => l_bflow_class_code
31340 ,p_balance_type => l_balance_type_code);
31341 ELSE
31342 NULL;
31343 -- No business flow processing for business flow method of NONE.
31344 END IF;
31345
31346 --
31347 -- call analytical criteria
31348 --
31349
31350 --
31351 -- call description
31352 --
31353
31354 xla_ae_lines_pkg.SetLineDescription(
31355 p_ae_header_id => l_ae_header_id
31356 ,p_description => Description_1 (
31357 p_application_id => p_application_id
31358 , p_ae_header_id => l_ae_header_id
31359 , p_source_1 => p_source_1
31360 , p_source_2 => p_source_2
31361 , p_source_3 => p_source_3
31362 , p_source_4 => p_source_4
31363 , p_source_5 => p_source_5
31364 )
31365 );
31366
31367
31368 --
31369 -- call ADRs
31370 -- Bug 4922099
31371 --
31372 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31373 (NVL(l_actual_upg_option, 'N') = 'O') OR
31374 (NVL(l_enc_upg_option, 'N') = 'O')
31375 )
31376 THEN
31377 NULL;
31378 --
31379 --
31380
31381 l_ccid := AcctDerRule_6(
31382 p_application_id => p_application_id
31383 , p_ae_header_id => l_ae_header_id
31384 , p_source_11 => p_source_11
31385 , x_transaction_coa_id => l_adr_transaction_coa_id
31386 , x_accounting_coa_id => l_adr_accounting_coa_id
31387 , x_value_type_code => l_adr_value_type_code
31388 , p_side => 'NA'
31389 );
31390
31391 xla_ae_lines_pkg.set_ccid(
31392 p_code_combination_id => l_ccid
31393 , p_value_type_code => l_adr_value_type_code
31394 , p_transaction_coa_id => l_adr_transaction_coa_id
31395 , p_accounting_coa_id => l_adr_accounting_coa_id
31396 , p_adr_code => 'CST_DEFAULT'
31397 , p_adr_type_code => 'S'
31398 , p_component_type => l_component_type
31399 , p_component_code => l_component_code
31400 , p_component_type_code => l_component_type_code
31401 , p_component_appl_id => l_component_appl_id
31402 , p_amb_context_code => l_amb_context_code
31403 , p_side => 'NA'
31404 );
31405
31406
31407 --
31408 --
31409 END IF;
31410 --
31411 -- Bug 4922099
31412 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31413 (NVL(l_enc_upg_option, 'N') = 'O')
31414 ) AND
31415 (l_bflow_method_code = 'PRIOR_ENTRY')
31416 )
31417 THEN
31418 IF
31419 --
31420 1 = 2
31421 --
31422 THEN
31423 xla_accounting_err_pkg.build_message
31424 (p_appli_s_name => 'XLA'
31425 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31426 ,p_token_1 => 'LINE_NUMBER'
31427 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31428 ,p_token_2 => 'LINE_TYPE_NAME'
31429 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31430 l_component_type
31431 ,l_component_code
31432 ,l_component_type_code
31433 ,l_component_appl_id
31434 ,l_amb_context_code
31435 ,l_entity_code
31436 ,l_event_class_code
31437 )
31438 ,p_token_3 => 'OWNER'
31439 ,p_value_3 => xla_lookups_pkg.get_meaning(
31440 p_lookup_type => 'XLA_OWNER_TYPE'
31441 ,p_lookup_code => l_component_type_code
31442 )
31443 ,p_token_4 => 'PRODUCT_NAME'
31444 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31445 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31446 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31447 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31448 ,p_ae_header_id => NULL
31449 );
31450
31451 IF (C_LEVEL_ERROR>= g_log_level) THEN
31452 trace
31453 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31454 ,p_level => C_LEVEL_ERROR
31455 ,p_module => l_log_module);
31456 END IF;
31457 END IF;
31458 END IF;
31459 --
31460 --
31461 ------------------------------------------------------------------------------------------------
31462 -- 4219869 Business Flow
31463 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31464 -- Prior Entry. Currently, the following code is always generated.
31465 ------------------------------------------------------------------------------------------------
31466 XLA_AE_LINES_PKG.ValidateCurrentLine;
31467
31468 ------------------------------------------------------------------------------------
31469 -- 4219869 Business Flow
31470 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31471 ------------------------------------------------------------------------------------
31472 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31473
31474 ----------------------------------------------------------------------------------
31475 -- 4219869 Business Flow
31476 -- Update journal entry status -- Need to generate this within IF <condition>
31477 ----------------------------------------------------------------------------------
31478 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31479 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31480 ,p_balance_type_code => l_balance_type_code
31481 );
31482
31483 -------------------------------------------------------------------------------------------
31484 -- 4262811 - Generate the Accrual Reversal lines
31485 -------------------------------------------------------------------------------------------
31486 BEGIN
31487 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31488 (g_array_event(p_event_id).array_value_num('header_index'));
31489 IF l_acc_rev_flag IS NULL THEN
31490 l_acc_rev_flag := 'N';
31491 END IF;
31492 EXCEPTION
31493 WHEN OTHERS THEN
31494 l_acc_rev_flag := 'N';
31495 END;
31496 --
31497 IF (l_acc_rev_flag = 'Y') THEN
31498
31499 -- 4645092 ------------------------------------------------------------------------------
31500 -- To allow MPA report to determine if it should generate report process
31501 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31502 ------------------------------------------------------------------------------------------
31503
31504 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31505 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31506 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31507 -- call ADRs
31508 -- Bug 4922099
31509 --
31510 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31511 (NVL(l_actual_upg_option, 'N') = 'O') OR
31512 (NVL(l_enc_upg_option, 'N') = 'O')
31513 )
31514 THEN
31515 NULL;
31516 --
31517 --
31518
31519 l_ccid := AcctDerRule_6(
31520 p_application_id => p_application_id
31521 , p_ae_header_id => l_ae_header_id
31522 , p_source_11 => p_source_11
31523 , x_transaction_coa_id => l_adr_transaction_coa_id
31524 , x_accounting_coa_id => l_adr_accounting_coa_id
31525 , x_value_type_code => l_adr_value_type_code
31526 , p_side => 'NA'
31527 );
31528
31529 xla_ae_lines_pkg.set_ccid(
31530 p_code_combination_id => l_ccid
31531 , p_value_type_code => l_adr_value_type_code
31532 , p_transaction_coa_id => l_adr_transaction_coa_id
31533 , p_accounting_coa_id => l_adr_accounting_coa_id
31534 , p_adr_code => 'CST_DEFAULT'
31535 , p_adr_type_code => 'S'
31536 , p_component_type => l_component_type
31537 , p_component_code => l_component_code
31538 , p_component_type_code => l_component_type_code
31539 , p_component_appl_id => l_component_appl_id
31540 , p_amb_context_code => l_amb_context_code
31541 , p_side => 'NA'
31542 );
31543
31544
31545 --
31546 --
31547 END IF;
31548
31549 --
31550 -- Update the line information that should be overwritten
31551 --
31552 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31553 p_header_num => 1);
31554 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31555
31556 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31557
31558 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31559 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31560 END IF;
31561
31562 --
31563 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31564 --
31565 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31566 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31567 ELSE
31568 ---------------------------------------------------------------------------------------------------
31569 -- 4262811a Switch Sign
31570 ---------------------------------------------------------------------------------------------------
31571 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31572 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31573 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31574 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31575 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31576 -- 5132302
31577 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31578 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31579
31580 END IF;
31581
31582 -- 4955764
31583 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31584 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31585
31586
31587 XLA_AE_LINES_PKG.ValidateCurrentLine;
31588 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31589
31590 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31591 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31592 ,p_balance_type_code => l_balance_type_code);
31593
31594 END IF;
31595
31596 -----------------------------------------------------------------------------------------
31597 -- 4262811 Multiperiod Accounting
31598 -----------------------------------------------------------------------------------------
31599 -- No MPA option is assigned.
31600
31601
31602 END IF;
31603 END IF;
31604 --
31605
31606 --
31607 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31608 trace
31609 (p_msg => 'END of AcctLineType_81'
31610 ,p_level => C_LEVEL_PROCEDURE
31611 ,p_module => l_log_module);
31612 END IF;
31613 --
31614 EXCEPTION
31615 WHEN xla_exceptions_pkg.application_exception THEN
31616 RAISE;
31617 WHEN OTHERS THEN
31618 xla_exceptions_pkg.raise_message
31619 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_81');
31620 END AcctLineType_81;
31621 --
31622
31623 ---------------------------------------
31624 --
31625 -- PRIVATE FUNCTION
31626 -- AcctLineType_82
31627 --
31628 ---------------------------------------
31629 PROCEDURE AcctLineType_82 (
31630 p_application_id IN NUMBER
31631 ,p_event_id IN NUMBER
31632 ,p_calculate_acctd_flag IN VARCHAR2
31633 ,p_calculate_g_l_flag IN VARCHAR2
31634 ,p_actual_flag IN OUT VARCHAR2
31635 ,p_balance_type_code OUT VARCHAR2
31636 ,p_gain_or_loss_ref OUT VARCHAR2
31637
31638 --TRANSACTION_ID
31639 , p_source_1 IN NUMBER
31640 --Item Concatenated Segments
31641 , p_source_2 IN VARCHAR2
31642 --Transaction Quantity
31643 , p_source_3 IN NUMBER
31644 --Transaction Unit of Measure Code
31645 , p_source_4 IN VARCHAR2
31646 --Inventory Transaction Type Description
31647 , p_source_5 IN VARCHAR2
31648 --Cost Management Default Account
31649 , p_source_11 IN NUMBER
31650 --DISTRIBUTION_IDENTIFIER
31651 , p_source_84 IN NUMBER
31652 --Distribution Type
31653 , p_source_85 IN VARCHAR2
31654 , p_source_85_meaning IN VARCHAR2
31655 --Entered Currency Code
31656 , p_source_88 IN VARCHAR2
31657 --Entered Amount
31658 , p_source_91 IN NUMBER
31659 --Currency Conversion Date
31660 , p_source_92 IN DATE
31661 --Currency Conversion Rate
31662 , p_source_93 IN NUMBER
31663 --Currency Conversion Type
31664 , p_source_94 IN VARCHAR2
31665 --Accounted Amount
31666 , p_source_95 IN NUMBER
31667 --Accounting Line Type
31668 , p_source_97 IN NUMBER
31669 )
31670 IS
31671
31672 l_component_type VARCHAR2(80);
31673 l_component_code VARCHAR2(30);
31674 l_component_type_code VARCHAR2(1);
31675 l_component_appl_id INTEGER;
31676 l_amb_context_code VARCHAR2(30);
31677 l_entity_code VARCHAR2(30);
31678 l_event_class_code VARCHAR2(30);
31679 l_ae_header_id NUMBER;
31680 l_event_type_code VARCHAR2(30);
31681 l_line_definition_code VARCHAR2(30);
31682 l_line_definition_owner_code VARCHAR2(1);
31683 --
31684 -- adr variables
31685 l_segment VARCHAR2(30);
31686 l_ccid NUMBER;
31687 l_adr_transaction_coa_id NUMBER;
31688 l_adr_accounting_coa_id NUMBER;
31689 l_adr_flexfield_segment_code VARCHAR2(30);
31690 l_adr_flex_value_set_id NUMBER;
31691 l_adr_value_type_code VARCHAR2(30);
31692 l_adr_value_combination_id NUMBER;
31693 l_adr_value_segment_code VARCHAR2(30);
31694
31695 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31696 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31697 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31698 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31699
31700 -- 4262811 Variables ------------------------------------------------------------------------------------------
31701 l_entered_amt_idx NUMBER;
31702 l_accted_amt_idx NUMBER;
31703 l_acc_rev_flag VARCHAR2(1);
31704 l_accrual_line_num NUMBER;
31705 l_tmp_amt NUMBER;
31706 l_acc_rev_natural_side_code VARCHAR2(1);
31707
31708 l_num_entries NUMBER;
31709 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31710 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31711 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31712 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31713 l_recog_line_1 NUMBER;
31714 l_recog_line_2 NUMBER;
31715
31716 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31717 l_bflow_applied_to_amt NUMBER; -- 5132302
31718 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31719
31720 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31721
31722 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31723 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31724
31725 ---------------------------------------------------------------------------------------------------------------
31726
31727
31728 --
31729 -- bulk performance
31730 --
31731 l_balance_type_code VARCHAR2(1);
31732 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31733 l_log_module VARCHAR2(240);
31734
31735 --
31736 -- Upgrade strategy
31737 --
31738 l_actual_upg_option VARCHAR2(1);
31739 l_enc_upg_option VARCHAR2(1);
31740
31741 --
31742 BEGIN
31743 --
31744 IF g_log_enabled THEN
31745 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_82';
31746 END IF;
31747 --
31748 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31749
31750 trace
31751 (p_msg => 'BEGIN of AcctLineType_82'
31752 ,p_level => C_LEVEL_PROCEDURE
31753 ,p_module => l_log_module);
31754
31755 END IF;
31756 --
31757 l_component_type := 'AMB_JLT';
31758 l_component_code := 'COST_VARIANCE';
31759 l_component_type_code := 'S';
31760 l_component_appl_id := 707;
31761 l_amb_context_code := 'DEFAULT';
31762 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
31763 l_event_class_code := 'MTL_COST_UPD';
31764 l_event_type_code := 'IPV_TXFR';
31765 l_line_definition_owner_code := 'S';
31766 l_line_definition_code := 'PI_IPV_TXFR';
31767 --
31768 l_balance_type_code := 'A';
31769 l_segment := NULL;
31770 l_ccid := NULL;
31771 l_adr_transaction_coa_id := NULL;
31772 l_adr_accounting_coa_id := NULL;
31773 l_adr_flexfield_segment_code := NULL;
31774 l_adr_flex_value_set_id := NULL;
31775 l_adr_value_type_code := NULL;
31776 l_adr_value_combination_id := NULL;
31777 l_adr_value_segment_code := NULL;
31778
31779 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31780 l_bflow_class_code := ''; -- 4219869 Business Flow
31781 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31782 l_budgetary_control_flag := 'N';
31783
31784 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31785 l_bflow_applied_to_amt := NULL; -- 5132302
31786 l_entered_amt_idx := NULL; -- 4262811
31787 l_accted_amt_idx := NULL; -- 4262811
31788 l_acc_rev_flag := NULL; -- 4262811
31789 l_accrual_line_num := NULL; -- 4262811
31790 l_tmp_amt := NULL; -- 4262811
31791 --
31792
31793 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31794 l_balance_type_code <> 'B' THEN
31795 IF NVL(p_source_97,9E125) = 13
31796 THEN
31797
31798 --
31799 XLA_AE_LINES_PKG.SetNewLine;
31800
31801 p_balance_type_code := l_balance_type_code;
31802 -- set the flag so later we will know whether the gain loss line needs to be created
31803
31804 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31805 p_actual_flag :='A';
31806 END IF;
31807
31808 --
31809 -- bulk performance
31810 --
31811 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31812 p_header_num => 0); -- 4262811
31813 --
31814 -- set accounting line options
31815 --
31816 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31817 p_natural_side_code => 'D'
31818 , p_gain_or_loss_flag => 'N'
31819 , p_gl_transfer_mode_code => 'S'
31820 , p_acct_entry_type_code => 'A'
31821 , p_switch_side_flag => 'Y'
31822 , p_merge_duplicate_code => 'N'
31823 );
31824 --
31825 l_acc_rev_natural_side_code := 'C'; -- 4262811
31826 --
31827 --
31828 -- set accounting line type info
31829 --
31830 xla_ae_lines_pkg.SetAcctLineType
31831 (p_component_type => l_component_type
31832 ,p_event_type_code => l_event_type_code
31833 ,p_line_definition_owner_code => l_line_definition_owner_code
31834 ,p_line_definition_code => l_line_definition_code
31835 ,p_accounting_line_code => l_component_code
31836 ,p_accounting_line_type_code => l_component_type_code
31837 ,p_accounting_line_appl_id => l_component_appl_id
31838 ,p_amb_context_code => l_amb_context_code
31839 ,p_entity_code => l_entity_code
31840 ,p_event_class_code => l_event_class_code);
31841 --
31842 -- set accounting class
31843 --
31844 xla_ae_lines_pkg.SetAcctClass(
31845 p_accounting_class_code => 'COST_VARIANCE'
31846 , p_ae_header_id => l_ae_header_id
31847 );
31848
31849 --
31850 -- set rounding class
31851 --
31852 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31853 'COST_VARIANCE';
31854
31855 --
31856 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31857 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31858 --
31859 -- bulk performance
31860 --
31861 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31862
31863 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31864 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31865
31866 -- 4955764
31867 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31868 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31869
31870 -- 4458381 Public Sector Enh
31871
31872 --
31873 -- set accounting attributes for the line type
31874 --
31875 l_entered_amt_idx := 3;
31876 l_accted_amt_idx := 8;
31877 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31878 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
31879 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
31880 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
31881 l_rec_acct_attrs.array_char_value(2) := p_source_85;
31882 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
31883 l_rec_acct_attrs.array_num_value(3) := p_source_91;
31884 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
31885 l_rec_acct_attrs.array_char_value(4) := p_source_88;
31886 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
31887 l_rec_acct_attrs.array_date_value(5) := p_source_92;
31888 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
31889 l_rec_acct_attrs.array_num_value(6) := p_source_93;
31890 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
31891 l_rec_acct_attrs.array_char_value(7) := p_source_94;
31892 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
31893 l_rec_acct_attrs.array_num_value(8) := p_source_95;
31894
31895 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31896 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31897
31898 ---------------------------------------------------------------------------------------------------------------
31899 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31900 ---------------------------------------------------------------------------------------------------------------
31901 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
31902
31903 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31904 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31905
31906 IF xla_accounting_cache_pkg.GetValueChar
31907 (p_source_code => 'LEDGER_CATEGORY_CODE'
31908 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
31909 AND l_bflow_method_code = 'PRIOR_ENTRY'
31910 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
31911 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
31912 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
31913 )
31914 THEN
31915 xla_ae_lines_pkg.BflowUpgEntry
31916 (p_business_method_code => l_bflow_method_code
31917 ,p_business_class_code => l_bflow_class_code
31918 ,p_balance_type => l_balance_type_code);
31919 ELSE
31920 NULL;
31921 -- No business flow processing for business flow method of NONE.
31922 END IF;
31923
31924 --
31925 -- call analytical criteria
31926 --
31927
31928 --
31929 -- call description
31930 --
31931
31932 xla_ae_lines_pkg.SetLineDescription(
31933 p_ae_header_id => l_ae_header_id
31934 ,p_description => Description_1 (
31935 p_application_id => p_application_id
31936 , p_ae_header_id => l_ae_header_id
31937 , p_source_1 => p_source_1
31938 , p_source_2 => p_source_2
31939 , p_source_3 => p_source_3
31940 , p_source_4 => p_source_4
31941 , p_source_5 => p_source_5
31942 )
31943 );
31944
31945
31946 --
31947 -- call ADRs
31948 -- Bug 4922099
31949 --
31950 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31951 (NVL(l_actual_upg_option, 'N') = 'O') OR
31952 (NVL(l_enc_upg_option, 'N') = 'O')
31953 )
31954 THEN
31955 NULL;
31956 --
31957 --
31958
31959 l_ccid := AcctDerRule_6(
31960 p_application_id => p_application_id
31961 , p_ae_header_id => l_ae_header_id
31962 , p_source_11 => p_source_11
31963 , x_transaction_coa_id => l_adr_transaction_coa_id
31964 , x_accounting_coa_id => l_adr_accounting_coa_id
31965 , x_value_type_code => l_adr_value_type_code
31966 , p_side => 'NA'
31967 );
31968
31969 xla_ae_lines_pkg.set_ccid(
31970 p_code_combination_id => l_ccid
31971 , p_value_type_code => l_adr_value_type_code
31972 , p_transaction_coa_id => l_adr_transaction_coa_id
31973 , p_accounting_coa_id => l_adr_accounting_coa_id
31974 , p_adr_code => 'CST_DEFAULT'
31975 , p_adr_type_code => 'S'
31976 , p_component_type => l_component_type
31977 , p_component_code => l_component_code
31978 , p_component_type_code => l_component_type_code
31979 , p_component_appl_id => l_component_appl_id
31980 , p_amb_context_code => l_amb_context_code
31981 , p_side => 'NA'
31982 );
31983
31984
31985 --
31986 --
31987 END IF;
31988 --
31989 -- Bug 4922099
31990 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31991 (NVL(l_enc_upg_option, 'N') = 'O')
31992 ) AND
31993 (l_bflow_method_code = 'PRIOR_ENTRY')
31994 )
31995 THEN
31996 IF
31997 --
31998 1 = 2
31999 --
32000 THEN
32001 xla_accounting_err_pkg.build_message
32002 (p_appli_s_name => 'XLA'
32003 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32004 ,p_token_1 => 'LINE_NUMBER'
32005 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32006 ,p_token_2 => 'LINE_TYPE_NAME'
32007 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32008 l_component_type
32009 ,l_component_code
32010 ,l_component_type_code
32011 ,l_component_appl_id
32012 ,l_amb_context_code
32013 ,l_entity_code
32014 ,l_event_class_code
32015 )
32016 ,p_token_3 => 'OWNER'
32017 ,p_value_3 => xla_lookups_pkg.get_meaning(
32018 p_lookup_type => 'XLA_OWNER_TYPE'
32019 ,p_lookup_code => l_component_type_code
32020 )
32021 ,p_token_4 => 'PRODUCT_NAME'
32022 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32023 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32024 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32025 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32026 ,p_ae_header_id => NULL
32027 );
32028
32029 IF (C_LEVEL_ERROR>= g_log_level) THEN
32030 trace
32031 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32032 ,p_level => C_LEVEL_ERROR
32033 ,p_module => l_log_module);
32034 END IF;
32035 END IF;
32036 END IF;
32037 --
32038 --
32039 ------------------------------------------------------------------------------------------------
32040 -- 4219869 Business Flow
32041 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32042 -- Prior Entry. Currently, the following code is always generated.
32043 ------------------------------------------------------------------------------------------------
32044 XLA_AE_LINES_PKG.ValidateCurrentLine;
32045
32046 ------------------------------------------------------------------------------------
32047 -- 4219869 Business Flow
32048 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32049 ------------------------------------------------------------------------------------
32050 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32051
32052 ----------------------------------------------------------------------------------
32053 -- 4219869 Business Flow
32054 -- Update journal entry status -- Need to generate this within IF <condition>
32055 ----------------------------------------------------------------------------------
32056 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32057 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32058 ,p_balance_type_code => l_balance_type_code
32059 );
32060
32061 -------------------------------------------------------------------------------------------
32062 -- 4262811 - Generate the Accrual Reversal lines
32063 -------------------------------------------------------------------------------------------
32064 BEGIN
32065 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32066 (g_array_event(p_event_id).array_value_num('header_index'));
32067 IF l_acc_rev_flag IS NULL THEN
32068 l_acc_rev_flag := 'N';
32069 END IF;
32070 EXCEPTION
32071 WHEN OTHERS THEN
32072 l_acc_rev_flag := 'N';
32073 END;
32074 --
32075 IF (l_acc_rev_flag = 'Y') THEN
32076
32077 -- 4645092 ------------------------------------------------------------------------------
32078 -- To allow MPA report to determine if it should generate report process
32079 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32080 ------------------------------------------------------------------------------------------
32081
32082 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32083 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32084 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32085 -- call ADRs
32086 -- Bug 4922099
32087 --
32088 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32089 (NVL(l_actual_upg_option, 'N') = 'O') OR
32090 (NVL(l_enc_upg_option, 'N') = 'O')
32091 )
32092 THEN
32093 NULL;
32094 --
32095 --
32096
32097 l_ccid := AcctDerRule_6(
32098 p_application_id => p_application_id
32099 , p_ae_header_id => l_ae_header_id
32100 , p_source_11 => p_source_11
32101 , x_transaction_coa_id => l_adr_transaction_coa_id
32102 , x_accounting_coa_id => l_adr_accounting_coa_id
32103 , x_value_type_code => l_adr_value_type_code
32104 , p_side => 'NA'
32105 );
32106
32107 xla_ae_lines_pkg.set_ccid(
32108 p_code_combination_id => l_ccid
32109 , p_value_type_code => l_adr_value_type_code
32110 , p_transaction_coa_id => l_adr_transaction_coa_id
32111 , p_accounting_coa_id => l_adr_accounting_coa_id
32112 , p_adr_code => 'CST_DEFAULT'
32113 , p_adr_type_code => 'S'
32114 , p_component_type => l_component_type
32115 , p_component_code => l_component_code
32116 , p_component_type_code => l_component_type_code
32117 , p_component_appl_id => l_component_appl_id
32118 , p_amb_context_code => l_amb_context_code
32119 , p_side => 'NA'
32120 );
32121
32122
32123 --
32124 --
32125 END IF;
32126
32127 --
32128 -- Update the line information that should be overwritten
32129 --
32130 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32131 p_header_num => 1);
32132 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32133
32134 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32135
32136 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32137 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32138 END IF;
32139
32140 --
32141 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32142 --
32143 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32144 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32145 ELSE
32146 ---------------------------------------------------------------------------------------------------
32147 -- 4262811a Switch Sign
32148 ---------------------------------------------------------------------------------------------------
32149 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32150 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32151 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32152 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32153 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32154 -- 5132302
32155 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32156 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32157
32158 END IF;
32159
32160 -- 4955764
32161 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32162 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32163
32164
32165 XLA_AE_LINES_PKG.ValidateCurrentLine;
32166 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32167
32168 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32169 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32170 ,p_balance_type_code => l_balance_type_code);
32171
32172 END IF;
32173
32174 -----------------------------------------------------------------------------------------
32175 -- 4262811 Multiperiod Accounting
32176 -----------------------------------------------------------------------------------------
32177 -- No MPA option is assigned.
32178
32179
32180 END IF;
32181 END IF;
32182 --
32183
32184 --
32185 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32186 trace
32187 (p_msg => 'END of AcctLineType_82'
32188 ,p_level => C_LEVEL_PROCEDURE
32189 ,p_module => l_log_module);
32190 END IF;
32191 --
32192 EXCEPTION
32193 WHEN xla_exceptions_pkg.application_exception THEN
32194 RAISE;
32195 WHEN OTHERS THEN
32196 xla_exceptions_pkg.raise_message
32197 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_82');
32198 END AcctLineType_82;
32199 --
32200
32201 ---------------------------------------
32202 --
32203 -- PRIVATE FUNCTION
32204 -- AcctLineType_83
32205 --
32206 ---------------------------------------
32207 PROCEDURE AcctLineType_83 (
32208 p_application_id IN NUMBER
32209 ,p_event_id IN NUMBER
32210 ,p_calculate_acctd_flag IN VARCHAR2
32211 ,p_calculate_g_l_flag IN VARCHAR2
32212 ,p_actual_flag IN OUT VARCHAR2
32213 ,p_balance_type_code OUT VARCHAR2
32214 ,p_gain_or_loss_ref OUT VARCHAR2
32215
32216 --TRANSACTION_ID
32217 , p_source_1 IN NUMBER
32218 --Item Concatenated Segments
32219 , p_source_2 IN VARCHAR2
32220 --Transaction Quantity
32221 , p_source_3 IN NUMBER
32222 --Transaction Unit of Measure Code
32223 , p_source_4 IN VARCHAR2
32224 --Inventory Transaction Type Description
32225 , p_source_5 IN VARCHAR2
32226 --Cost Management Default Account
32227 , p_source_11 IN NUMBER
32228 --Applied to Application ID
32229 , p_source_79 IN NUMBER
32230 --Applied to Distribution Link Type
32231 , p_source_80 IN VARCHAR2
32232 --Applied to Entity Code
32233 , p_source_81 IN VARCHAR2
32234 --Applied To Purchase Document Identifier
32235 , p_source_83 IN NUMBER
32236 --DISTRIBUTION_IDENTIFIER
32237 , p_source_84 IN NUMBER
32238 --Distribution Type
32239 , p_source_85 IN VARCHAR2
32240 , p_source_85_meaning IN VARCHAR2
32241 --PO Budget Account
32242 , p_source_86 IN NUMBER
32243 --Encumbrance Reversal Amount Entered
32244 , p_source_87 IN NUMBER
32245 --Entered Currency Code
32246 , p_source_88 IN VARCHAR2
32247 --Transaction Encumbrance Reversal Amount
32248 , p_source_89 IN NUMBER
32249 --Entered Amount
32250 , p_source_91 IN NUMBER
32251 --Currency Conversion Date
32252 , p_source_92 IN DATE
32253 --Currency Conversion Rate
32254 , p_source_93 IN NUMBER
32255 --Currency Conversion Type
32256 , p_source_94 IN VARCHAR2
32257 --Accounted Amount
32258 , p_source_95 IN NUMBER
32259 --Purchasing Encumbrance Type Identifier
32260 , p_source_96 IN NUMBER
32261 --Accounting Line Type
32262 , p_source_97 IN NUMBER
32263 --Costing Encumbrance Upgrade Option
32264 , p_source_100 IN VARCHAR2
32265 --TXN_PO_DISTRIBUTION_ID
32266 , p_source_101 IN NUMBER
32267 )
32268 IS
32269
32270 l_component_type VARCHAR2(80);
32271 l_component_code VARCHAR2(30);
32272 l_component_type_code VARCHAR2(1);
32273 l_component_appl_id INTEGER;
32274 l_amb_context_code VARCHAR2(30);
32275 l_entity_code VARCHAR2(30);
32276 l_event_class_code VARCHAR2(30);
32277 l_ae_header_id NUMBER;
32278 l_event_type_code VARCHAR2(30);
32279 l_line_definition_code VARCHAR2(30);
32280 l_line_definition_owner_code VARCHAR2(1);
32281 --
32282 -- adr variables
32283 l_segment VARCHAR2(30);
32284 l_ccid NUMBER;
32285 l_adr_transaction_coa_id NUMBER;
32286 l_adr_accounting_coa_id NUMBER;
32287 l_adr_flexfield_segment_code VARCHAR2(30);
32288 l_adr_flex_value_set_id NUMBER;
32289 l_adr_value_type_code VARCHAR2(30);
32290 l_adr_value_combination_id NUMBER;
32291 l_adr_value_segment_code VARCHAR2(30);
32292
32293 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32294 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32295 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32296 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32297
32298 -- 4262811 Variables ------------------------------------------------------------------------------------------
32299 l_entered_amt_idx NUMBER;
32300 l_accted_amt_idx NUMBER;
32301 l_acc_rev_flag VARCHAR2(1);
32302 l_accrual_line_num NUMBER;
32303 l_tmp_amt NUMBER;
32304 l_acc_rev_natural_side_code VARCHAR2(1);
32305
32306 l_num_entries NUMBER;
32307 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32308 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32309 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32310 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32311 l_recog_line_1 NUMBER;
32312 l_recog_line_2 NUMBER;
32313
32314 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32315 l_bflow_applied_to_amt NUMBER; -- 5132302
32316 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32317
32318 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32319
32320 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32321 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32322
32323 ---------------------------------------------------------------------------------------------------------------
32324
32325
32326 --
32327 -- bulk performance
32328 --
32329 l_balance_type_code VARCHAR2(1);
32330 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32331 l_log_module VARCHAR2(240);
32332
32333 --
32334 -- Upgrade strategy
32335 --
32336 l_actual_upg_option VARCHAR2(1);
32337 l_enc_upg_option VARCHAR2(1);
32338
32339 --
32340 BEGIN
32341 --
32342 IF g_log_enabled THEN
32343 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_83';
32344 END IF;
32345 --
32346 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32347
32348 trace
32349 (p_msg => 'BEGIN of AcctLineType_83'
32350 ,p_level => C_LEVEL_PROCEDURE
32351 ,p_module => l_log_module);
32352
32353 END IF;
32354 --
32355 l_component_type := 'AMB_JLT';
32356 l_component_code := 'COST_VARIANCE';
32357 l_component_type_code := 'S';
32358 l_component_appl_id := 707;
32359 l_amb_context_code := 'DEFAULT';
32360 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
32361 l_event_class_code := 'PURCHASE_ORDER';
32362 l_event_type_code := 'LOG_PO_DEL_ADJ';
32363 l_line_definition_owner_code := 'S';
32364 l_line_definition_code := 'PI_LOG_PO_DEL_ADJ';
32365 --
32366 l_balance_type_code := 'A';
32367 l_segment := NULL;
32368 l_ccid := NULL;
32369 l_adr_transaction_coa_id := NULL;
32370 l_adr_accounting_coa_id := NULL;
32371 l_adr_flexfield_segment_code := NULL;
32372 l_adr_flex_value_set_id := NULL;
32373 l_adr_value_type_code := NULL;
32374 l_adr_value_combination_id := NULL;
32375 l_adr_value_segment_code := NULL;
32376
32377 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
32378 l_bflow_class_code := ''; -- 4219869 Business Flow
32379 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
32380 l_budgetary_control_flag := 'N';
32381
32382 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32383 l_bflow_applied_to_amt := NULL; -- 5132302
32384 l_entered_amt_idx := NULL; -- 4262811
32385 l_accted_amt_idx := NULL; -- 4262811
32386 l_acc_rev_flag := NULL; -- 4262811
32387 l_accrual_line_num := NULL; -- 4262811
32388 l_tmp_amt := NULL; -- 4262811
32389 --
32390
32391 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
32392 l_balance_type_code <> 'B' THEN
32393 IF NVL(p_source_97,9E125) = 13
32394 THEN
32395
32396 --
32397 XLA_AE_LINES_PKG.SetNewLine;
32398
32399 p_balance_type_code := l_balance_type_code;
32400 -- set the flag so later we will know whether the gain loss line needs to be created
32401
32402 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
32403 p_actual_flag :='A';
32404 END IF;
32405
32406 --
32407 -- bulk performance
32408 --
32409 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
32410 p_header_num => 0); -- 4262811
32411 --
32412 -- set accounting line options
32413 --
32414 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
32415 p_natural_side_code => 'D'
32416 , p_gain_or_loss_flag => 'N'
32417 , p_gl_transfer_mode_code => 'S'
32418 , p_acct_entry_type_code => 'A'
32419 , p_switch_side_flag => 'Y'
32420 , p_merge_duplicate_code => 'N'
32421 );
32422 --
32423 l_acc_rev_natural_side_code := 'C'; -- 4262811
32424 --
32425 --
32426 -- set accounting line type info
32427 --
32428 xla_ae_lines_pkg.SetAcctLineType
32429 (p_component_type => l_component_type
32430 ,p_event_type_code => l_event_type_code
32431 ,p_line_definition_owner_code => l_line_definition_owner_code
32432 ,p_line_definition_code => l_line_definition_code
32433 ,p_accounting_line_code => l_component_code
32434 ,p_accounting_line_type_code => l_component_type_code
32435 ,p_accounting_line_appl_id => l_component_appl_id
32436 ,p_amb_context_code => l_amb_context_code
32437 ,p_entity_code => l_entity_code
32438 ,p_event_class_code => l_event_class_code);
32439 --
32440 -- set accounting class
32441 --
32442 xla_ae_lines_pkg.SetAcctClass(
32443 p_accounting_class_code => 'COST_VARIANCE'
32444 , p_ae_header_id => l_ae_header_id
32445 );
32446
32447 --
32448 -- set rounding class
32449 --
32450 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32451 'COST_VARIANCE';
32452
32453 --
32454 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32455 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32456 --
32457 -- bulk performance
32458 --
32459 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32460
32461 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32462 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32463
32464 -- 4955764
32465 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32466 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32467
32468 -- 4458381 Public Sector Enh
32469
32470 --
32471 -- set accounting attributes for the line type
32472 --
32473 l_entered_amt_idx := 17;
32474 l_accted_amt_idx := 22;
32475 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32476 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
32477 l_rec_acct_attrs.array_num_value(1) := p_source_79;
32478 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
32479 l_rec_acct_attrs.array_char_value(2) := p_source_80;
32480 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
32481 l_rec_acct_attrs.array_char_value(3) := p_source_81;
32482 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
32483 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
32484 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
32485 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
32486 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
32487 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
32488 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
32489 l_rec_acct_attrs.array_char_value(7) := p_source_85;
32490 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
32491 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
32492 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
32493 l_rec_acct_attrs.array_num_value(9) := p_source_87;
32494 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
32495 l_rec_acct_attrs.array_char_value(10) := p_source_88;
32496 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
32497 l_rec_acct_attrs.array_num_value(11) := p_source_89;
32498 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
32499 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
32500 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
32501 l_rec_acct_attrs.array_num_value(13) := p_source_87;
32502 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
32503 l_rec_acct_attrs.array_char_value(14) := p_source_88;
32504 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
32505 l_rec_acct_attrs.array_num_value(15) := p_source_89;
32506 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
32507 l_rec_acct_attrs.array_char_value(16) := p_source_100;
32508 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
32509 l_rec_acct_attrs.array_num_value(17) := p_source_91;
32510 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
32511 l_rec_acct_attrs.array_char_value(18) := p_source_88;
32512 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
32513 l_rec_acct_attrs.array_date_value(19) := p_source_92;
32514 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
32515 l_rec_acct_attrs.array_num_value(20) := p_source_93;
32516 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
32517 l_rec_acct_attrs.array_char_value(21) := p_source_94;
32518 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
32519 l_rec_acct_attrs.array_num_value(22) := p_source_95;
32520 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
32521 l_rec_acct_attrs.array_num_value(23) := p_source_96;
32522 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
32523 l_rec_acct_attrs.array_num_value(24) := p_source_96;
32524
32525 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
32526 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
32527
32528 ---------------------------------------------------------------------------------------------------------------
32529 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
32530 ---------------------------------------------------------------------------------------------------------------
32531 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32532
32533 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32534 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32535
32536 IF xla_accounting_cache_pkg.GetValueChar
32537 (p_source_code => 'LEDGER_CATEGORY_CODE'
32538 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32539 AND l_bflow_method_code = 'PRIOR_ENTRY'
32540 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32541 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32542 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32543 )
32544 THEN
32545 xla_ae_lines_pkg.BflowUpgEntry
32546 (p_business_method_code => l_bflow_method_code
32547 ,p_business_class_code => l_bflow_class_code
32548 ,p_balance_type => l_balance_type_code);
32549 ELSE
32550 NULL;
32551 -- No business flow processing for business flow method of NONE.
32552 END IF;
32553
32554 --
32555 -- call analytical criteria
32556 --
32557
32558 --
32559 -- call description
32560 --
32561
32562 xla_ae_lines_pkg.SetLineDescription(
32563 p_ae_header_id => l_ae_header_id
32564 ,p_description => Description_1 (
32565 p_application_id => p_application_id
32566 , p_ae_header_id => l_ae_header_id
32567 , p_source_1 => p_source_1
32568 , p_source_2 => p_source_2
32569 , p_source_3 => p_source_3
32570 , p_source_4 => p_source_4
32571 , p_source_5 => p_source_5
32572 )
32573 );
32574
32575
32576 --
32577 -- call ADRs
32578 -- Bug 4922099
32579 --
32580 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32581 (NVL(l_actual_upg_option, 'N') = 'O') OR
32582 (NVL(l_enc_upg_option, 'N') = 'O')
32583 )
32584 THEN
32585 NULL;
32586 --
32587 --
32588
32589 l_ccid := AcctDerRule_6(
32590 p_application_id => p_application_id
32591 , p_ae_header_id => l_ae_header_id
32592 , p_source_11 => p_source_11
32593 , x_transaction_coa_id => l_adr_transaction_coa_id
32594 , x_accounting_coa_id => l_adr_accounting_coa_id
32595 , x_value_type_code => l_adr_value_type_code
32596 , p_side => 'NA'
32597 );
32598
32599 xla_ae_lines_pkg.set_ccid(
32600 p_code_combination_id => l_ccid
32601 , p_value_type_code => l_adr_value_type_code
32602 , p_transaction_coa_id => l_adr_transaction_coa_id
32603 , p_accounting_coa_id => l_adr_accounting_coa_id
32604 , p_adr_code => 'CST_DEFAULT'
32605 , p_adr_type_code => 'S'
32606 , p_component_type => l_component_type
32607 , p_component_code => l_component_code
32608 , p_component_type_code => l_component_type_code
32609 , p_component_appl_id => l_component_appl_id
32610 , p_amb_context_code => l_amb_context_code
32611 , p_side => 'NA'
32612 );
32613
32614
32615 --
32616 --
32617 END IF;
32618 --
32619 -- Bug 4922099
32620 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32621 (NVL(l_enc_upg_option, 'N') = 'O')
32622 ) AND
32623 (l_bflow_method_code = 'PRIOR_ENTRY')
32624 )
32625 THEN
32626 IF
32627 --
32628 1 = 2
32629 --
32630 THEN
32631 xla_accounting_err_pkg.build_message
32632 (p_appli_s_name => 'XLA'
32633 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32634 ,p_token_1 => 'LINE_NUMBER'
32635 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32636 ,p_token_2 => 'LINE_TYPE_NAME'
32637 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32638 l_component_type
32639 ,l_component_code
32640 ,l_component_type_code
32641 ,l_component_appl_id
32642 ,l_amb_context_code
32643 ,l_entity_code
32644 ,l_event_class_code
32645 )
32646 ,p_token_3 => 'OWNER'
32647 ,p_value_3 => xla_lookups_pkg.get_meaning(
32648 p_lookup_type => 'XLA_OWNER_TYPE'
32649 ,p_lookup_code => l_component_type_code
32650 )
32651 ,p_token_4 => 'PRODUCT_NAME'
32652 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32653 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32654 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32655 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32656 ,p_ae_header_id => NULL
32657 );
32658
32659 IF (C_LEVEL_ERROR>= g_log_level) THEN
32660 trace
32661 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32662 ,p_level => C_LEVEL_ERROR
32663 ,p_module => l_log_module);
32664 END IF;
32665 END IF;
32666 END IF;
32667 --
32668 --
32669 ------------------------------------------------------------------------------------------------
32670 -- 4219869 Business Flow
32671 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32672 -- Prior Entry. Currently, the following code is always generated.
32673 ------------------------------------------------------------------------------------------------
32674 XLA_AE_LINES_PKG.ValidateCurrentLine;
32675
32676 ------------------------------------------------------------------------------------
32677 -- 4219869 Business Flow
32678 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32679 ------------------------------------------------------------------------------------
32680 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32681
32682 ----------------------------------------------------------------------------------
32683 -- 4219869 Business Flow
32684 -- Update journal entry status -- Need to generate this within IF <condition>
32685 ----------------------------------------------------------------------------------
32686 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32687 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32688 ,p_balance_type_code => l_balance_type_code
32689 );
32690
32691 -------------------------------------------------------------------------------------------
32692 -- 4262811 - Generate the Accrual Reversal lines
32693 -------------------------------------------------------------------------------------------
32694 BEGIN
32695 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32696 (g_array_event(p_event_id).array_value_num('header_index'));
32697 IF l_acc_rev_flag IS NULL THEN
32698 l_acc_rev_flag := 'N';
32699 END IF;
32700 EXCEPTION
32701 WHEN OTHERS THEN
32702 l_acc_rev_flag := 'N';
32703 END;
32704 --
32705 IF (l_acc_rev_flag = 'Y') THEN
32706
32707 -- 4645092 ------------------------------------------------------------------------------
32708 -- To allow MPA report to determine if it should generate report process
32709 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32710 ------------------------------------------------------------------------------------------
32711
32712 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32713 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32714 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32715 -- call ADRs
32716 -- Bug 4922099
32717 --
32718 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32719 (NVL(l_actual_upg_option, 'N') = 'O') OR
32720 (NVL(l_enc_upg_option, 'N') = 'O')
32721 )
32722 THEN
32723 NULL;
32724 --
32725 --
32726
32727 l_ccid := AcctDerRule_6(
32728 p_application_id => p_application_id
32729 , p_ae_header_id => l_ae_header_id
32730 , p_source_11 => p_source_11
32731 , x_transaction_coa_id => l_adr_transaction_coa_id
32732 , x_accounting_coa_id => l_adr_accounting_coa_id
32733 , x_value_type_code => l_adr_value_type_code
32734 , p_side => 'NA'
32735 );
32736
32737 xla_ae_lines_pkg.set_ccid(
32738 p_code_combination_id => l_ccid
32739 , p_value_type_code => l_adr_value_type_code
32740 , p_transaction_coa_id => l_adr_transaction_coa_id
32741 , p_accounting_coa_id => l_adr_accounting_coa_id
32742 , p_adr_code => 'CST_DEFAULT'
32743 , p_adr_type_code => 'S'
32744 , p_component_type => l_component_type
32745 , p_component_code => l_component_code
32746 , p_component_type_code => l_component_type_code
32747 , p_component_appl_id => l_component_appl_id
32748 , p_amb_context_code => l_amb_context_code
32749 , p_side => 'NA'
32750 );
32751
32752
32753 --
32754 --
32755 END IF;
32756
32757 --
32758 -- Update the line information that should be overwritten
32759 --
32760 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32761 p_header_num => 1);
32762 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32763
32764 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32765
32766 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32767 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32768 END IF;
32769
32770 --
32771 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32772 --
32773 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32774 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32775 ELSE
32776 ---------------------------------------------------------------------------------------------------
32777 -- 4262811a Switch Sign
32778 ---------------------------------------------------------------------------------------------------
32779 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32780 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32781 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32782 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32783 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32784 -- 5132302
32785 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32786 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32787
32788 END IF;
32789
32790 -- 4955764
32791 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32792 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32793
32794
32795 XLA_AE_LINES_PKG.ValidateCurrentLine;
32796 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32797
32798 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32799 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32800 ,p_balance_type_code => l_balance_type_code);
32801
32802 END IF;
32803
32804 -----------------------------------------------------------------------------------------
32805 -- 4262811 Multiperiod Accounting
32806 -----------------------------------------------------------------------------------------
32807 -- No MPA option is assigned.
32808
32809
32810 END IF;
32811 END IF;
32812 --
32813
32814 --
32815 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32816 trace
32817 (p_msg => 'END of AcctLineType_83'
32818 ,p_level => C_LEVEL_PROCEDURE
32819 ,p_module => l_log_module);
32820 END IF;
32821 --
32822 EXCEPTION
32823 WHEN xla_exceptions_pkg.application_exception THEN
32824 RAISE;
32825 WHEN OTHERS THEN
32826 xla_exceptions_pkg.raise_message
32827 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_83');
32828 END AcctLineType_83;
32829 --
32830
32831 ---------------------------------------
32832 --
32833 -- PRIVATE FUNCTION
32834 -- AcctLineType_84
32835 --
32836 ---------------------------------------
32837 PROCEDURE AcctLineType_84 (
32838 p_application_id IN NUMBER
32839 ,p_event_id IN NUMBER
32840 ,p_calculate_acctd_flag IN VARCHAR2
32841 ,p_calculate_g_l_flag IN VARCHAR2
32842 ,p_actual_flag IN OUT VARCHAR2
32843 ,p_balance_type_code OUT VARCHAR2
32844 ,p_gain_or_loss_ref OUT VARCHAR2
32845
32846 --TRANSACTION_ID
32847 , p_source_1 IN NUMBER
32848 --Item Concatenated Segments
32849 , p_source_2 IN VARCHAR2
32850 --Transaction Quantity
32851 , p_source_3 IN NUMBER
32852 --Transaction Unit of Measure Code
32853 , p_source_4 IN VARCHAR2
32854 --Inventory Transaction Type Description
32855 , p_source_5 IN VARCHAR2
32856 --Cost Management Default Account
32857 , p_source_11 IN NUMBER
32858 --Applied to Application ID
32859 , p_source_79 IN NUMBER
32860 --Applied to Distribution Link Type
32861 , p_source_80 IN VARCHAR2
32862 --Applied to Entity Code
32863 , p_source_81 IN VARCHAR2
32864 --Applied To Purchase Document Identifier
32865 , p_source_83 IN NUMBER
32866 --DISTRIBUTION_IDENTIFIER
32867 , p_source_84 IN NUMBER
32868 --Distribution Type
32869 , p_source_85 IN VARCHAR2
32870 , p_source_85_meaning IN VARCHAR2
32871 --PO Budget Account
32872 , p_source_86 IN NUMBER
32873 --Encumbrance Reversal Amount Entered
32874 , p_source_87 IN NUMBER
32875 --Entered Currency Code
32876 , p_source_88 IN VARCHAR2
32877 --Transaction Encumbrance Reversal Amount
32878 , p_source_89 IN NUMBER
32879 --Entered Amount
32880 , p_source_91 IN NUMBER
32881 --Currency Conversion Date
32882 , p_source_92 IN DATE
32883 --Currency Conversion Rate
32884 , p_source_93 IN NUMBER
32885 --Currency Conversion Type
32886 , p_source_94 IN VARCHAR2
32887 --Accounted Amount
32888 , p_source_95 IN NUMBER
32889 --Purchasing Encumbrance Type Identifier
32890 , p_source_96 IN NUMBER
32891 --Accounting Line Type
32892 , p_source_97 IN NUMBER
32893 --Costing Encumbrance Upgrade Option
32894 , p_source_100 IN VARCHAR2
32895 --TXN_PO_DISTRIBUTION_ID
32896 , p_source_101 IN NUMBER
32897 )
32898 IS
32899
32900 l_component_type VARCHAR2(80);
32901 l_component_code VARCHAR2(30);
32902 l_component_type_code VARCHAR2(1);
32903 l_component_appl_id INTEGER;
32904 l_amb_context_code VARCHAR2(30);
32905 l_entity_code VARCHAR2(30);
32906 l_event_class_code VARCHAR2(30);
32907 l_ae_header_id NUMBER;
32908 l_event_type_code VARCHAR2(30);
32909 l_line_definition_code VARCHAR2(30);
32910 l_line_definition_owner_code VARCHAR2(1);
32911 --
32912 -- adr variables
32913 l_segment VARCHAR2(30);
32914 l_ccid NUMBER;
32915 l_adr_transaction_coa_id NUMBER;
32916 l_adr_accounting_coa_id NUMBER;
32917 l_adr_flexfield_segment_code VARCHAR2(30);
32918 l_adr_flex_value_set_id NUMBER;
32919 l_adr_value_type_code VARCHAR2(30);
32920 l_adr_value_combination_id NUMBER;
32921 l_adr_value_segment_code VARCHAR2(30);
32922
32923 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32924 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32925 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32926 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32927
32928 -- 4262811 Variables ------------------------------------------------------------------------------------------
32929 l_entered_amt_idx NUMBER;
32930 l_accted_amt_idx NUMBER;
32931 l_acc_rev_flag VARCHAR2(1);
32932 l_accrual_line_num NUMBER;
32933 l_tmp_amt NUMBER;
32934 l_acc_rev_natural_side_code VARCHAR2(1);
32935
32936 l_num_entries NUMBER;
32937 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32938 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32939 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32940 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32941 l_recog_line_1 NUMBER;
32942 l_recog_line_2 NUMBER;
32943
32944 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32945 l_bflow_applied_to_amt NUMBER; -- 5132302
32946 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32947
32948 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32949
32950 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32951 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32952
32953 ---------------------------------------------------------------------------------------------------------------
32954
32955
32956 --
32957 -- bulk performance
32958 --
32959 l_balance_type_code VARCHAR2(1);
32960 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32961 l_log_module VARCHAR2(240);
32962
32963 --
32964 -- Upgrade strategy
32965 --
32966 l_actual_upg_option VARCHAR2(1);
32967 l_enc_upg_option VARCHAR2(1);
32968
32969 --
32970 BEGIN
32971 --
32972 IF g_log_enabled THEN
32973 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_84';
32974 END IF;
32975 --
32976 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32977
32978 trace
32979 (p_msg => 'BEGIN of AcctLineType_84'
32980 ,p_level => C_LEVEL_PROCEDURE
32981 ,p_module => l_log_module);
32982
32983 END IF;
32984 --
32985 l_component_type := 'AMB_JLT';
32986 l_component_code := 'COST_VARIANCE';
32987 l_component_type_code := 'S';
32988 l_component_appl_id := 707;
32989 l_amb_context_code := 'DEFAULT';
32990 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
32991 l_event_class_code := 'PURCHASE_ORDER';
32992 l_event_type_code := 'LOG_RET_RI_INV';
32993 l_line_definition_owner_code := 'S';
32994 l_line_definition_code := 'PI_LOG_RET_RI_INV';
32995 --
32996 l_balance_type_code := 'A';
32997 l_segment := NULL;
32998 l_ccid := NULL;
32999 l_adr_transaction_coa_id := NULL;
33000 l_adr_accounting_coa_id := NULL;
33001 l_adr_flexfield_segment_code := NULL;
33002 l_adr_flex_value_set_id := NULL;
33003 l_adr_value_type_code := NULL;
33004 l_adr_value_combination_id := NULL;
33005 l_adr_value_segment_code := NULL;
33006
33007 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33008 l_bflow_class_code := ''; -- 4219869 Business Flow
33009 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33010 l_budgetary_control_flag := 'N';
33011
33012 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33013 l_bflow_applied_to_amt := NULL; -- 5132302
33014 l_entered_amt_idx := NULL; -- 4262811
33015 l_accted_amt_idx := NULL; -- 4262811
33016 l_acc_rev_flag := NULL; -- 4262811
33017 l_accrual_line_num := NULL; -- 4262811
33018 l_tmp_amt := NULL; -- 4262811
33019 --
33020
33021 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33022 l_balance_type_code <> 'B' THEN
33023 IF NVL(p_source_97,9E125) = 13
33024 THEN
33025
33026 --
33027 XLA_AE_LINES_PKG.SetNewLine;
33028
33029 p_balance_type_code := l_balance_type_code;
33030 -- set the flag so later we will know whether the gain loss line needs to be created
33031
33032 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33033 p_actual_flag :='A';
33034 END IF;
33035
33036 --
33037 -- bulk performance
33038 --
33039 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33040 p_header_num => 0); -- 4262811
33041 --
33042 -- set accounting line options
33043 --
33044 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33045 p_natural_side_code => 'D'
33046 , p_gain_or_loss_flag => 'N'
33047 , p_gl_transfer_mode_code => 'S'
33048 , p_acct_entry_type_code => 'A'
33049 , p_switch_side_flag => 'Y'
33050 , p_merge_duplicate_code => 'N'
33051 );
33052 --
33053 l_acc_rev_natural_side_code := 'C'; -- 4262811
33054 --
33055 --
33056 -- set accounting line type info
33057 --
33058 xla_ae_lines_pkg.SetAcctLineType
33059 (p_component_type => l_component_type
33060 ,p_event_type_code => l_event_type_code
33061 ,p_line_definition_owner_code => l_line_definition_owner_code
33062 ,p_line_definition_code => l_line_definition_code
33063 ,p_accounting_line_code => l_component_code
33064 ,p_accounting_line_type_code => l_component_type_code
33065 ,p_accounting_line_appl_id => l_component_appl_id
33066 ,p_amb_context_code => l_amb_context_code
33067 ,p_entity_code => l_entity_code
33068 ,p_event_class_code => l_event_class_code);
33069 --
33070 -- set accounting class
33071 --
33072 xla_ae_lines_pkg.SetAcctClass(
33073 p_accounting_class_code => 'COST_VARIANCE'
33074 , p_ae_header_id => l_ae_header_id
33075 );
33076
33077 --
33078 -- set rounding class
33079 --
33080 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33081 'COST_VARIANCE';
33082
33083 --
33084 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33085 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33086 --
33087 -- bulk performance
33088 --
33089 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33090
33091 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33092 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33093
33094 -- 4955764
33095 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33096 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33097
33098 -- 4458381 Public Sector Enh
33099
33100 --
33101 -- set accounting attributes for the line type
33102 --
33103 l_entered_amt_idx := 17;
33104 l_accted_amt_idx := 22;
33105 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33106 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
33107 l_rec_acct_attrs.array_num_value(1) := p_source_79;
33108 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
33109 l_rec_acct_attrs.array_char_value(2) := p_source_80;
33110 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
33111 l_rec_acct_attrs.array_char_value(3) := p_source_81;
33112 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
33113 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
33114 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
33115 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
33116 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
33117 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
33118 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
33119 l_rec_acct_attrs.array_char_value(7) := p_source_85;
33120 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
33121 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
33122 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
33123 l_rec_acct_attrs.array_num_value(9) := p_source_87;
33124 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
33125 l_rec_acct_attrs.array_char_value(10) := p_source_88;
33126 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
33127 l_rec_acct_attrs.array_num_value(11) := p_source_89;
33128 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
33129 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
33130 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
33131 l_rec_acct_attrs.array_num_value(13) := p_source_87;
33132 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
33133 l_rec_acct_attrs.array_char_value(14) := p_source_88;
33134 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
33135 l_rec_acct_attrs.array_num_value(15) := p_source_89;
33136 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
33137 l_rec_acct_attrs.array_char_value(16) := p_source_100;
33138 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
33139 l_rec_acct_attrs.array_num_value(17) := p_source_91;
33140 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
33141 l_rec_acct_attrs.array_char_value(18) := p_source_88;
33142 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
33143 l_rec_acct_attrs.array_date_value(19) := p_source_92;
33144 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
33145 l_rec_acct_attrs.array_num_value(20) := p_source_93;
33146 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
33147 l_rec_acct_attrs.array_char_value(21) := p_source_94;
33148 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
33149 l_rec_acct_attrs.array_num_value(22) := p_source_95;
33150 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
33151 l_rec_acct_attrs.array_num_value(23) := p_source_96;
33152 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
33153 l_rec_acct_attrs.array_num_value(24) := p_source_96;
33154
33155 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33156 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33157
33158 ---------------------------------------------------------------------------------------------------------------
33159 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33160 ---------------------------------------------------------------------------------------------------------------
33161 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33162
33163 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33164 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33165
33166 IF xla_accounting_cache_pkg.GetValueChar
33167 (p_source_code => 'LEDGER_CATEGORY_CODE'
33168 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33169 AND l_bflow_method_code = 'PRIOR_ENTRY'
33170 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33171 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33172 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33173 )
33174 THEN
33175 xla_ae_lines_pkg.BflowUpgEntry
33176 (p_business_method_code => l_bflow_method_code
33177 ,p_business_class_code => l_bflow_class_code
33178 ,p_balance_type => l_balance_type_code);
33179 ELSE
33180 NULL;
33181 -- No business flow processing for business flow method of NONE.
33182 END IF;
33183
33184 --
33185 -- call analytical criteria
33186 --
33187
33188 --
33189 -- call description
33190 --
33191
33192 xla_ae_lines_pkg.SetLineDescription(
33193 p_ae_header_id => l_ae_header_id
33194 ,p_description => Description_1 (
33195 p_application_id => p_application_id
33196 , p_ae_header_id => l_ae_header_id
33197 , p_source_1 => p_source_1
33198 , p_source_2 => p_source_2
33199 , p_source_3 => p_source_3
33200 , p_source_4 => p_source_4
33201 , p_source_5 => p_source_5
33202 )
33203 );
33204
33205
33206 --
33207 -- call ADRs
33208 -- Bug 4922099
33209 --
33210 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33211 (NVL(l_actual_upg_option, 'N') = 'O') OR
33212 (NVL(l_enc_upg_option, 'N') = 'O')
33213 )
33214 THEN
33215 NULL;
33216 --
33217 --
33218
33219 l_ccid := AcctDerRule_6(
33220 p_application_id => p_application_id
33221 , p_ae_header_id => l_ae_header_id
33222 , p_source_11 => p_source_11
33223 , x_transaction_coa_id => l_adr_transaction_coa_id
33224 , x_accounting_coa_id => l_adr_accounting_coa_id
33225 , x_value_type_code => l_adr_value_type_code
33226 , p_side => 'NA'
33227 );
33228
33229 xla_ae_lines_pkg.set_ccid(
33230 p_code_combination_id => l_ccid
33231 , p_value_type_code => l_adr_value_type_code
33232 , p_transaction_coa_id => l_adr_transaction_coa_id
33233 , p_accounting_coa_id => l_adr_accounting_coa_id
33234 , p_adr_code => 'CST_DEFAULT'
33235 , p_adr_type_code => 'S'
33236 , p_component_type => l_component_type
33237 , p_component_code => l_component_code
33238 , p_component_type_code => l_component_type_code
33239 , p_component_appl_id => l_component_appl_id
33240 , p_amb_context_code => l_amb_context_code
33241 , p_side => 'NA'
33242 );
33243
33244
33245 --
33246 --
33247 END IF;
33248 --
33249 -- Bug 4922099
33250 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33251 (NVL(l_enc_upg_option, 'N') = 'O')
33252 ) AND
33253 (l_bflow_method_code = 'PRIOR_ENTRY')
33254 )
33255 THEN
33256 IF
33257 --
33258 1 = 2
33259 --
33260 THEN
33261 xla_accounting_err_pkg.build_message
33262 (p_appli_s_name => 'XLA'
33263 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33264 ,p_token_1 => 'LINE_NUMBER'
33265 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33266 ,p_token_2 => 'LINE_TYPE_NAME'
33267 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33268 l_component_type
33269 ,l_component_code
33270 ,l_component_type_code
33271 ,l_component_appl_id
33272 ,l_amb_context_code
33273 ,l_entity_code
33274 ,l_event_class_code
33275 )
33276 ,p_token_3 => 'OWNER'
33277 ,p_value_3 => xla_lookups_pkg.get_meaning(
33278 p_lookup_type => 'XLA_OWNER_TYPE'
33279 ,p_lookup_code => l_component_type_code
33280 )
33281 ,p_token_4 => 'PRODUCT_NAME'
33282 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33283 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33284 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33285 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33286 ,p_ae_header_id => NULL
33287 );
33288
33289 IF (C_LEVEL_ERROR>= g_log_level) THEN
33290 trace
33291 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33292 ,p_level => C_LEVEL_ERROR
33293 ,p_module => l_log_module);
33294 END IF;
33295 END IF;
33296 END IF;
33297 --
33298 --
33299 ------------------------------------------------------------------------------------------------
33300 -- 4219869 Business Flow
33301 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33302 -- Prior Entry. Currently, the following code is always generated.
33303 ------------------------------------------------------------------------------------------------
33304 XLA_AE_LINES_PKG.ValidateCurrentLine;
33305
33306 ------------------------------------------------------------------------------------
33307 -- 4219869 Business Flow
33308 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33309 ------------------------------------------------------------------------------------
33310 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33311
33312 ----------------------------------------------------------------------------------
33313 -- 4219869 Business Flow
33314 -- Update journal entry status -- Need to generate this within IF <condition>
33315 ----------------------------------------------------------------------------------
33316 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33317 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33318 ,p_balance_type_code => l_balance_type_code
33319 );
33320
33321 -------------------------------------------------------------------------------------------
33322 -- 4262811 - Generate the Accrual Reversal lines
33323 -------------------------------------------------------------------------------------------
33324 BEGIN
33325 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33326 (g_array_event(p_event_id).array_value_num('header_index'));
33327 IF l_acc_rev_flag IS NULL THEN
33328 l_acc_rev_flag := 'N';
33329 END IF;
33330 EXCEPTION
33331 WHEN OTHERS THEN
33332 l_acc_rev_flag := 'N';
33333 END;
33334 --
33335 IF (l_acc_rev_flag = 'Y') THEN
33336
33337 -- 4645092 ------------------------------------------------------------------------------
33338 -- To allow MPA report to determine if it should generate report process
33339 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33340 ------------------------------------------------------------------------------------------
33341
33342 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33343 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33344 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33345 -- call ADRs
33346 -- Bug 4922099
33347 --
33348 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33349 (NVL(l_actual_upg_option, 'N') = 'O') OR
33350 (NVL(l_enc_upg_option, 'N') = 'O')
33351 )
33352 THEN
33353 NULL;
33354 --
33355 --
33356
33357 l_ccid := AcctDerRule_6(
33358 p_application_id => p_application_id
33359 , p_ae_header_id => l_ae_header_id
33360 , p_source_11 => p_source_11
33361 , x_transaction_coa_id => l_adr_transaction_coa_id
33362 , x_accounting_coa_id => l_adr_accounting_coa_id
33363 , x_value_type_code => l_adr_value_type_code
33364 , p_side => 'NA'
33365 );
33366
33367 xla_ae_lines_pkg.set_ccid(
33368 p_code_combination_id => l_ccid
33369 , p_value_type_code => l_adr_value_type_code
33370 , p_transaction_coa_id => l_adr_transaction_coa_id
33371 , p_accounting_coa_id => l_adr_accounting_coa_id
33372 , p_adr_code => 'CST_DEFAULT'
33373 , p_adr_type_code => 'S'
33374 , p_component_type => l_component_type
33375 , p_component_code => l_component_code
33376 , p_component_type_code => l_component_type_code
33377 , p_component_appl_id => l_component_appl_id
33378 , p_amb_context_code => l_amb_context_code
33379 , p_side => 'NA'
33380 );
33381
33382
33383 --
33384 --
33385 END IF;
33386
33387 --
33388 -- Update the line information that should be overwritten
33389 --
33390 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33391 p_header_num => 1);
33392 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33393
33394 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33395
33396 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33397 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33398 END IF;
33399
33400 --
33401 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33402 --
33403 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33404 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33405 ELSE
33406 ---------------------------------------------------------------------------------------------------
33407 -- 4262811a Switch Sign
33408 ---------------------------------------------------------------------------------------------------
33409 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33410 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33411 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33412 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33413 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33414 -- 5132302
33415 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33416 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33417
33418 END IF;
33419
33420 -- 4955764
33421 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33422 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33423
33424
33425 XLA_AE_LINES_PKG.ValidateCurrentLine;
33426 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33427
33428 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33429 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33430 ,p_balance_type_code => l_balance_type_code);
33431
33432 END IF;
33433
33434 -----------------------------------------------------------------------------------------
33435 -- 4262811 Multiperiod Accounting
33436 -----------------------------------------------------------------------------------------
33437 -- No MPA option is assigned.
33438
33439
33440 END IF;
33441 END IF;
33442 --
33443
33444 --
33445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33446 trace
33447 (p_msg => 'END of AcctLineType_84'
33448 ,p_level => C_LEVEL_PROCEDURE
33449 ,p_module => l_log_module);
33450 END IF;
33451 --
33452 EXCEPTION
33453 WHEN xla_exceptions_pkg.application_exception THEN
33454 RAISE;
33455 WHEN OTHERS THEN
33456 xla_exceptions_pkg.raise_message
33457 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_84');
33458 END AcctLineType_84;
33459 --
33460
33461 ---------------------------------------
33462 --
33463 -- PRIVATE FUNCTION
33464 -- AcctLineType_85
33465 --
33466 ---------------------------------------
33467 PROCEDURE AcctLineType_85 (
33468 p_application_id IN NUMBER
33469 ,p_event_id IN NUMBER
33470 ,p_calculate_acctd_flag IN VARCHAR2
33471 ,p_calculate_g_l_flag IN VARCHAR2
33472 ,p_actual_flag IN OUT VARCHAR2
33473 ,p_balance_type_code OUT VARCHAR2
33474 ,p_gain_or_loss_ref OUT VARCHAR2
33475
33476 --TRANSACTION_ID
33477 , p_source_1 IN NUMBER
33478 --Item Concatenated Segments
33479 , p_source_2 IN VARCHAR2
33480 --Transaction Quantity
33481 , p_source_3 IN NUMBER
33482 --Transaction Unit of Measure Code
33483 , p_source_4 IN VARCHAR2
33484 --Inventory Transaction Type Description
33485 , p_source_5 IN VARCHAR2
33486 --Cost Management Default Account
33487 , p_source_11 IN NUMBER
33488 --Applied to Application ID
33489 , p_source_79 IN NUMBER
33490 --Applied to Distribution Link Type
33491 , p_source_80 IN VARCHAR2
33492 --Applied to Entity Code
33493 , p_source_81 IN VARCHAR2
33494 --Applied To Purchase Document Identifier
33495 , p_source_83 IN NUMBER
33496 --DISTRIBUTION_IDENTIFIER
33497 , p_source_84 IN NUMBER
33498 --Distribution Type
33499 , p_source_85 IN VARCHAR2
33500 , p_source_85_meaning IN VARCHAR2
33501 --PO Budget Account
33502 , p_source_86 IN NUMBER
33503 --Encumbrance Reversal Amount Entered
33504 , p_source_87 IN NUMBER
33505 --Entered Currency Code
33506 , p_source_88 IN VARCHAR2
33507 --Transaction Encumbrance Reversal Amount
33508 , p_source_89 IN NUMBER
33509 --Entered Amount
33510 , p_source_91 IN NUMBER
33511 --Currency Conversion Date
33512 , p_source_92 IN DATE
33513 --Currency Conversion Rate
33514 , p_source_93 IN NUMBER
33515 --Currency Conversion Type
33516 , p_source_94 IN VARCHAR2
33517 --Accounted Amount
33518 , p_source_95 IN NUMBER
33519 --Purchasing Encumbrance Type Identifier
33520 , p_source_96 IN NUMBER
33521 --Accounting Line Type
33522 , p_source_97 IN NUMBER
33523 --Costing Encumbrance Upgrade Option
33524 , p_source_100 IN VARCHAR2
33525 --TXN_PO_DISTRIBUTION_ID
33526 , p_source_101 IN NUMBER
33527 )
33528 IS
33529
33530 l_component_type VARCHAR2(80);
33531 l_component_code VARCHAR2(30);
33532 l_component_type_code VARCHAR2(1);
33533 l_component_appl_id INTEGER;
33534 l_amb_context_code VARCHAR2(30);
33535 l_entity_code VARCHAR2(30);
33536 l_event_class_code VARCHAR2(30);
33537 l_ae_header_id NUMBER;
33538 l_event_type_code VARCHAR2(30);
33539 l_line_definition_code VARCHAR2(30);
33540 l_line_definition_owner_code VARCHAR2(1);
33541 --
33542 -- adr variables
33543 l_segment VARCHAR2(30);
33544 l_ccid NUMBER;
33545 l_adr_transaction_coa_id NUMBER;
33546 l_adr_accounting_coa_id NUMBER;
33547 l_adr_flexfield_segment_code VARCHAR2(30);
33548 l_adr_flex_value_set_id NUMBER;
33549 l_adr_value_type_code VARCHAR2(30);
33550 l_adr_value_combination_id NUMBER;
33551 l_adr_value_segment_code VARCHAR2(30);
33552
33553 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
33554 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
33555 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
33556 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
33557
33558 -- 4262811 Variables ------------------------------------------------------------------------------------------
33559 l_entered_amt_idx NUMBER;
33560 l_accted_amt_idx NUMBER;
33561 l_acc_rev_flag VARCHAR2(1);
33562 l_accrual_line_num NUMBER;
33563 l_tmp_amt NUMBER;
33564 l_acc_rev_natural_side_code VARCHAR2(1);
33565
33566 l_num_entries NUMBER;
33567 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
33568 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
33569 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
33570 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
33571 l_recog_line_1 NUMBER;
33572 l_recog_line_2 NUMBER;
33573
33574 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
33575 l_bflow_applied_to_amt NUMBER; -- 5132302
33576 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
33577
33578 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
33579
33580 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
33581 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
33582
33583 ---------------------------------------------------------------------------------------------------------------
33584
33585
33586 --
33587 -- bulk performance
33588 --
33589 l_balance_type_code VARCHAR2(1);
33590 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
33591 l_log_module VARCHAR2(240);
33592
33593 --
33594 -- Upgrade strategy
33595 --
33596 l_actual_upg_option VARCHAR2(1);
33597 l_enc_upg_option VARCHAR2(1);
33598
33599 --
33600 BEGIN
33601 --
33602 IF g_log_enabled THEN
33603 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_85';
33604 END IF;
33605 --
33606 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33607
33608 trace
33609 (p_msg => 'BEGIN of AcctLineType_85'
33610 ,p_level => C_LEVEL_PROCEDURE
33611 ,p_module => l_log_module);
33612
33613 END IF;
33614 --
33615 l_component_type := 'AMB_JLT';
33616 l_component_code := 'COST_VARIANCE';
33617 l_component_type_code := 'S';
33618 l_component_appl_id := 707;
33619 l_amb_context_code := 'DEFAULT';
33620 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
33621 l_event_class_code := 'PURCHASE_ORDER';
33622 l_event_type_code := 'PO_DEL_ADJ';
33623 l_line_definition_owner_code := 'S';
33624 l_line_definition_code := 'PI_PO_DEL_ADJ';
33625 --
33626 l_balance_type_code := 'A';
33627 l_segment := NULL;
33628 l_ccid := NULL;
33629 l_adr_transaction_coa_id := NULL;
33630 l_adr_accounting_coa_id := NULL;
33631 l_adr_flexfield_segment_code := NULL;
33632 l_adr_flex_value_set_id := NULL;
33633 l_adr_value_type_code := NULL;
33634 l_adr_value_combination_id := NULL;
33635 l_adr_value_segment_code := NULL;
33636
33637 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33638 l_bflow_class_code := ''; -- 4219869 Business Flow
33639 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33640 l_budgetary_control_flag := 'N';
33641
33642 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33643 l_bflow_applied_to_amt := NULL; -- 5132302
33644 l_entered_amt_idx := NULL; -- 4262811
33645 l_accted_amt_idx := NULL; -- 4262811
33646 l_acc_rev_flag := NULL; -- 4262811
33647 l_accrual_line_num := NULL; -- 4262811
33648 l_tmp_amt := NULL; -- 4262811
33649 --
33650
33651 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33652 l_balance_type_code <> 'B' THEN
33653 IF NVL(p_source_97,9E125) = 13
33654 THEN
33655
33656 --
33657 XLA_AE_LINES_PKG.SetNewLine;
33658
33659 p_balance_type_code := l_balance_type_code;
33660 -- set the flag so later we will know whether the gain loss line needs to be created
33661
33662 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33663 p_actual_flag :='A';
33664 END IF;
33665
33666 --
33667 -- bulk performance
33668 --
33669 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33670 p_header_num => 0); -- 4262811
33671 --
33672 -- set accounting line options
33673 --
33674 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33675 p_natural_side_code => 'D'
33676 , p_gain_or_loss_flag => 'N'
33677 , p_gl_transfer_mode_code => 'S'
33678 , p_acct_entry_type_code => 'A'
33679 , p_switch_side_flag => 'Y'
33680 , p_merge_duplicate_code => 'N'
33681 );
33682 --
33683 l_acc_rev_natural_side_code := 'C'; -- 4262811
33684 --
33685 --
33686 -- set accounting line type info
33687 --
33688 xla_ae_lines_pkg.SetAcctLineType
33689 (p_component_type => l_component_type
33690 ,p_event_type_code => l_event_type_code
33691 ,p_line_definition_owner_code => l_line_definition_owner_code
33692 ,p_line_definition_code => l_line_definition_code
33693 ,p_accounting_line_code => l_component_code
33694 ,p_accounting_line_type_code => l_component_type_code
33695 ,p_accounting_line_appl_id => l_component_appl_id
33696 ,p_amb_context_code => l_amb_context_code
33697 ,p_entity_code => l_entity_code
33698 ,p_event_class_code => l_event_class_code);
33699 --
33700 -- set accounting class
33701 --
33702 xla_ae_lines_pkg.SetAcctClass(
33703 p_accounting_class_code => 'COST_VARIANCE'
33704 , p_ae_header_id => l_ae_header_id
33705 );
33706
33707 --
33708 -- set rounding class
33709 --
33710 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33711 'COST_VARIANCE';
33712
33713 --
33714 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33715 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33716 --
33717 -- bulk performance
33718 --
33719 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33720
33721 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33722 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33723
33724 -- 4955764
33725 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33726 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33727
33728 -- 4458381 Public Sector Enh
33729
33730 --
33731 -- set accounting attributes for the line type
33732 --
33733 l_entered_amt_idx := 17;
33734 l_accted_amt_idx := 22;
33735 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33736 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
33737 l_rec_acct_attrs.array_num_value(1) := p_source_79;
33738 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
33739 l_rec_acct_attrs.array_char_value(2) := p_source_80;
33740 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
33741 l_rec_acct_attrs.array_char_value(3) := p_source_81;
33742 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
33743 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
33744 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
33745 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
33746 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
33747 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
33748 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
33749 l_rec_acct_attrs.array_char_value(7) := p_source_85;
33750 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
33751 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
33752 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
33753 l_rec_acct_attrs.array_num_value(9) := p_source_87;
33754 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
33755 l_rec_acct_attrs.array_char_value(10) := p_source_88;
33756 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
33757 l_rec_acct_attrs.array_num_value(11) := p_source_89;
33758 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
33759 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
33760 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
33761 l_rec_acct_attrs.array_num_value(13) := p_source_87;
33762 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
33763 l_rec_acct_attrs.array_char_value(14) := p_source_88;
33764 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
33765 l_rec_acct_attrs.array_num_value(15) := p_source_89;
33766 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
33767 l_rec_acct_attrs.array_char_value(16) := p_source_100;
33768 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
33769 l_rec_acct_attrs.array_num_value(17) := p_source_91;
33770 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
33771 l_rec_acct_attrs.array_char_value(18) := p_source_88;
33772 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
33773 l_rec_acct_attrs.array_date_value(19) := p_source_92;
33774 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
33775 l_rec_acct_attrs.array_num_value(20) := p_source_93;
33776 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
33777 l_rec_acct_attrs.array_char_value(21) := p_source_94;
33778 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
33779 l_rec_acct_attrs.array_num_value(22) := p_source_95;
33780 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
33781 l_rec_acct_attrs.array_num_value(23) := p_source_96;
33782 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
33783 l_rec_acct_attrs.array_num_value(24) := p_source_96;
33784
33785 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33786 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33787
33788 ---------------------------------------------------------------------------------------------------------------
33789 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33790 ---------------------------------------------------------------------------------------------------------------
33791 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33792
33793 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33794 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33795
33796 IF xla_accounting_cache_pkg.GetValueChar
33797 (p_source_code => 'LEDGER_CATEGORY_CODE'
33798 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33799 AND l_bflow_method_code = 'PRIOR_ENTRY'
33800 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33801 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33802 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33803 )
33804 THEN
33805 xla_ae_lines_pkg.BflowUpgEntry
33806 (p_business_method_code => l_bflow_method_code
33807 ,p_business_class_code => l_bflow_class_code
33808 ,p_balance_type => l_balance_type_code);
33809 ELSE
33810 NULL;
33811 -- No business flow processing for business flow method of NONE.
33812 END IF;
33813
33814 --
33815 -- call analytical criteria
33816 --
33817
33818 --
33819 -- call description
33820 --
33821
33822 xla_ae_lines_pkg.SetLineDescription(
33823 p_ae_header_id => l_ae_header_id
33824 ,p_description => Description_1 (
33825 p_application_id => p_application_id
33826 , p_ae_header_id => l_ae_header_id
33827 , p_source_1 => p_source_1
33828 , p_source_2 => p_source_2
33829 , p_source_3 => p_source_3
33830 , p_source_4 => p_source_4
33831 , p_source_5 => p_source_5
33832 )
33833 );
33834
33835
33836 --
33837 -- call ADRs
33838 -- Bug 4922099
33839 --
33840 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33841 (NVL(l_actual_upg_option, 'N') = 'O') OR
33842 (NVL(l_enc_upg_option, 'N') = 'O')
33843 )
33844 THEN
33845 NULL;
33846 --
33847 --
33848
33849 l_ccid := AcctDerRule_6(
33850 p_application_id => p_application_id
33851 , p_ae_header_id => l_ae_header_id
33852 , p_source_11 => p_source_11
33853 , x_transaction_coa_id => l_adr_transaction_coa_id
33854 , x_accounting_coa_id => l_adr_accounting_coa_id
33855 , x_value_type_code => l_adr_value_type_code
33856 , p_side => 'NA'
33857 );
33858
33859 xla_ae_lines_pkg.set_ccid(
33860 p_code_combination_id => l_ccid
33861 , p_value_type_code => l_adr_value_type_code
33862 , p_transaction_coa_id => l_adr_transaction_coa_id
33863 , p_accounting_coa_id => l_adr_accounting_coa_id
33864 , p_adr_code => 'CST_DEFAULT'
33865 , p_adr_type_code => 'S'
33866 , p_component_type => l_component_type
33867 , p_component_code => l_component_code
33868 , p_component_type_code => l_component_type_code
33869 , p_component_appl_id => l_component_appl_id
33870 , p_amb_context_code => l_amb_context_code
33871 , p_side => 'NA'
33872 );
33873
33874
33875 --
33876 --
33877 END IF;
33878 --
33879 -- Bug 4922099
33880 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33881 (NVL(l_enc_upg_option, 'N') = 'O')
33882 ) AND
33883 (l_bflow_method_code = 'PRIOR_ENTRY')
33884 )
33885 THEN
33886 IF
33887 --
33888 1 = 2
33889 --
33890 THEN
33891 xla_accounting_err_pkg.build_message
33892 (p_appli_s_name => 'XLA'
33893 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33894 ,p_token_1 => 'LINE_NUMBER'
33895 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33896 ,p_token_2 => 'LINE_TYPE_NAME'
33897 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33898 l_component_type
33899 ,l_component_code
33900 ,l_component_type_code
33901 ,l_component_appl_id
33902 ,l_amb_context_code
33903 ,l_entity_code
33904 ,l_event_class_code
33905 )
33906 ,p_token_3 => 'OWNER'
33907 ,p_value_3 => xla_lookups_pkg.get_meaning(
33908 p_lookup_type => 'XLA_OWNER_TYPE'
33909 ,p_lookup_code => l_component_type_code
33910 )
33911 ,p_token_4 => 'PRODUCT_NAME'
33912 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33913 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33914 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33915 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33916 ,p_ae_header_id => NULL
33917 );
33918
33919 IF (C_LEVEL_ERROR>= g_log_level) THEN
33920 trace
33921 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33922 ,p_level => C_LEVEL_ERROR
33923 ,p_module => l_log_module);
33924 END IF;
33925 END IF;
33926 END IF;
33927 --
33928 --
33929 ------------------------------------------------------------------------------------------------
33930 -- 4219869 Business Flow
33931 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33932 -- Prior Entry. Currently, the following code is always generated.
33933 ------------------------------------------------------------------------------------------------
33934 XLA_AE_LINES_PKG.ValidateCurrentLine;
33935
33936 ------------------------------------------------------------------------------------
33937 -- 4219869 Business Flow
33938 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33939 ------------------------------------------------------------------------------------
33940 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33941
33942 ----------------------------------------------------------------------------------
33943 -- 4219869 Business Flow
33944 -- Update journal entry status -- Need to generate this within IF <condition>
33945 ----------------------------------------------------------------------------------
33946 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33947 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33948 ,p_balance_type_code => l_balance_type_code
33949 );
33950
33951 -------------------------------------------------------------------------------------------
33952 -- 4262811 - Generate the Accrual Reversal lines
33953 -------------------------------------------------------------------------------------------
33954 BEGIN
33955 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33956 (g_array_event(p_event_id).array_value_num('header_index'));
33957 IF l_acc_rev_flag IS NULL THEN
33958 l_acc_rev_flag := 'N';
33959 END IF;
33960 EXCEPTION
33961 WHEN OTHERS THEN
33962 l_acc_rev_flag := 'N';
33963 END;
33964 --
33965 IF (l_acc_rev_flag = 'Y') THEN
33966
33967 -- 4645092 ------------------------------------------------------------------------------
33968 -- To allow MPA report to determine if it should generate report process
33969 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33970 ------------------------------------------------------------------------------------------
33971
33972 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33973 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33974 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33975 -- call ADRs
33976 -- Bug 4922099
33977 --
33978 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33979 (NVL(l_actual_upg_option, 'N') = 'O') OR
33980 (NVL(l_enc_upg_option, 'N') = 'O')
33981 )
33982 THEN
33983 NULL;
33984 --
33985 --
33986
33987 l_ccid := AcctDerRule_6(
33988 p_application_id => p_application_id
33989 , p_ae_header_id => l_ae_header_id
33990 , p_source_11 => p_source_11
33991 , x_transaction_coa_id => l_adr_transaction_coa_id
33992 , x_accounting_coa_id => l_adr_accounting_coa_id
33993 , x_value_type_code => l_adr_value_type_code
33994 , p_side => 'NA'
33995 );
33996
33997 xla_ae_lines_pkg.set_ccid(
33998 p_code_combination_id => l_ccid
33999 , p_value_type_code => l_adr_value_type_code
34000 , p_transaction_coa_id => l_adr_transaction_coa_id
34001 , p_accounting_coa_id => l_adr_accounting_coa_id
34002 , p_adr_code => 'CST_DEFAULT'
34003 , p_adr_type_code => 'S'
34004 , p_component_type => l_component_type
34005 , p_component_code => l_component_code
34006 , p_component_type_code => l_component_type_code
34007 , p_component_appl_id => l_component_appl_id
34008 , p_amb_context_code => l_amb_context_code
34009 , p_side => 'NA'
34010 );
34011
34012
34013 --
34014 --
34015 END IF;
34016
34017 --
34018 -- Update the line information that should be overwritten
34019 --
34020 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34021 p_header_num => 1);
34022 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34023
34024 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34025
34026 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34027 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34028 END IF;
34029
34030 --
34031 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34032 --
34033 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34034 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34035 ELSE
34036 ---------------------------------------------------------------------------------------------------
34037 -- 4262811a Switch Sign
34038 ---------------------------------------------------------------------------------------------------
34039 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34040 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34041 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34042 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34043 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34044 -- 5132302
34045 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34046 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34047
34048 END IF;
34049
34050 -- 4955764
34051 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34052 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34053
34054
34055 XLA_AE_LINES_PKG.ValidateCurrentLine;
34056 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34057
34058 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34059 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34060 ,p_balance_type_code => l_balance_type_code);
34061
34062 END IF;
34063
34064 -----------------------------------------------------------------------------------------
34065 -- 4262811 Multiperiod Accounting
34066 -----------------------------------------------------------------------------------------
34067 -- No MPA option is assigned.
34068
34069
34070 END IF;
34071 END IF;
34072 --
34073
34074 --
34075 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34076 trace
34077 (p_msg => 'END of AcctLineType_85'
34078 ,p_level => C_LEVEL_PROCEDURE
34079 ,p_module => l_log_module);
34080 END IF;
34081 --
34082 EXCEPTION
34083 WHEN xla_exceptions_pkg.application_exception THEN
34084 RAISE;
34085 WHEN OTHERS THEN
34086 xla_exceptions_pkg.raise_message
34087 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_85');
34088 END AcctLineType_85;
34089 --
34090
34091 ---------------------------------------
34092 --
34093 -- PRIVATE FUNCTION
34094 -- AcctLineType_86
34095 --
34096 ---------------------------------------
34097 PROCEDURE AcctLineType_86 (
34098 p_application_id IN NUMBER
34099 ,p_event_id IN NUMBER
34100 ,p_calculate_acctd_flag IN VARCHAR2
34101 ,p_calculate_g_l_flag IN VARCHAR2
34102 ,p_actual_flag IN OUT VARCHAR2
34103 ,p_balance_type_code OUT VARCHAR2
34104 ,p_gain_or_loss_ref OUT VARCHAR2
34105
34106 --TRANSACTION_ID
34107 , p_source_1 IN NUMBER
34108 --Item Concatenated Segments
34109 , p_source_2 IN VARCHAR2
34110 --Transaction Quantity
34111 , p_source_3 IN NUMBER
34112 --Transaction Unit of Measure Code
34113 , p_source_4 IN VARCHAR2
34114 --Inventory Transaction Type Description
34115 , p_source_5 IN VARCHAR2
34116 --Inventory Organization Average Cost Variance Account
34117 , p_source_21 IN NUMBER
34118 --DISTRIBUTION_IDENTIFIER
34119 , p_source_84 IN NUMBER
34120 --Distribution Type
34121 , p_source_85 IN VARCHAR2
34122 , p_source_85_meaning IN VARCHAR2
34123 --Entered Currency Code
34124 , p_source_88 IN VARCHAR2
34125 --Entered Amount
34126 , p_source_91 IN NUMBER
34127 --Currency Conversion Date
34128 , p_source_92 IN DATE
34129 --Currency Conversion Rate
34130 , p_source_93 IN NUMBER
34131 --Currency Conversion Type
34132 , p_source_94 IN VARCHAR2
34133 --Accounted Amount
34134 , p_source_95 IN NUMBER
34135 --Accounting Line Type
34136 , p_source_97 IN NUMBER
34137 )
34138 IS
34139
34140 l_component_type VARCHAR2(80);
34141 l_component_code VARCHAR2(30);
34142 l_component_type_code VARCHAR2(1);
34143 l_component_appl_id INTEGER;
34144 l_amb_context_code VARCHAR2(30);
34145 l_entity_code VARCHAR2(30);
34146 l_event_class_code VARCHAR2(30);
34147 l_ae_header_id NUMBER;
34148 l_event_type_code VARCHAR2(30);
34149 l_line_definition_code VARCHAR2(30);
34150 l_line_definition_owner_code VARCHAR2(1);
34151 --
34152 -- adr variables
34153 l_segment VARCHAR2(30);
34154 l_ccid NUMBER;
34155 l_adr_transaction_coa_id NUMBER;
34156 l_adr_accounting_coa_id NUMBER;
34157 l_adr_flexfield_segment_code VARCHAR2(30);
34158 l_adr_flex_value_set_id NUMBER;
34159 l_adr_value_type_code VARCHAR2(30);
34160 l_adr_value_combination_id NUMBER;
34161 l_adr_value_segment_code VARCHAR2(30);
34162
34163 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34164 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34165 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34166 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34167
34168 -- 4262811 Variables ------------------------------------------------------------------------------------------
34169 l_entered_amt_idx NUMBER;
34170 l_accted_amt_idx NUMBER;
34171 l_acc_rev_flag VARCHAR2(1);
34172 l_accrual_line_num NUMBER;
34173 l_tmp_amt NUMBER;
34174 l_acc_rev_natural_side_code VARCHAR2(1);
34175
34176 l_num_entries NUMBER;
34177 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34178 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34179 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34180 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34181 l_recog_line_1 NUMBER;
34182 l_recog_line_2 NUMBER;
34183
34184 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34185 l_bflow_applied_to_amt NUMBER; -- 5132302
34186 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34187
34188 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34189
34190 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34191 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34192
34193 ---------------------------------------------------------------------------------------------------------------
34194
34195
34196 --
34197 -- bulk performance
34198 --
34199 l_balance_type_code VARCHAR2(1);
34200 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34201 l_log_module VARCHAR2(240);
34202
34203 --
34204 -- Upgrade strategy
34205 --
34206 l_actual_upg_option VARCHAR2(1);
34207 l_enc_upg_option VARCHAR2(1);
34208
34209 --
34210 BEGIN
34211 --
34212 IF g_log_enabled THEN
34213 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_86';
34214 END IF;
34215 --
34216 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34217
34218 trace
34219 (p_msg => 'BEGIN of AcctLineType_86'
34220 ,p_level => C_LEVEL_PROCEDURE
34221 ,p_module => l_log_module);
34222
34223 END IF;
34224 --
34225 l_component_type := 'AMB_JLT';
34226 l_component_code := 'COST_VARIANCE';
34227 l_component_type_code := 'S';
34228 l_component_appl_id := 707;
34229 l_amb_context_code := 'DEFAULT';
34230 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
34231 l_event_class_code := 'WIP_MTL';
34232 l_event_type_code := 'WIP_ASSEMBLY_RETURN';
34233 l_line_definition_owner_code := 'S';
34234 l_line_definition_code := 'PI_WIP_ASSEMBLY_RETURN';
34235 --
34236 l_balance_type_code := 'A';
34237 l_segment := NULL;
34238 l_ccid := NULL;
34239 l_adr_transaction_coa_id := NULL;
34240 l_adr_accounting_coa_id := NULL;
34241 l_adr_flexfield_segment_code := NULL;
34242 l_adr_flex_value_set_id := NULL;
34243 l_adr_value_type_code := NULL;
34244 l_adr_value_combination_id := NULL;
34245 l_adr_value_segment_code := NULL;
34246
34247 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34248 l_bflow_class_code := ''; -- 4219869 Business Flow
34249 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34250 l_budgetary_control_flag := 'N';
34251
34252 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34253 l_bflow_applied_to_amt := NULL; -- 5132302
34254 l_entered_amt_idx := NULL; -- 4262811
34255 l_accted_amt_idx := NULL; -- 4262811
34256 l_acc_rev_flag := NULL; -- 4262811
34257 l_accrual_line_num := NULL; -- 4262811
34258 l_tmp_amt := NULL; -- 4262811
34259 --
34260
34261 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34262 l_balance_type_code <> 'B' THEN
34263 IF NVL(p_source_97,9E125) = 13
34264 THEN
34265
34266 --
34267 XLA_AE_LINES_PKG.SetNewLine;
34268
34269 p_balance_type_code := l_balance_type_code;
34270 -- set the flag so later we will know whether the gain loss line needs to be created
34271
34272 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34273 p_actual_flag :='A';
34274 END IF;
34275
34276 --
34277 -- bulk performance
34278 --
34279 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34280 p_header_num => 0); -- 4262811
34281 --
34282 -- set accounting line options
34283 --
34284 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34285 p_natural_side_code => 'D'
34286 , p_gain_or_loss_flag => 'N'
34287 , p_gl_transfer_mode_code => 'S'
34288 , p_acct_entry_type_code => 'A'
34289 , p_switch_side_flag => 'Y'
34290 , p_merge_duplicate_code => 'N'
34291 );
34292 --
34293 l_acc_rev_natural_side_code := 'C'; -- 4262811
34294 --
34295 --
34296 -- set accounting line type info
34297 --
34298 xla_ae_lines_pkg.SetAcctLineType
34299 (p_component_type => l_component_type
34300 ,p_event_type_code => l_event_type_code
34301 ,p_line_definition_owner_code => l_line_definition_owner_code
34302 ,p_line_definition_code => l_line_definition_code
34303 ,p_accounting_line_code => l_component_code
34304 ,p_accounting_line_type_code => l_component_type_code
34305 ,p_accounting_line_appl_id => l_component_appl_id
34306 ,p_amb_context_code => l_amb_context_code
34307 ,p_entity_code => l_entity_code
34308 ,p_event_class_code => l_event_class_code);
34309 --
34310 -- set accounting class
34311 --
34312 xla_ae_lines_pkg.SetAcctClass(
34313 p_accounting_class_code => 'COST_VARIANCE'
34314 , p_ae_header_id => l_ae_header_id
34315 );
34316
34317 --
34318 -- set rounding class
34319 --
34320 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34321 'COST_VARIANCE';
34322
34323 --
34324 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34325 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34326 --
34327 -- bulk performance
34328 --
34329 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34330
34331 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34332 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34333
34334 -- 4955764
34335 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34336 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34337
34338 -- 4458381 Public Sector Enh
34339
34340 --
34341 -- set accounting attributes for the line type
34342 --
34343 l_entered_amt_idx := 3;
34344 l_accted_amt_idx := 8;
34345 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34346 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
34347 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
34348 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
34349 l_rec_acct_attrs.array_char_value(2) := p_source_85;
34350 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
34351 l_rec_acct_attrs.array_num_value(3) := p_source_91;
34352 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
34353 l_rec_acct_attrs.array_char_value(4) := p_source_88;
34354 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
34355 l_rec_acct_attrs.array_date_value(5) := p_source_92;
34356 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
34357 l_rec_acct_attrs.array_num_value(6) := p_source_93;
34358 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
34359 l_rec_acct_attrs.array_char_value(7) := p_source_94;
34360 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
34361 l_rec_acct_attrs.array_num_value(8) := p_source_95;
34362
34363 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34364 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34365
34366 ---------------------------------------------------------------------------------------------------------------
34367 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34368 ---------------------------------------------------------------------------------------------------------------
34369 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34370
34371 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34372 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34373
34374 IF xla_accounting_cache_pkg.GetValueChar
34375 (p_source_code => 'LEDGER_CATEGORY_CODE'
34376 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34377 AND l_bflow_method_code = 'PRIOR_ENTRY'
34378 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34379 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34380 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34381 )
34382 THEN
34383 xla_ae_lines_pkg.BflowUpgEntry
34384 (p_business_method_code => l_bflow_method_code
34385 ,p_business_class_code => l_bflow_class_code
34386 ,p_balance_type => l_balance_type_code);
34387 ELSE
34388 NULL;
34389 -- No business flow processing for business flow method of NONE.
34390 END IF;
34391
34392 --
34393 -- call analytical criteria
34394 --
34395
34396 --
34397 -- call description
34398 --
34399
34400 xla_ae_lines_pkg.SetLineDescription(
34401 p_ae_header_id => l_ae_header_id
34402 ,p_description => Description_1 (
34403 p_application_id => p_application_id
34404 , p_ae_header_id => l_ae_header_id
34405 , p_source_1 => p_source_1
34406 , p_source_2 => p_source_2
34407 , p_source_3 => p_source_3
34408 , p_source_4 => p_source_4
34409 , p_source_5 => p_source_5
34410 )
34411 );
34412
34413
34414 --
34415 -- call ADRs
34416 -- Bug 4922099
34417 --
34418 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34419 (NVL(l_actual_upg_option, 'N') = 'O') OR
34420 (NVL(l_enc_upg_option, 'N') = 'O')
34421 )
34422 THEN
34423 NULL;
34424 --
34425 --
34426
34427 l_ccid := AcctDerRule_10(
34428 p_application_id => p_application_id
34429 , p_ae_header_id => l_ae_header_id
34430 , p_source_21 => p_source_21
34431 , x_transaction_coa_id => l_adr_transaction_coa_id
34432 , x_accounting_coa_id => l_adr_accounting_coa_id
34433 , x_value_type_code => l_adr_value_type_code
34434 , p_side => 'NA'
34435 );
34436
34437 xla_ae_lines_pkg.set_ccid(
34438 p_code_combination_id => l_ccid
34439 , p_value_type_code => l_adr_value_type_code
34440 , p_transaction_coa_id => l_adr_transaction_coa_id
34441 , p_accounting_coa_id => l_adr_accounting_coa_id
34442 , p_adr_code => 'PI_AVG_CST_VARIANCE'
34443 , p_adr_type_code => 'S'
34444 , p_component_type => l_component_type
34445 , p_component_code => l_component_code
34446 , p_component_type_code => l_component_type_code
34447 , p_component_appl_id => l_component_appl_id
34448 , p_amb_context_code => l_amb_context_code
34449 , p_side => 'NA'
34450 );
34451
34452
34453 --
34454 --
34455 END IF;
34456 --
34457 -- Bug 4922099
34458 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34459 (NVL(l_enc_upg_option, 'N') = 'O')
34460 ) AND
34461 (l_bflow_method_code = 'PRIOR_ENTRY')
34462 )
34463 THEN
34464 IF
34465 --
34466 1 = 2
34467 --
34468 THEN
34469 xla_accounting_err_pkg.build_message
34470 (p_appli_s_name => 'XLA'
34471 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34472 ,p_token_1 => 'LINE_NUMBER'
34473 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34474 ,p_token_2 => 'LINE_TYPE_NAME'
34475 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34476 l_component_type
34477 ,l_component_code
34478 ,l_component_type_code
34479 ,l_component_appl_id
34480 ,l_amb_context_code
34481 ,l_entity_code
34482 ,l_event_class_code
34483 )
34484 ,p_token_3 => 'OWNER'
34485 ,p_value_3 => xla_lookups_pkg.get_meaning(
34486 p_lookup_type => 'XLA_OWNER_TYPE'
34487 ,p_lookup_code => l_component_type_code
34488 )
34489 ,p_token_4 => 'PRODUCT_NAME'
34490 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34491 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34492 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
34493 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
34494 ,p_ae_header_id => NULL
34495 );
34496
34497 IF (C_LEVEL_ERROR>= g_log_level) THEN
34498 trace
34499 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34500 ,p_level => C_LEVEL_ERROR
34501 ,p_module => l_log_module);
34502 END IF;
34503 END IF;
34504 END IF;
34505 --
34506 --
34507 ------------------------------------------------------------------------------------------------
34508 -- 4219869 Business Flow
34509 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
34510 -- Prior Entry. Currently, the following code is always generated.
34511 ------------------------------------------------------------------------------------------------
34512 XLA_AE_LINES_PKG.ValidateCurrentLine;
34513
34514 ------------------------------------------------------------------------------------
34515 -- 4219869 Business Flow
34516 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
34517 ------------------------------------------------------------------------------------
34518 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34519
34520 ----------------------------------------------------------------------------------
34521 -- 4219869 Business Flow
34522 -- Update journal entry status -- Need to generate this within IF <condition>
34523 ----------------------------------------------------------------------------------
34524 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34525 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
34526 ,p_balance_type_code => l_balance_type_code
34527 );
34528
34529 -------------------------------------------------------------------------------------------
34530 -- 4262811 - Generate the Accrual Reversal lines
34531 -------------------------------------------------------------------------------------------
34532 BEGIN
34533 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
34534 (g_array_event(p_event_id).array_value_num('header_index'));
34535 IF l_acc_rev_flag IS NULL THEN
34536 l_acc_rev_flag := 'N';
34537 END IF;
34538 EXCEPTION
34539 WHEN OTHERS THEN
34540 l_acc_rev_flag := 'N';
34541 END;
34542 --
34543 IF (l_acc_rev_flag = 'Y') THEN
34544
34545 -- 4645092 ------------------------------------------------------------------------------
34546 -- To allow MPA report to determine if it should generate report process
34547 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
34548 ------------------------------------------------------------------------------------------
34549
34550 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
34551 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
34552 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
34553 -- call ADRs
34554 -- Bug 4922099
34555 --
34556 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34557 (NVL(l_actual_upg_option, 'N') = 'O') OR
34558 (NVL(l_enc_upg_option, 'N') = 'O')
34559 )
34560 THEN
34561 NULL;
34562 --
34563 --
34564
34565 l_ccid := AcctDerRule_10(
34566 p_application_id => p_application_id
34567 , p_ae_header_id => l_ae_header_id
34568 , p_source_21 => p_source_21
34569 , x_transaction_coa_id => l_adr_transaction_coa_id
34570 , x_accounting_coa_id => l_adr_accounting_coa_id
34571 , x_value_type_code => l_adr_value_type_code
34572 , p_side => 'NA'
34573 );
34574
34575 xla_ae_lines_pkg.set_ccid(
34576 p_code_combination_id => l_ccid
34577 , p_value_type_code => l_adr_value_type_code
34578 , p_transaction_coa_id => l_adr_transaction_coa_id
34579 , p_accounting_coa_id => l_adr_accounting_coa_id
34580 , p_adr_code => 'PI_AVG_CST_VARIANCE'
34581 , p_adr_type_code => 'S'
34582 , p_component_type => l_component_type
34583 , p_component_code => l_component_code
34584 , p_component_type_code => l_component_type_code
34585 , p_component_appl_id => l_component_appl_id
34586 , p_amb_context_code => l_amb_context_code
34587 , p_side => 'NA'
34588 );
34589
34590
34591 --
34592 --
34593 END IF;
34594
34595 --
34596 -- Update the line information that should be overwritten
34597 --
34598 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34599 p_header_num => 1);
34600 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34601
34602 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34603
34604 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34605 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34606 END IF;
34607
34608 --
34609 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34610 --
34611 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34612 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34613 ELSE
34614 ---------------------------------------------------------------------------------------------------
34615 -- 4262811a Switch Sign
34616 ---------------------------------------------------------------------------------------------------
34617 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34618 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34620 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34622 -- 5132302
34623 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34625
34626 END IF;
34627
34628 -- 4955764
34629 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34630 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34631
34632
34633 XLA_AE_LINES_PKG.ValidateCurrentLine;
34634 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34635
34636 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34637 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34638 ,p_balance_type_code => l_balance_type_code);
34639
34640 END IF;
34641
34642 -----------------------------------------------------------------------------------------
34643 -- 4262811 Multiperiod Accounting
34644 -----------------------------------------------------------------------------------------
34645 -- No MPA option is assigned.
34646
34647
34648 END IF;
34649 END IF;
34650 --
34651
34652 --
34653 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34654 trace
34655 (p_msg => 'END of AcctLineType_86'
34656 ,p_level => C_LEVEL_PROCEDURE
34657 ,p_module => l_log_module);
34658 END IF;
34659 --
34660 EXCEPTION
34661 WHEN xla_exceptions_pkg.application_exception THEN
34662 RAISE;
34663 WHEN OTHERS THEN
34664 xla_exceptions_pkg.raise_message
34665 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_86');
34666 END AcctLineType_86;
34667 --
34668
34669 ---------------------------------------
34670 --
34671 -- PRIVATE FUNCTION
34672 -- AcctLineType_87
34673 --
34674 ---------------------------------------
34675 PROCEDURE AcctLineType_87 (
34676 p_application_id IN NUMBER
34677 ,p_event_id IN NUMBER
34678 ,p_calculate_acctd_flag IN VARCHAR2
34679 ,p_calculate_g_l_flag IN VARCHAR2
34680 ,p_actual_flag IN OUT VARCHAR2
34681 ,p_balance_type_code OUT VARCHAR2
34682 ,p_gain_or_loss_ref OUT VARCHAR2
34683
34684 --TRANSACTION_ID
34685 , p_source_1 IN NUMBER
34686 --Item Concatenated Segments
34687 , p_source_2 IN VARCHAR2
34688 --Transaction Quantity
34689 , p_source_3 IN NUMBER
34690 --Transaction Unit of Measure Code
34691 , p_source_4 IN VARCHAR2
34692 --Inventory Transaction Type Description
34693 , p_source_5 IN VARCHAR2
34694 --Cost Management Default Account
34695 , p_source_11 IN NUMBER
34696 --DISTRIBUTION_IDENTIFIER
34697 , p_source_84 IN NUMBER
34698 --Distribution Type
34699 , p_source_85 IN VARCHAR2
34700 , p_source_85_meaning IN VARCHAR2
34701 --Entered Currency Code
34702 , p_source_88 IN VARCHAR2
34703 --Entered Amount
34704 , p_source_91 IN NUMBER
34705 --Currency Conversion Date
34706 , p_source_92 IN DATE
34707 --Currency Conversion Rate
34708 , p_source_93 IN NUMBER
34709 --Currency Conversion Type
34710 , p_source_94 IN VARCHAR2
34711 --Accounted Amount
34712 , p_source_95 IN NUMBER
34713 --Accounting Line Type
34714 , p_source_97 IN NUMBER
34715 )
34716 IS
34717
34718 l_component_type VARCHAR2(80);
34719 l_component_code VARCHAR2(30);
34720 l_component_type_code VARCHAR2(1);
34721 l_component_appl_id INTEGER;
34722 l_amb_context_code VARCHAR2(30);
34723 l_entity_code VARCHAR2(30);
34724 l_event_class_code VARCHAR2(30);
34725 l_ae_header_id NUMBER;
34726 l_event_type_code VARCHAR2(30);
34727 l_line_definition_code VARCHAR2(30);
34728 l_line_definition_owner_code VARCHAR2(1);
34729 --
34730 -- adr variables
34731 l_segment VARCHAR2(30);
34732 l_ccid NUMBER;
34733 l_adr_transaction_coa_id NUMBER;
34734 l_adr_accounting_coa_id NUMBER;
34735 l_adr_flexfield_segment_code VARCHAR2(30);
34736 l_adr_flex_value_set_id NUMBER;
34737 l_adr_value_type_code VARCHAR2(30);
34738 l_adr_value_combination_id NUMBER;
34739 l_adr_value_segment_code VARCHAR2(30);
34740
34741 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34742 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34743 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34744 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34745
34746 -- 4262811 Variables ------------------------------------------------------------------------------------------
34747 l_entered_amt_idx NUMBER;
34748 l_accted_amt_idx NUMBER;
34749 l_acc_rev_flag VARCHAR2(1);
34750 l_accrual_line_num NUMBER;
34751 l_tmp_amt NUMBER;
34752 l_acc_rev_natural_side_code VARCHAR2(1);
34753
34754 l_num_entries NUMBER;
34755 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34756 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34757 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34758 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34759 l_recog_line_1 NUMBER;
34760 l_recog_line_2 NUMBER;
34761
34762 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34763 l_bflow_applied_to_amt NUMBER; -- 5132302
34764 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34765
34766 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34767
34768 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34769 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34770
34771 ---------------------------------------------------------------------------------------------------------------
34772
34773
34774 --
34775 -- bulk performance
34776 --
34777 l_balance_type_code VARCHAR2(1);
34778 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34779 l_log_module VARCHAR2(240);
34780
34781 --
34782 -- Upgrade strategy
34783 --
34784 l_actual_upg_option VARCHAR2(1);
34785 l_enc_upg_option VARCHAR2(1);
34786
34787 --
34788 BEGIN
34789 --
34790 IF g_log_enabled THEN
34791 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_87';
34792 END IF;
34793 --
34794 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34795
34796 trace
34797 (p_msg => 'BEGIN of AcctLineType_87'
34798 ,p_level => C_LEVEL_PROCEDURE
34799 ,p_module => l_log_module);
34800
34801 END IF;
34802 --
34803 l_component_type := 'AMB_JLT';
34804 l_component_code := 'COST_VARIANCE';
34805 l_component_type_code := 'S';
34806 l_component_appl_id := 707;
34807 l_amb_context_code := 'DEFAULT';
34808 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
34809 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
34810 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
34811 l_line_definition_owner_code := 'S';
34812 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
34813 --
34814 l_balance_type_code := 'A';
34815 l_segment := NULL;
34816 l_ccid := NULL;
34817 l_adr_transaction_coa_id := NULL;
34818 l_adr_accounting_coa_id := NULL;
34819 l_adr_flexfield_segment_code := NULL;
34820 l_adr_flex_value_set_id := NULL;
34821 l_adr_value_type_code := NULL;
34822 l_adr_value_combination_id := NULL;
34823 l_adr_value_segment_code := NULL;
34824
34825 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34826 l_bflow_class_code := ''; -- 4219869 Business Flow
34827 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34828 l_budgetary_control_flag := 'N';
34829
34830 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34831 l_bflow_applied_to_amt := NULL; -- 5132302
34832 l_entered_amt_idx := NULL; -- 4262811
34833 l_accted_amt_idx := NULL; -- 4262811
34834 l_acc_rev_flag := NULL; -- 4262811
34835 l_accrual_line_num := NULL; -- 4262811
34836 l_tmp_amt := NULL; -- 4262811
34837 --
34838
34839 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34840 l_balance_type_code <> 'B' THEN
34841 IF NVL(p_source_97,9E125) = 13
34842 THEN
34843
34844 --
34845 XLA_AE_LINES_PKG.SetNewLine;
34846
34847 p_balance_type_code := l_balance_type_code;
34848 -- set the flag so later we will know whether the gain loss line needs to be created
34849
34850 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34851 p_actual_flag :='A';
34852 END IF;
34853
34854 --
34855 -- bulk performance
34856 --
34857 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34858 p_header_num => 0); -- 4262811
34859 --
34860 -- set accounting line options
34861 --
34862 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34863 p_natural_side_code => 'D'
34864 , p_gain_or_loss_flag => 'N'
34865 , p_gl_transfer_mode_code => 'S'
34866 , p_acct_entry_type_code => 'A'
34867 , p_switch_side_flag => 'Y'
34868 , p_merge_duplicate_code => 'N'
34869 );
34870 --
34871 l_acc_rev_natural_side_code := 'C'; -- 4262811
34872 --
34873 --
34874 -- set accounting line type info
34875 --
34876 xla_ae_lines_pkg.SetAcctLineType
34877 (p_component_type => l_component_type
34878 ,p_event_type_code => l_event_type_code
34879 ,p_line_definition_owner_code => l_line_definition_owner_code
34880 ,p_line_definition_code => l_line_definition_code
34881 ,p_accounting_line_code => l_component_code
34882 ,p_accounting_line_type_code => l_component_type_code
34883 ,p_accounting_line_appl_id => l_component_appl_id
34884 ,p_amb_context_code => l_amb_context_code
34885 ,p_entity_code => l_entity_code
34886 ,p_event_class_code => l_event_class_code);
34887 --
34888 -- set accounting class
34889 --
34890 xla_ae_lines_pkg.SetAcctClass(
34891 p_accounting_class_code => 'COST_VARIANCE'
34892 , p_ae_header_id => l_ae_header_id
34893 );
34894
34895 --
34896 -- set rounding class
34897 --
34898 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34899 'COST_VARIANCE';
34900
34901 --
34902 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34903 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34904 --
34905 -- bulk performance
34906 --
34907 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34908
34909 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34910 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34911
34912 -- 4955764
34913 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34914 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34915
34916 -- 4458381 Public Sector Enh
34917
34918 --
34919 -- set accounting attributes for the line type
34920 --
34921 l_entered_amt_idx := 3;
34922 l_accted_amt_idx := 8;
34923 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34924 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
34925 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
34926 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
34927 l_rec_acct_attrs.array_char_value(2) := p_source_85;
34928 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
34929 l_rec_acct_attrs.array_num_value(3) := p_source_91;
34930 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
34931 l_rec_acct_attrs.array_char_value(4) := p_source_88;
34932 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
34933 l_rec_acct_attrs.array_date_value(5) := p_source_92;
34934 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
34935 l_rec_acct_attrs.array_num_value(6) := p_source_93;
34936 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
34937 l_rec_acct_attrs.array_char_value(7) := p_source_94;
34938 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
34939 l_rec_acct_attrs.array_num_value(8) := p_source_95;
34940
34941 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34942 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34943
34944 ---------------------------------------------------------------------------------------------------------------
34945 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34946 ---------------------------------------------------------------------------------------------------------------
34947 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34948
34949 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34950 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34951
34952 IF xla_accounting_cache_pkg.GetValueChar
34953 (p_source_code => 'LEDGER_CATEGORY_CODE'
34954 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34955 AND l_bflow_method_code = 'PRIOR_ENTRY'
34956 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34957 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34958 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34959 )
34960 THEN
34961 xla_ae_lines_pkg.BflowUpgEntry
34962 (p_business_method_code => l_bflow_method_code
34963 ,p_business_class_code => l_bflow_class_code
34964 ,p_balance_type => l_balance_type_code);
34965 ELSE
34966 NULL;
34967 -- No business flow processing for business flow method of NONE.
34968 END IF;
34969
34970 --
34971 -- call analytical criteria
34972 --
34973
34974 --
34975 -- call description
34976 --
34977
34978 xla_ae_lines_pkg.SetLineDescription(
34979 p_ae_header_id => l_ae_header_id
34980 ,p_description => Description_1 (
34981 p_application_id => p_application_id
34982 , p_ae_header_id => l_ae_header_id
34983 , p_source_1 => p_source_1
34984 , p_source_2 => p_source_2
34985 , p_source_3 => p_source_3
34986 , p_source_4 => p_source_4
34987 , p_source_5 => p_source_5
34988 )
34989 );
34990
34991
34992 --
34993 -- call ADRs
34994 -- Bug 4922099
34995 --
34996 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34997 (NVL(l_actual_upg_option, 'N') = 'O') OR
34998 (NVL(l_enc_upg_option, 'N') = 'O')
34999 )
35000 THEN
35001 NULL;
35002 --
35003 --
35004
35005 l_ccid := AcctDerRule_6(
35006 p_application_id => p_application_id
35007 , p_ae_header_id => l_ae_header_id
35008 , p_source_11 => p_source_11
35009 , x_transaction_coa_id => l_adr_transaction_coa_id
35010 , x_accounting_coa_id => l_adr_accounting_coa_id
35011 , x_value_type_code => l_adr_value_type_code
35012 , p_side => 'NA'
35013 );
35014
35015 xla_ae_lines_pkg.set_ccid(
35016 p_code_combination_id => l_ccid
35017 , p_value_type_code => l_adr_value_type_code
35018 , p_transaction_coa_id => l_adr_transaction_coa_id
35019 , p_accounting_coa_id => l_adr_accounting_coa_id
35020 , p_adr_code => 'CST_DEFAULT'
35021 , p_adr_type_code => 'S'
35022 , p_component_type => l_component_type
35023 , p_component_code => l_component_code
35024 , p_component_type_code => l_component_type_code
35025 , p_component_appl_id => l_component_appl_id
35026 , p_amb_context_code => l_amb_context_code
35027 , p_side => 'NA'
35028 );
35029
35030
35031 --
35032 --
35033 END IF;
35034 --
35035 -- Bug 4922099
35036 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35037 (NVL(l_enc_upg_option, 'N') = 'O')
35038 ) AND
35039 (l_bflow_method_code = 'PRIOR_ENTRY')
35040 )
35041 THEN
35042 IF
35043 --
35044 1 = 2
35045 --
35046 THEN
35047 xla_accounting_err_pkg.build_message
35048 (p_appli_s_name => 'XLA'
35049 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35050 ,p_token_1 => 'LINE_NUMBER'
35051 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35052 ,p_token_2 => 'LINE_TYPE_NAME'
35053 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35054 l_component_type
35055 ,l_component_code
35056 ,l_component_type_code
35057 ,l_component_appl_id
35058 ,l_amb_context_code
35059 ,l_entity_code
35060 ,l_event_class_code
35061 )
35062 ,p_token_3 => 'OWNER'
35063 ,p_value_3 => xla_lookups_pkg.get_meaning(
35064 p_lookup_type => 'XLA_OWNER_TYPE'
35065 ,p_lookup_code => l_component_type_code
35066 )
35067 ,p_token_4 => 'PRODUCT_NAME'
35068 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35069 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35070 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35071 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35072 ,p_ae_header_id => NULL
35073 );
35074
35075 IF (C_LEVEL_ERROR>= g_log_level) THEN
35076 trace
35077 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35078 ,p_level => C_LEVEL_ERROR
35079 ,p_module => l_log_module);
35080 END IF;
35081 END IF;
35082 END IF;
35083 --
35084 --
35085 ------------------------------------------------------------------------------------------------
35086 -- 4219869 Business Flow
35087 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35088 -- Prior Entry. Currently, the following code is always generated.
35089 ------------------------------------------------------------------------------------------------
35090 XLA_AE_LINES_PKG.ValidateCurrentLine;
35091
35092 ------------------------------------------------------------------------------------
35093 -- 4219869 Business Flow
35094 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35095 ------------------------------------------------------------------------------------
35096 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35097
35098 ----------------------------------------------------------------------------------
35099 -- 4219869 Business Flow
35100 -- Update journal entry status -- Need to generate this within IF <condition>
35101 ----------------------------------------------------------------------------------
35102 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35103 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35104 ,p_balance_type_code => l_balance_type_code
35105 );
35106
35107 -------------------------------------------------------------------------------------------
35108 -- 4262811 - Generate the Accrual Reversal lines
35109 -------------------------------------------------------------------------------------------
35110 BEGIN
35111 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35112 (g_array_event(p_event_id).array_value_num('header_index'));
35113 IF l_acc_rev_flag IS NULL THEN
35114 l_acc_rev_flag := 'N';
35115 END IF;
35116 EXCEPTION
35117 WHEN OTHERS THEN
35118 l_acc_rev_flag := 'N';
35119 END;
35120 --
35121 IF (l_acc_rev_flag = 'Y') THEN
35122
35123 -- 4645092 ------------------------------------------------------------------------------
35124 -- To allow MPA report to determine if it should generate report process
35125 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35126 ------------------------------------------------------------------------------------------
35127
35128 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35129 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35130 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35131 -- call ADRs
35132 -- Bug 4922099
35133 --
35134 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35135 (NVL(l_actual_upg_option, 'N') = 'O') OR
35136 (NVL(l_enc_upg_option, 'N') = 'O')
35137 )
35138 THEN
35139 NULL;
35140 --
35141 --
35142
35143 l_ccid := AcctDerRule_6(
35144 p_application_id => p_application_id
35145 , p_ae_header_id => l_ae_header_id
35146 , p_source_11 => p_source_11
35147 , x_transaction_coa_id => l_adr_transaction_coa_id
35148 , x_accounting_coa_id => l_adr_accounting_coa_id
35149 , x_value_type_code => l_adr_value_type_code
35150 , p_side => 'NA'
35151 );
35152
35153 xla_ae_lines_pkg.set_ccid(
35154 p_code_combination_id => l_ccid
35155 , p_value_type_code => l_adr_value_type_code
35156 , p_transaction_coa_id => l_adr_transaction_coa_id
35157 , p_accounting_coa_id => l_adr_accounting_coa_id
35158 , p_adr_code => 'CST_DEFAULT'
35159 , p_adr_type_code => 'S'
35160 , p_component_type => l_component_type
35161 , p_component_code => l_component_code
35162 , p_component_type_code => l_component_type_code
35163 , p_component_appl_id => l_component_appl_id
35164 , p_amb_context_code => l_amb_context_code
35165 , p_side => 'NA'
35166 );
35167
35168
35169 --
35170 --
35171 END IF;
35172
35173 --
35174 -- Update the line information that should be overwritten
35175 --
35176 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35177 p_header_num => 1);
35178 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35179
35180 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35181
35182 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35183 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35184 END IF;
35185
35186 --
35187 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35188 --
35189 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35190 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35191 ELSE
35192 ---------------------------------------------------------------------------------------------------
35193 -- 4262811a Switch Sign
35194 ---------------------------------------------------------------------------------------------------
35195 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35196 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35197 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35198 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35199 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35200 -- 5132302
35201 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35202 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35203
35204 END IF;
35205
35206 -- 4955764
35207 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35208 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35209
35210
35211 XLA_AE_LINES_PKG.ValidateCurrentLine;
35212 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35213
35214 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35215 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35216 ,p_balance_type_code => l_balance_type_code);
35217
35218 END IF;
35219
35220 -----------------------------------------------------------------------------------------
35221 -- 4262811 Multiperiod Accounting
35222 -----------------------------------------------------------------------------------------
35223 -- No MPA option is assigned.
35224
35225
35226 END IF;
35227 END IF;
35228 --
35229
35230 --
35231 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35232 trace
35233 (p_msg => 'END of AcctLineType_87'
35234 ,p_level => C_LEVEL_PROCEDURE
35235 ,p_module => l_log_module);
35236 END IF;
35237 --
35238 EXCEPTION
35239 WHEN xla_exceptions_pkg.application_exception THEN
35240 RAISE;
35241 WHEN OTHERS THEN
35242 xla_exceptions_pkg.raise_message
35243 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_87');
35244 END AcctLineType_87;
35245 --
35246
35247 ---------------------------------------
35248 --
35249 -- PRIVATE FUNCTION
35250 -- AcctLineType_88
35251 --
35252 ---------------------------------------
35253 PROCEDURE AcctLineType_88 (
35254 p_application_id IN NUMBER
35255 ,p_event_id IN NUMBER
35256 ,p_calculate_acctd_flag IN VARCHAR2
35257 ,p_calculate_g_l_flag IN VARCHAR2
35258 ,p_actual_flag IN OUT VARCHAR2
35259 ,p_balance_type_code OUT VARCHAR2
35260 ,p_gain_or_loss_ref OUT VARCHAR2
35261
35262 --Cost Management Default Account
35263 , p_source_11 IN NUMBER
35264 --DISTRIBUTION_IDENTIFIER
35265 , p_source_84 IN NUMBER
35266 --Distribution Type
35267 , p_source_85 IN VARCHAR2
35268 , p_source_85_meaning IN VARCHAR2
35269 --Entered Currency Code
35270 , p_source_88 IN VARCHAR2
35271 --Entered Amount
35272 , p_source_91 IN NUMBER
35273 --Currency Conversion Date
35274 , p_source_92 IN DATE
35275 --Currency Conversion Rate
35276 , p_source_93 IN NUMBER
35277 --Currency Conversion Type
35278 , p_source_94 IN VARCHAR2
35279 --Accounted Amount
35280 , p_source_95 IN NUMBER
35281 --Accounting Line Type
35282 , p_source_97 IN NUMBER
35283 )
35284 IS
35285
35286 l_component_type VARCHAR2(80);
35287 l_component_code VARCHAR2(30);
35288 l_component_type_code VARCHAR2(1);
35289 l_component_appl_id INTEGER;
35290 l_amb_context_code VARCHAR2(30);
35291 l_entity_code VARCHAR2(30);
35292 l_event_class_code VARCHAR2(30);
35293 l_ae_header_id NUMBER;
35294 l_event_type_code VARCHAR2(30);
35295 l_line_definition_code VARCHAR2(30);
35296 l_line_definition_owner_code VARCHAR2(1);
35297 --
35298 -- adr variables
35299 l_segment VARCHAR2(30);
35300 l_ccid NUMBER;
35301 l_adr_transaction_coa_id NUMBER;
35302 l_adr_accounting_coa_id NUMBER;
35303 l_adr_flexfield_segment_code VARCHAR2(30);
35304 l_adr_flex_value_set_id NUMBER;
35305 l_adr_value_type_code VARCHAR2(30);
35306 l_adr_value_combination_id NUMBER;
35307 l_adr_value_segment_code VARCHAR2(30);
35308
35309 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35310 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35311 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35312 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35313
35314 -- 4262811 Variables ------------------------------------------------------------------------------------------
35315 l_entered_amt_idx NUMBER;
35316 l_accted_amt_idx NUMBER;
35317 l_acc_rev_flag VARCHAR2(1);
35318 l_accrual_line_num NUMBER;
35319 l_tmp_amt NUMBER;
35320 l_acc_rev_natural_side_code VARCHAR2(1);
35321
35322 l_num_entries NUMBER;
35323 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35324 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35325 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35326 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35327 l_recog_line_1 NUMBER;
35328 l_recog_line_2 NUMBER;
35329
35330 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35331 l_bflow_applied_to_amt NUMBER; -- 5132302
35332 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35333
35334 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35335
35336 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35337 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35338
35339 ---------------------------------------------------------------------------------------------------------------
35340
35341
35342 --
35343 -- bulk performance
35344 --
35345 l_balance_type_code VARCHAR2(1);
35346 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35347 l_log_module VARCHAR2(240);
35348
35349 --
35350 -- Upgrade strategy
35351 --
35352 l_actual_upg_option VARCHAR2(1);
35353 l_enc_upg_option VARCHAR2(1);
35354
35355 --
35356 BEGIN
35357 --
35358 IF g_log_enabled THEN
35359 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_88';
35360 END IF;
35361 --
35362 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35363
35364 trace
35365 (p_msg => 'BEGIN of AcctLineType_88'
35366 ,p_level => C_LEVEL_PROCEDURE
35367 ,p_module => l_log_module);
35368
35369 END IF;
35370 --
35371 l_component_type := 'AMB_JLT';
35372 l_component_code := 'COST_VARIANCE';
35373 l_component_type_code := 'S';
35374 l_component_appl_id := 707;
35375 l_amb_context_code := 'DEFAULT';
35376 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
35377 l_event_class_code := 'USER_DEFINE';
35378 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
35379 l_line_definition_owner_code := 'S';
35380 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
35381 --
35382 l_balance_type_code := 'A';
35383 l_segment := NULL;
35384 l_ccid := NULL;
35385 l_adr_transaction_coa_id := NULL;
35386 l_adr_accounting_coa_id := NULL;
35387 l_adr_flexfield_segment_code := NULL;
35388 l_adr_flex_value_set_id := NULL;
35389 l_adr_value_type_code := NULL;
35390 l_adr_value_combination_id := NULL;
35391 l_adr_value_segment_code := NULL;
35392
35393 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35394 l_bflow_class_code := ''; -- 4219869 Business Flow
35395 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35396 l_budgetary_control_flag := 'N';
35397
35398 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35399 l_bflow_applied_to_amt := NULL; -- 5132302
35400 l_entered_amt_idx := NULL; -- 4262811
35401 l_accted_amt_idx := NULL; -- 4262811
35402 l_acc_rev_flag := NULL; -- 4262811
35403 l_accrual_line_num := NULL; -- 4262811
35404 l_tmp_amt := NULL; -- 4262811
35405 --
35406
35407 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35408 l_balance_type_code <> 'B' THEN
35409 IF NVL(p_source_97,9E125) = 13
35410 THEN
35411
35412 --
35413 XLA_AE_LINES_PKG.SetNewLine;
35414
35415 p_balance_type_code := l_balance_type_code;
35416 -- set the flag so later we will know whether the gain loss line needs to be created
35417
35418 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35419 p_actual_flag :='A';
35420 END IF;
35421
35422 --
35423 -- bulk performance
35424 --
35425 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35426 p_header_num => 0); -- 4262811
35427 --
35428 -- set accounting line options
35429 --
35430 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35431 p_natural_side_code => 'D'
35432 , p_gain_or_loss_flag => 'N'
35433 , p_gl_transfer_mode_code => 'S'
35434 , p_acct_entry_type_code => 'A'
35435 , p_switch_side_flag => 'Y'
35436 , p_merge_duplicate_code => 'N'
35437 );
35438 --
35439 l_acc_rev_natural_side_code := 'C'; -- 4262811
35440 --
35441 --
35442 -- set accounting line type info
35443 --
35444 xla_ae_lines_pkg.SetAcctLineType
35445 (p_component_type => l_component_type
35446 ,p_event_type_code => l_event_type_code
35447 ,p_line_definition_owner_code => l_line_definition_owner_code
35448 ,p_line_definition_code => l_line_definition_code
35449 ,p_accounting_line_code => l_component_code
35450 ,p_accounting_line_type_code => l_component_type_code
35451 ,p_accounting_line_appl_id => l_component_appl_id
35452 ,p_amb_context_code => l_amb_context_code
35453 ,p_entity_code => l_entity_code
35454 ,p_event_class_code => l_event_class_code);
35455 --
35456 -- set accounting class
35457 --
35458 xla_ae_lines_pkg.SetAcctClass(
35459 p_accounting_class_code => 'COST_VARIANCE'
35460 , p_ae_header_id => l_ae_header_id
35461 );
35462
35463 --
35464 -- set rounding class
35465 --
35466 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35467 'COST_VARIANCE';
35468
35469 --
35470 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35471 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35472 --
35473 -- bulk performance
35474 --
35475 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35476
35477 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35478 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35479
35480 -- 4955764
35481 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35482 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35483
35484 -- 4458381 Public Sector Enh
35485
35486 --
35487 -- set accounting attributes for the line type
35488 --
35489 l_entered_amt_idx := 3;
35490 l_accted_amt_idx := 8;
35491 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35492 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
35493 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
35494 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
35495 l_rec_acct_attrs.array_char_value(2) := p_source_85;
35496 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
35497 l_rec_acct_attrs.array_num_value(3) := p_source_91;
35498 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
35499 l_rec_acct_attrs.array_char_value(4) := p_source_88;
35500 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
35501 l_rec_acct_attrs.array_date_value(5) := p_source_92;
35502 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
35503 l_rec_acct_attrs.array_num_value(6) := p_source_93;
35504 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
35505 l_rec_acct_attrs.array_char_value(7) := p_source_94;
35506 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
35507 l_rec_acct_attrs.array_num_value(8) := p_source_95;
35508
35509 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35510 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35511
35512 ---------------------------------------------------------------------------------------------------------------
35513 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35514 ---------------------------------------------------------------------------------------------------------------
35515 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
35516
35517 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35518 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35519
35520 IF xla_accounting_cache_pkg.GetValueChar
35521 (p_source_code => 'LEDGER_CATEGORY_CODE'
35522 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
35523 AND l_bflow_method_code = 'PRIOR_ENTRY'
35524 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
35525 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
35526 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
35527 )
35528 THEN
35529 xla_ae_lines_pkg.BflowUpgEntry
35530 (p_business_method_code => l_bflow_method_code
35531 ,p_business_class_code => l_bflow_class_code
35532 ,p_balance_type => l_balance_type_code);
35533 ELSE
35534 NULL;
35535 -- No business flow processing for business flow method of NONE.
35536 END IF;
35537
35538 --
35539 -- call analytical criteria
35540 --
35541
35542 --
35543 -- call description
35544 --
35545 -- No description or it is inherited.
35546 --
35547 -- call ADRs
35548 -- Bug 4922099
35549 --
35550 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35551 (NVL(l_actual_upg_option, 'N') = 'O') OR
35552 (NVL(l_enc_upg_option, 'N') = 'O')
35553 )
35554 THEN
35555 NULL;
35556 --
35557 --
35558
35559 l_ccid := AcctDerRule_6(
35560 p_application_id => p_application_id
35561 , p_ae_header_id => l_ae_header_id
35562 , p_source_11 => p_source_11
35563 , x_transaction_coa_id => l_adr_transaction_coa_id
35564 , x_accounting_coa_id => l_adr_accounting_coa_id
35565 , x_value_type_code => l_adr_value_type_code
35566 , p_side => 'NA'
35567 );
35568
35569 xla_ae_lines_pkg.set_ccid(
35570 p_code_combination_id => l_ccid
35571 , p_value_type_code => l_adr_value_type_code
35572 , p_transaction_coa_id => l_adr_transaction_coa_id
35573 , p_accounting_coa_id => l_adr_accounting_coa_id
35574 , p_adr_code => 'CST_DEFAULT'
35575 , p_adr_type_code => 'S'
35576 , p_component_type => l_component_type
35577 , p_component_code => l_component_code
35578 , p_component_type_code => l_component_type_code
35579 , p_component_appl_id => l_component_appl_id
35580 , p_amb_context_code => l_amb_context_code
35581 , p_side => 'NA'
35582 );
35583
35584
35585 --
35586 --
35587 END IF;
35588 --
35589 -- Bug 4922099
35590 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35591 (NVL(l_enc_upg_option, 'N') = 'O')
35592 ) AND
35593 (l_bflow_method_code = 'PRIOR_ENTRY')
35594 )
35595 THEN
35596 IF
35597 --
35598 1 = 2
35599 --
35600 THEN
35601 xla_accounting_err_pkg.build_message
35602 (p_appli_s_name => 'XLA'
35603 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35604 ,p_token_1 => 'LINE_NUMBER'
35605 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35606 ,p_token_2 => 'LINE_TYPE_NAME'
35607 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35608 l_component_type
35609 ,l_component_code
35610 ,l_component_type_code
35611 ,l_component_appl_id
35612 ,l_amb_context_code
35613 ,l_entity_code
35614 ,l_event_class_code
35615 )
35616 ,p_token_3 => 'OWNER'
35617 ,p_value_3 => xla_lookups_pkg.get_meaning(
35618 p_lookup_type => 'XLA_OWNER_TYPE'
35619 ,p_lookup_code => l_component_type_code
35620 )
35621 ,p_token_4 => 'PRODUCT_NAME'
35622 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35623 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35624 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35625 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35626 ,p_ae_header_id => NULL
35627 );
35628
35629 IF (C_LEVEL_ERROR>= g_log_level) THEN
35630 trace
35631 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35632 ,p_level => C_LEVEL_ERROR
35633 ,p_module => l_log_module);
35634 END IF;
35635 END IF;
35636 END IF;
35637 --
35638 --
35639 ------------------------------------------------------------------------------------------------
35640 -- 4219869 Business Flow
35641 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35642 -- Prior Entry. Currently, the following code is always generated.
35643 ------------------------------------------------------------------------------------------------
35644 XLA_AE_LINES_PKG.ValidateCurrentLine;
35645
35646 ------------------------------------------------------------------------------------
35647 -- 4219869 Business Flow
35648 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35649 ------------------------------------------------------------------------------------
35650 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35651
35652 ----------------------------------------------------------------------------------
35653 -- 4219869 Business Flow
35654 -- Update journal entry status -- Need to generate this within IF <condition>
35655 ----------------------------------------------------------------------------------
35656 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35657 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35658 ,p_balance_type_code => l_balance_type_code
35659 );
35660
35661 -------------------------------------------------------------------------------------------
35662 -- 4262811 - Generate the Accrual Reversal lines
35663 -------------------------------------------------------------------------------------------
35664 BEGIN
35665 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35666 (g_array_event(p_event_id).array_value_num('header_index'));
35667 IF l_acc_rev_flag IS NULL THEN
35668 l_acc_rev_flag := 'N';
35669 END IF;
35670 EXCEPTION
35671 WHEN OTHERS THEN
35672 l_acc_rev_flag := 'N';
35673 END;
35674 --
35675 IF (l_acc_rev_flag = 'Y') THEN
35676
35677 -- 4645092 ------------------------------------------------------------------------------
35678 -- To allow MPA report to determine if it should generate report process
35679 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35680 ------------------------------------------------------------------------------------------
35681
35682 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35683 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35684 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35685 -- call ADRs
35686 -- Bug 4922099
35687 --
35688 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35689 (NVL(l_actual_upg_option, 'N') = 'O') OR
35690 (NVL(l_enc_upg_option, 'N') = 'O')
35691 )
35692 THEN
35693 NULL;
35694 --
35695 --
35696
35697 l_ccid := AcctDerRule_6(
35698 p_application_id => p_application_id
35699 , p_ae_header_id => l_ae_header_id
35700 , p_source_11 => p_source_11
35701 , x_transaction_coa_id => l_adr_transaction_coa_id
35702 , x_accounting_coa_id => l_adr_accounting_coa_id
35703 , x_value_type_code => l_adr_value_type_code
35704 , p_side => 'NA'
35705 );
35706
35707 xla_ae_lines_pkg.set_ccid(
35708 p_code_combination_id => l_ccid
35709 , p_value_type_code => l_adr_value_type_code
35710 , p_transaction_coa_id => l_adr_transaction_coa_id
35711 , p_accounting_coa_id => l_adr_accounting_coa_id
35712 , p_adr_code => 'CST_DEFAULT'
35713 , p_adr_type_code => 'S'
35714 , p_component_type => l_component_type
35715 , p_component_code => l_component_code
35716 , p_component_type_code => l_component_type_code
35717 , p_component_appl_id => l_component_appl_id
35718 , p_amb_context_code => l_amb_context_code
35719 , p_side => 'NA'
35720 );
35721
35722
35723 --
35724 --
35725 END IF;
35726
35727 --
35728 -- Update the line information that should be overwritten
35729 --
35730 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35731 p_header_num => 1);
35732 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35733
35734 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35735
35736 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35737 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35738 END IF;
35739
35740 --
35741 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35742 --
35743 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35744 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35745 ELSE
35746 ---------------------------------------------------------------------------------------------------
35747 -- 4262811a Switch Sign
35748 ---------------------------------------------------------------------------------------------------
35749 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35750 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35751 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35752 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35753 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35754 -- 5132302
35755 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35756 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35757
35758 END IF;
35759
35760 -- 4955764
35761 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35762 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35763
35764
35765 XLA_AE_LINES_PKG.ValidateCurrentLine;
35766 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35767
35768 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35769 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35770 ,p_balance_type_code => l_balance_type_code);
35771
35772 END IF;
35773
35774 -----------------------------------------------------------------------------------------
35775 -- 4262811 Multiperiod Accounting
35776 -----------------------------------------------------------------------------------------
35777 -- No MPA option is assigned.
35778
35779
35780 END IF;
35781 END IF;
35782 --
35783
35784 --
35785 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35786 trace
35787 (p_msg => 'END of AcctLineType_88'
35788 ,p_level => C_LEVEL_PROCEDURE
35789 ,p_module => l_log_module);
35790 END IF;
35791 --
35792 EXCEPTION
35793 WHEN xla_exceptions_pkg.application_exception THEN
35794 RAISE;
35795 WHEN OTHERS THEN
35796 xla_exceptions_pkg.raise_message
35797 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_88');
35798 END AcctLineType_88;
35799 --
35800
35801 ---------------------------------------
35802 --
35803 -- PRIVATE FUNCTION
35804 -- AcctLineType_89
35805 --
35806 ---------------------------------------
35807 PROCEDURE AcctLineType_89 (
35808 p_application_id IN NUMBER
35809 ,p_event_id IN NUMBER
35810 ,p_calculate_acctd_flag IN VARCHAR2
35811 ,p_calculate_g_l_flag IN VARCHAR2
35812 ,p_actual_flag IN OUT VARCHAR2
35813 ,p_balance_type_code OUT VARCHAR2
35814 ,p_gain_or_loss_ref OUT VARCHAR2
35815
35816 --TRANSACTION_ID
35817 , p_source_1 IN NUMBER
35818 --Item Concatenated Segments
35819 , p_source_2 IN VARCHAR2
35820 --Transaction Quantity
35821 , p_source_3 IN NUMBER
35822 --Transaction Unit of Measure Code
35823 , p_source_4 IN VARCHAR2
35824 --Inventory Transaction Type Description
35825 , p_source_5 IN VARCHAR2
35826 --Inventory Organization Average Cost Variance Account
35827 , p_source_21 IN NUMBER
35828 --DISTRIBUTION_IDENTIFIER
35829 , p_source_84 IN NUMBER
35830 --Distribution Type
35831 , p_source_85 IN VARCHAR2
35832 , p_source_85_meaning IN VARCHAR2
35833 --Entered Currency Code
35834 , p_source_88 IN VARCHAR2
35835 --Entered Amount
35836 , p_source_91 IN NUMBER
35837 --Currency Conversion Date
35838 , p_source_92 IN DATE
35839 --Currency Conversion Rate
35840 , p_source_93 IN NUMBER
35841 --Currency Conversion Type
35842 , p_source_94 IN VARCHAR2
35843 --Accounted Amount
35844 , p_source_95 IN NUMBER
35845 --Accounting Line Type
35846 , p_source_97 IN NUMBER
35847 )
35848 IS
35849
35850 l_component_type VARCHAR2(80);
35851 l_component_code VARCHAR2(30);
35852 l_component_type_code VARCHAR2(1);
35853 l_component_appl_id INTEGER;
35854 l_amb_context_code VARCHAR2(30);
35855 l_entity_code VARCHAR2(30);
35856 l_event_class_code VARCHAR2(30);
35857 l_ae_header_id NUMBER;
35858 l_event_type_code VARCHAR2(30);
35859 l_line_definition_code VARCHAR2(30);
35860 l_line_definition_owner_code VARCHAR2(1);
35861 --
35862 -- adr variables
35863 l_segment VARCHAR2(30);
35864 l_ccid NUMBER;
35865 l_adr_transaction_coa_id NUMBER;
35866 l_adr_accounting_coa_id NUMBER;
35867 l_adr_flexfield_segment_code VARCHAR2(30);
35868 l_adr_flex_value_set_id NUMBER;
35869 l_adr_value_type_code VARCHAR2(30);
35870 l_adr_value_combination_id NUMBER;
35871 l_adr_value_segment_code VARCHAR2(30);
35872
35873 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35874 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35875 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35876 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35877
35878 -- 4262811 Variables ------------------------------------------------------------------------------------------
35879 l_entered_amt_idx NUMBER;
35880 l_accted_amt_idx NUMBER;
35881 l_acc_rev_flag VARCHAR2(1);
35882 l_accrual_line_num NUMBER;
35883 l_tmp_amt NUMBER;
35884 l_acc_rev_natural_side_code VARCHAR2(1);
35885
35886 l_num_entries NUMBER;
35887 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35888 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35889 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35890 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35891 l_recog_line_1 NUMBER;
35892 l_recog_line_2 NUMBER;
35893
35894 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35895 l_bflow_applied_to_amt NUMBER; -- 5132302
35896 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35897
35898 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35899
35900 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35901 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35902
35903 ---------------------------------------------------------------------------------------------------------------
35904
35905
35906 --
35907 -- bulk performance
35908 --
35909 l_balance_type_code VARCHAR2(1);
35910 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35911 l_log_module VARCHAR2(240);
35912
35913 --
35914 -- Upgrade strategy
35915 --
35916 l_actual_upg_option VARCHAR2(1);
35917 l_enc_upg_option VARCHAR2(1);
35918
35919 --
35920 BEGIN
35921 --
35922 IF g_log_enabled THEN
35923 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_89';
35924 END IF;
35925 --
35926 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35927
35928 trace
35929 (p_msg => 'BEGIN of AcctLineType_89'
35930 ,p_level => C_LEVEL_PROCEDURE
35931 ,p_module => l_log_module);
35932
35933 END IF;
35934 --
35935 l_component_type := 'AMB_JLT';
35936 l_component_code := 'COST_VARIANCE';
35937 l_component_type_code := 'S';
35938 l_component_appl_id := 707;
35939 l_amb_context_code := 'DEFAULT';
35940 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
35941 l_event_class_code := 'WIP_MTL';
35942 l_event_type_code := 'WIP_ASSEMBLY_COMPLETION';
35943 l_line_definition_owner_code := 'S';
35944 l_line_definition_code := 'PI_WIP_ASSEMBLY_COMPLETION';
35945 --
35946 l_balance_type_code := 'A';
35947 l_segment := NULL;
35948 l_ccid := NULL;
35949 l_adr_transaction_coa_id := NULL;
35950 l_adr_accounting_coa_id := NULL;
35951 l_adr_flexfield_segment_code := NULL;
35952 l_adr_flex_value_set_id := NULL;
35953 l_adr_value_type_code := NULL;
35954 l_adr_value_combination_id := NULL;
35955 l_adr_value_segment_code := NULL;
35956
35957 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35958 l_bflow_class_code := ''; -- 4219869 Business Flow
35959 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35960 l_budgetary_control_flag := 'N';
35961
35962 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35963 l_bflow_applied_to_amt := NULL; -- 5132302
35964 l_entered_amt_idx := NULL; -- 4262811
35965 l_accted_amt_idx := NULL; -- 4262811
35966 l_acc_rev_flag := NULL; -- 4262811
35967 l_accrual_line_num := NULL; -- 4262811
35968 l_tmp_amt := NULL; -- 4262811
35969 --
35970
35971 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35972 l_balance_type_code <> 'B' THEN
35973 IF NVL(p_source_97,9E125) = 13
35974 THEN
35975
35976 --
35977 XLA_AE_LINES_PKG.SetNewLine;
35978
35979 p_balance_type_code := l_balance_type_code;
35980 -- set the flag so later we will know whether the gain loss line needs to be created
35981
35982 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35983 p_actual_flag :='A';
35984 END IF;
35985
35986 --
35987 -- bulk performance
35988 --
35989 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35990 p_header_num => 0); -- 4262811
35991 --
35992 -- set accounting line options
35993 --
35994 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35995 p_natural_side_code => 'D'
35996 , p_gain_or_loss_flag => 'N'
35997 , p_gl_transfer_mode_code => 'S'
35998 , p_acct_entry_type_code => 'A'
35999 , p_switch_side_flag => 'Y'
36000 , p_merge_duplicate_code => 'N'
36001 );
36002 --
36003 l_acc_rev_natural_side_code := 'C'; -- 4262811
36004 --
36005 --
36006 -- set accounting line type info
36007 --
36008 xla_ae_lines_pkg.SetAcctLineType
36009 (p_component_type => l_component_type
36010 ,p_event_type_code => l_event_type_code
36011 ,p_line_definition_owner_code => l_line_definition_owner_code
36012 ,p_line_definition_code => l_line_definition_code
36013 ,p_accounting_line_code => l_component_code
36014 ,p_accounting_line_type_code => l_component_type_code
36015 ,p_accounting_line_appl_id => l_component_appl_id
36016 ,p_amb_context_code => l_amb_context_code
36017 ,p_entity_code => l_entity_code
36018 ,p_event_class_code => l_event_class_code);
36019 --
36020 -- set accounting class
36021 --
36022 xla_ae_lines_pkg.SetAcctClass(
36023 p_accounting_class_code => 'COST_VARIANCE'
36024 , p_ae_header_id => l_ae_header_id
36025 );
36026
36027 --
36028 -- set rounding class
36029 --
36030 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36031 'COST_VARIANCE';
36032
36033 --
36034 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36035 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36036 --
36037 -- bulk performance
36038 --
36039 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36040
36041 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36042 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36043
36044 -- 4955764
36045 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36046 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36047
36048 -- 4458381 Public Sector Enh
36049
36050 --
36051 -- set accounting attributes for the line type
36052 --
36053 l_entered_amt_idx := 3;
36054 l_accted_amt_idx := 8;
36055 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36056 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
36057 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
36058 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
36059 l_rec_acct_attrs.array_char_value(2) := p_source_85;
36060 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
36061 l_rec_acct_attrs.array_num_value(3) := p_source_91;
36062 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
36063 l_rec_acct_attrs.array_char_value(4) := p_source_88;
36064 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
36065 l_rec_acct_attrs.array_date_value(5) := p_source_92;
36066 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
36067 l_rec_acct_attrs.array_num_value(6) := p_source_93;
36068 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
36069 l_rec_acct_attrs.array_char_value(7) := p_source_94;
36070 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
36071 l_rec_acct_attrs.array_num_value(8) := p_source_95;
36072
36073 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36074 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36075
36076 ---------------------------------------------------------------------------------------------------------------
36077 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36078 ---------------------------------------------------------------------------------------------------------------
36079 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36080
36081 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36082 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36083
36084 IF xla_accounting_cache_pkg.GetValueChar
36085 (p_source_code => 'LEDGER_CATEGORY_CODE'
36086 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36087 AND l_bflow_method_code = 'PRIOR_ENTRY'
36088 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36089 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36090 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36091 )
36092 THEN
36093 xla_ae_lines_pkg.BflowUpgEntry
36094 (p_business_method_code => l_bflow_method_code
36095 ,p_business_class_code => l_bflow_class_code
36096 ,p_balance_type => l_balance_type_code);
36097 ELSE
36098 NULL;
36099 -- No business flow processing for business flow method of NONE.
36100 END IF;
36101
36102 --
36103 -- call analytical criteria
36104 --
36105
36106 --
36107 -- call description
36108 --
36109
36110 xla_ae_lines_pkg.SetLineDescription(
36111 p_ae_header_id => l_ae_header_id
36112 ,p_description => Description_1 (
36113 p_application_id => p_application_id
36114 , p_ae_header_id => l_ae_header_id
36115 , p_source_1 => p_source_1
36116 , p_source_2 => p_source_2
36117 , p_source_3 => p_source_3
36118 , p_source_4 => p_source_4
36119 , p_source_5 => p_source_5
36120 )
36121 );
36122
36123
36124 --
36125 -- call ADRs
36126 -- Bug 4922099
36127 --
36128 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36129 (NVL(l_actual_upg_option, 'N') = 'O') OR
36130 (NVL(l_enc_upg_option, 'N') = 'O')
36131 )
36132 THEN
36133 NULL;
36134 --
36135 --
36136
36137 l_ccid := AcctDerRule_10(
36138 p_application_id => p_application_id
36139 , p_ae_header_id => l_ae_header_id
36140 , p_source_21 => p_source_21
36141 , x_transaction_coa_id => l_adr_transaction_coa_id
36142 , x_accounting_coa_id => l_adr_accounting_coa_id
36143 , x_value_type_code => l_adr_value_type_code
36144 , p_side => 'NA'
36145 );
36146
36147 xla_ae_lines_pkg.set_ccid(
36148 p_code_combination_id => l_ccid
36149 , p_value_type_code => l_adr_value_type_code
36150 , p_transaction_coa_id => l_adr_transaction_coa_id
36151 , p_accounting_coa_id => l_adr_accounting_coa_id
36152 , p_adr_code => 'PI_AVG_CST_VARIANCE'
36153 , p_adr_type_code => 'S'
36154 , p_component_type => l_component_type
36155 , p_component_code => l_component_code
36156 , p_component_type_code => l_component_type_code
36157 , p_component_appl_id => l_component_appl_id
36158 , p_amb_context_code => l_amb_context_code
36159 , p_side => 'NA'
36160 );
36161
36162
36163 --
36164 --
36165 END IF;
36166 --
36167 -- Bug 4922099
36168 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36169 (NVL(l_enc_upg_option, 'N') = 'O')
36170 ) AND
36171 (l_bflow_method_code = 'PRIOR_ENTRY')
36172 )
36173 THEN
36174 IF
36175 --
36176 1 = 2
36177 --
36178 THEN
36179 xla_accounting_err_pkg.build_message
36180 (p_appli_s_name => 'XLA'
36181 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36182 ,p_token_1 => 'LINE_NUMBER'
36183 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36184 ,p_token_2 => 'LINE_TYPE_NAME'
36185 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36186 l_component_type
36187 ,l_component_code
36188 ,l_component_type_code
36189 ,l_component_appl_id
36190 ,l_amb_context_code
36191 ,l_entity_code
36192 ,l_event_class_code
36193 )
36194 ,p_token_3 => 'OWNER'
36195 ,p_value_3 => xla_lookups_pkg.get_meaning(
36196 p_lookup_type => 'XLA_OWNER_TYPE'
36197 ,p_lookup_code => l_component_type_code
36198 )
36199 ,p_token_4 => 'PRODUCT_NAME'
36200 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36201 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36202 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36203 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36204 ,p_ae_header_id => NULL
36205 );
36206
36207 IF (C_LEVEL_ERROR>= g_log_level) THEN
36208 trace
36209 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36210 ,p_level => C_LEVEL_ERROR
36211 ,p_module => l_log_module);
36212 END IF;
36213 END IF;
36214 END IF;
36215 --
36216 --
36217 ------------------------------------------------------------------------------------------------
36218 -- 4219869 Business Flow
36219 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36220 -- Prior Entry. Currently, the following code is always generated.
36221 ------------------------------------------------------------------------------------------------
36222 XLA_AE_LINES_PKG.ValidateCurrentLine;
36223
36224 ------------------------------------------------------------------------------------
36225 -- 4219869 Business Flow
36226 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36227 ------------------------------------------------------------------------------------
36228 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36229
36230 ----------------------------------------------------------------------------------
36231 -- 4219869 Business Flow
36232 -- Update journal entry status -- Need to generate this within IF <condition>
36233 ----------------------------------------------------------------------------------
36234 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36235 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36236 ,p_balance_type_code => l_balance_type_code
36237 );
36238
36239 -------------------------------------------------------------------------------------------
36240 -- 4262811 - Generate the Accrual Reversal lines
36241 -------------------------------------------------------------------------------------------
36242 BEGIN
36243 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36244 (g_array_event(p_event_id).array_value_num('header_index'));
36245 IF l_acc_rev_flag IS NULL THEN
36246 l_acc_rev_flag := 'N';
36247 END IF;
36248 EXCEPTION
36249 WHEN OTHERS THEN
36250 l_acc_rev_flag := 'N';
36251 END;
36252 --
36253 IF (l_acc_rev_flag = 'Y') THEN
36254
36255 -- 4645092 ------------------------------------------------------------------------------
36256 -- To allow MPA report to determine if it should generate report process
36257 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36258 ------------------------------------------------------------------------------------------
36259
36260 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36261 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36262 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36263 -- call ADRs
36264 -- Bug 4922099
36265 --
36266 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36267 (NVL(l_actual_upg_option, 'N') = 'O') OR
36268 (NVL(l_enc_upg_option, 'N') = 'O')
36269 )
36270 THEN
36271 NULL;
36272 --
36273 --
36274
36275 l_ccid := AcctDerRule_10(
36276 p_application_id => p_application_id
36277 , p_ae_header_id => l_ae_header_id
36278 , p_source_21 => p_source_21
36279 , x_transaction_coa_id => l_adr_transaction_coa_id
36280 , x_accounting_coa_id => l_adr_accounting_coa_id
36281 , x_value_type_code => l_adr_value_type_code
36282 , p_side => 'NA'
36283 );
36284
36285 xla_ae_lines_pkg.set_ccid(
36286 p_code_combination_id => l_ccid
36287 , p_value_type_code => l_adr_value_type_code
36288 , p_transaction_coa_id => l_adr_transaction_coa_id
36289 , p_accounting_coa_id => l_adr_accounting_coa_id
36290 , p_adr_code => 'PI_AVG_CST_VARIANCE'
36291 , p_adr_type_code => 'S'
36292 , p_component_type => l_component_type
36293 , p_component_code => l_component_code
36294 , p_component_type_code => l_component_type_code
36295 , p_component_appl_id => l_component_appl_id
36296 , p_amb_context_code => l_amb_context_code
36297 , p_side => 'NA'
36298 );
36299
36300
36301 --
36302 --
36303 END IF;
36304
36305 --
36306 -- Update the line information that should be overwritten
36307 --
36308 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36309 p_header_num => 1);
36310 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36311
36312 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36313
36314 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36315 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36316 END IF;
36317
36318 --
36319 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36320 --
36321 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36322 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36323 ELSE
36324 ---------------------------------------------------------------------------------------------------
36325 -- 4262811a Switch Sign
36326 ---------------------------------------------------------------------------------------------------
36327 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36329 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36330 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36331 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36332 -- 5132302
36333 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36334 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36335
36336 END IF;
36337
36338 -- 4955764
36339 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36340 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36341
36342
36343 XLA_AE_LINES_PKG.ValidateCurrentLine;
36344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36345
36346 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36347 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36348 ,p_balance_type_code => l_balance_type_code);
36349
36350 END IF;
36351
36352 -----------------------------------------------------------------------------------------
36353 -- 4262811 Multiperiod Accounting
36354 -----------------------------------------------------------------------------------------
36355 -- No MPA option is assigned.
36356
36357
36358 END IF;
36359 END IF;
36360 --
36361
36362 --
36363 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36364 trace
36365 (p_msg => 'END of AcctLineType_89'
36366 ,p_level => C_LEVEL_PROCEDURE
36367 ,p_module => l_log_module);
36368 END IF;
36369 --
36370 EXCEPTION
36371 WHEN xla_exceptions_pkg.application_exception THEN
36372 RAISE;
36373 WHEN OTHERS THEN
36374 xla_exceptions_pkg.raise_message
36375 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_89');
36376 END AcctLineType_89;
36377 --
36378
36379 ---------------------------------------
36380 --
36381 -- PRIVATE FUNCTION
36382 -- AcctLineType_90
36383 --
36384 ---------------------------------------
36385 PROCEDURE AcctLineType_90 (
36386 p_application_id IN NUMBER
36387 ,p_event_id IN NUMBER
36388 ,p_calculate_acctd_flag IN VARCHAR2
36389 ,p_calculate_g_l_flag IN VARCHAR2
36390 ,p_actual_flag IN OUT VARCHAR2
36391 ,p_balance_type_code OUT VARCHAR2
36392 ,p_gain_or_loss_ref OUT VARCHAR2
36393
36394 --TRANSACTION_ID
36395 , p_source_1 IN NUMBER
36396 --Item Concatenated Segments
36397 , p_source_2 IN VARCHAR2
36398 --Transaction Quantity
36399 , p_source_3 IN NUMBER
36400 --Transaction Unit of Measure Code
36401 , p_source_4 IN VARCHAR2
36402 --Inventory Transaction Type Description
36403 , p_source_5 IN VARCHAR2
36404 --Cost Management Default Account
36405 , p_source_11 IN NUMBER
36406 --DISTRIBUTION_IDENTIFIER
36407 , p_source_84 IN NUMBER
36408 --Distribution Type
36409 , p_source_85 IN VARCHAR2
36410 , p_source_85_meaning IN VARCHAR2
36411 --Entered Currency Code
36412 , p_source_88 IN VARCHAR2
36413 --Entered Amount
36414 , p_source_91 IN NUMBER
36415 --Currency Conversion Date
36416 , p_source_92 IN DATE
36417 --Currency Conversion Rate
36418 , p_source_93 IN NUMBER
36419 --Currency Conversion Type
36420 , p_source_94 IN VARCHAR2
36421 --Accounted Amount
36422 , p_source_95 IN NUMBER
36423 --Accounting Line Type
36424 , p_source_97 IN NUMBER
36425 )
36426 IS
36427
36428 l_component_type VARCHAR2(80);
36429 l_component_code VARCHAR2(30);
36430 l_component_type_code VARCHAR2(1);
36431 l_component_appl_id INTEGER;
36432 l_amb_context_code VARCHAR2(30);
36433 l_entity_code VARCHAR2(30);
36434 l_event_class_code VARCHAR2(30);
36435 l_ae_header_id NUMBER;
36436 l_event_type_code VARCHAR2(30);
36437 l_line_definition_code VARCHAR2(30);
36438 l_line_definition_owner_code VARCHAR2(1);
36439 --
36440 -- adr variables
36441 l_segment VARCHAR2(30);
36442 l_ccid NUMBER;
36443 l_adr_transaction_coa_id NUMBER;
36444 l_adr_accounting_coa_id NUMBER;
36445 l_adr_flexfield_segment_code VARCHAR2(30);
36446 l_adr_flex_value_set_id NUMBER;
36447 l_adr_value_type_code VARCHAR2(30);
36448 l_adr_value_combination_id NUMBER;
36449 l_adr_value_segment_code VARCHAR2(30);
36450
36451 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
36452 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
36453 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
36454 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
36455
36456 -- 4262811 Variables ------------------------------------------------------------------------------------------
36457 l_entered_amt_idx NUMBER;
36458 l_accted_amt_idx NUMBER;
36459 l_acc_rev_flag VARCHAR2(1);
36460 l_accrual_line_num NUMBER;
36461 l_tmp_amt NUMBER;
36462 l_acc_rev_natural_side_code VARCHAR2(1);
36463
36464 l_num_entries NUMBER;
36465 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
36466 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
36467 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
36468 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
36469 l_recog_line_1 NUMBER;
36470 l_recog_line_2 NUMBER;
36471
36472 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
36473 l_bflow_applied_to_amt NUMBER; -- 5132302
36474 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
36475
36476 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
36477
36478 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
36479 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
36480
36481 ---------------------------------------------------------------------------------------------------------------
36482
36483
36484 --
36485 -- bulk performance
36486 --
36487 l_balance_type_code VARCHAR2(1);
36488 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36489 l_log_module VARCHAR2(240);
36490
36491 --
36492 -- Upgrade strategy
36493 --
36494 l_actual_upg_option VARCHAR2(1);
36495 l_enc_upg_option VARCHAR2(1);
36496
36497 --
36498 BEGIN
36499 --
36500 IF g_log_enabled THEN
36501 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_90';
36502 END IF;
36503 --
36504 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36505
36506 trace
36507 (p_msg => 'BEGIN of AcctLineType_90'
36508 ,p_level => C_LEVEL_PROCEDURE
36509 ,p_module => l_log_module);
36510
36511 END IF;
36512 --
36513 l_component_type := 'AMB_JLT';
36514 l_component_code := 'COST_VARIANCE';
36515 l_component_type_code := 'S';
36516 l_component_appl_id := 707;
36517 l_amb_context_code := 'DEFAULT';
36518 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
36519 l_event_class_code := 'WIP_MTL';
36520 l_event_type_code := 'WIP_COMP_ISSUE';
36521 l_line_definition_owner_code := 'S';
36522 l_line_definition_code := 'PI_WIP_COMP_ISSUE';
36523 --
36524 l_balance_type_code := 'A';
36525 l_segment := NULL;
36526 l_ccid := NULL;
36527 l_adr_transaction_coa_id := NULL;
36528 l_adr_accounting_coa_id := NULL;
36529 l_adr_flexfield_segment_code := NULL;
36530 l_adr_flex_value_set_id := NULL;
36531 l_adr_value_type_code := NULL;
36532 l_adr_value_combination_id := NULL;
36533 l_adr_value_segment_code := NULL;
36534
36535 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36536 l_bflow_class_code := ''; -- 4219869 Business Flow
36537 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36538 l_budgetary_control_flag := 'N';
36539
36540 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36541 l_bflow_applied_to_amt := NULL; -- 5132302
36542 l_entered_amt_idx := NULL; -- 4262811
36543 l_accted_amt_idx := NULL; -- 4262811
36544 l_acc_rev_flag := NULL; -- 4262811
36545 l_accrual_line_num := NULL; -- 4262811
36546 l_tmp_amt := NULL; -- 4262811
36547 --
36548
36549 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36550 l_balance_type_code <> 'B' THEN
36551 IF NVL(p_source_97,9E125) = 13
36552 THEN
36553
36554 --
36555 XLA_AE_LINES_PKG.SetNewLine;
36556
36557 p_balance_type_code := l_balance_type_code;
36558 -- set the flag so later we will know whether the gain loss line needs to be created
36559
36560 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36561 p_actual_flag :='A';
36562 END IF;
36563
36564 --
36565 -- bulk performance
36566 --
36567 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36568 p_header_num => 0); -- 4262811
36569 --
36570 -- set accounting line options
36571 --
36572 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36573 p_natural_side_code => 'D'
36574 , p_gain_or_loss_flag => 'N'
36575 , p_gl_transfer_mode_code => 'S'
36576 , p_acct_entry_type_code => 'A'
36577 , p_switch_side_flag => 'Y'
36578 , p_merge_duplicate_code => 'N'
36579 );
36580 --
36581 l_acc_rev_natural_side_code := 'C'; -- 4262811
36582 --
36583 --
36584 -- set accounting line type info
36585 --
36586 xla_ae_lines_pkg.SetAcctLineType
36587 (p_component_type => l_component_type
36588 ,p_event_type_code => l_event_type_code
36589 ,p_line_definition_owner_code => l_line_definition_owner_code
36590 ,p_line_definition_code => l_line_definition_code
36591 ,p_accounting_line_code => l_component_code
36592 ,p_accounting_line_type_code => l_component_type_code
36593 ,p_accounting_line_appl_id => l_component_appl_id
36594 ,p_amb_context_code => l_amb_context_code
36595 ,p_entity_code => l_entity_code
36596 ,p_event_class_code => l_event_class_code);
36597 --
36598 -- set accounting class
36599 --
36600 xla_ae_lines_pkg.SetAcctClass(
36601 p_accounting_class_code => 'COST_VARIANCE'
36602 , p_ae_header_id => l_ae_header_id
36603 );
36604
36605 --
36606 -- set rounding class
36607 --
36608 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36609 'COST_VARIANCE';
36610
36611 --
36612 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36613 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36614 --
36615 -- bulk performance
36616 --
36617 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36618
36619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36620 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36621
36622 -- 4955764
36623 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36624 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36625
36626 -- 4458381 Public Sector Enh
36627
36628 --
36629 -- set accounting attributes for the line type
36630 --
36631 l_entered_amt_idx := 3;
36632 l_accted_amt_idx := 8;
36633 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36634 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
36635 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
36636 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
36637 l_rec_acct_attrs.array_char_value(2) := p_source_85;
36638 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
36639 l_rec_acct_attrs.array_num_value(3) := p_source_91;
36640 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
36641 l_rec_acct_attrs.array_char_value(4) := p_source_88;
36642 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
36643 l_rec_acct_attrs.array_date_value(5) := p_source_92;
36644 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
36645 l_rec_acct_attrs.array_num_value(6) := p_source_93;
36646 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
36647 l_rec_acct_attrs.array_char_value(7) := p_source_94;
36648 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
36649 l_rec_acct_attrs.array_num_value(8) := p_source_95;
36650
36651 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36652 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36653
36654 ---------------------------------------------------------------------------------------------------------------
36655 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36656 ---------------------------------------------------------------------------------------------------------------
36657 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36658
36659 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36660 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36661
36662 IF xla_accounting_cache_pkg.GetValueChar
36663 (p_source_code => 'LEDGER_CATEGORY_CODE'
36664 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36665 AND l_bflow_method_code = 'PRIOR_ENTRY'
36666 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36667 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36668 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36669 )
36670 THEN
36671 xla_ae_lines_pkg.BflowUpgEntry
36672 (p_business_method_code => l_bflow_method_code
36673 ,p_business_class_code => l_bflow_class_code
36674 ,p_balance_type => l_balance_type_code);
36675 ELSE
36676 NULL;
36677 -- No business flow processing for business flow method of NONE.
36678 END IF;
36679
36680 --
36681 -- call analytical criteria
36682 --
36683
36684 --
36685 -- call description
36686 --
36687
36688 xla_ae_lines_pkg.SetLineDescription(
36689 p_ae_header_id => l_ae_header_id
36690 ,p_description => Description_1 (
36691 p_application_id => p_application_id
36692 , p_ae_header_id => l_ae_header_id
36693 , p_source_1 => p_source_1
36694 , p_source_2 => p_source_2
36695 , p_source_3 => p_source_3
36696 , p_source_4 => p_source_4
36697 , p_source_5 => p_source_5
36698 )
36699 );
36700
36701
36702 --
36703 -- call ADRs
36704 -- Bug 4922099
36705 --
36706 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36707 (NVL(l_actual_upg_option, 'N') = 'O') OR
36708 (NVL(l_enc_upg_option, 'N') = 'O')
36709 )
36710 THEN
36711 NULL;
36712 --
36713 --
36714
36715 l_ccid := AcctDerRule_6(
36716 p_application_id => p_application_id
36717 , p_ae_header_id => l_ae_header_id
36718 , p_source_11 => p_source_11
36719 , x_transaction_coa_id => l_adr_transaction_coa_id
36720 , x_accounting_coa_id => l_adr_accounting_coa_id
36721 , x_value_type_code => l_adr_value_type_code
36722 , p_side => 'NA'
36723 );
36724
36725 xla_ae_lines_pkg.set_ccid(
36726 p_code_combination_id => l_ccid
36727 , p_value_type_code => l_adr_value_type_code
36728 , p_transaction_coa_id => l_adr_transaction_coa_id
36729 , p_accounting_coa_id => l_adr_accounting_coa_id
36730 , p_adr_code => 'CST_DEFAULT'
36731 , p_adr_type_code => 'S'
36732 , p_component_type => l_component_type
36733 , p_component_code => l_component_code
36734 , p_component_type_code => l_component_type_code
36735 , p_component_appl_id => l_component_appl_id
36736 , p_amb_context_code => l_amb_context_code
36737 , p_side => 'NA'
36738 );
36739
36740
36741 --
36742 --
36743 END IF;
36744 --
36745 -- Bug 4922099
36746 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36747 (NVL(l_enc_upg_option, 'N') = 'O')
36748 ) AND
36749 (l_bflow_method_code = 'PRIOR_ENTRY')
36750 )
36751 THEN
36752 IF
36753 --
36754 1 = 2
36755 --
36756 THEN
36757 xla_accounting_err_pkg.build_message
36758 (p_appli_s_name => 'XLA'
36759 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36760 ,p_token_1 => 'LINE_NUMBER'
36761 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36762 ,p_token_2 => 'LINE_TYPE_NAME'
36763 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36764 l_component_type
36765 ,l_component_code
36766 ,l_component_type_code
36767 ,l_component_appl_id
36768 ,l_amb_context_code
36769 ,l_entity_code
36770 ,l_event_class_code
36771 )
36772 ,p_token_3 => 'OWNER'
36773 ,p_value_3 => xla_lookups_pkg.get_meaning(
36774 p_lookup_type => 'XLA_OWNER_TYPE'
36775 ,p_lookup_code => l_component_type_code
36776 )
36777 ,p_token_4 => 'PRODUCT_NAME'
36778 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36779 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36780 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36781 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36782 ,p_ae_header_id => NULL
36783 );
36784
36785 IF (C_LEVEL_ERROR>= g_log_level) THEN
36786 trace
36787 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36788 ,p_level => C_LEVEL_ERROR
36789 ,p_module => l_log_module);
36790 END IF;
36791 END IF;
36792 END IF;
36793 --
36794 --
36795 ------------------------------------------------------------------------------------------------
36796 -- 4219869 Business Flow
36797 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36798 -- Prior Entry. Currently, the following code is always generated.
36799 ------------------------------------------------------------------------------------------------
36800 XLA_AE_LINES_PKG.ValidateCurrentLine;
36801
36802 ------------------------------------------------------------------------------------
36803 -- 4219869 Business Flow
36804 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36805 ------------------------------------------------------------------------------------
36806 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36807
36808 ----------------------------------------------------------------------------------
36809 -- 4219869 Business Flow
36810 -- Update journal entry status -- Need to generate this within IF <condition>
36811 ----------------------------------------------------------------------------------
36812 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36813 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36814 ,p_balance_type_code => l_balance_type_code
36815 );
36816
36817 -------------------------------------------------------------------------------------------
36818 -- 4262811 - Generate the Accrual Reversal lines
36819 -------------------------------------------------------------------------------------------
36820 BEGIN
36821 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36822 (g_array_event(p_event_id).array_value_num('header_index'));
36823 IF l_acc_rev_flag IS NULL THEN
36824 l_acc_rev_flag := 'N';
36825 END IF;
36826 EXCEPTION
36827 WHEN OTHERS THEN
36828 l_acc_rev_flag := 'N';
36829 END;
36830 --
36831 IF (l_acc_rev_flag = 'Y') THEN
36832
36833 -- 4645092 ------------------------------------------------------------------------------
36834 -- To allow MPA report to determine if it should generate report process
36835 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36836 ------------------------------------------------------------------------------------------
36837
36838 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36839 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36840 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36841 -- call ADRs
36842 -- Bug 4922099
36843 --
36844 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36845 (NVL(l_actual_upg_option, 'N') = 'O') OR
36846 (NVL(l_enc_upg_option, 'N') = 'O')
36847 )
36848 THEN
36849 NULL;
36850 --
36851 --
36852
36853 l_ccid := AcctDerRule_6(
36854 p_application_id => p_application_id
36855 , p_ae_header_id => l_ae_header_id
36856 , p_source_11 => p_source_11
36857 , x_transaction_coa_id => l_adr_transaction_coa_id
36858 , x_accounting_coa_id => l_adr_accounting_coa_id
36859 , x_value_type_code => l_adr_value_type_code
36860 , p_side => 'NA'
36861 );
36862
36863 xla_ae_lines_pkg.set_ccid(
36864 p_code_combination_id => l_ccid
36865 , p_value_type_code => l_adr_value_type_code
36866 , p_transaction_coa_id => l_adr_transaction_coa_id
36867 , p_accounting_coa_id => l_adr_accounting_coa_id
36868 , p_adr_code => 'CST_DEFAULT'
36869 , p_adr_type_code => 'S'
36870 , p_component_type => l_component_type
36871 , p_component_code => l_component_code
36872 , p_component_type_code => l_component_type_code
36873 , p_component_appl_id => l_component_appl_id
36874 , p_amb_context_code => l_amb_context_code
36875 , p_side => 'NA'
36876 );
36877
36878
36879 --
36880 --
36881 END IF;
36882
36883 --
36884 -- Update the line information that should be overwritten
36885 --
36886 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36887 p_header_num => 1);
36888 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36889
36890 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36891
36892 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36893 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36894 END IF;
36895
36896 --
36897 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36898 --
36899 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36900 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36901 ELSE
36902 ---------------------------------------------------------------------------------------------------
36903 -- 4262811a Switch Sign
36904 ---------------------------------------------------------------------------------------------------
36905 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36906 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36907 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36908 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36909 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36910 -- 5132302
36911 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36912 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36913
36914 END IF;
36915
36916 -- 4955764
36917 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36918 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36919
36920
36921 XLA_AE_LINES_PKG.ValidateCurrentLine;
36922 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36923
36924 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36925 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36926 ,p_balance_type_code => l_balance_type_code);
36927
36928 END IF;
36929
36930 -----------------------------------------------------------------------------------------
36931 -- 4262811 Multiperiod Accounting
36932 -----------------------------------------------------------------------------------------
36933 -- No MPA option is assigned.
36934
36935
36936 END IF;
36937 END IF;
36938 --
36939
36940 --
36941 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36942 trace
36943 (p_msg => 'END of AcctLineType_90'
36944 ,p_level => C_LEVEL_PROCEDURE
36945 ,p_module => l_log_module);
36946 END IF;
36947 --
36948 EXCEPTION
36949 WHEN xla_exceptions_pkg.application_exception THEN
36950 RAISE;
36951 WHEN OTHERS THEN
36952 xla_exceptions_pkg.raise_message
36953 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_90');
36954 END AcctLineType_90;
36955 --
36956
36957 ---------------------------------------
36958 --
36959 -- PRIVATE FUNCTION
36960 -- AcctLineType_91
36961 --
36962 ---------------------------------------
36963 PROCEDURE AcctLineType_91 (
36964 p_application_id IN NUMBER
36965 ,p_event_id IN NUMBER
36966 ,p_calculate_acctd_flag IN VARCHAR2
36967 ,p_calculate_g_l_flag IN VARCHAR2
36968 ,p_actual_flag IN OUT VARCHAR2
36969 ,p_balance_type_code OUT VARCHAR2
36970 ,p_gain_or_loss_ref OUT VARCHAR2
36971
36972 --TRANSACTION_ID
36973 , p_source_1 IN NUMBER
36974 --Item Concatenated Segments
36975 , p_source_2 IN VARCHAR2
36976 --Transaction Quantity
36977 , p_source_3 IN NUMBER
36978 --Transaction Unit of Measure Code
36979 , p_source_4 IN VARCHAR2
36980 --Inventory Transaction Type Description
36981 , p_source_5 IN VARCHAR2
36982 --Cost Management Default Account
36983 , p_source_11 IN NUMBER
36984 --DISTRIBUTION_IDENTIFIER
36985 , p_source_84 IN NUMBER
36986 --Distribution Type
36987 , p_source_85 IN VARCHAR2
36988 , p_source_85_meaning IN VARCHAR2
36989 --Entered Currency Code
36990 , p_source_88 IN VARCHAR2
36991 --Entered Amount
36992 , p_source_91 IN NUMBER
36993 --Currency Conversion Date
36994 , p_source_92 IN DATE
36995 --Currency Conversion Rate
36996 , p_source_93 IN NUMBER
36997 --Currency Conversion Type
36998 , p_source_94 IN VARCHAR2
36999 --Accounted Amount
37000 , p_source_95 IN NUMBER
37001 --Accounting Line Type
37002 , p_source_97 IN NUMBER
37003 )
37004 IS
37005
37006 l_component_type VARCHAR2(80);
37007 l_component_code VARCHAR2(30);
37008 l_component_type_code VARCHAR2(1);
37009 l_component_appl_id INTEGER;
37010 l_amb_context_code VARCHAR2(30);
37011 l_entity_code VARCHAR2(30);
37012 l_event_class_code VARCHAR2(30);
37013 l_ae_header_id NUMBER;
37014 l_event_type_code VARCHAR2(30);
37015 l_line_definition_code VARCHAR2(30);
37016 l_line_definition_owner_code VARCHAR2(1);
37017 --
37018 -- adr variables
37019 l_segment VARCHAR2(30);
37020 l_ccid NUMBER;
37021 l_adr_transaction_coa_id NUMBER;
37022 l_adr_accounting_coa_id NUMBER;
37023 l_adr_flexfield_segment_code VARCHAR2(30);
37024 l_adr_flex_value_set_id NUMBER;
37025 l_adr_value_type_code VARCHAR2(30);
37026 l_adr_value_combination_id NUMBER;
37027 l_adr_value_segment_code VARCHAR2(30);
37028
37029 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37030 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37031 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37032 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37033
37034 -- 4262811 Variables ------------------------------------------------------------------------------------------
37035 l_entered_amt_idx NUMBER;
37036 l_accted_amt_idx NUMBER;
37037 l_acc_rev_flag VARCHAR2(1);
37038 l_accrual_line_num NUMBER;
37039 l_tmp_amt NUMBER;
37040 l_acc_rev_natural_side_code VARCHAR2(1);
37041
37042 l_num_entries NUMBER;
37043 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37044 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37045 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37046 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37047 l_recog_line_1 NUMBER;
37048 l_recog_line_2 NUMBER;
37049
37050 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37051 l_bflow_applied_to_amt NUMBER; -- 5132302
37052 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37053
37054 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37055
37056 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37057 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37058
37059 ---------------------------------------------------------------------------------------------------------------
37060
37061
37062 --
37063 -- bulk performance
37064 --
37065 l_balance_type_code VARCHAR2(1);
37066 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37067 l_log_module VARCHAR2(240);
37068
37069 --
37070 -- Upgrade strategy
37071 --
37072 l_actual_upg_option VARCHAR2(1);
37073 l_enc_upg_option VARCHAR2(1);
37074
37075 --
37076 BEGIN
37077 --
37078 IF g_log_enabled THEN
37079 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_91';
37080 END IF;
37081 --
37082 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37083
37084 trace
37085 (p_msg => 'BEGIN of AcctLineType_91'
37086 ,p_level => C_LEVEL_PROCEDURE
37087 ,p_module => l_log_module);
37088
37089 END IF;
37090 --
37091 l_component_type := 'AMB_JLT';
37092 l_component_code := 'COST_VARIANCE';
37093 l_component_type_code := 'S';
37094 l_component_appl_id := 707;
37095 l_amb_context_code := 'DEFAULT';
37096 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
37097 l_event_class_code := 'MTL_COST_UPD';
37098 l_event_type_code := 'AVG_COST_UPD';
37099 l_line_definition_owner_code := 'S';
37100 l_line_definition_code := 'PI_AVG_COST_UPD';
37101 --
37102 l_balance_type_code := 'A';
37103 l_segment := NULL;
37104 l_ccid := NULL;
37105 l_adr_transaction_coa_id := NULL;
37106 l_adr_accounting_coa_id := NULL;
37107 l_adr_flexfield_segment_code := NULL;
37108 l_adr_flex_value_set_id := NULL;
37109 l_adr_value_type_code := NULL;
37110 l_adr_value_combination_id := NULL;
37111 l_adr_value_segment_code := NULL;
37112
37113 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37114 l_bflow_class_code := ''; -- 4219869 Business Flow
37115 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37116 l_budgetary_control_flag := 'N';
37117
37118 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37119 l_bflow_applied_to_amt := NULL; -- 5132302
37120 l_entered_amt_idx := NULL; -- 4262811
37121 l_accted_amt_idx := NULL; -- 4262811
37122 l_acc_rev_flag := NULL; -- 4262811
37123 l_accrual_line_num := NULL; -- 4262811
37124 l_tmp_amt := NULL; -- 4262811
37125 --
37126
37127 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37128 l_balance_type_code <> 'B' THEN
37129 IF NVL(p_source_97,9E125) = 13
37130 THEN
37131
37132 --
37133 XLA_AE_LINES_PKG.SetNewLine;
37134
37135 p_balance_type_code := l_balance_type_code;
37136 -- set the flag so later we will know whether the gain loss line needs to be created
37137
37138 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37139 p_actual_flag :='A';
37140 END IF;
37141
37142 --
37143 -- bulk performance
37144 --
37145 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37146 p_header_num => 0); -- 4262811
37147 --
37148 -- set accounting line options
37149 --
37150 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37151 p_natural_side_code => 'D'
37152 , p_gain_or_loss_flag => 'N'
37153 , p_gl_transfer_mode_code => 'S'
37154 , p_acct_entry_type_code => 'A'
37155 , p_switch_side_flag => 'Y'
37156 , p_merge_duplicate_code => 'N'
37157 );
37158 --
37159 l_acc_rev_natural_side_code := 'C'; -- 4262811
37160 --
37161 --
37162 -- set accounting line type info
37163 --
37164 xla_ae_lines_pkg.SetAcctLineType
37165 (p_component_type => l_component_type
37166 ,p_event_type_code => l_event_type_code
37167 ,p_line_definition_owner_code => l_line_definition_owner_code
37168 ,p_line_definition_code => l_line_definition_code
37169 ,p_accounting_line_code => l_component_code
37170 ,p_accounting_line_type_code => l_component_type_code
37171 ,p_accounting_line_appl_id => l_component_appl_id
37172 ,p_amb_context_code => l_amb_context_code
37173 ,p_entity_code => l_entity_code
37174 ,p_event_class_code => l_event_class_code);
37175 --
37176 -- set accounting class
37177 --
37178 xla_ae_lines_pkg.SetAcctClass(
37179 p_accounting_class_code => 'COST_VARIANCE'
37180 , p_ae_header_id => l_ae_header_id
37181 );
37182
37183 --
37184 -- set rounding class
37185 --
37186 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37187 'COST_VARIANCE';
37188
37189 --
37190 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37191 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37192 --
37193 -- bulk performance
37194 --
37195 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37196
37197 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37198 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37199
37200 -- 4955764
37201 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37202 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37203
37204 -- 4458381 Public Sector Enh
37205
37206 --
37207 -- set accounting attributes for the line type
37208 --
37209 l_entered_amt_idx := 3;
37210 l_accted_amt_idx := 8;
37211 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37212 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
37213 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
37214 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
37215 l_rec_acct_attrs.array_char_value(2) := p_source_85;
37216 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
37217 l_rec_acct_attrs.array_num_value(3) := p_source_91;
37218 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
37219 l_rec_acct_attrs.array_char_value(4) := p_source_88;
37220 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
37221 l_rec_acct_attrs.array_date_value(5) := p_source_92;
37222 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
37223 l_rec_acct_attrs.array_num_value(6) := p_source_93;
37224 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
37225 l_rec_acct_attrs.array_char_value(7) := p_source_94;
37226 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
37227 l_rec_acct_attrs.array_num_value(8) := p_source_95;
37228
37229 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37230 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37231
37232 ---------------------------------------------------------------------------------------------------------------
37233 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37234 ---------------------------------------------------------------------------------------------------------------
37235 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37236
37237 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37238 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37239
37240 IF xla_accounting_cache_pkg.GetValueChar
37241 (p_source_code => 'LEDGER_CATEGORY_CODE'
37242 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37243 AND l_bflow_method_code = 'PRIOR_ENTRY'
37244 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37245 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37246 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37247 )
37248 THEN
37249 xla_ae_lines_pkg.BflowUpgEntry
37250 (p_business_method_code => l_bflow_method_code
37251 ,p_business_class_code => l_bflow_class_code
37252 ,p_balance_type => l_balance_type_code);
37253 ELSE
37254 NULL;
37255 -- No business flow processing for business flow method of NONE.
37256 END IF;
37257
37258 --
37259 -- call analytical criteria
37260 --
37261
37262 --
37263 -- call description
37264 --
37265
37266 xla_ae_lines_pkg.SetLineDescription(
37267 p_ae_header_id => l_ae_header_id
37268 ,p_description => Description_1 (
37269 p_application_id => p_application_id
37270 , p_ae_header_id => l_ae_header_id
37271 , p_source_1 => p_source_1
37272 , p_source_2 => p_source_2
37273 , p_source_3 => p_source_3
37274 , p_source_4 => p_source_4
37275 , p_source_5 => p_source_5
37276 )
37277 );
37278
37279
37280 --
37281 -- call ADRs
37282 -- Bug 4922099
37283 --
37284 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37285 (NVL(l_actual_upg_option, 'N') = 'O') OR
37286 (NVL(l_enc_upg_option, 'N') = 'O')
37287 )
37288 THEN
37289 NULL;
37290 --
37291 --
37292
37293 l_ccid := AcctDerRule_6(
37294 p_application_id => p_application_id
37295 , p_ae_header_id => l_ae_header_id
37296 , p_source_11 => p_source_11
37297 , x_transaction_coa_id => l_adr_transaction_coa_id
37298 , x_accounting_coa_id => l_adr_accounting_coa_id
37299 , x_value_type_code => l_adr_value_type_code
37300 , p_side => 'NA'
37301 );
37302
37303 xla_ae_lines_pkg.set_ccid(
37304 p_code_combination_id => l_ccid
37305 , p_value_type_code => l_adr_value_type_code
37306 , p_transaction_coa_id => l_adr_transaction_coa_id
37307 , p_accounting_coa_id => l_adr_accounting_coa_id
37308 , p_adr_code => 'CST_DEFAULT'
37309 , p_adr_type_code => 'S'
37310 , p_component_type => l_component_type
37311 , p_component_code => l_component_code
37312 , p_component_type_code => l_component_type_code
37313 , p_component_appl_id => l_component_appl_id
37314 , p_amb_context_code => l_amb_context_code
37315 , p_side => 'NA'
37316 );
37317
37318
37319 --
37320 --
37321 END IF;
37322 --
37323 -- Bug 4922099
37324 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37325 (NVL(l_enc_upg_option, 'N') = 'O')
37326 ) AND
37327 (l_bflow_method_code = 'PRIOR_ENTRY')
37328 )
37329 THEN
37330 IF
37331 --
37332 1 = 2
37333 --
37334 THEN
37335 xla_accounting_err_pkg.build_message
37336 (p_appli_s_name => 'XLA'
37337 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37338 ,p_token_1 => 'LINE_NUMBER'
37339 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37340 ,p_token_2 => 'LINE_TYPE_NAME'
37341 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37342 l_component_type
37343 ,l_component_code
37344 ,l_component_type_code
37345 ,l_component_appl_id
37346 ,l_amb_context_code
37347 ,l_entity_code
37348 ,l_event_class_code
37349 )
37350 ,p_token_3 => 'OWNER'
37351 ,p_value_3 => xla_lookups_pkg.get_meaning(
37352 p_lookup_type => 'XLA_OWNER_TYPE'
37353 ,p_lookup_code => l_component_type_code
37354 )
37355 ,p_token_4 => 'PRODUCT_NAME'
37356 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37357 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37358 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37359 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37360 ,p_ae_header_id => NULL
37361 );
37362
37363 IF (C_LEVEL_ERROR>= g_log_level) THEN
37364 trace
37365 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37366 ,p_level => C_LEVEL_ERROR
37367 ,p_module => l_log_module);
37368 END IF;
37369 END IF;
37370 END IF;
37371 --
37372 --
37373 ------------------------------------------------------------------------------------------------
37374 -- 4219869 Business Flow
37375 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37376 -- Prior Entry. Currently, the following code is always generated.
37377 ------------------------------------------------------------------------------------------------
37378 XLA_AE_LINES_PKG.ValidateCurrentLine;
37379
37380 ------------------------------------------------------------------------------------
37381 -- 4219869 Business Flow
37382 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37383 ------------------------------------------------------------------------------------
37384 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37385
37386 ----------------------------------------------------------------------------------
37387 -- 4219869 Business Flow
37388 -- Update journal entry status -- Need to generate this within IF <condition>
37389 ----------------------------------------------------------------------------------
37390 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37391 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37392 ,p_balance_type_code => l_balance_type_code
37393 );
37394
37395 -------------------------------------------------------------------------------------------
37396 -- 4262811 - Generate the Accrual Reversal lines
37397 -------------------------------------------------------------------------------------------
37398 BEGIN
37399 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37400 (g_array_event(p_event_id).array_value_num('header_index'));
37401 IF l_acc_rev_flag IS NULL THEN
37402 l_acc_rev_flag := 'N';
37403 END IF;
37404 EXCEPTION
37405 WHEN OTHERS THEN
37406 l_acc_rev_flag := 'N';
37407 END;
37408 --
37409 IF (l_acc_rev_flag = 'Y') THEN
37410
37411 -- 4645092 ------------------------------------------------------------------------------
37412 -- To allow MPA report to determine if it should generate report process
37413 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37414 ------------------------------------------------------------------------------------------
37415
37416 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37417 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37418 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37419 -- call ADRs
37420 -- Bug 4922099
37421 --
37422 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37423 (NVL(l_actual_upg_option, 'N') = 'O') OR
37424 (NVL(l_enc_upg_option, 'N') = 'O')
37425 )
37426 THEN
37427 NULL;
37428 --
37429 --
37430
37431 l_ccid := AcctDerRule_6(
37432 p_application_id => p_application_id
37433 , p_ae_header_id => l_ae_header_id
37434 , p_source_11 => p_source_11
37435 , x_transaction_coa_id => l_adr_transaction_coa_id
37436 , x_accounting_coa_id => l_adr_accounting_coa_id
37437 , x_value_type_code => l_adr_value_type_code
37438 , p_side => 'NA'
37439 );
37440
37441 xla_ae_lines_pkg.set_ccid(
37442 p_code_combination_id => l_ccid
37443 , p_value_type_code => l_adr_value_type_code
37444 , p_transaction_coa_id => l_adr_transaction_coa_id
37445 , p_accounting_coa_id => l_adr_accounting_coa_id
37446 , p_adr_code => 'CST_DEFAULT'
37447 , p_adr_type_code => 'S'
37448 , p_component_type => l_component_type
37449 , p_component_code => l_component_code
37450 , p_component_type_code => l_component_type_code
37451 , p_component_appl_id => l_component_appl_id
37452 , p_amb_context_code => l_amb_context_code
37453 , p_side => 'NA'
37454 );
37455
37456
37457 --
37458 --
37459 END IF;
37460
37461 --
37462 -- Update the line information that should be overwritten
37463 --
37464 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37465 p_header_num => 1);
37466 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37467
37468 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37469
37470 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37471 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37472 END IF;
37473
37474 --
37475 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37476 --
37477 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37478 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37479 ELSE
37480 ---------------------------------------------------------------------------------------------------
37481 -- 4262811a Switch Sign
37482 ---------------------------------------------------------------------------------------------------
37483 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37484 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37485 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37486 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37487 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37488 -- 5132302
37489 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37490 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37491
37492 END IF;
37493
37494 -- 4955764
37495 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37496 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37497
37498
37499 XLA_AE_LINES_PKG.ValidateCurrentLine;
37500 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37501
37502 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37503 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37504 ,p_balance_type_code => l_balance_type_code);
37505
37506 END IF;
37507
37508 -----------------------------------------------------------------------------------------
37509 -- 4262811 Multiperiod Accounting
37510 -----------------------------------------------------------------------------------------
37511 -- No MPA option is assigned.
37512
37513
37514 END IF;
37515 END IF;
37516 --
37517
37518 --
37519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37520 trace
37521 (p_msg => 'END of AcctLineType_91'
37522 ,p_level => C_LEVEL_PROCEDURE
37523 ,p_module => l_log_module);
37524 END IF;
37525 --
37526 EXCEPTION
37527 WHEN xla_exceptions_pkg.application_exception THEN
37528 RAISE;
37529 WHEN OTHERS THEN
37530 xla_exceptions_pkg.raise_message
37531 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_91');
37532 END AcctLineType_91;
37533 --
37534
37535 ---------------------------------------
37536 --
37537 -- PRIVATE FUNCTION
37538 -- AcctLineType_92
37539 --
37540 ---------------------------------------
37541 PROCEDURE AcctLineType_92 (
37542 p_application_id IN NUMBER
37543 ,p_event_id IN NUMBER
37544 ,p_calculate_acctd_flag IN VARCHAR2
37545 ,p_calculate_g_l_flag IN VARCHAR2
37546 ,p_actual_flag IN OUT VARCHAR2
37547 ,p_balance_type_code OUT VARCHAR2
37548 ,p_gain_or_loss_ref OUT VARCHAR2
37549
37550 --TRANSACTION_ID
37551 , p_source_1 IN NUMBER
37552 --Item Concatenated Segments
37553 , p_source_2 IN VARCHAR2
37554 --Transaction Quantity
37555 , p_source_3 IN NUMBER
37556 --Transaction Unit of Measure Code
37557 , p_source_4 IN VARCHAR2
37558 --Inventory Transaction Type Description
37559 , p_source_5 IN VARCHAR2
37560 --Cost Management Default Account
37561 , p_source_11 IN NUMBER
37562 --Applied to Application ID
37563 , p_source_79 IN NUMBER
37564 --Applied to Distribution Link Type
37565 , p_source_80 IN VARCHAR2
37566 --Applied to Entity Code
37567 , p_source_81 IN VARCHAR2
37568 --Applied To Purchase Document Identifier
37569 , p_source_83 IN NUMBER
37570 --DISTRIBUTION_IDENTIFIER
37571 , p_source_84 IN NUMBER
37572 --Distribution Type
37573 , p_source_85 IN VARCHAR2
37574 , p_source_85_meaning IN VARCHAR2
37575 --PO Budget Account
37576 , p_source_86 IN NUMBER
37577 --Encumbrance Reversal Amount Entered
37578 , p_source_87 IN NUMBER
37579 --Entered Currency Code
37580 , p_source_88 IN VARCHAR2
37581 --Transaction Encumbrance Reversal Amount
37582 , p_source_89 IN NUMBER
37583 --Entered Amount
37584 , p_source_91 IN NUMBER
37585 --Currency Conversion Date
37586 , p_source_92 IN DATE
37587 --Currency Conversion Rate
37588 , p_source_93 IN NUMBER
37589 --Currency Conversion Type
37590 , p_source_94 IN VARCHAR2
37591 --Accounted Amount
37592 , p_source_95 IN NUMBER
37593 --Purchasing Encumbrance Type Identifier
37594 , p_source_96 IN NUMBER
37595 --Accounting Line Type
37596 , p_source_97 IN NUMBER
37597 --Costing Encumbrance Upgrade Option
37598 , p_source_100 IN VARCHAR2
37599 --TXN_PO_DISTRIBUTION_ID
37600 , p_source_101 IN NUMBER
37601 )
37602 IS
37603
37604 l_component_type VARCHAR2(80);
37605 l_component_code VARCHAR2(30);
37606 l_component_type_code VARCHAR2(1);
37607 l_component_appl_id INTEGER;
37608 l_amb_context_code VARCHAR2(30);
37609 l_entity_code VARCHAR2(30);
37610 l_event_class_code VARCHAR2(30);
37611 l_ae_header_id NUMBER;
37612 l_event_type_code VARCHAR2(30);
37613 l_line_definition_code VARCHAR2(30);
37614 l_line_definition_owner_code VARCHAR2(1);
37615 --
37616 -- adr variables
37617 l_segment VARCHAR2(30);
37618 l_ccid NUMBER;
37619 l_adr_transaction_coa_id NUMBER;
37620 l_adr_accounting_coa_id NUMBER;
37621 l_adr_flexfield_segment_code VARCHAR2(30);
37622 l_adr_flex_value_set_id NUMBER;
37623 l_adr_value_type_code VARCHAR2(30);
37624 l_adr_value_combination_id NUMBER;
37625 l_adr_value_segment_code VARCHAR2(30);
37626
37627 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37628 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37629 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37630 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37631
37632 -- 4262811 Variables ------------------------------------------------------------------------------------------
37633 l_entered_amt_idx NUMBER;
37634 l_accted_amt_idx NUMBER;
37635 l_acc_rev_flag VARCHAR2(1);
37636 l_accrual_line_num NUMBER;
37637 l_tmp_amt NUMBER;
37638 l_acc_rev_natural_side_code VARCHAR2(1);
37639
37640 l_num_entries NUMBER;
37641 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37642 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37643 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37644 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37645 l_recog_line_1 NUMBER;
37646 l_recog_line_2 NUMBER;
37647
37648 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37649 l_bflow_applied_to_amt NUMBER; -- 5132302
37650 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37651
37652 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37653
37654 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37655 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37656
37657 ---------------------------------------------------------------------------------------------------------------
37658
37659
37660 --
37661 -- bulk performance
37662 --
37663 l_balance_type_code VARCHAR2(1);
37664 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37665 l_log_module VARCHAR2(240);
37666
37667 --
37668 -- Upgrade strategy
37669 --
37670 l_actual_upg_option VARCHAR2(1);
37671 l_enc_upg_option VARCHAR2(1);
37672
37673 --
37674 BEGIN
37675 --
37676 IF g_log_enabled THEN
37677 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_92';
37678 END IF;
37679 --
37680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37681
37682 trace
37683 (p_msg => 'BEGIN of AcctLineType_92'
37684 ,p_level => C_LEVEL_PROCEDURE
37685 ,p_module => l_log_module);
37686
37687 END IF;
37688 --
37689 l_component_type := 'AMB_JLT';
37690 l_component_code := 'COST_VARIANCE';
37691 l_component_type_code := 'S';
37692 l_component_appl_id := 707;
37693 l_amb_context_code := 'DEFAULT';
37694 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
37695 l_event_class_code := 'PURCHASE_ORDER';
37696 l_event_type_code := 'RET_RI_INV';
37697 l_line_definition_owner_code := 'S';
37698 l_line_definition_code := 'PI_RET_RI_INV';
37699 --
37700 l_balance_type_code := 'A';
37701 l_segment := NULL;
37702 l_ccid := NULL;
37703 l_adr_transaction_coa_id := NULL;
37704 l_adr_accounting_coa_id := NULL;
37705 l_adr_flexfield_segment_code := NULL;
37706 l_adr_flex_value_set_id := NULL;
37707 l_adr_value_type_code := NULL;
37708 l_adr_value_combination_id := NULL;
37709 l_adr_value_segment_code := NULL;
37710
37711 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37712 l_bflow_class_code := ''; -- 4219869 Business Flow
37713 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37714 l_budgetary_control_flag := 'N';
37715
37716 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37717 l_bflow_applied_to_amt := NULL; -- 5132302
37718 l_entered_amt_idx := NULL; -- 4262811
37719 l_accted_amt_idx := NULL; -- 4262811
37720 l_acc_rev_flag := NULL; -- 4262811
37721 l_accrual_line_num := NULL; -- 4262811
37722 l_tmp_amt := NULL; -- 4262811
37723 --
37724
37725 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37726 l_balance_type_code <> 'B' THEN
37727 IF NVL(p_source_97,9E125) = 13
37728 THEN
37729
37730 --
37731 XLA_AE_LINES_PKG.SetNewLine;
37732
37733 p_balance_type_code := l_balance_type_code;
37734 -- set the flag so later we will know whether the gain loss line needs to be created
37735
37736 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37737 p_actual_flag :='A';
37738 END IF;
37739
37740 --
37741 -- bulk performance
37742 --
37743 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37744 p_header_num => 0); -- 4262811
37745 --
37746 -- set accounting line options
37747 --
37748 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37749 p_natural_side_code => 'D'
37750 , p_gain_or_loss_flag => 'N'
37751 , p_gl_transfer_mode_code => 'S'
37752 , p_acct_entry_type_code => 'A'
37753 , p_switch_side_flag => 'Y'
37754 , p_merge_duplicate_code => 'N'
37755 );
37756 --
37757 l_acc_rev_natural_side_code := 'C'; -- 4262811
37758 --
37759 --
37760 -- set accounting line type info
37761 --
37762 xla_ae_lines_pkg.SetAcctLineType
37763 (p_component_type => l_component_type
37764 ,p_event_type_code => l_event_type_code
37765 ,p_line_definition_owner_code => l_line_definition_owner_code
37766 ,p_line_definition_code => l_line_definition_code
37767 ,p_accounting_line_code => l_component_code
37768 ,p_accounting_line_type_code => l_component_type_code
37769 ,p_accounting_line_appl_id => l_component_appl_id
37770 ,p_amb_context_code => l_amb_context_code
37771 ,p_entity_code => l_entity_code
37772 ,p_event_class_code => l_event_class_code);
37773 --
37774 -- set accounting class
37775 --
37776 xla_ae_lines_pkg.SetAcctClass(
37777 p_accounting_class_code => 'COST_VARIANCE'
37778 , p_ae_header_id => l_ae_header_id
37779 );
37780
37781 --
37782 -- set rounding class
37783 --
37784 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37785 'COST_VARIANCE';
37786
37787 --
37788 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37789 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37790 --
37791 -- bulk performance
37792 --
37793 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37794
37795 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37796 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37797
37798 -- 4955764
37799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37801
37802 -- 4458381 Public Sector Enh
37803
37804 --
37805 -- set accounting attributes for the line type
37806 --
37807 l_entered_amt_idx := 17;
37808 l_accted_amt_idx := 22;
37809 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37810 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
37811 l_rec_acct_attrs.array_num_value(1) := p_source_79;
37812 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
37813 l_rec_acct_attrs.array_char_value(2) := p_source_80;
37814 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
37815 l_rec_acct_attrs.array_char_value(3) := p_source_81;
37816 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
37817 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
37818 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
37819 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
37820 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
37821 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
37822 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
37823 l_rec_acct_attrs.array_char_value(7) := p_source_85;
37824 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
37825 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
37826 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
37827 l_rec_acct_attrs.array_num_value(9) := p_source_87;
37828 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
37829 l_rec_acct_attrs.array_char_value(10) := p_source_88;
37830 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
37831 l_rec_acct_attrs.array_num_value(11) := p_source_89;
37832 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
37833 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
37834 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
37835 l_rec_acct_attrs.array_num_value(13) := p_source_87;
37836 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
37837 l_rec_acct_attrs.array_char_value(14) := p_source_88;
37838 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
37839 l_rec_acct_attrs.array_num_value(15) := p_source_89;
37840 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
37841 l_rec_acct_attrs.array_char_value(16) := p_source_100;
37842 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
37843 l_rec_acct_attrs.array_num_value(17) := p_source_91;
37844 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
37845 l_rec_acct_attrs.array_char_value(18) := p_source_88;
37846 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
37847 l_rec_acct_attrs.array_date_value(19) := p_source_92;
37848 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
37849 l_rec_acct_attrs.array_num_value(20) := p_source_93;
37850 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
37851 l_rec_acct_attrs.array_char_value(21) := p_source_94;
37852 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
37853 l_rec_acct_attrs.array_num_value(22) := p_source_95;
37854 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
37855 l_rec_acct_attrs.array_num_value(23) := p_source_96;
37856 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
37857 l_rec_acct_attrs.array_num_value(24) := p_source_96;
37858
37859 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37860 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37861
37862 ---------------------------------------------------------------------------------------------------------------
37863 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37864 ---------------------------------------------------------------------------------------------------------------
37865 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37866
37867 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37868 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37869
37870 IF xla_accounting_cache_pkg.GetValueChar
37871 (p_source_code => 'LEDGER_CATEGORY_CODE'
37872 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37873 AND l_bflow_method_code = 'PRIOR_ENTRY'
37874 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37875 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37876 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37877 )
37878 THEN
37879 xla_ae_lines_pkg.BflowUpgEntry
37880 (p_business_method_code => l_bflow_method_code
37881 ,p_business_class_code => l_bflow_class_code
37882 ,p_balance_type => l_balance_type_code);
37883 ELSE
37884 NULL;
37885 -- No business flow processing for business flow method of NONE.
37886 END IF;
37887
37888 --
37889 -- call analytical criteria
37890 --
37891
37892 --
37893 -- call description
37894 --
37895
37896 xla_ae_lines_pkg.SetLineDescription(
37897 p_ae_header_id => l_ae_header_id
37898 ,p_description => Description_1 (
37899 p_application_id => p_application_id
37900 , p_ae_header_id => l_ae_header_id
37901 , p_source_1 => p_source_1
37902 , p_source_2 => p_source_2
37903 , p_source_3 => p_source_3
37904 , p_source_4 => p_source_4
37905 , p_source_5 => p_source_5
37906 )
37907 );
37908
37909
37910 --
37911 -- call ADRs
37912 -- Bug 4922099
37913 --
37914 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37915 (NVL(l_actual_upg_option, 'N') = 'O') OR
37916 (NVL(l_enc_upg_option, 'N') = 'O')
37917 )
37918 THEN
37919 NULL;
37920 --
37921 --
37922
37923 l_ccid := AcctDerRule_6(
37924 p_application_id => p_application_id
37925 , p_ae_header_id => l_ae_header_id
37926 , p_source_11 => p_source_11
37927 , x_transaction_coa_id => l_adr_transaction_coa_id
37928 , x_accounting_coa_id => l_adr_accounting_coa_id
37929 , x_value_type_code => l_adr_value_type_code
37930 , p_side => 'NA'
37931 );
37932
37933 xla_ae_lines_pkg.set_ccid(
37934 p_code_combination_id => l_ccid
37935 , p_value_type_code => l_adr_value_type_code
37936 , p_transaction_coa_id => l_adr_transaction_coa_id
37937 , p_accounting_coa_id => l_adr_accounting_coa_id
37938 , p_adr_code => 'CST_DEFAULT'
37939 , p_adr_type_code => 'S'
37940 , p_component_type => l_component_type
37941 , p_component_code => l_component_code
37942 , p_component_type_code => l_component_type_code
37943 , p_component_appl_id => l_component_appl_id
37944 , p_amb_context_code => l_amb_context_code
37945 , p_side => 'NA'
37946 );
37947
37948
37949 --
37950 --
37951 END IF;
37952 --
37953 -- Bug 4922099
37954 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37955 (NVL(l_enc_upg_option, 'N') = 'O')
37956 ) AND
37957 (l_bflow_method_code = 'PRIOR_ENTRY')
37958 )
37959 THEN
37960 IF
37961 --
37962 1 = 2
37963 --
37964 THEN
37965 xla_accounting_err_pkg.build_message
37966 (p_appli_s_name => 'XLA'
37967 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37968 ,p_token_1 => 'LINE_NUMBER'
37969 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37970 ,p_token_2 => 'LINE_TYPE_NAME'
37971 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37972 l_component_type
37973 ,l_component_code
37974 ,l_component_type_code
37975 ,l_component_appl_id
37976 ,l_amb_context_code
37977 ,l_entity_code
37978 ,l_event_class_code
37979 )
37980 ,p_token_3 => 'OWNER'
37981 ,p_value_3 => xla_lookups_pkg.get_meaning(
37982 p_lookup_type => 'XLA_OWNER_TYPE'
37983 ,p_lookup_code => l_component_type_code
37984 )
37985 ,p_token_4 => 'PRODUCT_NAME'
37986 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37987 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37988 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37989 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37990 ,p_ae_header_id => NULL
37991 );
37992
37993 IF (C_LEVEL_ERROR>= g_log_level) THEN
37994 trace
37995 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37996 ,p_level => C_LEVEL_ERROR
37997 ,p_module => l_log_module);
37998 END IF;
37999 END IF;
38000 END IF;
38001 --
38002 --
38003 ------------------------------------------------------------------------------------------------
38004 -- 4219869 Business Flow
38005 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38006 -- Prior Entry. Currently, the following code is always generated.
38007 ------------------------------------------------------------------------------------------------
38008 XLA_AE_LINES_PKG.ValidateCurrentLine;
38009
38010 ------------------------------------------------------------------------------------
38011 -- 4219869 Business Flow
38012 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38013 ------------------------------------------------------------------------------------
38014 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38015
38016 ----------------------------------------------------------------------------------
38017 -- 4219869 Business Flow
38018 -- Update journal entry status -- Need to generate this within IF <condition>
38019 ----------------------------------------------------------------------------------
38020 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38021 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38022 ,p_balance_type_code => l_balance_type_code
38023 );
38024
38025 -------------------------------------------------------------------------------------------
38026 -- 4262811 - Generate the Accrual Reversal lines
38027 -------------------------------------------------------------------------------------------
38028 BEGIN
38029 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38030 (g_array_event(p_event_id).array_value_num('header_index'));
38031 IF l_acc_rev_flag IS NULL THEN
38032 l_acc_rev_flag := 'N';
38033 END IF;
38034 EXCEPTION
38035 WHEN OTHERS THEN
38036 l_acc_rev_flag := 'N';
38037 END;
38038 --
38039 IF (l_acc_rev_flag = 'Y') THEN
38040
38041 -- 4645092 ------------------------------------------------------------------------------
38042 -- To allow MPA report to determine if it should generate report process
38043 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38044 ------------------------------------------------------------------------------------------
38045
38046 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38047 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38048 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38049 -- call ADRs
38050 -- Bug 4922099
38051 --
38052 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38053 (NVL(l_actual_upg_option, 'N') = 'O') OR
38054 (NVL(l_enc_upg_option, 'N') = 'O')
38055 )
38056 THEN
38057 NULL;
38058 --
38059 --
38060
38061 l_ccid := AcctDerRule_6(
38062 p_application_id => p_application_id
38063 , p_ae_header_id => l_ae_header_id
38064 , p_source_11 => p_source_11
38065 , x_transaction_coa_id => l_adr_transaction_coa_id
38066 , x_accounting_coa_id => l_adr_accounting_coa_id
38067 , x_value_type_code => l_adr_value_type_code
38068 , p_side => 'NA'
38069 );
38070
38071 xla_ae_lines_pkg.set_ccid(
38072 p_code_combination_id => l_ccid
38073 , p_value_type_code => l_adr_value_type_code
38074 , p_transaction_coa_id => l_adr_transaction_coa_id
38075 , p_accounting_coa_id => l_adr_accounting_coa_id
38076 , p_adr_code => 'CST_DEFAULT'
38077 , p_adr_type_code => 'S'
38078 , p_component_type => l_component_type
38079 , p_component_code => l_component_code
38080 , p_component_type_code => l_component_type_code
38081 , p_component_appl_id => l_component_appl_id
38082 , p_amb_context_code => l_amb_context_code
38083 , p_side => 'NA'
38084 );
38085
38086
38087 --
38088 --
38089 END IF;
38090
38091 --
38092 -- Update the line information that should be overwritten
38093 --
38094 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38095 p_header_num => 1);
38096 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38097
38098 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38099
38100 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38101 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38102 END IF;
38103
38104 --
38105 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38106 --
38107 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38108 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38109 ELSE
38110 ---------------------------------------------------------------------------------------------------
38111 -- 4262811a Switch Sign
38112 ---------------------------------------------------------------------------------------------------
38113 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38114 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38116 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38117 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38118 -- 5132302
38119 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38120 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38121
38122 END IF;
38123
38124 -- 4955764
38125 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38126 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38127
38128
38129 XLA_AE_LINES_PKG.ValidateCurrentLine;
38130 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38131
38132 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38133 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38134 ,p_balance_type_code => l_balance_type_code);
38135
38136 END IF;
38137
38138 -----------------------------------------------------------------------------------------
38139 -- 4262811 Multiperiod Accounting
38140 -----------------------------------------------------------------------------------------
38141 -- No MPA option is assigned.
38142
38143
38144 END IF;
38145 END IF;
38146 --
38147
38148 --
38149 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38150 trace
38151 (p_msg => 'END of AcctLineType_92'
38152 ,p_level => C_LEVEL_PROCEDURE
38153 ,p_module => l_log_module);
38154 END IF;
38155 --
38156 EXCEPTION
38157 WHEN xla_exceptions_pkg.application_exception THEN
38158 RAISE;
38159 WHEN OTHERS THEN
38160 xla_exceptions_pkg.raise_message
38161 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_92');
38162 END AcctLineType_92;
38163 --
38164
38165 ---------------------------------------
38166 --
38167 -- PRIVATE FUNCTION
38168 -- AcctLineType_93
38169 --
38170 ---------------------------------------
38171 PROCEDURE AcctLineType_93 (
38172 p_application_id IN NUMBER
38173 ,p_event_id IN NUMBER
38174 ,p_calculate_acctd_flag IN VARCHAR2
38175 ,p_calculate_g_l_flag IN VARCHAR2
38176 ,p_actual_flag IN OUT VARCHAR2
38177 ,p_balance_type_code OUT VARCHAR2
38178 ,p_gain_or_loss_ref OUT VARCHAR2
38179
38180 --Cost Management Default Account
38181 , p_source_11 IN NUMBER
38182 --DISTRIBUTION_IDENTIFIER
38183 , p_source_84 IN NUMBER
38184 --Distribution Type
38185 , p_source_85 IN VARCHAR2
38186 , p_source_85_meaning IN VARCHAR2
38187 --Entered Currency Code
38188 , p_source_88 IN VARCHAR2
38189 --Entered Amount
38190 , p_source_91 IN NUMBER
38191 --Currency Conversion Date
38192 , p_source_92 IN DATE
38193 --Currency Conversion Rate
38194 , p_source_93 IN NUMBER
38195 --Currency Conversion Type
38196 , p_source_94 IN VARCHAR2
38197 --Accounted Amount
38198 , p_source_95 IN NUMBER
38199 --Accounting Line Type
38200 , p_source_97 IN NUMBER
38201 )
38202 IS
38203
38204 l_component_type VARCHAR2(80);
38205 l_component_code VARCHAR2(30);
38206 l_component_type_code VARCHAR2(1);
38207 l_component_appl_id INTEGER;
38208 l_amb_context_code VARCHAR2(30);
38209 l_entity_code VARCHAR2(30);
38210 l_event_class_code VARCHAR2(30);
38211 l_ae_header_id NUMBER;
38212 l_event_type_code VARCHAR2(30);
38213 l_line_definition_code VARCHAR2(30);
38214 l_line_definition_owner_code VARCHAR2(1);
38215 --
38216 -- adr variables
38217 l_segment VARCHAR2(30);
38218 l_ccid NUMBER;
38219 l_adr_transaction_coa_id NUMBER;
38220 l_adr_accounting_coa_id NUMBER;
38221 l_adr_flexfield_segment_code VARCHAR2(30);
38222 l_adr_flex_value_set_id NUMBER;
38223 l_adr_value_type_code VARCHAR2(30);
38224 l_adr_value_combination_id NUMBER;
38225 l_adr_value_segment_code VARCHAR2(30);
38226
38227 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
38228 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
38229 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
38230 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
38231
38232 -- 4262811 Variables ------------------------------------------------------------------------------------------
38233 l_entered_amt_idx NUMBER;
38234 l_accted_amt_idx NUMBER;
38235 l_acc_rev_flag VARCHAR2(1);
38236 l_accrual_line_num NUMBER;
38237 l_tmp_amt NUMBER;
38238 l_acc_rev_natural_side_code VARCHAR2(1);
38239
38240 l_num_entries NUMBER;
38241 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
38242 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
38243 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
38244 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
38245 l_recog_line_1 NUMBER;
38246 l_recog_line_2 NUMBER;
38247
38248 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
38249 l_bflow_applied_to_amt NUMBER; -- 5132302
38250 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
38251
38252 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
38253
38254 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
38255 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
38256
38257 ---------------------------------------------------------------------------------------------------------------
38258
38259
38260 --
38261 -- bulk performance
38262 --
38263 l_balance_type_code VARCHAR2(1);
38264 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
38265 l_log_module VARCHAR2(240);
38266
38267 --
38268 -- Upgrade strategy
38269 --
38270 l_actual_upg_option VARCHAR2(1);
38271 l_enc_upg_option VARCHAR2(1);
38272
38273 --
38274 BEGIN
38275 --
38276 IF g_log_enabled THEN
38277 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_93';
38278 END IF;
38279 --
38280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38281
38282 trace
38283 (p_msg => 'BEGIN of AcctLineType_93'
38284 ,p_level => C_LEVEL_PROCEDURE
38285 ,p_module => l_log_module);
38286
38287 END IF;
38288 --
38289 l_component_type := 'AMB_JLT';
38290 l_component_code := 'COST_VARIANCE';
38291 l_component_type_code := 'S';
38292 l_component_appl_id := 707;
38293 l_amb_context_code := 'DEFAULT';
38294 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
38295 l_event_class_code := 'SALES_ORDER';
38296 l_event_type_code := 'COGS_RECOGNITION';
38297 l_line_definition_owner_code := 'S';
38298 l_line_definition_code := 'PI_COGS_RECOGNITION';
38299 --
38300 l_balance_type_code := 'A';
38301 l_segment := NULL;
38302 l_ccid := NULL;
38303 l_adr_transaction_coa_id := NULL;
38304 l_adr_accounting_coa_id := NULL;
38305 l_adr_flexfield_segment_code := NULL;
38306 l_adr_flex_value_set_id := NULL;
38307 l_adr_value_type_code := NULL;
38308 l_adr_value_combination_id := NULL;
38309 l_adr_value_segment_code := NULL;
38310
38311 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38312 l_bflow_class_code := ''; -- 4219869 Business Flow
38313 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38314 l_budgetary_control_flag := 'N';
38315
38316 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38317 l_bflow_applied_to_amt := NULL; -- 5132302
38318 l_entered_amt_idx := NULL; -- 4262811
38319 l_accted_amt_idx := NULL; -- 4262811
38320 l_acc_rev_flag := NULL; -- 4262811
38321 l_accrual_line_num := NULL; -- 4262811
38322 l_tmp_amt := NULL; -- 4262811
38323 --
38324
38325 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38326 l_balance_type_code <> 'B' THEN
38327 IF NVL(p_source_97,9E125) = 13
38328 THEN
38329
38330 --
38331 XLA_AE_LINES_PKG.SetNewLine;
38332
38333 p_balance_type_code := l_balance_type_code;
38334 -- set the flag so later we will know whether the gain loss line needs to be created
38335
38336 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38337 p_actual_flag :='A';
38338 END IF;
38339
38340 --
38341 -- bulk performance
38342 --
38343 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38344 p_header_num => 0); -- 4262811
38345 --
38346 -- set accounting line options
38347 --
38348 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38349 p_natural_side_code => 'D'
38350 , p_gain_or_loss_flag => 'N'
38351 , p_gl_transfer_mode_code => 'S'
38352 , p_acct_entry_type_code => 'A'
38353 , p_switch_side_flag => 'Y'
38354 , p_merge_duplicate_code => 'N'
38355 );
38356 --
38357 l_acc_rev_natural_side_code := 'C'; -- 4262811
38358 --
38359 --
38360 -- set accounting line type info
38361 --
38362 xla_ae_lines_pkg.SetAcctLineType
38363 (p_component_type => l_component_type
38364 ,p_event_type_code => l_event_type_code
38365 ,p_line_definition_owner_code => l_line_definition_owner_code
38366 ,p_line_definition_code => l_line_definition_code
38367 ,p_accounting_line_code => l_component_code
38368 ,p_accounting_line_type_code => l_component_type_code
38369 ,p_accounting_line_appl_id => l_component_appl_id
38370 ,p_amb_context_code => l_amb_context_code
38371 ,p_entity_code => l_entity_code
38372 ,p_event_class_code => l_event_class_code);
38373 --
38374 -- set accounting class
38375 --
38376 xla_ae_lines_pkg.SetAcctClass(
38377 p_accounting_class_code => 'COST_VARIANCE'
38378 , p_ae_header_id => l_ae_header_id
38379 );
38380
38381 --
38382 -- set rounding class
38383 --
38384 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38385 'COST_VARIANCE';
38386
38387 --
38388 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38389 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38390 --
38391 -- bulk performance
38392 --
38393 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38394
38395 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38396 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38397
38398 -- 4955764
38399 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38400 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38401
38402 -- 4458381 Public Sector Enh
38403
38404 --
38405 -- set accounting attributes for the line type
38406 --
38407 l_entered_amt_idx := 3;
38408 l_accted_amt_idx := 8;
38409 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38410 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
38411 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
38412 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
38413 l_rec_acct_attrs.array_char_value(2) := p_source_85;
38414 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
38415 l_rec_acct_attrs.array_num_value(3) := p_source_91;
38416 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
38417 l_rec_acct_attrs.array_char_value(4) := p_source_88;
38418 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
38419 l_rec_acct_attrs.array_date_value(5) := p_source_92;
38420 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
38421 l_rec_acct_attrs.array_num_value(6) := p_source_93;
38422 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
38423 l_rec_acct_attrs.array_char_value(7) := p_source_94;
38424 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
38425 l_rec_acct_attrs.array_num_value(8) := p_source_95;
38426
38427 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38428 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38429
38430 ---------------------------------------------------------------------------------------------------------------
38431 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38432 ---------------------------------------------------------------------------------------------------------------
38433 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38434
38435 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38436 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38437
38438 IF xla_accounting_cache_pkg.GetValueChar
38439 (p_source_code => 'LEDGER_CATEGORY_CODE'
38440 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38441 AND l_bflow_method_code = 'PRIOR_ENTRY'
38442 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38443 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38444 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38445 )
38446 THEN
38447 xla_ae_lines_pkg.BflowUpgEntry
38448 (p_business_method_code => l_bflow_method_code
38449 ,p_business_class_code => l_bflow_class_code
38450 ,p_balance_type => l_balance_type_code);
38451 ELSE
38452 NULL;
38453 -- No business flow processing for business flow method of NONE.
38454 END IF;
38455
38456 --
38457 -- call analytical criteria
38458 --
38459
38460 --
38461 -- call description
38462 --
38463 -- No description or it is inherited.
38464 --
38465 -- call ADRs
38466 -- Bug 4922099
38467 --
38468 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38469 (NVL(l_actual_upg_option, 'N') = 'O') OR
38470 (NVL(l_enc_upg_option, 'N') = 'O')
38471 )
38472 THEN
38473 NULL;
38474 --
38475 --
38476
38477 l_ccid := AcctDerRule_6(
38478 p_application_id => p_application_id
38479 , p_ae_header_id => l_ae_header_id
38480 , p_source_11 => p_source_11
38481 , x_transaction_coa_id => l_adr_transaction_coa_id
38482 , x_accounting_coa_id => l_adr_accounting_coa_id
38483 , x_value_type_code => l_adr_value_type_code
38484 , p_side => 'NA'
38485 );
38486
38487 xla_ae_lines_pkg.set_ccid(
38488 p_code_combination_id => l_ccid
38489 , p_value_type_code => l_adr_value_type_code
38490 , p_transaction_coa_id => l_adr_transaction_coa_id
38491 , p_accounting_coa_id => l_adr_accounting_coa_id
38492 , p_adr_code => 'CST_DEFAULT'
38493 , p_adr_type_code => 'S'
38494 , p_component_type => l_component_type
38495 , p_component_code => l_component_code
38496 , p_component_type_code => l_component_type_code
38497 , p_component_appl_id => l_component_appl_id
38498 , p_amb_context_code => l_amb_context_code
38499 , p_side => 'NA'
38500 );
38501
38502
38503 --
38504 --
38505 END IF;
38506 --
38507 -- Bug 4922099
38508 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38509 (NVL(l_enc_upg_option, 'N') = 'O')
38510 ) AND
38511 (l_bflow_method_code = 'PRIOR_ENTRY')
38512 )
38513 THEN
38514 IF
38515 --
38516 1 = 2
38517 --
38518 THEN
38519 xla_accounting_err_pkg.build_message
38520 (p_appli_s_name => 'XLA'
38521 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38522 ,p_token_1 => 'LINE_NUMBER'
38523 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38524 ,p_token_2 => 'LINE_TYPE_NAME'
38525 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38526 l_component_type
38527 ,l_component_code
38528 ,l_component_type_code
38529 ,l_component_appl_id
38530 ,l_amb_context_code
38531 ,l_entity_code
38532 ,l_event_class_code
38533 )
38534 ,p_token_3 => 'OWNER'
38535 ,p_value_3 => xla_lookups_pkg.get_meaning(
38536 p_lookup_type => 'XLA_OWNER_TYPE'
38537 ,p_lookup_code => l_component_type_code
38538 )
38539 ,p_token_4 => 'PRODUCT_NAME'
38540 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38541 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38542 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38543 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38544 ,p_ae_header_id => NULL
38545 );
38546
38547 IF (C_LEVEL_ERROR>= g_log_level) THEN
38548 trace
38549 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38550 ,p_level => C_LEVEL_ERROR
38551 ,p_module => l_log_module);
38552 END IF;
38553 END IF;
38554 END IF;
38555 --
38556 --
38557 ------------------------------------------------------------------------------------------------
38558 -- 4219869 Business Flow
38559 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38560 -- Prior Entry. Currently, the following code is always generated.
38561 ------------------------------------------------------------------------------------------------
38562 XLA_AE_LINES_PKG.ValidateCurrentLine;
38563
38564 ------------------------------------------------------------------------------------
38565 -- 4219869 Business Flow
38566 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38567 ------------------------------------------------------------------------------------
38568 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38569
38570 ----------------------------------------------------------------------------------
38571 -- 4219869 Business Flow
38572 -- Update journal entry status -- Need to generate this within IF <condition>
38573 ----------------------------------------------------------------------------------
38574 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38575 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38576 ,p_balance_type_code => l_balance_type_code
38577 );
38578
38579 -------------------------------------------------------------------------------------------
38580 -- 4262811 - Generate the Accrual Reversal lines
38581 -------------------------------------------------------------------------------------------
38582 BEGIN
38583 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38584 (g_array_event(p_event_id).array_value_num('header_index'));
38585 IF l_acc_rev_flag IS NULL THEN
38586 l_acc_rev_flag := 'N';
38587 END IF;
38588 EXCEPTION
38589 WHEN OTHERS THEN
38590 l_acc_rev_flag := 'N';
38591 END;
38592 --
38593 IF (l_acc_rev_flag = 'Y') THEN
38594
38595 -- 4645092 ------------------------------------------------------------------------------
38596 -- To allow MPA report to determine if it should generate report process
38597 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38598 ------------------------------------------------------------------------------------------
38599
38600 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38601 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38602 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38603 -- call ADRs
38604 -- Bug 4922099
38605 --
38606 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38607 (NVL(l_actual_upg_option, 'N') = 'O') OR
38608 (NVL(l_enc_upg_option, 'N') = 'O')
38609 )
38610 THEN
38611 NULL;
38612 --
38613 --
38614
38615 l_ccid := AcctDerRule_6(
38616 p_application_id => p_application_id
38617 , p_ae_header_id => l_ae_header_id
38618 , p_source_11 => p_source_11
38619 , x_transaction_coa_id => l_adr_transaction_coa_id
38620 , x_accounting_coa_id => l_adr_accounting_coa_id
38621 , x_value_type_code => l_adr_value_type_code
38622 , p_side => 'NA'
38623 );
38624
38625 xla_ae_lines_pkg.set_ccid(
38626 p_code_combination_id => l_ccid
38627 , p_value_type_code => l_adr_value_type_code
38628 , p_transaction_coa_id => l_adr_transaction_coa_id
38629 , p_accounting_coa_id => l_adr_accounting_coa_id
38630 , p_adr_code => 'CST_DEFAULT'
38631 , p_adr_type_code => 'S'
38632 , p_component_type => l_component_type
38633 , p_component_code => l_component_code
38634 , p_component_type_code => l_component_type_code
38635 , p_component_appl_id => l_component_appl_id
38636 , p_amb_context_code => l_amb_context_code
38637 , p_side => 'NA'
38638 );
38639
38640
38641 --
38642 --
38643 END IF;
38644
38645 --
38646 -- Update the line information that should be overwritten
38647 --
38648 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38649 p_header_num => 1);
38650 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38651
38652 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38653
38654 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38655 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38656 END IF;
38657
38658 --
38659 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38660 --
38661 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38662 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38663 ELSE
38664 ---------------------------------------------------------------------------------------------------
38665 -- 4262811a Switch Sign
38666 ---------------------------------------------------------------------------------------------------
38667 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38668 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38669 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38670 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38671 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38672 -- 5132302
38673 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38674 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38675
38676 END IF;
38677
38678 -- 4955764
38679 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38680 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38681
38682
38683 XLA_AE_LINES_PKG.ValidateCurrentLine;
38684 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38685
38686 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38687 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38688 ,p_balance_type_code => l_balance_type_code);
38689
38690 END IF;
38691
38692 -----------------------------------------------------------------------------------------
38693 -- 4262811 Multiperiod Accounting
38694 -----------------------------------------------------------------------------------------
38695 -- No MPA option is assigned.
38696
38697
38698 END IF;
38699 END IF;
38700 --
38701
38702 --
38703 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38704 trace
38705 (p_msg => 'END of AcctLineType_93'
38706 ,p_level => C_LEVEL_PROCEDURE
38707 ,p_module => l_log_module);
38708 END IF;
38709 --
38710 EXCEPTION
38711 WHEN xla_exceptions_pkg.application_exception THEN
38712 RAISE;
38713 WHEN OTHERS THEN
38714 xla_exceptions_pkg.raise_message
38715 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_93');
38716 END AcctLineType_93;
38717 --
38718
38719 ---------------------------------------
38720 --
38721 -- PRIVATE FUNCTION
38722 -- AcctLineType_94
38723 --
38724 ---------------------------------------
38725 PROCEDURE AcctLineType_94 (
38726 p_application_id IN NUMBER
38727 ,p_event_id IN NUMBER
38728 ,p_calculate_acctd_flag IN VARCHAR2
38729 ,p_calculate_g_l_flag IN VARCHAR2
38730 ,p_actual_flag IN OUT VARCHAR2
38731 ,p_balance_type_code OUT VARCHAR2
38732 ,p_gain_or_loss_ref OUT VARCHAR2
38733
38734 --TRANSACTION_ID
38735 , p_source_1 IN NUMBER
38736 --Item Concatenated Segments
38737 , p_source_2 IN VARCHAR2
38738 --Transaction Quantity
38739 , p_source_3 IN NUMBER
38740 --Transaction Unit of Measure Code
38741 , p_source_4 IN VARCHAR2
38742 --Inventory Transaction Type Description
38743 , p_source_5 IN VARCHAR2
38744 --Cost Management Default Account
38745 , p_source_11 IN NUMBER
38746 --DISTRIBUTION_IDENTIFIER
38747 , p_source_84 IN NUMBER
38748 --Distribution Type
38749 , p_source_85 IN VARCHAR2
38750 , p_source_85_meaning IN VARCHAR2
38751 --Entered Currency Code
38752 , p_source_88 IN VARCHAR2
38753 --Entered Amount
38754 , p_source_91 IN NUMBER
38755 --Currency Conversion Date
38756 , p_source_92 IN DATE
38757 --Currency Conversion Rate
38758 , p_source_93 IN NUMBER
38759 --Currency Conversion Type
38760 , p_source_94 IN VARCHAR2
38761 --Accounted Amount
38762 , p_source_95 IN NUMBER
38763 --Accounting Line Type
38764 , p_source_97 IN NUMBER
38765 )
38766 IS
38767
38768 l_component_type VARCHAR2(80);
38769 l_component_code VARCHAR2(30);
38770 l_component_type_code VARCHAR2(1);
38771 l_component_appl_id INTEGER;
38772 l_amb_context_code VARCHAR2(30);
38773 l_entity_code VARCHAR2(30);
38774 l_event_class_code VARCHAR2(30);
38775 l_ae_header_id NUMBER;
38776 l_event_type_code VARCHAR2(30);
38777 l_line_definition_code VARCHAR2(30);
38778 l_line_definition_owner_code VARCHAR2(1);
38779 --
38780 -- adr variables
38781 l_segment VARCHAR2(30);
38782 l_ccid NUMBER;
38783 l_adr_transaction_coa_id NUMBER;
38784 l_adr_accounting_coa_id NUMBER;
38785 l_adr_flexfield_segment_code VARCHAR2(30);
38786 l_adr_flex_value_set_id NUMBER;
38787 l_adr_value_type_code VARCHAR2(30);
38788 l_adr_value_combination_id NUMBER;
38789 l_adr_value_segment_code VARCHAR2(30);
38790
38791 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
38792 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
38793 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
38794 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
38795
38796 -- 4262811 Variables ------------------------------------------------------------------------------------------
38797 l_entered_amt_idx NUMBER;
38798 l_accted_amt_idx NUMBER;
38799 l_acc_rev_flag VARCHAR2(1);
38800 l_accrual_line_num NUMBER;
38801 l_tmp_amt NUMBER;
38802 l_acc_rev_natural_side_code VARCHAR2(1);
38803
38804 l_num_entries NUMBER;
38805 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
38806 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
38807 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
38808 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
38809 l_recog_line_1 NUMBER;
38810 l_recog_line_2 NUMBER;
38811
38812 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
38813 l_bflow_applied_to_amt NUMBER; -- 5132302
38814 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
38815
38816 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
38817
38818 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
38819 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
38820
38821 ---------------------------------------------------------------------------------------------------------------
38822
38823
38824 --
38825 -- bulk performance
38826 --
38827 l_balance_type_code VARCHAR2(1);
38828 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
38829 l_log_module VARCHAR2(240);
38830
38831 --
38832 -- Upgrade strategy
38833 --
38834 l_actual_upg_option VARCHAR2(1);
38835 l_enc_upg_option VARCHAR2(1);
38836
38837 --
38838 BEGIN
38839 --
38840 IF g_log_enabled THEN
38841 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_94';
38842 END IF;
38843 --
38844 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38845
38846 trace
38847 (p_msg => 'BEGIN of AcctLineType_94'
38848 ,p_level => C_LEVEL_PROCEDURE
38849 ,p_module => l_log_module);
38850
38851 END IF;
38852 --
38853 l_component_type := 'AMB_JLT';
38854 l_component_code := 'COST_VARIANCE';
38855 l_component_type_code := 'S';
38856 l_component_appl_id := 707;
38857 l_amb_context_code := 'DEFAULT';
38858 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
38859 l_event_class_code := 'WIP_MTL';
38860 l_event_type_code := 'WIP_COMP_RETURN';
38861 l_line_definition_owner_code := 'S';
38862 l_line_definition_code := 'PI_WIP_COMP_RETURN';
38863 --
38864 l_balance_type_code := 'A';
38865 l_segment := NULL;
38866 l_ccid := NULL;
38867 l_adr_transaction_coa_id := NULL;
38868 l_adr_accounting_coa_id := NULL;
38869 l_adr_flexfield_segment_code := NULL;
38870 l_adr_flex_value_set_id := NULL;
38871 l_adr_value_type_code := NULL;
38872 l_adr_value_combination_id := NULL;
38873 l_adr_value_segment_code := NULL;
38874
38875 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38876 l_bflow_class_code := ''; -- 4219869 Business Flow
38877 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38878 l_budgetary_control_flag := 'N';
38879
38880 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38881 l_bflow_applied_to_amt := NULL; -- 5132302
38882 l_entered_amt_idx := NULL; -- 4262811
38883 l_accted_amt_idx := NULL; -- 4262811
38884 l_acc_rev_flag := NULL; -- 4262811
38885 l_accrual_line_num := NULL; -- 4262811
38886 l_tmp_amt := NULL; -- 4262811
38887 --
38888
38889 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38890 l_balance_type_code <> 'B' THEN
38891 IF NVL(p_source_97,9E125) = 13
38892 THEN
38893
38894 --
38895 XLA_AE_LINES_PKG.SetNewLine;
38896
38897 p_balance_type_code := l_balance_type_code;
38898 -- set the flag so later we will know whether the gain loss line needs to be created
38899
38900 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38901 p_actual_flag :='A';
38902 END IF;
38903
38904 --
38905 -- bulk performance
38906 --
38907 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38908 p_header_num => 0); -- 4262811
38909 --
38910 -- set accounting line options
38911 --
38912 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38913 p_natural_side_code => 'D'
38914 , p_gain_or_loss_flag => 'N'
38915 , p_gl_transfer_mode_code => 'S'
38916 , p_acct_entry_type_code => 'A'
38917 , p_switch_side_flag => 'Y'
38918 , p_merge_duplicate_code => 'N'
38919 );
38920 --
38921 l_acc_rev_natural_side_code := 'C'; -- 4262811
38922 --
38923 --
38924 -- set accounting line type info
38925 --
38926 xla_ae_lines_pkg.SetAcctLineType
38927 (p_component_type => l_component_type
38928 ,p_event_type_code => l_event_type_code
38929 ,p_line_definition_owner_code => l_line_definition_owner_code
38930 ,p_line_definition_code => l_line_definition_code
38931 ,p_accounting_line_code => l_component_code
38932 ,p_accounting_line_type_code => l_component_type_code
38933 ,p_accounting_line_appl_id => l_component_appl_id
38934 ,p_amb_context_code => l_amb_context_code
38935 ,p_entity_code => l_entity_code
38936 ,p_event_class_code => l_event_class_code);
38937 --
38938 -- set accounting class
38939 --
38940 xla_ae_lines_pkg.SetAcctClass(
38941 p_accounting_class_code => 'COST_VARIANCE'
38942 , p_ae_header_id => l_ae_header_id
38943 );
38944
38945 --
38946 -- set rounding class
38947 --
38948 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38949 'COST_VARIANCE';
38950
38951 --
38952 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38953 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38954 --
38955 -- bulk performance
38956 --
38957 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38958
38959 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38960 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38961
38962 -- 4955764
38963 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38964 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38965
38966 -- 4458381 Public Sector Enh
38967
38968 --
38969 -- set accounting attributes for the line type
38970 --
38971 l_entered_amt_idx := 3;
38972 l_accted_amt_idx := 8;
38973 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38974 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
38975 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
38976 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
38977 l_rec_acct_attrs.array_char_value(2) := p_source_85;
38978 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
38979 l_rec_acct_attrs.array_num_value(3) := p_source_91;
38980 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
38981 l_rec_acct_attrs.array_char_value(4) := p_source_88;
38982 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
38983 l_rec_acct_attrs.array_date_value(5) := p_source_92;
38984 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
38985 l_rec_acct_attrs.array_num_value(6) := p_source_93;
38986 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
38987 l_rec_acct_attrs.array_char_value(7) := p_source_94;
38988 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
38989 l_rec_acct_attrs.array_num_value(8) := p_source_95;
38990
38991 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38992 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38993
38994 ---------------------------------------------------------------------------------------------------------------
38995 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38996 ---------------------------------------------------------------------------------------------------------------
38997 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38998
38999 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39000 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39001
39002 IF xla_accounting_cache_pkg.GetValueChar
39003 (p_source_code => 'LEDGER_CATEGORY_CODE'
39004 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39005 AND l_bflow_method_code = 'PRIOR_ENTRY'
39006 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39007 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39008 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39009 )
39010 THEN
39011 xla_ae_lines_pkg.BflowUpgEntry
39012 (p_business_method_code => l_bflow_method_code
39013 ,p_business_class_code => l_bflow_class_code
39014 ,p_balance_type => l_balance_type_code);
39015 ELSE
39016 NULL;
39017 -- No business flow processing for business flow method of NONE.
39018 END IF;
39019
39020 --
39021 -- call analytical criteria
39022 --
39023
39024 --
39025 -- call description
39026 --
39027
39028 xla_ae_lines_pkg.SetLineDescription(
39029 p_ae_header_id => l_ae_header_id
39030 ,p_description => Description_1 (
39031 p_application_id => p_application_id
39032 , p_ae_header_id => l_ae_header_id
39033 , p_source_1 => p_source_1
39034 , p_source_2 => p_source_2
39035 , p_source_3 => p_source_3
39036 , p_source_4 => p_source_4
39037 , p_source_5 => p_source_5
39038 )
39039 );
39040
39041
39042 --
39043 -- call ADRs
39044 -- Bug 4922099
39045 --
39046 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39047 (NVL(l_actual_upg_option, 'N') = 'O') OR
39048 (NVL(l_enc_upg_option, 'N') = 'O')
39049 )
39050 THEN
39051 NULL;
39052 --
39053 --
39054
39055 l_ccid := AcctDerRule_6(
39056 p_application_id => p_application_id
39057 , p_ae_header_id => l_ae_header_id
39058 , p_source_11 => p_source_11
39059 , x_transaction_coa_id => l_adr_transaction_coa_id
39060 , x_accounting_coa_id => l_adr_accounting_coa_id
39061 , x_value_type_code => l_adr_value_type_code
39062 , p_side => 'NA'
39063 );
39064
39065 xla_ae_lines_pkg.set_ccid(
39066 p_code_combination_id => l_ccid
39067 , p_value_type_code => l_adr_value_type_code
39068 , p_transaction_coa_id => l_adr_transaction_coa_id
39069 , p_accounting_coa_id => l_adr_accounting_coa_id
39070 , p_adr_code => 'CST_DEFAULT'
39071 , p_adr_type_code => 'S'
39072 , p_component_type => l_component_type
39073 , p_component_code => l_component_code
39074 , p_component_type_code => l_component_type_code
39075 , p_component_appl_id => l_component_appl_id
39076 , p_amb_context_code => l_amb_context_code
39077 , p_side => 'NA'
39078 );
39079
39080
39081 --
39082 --
39083 END IF;
39084 --
39085 -- Bug 4922099
39086 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39087 (NVL(l_enc_upg_option, 'N') = 'O')
39088 ) AND
39089 (l_bflow_method_code = 'PRIOR_ENTRY')
39090 )
39091 THEN
39092 IF
39093 --
39094 1 = 2
39095 --
39096 THEN
39097 xla_accounting_err_pkg.build_message
39098 (p_appli_s_name => 'XLA'
39099 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39100 ,p_token_1 => 'LINE_NUMBER'
39101 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39102 ,p_token_2 => 'LINE_TYPE_NAME'
39103 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39104 l_component_type
39105 ,l_component_code
39106 ,l_component_type_code
39107 ,l_component_appl_id
39108 ,l_amb_context_code
39109 ,l_entity_code
39110 ,l_event_class_code
39111 )
39112 ,p_token_3 => 'OWNER'
39113 ,p_value_3 => xla_lookups_pkg.get_meaning(
39114 p_lookup_type => 'XLA_OWNER_TYPE'
39115 ,p_lookup_code => l_component_type_code
39116 )
39117 ,p_token_4 => 'PRODUCT_NAME'
39118 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
39119 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
39120 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
39121 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
39122 ,p_ae_header_id => NULL
39123 );
39124
39125 IF (C_LEVEL_ERROR>= g_log_level) THEN
39126 trace
39127 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39128 ,p_level => C_LEVEL_ERROR
39129 ,p_module => l_log_module);
39130 END IF;
39131 END IF;
39132 END IF;
39133 --
39134 --
39135 ------------------------------------------------------------------------------------------------
39136 -- 4219869 Business Flow
39137 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
39138 -- Prior Entry. Currently, the following code is always generated.
39139 ------------------------------------------------------------------------------------------------
39140 XLA_AE_LINES_PKG.ValidateCurrentLine;
39141
39142 ------------------------------------------------------------------------------------
39143 -- 4219869 Business Flow
39144 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
39145 ------------------------------------------------------------------------------------
39146 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39147
39148 ----------------------------------------------------------------------------------
39149 -- 4219869 Business Flow
39150 -- Update journal entry status -- Need to generate this within IF <condition>
39151 ----------------------------------------------------------------------------------
39152 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39153 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
39154 ,p_balance_type_code => l_balance_type_code
39155 );
39156
39157 -------------------------------------------------------------------------------------------
39158 -- 4262811 - Generate the Accrual Reversal lines
39159 -------------------------------------------------------------------------------------------
39160 BEGIN
39161 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
39162 (g_array_event(p_event_id).array_value_num('header_index'));
39163 IF l_acc_rev_flag IS NULL THEN
39164 l_acc_rev_flag := 'N';
39165 END IF;
39166 EXCEPTION
39167 WHEN OTHERS THEN
39168 l_acc_rev_flag := 'N';
39169 END;
39170 --
39171 IF (l_acc_rev_flag = 'Y') THEN
39172
39173 -- 4645092 ------------------------------------------------------------------------------
39174 -- To allow MPA report to determine if it should generate report process
39175 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
39176 ------------------------------------------------------------------------------------------
39177
39178 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
39179 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
39180 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
39181 -- call ADRs
39182 -- Bug 4922099
39183 --
39184 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39185 (NVL(l_actual_upg_option, 'N') = 'O') OR
39186 (NVL(l_enc_upg_option, 'N') = 'O')
39187 )
39188 THEN
39189 NULL;
39190 --
39191 --
39192
39193 l_ccid := AcctDerRule_6(
39194 p_application_id => p_application_id
39195 , p_ae_header_id => l_ae_header_id
39196 , p_source_11 => p_source_11
39197 , x_transaction_coa_id => l_adr_transaction_coa_id
39198 , x_accounting_coa_id => l_adr_accounting_coa_id
39199 , x_value_type_code => l_adr_value_type_code
39200 , p_side => 'NA'
39201 );
39202
39203 xla_ae_lines_pkg.set_ccid(
39204 p_code_combination_id => l_ccid
39205 , p_value_type_code => l_adr_value_type_code
39206 , p_transaction_coa_id => l_adr_transaction_coa_id
39207 , p_accounting_coa_id => l_adr_accounting_coa_id
39208 , p_adr_code => 'CST_DEFAULT'
39209 , p_adr_type_code => 'S'
39210 , p_component_type => l_component_type
39211 , p_component_code => l_component_code
39212 , p_component_type_code => l_component_type_code
39213 , p_component_appl_id => l_component_appl_id
39214 , p_amb_context_code => l_amb_context_code
39215 , p_side => 'NA'
39216 );
39217
39218
39219 --
39220 --
39221 END IF;
39222
39223 --
39224 -- Update the line information that should be overwritten
39225 --
39226 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
39227 p_header_num => 1);
39228 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
39229
39230 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
39231
39232 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
39233 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
39234 END IF;
39235
39236 --
39237 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
39238 --
39239 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
39240 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
39241 ELSE
39242 ---------------------------------------------------------------------------------------------------
39243 -- 4262811a Switch Sign
39244 ---------------------------------------------------------------------------------------------------
39245 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39246 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39247 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39248 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39249 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39250 -- 5132302
39251 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39252 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39253
39254 END IF;
39255
39256 -- 4955764
39257 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39258 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39259
39260
39261 XLA_AE_LINES_PKG.ValidateCurrentLine;
39262 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39263
39264 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39265 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39266 ,p_balance_type_code => l_balance_type_code);
39267
39268 END IF;
39269
39270 -----------------------------------------------------------------------------------------
39271 -- 4262811 Multiperiod Accounting
39272 -----------------------------------------------------------------------------------------
39273 -- No MPA option is assigned.
39274
39275
39276 END IF;
39277 END IF;
39278 --
39279
39280 --
39281 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39282 trace
39283 (p_msg => 'END of AcctLineType_94'
39284 ,p_level => C_LEVEL_PROCEDURE
39285 ,p_module => l_log_module);
39286 END IF;
39287 --
39288 EXCEPTION
39289 WHEN xla_exceptions_pkg.application_exception THEN
39290 RAISE;
39291 WHEN OTHERS THEN
39292 xla_exceptions_pkg.raise_message
39293 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_94');
39294 END AcctLineType_94;
39295 --
39296
39297 ---------------------------------------
39298 --
39299 -- PRIVATE FUNCTION
39300 -- AcctLineType_95
39301 --
39302 ---------------------------------------
39303 PROCEDURE AcctLineType_95 (
39304 p_application_id IN NUMBER
39305 ,p_event_id IN NUMBER
39306 ,p_calculate_acctd_flag IN VARCHAR2
39307 ,p_calculate_g_l_flag IN VARCHAR2
39308 ,p_actual_flag IN OUT VARCHAR2
39309 ,p_balance_type_code OUT VARCHAR2
39310 ,p_gain_or_loss_ref OUT VARCHAR2
39311
39312 --TRANSACTION_ID
39313 , p_source_1 IN NUMBER
39314 --Item Concatenated Segments
39315 , p_source_2 IN VARCHAR2
39316 --Transaction Quantity
39317 , p_source_3 IN NUMBER
39318 --Transaction Unit of Measure Code
39319 , p_source_4 IN VARCHAR2
39320 --Inventory Transaction Type Description
39321 , p_source_5 IN VARCHAR2
39322 --Cost Management Default Account
39323 , p_source_11 IN NUMBER
39324 --DISTRIBUTION_IDENTIFIER
39325 , p_source_84 IN NUMBER
39326 --Distribution Type
39327 , p_source_85 IN VARCHAR2
39328 , p_source_85_meaning IN VARCHAR2
39329 --Entered Currency Code
39330 , p_source_88 IN VARCHAR2
39331 --Entered Amount
39332 , p_source_91 IN NUMBER
39333 --Currency Conversion Date
39334 , p_source_92 IN DATE
39335 --Currency Conversion Rate
39336 , p_source_93 IN NUMBER
39337 --Currency Conversion Type
39338 , p_source_94 IN VARCHAR2
39339 --Accounted Amount
39340 , p_source_95 IN NUMBER
39341 --Accounting Line Type
39342 , p_source_97 IN NUMBER
39343 )
39344 IS
39345
39346 l_component_type VARCHAR2(80);
39347 l_component_code VARCHAR2(30);
39348 l_component_type_code VARCHAR2(1);
39349 l_component_appl_id INTEGER;
39350 l_amb_context_code VARCHAR2(30);
39351 l_entity_code VARCHAR2(30);
39352 l_event_class_code VARCHAR2(30);
39353 l_ae_header_id NUMBER;
39354 l_event_type_code VARCHAR2(30);
39355 l_line_definition_code VARCHAR2(30);
39356 l_line_definition_owner_code VARCHAR2(1);
39357 --
39358 -- adr variables
39359 l_segment VARCHAR2(30);
39360 l_ccid NUMBER;
39361 l_adr_transaction_coa_id NUMBER;
39362 l_adr_accounting_coa_id NUMBER;
39363 l_adr_flexfield_segment_code VARCHAR2(30);
39364 l_adr_flex_value_set_id NUMBER;
39365 l_adr_value_type_code VARCHAR2(30);
39366 l_adr_value_combination_id NUMBER;
39367 l_adr_value_segment_code VARCHAR2(30);
39368
39369 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39370 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39371 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39372 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39373
39374 -- 4262811 Variables ------------------------------------------------------------------------------------------
39375 l_entered_amt_idx NUMBER;
39376 l_accted_amt_idx NUMBER;
39377 l_acc_rev_flag VARCHAR2(1);
39378 l_accrual_line_num NUMBER;
39379 l_tmp_amt NUMBER;
39380 l_acc_rev_natural_side_code VARCHAR2(1);
39381
39382 l_num_entries NUMBER;
39383 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39384 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39385 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39386 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39387 l_recog_line_1 NUMBER;
39388 l_recog_line_2 NUMBER;
39389
39390 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39391 l_bflow_applied_to_amt NUMBER; -- 5132302
39392 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39393
39394 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39395
39396 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39397 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39398
39399 ---------------------------------------------------------------------------------------------------------------
39400
39401
39402 --
39403 -- bulk performance
39404 --
39405 l_balance_type_code VARCHAR2(1);
39406 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39407 l_log_module VARCHAR2(240);
39408
39409 --
39410 -- Upgrade strategy
39411 --
39412 l_actual_upg_option VARCHAR2(1);
39413 l_enc_upg_option VARCHAR2(1);
39414
39415 --
39416 BEGIN
39417 --
39418 IF g_log_enabled THEN
39419 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_95';
39420 END IF;
39421 --
39422 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39423
39424 trace
39425 (p_msg => 'BEGIN of AcctLineType_95'
39426 ,p_level => C_LEVEL_PROCEDURE
39427 ,p_module => l_log_module);
39428
39429 END IF;
39430 --
39431 l_component_type := 'AMB_JLT';
39432 l_component_code := 'COST_VARIANCE';
39433 l_component_type_code := 'S';
39434 l_component_appl_id := 707;
39435 l_amb_context_code := 'DEFAULT';
39436 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
39437 l_event_class_code := 'MTL_COST_UPD';
39438 l_event_type_code := 'LAYER_COST_UPD';
39439 l_line_definition_owner_code := 'S';
39440 l_line_definition_code := 'PI_LAYER_COST_UPDATE';
39441 --
39442 l_balance_type_code := 'A';
39443 l_segment := NULL;
39444 l_ccid := NULL;
39445 l_adr_transaction_coa_id := NULL;
39446 l_adr_accounting_coa_id := NULL;
39447 l_adr_flexfield_segment_code := NULL;
39448 l_adr_flex_value_set_id := NULL;
39449 l_adr_value_type_code := NULL;
39450 l_adr_value_combination_id := NULL;
39451 l_adr_value_segment_code := NULL;
39452
39453 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39454 l_bflow_class_code := ''; -- 4219869 Business Flow
39455 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39456 l_budgetary_control_flag := 'N';
39457
39458 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39459 l_bflow_applied_to_amt := NULL; -- 5132302
39460 l_entered_amt_idx := NULL; -- 4262811
39461 l_accted_amt_idx := NULL; -- 4262811
39462 l_acc_rev_flag := NULL; -- 4262811
39463 l_accrual_line_num := NULL; -- 4262811
39464 l_tmp_amt := NULL; -- 4262811
39465 --
39466
39467 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39468 l_balance_type_code <> 'B' THEN
39469 IF NVL(p_source_97,9E125) = 13
39470 THEN
39471
39472 --
39473 XLA_AE_LINES_PKG.SetNewLine;
39474
39475 p_balance_type_code := l_balance_type_code;
39476 -- set the flag so later we will know whether the gain loss line needs to be created
39477
39478 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39479 p_actual_flag :='A';
39480 END IF;
39481
39482 --
39483 -- bulk performance
39484 --
39485 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39486 p_header_num => 0); -- 4262811
39487 --
39488 -- set accounting line options
39489 --
39490 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39491 p_natural_side_code => 'D'
39492 , p_gain_or_loss_flag => 'N'
39493 , p_gl_transfer_mode_code => 'S'
39494 , p_acct_entry_type_code => 'A'
39495 , p_switch_side_flag => 'Y'
39496 , p_merge_duplicate_code => 'N'
39497 );
39498 --
39499 l_acc_rev_natural_side_code := 'C'; -- 4262811
39500 --
39501 --
39502 -- set accounting line type info
39503 --
39504 xla_ae_lines_pkg.SetAcctLineType
39505 (p_component_type => l_component_type
39506 ,p_event_type_code => l_event_type_code
39507 ,p_line_definition_owner_code => l_line_definition_owner_code
39508 ,p_line_definition_code => l_line_definition_code
39509 ,p_accounting_line_code => l_component_code
39510 ,p_accounting_line_type_code => l_component_type_code
39511 ,p_accounting_line_appl_id => l_component_appl_id
39512 ,p_amb_context_code => l_amb_context_code
39513 ,p_entity_code => l_entity_code
39514 ,p_event_class_code => l_event_class_code);
39515 --
39516 -- set accounting class
39517 --
39518 xla_ae_lines_pkg.SetAcctClass(
39519 p_accounting_class_code => 'COST_VARIANCE'
39520 , p_ae_header_id => l_ae_header_id
39521 );
39522
39523 --
39524 -- set rounding class
39525 --
39526 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39527 'COST_VARIANCE';
39528
39529 --
39530 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39531 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39532 --
39533 -- bulk performance
39534 --
39535 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39536
39537 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39538 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39539
39540 -- 4955764
39541 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39542 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39543
39544 -- 4458381 Public Sector Enh
39545
39546 --
39547 -- set accounting attributes for the line type
39548 --
39549 l_entered_amt_idx := 3;
39550 l_accted_amt_idx := 8;
39551 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39552 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
39553 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
39554 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
39555 l_rec_acct_attrs.array_char_value(2) := p_source_85;
39556 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
39557 l_rec_acct_attrs.array_num_value(3) := p_source_91;
39558 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
39559 l_rec_acct_attrs.array_char_value(4) := p_source_88;
39560 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
39561 l_rec_acct_attrs.array_date_value(5) := p_source_92;
39562 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
39563 l_rec_acct_attrs.array_num_value(6) := p_source_93;
39564 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
39565 l_rec_acct_attrs.array_char_value(7) := p_source_94;
39566 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
39567 l_rec_acct_attrs.array_num_value(8) := p_source_95;
39568
39569 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39570 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39571
39572 ---------------------------------------------------------------------------------------------------------------
39573 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39574 ---------------------------------------------------------------------------------------------------------------
39575 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39576
39577 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39578 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39579
39580 IF xla_accounting_cache_pkg.GetValueChar
39581 (p_source_code => 'LEDGER_CATEGORY_CODE'
39582 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39583 AND l_bflow_method_code = 'PRIOR_ENTRY'
39584 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39585 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39586 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39587 )
39588 THEN
39589 xla_ae_lines_pkg.BflowUpgEntry
39590 (p_business_method_code => l_bflow_method_code
39591 ,p_business_class_code => l_bflow_class_code
39592 ,p_balance_type => l_balance_type_code);
39593 ELSE
39594 NULL;
39595 -- No business flow processing for business flow method of NONE.
39596 END IF;
39597
39598 --
39599 -- call analytical criteria
39600 --
39601
39602 --
39603 -- call description
39604 --
39605
39606 xla_ae_lines_pkg.SetLineDescription(
39607 p_ae_header_id => l_ae_header_id
39608 ,p_description => Description_1 (
39609 p_application_id => p_application_id
39610 , p_ae_header_id => l_ae_header_id
39611 , p_source_1 => p_source_1
39612 , p_source_2 => p_source_2
39613 , p_source_3 => p_source_3
39614 , p_source_4 => p_source_4
39615 , p_source_5 => p_source_5
39616 )
39617 );
39618
39619
39620 --
39621 -- call ADRs
39622 -- Bug 4922099
39623 --
39624 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39625 (NVL(l_actual_upg_option, 'N') = 'O') OR
39626 (NVL(l_enc_upg_option, 'N') = 'O')
39627 )
39628 THEN
39629 NULL;
39630 --
39631 --
39632
39633 l_ccid := AcctDerRule_6(
39634 p_application_id => p_application_id
39635 , p_ae_header_id => l_ae_header_id
39636 , p_source_11 => p_source_11
39637 , x_transaction_coa_id => l_adr_transaction_coa_id
39638 , x_accounting_coa_id => l_adr_accounting_coa_id
39639 , x_value_type_code => l_adr_value_type_code
39640 , p_side => 'NA'
39641 );
39642
39643 xla_ae_lines_pkg.set_ccid(
39644 p_code_combination_id => l_ccid
39645 , p_value_type_code => l_adr_value_type_code
39646 , p_transaction_coa_id => l_adr_transaction_coa_id
39647 , p_accounting_coa_id => l_adr_accounting_coa_id
39648 , p_adr_code => 'CST_DEFAULT'
39649 , p_adr_type_code => 'S'
39650 , p_component_type => l_component_type
39651 , p_component_code => l_component_code
39652 , p_component_type_code => l_component_type_code
39653 , p_component_appl_id => l_component_appl_id
39654 , p_amb_context_code => l_amb_context_code
39655 , p_side => 'NA'
39656 );
39657
39658
39659 --
39660 --
39661 END IF;
39662 --
39663 -- Bug 4922099
39664 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39665 (NVL(l_enc_upg_option, 'N') = 'O')
39666 ) AND
39667 (l_bflow_method_code = 'PRIOR_ENTRY')
39668 )
39669 THEN
39670 IF
39671 --
39672 1 = 2
39673 --
39674 THEN
39675 xla_accounting_err_pkg.build_message
39676 (p_appli_s_name => 'XLA'
39677 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39678 ,p_token_1 => 'LINE_NUMBER'
39679 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39680 ,p_token_2 => 'LINE_TYPE_NAME'
39681 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39682 l_component_type
39683 ,l_component_code
39684 ,l_component_type_code
39685 ,l_component_appl_id
39686 ,l_amb_context_code
39687 ,l_entity_code
39688 ,l_event_class_code
39689 )
39690 ,p_token_3 => 'OWNER'
39691 ,p_value_3 => xla_lookups_pkg.get_meaning(
39692 p_lookup_type => 'XLA_OWNER_TYPE'
39693 ,p_lookup_code => l_component_type_code
39694 )
39695 ,p_token_4 => 'PRODUCT_NAME'
39696 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
39697 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
39698 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
39699 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
39700 ,p_ae_header_id => NULL
39701 );
39702
39703 IF (C_LEVEL_ERROR>= g_log_level) THEN
39704 trace
39705 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39706 ,p_level => C_LEVEL_ERROR
39707 ,p_module => l_log_module);
39708 END IF;
39709 END IF;
39710 END IF;
39711 --
39712 --
39713 ------------------------------------------------------------------------------------------------
39714 -- 4219869 Business Flow
39715 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
39716 -- Prior Entry. Currently, the following code is always generated.
39717 ------------------------------------------------------------------------------------------------
39718 XLA_AE_LINES_PKG.ValidateCurrentLine;
39719
39720 ------------------------------------------------------------------------------------
39721 -- 4219869 Business Flow
39722 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
39723 ------------------------------------------------------------------------------------
39724 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39725
39726 ----------------------------------------------------------------------------------
39727 -- 4219869 Business Flow
39728 -- Update journal entry status -- Need to generate this within IF <condition>
39729 ----------------------------------------------------------------------------------
39730 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39731 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
39732 ,p_balance_type_code => l_balance_type_code
39733 );
39734
39735 -------------------------------------------------------------------------------------------
39736 -- 4262811 - Generate the Accrual Reversal lines
39737 -------------------------------------------------------------------------------------------
39738 BEGIN
39739 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
39740 (g_array_event(p_event_id).array_value_num('header_index'));
39741 IF l_acc_rev_flag IS NULL THEN
39742 l_acc_rev_flag := 'N';
39743 END IF;
39744 EXCEPTION
39745 WHEN OTHERS THEN
39746 l_acc_rev_flag := 'N';
39747 END;
39748 --
39749 IF (l_acc_rev_flag = 'Y') THEN
39750
39751 -- 4645092 ------------------------------------------------------------------------------
39752 -- To allow MPA report to determine if it should generate report process
39753 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
39754 ------------------------------------------------------------------------------------------
39755
39756 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
39757 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
39758 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
39759 -- call ADRs
39760 -- Bug 4922099
39761 --
39762 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39763 (NVL(l_actual_upg_option, 'N') = 'O') OR
39764 (NVL(l_enc_upg_option, 'N') = 'O')
39765 )
39766 THEN
39767 NULL;
39768 --
39769 --
39770
39771 l_ccid := AcctDerRule_6(
39772 p_application_id => p_application_id
39773 , p_ae_header_id => l_ae_header_id
39774 , p_source_11 => p_source_11
39775 , x_transaction_coa_id => l_adr_transaction_coa_id
39776 , x_accounting_coa_id => l_adr_accounting_coa_id
39777 , x_value_type_code => l_adr_value_type_code
39778 , p_side => 'NA'
39779 );
39780
39781 xla_ae_lines_pkg.set_ccid(
39782 p_code_combination_id => l_ccid
39783 , p_value_type_code => l_adr_value_type_code
39784 , p_transaction_coa_id => l_adr_transaction_coa_id
39785 , p_accounting_coa_id => l_adr_accounting_coa_id
39786 , p_adr_code => 'CST_DEFAULT'
39787 , p_adr_type_code => 'S'
39788 , p_component_type => l_component_type
39789 , p_component_code => l_component_code
39790 , p_component_type_code => l_component_type_code
39791 , p_component_appl_id => l_component_appl_id
39792 , p_amb_context_code => l_amb_context_code
39793 , p_side => 'NA'
39794 );
39795
39796
39797 --
39798 --
39799 END IF;
39800
39801 --
39802 -- Update the line information that should be overwritten
39803 --
39804 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
39805 p_header_num => 1);
39806 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
39807
39808 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
39809
39810 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
39811 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
39812 END IF;
39813
39814 --
39815 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
39816 --
39817 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
39818 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
39819 ELSE
39820 ---------------------------------------------------------------------------------------------------
39821 -- 4262811a Switch Sign
39822 ---------------------------------------------------------------------------------------------------
39823 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39824 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39825 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39826 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39827 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39828 -- 5132302
39829 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39830 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39831
39832 END IF;
39833
39834 -- 4955764
39835 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39836 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39837
39838
39839 XLA_AE_LINES_PKG.ValidateCurrentLine;
39840 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39841
39842 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39843 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39844 ,p_balance_type_code => l_balance_type_code);
39845
39846 END IF;
39847
39848 -----------------------------------------------------------------------------------------
39849 -- 4262811 Multiperiod Accounting
39850 -----------------------------------------------------------------------------------------
39851 -- No MPA option is assigned.
39852
39853
39854 END IF;
39855 END IF;
39856 --
39857
39858 --
39859 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39860 trace
39861 (p_msg => 'END of AcctLineType_95'
39862 ,p_level => C_LEVEL_PROCEDURE
39863 ,p_module => l_log_module);
39864 END IF;
39865 --
39866 EXCEPTION
39867 WHEN xla_exceptions_pkg.application_exception THEN
39868 RAISE;
39869 WHEN OTHERS THEN
39870 xla_exceptions_pkg.raise_message
39871 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_95');
39872 END AcctLineType_95;
39873 --
39874
39875 ---------------------------------------
39876 --
39877 -- PRIVATE FUNCTION
39878 -- AcctLineType_96
39879 --
39880 ---------------------------------------
39881 PROCEDURE AcctLineType_96 (
39882 p_application_id IN NUMBER
39883 ,p_event_id IN NUMBER
39884 ,p_calculate_acctd_flag IN VARCHAR2
39885 ,p_calculate_g_l_flag IN VARCHAR2
39886 ,p_actual_flag IN OUT VARCHAR2
39887 ,p_balance_type_code OUT VARCHAR2
39888 ,p_gain_or_loss_ref OUT VARCHAR2
39889
39890 --TRANSACTION_ID
39891 , p_source_1 IN NUMBER
39892 --Item Concatenated Segments
39893 , p_source_2 IN VARCHAR2
39894 --Transaction Quantity
39895 , p_source_3 IN NUMBER
39896 --Transaction Unit of Measure Code
39897 , p_source_4 IN VARCHAR2
39898 --Inventory Transaction Type Description
39899 , p_source_5 IN VARCHAR2
39900 --Cost Management Default Account
39901 , p_source_11 IN NUMBER
39902 --DISTRIBUTION_IDENTIFIER
39903 , p_source_84 IN NUMBER
39904 --Distribution Type
39905 , p_source_85 IN VARCHAR2
39906 , p_source_85_meaning IN VARCHAR2
39907 --Entered Currency Code
39908 , p_source_88 IN VARCHAR2
39909 --Entered Amount
39910 , p_source_91 IN NUMBER
39911 --Currency Conversion Date
39912 , p_source_92 IN DATE
39913 --Currency Conversion Rate
39914 , p_source_93 IN NUMBER
39915 --Currency Conversion Type
39916 , p_source_94 IN VARCHAR2
39917 --Accounted Amount
39918 , p_source_95 IN NUMBER
39919 --Accounting Line Type
39920 , p_source_97 IN NUMBER
39921 )
39922 IS
39923
39924 l_component_type VARCHAR2(80);
39925 l_component_code VARCHAR2(30);
39926 l_component_type_code VARCHAR2(1);
39927 l_component_appl_id INTEGER;
39928 l_amb_context_code VARCHAR2(30);
39929 l_entity_code VARCHAR2(30);
39930 l_event_class_code VARCHAR2(30);
39931 l_ae_header_id NUMBER;
39932 l_event_type_code VARCHAR2(30);
39933 l_line_definition_code VARCHAR2(30);
39934 l_line_definition_owner_code VARCHAR2(1);
39935 --
39936 -- adr variables
39937 l_segment VARCHAR2(30);
39938 l_ccid NUMBER;
39939 l_adr_transaction_coa_id NUMBER;
39940 l_adr_accounting_coa_id NUMBER;
39941 l_adr_flexfield_segment_code VARCHAR2(30);
39942 l_adr_flex_value_set_id NUMBER;
39943 l_adr_value_type_code VARCHAR2(30);
39944 l_adr_value_combination_id NUMBER;
39945 l_adr_value_segment_code VARCHAR2(30);
39946
39947 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39948 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39949 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39950 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39951
39952 -- 4262811 Variables ------------------------------------------------------------------------------------------
39953 l_entered_amt_idx NUMBER;
39954 l_accted_amt_idx NUMBER;
39955 l_acc_rev_flag VARCHAR2(1);
39956 l_accrual_line_num NUMBER;
39957 l_tmp_amt NUMBER;
39958 l_acc_rev_natural_side_code VARCHAR2(1);
39959
39960 l_num_entries NUMBER;
39961 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39962 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39963 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39964 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39965 l_recog_line_1 NUMBER;
39966 l_recog_line_2 NUMBER;
39967
39968 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39969 l_bflow_applied_to_amt NUMBER; -- 5132302
39970 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39971
39972 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39973
39974 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39975 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39976
39977 ---------------------------------------------------------------------------------------------------------------
39978
39979
39980 --
39981 -- bulk performance
39982 --
39983 l_balance_type_code VARCHAR2(1);
39984 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39985 l_log_module VARCHAR2(240);
39986
39987 --
39988 -- Upgrade strategy
39989 --
39990 l_actual_upg_option VARCHAR2(1);
39991 l_enc_upg_option VARCHAR2(1);
39992
39993 --
39994 BEGIN
39995 --
39996 IF g_log_enabled THEN
39997 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_96';
39998 END IF;
39999 --
40000 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40001
40002 trace
40003 (p_msg => 'BEGIN of AcctLineType_96'
40004 ,p_level => C_LEVEL_PROCEDURE
40005 ,p_module => l_log_module);
40006
40007 END IF;
40008 --
40009 l_component_type := 'AMB_JLT';
40010 l_component_code := 'COST_VARIANCE';
40011 l_component_type_code := 'S';
40012 l_component_appl_id := 707;
40013 l_amb_context_code := 'DEFAULT';
40014 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
40015 l_event_class_code := 'MTL_COST_UPD';
40016 l_event_type_code := 'STD_COST_UPD';
40017 l_line_definition_owner_code := 'S';
40018 l_line_definition_code := 'PI_STD_COST_UPD';
40019 --
40020 l_balance_type_code := 'A';
40021 l_segment := NULL;
40022 l_ccid := NULL;
40023 l_adr_transaction_coa_id := NULL;
40024 l_adr_accounting_coa_id := NULL;
40025 l_adr_flexfield_segment_code := NULL;
40026 l_adr_flex_value_set_id := NULL;
40027 l_adr_value_type_code := NULL;
40028 l_adr_value_combination_id := NULL;
40029 l_adr_value_segment_code := NULL;
40030
40031 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40032 l_bflow_class_code := ''; -- 4219869 Business Flow
40033 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40034 l_budgetary_control_flag := 'N';
40035
40036 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40037 l_bflow_applied_to_amt := NULL; -- 5132302
40038 l_entered_amt_idx := NULL; -- 4262811
40039 l_accted_amt_idx := NULL; -- 4262811
40040 l_acc_rev_flag := NULL; -- 4262811
40041 l_accrual_line_num := NULL; -- 4262811
40042 l_tmp_amt := NULL; -- 4262811
40043 --
40044
40045 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40046 l_balance_type_code <> 'B' THEN
40047 IF NVL(p_source_97,9E125) = 13
40048 THEN
40049
40050 --
40051 XLA_AE_LINES_PKG.SetNewLine;
40052
40053 p_balance_type_code := l_balance_type_code;
40054 -- set the flag so later we will know whether the gain loss line needs to be created
40055
40056 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40057 p_actual_flag :='A';
40058 END IF;
40059
40060 --
40061 -- bulk performance
40062 --
40063 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40064 p_header_num => 0); -- 4262811
40065 --
40066 -- set accounting line options
40067 --
40068 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40069 p_natural_side_code => 'D'
40070 , p_gain_or_loss_flag => 'N'
40071 , p_gl_transfer_mode_code => 'S'
40072 , p_acct_entry_type_code => 'A'
40073 , p_switch_side_flag => 'Y'
40074 , p_merge_duplicate_code => 'N'
40075 );
40076 --
40077 l_acc_rev_natural_side_code := 'C'; -- 4262811
40078 --
40079 --
40080 -- set accounting line type info
40081 --
40082 xla_ae_lines_pkg.SetAcctLineType
40083 (p_component_type => l_component_type
40084 ,p_event_type_code => l_event_type_code
40085 ,p_line_definition_owner_code => l_line_definition_owner_code
40086 ,p_line_definition_code => l_line_definition_code
40087 ,p_accounting_line_code => l_component_code
40088 ,p_accounting_line_type_code => l_component_type_code
40089 ,p_accounting_line_appl_id => l_component_appl_id
40090 ,p_amb_context_code => l_amb_context_code
40091 ,p_entity_code => l_entity_code
40092 ,p_event_class_code => l_event_class_code);
40093 --
40094 -- set accounting class
40095 --
40096 xla_ae_lines_pkg.SetAcctClass(
40097 p_accounting_class_code => 'COST_VARIANCE'
40098 , p_ae_header_id => l_ae_header_id
40099 );
40100
40101 --
40102 -- set rounding class
40103 --
40104 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40105 'COST_VARIANCE';
40106
40107 --
40108 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40109 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40110 --
40111 -- bulk performance
40112 --
40113 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40114
40115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40116 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40117
40118 -- 4955764
40119 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40120 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40121
40122 -- 4458381 Public Sector Enh
40123
40124 --
40125 -- set accounting attributes for the line type
40126 --
40127 l_entered_amt_idx := 3;
40128 l_accted_amt_idx := 8;
40129 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40130 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
40131 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
40132 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
40133 l_rec_acct_attrs.array_char_value(2) := p_source_85;
40134 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
40135 l_rec_acct_attrs.array_num_value(3) := p_source_91;
40136 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
40137 l_rec_acct_attrs.array_char_value(4) := p_source_88;
40138 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
40139 l_rec_acct_attrs.array_date_value(5) := p_source_92;
40140 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
40141 l_rec_acct_attrs.array_num_value(6) := p_source_93;
40142 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
40143 l_rec_acct_attrs.array_char_value(7) := p_source_94;
40144 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
40145 l_rec_acct_attrs.array_num_value(8) := p_source_95;
40146
40147 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
40148 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
40149
40150 ---------------------------------------------------------------------------------------------------------------
40151 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
40152 ---------------------------------------------------------------------------------------------------------------
40153 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
40154
40155 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40156 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40157
40158 IF xla_accounting_cache_pkg.GetValueChar
40159 (p_source_code => 'LEDGER_CATEGORY_CODE'
40160 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
40161 AND l_bflow_method_code = 'PRIOR_ENTRY'
40162 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
40163 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
40164 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
40165 )
40166 THEN
40167 xla_ae_lines_pkg.BflowUpgEntry
40168 (p_business_method_code => l_bflow_method_code
40169 ,p_business_class_code => l_bflow_class_code
40170 ,p_balance_type => l_balance_type_code);
40171 ELSE
40172 NULL;
40173 -- No business flow processing for business flow method of NONE.
40174 END IF;
40175
40176 --
40177 -- call analytical criteria
40178 --
40179
40180 --
40181 -- call description
40182 --
40183
40184 xla_ae_lines_pkg.SetLineDescription(
40185 p_ae_header_id => l_ae_header_id
40186 ,p_description => Description_1 (
40187 p_application_id => p_application_id
40188 , p_ae_header_id => l_ae_header_id
40189 , p_source_1 => p_source_1
40190 , p_source_2 => p_source_2
40191 , p_source_3 => p_source_3
40192 , p_source_4 => p_source_4
40193 , p_source_5 => p_source_5
40194 )
40195 );
40196
40197
40198 --
40199 -- call ADRs
40200 -- Bug 4922099
40201 --
40202 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40203 (NVL(l_actual_upg_option, 'N') = 'O') OR
40204 (NVL(l_enc_upg_option, 'N') = 'O')
40205 )
40206 THEN
40207 NULL;
40208 --
40209 --
40210
40211 l_ccid := AcctDerRule_6(
40212 p_application_id => p_application_id
40213 , p_ae_header_id => l_ae_header_id
40214 , p_source_11 => p_source_11
40215 , x_transaction_coa_id => l_adr_transaction_coa_id
40216 , x_accounting_coa_id => l_adr_accounting_coa_id
40217 , x_value_type_code => l_adr_value_type_code
40218 , p_side => 'NA'
40219 );
40220
40221 xla_ae_lines_pkg.set_ccid(
40222 p_code_combination_id => l_ccid
40223 , p_value_type_code => l_adr_value_type_code
40224 , p_transaction_coa_id => l_adr_transaction_coa_id
40225 , p_accounting_coa_id => l_adr_accounting_coa_id
40226 , p_adr_code => 'CST_DEFAULT'
40227 , p_adr_type_code => 'S'
40228 , p_component_type => l_component_type
40229 , p_component_code => l_component_code
40230 , p_component_type_code => l_component_type_code
40231 , p_component_appl_id => l_component_appl_id
40232 , p_amb_context_code => l_amb_context_code
40233 , p_side => 'NA'
40234 );
40235
40236
40237 --
40238 --
40239 END IF;
40240 --
40241 -- Bug 4922099
40242 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40243 (NVL(l_enc_upg_option, 'N') = 'O')
40244 ) AND
40245 (l_bflow_method_code = 'PRIOR_ENTRY')
40246 )
40247 THEN
40248 IF
40249 --
40250 1 = 2
40251 --
40252 THEN
40253 xla_accounting_err_pkg.build_message
40254 (p_appli_s_name => 'XLA'
40255 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40256 ,p_token_1 => 'LINE_NUMBER'
40257 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40258 ,p_token_2 => 'LINE_TYPE_NAME'
40259 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40260 l_component_type
40261 ,l_component_code
40262 ,l_component_type_code
40263 ,l_component_appl_id
40264 ,l_amb_context_code
40265 ,l_entity_code
40266 ,l_event_class_code
40267 )
40268 ,p_token_3 => 'OWNER'
40269 ,p_value_3 => xla_lookups_pkg.get_meaning(
40270 p_lookup_type => 'XLA_OWNER_TYPE'
40271 ,p_lookup_code => l_component_type_code
40272 )
40273 ,p_token_4 => 'PRODUCT_NAME'
40274 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40275 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40276 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40277 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40278 ,p_ae_header_id => NULL
40279 );
40280
40281 IF (C_LEVEL_ERROR>= g_log_level) THEN
40282 trace
40283 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40284 ,p_level => C_LEVEL_ERROR
40285 ,p_module => l_log_module);
40286 END IF;
40287 END IF;
40288 END IF;
40289 --
40290 --
40291 ------------------------------------------------------------------------------------------------
40292 -- 4219869 Business Flow
40293 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40294 -- Prior Entry. Currently, the following code is always generated.
40295 ------------------------------------------------------------------------------------------------
40296 XLA_AE_LINES_PKG.ValidateCurrentLine;
40297
40298 ------------------------------------------------------------------------------------
40299 -- 4219869 Business Flow
40300 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40301 ------------------------------------------------------------------------------------
40302 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40303
40304 ----------------------------------------------------------------------------------
40305 -- 4219869 Business Flow
40306 -- Update journal entry status -- Need to generate this within IF <condition>
40307 ----------------------------------------------------------------------------------
40308 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40309 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40310 ,p_balance_type_code => l_balance_type_code
40311 );
40312
40313 -------------------------------------------------------------------------------------------
40314 -- 4262811 - Generate the Accrual Reversal lines
40315 -------------------------------------------------------------------------------------------
40316 BEGIN
40317 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40318 (g_array_event(p_event_id).array_value_num('header_index'));
40319 IF l_acc_rev_flag IS NULL THEN
40320 l_acc_rev_flag := 'N';
40321 END IF;
40322 EXCEPTION
40323 WHEN OTHERS THEN
40324 l_acc_rev_flag := 'N';
40325 END;
40326 --
40327 IF (l_acc_rev_flag = 'Y') THEN
40328
40329 -- 4645092 ------------------------------------------------------------------------------
40330 -- To allow MPA report to determine if it should generate report process
40331 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40332 ------------------------------------------------------------------------------------------
40333
40334 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40335 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40336 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40337 -- call ADRs
40338 -- Bug 4922099
40339 --
40340 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40341 (NVL(l_actual_upg_option, 'N') = 'O') OR
40342 (NVL(l_enc_upg_option, 'N') = 'O')
40343 )
40344 THEN
40345 NULL;
40346 --
40347 --
40348
40349 l_ccid := AcctDerRule_6(
40350 p_application_id => p_application_id
40351 , p_ae_header_id => l_ae_header_id
40352 , p_source_11 => p_source_11
40353 , x_transaction_coa_id => l_adr_transaction_coa_id
40354 , x_accounting_coa_id => l_adr_accounting_coa_id
40355 , x_value_type_code => l_adr_value_type_code
40356 , p_side => 'NA'
40357 );
40358
40359 xla_ae_lines_pkg.set_ccid(
40360 p_code_combination_id => l_ccid
40361 , p_value_type_code => l_adr_value_type_code
40362 , p_transaction_coa_id => l_adr_transaction_coa_id
40363 , p_accounting_coa_id => l_adr_accounting_coa_id
40364 , p_adr_code => 'CST_DEFAULT'
40365 , p_adr_type_code => 'S'
40366 , p_component_type => l_component_type
40367 , p_component_code => l_component_code
40368 , p_component_type_code => l_component_type_code
40369 , p_component_appl_id => l_component_appl_id
40370 , p_amb_context_code => l_amb_context_code
40371 , p_side => 'NA'
40372 );
40373
40374
40375 --
40376 --
40377 END IF;
40378
40379 --
40380 -- Update the line information that should be overwritten
40381 --
40382 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40383 p_header_num => 1);
40384 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40385
40386 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40387
40388 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40389 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40390 END IF;
40391
40392 --
40393 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40394 --
40395 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40396 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40397 ELSE
40398 ---------------------------------------------------------------------------------------------------
40399 -- 4262811a Switch Sign
40400 ---------------------------------------------------------------------------------------------------
40401 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40402 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40403 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40404 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40405 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40406 -- 5132302
40407 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40408 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40409
40410 END IF;
40411
40412 -- 4955764
40413 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40414 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40415
40416
40417 XLA_AE_LINES_PKG.ValidateCurrentLine;
40418 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40419
40420 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40421 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40422 ,p_balance_type_code => l_balance_type_code);
40423
40424 END IF;
40425
40426 -----------------------------------------------------------------------------------------
40427 -- 4262811 Multiperiod Accounting
40428 -----------------------------------------------------------------------------------------
40429 -- No MPA option is assigned.
40430
40431
40432 END IF;
40433 END IF;
40434 --
40435
40436 --
40437 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40438 trace
40439 (p_msg => 'END of AcctLineType_96'
40440 ,p_level => C_LEVEL_PROCEDURE
40441 ,p_module => l_log_module);
40442 END IF;
40443 --
40444 EXCEPTION
40445 WHEN xla_exceptions_pkg.application_exception THEN
40446 RAISE;
40447 WHEN OTHERS THEN
40448 xla_exceptions_pkg.raise_message
40449 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_96');
40450 END AcctLineType_96;
40451 --
40452
40453 ---------------------------------------
40454 --
40455 -- PRIVATE FUNCTION
40456 -- AcctLineType_97
40457 --
40458 ---------------------------------------
40459 PROCEDURE AcctLineType_97 (
40460 p_application_id IN NUMBER
40461 ,p_event_id IN NUMBER
40462 ,p_calculate_acctd_flag IN VARCHAR2
40463 ,p_calculate_g_l_flag IN VARCHAR2
40464 ,p_actual_flag IN OUT VARCHAR2
40465 ,p_balance_type_code OUT VARCHAR2
40466 ,p_gain_or_loss_ref OUT VARCHAR2
40467
40468 --TRANSACTION_ID
40469 , p_source_1 IN NUMBER
40470 --Item Concatenated Segments
40471 , p_source_2 IN VARCHAR2
40472 --Transaction Quantity
40473 , p_source_3 IN NUMBER
40474 --Transaction Unit of Measure Code
40475 , p_source_4 IN VARCHAR2
40476 --Inventory Transaction Type Description
40477 , p_source_5 IN VARCHAR2
40478 --Cost Management Default Account
40479 , p_source_11 IN NUMBER
40480 --DISTRIBUTION_IDENTIFIER
40481 , p_source_84 IN NUMBER
40482 --Distribution Type
40483 , p_source_85 IN VARCHAR2
40484 , p_source_85_meaning IN VARCHAR2
40485 --Entered Currency Code
40486 , p_source_88 IN VARCHAR2
40487 --Entered Amount
40488 , p_source_91 IN NUMBER
40489 --Currency Conversion Date
40490 , p_source_92 IN DATE
40491 --Currency Conversion Rate
40492 , p_source_93 IN NUMBER
40493 --Currency Conversion Type
40494 , p_source_94 IN VARCHAR2
40495 --Accounted Amount
40496 , p_source_95 IN NUMBER
40497 --Accounting Line Type
40498 , p_source_97 IN NUMBER
40499 )
40500 IS
40501
40502 l_component_type VARCHAR2(80);
40503 l_component_code VARCHAR2(30);
40504 l_component_type_code VARCHAR2(1);
40505 l_component_appl_id INTEGER;
40506 l_amb_context_code VARCHAR2(30);
40507 l_entity_code VARCHAR2(30);
40508 l_event_class_code VARCHAR2(30);
40509 l_ae_header_id NUMBER;
40510 l_event_type_code VARCHAR2(30);
40511 l_line_definition_code VARCHAR2(30);
40512 l_line_definition_owner_code VARCHAR2(1);
40513 --
40514 -- adr variables
40515 l_segment VARCHAR2(30);
40516 l_ccid NUMBER;
40517 l_adr_transaction_coa_id NUMBER;
40518 l_adr_accounting_coa_id NUMBER;
40519 l_adr_flexfield_segment_code VARCHAR2(30);
40520 l_adr_flex_value_set_id NUMBER;
40521 l_adr_value_type_code VARCHAR2(30);
40522 l_adr_value_combination_id NUMBER;
40523 l_adr_value_segment_code VARCHAR2(30);
40524
40525 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40526 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40527 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40528 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40529
40530 -- 4262811 Variables ------------------------------------------------------------------------------------------
40531 l_entered_amt_idx NUMBER;
40532 l_accted_amt_idx NUMBER;
40533 l_acc_rev_flag VARCHAR2(1);
40534 l_accrual_line_num NUMBER;
40535 l_tmp_amt NUMBER;
40536 l_acc_rev_natural_side_code VARCHAR2(1);
40537
40538 l_num_entries NUMBER;
40539 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40540 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40541 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40542 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40543 l_recog_line_1 NUMBER;
40544 l_recog_line_2 NUMBER;
40545
40546 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40547 l_bflow_applied_to_amt NUMBER; -- 5132302
40548 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40549
40550 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40551
40552 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40553 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40554
40555 ---------------------------------------------------------------------------------------------------------------
40556
40557
40558 --
40559 -- bulk performance
40560 --
40561 l_balance_type_code VARCHAR2(1);
40562 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40563 l_log_module VARCHAR2(240);
40564
40565 --
40566 -- Upgrade strategy
40567 --
40568 l_actual_upg_option VARCHAR2(1);
40569 l_enc_upg_option VARCHAR2(1);
40570
40571 --
40572 BEGIN
40573 --
40574 IF g_log_enabled THEN
40575 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_97';
40576 END IF;
40577 --
40578 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40579
40580 trace
40581 (p_msg => 'BEGIN of AcctLineType_97'
40582 ,p_level => C_LEVEL_PROCEDURE
40583 ,p_module => l_log_module);
40584
40585 END IF;
40586 --
40587 l_component_type := 'AMB_JLT';
40588 l_component_code := 'COST_VARIANCE';
40589 l_component_type_code := 'S';
40590 l_component_appl_id := 707;
40591 l_amb_context_code := 'DEFAULT';
40592 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
40593 l_event_class_code := 'USER_DEFINE';
40594 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
40595 l_line_definition_owner_code := 'S';
40596 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
40597 --
40598 l_balance_type_code := 'A';
40599 l_segment := NULL;
40600 l_ccid := NULL;
40601 l_adr_transaction_coa_id := NULL;
40602 l_adr_accounting_coa_id := NULL;
40603 l_adr_flexfield_segment_code := NULL;
40604 l_adr_flex_value_set_id := NULL;
40605 l_adr_value_type_code := NULL;
40606 l_adr_value_combination_id := NULL;
40607 l_adr_value_segment_code := NULL;
40608
40609 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40610 l_bflow_class_code := ''; -- 4219869 Business Flow
40611 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40612 l_budgetary_control_flag := 'N';
40613
40614 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40615 l_bflow_applied_to_amt := NULL; -- 5132302
40616 l_entered_amt_idx := NULL; -- 4262811
40617 l_accted_amt_idx := NULL; -- 4262811
40618 l_acc_rev_flag := NULL; -- 4262811
40619 l_accrual_line_num := NULL; -- 4262811
40620 l_tmp_amt := NULL; -- 4262811
40621 --
40622
40623 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40624 l_balance_type_code <> 'B' THEN
40625 IF NVL(p_source_97,9E125) = 13
40626 THEN
40627
40628 --
40629 XLA_AE_LINES_PKG.SetNewLine;
40630
40631 p_balance_type_code := l_balance_type_code;
40632 -- set the flag so later we will know whether the gain loss line needs to be created
40633
40634 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40635 p_actual_flag :='A';
40636 END IF;
40637
40638 --
40639 -- bulk performance
40640 --
40641 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40642 p_header_num => 0); -- 4262811
40643 --
40644 -- set accounting line options
40645 --
40646 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40647 p_natural_side_code => 'D'
40648 , p_gain_or_loss_flag => 'N'
40649 , p_gl_transfer_mode_code => 'S'
40650 , p_acct_entry_type_code => 'A'
40651 , p_switch_side_flag => 'Y'
40652 , p_merge_duplicate_code => 'N'
40653 );
40654 --
40655 l_acc_rev_natural_side_code := 'C'; -- 4262811
40656 --
40657 --
40658 -- set accounting line type info
40659 --
40660 xla_ae_lines_pkg.SetAcctLineType
40661 (p_component_type => l_component_type
40662 ,p_event_type_code => l_event_type_code
40663 ,p_line_definition_owner_code => l_line_definition_owner_code
40664 ,p_line_definition_code => l_line_definition_code
40665 ,p_accounting_line_code => l_component_code
40666 ,p_accounting_line_type_code => l_component_type_code
40667 ,p_accounting_line_appl_id => l_component_appl_id
40668 ,p_amb_context_code => l_amb_context_code
40669 ,p_entity_code => l_entity_code
40670 ,p_event_class_code => l_event_class_code);
40671 --
40672 -- set accounting class
40673 --
40674 xla_ae_lines_pkg.SetAcctClass(
40675 p_accounting_class_code => 'COST_VARIANCE'
40676 , p_ae_header_id => l_ae_header_id
40677 );
40678
40679 --
40680 -- set rounding class
40681 --
40682 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40683 'COST_VARIANCE';
40684
40685 --
40686 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40687 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40688 --
40689 -- bulk performance
40690 --
40691 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40692
40693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40694 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40695
40696 -- 4955764
40697 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40698 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40699
40700 -- 4458381 Public Sector Enh
40701
40702 --
40703 -- set accounting attributes for the line type
40704 --
40705 l_entered_amt_idx := 3;
40706 l_accted_amt_idx := 8;
40707 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40708 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
40709 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
40710 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
40711 l_rec_acct_attrs.array_char_value(2) := p_source_85;
40712 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
40713 l_rec_acct_attrs.array_num_value(3) := p_source_91;
40714 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
40715 l_rec_acct_attrs.array_char_value(4) := p_source_88;
40716 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
40717 l_rec_acct_attrs.array_date_value(5) := p_source_92;
40718 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
40719 l_rec_acct_attrs.array_num_value(6) := p_source_93;
40720 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
40721 l_rec_acct_attrs.array_char_value(7) := p_source_94;
40722 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
40723 l_rec_acct_attrs.array_num_value(8) := p_source_95;
40724
40725 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
40726 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
40727
40728 ---------------------------------------------------------------------------------------------------------------
40729 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
40730 ---------------------------------------------------------------------------------------------------------------
40731 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
40732
40733 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40734 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40735
40736 IF xla_accounting_cache_pkg.GetValueChar
40737 (p_source_code => 'LEDGER_CATEGORY_CODE'
40738 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
40739 AND l_bflow_method_code = 'PRIOR_ENTRY'
40740 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
40741 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
40742 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
40743 )
40744 THEN
40745 xla_ae_lines_pkg.BflowUpgEntry
40746 (p_business_method_code => l_bflow_method_code
40747 ,p_business_class_code => l_bflow_class_code
40748 ,p_balance_type => l_balance_type_code);
40749 ELSE
40750 NULL;
40751 -- No business flow processing for business flow method of NONE.
40752 END IF;
40753
40754 --
40755 -- call analytical criteria
40756 --
40757
40758 --
40759 -- call description
40760 --
40761
40762 xla_ae_lines_pkg.SetLineDescription(
40763 p_ae_header_id => l_ae_header_id
40764 ,p_description => Description_1 (
40765 p_application_id => p_application_id
40766 , p_ae_header_id => l_ae_header_id
40767 , p_source_1 => p_source_1
40768 , p_source_2 => p_source_2
40769 , p_source_3 => p_source_3
40770 , p_source_4 => p_source_4
40771 , p_source_5 => p_source_5
40772 )
40773 );
40774
40775
40776 --
40777 -- call ADRs
40778 -- Bug 4922099
40779 --
40780 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40781 (NVL(l_actual_upg_option, 'N') = 'O') OR
40782 (NVL(l_enc_upg_option, 'N') = 'O')
40783 )
40784 THEN
40785 NULL;
40786 --
40787 --
40788
40789 l_ccid := AcctDerRule_6(
40790 p_application_id => p_application_id
40791 , p_ae_header_id => l_ae_header_id
40792 , p_source_11 => p_source_11
40793 , x_transaction_coa_id => l_adr_transaction_coa_id
40794 , x_accounting_coa_id => l_adr_accounting_coa_id
40795 , x_value_type_code => l_adr_value_type_code
40796 , p_side => 'NA'
40797 );
40798
40799 xla_ae_lines_pkg.set_ccid(
40800 p_code_combination_id => l_ccid
40801 , p_value_type_code => l_adr_value_type_code
40802 , p_transaction_coa_id => l_adr_transaction_coa_id
40803 , p_accounting_coa_id => l_adr_accounting_coa_id
40804 , p_adr_code => 'CST_DEFAULT'
40805 , p_adr_type_code => 'S'
40806 , p_component_type => l_component_type
40807 , p_component_code => l_component_code
40808 , p_component_type_code => l_component_type_code
40809 , p_component_appl_id => l_component_appl_id
40810 , p_amb_context_code => l_amb_context_code
40811 , p_side => 'NA'
40812 );
40813
40814
40815 --
40816 --
40817 END IF;
40818 --
40819 -- Bug 4922099
40820 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40821 (NVL(l_enc_upg_option, 'N') = 'O')
40822 ) AND
40823 (l_bflow_method_code = 'PRIOR_ENTRY')
40824 )
40825 THEN
40826 IF
40827 --
40828 1 = 2
40829 --
40830 THEN
40831 xla_accounting_err_pkg.build_message
40832 (p_appli_s_name => 'XLA'
40833 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40834 ,p_token_1 => 'LINE_NUMBER'
40835 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40836 ,p_token_2 => 'LINE_TYPE_NAME'
40837 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40838 l_component_type
40839 ,l_component_code
40840 ,l_component_type_code
40841 ,l_component_appl_id
40842 ,l_amb_context_code
40843 ,l_entity_code
40844 ,l_event_class_code
40845 )
40846 ,p_token_3 => 'OWNER'
40847 ,p_value_3 => xla_lookups_pkg.get_meaning(
40848 p_lookup_type => 'XLA_OWNER_TYPE'
40849 ,p_lookup_code => l_component_type_code
40850 )
40851 ,p_token_4 => 'PRODUCT_NAME'
40852 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40853 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40854 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40855 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40856 ,p_ae_header_id => NULL
40857 );
40858
40859 IF (C_LEVEL_ERROR>= g_log_level) THEN
40860 trace
40861 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40862 ,p_level => C_LEVEL_ERROR
40863 ,p_module => l_log_module);
40864 END IF;
40865 END IF;
40866 END IF;
40867 --
40868 --
40869 ------------------------------------------------------------------------------------------------
40870 -- 4219869 Business Flow
40871 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40872 -- Prior Entry. Currently, the following code is always generated.
40873 ------------------------------------------------------------------------------------------------
40874 XLA_AE_LINES_PKG.ValidateCurrentLine;
40875
40876 ------------------------------------------------------------------------------------
40877 -- 4219869 Business Flow
40878 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40879 ------------------------------------------------------------------------------------
40880 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40881
40882 ----------------------------------------------------------------------------------
40883 -- 4219869 Business Flow
40884 -- Update journal entry status -- Need to generate this within IF <condition>
40885 ----------------------------------------------------------------------------------
40886 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40887 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40888 ,p_balance_type_code => l_balance_type_code
40889 );
40890
40891 -------------------------------------------------------------------------------------------
40892 -- 4262811 - Generate the Accrual Reversal lines
40893 -------------------------------------------------------------------------------------------
40894 BEGIN
40895 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40896 (g_array_event(p_event_id).array_value_num('header_index'));
40897 IF l_acc_rev_flag IS NULL THEN
40898 l_acc_rev_flag := 'N';
40899 END IF;
40900 EXCEPTION
40901 WHEN OTHERS THEN
40902 l_acc_rev_flag := 'N';
40903 END;
40904 --
40905 IF (l_acc_rev_flag = 'Y') THEN
40906
40907 -- 4645092 ------------------------------------------------------------------------------
40908 -- To allow MPA report to determine if it should generate report process
40909 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40910 ------------------------------------------------------------------------------------------
40911
40912 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40913 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40914 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40915 -- call ADRs
40916 -- Bug 4922099
40917 --
40918 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40919 (NVL(l_actual_upg_option, 'N') = 'O') OR
40920 (NVL(l_enc_upg_option, 'N') = 'O')
40921 )
40922 THEN
40923 NULL;
40924 --
40925 --
40926
40927 l_ccid := AcctDerRule_6(
40928 p_application_id => p_application_id
40929 , p_ae_header_id => l_ae_header_id
40930 , p_source_11 => p_source_11
40931 , x_transaction_coa_id => l_adr_transaction_coa_id
40932 , x_accounting_coa_id => l_adr_accounting_coa_id
40933 , x_value_type_code => l_adr_value_type_code
40934 , p_side => 'NA'
40935 );
40936
40937 xla_ae_lines_pkg.set_ccid(
40938 p_code_combination_id => l_ccid
40939 , p_value_type_code => l_adr_value_type_code
40940 , p_transaction_coa_id => l_adr_transaction_coa_id
40941 , p_accounting_coa_id => l_adr_accounting_coa_id
40942 , p_adr_code => 'CST_DEFAULT'
40943 , p_adr_type_code => 'S'
40944 , p_component_type => l_component_type
40945 , p_component_code => l_component_code
40946 , p_component_type_code => l_component_type_code
40947 , p_component_appl_id => l_component_appl_id
40948 , p_amb_context_code => l_amb_context_code
40949 , p_side => 'NA'
40950 );
40951
40952
40953 --
40954 --
40955 END IF;
40956
40957 --
40958 -- Update the line information that should be overwritten
40959 --
40960 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40961 p_header_num => 1);
40962 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40963
40964 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40965
40966 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40967 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40968 END IF;
40969
40970 --
40971 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40972 --
40973 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40974 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40975 ELSE
40976 ---------------------------------------------------------------------------------------------------
40977 -- 4262811a Switch Sign
40978 ---------------------------------------------------------------------------------------------------
40979 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40982 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40983 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40984 -- 5132302
40985 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40986 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40987
40988 END IF;
40989
40990 -- 4955764
40991 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40992 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40993
40994
40995 XLA_AE_LINES_PKG.ValidateCurrentLine;
40996 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40997
40998 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40999 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41000 ,p_balance_type_code => l_balance_type_code);
41001
41002 END IF;
41003
41004 -----------------------------------------------------------------------------------------
41005 -- 4262811 Multiperiod Accounting
41006 -----------------------------------------------------------------------------------------
41007 -- No MPA option is assigned.
41008
41009
41010 END IF;
41011 END IF;
41012 --
41013
41014 --
41015 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41016 trace
41017 (p_msg => 'END of AcctLineType_97'
41018 ,p_level => C_LEVEL_PROCEDURE
41019 ,p_module => l_log_module);
41020 END IF;
41021 --
41022 EXCEPTION
41023 WHEN xla_exceptions_pkg.application_exception THEN
41024 RAISE;
41025 WHEN OTHERS THEN
41026 xla_exceptions_pkg.raise_message
41027 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_97');
41028 END AcctLineType_97;
41029 --
41030
41031 ---------------------------------------
41032 --
41033 -- PRIVATE FUNCTION
41034 -- AcctLineType_98
41035 --
41036 ---------------------------------------
41037 PROCEDURE AcctLineType_98 (
41038 p_application_id IN NUMBER
41039 ,p_event_id IN NUMBER
41040 ,p_calculate_acctd_flag IN VARCHAR2
41041 ,p_calculate_g_l_flag IN VARCHAR2
41042 ,p_actual_flag IN OUT VARCHAR2
41043 ,p_balance_type_code OUT VARCHAR2
41044 ,p_gain_or_loss_ref OUT VARCHAR2
41045
41046 --TRANSACTION_ID
41047 , p_source_1 IN NUMBER
41048 --Item Concatenated Segments
41049 , p_source_2 IN VARCHAR2
41050 --Transaction Quantity
41051 , p_source_3 IN NUMBER
41052 --Transaction Unit of Measure Code
41053 , p_source_4 IN VARCHAR2
41054 --Inventory Transaction Type Description
41055 , p_source_5 IN VARCHAR2
41056 --Product Line Accounting Category Average Cost Variance Account
41057 , p_source_23 IN NUMBER
41058 --DISTRIBUTION_IDENTIFIER
41059 , p_source_84 IN NUMBER
41060 --Distribution Type
41061 , p_source_85 IN VARCHAR2
41062 , p_source_85_meaning IN VARCHAR2
41063 --Entered Currency Code
41064 , p_source_88 IN VARCHAR2
41065 --Entered Amount
41066 , p_source_91 IN NUMBER
41067 --Currency Conversion Date
41068 , p_source_92 IN DATE
41069 --Currency Conversion Rate
41070 , p_source_93 IN NUMBER
41071 --Currency Conversion Type
41072 , p_source_94 IN VARCHAR2
41073 --Accounted Amount
41074 , p_source_95 IN NUMBER
41075 --Accounting Line Type
41076 , p_source_97 IN NUMBER
41077 )
41078 IS
41079
41080 l_component_type VARCHAR2(80);
41081 l_component_code VARCHAR2(30);
41082 l_component_type_code VARCHAR2(1);
41083 l_component_appl_id INTEGER;
41084 l_amb_context_code VARCHAR2(30);
41085 l_entity_code VARCHAR2(30);
41086 l_event_class_code VARCHAR2(30);
41087 l_ae_header_id NUMBER;
41088 l_event_type_code VARCHAR2(30);
41089 l_line_definition_code VARCHAR2(30);
41090 l_line_definition_owner_code VARCHAR2(1);
41091 --
41092 -- adr variables
41093 l_segment VARCHAR2(30);
41094 l_ccid NUMBER;
41095 l_adr_transaction_coa_id NUMBER;
41096 l_adr_accounting_coa_id NUMBER;
41097 l_adr_flexfield_segment_code VARCHAR2(30);
41098 l_adr_flex_value_set_id NUMBER;
41099 l_adr_value_type_code VARCHAR2(30);
41100 l_adr_value_combination_id NUMBER;
41101 l_adr_value_segment_code VARCHAR2(30);
41102
41103 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41104 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41105 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41106 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41107
41108 -- 4262811 Variables ------------------------------------------------------------------------------------------
41109 l_entered_amt_idx NUMBER;
41110 l_accted_amt_idx NUMBER;
41111 l_acc_rev_flag VARCHAR2(1);
41112 l_accrual_line_num NUMBER;
41113 l_tmp_amt NUMBER;
41114 l_acc_rev_natural_side_code VARCHAR2(1);
41115
41116 l_num_entries NUMBER;
41117 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41118 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41119 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41120 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41121 l_recog_line_1 NUMBER;
41122 l_recog_line_2 NUMBER;
41123
41124 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41125 l_bflow_applied_to_amt NUMBER; -- 5132302
41126 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41127
41128 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41129
41130 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41131 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41132
41133 ---------------------------------------------------------------------------------------------------------------
41134
41135
41136 --
41137 -- bulk performance
41138 --
41139 l_balance_type_code VARCHAR2(1);
41140 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41141 l_log_module VARCHAR2(240);
41142
41143 --
41144 -- Upgrade strategy
41145 --
41146 l_actual_upg_option VARCHAR2(1);
41147 l_enc_upg_option VARCHAR2(1);
41148
41149 --
41150 BEGIN
41151 --
41152 IF g_log_enabled THEN
41153 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_98';
41154 END IF;
41155 --
41156 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41157
41158 trace
41159 (p_msg => 'BEGIN of AcctLineType_98'
41160 ,p_level => C_LEVEL_PROCEDURE
41161 ,p_module => l_log_module);
41162
41163 END IF;
41164 --
41165 l_component_type := 'AMB_JLT';
41166 l_component_code := 'COST_VARIANCE';
41167 l_component_type_code := 'S';
41168 l_component_appl_id := 707;
41169 l_amb_context_code := 'DEFAULT';
41170 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
41171 l_event_class_code := 'USER_DEFINE';
41172 l_event_type_code := 'UMISC_ISSUE';
41173 l_line_definition_owner_code := 'S';
41174 l_line_definition_code := 'PI_USER_ISSUE';
41175 --
41176 l_balance_type_code := 'A';
41177 l_segment := NULL;
41178 l_ccid := NULL;
41179 l_adr_transaction_coa_id := NULL;
41180 l_adr_accounting_coa_id := NULL;
41181 l_adr_flexfield_segment_code := NULL;
41182 l_adr_flex_value_set_id := NULL;
41183 l_adr_value_type_code := NULL;
41184 l_adr_value_combination_id := NULL;
41185 l_adr_value_segment_code := NULL;
41186
41187 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41188 l_bflow_class_code := ''; -- 4219869 Business Flow
41189 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41190 l_budgetary_control_flag := 'N';
41191
41192 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41193 l_bflow_applied_to_amt := NULL; -- 5132302
41194 l_entered_amt_idx := NULL; -- 4262811
41195 l_accted_amt_idx := NULL; -- 4262811
41196 l_acc_rev_flag := NULL; -- 4262811
41197 l_accrual_line_num := NULL; -- 4262811
41198 l_tmp_amt := NULL; -- 4262811
41199 --
41200
41201 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41202 l_balance_type_code <> 'B' THEN
41203 IF NVL(p_source_97,9E125) = 13
41204 THEN
41205
41206 --
41207 XLA_AE_LINES_PKG.SetNewLine;
41208
41209 p_balance_type_code := l_balance_type_code;
41210 -- set the flag so later we will know whether the gain loss line needs to be created
41211
41212 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41213 p_actual_flag :='A';
41214 END IF;
41215
41216 --
41217 -- bulk performance
41218 --
41219 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41220 p_header_num => 0); -- 4262811
41221 --
41222 -- set accounting line options
41223 --
41224 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41225 p_natural_side_code => 'D'
41226 , p_gain_or_loss_flag => 'N'
41227 , p_gl_transfer_mode_code => 'S'
41228 , p_acct_entry_type_code => 'A'
41229 , p_switch_side_flag => 'Y'
41230 , p_merge_duplicate_code => 'N'
41231 );
41232 --
41233 l_acc_rev_natural_side_code := 'C'; -- 4262811
41234 --
41235 --
41236 -- set accounting line type info
41237 --
41238 xla_ae_lines_pkg.SetAcctLineType
41239 (p_component_type => l_component_type
41240 ,p_event_type_code => l_event_type_code
41241 ,p_line_definition_owner_code => l_line_definition_owner_code
41242 ,p_line_definition_code => l_line_definition_code
41243 ,p_accounting_line_code => l_component_code
41244 ,p_accounting_line_type_code => l_component_type_code
41245 ,p_accounting_line_appl_id => l_component_appl_id
41246 ,p_amb_context_code => l_amb_context_code
41247 ,p_entity_code => l_entity_code
41248 ,p_event_class_code => l_event_class_code);
41249 --
41250 -- set accounting class
41251 --
41252 xla_ae_lines_pkg.SetAcctClass(
41253 p_accounting_class_code => 'COST_VARIANCE'
41254 , p_ae_header_id => l_ae_header_id
41255 );
41256
41257 --
41258 -- set rounding class
41259 --
41260 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41261 'COST_VARIANCE';
41262
41263 --
41264 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41265 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41266 --
41267 -- bulk performance
41268 --
41269 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41270
41271 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41272 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41273
41274 -- 4955764
41275 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41276 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41277
41278 -- 4458381 Public Sector Enh
41279
41280 --
41281 -- set accounting attributes for the line type
41282 --
41283 l_entered_amt_idx := 3;
41284 l_accted_amt_idx := 8;
41285 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41286 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
41287 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
41288 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
41289 l_rec_acct_attrs.array_char_value(2) := p_source_85;
41290 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
41291 l_rec_acct_attrs.array_num_value(3) := p_source_91;
41292 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
41293 l_rec_acct_attrs.array_char_value(4) := p_source_88;
41294 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
41295 l_rec_acct_attrs.array_date_value(5) := p_source_92;
41296 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
41297 l_rec_acct_attrs.array_num_value(6) := p_source_93;
41298 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
41299 l_rec_acct_attrs.array_char_value(7) := p_source_94;
41300 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
41301 l_rec_acct_attrs.array_num_value(8) := p_source_95;
41302
41303 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41304 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41305
41306 ---------------------------------------------------------------------------------------------------------------
41307 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41308 ---------------------------------------------------------------------------------------------------------------
41309 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41310
41311 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41312 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41313
41314 IF xla_accounting_cache_pkg.GetValueChar
41315 (p_source_code => 'LEDGER_CATEGORY_CODE'
41316 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41317 AND l_bflow_method_code = 'PRIOR_ENTRY'
41318 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41319 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41320 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41321 )
41322 THEN
41323 xla_ae_lines_pkg.BflowUpgEntry
41324 (p_business_method_code => l_bflow_method_code
41325 ,p_business_class_code => l_bflow_class_code
41326 ,p_balance_type => l_balance_type_code);
41327 ELSE
41328 NULL;
41329 -- No business flow processing for business flow method of NONE.
41330 END IF;
41331
41332 --
41333 -- call analytical criteria
41334 --
41335
41336 --
41337 -- call description
41338 --
41339
41340 xla_ae_lines_pkg.SetLineDescription(
41341 p_ae_header_id => l_ae_header_id
41342 ,p_description => Description_1 (
41343 p_application_id => p_application_id
41344 , p_ae_header_id => l_ae_header_id
41345 , p_source_1 => p_source_1
41346 , p_source_2 => p_source_2
41347 , p_source_3 => p_source_3
41348 , p_source_4 => p_source_4
41349 , p_source_5 => p_source_5
41350 )
41351 );
41352
41353
41354 --
41355 -- call ADRs
41356 -- Bug 4922099
41357 --
41358 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41359 (NVL(l_actual_upg_option, 'N') = 'O') OR
41360 (NVL(l_enc_upg_option, 'N') = 'O')
41361 )
41362 THEN
41363 NULL;
41364 --
41365 --
41366
41367 l_ccid := AcctDerRule_12(
41368 p_application_id => p_application_id
41369 , p_ae_header_id => l_ae_header_id
41370 , p_source_23 => p_source_23
41371 , x_transaction_coa_id => l_adr_transaction_coa_id
41372 , x_accounting_coa_id => l_adr_accounting_coa_id
41373 , x_value_type_code => l_adr_value_type_code
41374 , p_side => 'NA'
41375 );
41376
41377 xla_ae_lines_pkg.set_ccid(
41378 p_code_combination_id => l_ccid
41379 , p_value_type_code => l_adr_value_type_code
41380 , p_transaction_coa_id => l_adr_transaction_coa_id
41381 , p_accounting_coa_id => l_adr_accounting_coa_id
41382 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
41383 , p_adr_type_code => 'S'
41384 , p_component_type => l_component_type
41385 , p_component_code => l_component_code
41386 , p_component_type_code => l_component_type_code
41387 , p_component_appl_id => l_component_appl_id
41388 , p_amb_context_code => l_amb_context_code
41389 , p_side => 'NA'
41390 );
41391
41392
41393 --
41394 --
41395 END IF;
41396 --
41397 -- Bug 4922099
41398 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41399 (NVL(l_enc_upg_option, 'N') = 'O')
41400 ) AND
41401 (l_bflow_method_code = 'PRIOR_ENTRY')
41402 )
41403 THEN
41404 IF
41405 --
41406 1 = 2
41407 --
41408 THEN
41409 xla_accounting_err_pkg.build_message
41410 (p_appli_s_name => 'XLA'
41411 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41412 ,p_token_1 => 'LINE_NUMBER'
41413 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41414 ,p_token_2 => 'LINE_TYPE_NAME'
41415 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41416 l_component_type
41417 ,l_component_code
41418 ,l_component_type_code
41419 ,l_component_appl_id
41420 ,l_amb_context_code
41421 ,l_entity_code
41422 ,l_event_class_code
41423 )
41424 ,p_token_3 => 'OWNER'
41425 ,p_value_3 => xla_lookups_pkg.get_meaning(
41426 p_lookup_type => 'XLA_OWNER_TYPE'
41427 ,p_lookup_code => l_component_type_code
41428 )
41429 ,p_token_4 => 'PRODUCT_NAME'
41430 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41431 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41432 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41433 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41434 ,p_ae_header_id => NULL
41435 );
41436
41437 IF (C_LEVEL_ERROR>= g_log_level) THEN
41438 trace
41439 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41440 ,p_level => C_LEVEL_ERROR
41441 ,p_module => l_log_module);
41442 END IF;
41443 END IF;
41444 END IF;
41445 --
41446 --
41447 ------------------------------------------------------------------------------------------------
41448 -- 4219869 Business Flow
41449 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41450 -- Prior Entry. Currently, the following code is always generated.
41451 ------------------------------------------------------------------------------------------------
41452 XLA_AE_LINES_PKG.ValidateCurrentLine;
41453
41454 ------------------------------------------------------------------------------------
41455 -- 4219869 Business Flow
41456 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41457 ------------------------------------------------------------------------------------
41458 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41459
41460 ----------------------------------------------------------------------------------
41461 -- 4219869 Business Flow
41462 -- Update journal entry status -- Need to generate this within IF <condition>
41463 ----------------------------------------------------------------------------------
41464 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41465 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41466 ,p_balance_type_code => l_balance_type_code
41467 );
41468
41469 -------------------------------------------------------------------------------------------
41470 -- 4262811 - Generate the Accrual Reversal lines
41471 -------------------------------------------------------------------------------------------
41472 BEGIN
41473 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41474 (g_array_event(p_event_id).array_value_num('header_index'));
41475 IF l_acc_rev_flag IS NULL THEN
41476 l_acc_rev_flag := 'N';
41477 END IF;
41478 EXCEPTION
41479 WHEN OTHERS THEN
41480 l_acc_rev_flag := 'N';
41481 END;
41482 --
41483 IF (l_acc_rev_flag = 'Y') THEN
41484
41485 -- 4645092 ------------------------------------------------------------------------------
41486 -- To allow MPA report to determine if it should generate report process
41487 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41488 ------------------------------------------------------------------------------------------
41489
41490 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41491 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41492 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41493 -- call ADRs
41494 -- Bug 4922099
41495 --
41496 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41497 (NVL(l_actual_upg_option, 'N') = 'O') OR
41498 (NVL(l_enc_upg_option, 'N') = 'O')
41499 )
41500 THEN
41501 NULL;
41502 --
41503 --
41504
41505 l_ccid := AcctDerRule_12(
41506 p_application_id => p_application_id
41507 , p_ae_header_id => l_ae_header_id
41508 , p_source_23 => p_source_23
41509 , x_transaction_coa_id => l_adr_transaction_coa_id
41510 , x_accounting_coa_id => l_adr_accounting_coa_id
41511 , x_value_type_code => l_adr_value_type_code
41512 , p_side => 'NA'
41513 );
41514
41515 xla_ae_lines_pkg.set_ccid(
41516 p_code_combination_id => l_ccid
41517 , p_value_type_code => l_adr_value_type_code
41518 , p_transaction_coa_id => l_adr_transaction_coa_id
41519 , p_accounting_coa_id => l_adr_accounting_coa_id
41520 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
41521 , p_adr_type_code => 'S'
41522 , p_component_type => l_component_type
41523 , p_component_code => l_component_code
41524 , p_component_type_code => l_component_type_code
41525 , p_component_appl_id => l_component_appl_id
41526 , p_amb_context_code => l_amb_context_code
41527 , p_side => 'NA'
41528 );
41529
41530
41531 --
41532 --
41533 END IF;
41534
41535 --
41536 -- Update the line information that should be overwritten
41537 --
41538 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41539 p_header_num => 1);
41540 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41541
41542 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41543
41544 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41545 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41546 END IF;
41547
41548 --
41549 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41550 --
41551 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41552 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41553 ELSE
41554 ---------------------------------------------------------------------------------------------------
41555 -- 4262811a Switch Sign
41556 ---------------------------------------------------------------------------------------------------
41557 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41558 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41559 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41560 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41561 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41562 -- 5132302
41563 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41564 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41565
41566 END IF;
41567
41568 -- 4955764
41569 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41570 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41571
41572
41573 XLA_AE_LINES_PKG.ValidateCurrentLine;
41574 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41575
41576 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41577 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41578 ,p_balance_type_code => l_balance_type_code);
41579
41580 END IF;
41581
41582 -----------------------------------------------------------------------------------------
41583 -- 4262811 Multiperiod Accounting
41584 -----------------------------------------------------------------------------------------
41585 -- No MPA option is assigned.
41586
41587
41588 END IF;
41589 END IF;
41590 --
41591
41592 --
41593 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41594 trace
41595 (p_msg => 'END of AcctLineType_98'
41596 ,p_level => C_LEVEL_PROCEDURE
41597 ,p_module => l_log_module);
41598 END IF;
41599 --
41600 EXCEPTION
41601 WHEN xla_exceptions_pkg.application_exception THEN
41602 RAISE;
41603 WHEN OTHERS THEN
41604 xla_exceptions_pkg.raise_message
41605 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_98');
41606 END AcctLineType_98;
41607 --
41608
41609 ---------------------------------------
41610 --
41611 -- PRIVATE FUNCTION
41612 -- AcctLineType_99
41613 --
41614 ---------------------------------------
41615 PROCEDURE AcctLineType_99 (
41616 p_application_id IN NUMBER
41617 ,p_event_id IN NUMBER
41618 ,p_calculate_acctd_flag IN VARCHAR2
41619 ,p_calculate_g_l_flag IN VARCHAR2
41620 ,p_actual_flag IN OUT VARCHAR2
41621 ,p_balance_type_code OUT VARCHAR2
41622 ,p_gain_or_loss_ref OUT VARCHAR2
41623
41624 --TRANSACTION_ID
41625 , p_source_1 IN NUMBER
41626 --Item Concatenated Segments
41627 , p_source_2 IN VARCHAR2
41628 --Transaction Quantity
41629 , p_source_3 IN NUMBER
41630 --Transaction Unit of Measure Code
41631 , p_source_4 IN VARCHAR2
41632 --Inventory Transaction Type Description
41633 , p_source_5 IN VARCHAR2
41634 --Cost Management Default Account
41635 , p_source_11 IN NUMBER
41636 --Applied to Application ID
41637 , p_source_79 IN NUMBER
41638 --Applied to Distribution Link Type
41639 , p_source_80 IN VARCHAR2
41640 --Applied to Entity Code
41641 , p_source_81 IN VARCHAR2
41642 --DISTRIBUTION_IDENTIFIER
41643 , p_source_84 IN NUMBER
41644 --Distribution Type
41645 , p_source_85 IN VARCHAR2
41646 , p_source_85_meaning IN VARCHAR2
41647 --Encumbrance Reversal Amount Entered
41648 , p_source_87 IN NUMBER
41649 --Entered Currency Code
41650 , p_source_88 IN VARCHAR2
41651 --Transaction Encumbrance Reversal Amount
41652 , p_source_89 IN NUMBER
41653 --Entered Amount
41654 , p_source_91 IN NUMBER
41655 --Currency Conversion Date
41656 , p_source_92 IN DATE
41657 --Currency Conversion Rate
41658 , p_source_93 IN NUMBER
41659 --Currency Conversion Type
41660 , p_source_94 IN VARCHAR2
41661 --Accounted Amount
41662 , p_source_95 IN NUMBER
41663 --Accounting Line Type
41664 , p_source_97 IN NUMBER
41665 --Costing Encumbrance Upgrade Option
41666 , p_source_100 IN VARCHAR2
41667 --TXN_PO_DISTRIBUTION_ID
41668 , p_source_101 IN NUMBER
41669 --TXN_PO_HEADER_ID
41670 , p_source_102 IN NUMBER
41671 --Requisition Budget Account
41672 , p_source_103 IN NUMBER
41673 --Requisition Encumbrance Type Identifier
41674 , p_source_104 IN NUMBER
41675 )
41676 IS
41677
41678 l_component_type VARCHAR2(80);
41679 l_component_code VARCHAR2(30);
41680 l_component_type_code VARCHAR2(1);
41681 l_component_appl_id INTEGER;
41682 l_amb_context_code VARCHAR2(30);
41683 l_entity_code VARCHAR2(30);
41684 l_event_class_code VARCHAR2(30);
41685 l_ae_header_id NUMBER;
41686 l_event_type_code VARCHAR2(30);
41687 l_line_definition_code VARCHAR2(30);
41688 l_line_definition_owner_code VARCHAR2(1);
41689 --
41690 -- adr variables
41691 l_segment VARCHAR2(30);
41692 l_ccid NUMBER;
41693 l_adr_transaction_coa_id NUMBER;
41694 l_adr_accounting_coa_id NUMBER;
41695 l_adr_flexfield_segment_code VARCHAR2(30);
41696 l_adr_flex_value_set_id NUMBER;
41697 l_adr_value_type_code VARCHAR2(30);
41698 l_adr_value_combination_id NUMBER;
41699 l_adr_value_segment_code VARCHAR2(30);
41700
41701 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41702 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41703 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41704 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41705
41706 -- 4262811 Variables ------------------------------------------------------------------------------------------
41707 l_entered_amt_idx NUMBER;
41708 l_accted_amt_idx NUMBER;
41709 l_acc_rev_flag VARCHAR2(1);
41710 l_accrual_line_num NUMBER;
41711 l_tmp_amt NUMBER;
41712 l_acc_rev_natural_side_code VARCHAR2(1);
41713
41714 l_num_entries NUMBER;
41715 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41716 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41717 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41718 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41719 l_recog_line_1 NUMBER;
41720 l_recog_line_2 NUMBER;
41721
41722 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41723 l_bflow_applied_to_amt NUMBER; -- 5132302
41724 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41725
41726 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41727
41728 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41729 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41730
41731 ---------------------------------------------------------------------------------------------------------------
41732
41733
41734 --
41735 -- bulk performance
41736 --
41737 l_balance_type_code VARCHAR2(1);
41738 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41739 l_log_module VARCHAR2(240);
41740
41741 --
41742 -- Upgrade strategy
41743 --
41744 l_actual_upg_option VARCHAR2(1);
41745 l_enc_upg_option VARCHAR2(1);
41746
41747 --
41748 BEGIN
41749 --
41750 IF g_log_enabled THEN
41751 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_99';
41752 END IF;
41753 --
41754 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41755
41756 trace
41757 (p_msg => 'BEGIN of AcctLineType_99'
41758 ,p_level => C_LEVEL_PROCEDURE
41759 ,p_module => l_log_module);
41760
41761 END IF;
41762 --
41763 l_component_type := 'AMB_JLT';
41764 l_component_code := 'COST_VARIANCE';
41765 l_component_type_code := 'S';
41766 l_component_appl_id := 707;
41767 l_amb_context_code := 'DEFAULT';
41768 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
41769 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
41770 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
41771 l_line_definition_owner_code := 'S';
41772 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
41773 --
41774 l_balance_type_code := 'A';
41775 l_segment := NULL;
41776 l_ccid := NULL;
41777 l_adr_transaction_coa_id := NULL;
41778 l_adr_accounting_coa_id := NULL;
41779 l_adr_flexfield_segment_code := NULL;
41780 l_adr_flex_value_set_id := NULL;
41781 l_adr_value_type_code := NULL;
41782 l_adr_value_combination_id := NULL;
41783 l_adr_value_segment_code := NULL;
41784
41785 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41786 l_bflow_class_code := ''; -- 4219869 Business Flow
41787 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41788 l_budgetary_control_flag := 'N';
41789
41790 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41791 l_bflow_applied_to_amt := NULL; -- 5132302
41792 l_entered_amt_idx := NULL; -- 4262811
41793 l_accted_amt_idx := NULL; -- 4262811
41794 l_acc_rev_flag := NULL; -- 4262811
41795 l_accrual_line_num := NULL; -- 4262811
41796 l_tmp_amt := NULL; -- 4262811
41797 --
41798
41799 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41800 l_balance_type_code <> 'B' THEN
41801 IF NVL(p_source_97,9E125) = 13
41802 THEN
41803
41804 --
41805 XLA_AE_LINES_PKG.SetNewLine;
41806
41807 p_balance_type_code := l_balance_type_code;
41808 -- set the flag so later we will know whether the gain loss line needs to be created
41809
41810 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41811 p_actual_flag :='A';
41812 END IF;
41813
41814 --
41815 -- bulk performance
41816 --
41817 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41818 p_header_num => 0); -- 4262811
41819 --
41820 -- set accounting line options
41821 --
41822 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41823 p_natural_side_code => 'D'
41824 , p_gain_or_loss_flag => 'N'
41825 , p_gl_transfer_mode_code => 'S'
41826 , p_acct_entry_type_code => 'A'
41827 , p_switch_side_flag => 'Y'
41828 , p_merge_duplicate_code => 'N'
41829 );
41830 --
41831 l_acc_rev_natural_side_code := 'C'; -- 4262811
41832 --
41833 --
41834 -- set accounting line type info
41835 --
41836 xla_ae_lines_pkg.SetAcctLineType
41837 (p_component_type => l_component_type
41838 ,p_event_type_code => l_event_type_code
41839 ,p_line_definition_owner_code => l_line_definition_owner_code
41840 ,p_line_definition_code => l_line_definition_code
41841 ,p_accounting_line_code => l_component_code
41842 ,p_accounting_line_type_code => l_component_type_code
41843 ,p_accounting_line_appl_id => l_component_appl_id
41844 ,p_amb_context_code => l_amb_context_code
41845 ,p_entity_code => l_entity_code
41846 ,p_event_class_code => l_event_class_code);
41847 --
41848 -- set accounting class
41849 --
41850 xla_ae_lines_pkg.SetAcctClass(
41851 p_accounting_class_code => 'COST_VARIANCE'
41852 , p_ae_header_id => l_ae_header_id
41853 );
41854
41855 --
41856 -- set rounding class
41857 --
41858 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41859 'COST_VARIANCE';
41860
41861 --
41862 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41863 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41864 --
41865 -- bulk performance
41866 --
41867 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41868
41869 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41870 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41871
41872 -- 4955764
41873 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41874 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41875
41876 -- 4458381 Public Sector Enh
41877
41878 --
41879 -- set accounting attributes for the line type
41880 --
41881 l_entered_amt_idx := 17;
41882 l_accted_amt_idx := 22;
41883 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41884 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
41885 l_rec_acct_attrs.array_num_value(1) := p_source_79;
41886 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
41887 l_rec_acct_attrs.array_char_value(2) := p_source_80;
41888 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
41889 l_rec_acct_attrs.array_char_value(3) := p_source_81;
41890 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
41891 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
41892 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
41893 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
41894 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
41895 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
41896 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
41897 l_rec_acct_attrs.array_char_value(7) := p_source_85;
41898 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
41899 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
41900 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
41901 l_rec_acct_attrs.array_num_value(9) := p_source_87;
41902 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
41903 l_rec_acct_attrs.array_char_value(10) := p_source_88;
41904 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
41905 l_rec_acct_attrs.array_num_value(11) := p_source_89;
41906 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
41907 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
41908 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
41909 l_rec_acct_attrs.array_num_value(13) := p_source_87;
41910 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
41911 l_rec_acct_attrs.array_char_value(14) := p_source_88;
41912 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
41913 l_rec_acct_attrs.array_num_value(15) := p_source_89;
41914 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
41915 l_rec_acct_attrs.array_char_value(16) := p_source_100;
41916 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
41917 l_rec_acct_attrs.array_num_value(17) := p_source_91;
41918 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
41919 l_rec_acct_attrs.array_char_value(18) := p_source_88;
41920 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
41921 l_rec_acct_attrs.array_date_value(19) := p_source_92;
41922 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
41923 l_rec_acct_attrs.array_num_value(20) := p_source_93;
41924 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
41925 l_rec_acct_attrs.array_char_value(21) := p_source_94;
41926 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
41927 l_rec_acct_attrs.array_num_value(22) := p_source_95;
41928 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
41929 l_rec_acct_attrs.array_num_value(23) := p_source_104;
41930 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
41931 l_rec_acct_attrs.array_num_value(24) := p_source_104;
41932
41933 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41934 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41935
41936 ---------------------------------------------------------------------------------------------------------------
41937 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41938 ---------------------------------------------------------------------------------------------------------------
41939 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41940
41941 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41942 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41943
41944 IF xla_accounting_cache_pkg.GetValueChar
41945 (p_source_code => 'LEDGER_CATEGORY_CODE'
41946 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41947 AND l_bflow_method_code = 'PRIOR_ENTRY'
41948 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41949 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41950 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41951 )
41952 THEN
41953 xla_ae_lines_pkg.BflowUpgEntry
41954 (p_business_method_code => l_bflow_method_code
41955 ,p_business_class_code => l_bflow_class_code
41956 ,p_balance_type => l_balance_type_code);
41957 ELSE
41958 NULL;
41959 -- No business flow processing for business flow method of NONE.
41960 END IF;
41961
41962 --
41963 -- call analytical criteria
41964 --
41965
41966 --
41967 -- call description
41968 --
41969
41970 xla_ae_lines_pkg.SetLineDescription(
41971 p_ae_header_id => l_ae_header_id
41972 ,p_description => Description_1 (
41973 p_application_id => p_application_id
41974 , p_ae_header_id => l_ae_header_id
41975 , p_source_1 => p_source_1
41976 , p_source_2 => p_source_2
41977 , p_source_3 => p_source_3
41978 , p_source_4 => p_source_4
41979 , p_source_5 => p_source_5
41980 )
41981 );
41982
41983
41984 --
41985 -- call ADRs
41986 -- Bug 4922099
41987 --
41988 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41989 (NVL(l_actual_upg_option, 'N') = 'O') OR
41990 (NVL(l_enc_upg_option, 'N') = 'O')
41991 )
41992 THEN
41993 NULL;
41994 --
41995 --
41996
41997 l_ccid := AcctDerRule_6(
41998 p_application_id => p_application_id
41999 , p_ae_header_id => l_ae_header_id
42000 , p_source_11 => p_source_11
42001 , x_transaction_coa_id => l_adr_transaction_coa_id
42002 , x_accounting_coa_id => l_adr_accounting_coa_id
42003 , x_value_type_code => l_adr_value_type_code
42004 , p_side => 'NA'
42005 );
42006
42007 xla_ae_lines_pkg.set_ccid(
42008 p_code_combination_id => l_ccid
42009 , p_value_type_code => l_adr_value_type_code
42010 , p_transaction_coa_id => l_adr_transaction_coa_id
42011 , p_accounting_coa_id => l_adr_accounting_coa_id
42012 , p_adr_code => 'CST_DEFAULT'
42013 , p_adr_type_code => 'S'
42014 , p_component_type => l_component_type
42015 , p_component_code => l_component_code
42016 , p_component_type_code => l_component_type_code
42017 , p_component_appl_id => l_component_appl_id
42018 , p_amb_context_code => l_amb_context_code
42019 , p_side => 'NA'
42020 );
42021
42022
42023 --
42024 --
42025 END IF;
42026 --
42027 -- Bug 4922099
42028 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42029 (NVL(l_enc_upg_option, 'N') = 'O')
42030 ) AND
42031 (l_bflow_method_code = 'PRIOR_ENTRY')
42032 )
42033 THEN
42034 IF
42035 --
42036 1 = 2
42037 --
42038 THEN
42039 xla_accounting_err_pkg.build_message
42040 (p_appli_s_name => 'XLA'
42041 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42042 ,p_token_1 => 'LINE_NUMBER'
42043 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42044 ,p_token_2 => 'LINE_TYPE_NAME'
42045 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42046 l_component_type
42047 ,l_component_code
42048 ,l_component_type_code
42049 ,l_component_appl_id
42050 ,l_amb_context_code
42051 ,l_entity_code
42052 ,l_event_class_code
42053 )
42054 ,p_token_3 => 'OWNER'
42055 ,p_value_3 => xla_lookups_pkg.get_meaning(
42056 p_lookup_type => 'XLA_OWNER_TYPE'
42057 ,p_lookup_code => l_component_type_code
42058 )
42059 ,p_token_4 => 'PRODUCT_NAME'
42060 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42061 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42062 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42063 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42064 ,p_ae_header_id => NULL
42065 );
42066
42067 IF (C_LEVEL_ERROR>= g_log_level) THEN
42068 trace
42069 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42070 ,p_level => C_LEVEL_ERROR
42071 ,p_module => l_log_module);
42072 END IF;
42073 END IF;
42074 END IF;
42075 --
42076 --
42077 ------------------------------------------------------------------------------------------------
42078 -- 4219869 Business Flow
42079 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42080 -- Prior Entry. Currently, the following code is always generated.
42081 ------------------------------------------------------------------------------------------------
42082 XLA_AE_LINES_PKG.ValidateCurrentLine;
42083
42084 ------------------------------------------------------------------------------------
42085 -- 4219869 Business Flow
42086 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42087 ------------------------------------------------------------------------------------
42088 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42089
42090 ----------------------------------------------------------------------------------
42091 -- 4219869 Business Flow
42092 -- Update journal entry status -- Need to generate this within IF <condition>
42093 ----------------------------------------------------------------------------------
42094 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42095 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42096 ,p_balance_type_code => l_balance_type_code
42097 );
42098
42099 -------------------------------------------------------------------------------------------
42100 -- 4262811 - Generate the Accrual Reversal lines
42101 -------------------------------------------------------------------------------------------
42102 BEGIN
42103 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42104 (g_array_event(p_event_id).array_value_num('header_index'));
42105 IF l_acc_rev_flag IS NULL THEN
42106 l_acc_rev_flag := 'N';
42107 END IF;
42108 EXCEPTION
42109 WHEN OTHERS THEN
42110 l_acc_rev_flag := 'N';
42111 END;
42112 --
42113 IF (l_acc_rev_flag = 'Y') THEN
42114
42115 -- 4645092 ------------------------------------------------------------------------------
42116 -- To allow MPA report to determine if it should generate report process
42117 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42118 ------------------------------------------------------------------------------------------
42119
42120 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42121 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42122 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42123 -- call ADRs
42124 -- Bug 4922099
42125 --
42126 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42127 (NVL(l_actual_upg_option, 'N') = 'O') OR
42128 (NVL(l_enc_upg_option, 'N') = 'O')
42129 )
42130 THEN
42131 NULL;
42132 --
42133 --
42134
42135 l_ccid := AcctDerRule_6(
42136 p_application_id => p_application_id
42137 , p_ae_header_id => l_ae_header_id
42138 , p_source_11 => p_source_11
42139 , x_transaction_coa_id => l_adr_transaction_coa_id
42140 , x_accounting_coa_id => l_adr_accounting_coa_id
42141 , x_value_type_code => l_adr_value_type_code
42142 , p_side => 'NA'
42143 );
42144
42145 xla_ae_lines_pkg.set_ccid(
42146 p_code_combination_id => l_ccid
42147 , p_value_type_code => l_adr_value_type_code
42148 , p_transaction_coa_id => l_adr_transaction_coa_id
42149 , p_accounting_coa_id => l_adr_accounting_coa_id
42150 , p_adr_code => 'CST_DEFAULT'
42151 , p_adr_type_code => 'S'
42152 , p_component_type => l_component_type
42153 , p_component_code => l_component_code
42154 , p_component_type_code => l_component_type_code
42155 , p_component_appl_id => l_component_appl_id
42156 , p_amb_context_code => l_amb_context_code
42157 , p_side => 'NA'
42158 );
42159
42160
42161 --
42162 --
42163 END IF;
42164
42165 --
42166 -- Update the line information that should be overwritten
42167 --
42168 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42169 p_header_num => 1);
42170 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42171
42172 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42173
42174 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42175 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42176 END IF;
42177
42178 --
42179 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42180 --
42181 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42182 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42183 ELSE
42184 ---------------------------------------------------------------------------------------------------
42185 -- 4262811a Switch Sign
42186 ---------------------------------------------------------------------------------------------------
42187 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42188 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42189 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42190 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42191 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42192 -- 5132302
42193 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42194 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42195
42196 END IF;
42197
42198 -- 4955764
42199 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42200 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42201
42202
42203 XLA_AE_LINES_PKG.ValidateCurrentLine;
42204 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42205
42206 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42207 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42208 ,p_balance_type_code => l_balance_type_code);
42209
42210 END IF;
42211
42212 -----------------------------------------------------------------------------------------
42213 -- 4262811 Multiperiod Accounting
42214 -----------------------------------------------------------------------------------------
42215 -- No MPA option is assigned.
42216
42217
42218 END IF;
42219 END IF;
42220 --
42221
42222 --
42223 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42224 trace
42225 (p_msg => 'END of AcctLineType_99'
42226 ,p_level => C_LEVEL_PROCEDURE
42227 ,p_module => l_log_module);
42228 END IF;
42229 --
42230 EXCEPTION
42231 WHEN xla_exceptions_pkg.application_exception THEN
42232 RAISE;
42233 WHEN OTHERS THEN
42234 xla_exceptions_pkg.raise_message
42235 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_99');
42236 END AcctLineType_99;
42237 --
42238
42239 ---------------------------------------
42240 --
42241 -- PRIVATE FUNCTION
42242 -- AcctLineType_100
42243 --
42244 ---------------------------------------
42245 PROCEDURE AcctLineType_100 (
42246 p_application_id IN NUMBER
42247 ,p_event_id IN NUMBER
42248 ,p_calculate_acctd_flag IN VARCHAR2
42249 ,p_calculate_g_l_flag IN VARCHAR2
42250 ,p_actual_flag IN OUT VARCHAR2
42251 ,p_balance_type_code OUT VARCHAR2
42252 ,p_gain_or_loss_ref OUT VARCHAR2
42253
42254 --TRANSACTION_ID
42255 , p_source_1 IN NUMBER
42256 --Item Concatenated Segments
42257 , p_source_2 IN VARCHAR2
42258 --Transaction Quantity
42259 , p_source_3 IN NUMBER
42260 --Transaction Unit of Measure Code
42261 , p_source_4 IN VARCHAR2
42262 --Inventory Transaction Type Description
42263 , p_source_5 IN VARCHAR2
42264 --Cost Management Default Account
42265 , p_source_11 IN NUMBER
42266 --DISTRIBUTION_IDENTIFIER
42267 , p_source_84 IN NUMBER
42268 --Distribution Type
42269 , p_source_85 IN VARCHAR2
42270 , p_source_85_meaning IN VARCHAR2
42271 --Entered Currency Code
42272 , p_source_88 IN VARCHAR2
42273 --Entered Amount
42274 , p_source_91 IN NUMBER
42275 --Currency Conversion Date
42276 , p_source_92 IN DATE
42277 --Currency Conversion Rate
42278 , p_source_93 IN NUMBER
42279 --Currency Conversion Type
42280 , p_source_94 IN VARCHAR2
42281 --Accounted Amount
42282 , p_source_95 IN NUMBER
42283 --Accounting Line Type
42284 , p_source_97 IN NUMBER
42285 )
42286 IS
42287
42288 l_component_type VARCHAR2(80);
42289 l_component_code VARCHAR2(30);
42290 l_component_type_code VARCHAR2(1);
42291 l_component_appl_id INTEGER;
42292 l_amb_context_code VARCHAR2(30);
42293 l_entity_code VARCHAR2(30);
42294 l_event_class_code VARCHAR2(30);
42295 l_ae_header_id NUMBER;
42296 l_event_type_code VARCHAR2(30);
42297 l_line_definition_code VARCHAR2(30);
42298 l_line_definition_owner_code VARCHAR2(1);
42299 --
42300 -- adr variables
42301 l_segment VARCHAR2(30);
42302 l_ccid NUMBER;
42303 l_adr_transaction_coa_id NUMBER;
42304 l_adr_accounting_coa_id NUMBER;
42305 l_adr_flexfield_segment_code VARCHAR2(30);
42306 l_adr_flex_value_set_id NUMBER;
42307 l_adr_value_type_code VARCHAR2(30);
42308 l_adr_value_combination_id NUMBER;
42309 l_adr_value_segment_code VARCHAR2(30);
42310
42311 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42312 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42313 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42314 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42315
42316 -- 4262811 Variables ------------------------------------------------------------------------------------------
42317 l_entered_amt_idx NUMBER;
42318 l_accted_amt_idx NUMBER;
42319 l_acc_rev_flag VARCHAR2(1);
42320 l_accrual_line_num NUMBER;
42321 l_tmp_amt NUMBER;
42322 l_acc_rev_natural_side_code VARCHAR2(1);
42323
42324 l_num_entries NUMBER;
42325 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42326 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42327 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42328 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42329 l_recog_line_1 NUMBER;
42330 l_recog_line_2 NUMBER;
42331
42332 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42333 l_bflow_applied_to_amt NUMBER; -- 5132302
42334 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42335
42336 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42337
42338 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42339 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42340
42341 ---------------------------------------------------------------------------------------------------------------
42342
42343
42344 --
42345 -- bulk performance
42346 --
42347 l_balance_type_code VARCHAR2(1);
42348 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42349 l_log_module VARCHAR2(240);
42350
42351 --
42352 -- Upgrade strategy
42353 --
42354 l_actual_upg_option VARCHAR2(1);
42355 l_enc_upg_option VARCHAR2(1);
42356
42357 --
42358 BEGIN
42359 --
42360 IF g_log_enabled THEN
42361 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_100';
42362 END IF;
42363 --
42364 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42365
42366 trace
42367 (p_msg => 'BEGIN of AcctLineType_100'
42368 ,p_level => C_LEVEL_PROCEDURE
42369 ,p_module => l_log_module);
42370
42371 END IF;
42372 --
42373 l_component_type := 'AMB_JLT';
42374 l_component_code := 'COST_VARIANCE';
42375 l_component_type_code := 'S';
42376 l_component_appl_id := 707;
42377 l_amb_context_code := 'DEFAULT';
42378 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
42379 l_event_class_code := 'MISC_ISSUE_RCPT';
42380 l_event_type_code := 'MISC_ISSUE_RCPT_ALL';
42381 l_line_definition_owner_code := 'S';
42382 l_line_definition_code := 'PI_MISC_ISSUE_RCPT';
42383 --
42384 l_balance_type_code := 'A';
42385 l_segment := NULL;
42386 l_ccid := NULL;
42387 l_adr_transaction_coa_id := NULL;
42388 l_adr_accounting_coa_id := NULL;
42389 l_adr_flexfield_segment_code := NULL;
42390 l_adr_flex_value_set_id := NULL;
42391 l_adr_value_type_code := NULL;
42392 l_adr_value_combination_id := NULL;
42393 l_adr_value_segment_code := NULL;
42394
42395 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42396 l_bflow_class_code := ''; -- 4219869 Business Flow
42397 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42398 l_budgetary_control_flag := 'N';
42399
42400 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42401 l_bflow_applied_to_amt := NULL; -- 5132302
42402 l_entered_amt_idx := NULL; -- 4262811
42403 l_accted_amt_idx := NULL; -- 4262811
42404 l_acc_rev_flag := NULL; -- 4262811
42405 l_accrual_line_num := NULL; -- 4262811
42406 l_tmp_amt := NULL; -- 4262811
42407 --
42408
42409 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42410 l_balance_type_code <> 'B' THEN
42411 IF NVL(p_source_97,9E125) = 13
42412 THEN
42413
42414 --
42415 XLA_AE_LINES_PKG.SetNewLine;
42416
42417 p_balance_type_code := l_balance_type_code;
42418 -- set the flag so later we will know whether the gain loss line needs to be created
42419
42420 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42421 p_actual_flag :='A';
42422 END IF;
42423
42424 --
42425 -- bulk performance
42426 --
42427 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42428 p_header_num => 0); -- 4262811
42429 --
42430 -- set accounting line options
42431 --
42432 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42433 p_natural_side_code => 'D'
42434 , p_gain_or_loss_flag => 'N'
42435 , p_gl_transfer_mode_code => 'S'
42436 , p_acct_entry_type_code => 'A'
42437 , p_switch_side_flag => 'Y'
42438 , p_merge_duplicate_code => 'N'
42439 );
42440 --
42441 l_acc_rev_natural_side_code := 'C'; -- 4262811
42442 --
42443 --
42444 -- set accounting line type info
42445 --
42446 xla_ae_lines_pkg.SetAcctLineType
42447 (p_component_type => l_component_type
42448 ,p_event_type_code => l_event_type_code
42449 ,p_line_definition_owner_code => l_line_definition_owner_code
42450 ,p_line_definition_code => l_line_definition_code
42451 ,p_accounting_line_code => l_component_code
42452 ,p_accounting_line_type_code => l_component_type_code
42453 ,p_accounting_line_appl_id => l_component_appl_id
42454 ,p_amb_context_code => l_amb_context_code
42455 ,p_entity_code => l_entity_code
42456 ,p_event_class_code => l_event_class_code);
42457 --
42458 -- set accounting class
42459 --
42460 xla_ae_lines_pkg.SetAcctClass(
42461 p_accounting_class_code => 'COST_VARIANCE'
42462 , p_ae_header_id => l_ae_header_id
42463 );
42464
42465 --
42466 -- set rounding class
42467 --
42468 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42469 'COST_VARIANCE';
42470
42471 --
42472 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42473 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42474 --
42475 -- bulk performance
42476 --
42477 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42478
42479 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42480 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42481
42482 -- 4955764
42483 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42484 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42485
42486 -- 4458381 Public Sector Enh
42487
42488 --
42489 -- set accounting attributes for the line type
42490 --
42491 l_entered_amt_idx := 3;
42492 l_accted_amt_idx := 8;
42493 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42494 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
42495 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
42496 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
42497 l_rec_acct_attrs.array_char_value(2) := p_source_85;
42498 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
42499 l_rec_acct_attrs.array_num_value(3) := p_source_91;
42500 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
42501 l_rec_acct_attrs.array_char_value(4) := p_source_88;
42502 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
42503 l_rec_acct_attrs.array_date_value(5) := p_source_92;
42504 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
42505 l_rec_acct_attrs.array_num_value(6) := p_source_93;
42506 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
42507 l_rec_acct_attrs.array_char_value(7) := p_source_94;
42508 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
42509 l_rec_acct_attrs.array_num_value(8) := p_source_95;
42510
42511 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42512 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42513
42514 ---------------------------------------------------------------------------------------------------------------
42515 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42516 ---------------------------------------------------------------------------------------------------------------
42517 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42518
42519 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42520 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42521
42522 IF xla_accounting_cache_pkg.GetValueChar
42523 (p_source_code => 'LEDGER_CATEGORY_CODE'
42524 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42525 AND l_bflow_method_code = 'PRIOR_ENTRY'
42526 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42527 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42528 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42529 )
42530 THEN
42531 xla_ae_lines_pkg.BflowUpgEntry
42532 (p_business_method_code => l_bflow_method_code
42533 ,p_business_class_code => l_bflow_class_code
42534 ,p_balance_type => l_balance_type_code);
42535 ELSE
42536 NULL;
42537 -- No business flow processing for business flow method of NONE.
42538 END IF;
42539
42540 --
42541 -- call analytical criteria
42542 --
42543
42544 --
42545 -- call description
42546 --
42547
42548 xla_ae_lines_pkg.SetLineDescription(
42549 p_ae_header_id => l_ae_header_id
42550 ,p_description => Description_1 (
42551 p_application_id => p_application_id
42552 , p_ae_header_id => l_ae_header_id
42553 , p_source_1 => p_source_1
42554 , p_source_2 => p_source_2
42555 , p_source_3 => p_source_3
42556 , p_source_4 => p_source_4
42557 , p_source_5 => p_source_5
42558 )
42559 );
42560
42561
42562 --
42563 -- call ADRs
42564 -- Bug 4922099
42565 --
42566 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42567 (NVL(l_actual_upg_option, 'N') = 'O') OR
42568 (NVL(l_enc_upg_option, 'N') = 'O')
42569 )
42570 THEN
42571 NULL;
42572 --
42573 --
42574
42575 l_ccid := AcctDerRule_6(
42576 p_application_id => p_application_id
42577 , p_ae_header_id => l_ae_header_id
42578 , p_source_11 => p_source_11
42579 , x_transaction_coa_id => l_adr_transaction_coa_id
42580 , x_accounting_coa_id => l_adr_accounting_coa_id
42581 , x_value_type_code => l_adr_value_type_code
42582 , p_side => 'NA'
42583 );
42584
42585 xla_ae_lines_pkg.set_ccid(
42586 p_code_combination_id => l_ccid
42587 , p_value_type_code => l_adr_value_type_code
42588 , p_transaction_coa_id => l_adr_transaction_coa_id
42589 , p_accounting_coa_id => l_adr_accounting_coa_id
42590 , p_adr_code => 'CST_DEFAULT'
42591 , p_adr_type_code => 'S'
42592 , p_component_type => l_component_type
42593 , p_component_code => l_component_code
42594 , p_component_type_code => l_component_type_code
42595 , p_component_appl_id => l_component_appl_id
42596 , p_amb_context_code => l_amb_context_code
42597 , p_side => 'NA'
42598 );
42599
42600
42601 --
42602 --
42603 END IF;
42604 --
42605 -- Bug 4922099
42606 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42607 (NVL(l_enc_upg_option, 'N') = 'O')
42608 ) AND
42609 (l_bflow_method_code = 'PRIOR_ENTRY')
42610 )
42611 THEN
42612 IF
42613 --
42614 1 = 2
42615 --
42616 THEN
42617 xla_accounting_err_pkg.build_message
42618 (p_appli_s_name => 'XLA'
42619 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42620 ,p_token_1 => 'LINE_NUMBER'
42621 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42622 ,p_token_2 => 'LINE_TYPE_NAME'
42623 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42624 l_component_type
42625 ,l_component_code
42626 ,l_component_type_code
42627 ,l_component_appl_id
42628 ,l_amb_context_code
42629 ,l_entity_code
42630 ,l_event_class_code
42631 )
42632 ,p_token_3 => 'OWNER'
42633 ,p_value_3 => xla_lookups_pkg.get_meaning(
42634 p_lookup_type => 'XLA_OWNER_TYPE'
42635 ,p_lookup_code => l_component_type_code
42636 )
42637 ,p_token_4 => 'PRODUCT_NAME'
42638 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42639 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42640 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42641 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42642 ,p_ae_header_id => NULL
42643 );
42644
42645 IF (C_LEVEL_ERROR>= g_log_level) THEN
42646 trace
42647 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42648 ,p_level => C_LEVEL_ERROR
42649 ,p_module => l_log_module);
42650 END IF;
42651 END IF;
42652 END IF;
42653 --
42654 --
42655 ------------------------------------------------------------------------------------------------
42656 -- 4219869 Business Flow
42657 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42658 -- Prior Entry. Currently, the following code is always generated.
42659 ------------------------------------------------------------------------------------------------
42660 XLA_AE_LINES_PKG.ValidateCurrentLine;
42661
42662 ------------------------------------------------------------------------------------
42663 -- 4219869 Business Flow
42664 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42665 ------------------------------------------------------------------------------------
42666 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42667
42668 ----------------------------------------------------------------------------------
42669 -- 4219869 Business Flow
42670 -- Update journal entry status -- Need to generate this within IF <condition>
42671 ----------------------------------------------------------------------------------
42672 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42673 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42674 ,p_balance_type_code => l_balance_type_code
42675 );
42676
42677 -------------------------------------------------------------------------------------------
42678 -- 4262811 - Generate the Accrual Reversal lines
42679 -------------------------------------------------------------------------------------------
42680 BEGIN
42681 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42682 (g_array_event(p_event_id).array_value_num('header_index'));
42683 IF l_acc_rev_flag IS NULL THEN
42684 l_acc_rev_flag := 'N';
42685 END IF;
42686 EXCEPTION
42687 WHEN OTHERS THEN
42688 l_acc_rev_flag := 'N';
42689 END;
42690 --
42691 IF (l_acc_rev_flag = 'Y') THEN
42692
42693 -- 4645092 ------------------------------------------------------------------------------
42694 -- To allow MPA report to determine if it should generate report process
42695 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42696 ------------------------------------------------------------------------------------------
42697
42698 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42699 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42700 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42701 -- call ADRs
42702 -- Bug 4922099
42703 --
42704 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42705 (NVL(l_actual_upg_option, 'N') = 'O') OR
42706 (NVL(l_enc_upg_option, 'N') = 'O')
42707 )
42708 THEN
42709 NULL;
42710 --
42711 --
42712
42713 l_ccid := AcctDerRule_6(
42714 p_application_id => p_application_id
42715 , p_ae_header_id => l_ae_header_id
42716 , p_source_11 => p_source_11
42717 , x_transaction_coa_id => l_adr_transaction_coa_id
42718 , x_accounting_coa_id => l_adr_accounting_coa_id
42719 , x_value_type_code => l_adr_value_type_code
42720 , p_side => 'NA'
42721 );
42722
42723 xla_ae_lines_pkg.set_ccid(
42724 p_code_combination_id => l_ccid
42725 , p_value_type_code => l_adr_value_type_code
42726 , p_transaction_coa_id => l_adr_transaction_coa_id
42727 , p_accounting_coa_id => l_adr_accounting_coa_id
42728 , p_adr_code => 'CST_DEFAULT'
42729 , p_adr_type_code => 'S'
42730 , p_component_type => l_component_type
42731 , p_component_code => l_component_code
42732 , p_component_type_code => l_component_type_code
42733 , p_component_appl_id => l_component_appl_id
42734 , p_amb_context_code => l_amb_context_code
42735 , p_side => 'NA'
42736 );
42737
42738
42739 --
42740 --
42741 END IF;
42742
42743 --
42744 -- Update the line information that should be overwritten
42745 --
42746 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42747 p_header_num => 1);
42748 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42749
42750 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42751
42752 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42753 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42754 END IF;
42755
42756 --
42757 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42758 --
42759 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42760 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42761 ELSE
42762 ---------------------------------------------------------------------------------------------------
42763 -- 4262811a Switch Sign
42764 ---------------------------------------------------------------------------------------------------
42765 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42766 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42767 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42768 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42769 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42770 -- 5132302
42771 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42772 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42773
42774 END IF;
42775
42776 -- 4955764
42777 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42778 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42779
42780
42781 XLA_AE_LINES_PKG.ValidateCurrentLine;
42782 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42783
42784 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42785 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42786 ,p_balance_type_code => l_balance_type_code);
42787
42788 END IF;
42789
42790 -----------------------------------------------------------------------------------------
42791 -- 4262811 Multiperiod Accounting
42792 -----------------------------------------------------------------------------------------
42793 -- No MPA option is assigned.
42794
42795
42796 END IF;
42797 END IF;
42798 --
42799
42800 --
42801 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42802 trace
42803 (p_msg => 'END of AcctLineType_100'
42804 ,p_level => C_LEVEL_PROCEDURE
42805 ,p_module => l_log_module);
42806 END IF;
42807 --
42808 EXCEPTION
42809 WHEN xla_exceptions_pkg.application_exception THEN
42810 RAISE;
42811 WHEN OTHERS THEN
42812 xla_exceptions_pkg.raise_message
42813 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_100');
42814 END AcctLineType_100;
42815 --
42816
42817 ---------------------------------------
42818 --
42819 -- PRIVATE FUNCTION
42820 -- AcctLineType_101
42821 --
42822 ---------------------------------------
42823 PROCEDURE AcctLineType_101 (
42824 p_application_id IN NUMBER
42825 ,p_event_id IN NUMBER
42826 ,p_calculate_acctd_flag IN VARCHAR2
42827 ,p_calculate_g_l_flag IN VARCHAR2
42828 ,p_actual_flag IN OUT VARCHAR2
42829 ,p_balance_type_code OUT VARCHAR2
42830 ,p_gain_or_loss_ref OUT VARCHAR2
42831
42832 --TRANSACTION_ID
42833 , p_source_1 IN NUMBER
42834 --Item Concatenated Segments
42835 , p_source_2 IN VARCHAR2
42836 --Transaction Quantity
42837 , p_source_3 IN NUMBER
42838 --Transaction Unit of Measure Code
42839 , p_source_4 IN VARCHAR2
42840 --Inventory Transaction Type Description
42841 , p_source_5 IN VARCHAR2
42842 --Cost Management Default Account
42843 , p_source_11 IN NUMBER
42844 --Applied to Application ID
42845 , p_source_79 IN NUMBER
42846 --Applied to Distribution Link Type
42847 , p_source_80 IN VARCHAR2
42848 --Applied to Entity Code
42849 , p_source_81 IN VARCHAR2
42850 --Applied To Purchase Document Identifier
42851 , p_source_83 IN NUMBER
42852 --DISTRIBUTION_IDENTIFIER
42853 , p_source_84 IN NUMBER
42854 --Distribution Type
42855 , p_source_85 IN VARCHAR2
42856 , p_source_85_meaning IN VARCHAR2
42857 --PO Budget Account
42858 , p_source_86 IN NUMBER
42859 --Encumbrance Reversal Amount Entered
42860 , p_source_87 IN NUMBER
42861 --Entered Currency Code
42862 , p_source_88 IN VARCHAR2
42863 --Transaction Encumbrance Reversal Amount
42864 , p_source_89 IN NUMBER
42865 --Entered Amount
42866 , p_source_91 IN NUMBER
42867 --Currency Conversion Date
42868 , p_source_92 IN DATE
42869 --Currency Conversion Rate
42870 , p_source_93 IN NUMBER
42871 --Currency Conversion Type
42872 , p_source_94 IN VARCHAR2
42873 --Accounted Amount
42874 , p_source_95 IN NUMBER
42875 --Purchasing Encumbrance Type Identifier
42876 , p_source_96 IN NUMBER
42877 --Accounting Line Type
42878 , p_source_97 IN NUMBER
42879 --Costing Encumbrance Upgrade Option
42880 , p_source_100 IN VARCHAR2
42881 --TXN_PO_DISTRIBUTION_ID
42882 , p_source_101 IN NUMBER
42883 )
42884 IS
42885
42886 l_component_type VARCHAR2(80);
42887 l_component_code VARCHAR2(30);
42888 l_component_type_code VARCHAR2(1);
42889 l_component_appl_id INTEGER;
42890 l_amb_context_code VARCHAR2(30);
42891 l_entity_code VARCHAR2(30);
42892 l_event_class_code VARCHAR2(30);
42893 l_ae_header_id NUMBER;
42894 l_event_type_code VARCHAR2(30);
42895 l_line_definition_code VARCHAR2(30);
42896 l_line_definition_owner_code VARCHAR2(1);
42897 --
42898 -- adr variables
42899 l_segment VARCHAR2(30);
42900 l_ccid NUMBER;
42901 l_adr_transaction_coa_id NUMBER;
42902 l_adr_accounting_coa_id NUMBER;
42903 l_adr_flexfield_segment_code VARCHAR2(30);
42904 l_adr_flex_value_set_id NUMBER;
42905 l_adr_value_type_code VARCHAR2(30);
42906 l_adr_value_combination_id NUMBER;
42907 l_adr_value_segment_code VARCHAR2(30);
42908
42909 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42910 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42911 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42912 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42913
42914 -- 4262811 Variables ------------------------------------------------------------------------------------------
42915 l_entered_amt_idx NUMBER;
42916 l_accted_amt_idx NUMBER;
42917 l_acc_rev_flag VARCHAR2(1);
42918 l_accrual_line_num NUMBER;
42919 l_tmp_amt NUMBER;
42920 l_acc_rev_natural_side_code VARCHAR2(1);
42921
42922 l_num_entries NUMBER;
42923 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42924 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42925 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42926 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42927 l_recog_line_1 NUMBER;
42928 l_recog_line_2 NUMBER;
42929
42930 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42931 l_bflow_applied_to_amt NUMBER; -- 5132302
42932 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42933
42934 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42935
42936 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42937 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42938
42939 ---------------------------------------------------------------------------------------------------------------
42940
42941
42942 --
42943 -- bulk performance
42944 --
42945 l_balance_type_code VARCHAR2(1);
42946 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42947 l_log_module VARCHAR2(240);
42948
42949 --
42950 -- Upgrade strategy
42951 --
42952 l_actual_upg_option VARCHAR2(1);
42953 l_enc_upg_option VARCHAR2(1);
42954
42955 --
42956 BEGIN
42957 --
42958 IF g_log_enabled THEN
42959 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_101';
42960 END IF;
42961 --
42962 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42963
42964 trace
42965 (p_msg => 'BEGIN of AcctLineType_101'
42966 ,p_level => C_LEVEL_PROCEDURE
42967 ,p_module => l_log_module);
42968
42969 END IF;
42970 --
42971 l_component_type := 'AMB_JLT';
42972 l_component_code := 'COST_VARIANCE';
42973 l_component_type_code := 'S';
42974 l_component_appl_id := 707;
42975 l_amb_context_code := 'DEFAULT';
42976 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
42977 l_event_class_code := 'PURCHASE_ORDER';
42978 l_event_type_code := 'PO_DEL_INV';
42979 l_line_definition_owner_code := 'S';
42980 l_line_definition_code := 'PI_PO_DEL_INV';
42981 --
42982 l_balance_type_code := 'A';
42983 l_segment := NULL;
42984 l_ccid := NULL;
42985 l_adr_transaction_coa_id := NULL;
42986 l_adr_accounting_coa_id := NULL;
42987 l_adr_flexfield_segment_code := NULL;
42988 l_adr_flex_value_set_id := NULL;
42989 l_adr_value_type_code := NULL;
42990 l_adr_value_combination_id := NULL;
42991 l_adr_value_segment_code := NULL;
42992
42993 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42994 l_bflow_class_code := ''; -- 4219869 Business Flow
42995 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42996 l_budgetary_control_flag := 'N';
42997
42998 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42999 l_bflow_applied_to_amt := NULL; -- 5132302
43000 l_entered_amt_idx := NULL; -- 4262811
43001 l_accted_amt_idx := NULL; -- 4262811
43002 l_acc_rev_flag := NULL; -- 4262811
43003 l_accrual_line_num := NULL; -- 4262811
43004 l_tmp_amt := NULL; -- 4262811
43005 --
43006
43007 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43008 l_balance_type_code <> 'B' THEN
43009 IF NVL(p_source_97,9E125) = 13
43010 THEN
43011
43012 --
43013 XLA_AE_LINES_PKG.SetNewLine;
43014
43015 p_balance_type_code := l_balance_type_code;
43016 -- set the flag so later we will know whether the gain loss line needs to be created
43017
43018 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43019 p_actual_flag :='A';
43020 END IF;
43021
43022 --
43023 -- bulk performance
43024 --
43025 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43026 p_header_num => 0); -- 4262811
43027 --
43028 -- set accounting line options
43029 --
43030 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43031 p_natural_side_code => 'D'
43032 , p_gain_or_loss_flag => 'N'
43033 , p_gl_transfer_mode_code => 'S'
43034 , p_acct_entry_type_code => 'A'
43035 , p_switch_side_flag => 'Y'
43036 , p_merge_duplicate_code => 'N'
43037 );
43038 --
43039 l_acc_rev_natural_side_code := 'C'; -- 4262811
43040 --
43041 --
43042 -- set accounting line type info
43043 --
43044 xla_ae_lines_pkg.SetAcctLineType
43045 (p_component_type => l_component_type
43046 ,p_event_type_code => l_event_type_code
43047 ,p_line_definition_owner_code => l_line_definition_owner_code
43048 ,p_line_definition_code => l_line_definition_code
43049 ,p_accounting_line_code => l_component_code
43050 ,p_accounting_line_type_code => l_component_type_code
43051 ,p_accounting_line_appl_id => l_component_appl_id
43052 ,p_amb_context_code => l_amb_context_code
43053 ,p_entity_code => l_entity_code
43054 ,p_event_class_code => l_event_class_code);
43055 --
43056 -- set accounting class
43057 --
43058 xla_ae_lines_pkg.SetAcctClass(
43059 p_accounting_class_code => 'COST_VARIANCE'
43060 , p_ae_header_id => l_ae_header_id
43061 );
43062
43063 --
43064 -- set rounding class
43065 --
43066 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43067 'COST_VARIANCE';
43068
43069 --
43070 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43071 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43072 --
43073 -- bulk performance
43074 --
43075 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43076
43077 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43078 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43079
43080 -- 4955764
43081 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43082 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43083
43084 -- 4458381 Public Sector Enh
43085
43086 --
43087 -- set accounting attributes for the line type
43088 --
43089 l_entered_amt_idx := 17;
43090 l_accted_amt_idx := 22;
43091 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43092 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
43093 l_rec_acct_attrs.array_num_value(1) := p_source_79;
43094 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
43095 l_rec_acct_attrs.array_char_value(2) := p_source_80;
43096 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
43097 l_rec_acct_attrs.array_char_value(3) := p_source_81;
43098 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
43099 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
43100 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
43101 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
43102 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
43103 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
43104 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
43105 l_rec_acct_attrs.array_char_value(7) := p_source_85;
43106 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
43107 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
43108 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
43109 l_rec_acct_attrs.array_num_value(9) := p_source_87;
43110 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
43111 l_rec_acct_attrs.array_char_value(10) := p_source_88;
43112 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
43113 l_rec_acct_attrs.array_num_value(11) := p_source_89;
43114 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
43115 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
43116 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
43117 l_rec_acct_attrs.array_num_value(13) := p_source_87;
43118 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
43119 l_rec_acct_attrs.array_char_value(14) := p_source_88;
43120 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
43121 l_rec_acct_attrs.array_num_value(15) := p_source_89;
43122 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
43123 l_rec_acct_attrs.array_char_value(16) := p_source_100;
43124 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
43125 l_rec_acct_attrs.array_num_value(17) := p_source_91;
43126 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
43127 l_rec_acct_attrs.array_char_value(18) := p_source_88;
43128 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
43129 l_rec_acct_attrs.array_date_value(19) := p_source_92;
43130 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
43131 l_rec_acct_attrs.array_num_value(20) := p_source_93;
43132 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
43133 l_rec_acct_attrs.array_char_value(21) := p_source_94;
43134 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
43135 l_rec_acct_attrs.array_num_value(22) := p_source_95;
43136 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
43137 l_rec_acct_attrs.array_num_value(23) := p_source_96;
43138 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
43139 l_rec_acct_attrs.array_num_value(24) := p_source_96;
43140
43141 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43142 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43143
43144 ---------------------------------------------------------------------------------------------------------------
43145 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43146 ---------------------------------------------------------------------------------------------------------------
43147 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43148
43149 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43150 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43151
43152 IF xla_accounting_cache_pkg.GetValueChar
43153 (p_source_code => 'LEDGER_CATEGORY_CODE'
43154 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43155 AND l_bflow_method_code = 'PRIOR_ENTRY'
43156 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43157 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43158 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43159 )
43160 THEN
43161 xla_ae_lines_pkg.BflowUpgEntry
43162 (p_business_method_code => l_bflow_method_code
43163 ,p_business_class_code => l_bflow_class_code
43164 ,p_balance_type => l_balance_type_code);
43165 ELSE
43166 NULL;
43167 -- No business flow processing for business flow method of NONE.
43168 END IF;
43169
43170 --
43171 -- call analytical criteria
43172 --
43173
43174 --
43175 -- call description
43176 --
43177
43178 xla_ae_lines_pkg.SetLineDescription(
43179 p_ae_header_id => l_ae_header_id
43180 ,p_description => Description_1 (
43181 p_application_id => p_application_id
43182 , p_ae_header_id => l_ae_header_id
43183 , p_source_1 => p_source_1
43184 , p_source_2 => p_source_2
43185 , p_source_3 => p_source_3
43186 , p_source_4 => p_source_4
43187 , p_source_5 => p_source_5
43188 )
43189 );
43190
43191
43192 --
43193 -- call ADRs
43194 -- Bug 4922099
43195 --
43196 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43197 (NVL(l_actual_upg_option, 'N') = 'O') OR
43198 (NVL(l_enc_upg_option, 'N') = 'O')
43199 )
43200 THEN
43201 NULL;
43202 --
43203 --
43204
43205 l_ccid := AcctDerRule_6(
43206 p_application_id => p_application_id
43207 , p_ae_header_id => l_ae_header_id
43208 , p_source_11 => p_source_11
43209 , x_transaction_coa_id => l_adr_transaction_coa_id
43210 , x_accounting_coa_id => l_adr_accounting_coa_id
43211 , x_value_type_code => l_adr_value_type_code
43212 , p_side => 'NA'
43213 );
43214
43215 xla_ae_lines_pkg.set_ccid(
43216 p_code_combination_id => l_ccid
43217 , p_value_type_code => l_adr_value_type_code
43218 , p_transaction_coa_id => l_adr_transaction_coa_id
43219 , p_accounting_coa_id => l_adr_accounting_coa_id
43220 , p_adr_code => 'CST_DEFAULT'
43221 , p_adr_type_code => 'S'
43222 , p_component_type => l_component_type
43223 , p_component_code => l_component_code
43224 , p_component_type_code => l_component_type_code
43225 , p_component_appl_id => l_component_appl_id
43226 , p_amb_context_code => l_amb_context_code
43227 , p_side => 'NA'
43228 );
43229
43230
43231 --
43232 --
43233 END IF;
43234 --
43235 -- Bug 4922099
43236 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43237 (NVL(l_enc_upg_option, 'N') = 'O')
43238 ) AND
43239 (l_bflow_method_code = 'PRIOR_ENTRY')
43240 )
43241 THEN
43242 IF
43243 --
43244 1 = 2
43245 --
43246 THEN
43247 xla_accounting_err_pkg.build_message
43248 (p_appli_s_name => 'XLA'
43249 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43250 ,p_token_1 => 'LINE_NUMBER'
43251 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43252 ,p_token_2 => 'LINE_TYPE_NAME'
43253 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43254 l_component_type
43255 ,l_component_code
43256 ,l_component_type_code
43257 ,l_component_appl_id
43258 ,l_amb_context_code
43259 ,l_entity_code
43260 ,l_event_class_code
43261 )
43262 ,p_token_3 => 'OWNER'
43263 ,p_value_3 => xla_lookups_pkg.get_meaning(
43264 p_lookup_type => 'XLA_OWNER_TYPE'
43265 ,p_lookup_code => l_component_type_code
43266 )
43267 ,p_token_4 => 'PRODUCT_NAME'
43268 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43269 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43270 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43271 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43272 ,p_ae_header_id => NULL
43273 );
43274
43275 IF (C_LEVEL_ERROR>= g_log_level) THEN
43276 trace
43277 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43278 ,p_level => C_LEVEL_ERROR
43279 ,p_module => l_log_module);
43280 END IF;
43281 END IF;
43282 END IF;
43283 --
43284 --
43285 ------------------------------------------------------------------------------------------------
43286 -- 4219869 Business Flow
43287 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43288 -- Prior Entry. Currently, the following code is always generated.
43289 ------------------------------------------------------------------------------------------------
43290 XLA_AE_LINES_PKG.ValidateCurrentLine;
43291
43292 ------------------------------------------------------------------------------------
43293 -- 4219869 Business Flow
43294 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43295 ------------------------------------------------------------------------------------
43296 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43297
43298 ----------------------------------------------------------------------------------
43299 -- 4219869 Business Flow
43300 -- Update journal entry status -- Need to generate this within IF <condition>
43301 ----------------------------------------------------------------------------------
43302 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43303 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43304 ,p_balance_type_code => l_balance_type_code
43305 );
43306
43307 -------------------------------------------------------------------------------------------
43308 -- 4262811 - Generate the Accrual Reversal lines
43309 -------------------------------------------------------------------------------------------
43310 BEGIN
43311 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43312 (g_array_event(p_event_id).array_value_num('header_index'));
43313 IF l_acc_rev_flag IS NULL THEN
43314 l_acc_rev_flag := 'N';
43315 END IF;
43316 EXCEPTION
43317 WHEN OTHERS THEN
43318 l_acc_rev_flag := 'N';
43319 END;
43320 --
43321 IF (l_acc_rev_flag = 'Y') THEN
43322
43323 -- 4645092 ------------------------------------------------------------------------------
43324 -- To allow MPA report to determine if it should generate report process
43325 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43326 ------------------------------------------------------------------------------------------
43327
43328 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43329 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43330 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43331 -- call ADRs
43332 -- Bug 4922099
43333 --
43334 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43335 (NVL(l_actual_upg_option, 'N') = 'O') OR
43336 (NVL(l_enc_upg_option, 'N') = 'O')
43337 )
43338 THEN
43339 NULL;
43340 --
43341 --
43342
43343 l_ccid := AcctDerRule_6(
43344 p_application_id => p_application_id
43345 , p_ae_header_id => l_ae_header_id
43346 , p_source_11 => p_source_11
43347 , x_transaction_coa_id => l_adr_transaction_coa_id
43348 , x_accounting_coa_id => l_adr_accounting_coa_id
43349 , x_value_type_code => l_adr_value_type_code
43350 , p_side => 'NA'
43351 );
43352
43353 xla_ae_lines_pkg.set_ccid(
43354 p_code_combination_id => l_ccid
43355 , p_value_type_code => l_adr_value_type_code
43356 , p_transaction_coa_id => l_adr_transaction_coa_id
43357 , p_accounting_coa_id => l_adr_accounting_coa_id
43358 , p_adr_code => 'CST_DEFAULT'
43359 , p_adr_type_code => 'S'
43360 , p_component_type => l_component_type
43361 , p_component_code => l_component_code
43362 , p_component_type_code => l_component_type_code
43363 , p_component_appl_id => l_component_appl_id
43364 , p_amb_context_code => l_amb_context_code
43365 , p_side => 'NA'
43366 );
43367
43368
43369 --
43370 --
43371 END IF;
43372
43373 --
43374 -- Update the line information that should be overwritten
43375 --
43376 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43377 p_header_num => 1);
43378 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43379
43380 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43381
43382 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43383 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43384 END IF;
43385
43386 --
43387 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43388 --
43389 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43390 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43391 ELSE
43392 ---------------------------------------------------------------------------------------------------
43393 -- 4262811a Switch Sign
43394 ---------------------------------------------------------------------------------------------------
43395 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43396 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43397 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43398 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43399 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43400 -- 5132302
43401 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43402 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43403
43404 END IF;
43405
43406 -- 4955764
43407 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43408 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43409
43410
43411 XLA_AE_LINES_PKG.ValidateCurrentLine;
43412 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43413
43414 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43415 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43416 ,p_balance_type_code => l_balance_type_code);
43417
43418 END IF;
43419
43420 -----------------------------------------------------------------------------------------
43421 -- 4262811 Multiperiod Accounting
43422 -----------------------------------------------------------------------------------------
43423 -- No MPA option is assigned.
43424
43425
43426 END IF;
43427 END IF;
43428 --
43429
43430 --
43431 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43432 trace
43433 (p_msg => 'END of AcctLineType_101'
43434 ,p_level => C_LEVEL_PROCEDURE
43435 ,p_module => l_log_module);
43436 END IF;
43437 --
43438 EXCEPTION
43439 WHEN xla_exceptions_pkg.application_exception THEN
43440 RAISE;
43441 WHEN OTHERS THEN
43442 xla_exceptions_pkg.raise_message
43443 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_101');
43444 END AcctLineType_101;
43445 --
43446
43447 ---------------------------------------
43448 --
43449 -- PRIVATE FUNCTION
43450 -- AcctLineType_102
43451 --
43452 ---------------------------------------
43453 PROCEDURE AcctLineType_102 (
43454 p_application_id IN NUMBER
43455 ,p_event_id IN NUMBER
43456 ,p_calculate_acctd_flag IN VARCHAR2
43457 ,p_calculate_g_l_flag IN VARCHAR2
43458 ,p_actual_flag IN OUT VARCHAR2
43459 ,p_balance_type_code OUT VARCHAR2
43460 ,p_gain_or_loss_ref OUT VARCHAR2
43461
43462 --TRANSACTION_ID
43463 , p_source_1 IN NUMBER
43464 --Item Concatenated Segments
43465 , p_source_2 IN VARCHAR2
43466 --Transaction Quantity
43467 , p_source_3 IN NUMBER
43468 --Transaction Unit of Measure Code
43469 , p_source_4 IN VARCHAR2
43470 --Inventory Transaction Type Description
43471 , p_source_5 IN VARCHAR2
43472 --Cost Management Default Account
43473 , p_source_11 IN NUMBER
43474 --DISTRIBUTION_IDENTIFIER
43475 , p_source_84 IN NUMBER
43476 --Distribution Type
43477 , p_source_85 IN VARCHAR2
43478 , p_source_85_meaning IN VARCHAR2
43479 --Entered Currency Code
43480 , p_source_88 IN VARCHAR2
43481 --Entered Amount
43482 , p_source_91 IN NUMBER
43483 --Currency Conversion Date
43484 , p_source_92 IN DATE
43485 --Currency Conversion Rate
43486 , p_source_93 IN NUMBER
43487 --Currency Conversion Type
43488 , p_source_94 IN VARCHAR2
43489 --Accounted Amount
43490 , p_source_95 IN NUMBER
43491 --Accounting Line Type
43492 , p_source_97 IN NUMBER
43493 )
43494 IS
43495
43496 l_component_type VARCHAR2(80);
43497 l_component_code VARCHAR2(30);
43498 l_component_type_code VARCHAR2(1);
43499 l_component_appl_id INTEGER;
43500 l_amb_context_code VARCHAR2(30);
43501 l_entity_code VARCHAR2(30);
43502 l_event_class_code VARCHAR2(30);
43503 l_ae_header_id NUMBER;
43504 l_event_type_code VARCHAR2(30);
43505 l_line_definition_code VARCHAR2(30);
43506 l_line_definition_owner_code VARCHAR2(1);
43507 --
43508 -- adr variables
43509 l_segment VARCHAR2(30);
43510 l_ccid NUMBER;
43511 l_adr_transaction_coa_id NUMBER;
43512 l_adr_accounting_coa_id NUMBER;
43513 l_adr_flexfield_segment_code VARCHAR2(30);
43514 l_adr_flex_value_set_id NUMBER;
43515 l_adr_value_type_code VARCHAR2(30);
43516 l_adr_value_combination_id NUMBER;
43517 l_adr_value_segment_code VARCHAR2(30);
43518
43519 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43520 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43521 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43522 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43523
43524 -- 4262811 Variables ------------------------------------------------------------------------------------------
43525 l_entered_amt_idx NUMBER;
43526 l_accted_amt_idx NUMBER;
43527 l_acc_rev_flag VARCHAR2(1);
43528 l_accrual_line_num NUMBER;
43529 l_tmp_amt NUMBER;
43530 l_acc_rev_natural_side_code VARCHAR2(1);
43531
43532 l_num_entries NUMBER;
43533 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43534 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43535 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43536 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43537 l_recog_line_1 NUMBER;
43538 l_recog_line_2 NUMBER;
43539
43540 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43541 l_bflow_applied_to_amt NUMBER; -- 5132302
43542 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43543
43544 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43545
43546 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43547 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43548
43549 ---------------------------------------------------------------------------------------------------------------
43550
43551
43552 --
43553 -- bulk performance
43554 --
43555 l_balance_type_code VARCHAR2(1);
43556 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43557 l_log_module VARCHAR2(240);
43558
43559 --
43560 -- Upgrade strategy
43561 --
43562 l_actual_upg_option VARCHAR2(1);
43563 l_enc_upg_option VARCHAR2(1);
43564
43565 --
43566 BEGIN
43567 --
43568 IF g_log_enabled THEN
43569 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_102';
43570 END IF;
43571 --
43572 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43573
43574 trace
43575 (p_msg => 'BEGIN of AcctLineType_102'
43576 ,p_level => C_LEVEL_PROCEDURE
43577 ,p_module => l_log_module);
43578
43579 END IF;
43580 --
43581 l_component_type := 'AMB_JLT';
43582 l_component_code := 'COST_VARIANCE';
43583 l_component_type_code := 'S';
43584 l_component_appl_id := 707;
43585 l_amb_context_code := 'DEFAULT';
43586 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
43587 l_event_class_code := 'SALES_ORDER';
43588 l_event_type_code := 'RMA_RCPT';
43589 l_line_definition_owner_code := 'S';
43590 l_line_definition_code := 'PI_RMA_RCPT';
43591 --
43592 l_balance_type_code := 'A';
43593 l_segment := NULL;
43594 l_ccid := NULL;
43595 l_adr_transaction_coa_id := NULL;
43596 l_adr_accounting_coa_id := NULL;
43597 l_adr_flexfield_segment_code := NULL;
43598 l_adr_flex_value_set_id := NULL;
43599 l_adr_value_type_code := NULL;
43600 l_adr_value_combination_id := NULL;
43601 l_adr_value_segment_code := NULL;
43602
43603 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43604 l_bflow_class_code := ''; -- 4219869 Business Flow
43605 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43606 l_budgetary_control_flag := 'N';
43607
43608 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43609 l_bflow_applied_to_amt := NULL; -- 5132302
43610 l_entered_amt_idx := NULL; -- 4262811
43611 l_accted_amt_idx := NULL; -- 4262811
43612 l_acc_rev_flag := NULL; -- 4262811
43613 l_accrual_line_num := NULL; -- 4262811
43614 l_tmp_amt := NULL; -- 4262811
43615 --
43616
43617 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43618 l_balance_type_code <> 'B' THEN
43619 IF NVL(p_source_97,9E125) = 13
43620 THEN
43621
43622 --
43623 XLA_AE_LINES_PKG.SetNewLine;
43624
43625 p_balance_type_code := l_balance_type_code;
43626 -- set the flag so later we will know whether the gain loss line needs to be created
43627
43628 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43629 p_actual_flag :='A';
43630 END IF;
43631
43632 --
43633 -- bulk performance
43634 --
43635 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43636 p_header_num => 0); -- 4262811
43637 --
43638 -- set accounting line options
43639 --
43640 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43641 p_natural_side_code => 'D'
43642 , p_gain_or_loss_flag => 'N'
43643 , p_gl_transfer_mode_code => 'S'
43644 , p_acct_entry_type_code => 'A'
43645 , p_switch_side_flag => 'Y'
43646 , p_merge_duplicate_code => 'N'
43647 );
43648 --
43649 l_acc_rev_natural_side_code := 'C'; -- 4262811
43650 --
43651 --
43652 -- set accounting line type info
43653 --
43654 xla_ae_lines_pkg.SetAcctLineType
43655 (p_component_type => l_component_type
43656 ,p_event_type_code => l_event_type_code
43657 ,p_line_definition_owner_code => l_line_definition_owner_code
43658 ,p_line_definition_code => l_line_definition_code
43659 ,p_accounting_line_code => l_component_code
43660 ,p_accounting_line_type_code => l_component_type_code
43661 ,p_accounting_line_appl_id => l_component_appl_id
43662 ,p_amb_context_code => l_amb_context_code
43663 ,p_entity_code => l_entity_code
43664 ,p_event_class_code => l_event_class_code);
43665 --
43666 -- set accounting class
43667 --
43668 xla_ae_lines_pkg.SetAcctClass(
43669 p_accounting_class_code => 'COST_VARIANCE'
43670 , p_ae_header_id => l_ae_header_id
43671 );
43672
43673 --
43674 -- set rounding class
43675 --
43676 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43677 'COST_VARIANCE';
43678
43679 --
43680 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43681 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43682 --
43683 -- bulk performance
43684 --
43685 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43686
43687 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43688 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43689
43690 -- 4955764
43691 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43692 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43693
43694 -- 4458381 Public Sector Enh
43695
43696 --
43697 -- set accounting attributes for the line type
43698 --
43699 l_entered_amt_idx := 3;
43700 l_accted_amt_idx := 8;
43701 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43702 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
43703 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
43704 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
43705 l_rec_acct_attrs.array_char_value(2) := p_source_85;
43706 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
43707 l_rec_acct_attrs.array_num_value(3) := p_source_91;
43708 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
43709 l_rec_acct_attrs.array_char_value(4) := p_source_88;
43710 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
43711 l_rec_acct_attrs.array_date_value(5) := p_source_92;
43712 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
43713 l_rec_acct_attrs.array_num_value(6) := p_source_93;
43714 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
43715 l_rec_acct_attrs.array_char_value(7) := p_source_94;
43716 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
43717 l_rec_acct_attrs.array_num_value(8) := p_source_95;
43718
43719 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43720 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43721
43722 ---------------------------------------------------------------------------------------------------------------
43723 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43724 ---------------------------------------------------------------------------------------------------------------
43725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43726
43727 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43728 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43729
43730 IF xla_accounting_cache_pkg.GetValueChar
43731 (p_source_code => 'LEDGER_CATEGORY_CODE'
43732 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43733 AND l_bflow_method_code = 'PRIOR_ENTRY'
43734 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43735 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43736 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43737 )
43738 THEN
43739 xla_ae_lines_pkg.BflowUpgEntry
43740 (p_business_method_code => l_bflow_method_code
43741 ,p_business_class_code => l_bflow_class_code
43742 ,p_balance_type => l_balance_type_code);
43743 ELSE
43744 NULL;
43745 -- No business flow processing for business flow method of NONE.
43746 END IF;
43747
43748 --
43749 -- call analytical criteria
43750 --
43751
43752 --
43753 -- call description
43754 --
43755
43756 xla_ae_lines_pkg.SetLineDescription(
43757 p_ae_header_id => l_ae_header_id
43758 ,p_description => Description_1 (
43759 p_application_id => p_application_id
43760 , p_ae_header_id => l_ae_header_id
43761 , p_source_1 => p_source_1
43762 , p_source_2 => p_source_2
43763 , p_source_3 => p_source_3
43764 , p_source_4 => p_source_4
43765 , p_source_5 => p_source_5
43766 )
43767 );
43768
43769
43770 --
43771 -- call ADRs
43772 -- Bug 4922099
43773 --
43774 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43775 (NVL(l_actual_upg_option, 'N') = 'O') OR
43776 (NVL(l_enc_upg_option, 'N') = 'O')
43777 )
43778 THEN
43779 NULL;
43780 --
43781 --
43782
43783 l_ccid := AcctDerRule_6(
43784 p_application_id => p_application_id
43785 , p_ae_header_id => l_ae_header_id
43786 , p_source_11 => p_source_11
43787 , x_transaction_coa_id => l_adr_transaction_coa_id
43788 , x_accounting_coa_id => l_adr_accounting_coa_id
43789 , x_value_type_code => l_adr_value_type_code
43790 , p_side => 'NA'
43791 );
43792
43793 xla_ae_lines_pkg.set_ccid(
43794 p_code_combination_id => l_ccid
43795 , p_value_type_code => l_adr_value_type_code
43796 , p_transaction_coa_id => l_adr_transaction_coa_id
43797 , p_accounting_coa_id => l_adr_accounting_coa_id
43798 , p_adr_code => 'CST_DEFAULT'
43799 , p_adr_type_code => 'S'
43800 , p_component_type => l_component_type
43801 , p_component_code => l_component_code
43802 , p_component_type_code => l_component_type_code
43803 , p_component_appl_id => l_component_appl_id
43804 , p_amb_context_code => l_amb_context_code
43805 , p_side => 'NA'
43806 );
43807
43808
43809 --
43810 --
43811 END IF;
43812 --
43813 -- Bug 4922099
43814 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43815 (NVL(l_enc_upg_option, 'N') = 'O')
43816 ) AND
43817 (l_bflow_method_code = 'PRIOR_ENTRY')
43818 )
43819 THEN
43820 IF
43821 --
43822 1 = 2
43823 --
43824 THEN
43825 xla_accounting_err_pkg.build_message
43826 (p_appli_s_name => 'XLA'
43827 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43828 ,p_token_1 => 'LINE_NUMBER'
43829 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43830 ,p_token_2 => 'LINE_TYPE_NAME'
43831 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43832 l_component_type
43833 ,l_component_code
43834 ,l_component_type_code
43835 ,l_component_appl_id
43836 ,l_amb_context_code
43837 ,l_entity_code
43838 ,l_event_class_code
43839 )
43840 ,p_token_3 => 'OWNER'
43841 ,p_value_3 => xla_lookups_pkg.get_meaning(
43842 p_lookup_type => 'XLA_OWNER_TYPE'
43843 ,p_lookup_code => l_component_type_code
43844 )
43845 ,p_token_4 => 'PRODUCT_NAME'
43846 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43847 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43848 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43849 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43850 ,p_ae_header_id => NULL
43851 );
43852
43853 IF (C_LEVEL_ERROR>= g_log_level) THEN
43854 trace
43855 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43856 ,p_level => C_LEVEL_ERROR
43857 ,p_module => l_log_module);
43858 END IF;
43859 END IF;
43860 END IF;
43861 --
43862 --
43863 ------------------------------------------------------------------------------------------------
43864 -- 4219869 Business Flow
43865 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43866 -- Prior Entry. Currently, the following code is always generated.
43867 ------------------------------------------------------------------------------------------------
43868 XLA_AE_LINES_PKG.ValidateCurrentLine;
43869
43870 ------------------------------------------------------------------------------------
43871 -- 4219869 Business Flow
43872 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43873 ------------------------------------------------------------------------------------
43874 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43875
43876 ----------------------------------------------------------------------------------
43877 -- 4219869 Business Flow
43878 -- Update journal entry status -- Need to generate this within IF <condition>
43879 ----------------------------------------------------------------------------------
43880 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43881 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43882 ,p_balance_type_code => l_balance_type_code
43883 );
43884
43885 -------------------------------------------------------------------------------------------
43886 -- 4262811 - Generate the Accrual Reversal lines
43887 -------------------------------------------------------------------------------------------
43888 BEGIN
43889 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43890 (g_array_event(p_event_id).array_value_num('header_index'));
43891 IF l_acc_rev_flag IS NULL THEN
43892 l_acc_rev_flag := 'N';
43893 END IF;
43894 EXCEPTION
43895 WHEN OTHERS THEN
43896 l_acc_rev_flag := 'N';
43897 END;
43898 --
43899 IF (l_acc_rev_flag = 'Y') THEN
43900
43901 -- 4645092 ------------------------------------------------------------------------------
43902 -- To allow MPA report to determine if it should generate report process
43903 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43904 ------------------------------------------------------------------------------------------
43905
43906 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43907 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43908 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43909 -- call ADRs
43910 -- Bug 4922099
43911 --
43912 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43913 (NVL(l_actual_upg_option, 'N') = 'O') OR
43914 (NVL(l_enc_upg_option, 'N') = 'O')
43915 )
43916 THEN
43917 NULL;
43918 --
43919 --
43920
43921 l_ccid := AcctDerRule_6(
43922 p_application_id => p_application_id
43923 , p_ae_header_id => l_ae_header_id
43924 , p_source_11 => p_source_11
43925 , x_transaction_coa_id => l_adr_transaction_coa_id
43926 , x_accounting_coa_id => l_adr_accounting_coa_id
43927 , x_value_type_code => l_adr_value_type_code
43928 , p_side => 'NA'
43929 );
43930
43931 xla_ae_lines_pkg.set_ccid(
43932 p_code_combination_id => l_ccid
43933 , p_value_type_code => l_adr_value_type_code
43934 , p_transaction_coa_id => l_adr_transaction_coa_id
43935 , p_accounting_coa_id => l_adr_accounting_coa_id
43936 , p_adr_code => 'CST_DEFAULT'
43937 , p_adr_type_code => 'S'
43938 , p_component_type => l_component_type
43939 , p_component_code => l_component_code
43940 , p_component_type_code => l_component_type_code
43941 , p_component_appl_id => l_component_appl_id
43942 , p_amb_context_code => l_amb_context_code
43943 , p_side => 'NA'
43944 );
43945
43946
43947 --
43948 --
43949 END IF;
43950
43951 --
43952 -- Update the line information that should be overwritten
43953 --
43954 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43955 p_header_num => 1);
43956 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43957
43958 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43959
43960 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43961 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43962 END IF;
43963
43964 --
43965 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43966 --
43967 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43968 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43969 ELSE
43970 ---------------------------------------------------------------------------------------------------
43971 -- 4262811a Switch Sign
43972 ---------------------------------------------------------------------------------------------------
43973 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43974 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43975 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43976 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43977 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43978 -- 5132302
43979 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43980 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43981
43982 END IF;
43983
43984 -- 4955764
43985 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43986 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43987
43988
43989 XLA_AE_LINES_PKG.ValidateCurrentLine;
43990 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43991
43992 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43993 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43994 ,p_balance_type_code => l_balance_type_code);
43995
43996 END IF;
43997
43998 -----------------------------------------------------------------------------------------
43999 -- 4262811 Multiperiod Accounting
44000 -----------------------------------------------------------------------------------------
44001 -- No MPA option is assigned.
44002
44003
44004 END IF;
44005 END IF;
44006 --
44007
44008 --
44009 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44010 trace
44011 (p_msg => 'END of AcctLineType_102'
44012 ,p_level => C_LEVEL_PROCEDURE
44013 ,p_module => l_log_module);
44014 END IF;
44015 --
44016 EXCEPTION
44017 WHEN xla_exceptions_pkg.application_exception THEN
44018 RAISE;
44019 WHEN OTHERS THEN
44020 xla_exceptions_pkg.raise_message
44021 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_102');
44022 END AcctLineType_102;
44023 --
44024
44025 ---------------------------------------
44026 --
44027 -- PRIVATE FUNCTION
44028 -- AcctLineType_103
44029 --
44030 ---------------------------------------
44031 PROCEDURE AcctLineType_103 (
44032 p_application_id IN NUMBER
44033 ,p_event_id IN NUMBER
44034 ,p_calculate_acctd_flag IN VARCHAR2
44035 ,p_calculate_g_l_flag IN VARCHAR2
44036 ,p_actual_flag IN OUT VARCHAR2
44037 ,p_balance_type_code OUT VARCHAR2
44038 ,p_gain_or_loss_ref OUT VARCHAR2
44039
44040 --TRANSACTION_ID
44041 , p_source_1 IN NUMBER
44042 --Item Concatenated Segments
44043 , p_source_2 IN VARCHAR2
44044 --Transaction Quantity
44045 , p_source_3 IN NUMBER
44046 --Transaction Unit of Measure Code
44047 , p_source_4 IN VARCHAR2
44048 --Inventory Transaction Type Description
44049 , p_source_5 IN VARCHAR2
44050 --Product Line Accounting Category Average Cost Variance Account
44051 , p_source_23 IN NUMBER
44052 --DISTRIBUTION_IDENTIFIER
44053 , p_source_84 IN NUMBER
44054 --Distribution Type
44055 , p_source_85 IN VARCHAR2
44056 , p_source_85_meaning IN VARCHAR2
44057 --Entered Currency Code
44058 , p_source_88 IN VARCHAR2
44059 --Entered Amount
44060 , p_source_91 IN NUMBER
44061 --Currency Conversion Date
44062 , p_source_92 IN DATE
44063 --Currency Conversion Rate
44064 , p_source_93 IN NUMBER
44065 --Currency Conversion Type
44066 , p_source_94 IN VARCHAR2
44067 --Accounted Amount
44068 , p_source_95 IN NUMBER
44069 --Accounting Line Type
44070 , p_source_97 IN NUMBER
44071 )
44072 IS
44073
44074 l_component_type VARCHAR2(80);
44075 l_component_code VARCHAR2(30);
44076 l_component_type_code VARCHAR2(1);
44077 l_component_appl_id INTEGER;
44078 l_amb_context_code VARCHAR2(30);
44079 l_entity_code VARCHAR2(30);
44080 l_event_class_code VARCHAR2(30);
44081 l_ae_header_id NUMBER;
44082 l_event_type_code VARCHAR2(30);
44083 l_line_definition_code VARCHAR2(30);
44084 l_line_definition_owner_code VARCHAR2(1);
44085 --
44086 -- adr variables
44087 l_segment VARCHAR2(30);
44088 l_ccid NUMBER;
44089 l_adr_transaction_coa_id NUMBER;
44090 l_adr_accounting_coa_id NUMBER;
44091 l_adr_flexfield_segment_code VARCHAR2(30);
44092 l_adr_flex_value_set_id NUMBER;
44093 l_adr_value_type_code VARCHAR2(30);
44094 l_adr_value_combination_id NUMBER;
44095 l_adr_value_segment_code VARCHAR2(30);
44096
44097 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44098 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44099 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44100 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44101
44102 -- 4262811 Variables ------------------------------------------------------------------------------------------
44103 l_entered_amt_idx NUMBER;
44104 l_accted_amt_idx NUMBER;
44105 l_acc_rev_flag VARCHAR2(1);
44106 l_accrual_line_num NUMBER;
44107 l_tmp_amt NUMBER;
44108 l_acc_rev_natural_side_code VARCHAR2(1);
44109
44110 l_num_entries NUMBER;
44111 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44112 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44113 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44114 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44115 l_recog_line_1 NUMBER;
44116 l_recog_line_2 NUMBER;
44117
44118 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44119 l_bflow_applied_to_amt NUMBER; -- 5132302
44120 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44121
44122 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44123
44124 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44125 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44126
44127 ---------------------------------------------------------------------------------------------------------------
44128
44129
44130 --
44131 -- bulk performance
44132 --
44133 l_balance_type_code VARCHAR2(1);
44134 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44135 l_log_module VARCHAR2(240);
44136
44137 --
44138 -- Upgrade strategy
44139 --
44140 l_actual_upg_option VARCHAR2(1);
44141 l_enc_upg_option VARCHAR2(1);
44142
44143 --
44144 BEGIN
44145 --
44146 IF g_log_enabled THEN
44147 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_103';
44148 END IF;
44149 --
44150 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44151
44152 trace
44153 (p_msg => 'BEGIN of AcctLineType_103'
44154 ,p_level => C_LEVEL_PROCEDURE
44155 ,p_module => l_log_module);
44156
44157 END IF;
44158 --
44159 l_component_type := 'AMB_JLT';
44160 l_component_code := 'COST_VARIANCE';
44161 l_component_type_code := 'S';
44162 l_component_appl_id := 707;
44163 l_amb_context_code := 'DEFAULT';
44164 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
44165 l_event_class_code := 'USER_DEFINE';
44166 l_event_type_code := 'UCG_TXFR';
44167 l_line_definition_owner_code := 'S';
44168 l_line_definition_code := 'PI_CG_TXFR';
44169 --
44170 l_balance_type_code := 'A';
44171 l_segment := NULL;
44172 l_ccid := NULL;
44173 l_adr_transaction_coa_id := NULL;
44174 l_adr_accounting_coa_id := NULL;
44175 l_adr_flexfield_segment_code := NULL;
44176 l_adr_flex_value_set_id := NULL;
44177 l_adr_value_type_code := NULL;
44178 l_adr_value_combination_id := NULL;
44179 l_adr_value_segment_code := NULL;
44180
44181 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44182 l_bflow_class_code := ''; -- 4219869 Business Flow
44183 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44184 l_budgetary_control_flag := 'N';
44185
44186 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44187 l_bflow_applied_to_amt := NULL; -- 5132302
44188 l_entered_amt_idx := NULL; -- 4262811
44189 l_accted_amt_idx := NULL; -- 4262811
44190 l_acc_rev_flag := NULL; -- 4262811
44191 l_accrual_line_num := NULL; -- 4262811
44192 l_tmp_amt := NULL; -- 4262811
44193 --
44194
44195 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44196 l_balance_type_code <> 'B' THEN
44197 IF NVL(p_source_97,9E125) = 13
44198 THEN
44199
44200 --
44201 XLA_AE_LINES_PKG.SetNewLine;
44202
44203 p_balance_type_code := l_balance_type_code;
44204 -- set the flag so later we will know whether the gain loss line needs to be created
44205
44206 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44207 p_actual_flag :='A';
44208 END IF;
44209
44210 --
44211 -- bulk performance
44212 --
44213 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44214 p_header_num => 0); -- 4262811
44215 --
44216 -- set accounting line options
44217 --
44218 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44219 p_natural_side_code => 'D'
44220 , p_gain_or_loss_flag => 'N'
44221 , p_gl_transfer_mode_code => 'S'
44222 , p_acct_entry_type_code => 'A'
44223 , p_switch_side_flag => 'Y'
44224 , p_merge_duplicate_code => 'N'
44225 );
44226 --
44227 l_acc_rev_natural_side_code := 'C'; -- 4262811
44228 --
44229 --
44230 -- set accounting line type info
44231 --
44232 xla_ae_lines_pkg.SetAcctLineType
44233 (p_component_type => l_component_type
44234 ,p_event_type_code => l_event_type_code
44235 ,p_line_definition_owner_code => l_line_definition_owner_code
44236 ,p_line_definition_code => l_line_definition_code
44237 ,p_accounting_line_code => l_component_code
44238 ,p_accounting_line_type_code => l_component_type_code
44239 ,p_accounting_line_appl_id => l_component_appl_id
44240 ,p_amb_context_code => l_amb_context_code
44241 ,p_entity_code => l_entity_code
44242 ,p_event_class_code => l_event_class_code);
44243 --
44244 -- set accounting class
44245 --
44246 xla_ae_lines_pkg.SetAcctClass(
44247 p_accounting_class_code => 'COST_VARIANCE'
44248 , p_ae_header_id => l_ae_header_id
44249 );
44250
44251 --
44252 -- set rounding class
44253 --
44254 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44255 'COST_VARIANCE';
44256
44257 --
44258 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44259 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44260 --
44261 -- bulk performance
44262 --
44263 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44264
44265 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44266 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44267
44268 -- 4955764
44269 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44270 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44271
44272 -- 4458381 Public Sector Enh
44273
44274 --
44275 -- set accounting attributes for the line type
44276 --
44277 l_entered_amt_idx := 3;
44278 l_accted_amt_idx := 8;
44279 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44280 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
44281 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
44282 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
44283 l_rec_acct_attrs.array_char_value(2) := p_source_85;
44284 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
44285 l_rec_acct_attrs.array_num_value(3) := p_source_91;
44286 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
44287 l_rec_acct_attrs.array_char_value(4) := p_source_88;
44288 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
44289 l_rec_acct_attrs.array_date_value(5) := p_source_92;
44290 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
44291 l_rec_acct_attrs.array_num_value(6) := p_source_93;
44292 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
44293 l_rec_acct_attrs.array_char_value(7) := p_source_94;
44294 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
44295 l_rec_acct_attrs.array_num_value(8) := p_source_95;
44296
44297 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44298 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44299
44300 ---------------------------------------------------------------------------------------------------------------
44301 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44302 ---------------------------------------------------------------------------------------------------------------
44303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44304
44305 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44306 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44307
44308 IF xla_accounting_cache_pkg.GetValueChar
44309 (p_source_code => 'LEDGER_CATEGORY_CODE'
44310 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44311 AND l_bflow_method_code = 'PRIOR_ENTRY'
44312 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44313 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44314 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44315 )
44316 THEN
44317 xla_ae_lines_pkg.BflowUpgEntry
44318 (p_business_method_code => l_bflow_method_code
44319 ,p_business_class_code => l_bflow_class_code
44320 ,p_balance_type => l_balance_type_code);
44321 ELSE
44322 NULL;
44323 -- No business flow processing for business flow method of NONE.
44324 END IF;
44325
44326 --
44327 -- call analytical criteria
44328 --
44329
44330 --
44331 -- call description
44332 --
44333
44334 xla_ae_lines_pkg.SetLineDescription(
44335 p_ae_header_id => l_ae_header_id
44336 ,p_description => Description_1 (
44337 p_application_id => p_application_id
44338 , p_ae_header_id => l_ae_header_id
44339 , p_source_1 => p_source_1
44340 , p_source_2 => p_source_2
44341 , p_source_3 => p_source_3
44342 , p_source_4 => p_source_4
44343 , p_source_5 => p_source_5
44344 )
44345 );
44346
44347
44348 --
44349 -- call ADRs
44350 -- Bug 4922099
44351 --
44352 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44353 (NVL(l_actual_upg_option, 'N') = 'O') OR
44354 (NVL(l_enc_upg_option, 'N') = 'O')
44355 )
44356 THEN
44357 NULL;
44358 --
44359 --
44360
44361 l_ccid := AcctDerRule_12(
44362 p_application_id => p_application_id
44363 , p_ae_header_id => l_ae_header_id
44364 , p_source_23 => p_source_23
44365 , x_transaction_coa_id => l_adr_transaction_coa_id
44366 , x_accounting_coa_id => l_adr_accounting_coa_id
44367 , x_value_type_code => l_adr_value_type_code
44368 , p_side => 'NA'
44369 );
44370
44371 xla_ae_lines_pkg.set_ccid(
44372 p_code_combination_id => l_ccid
44373 , p_value_type_code => l_adr_value_type_code
44374 , p_transaction_coa_id => l_adr_transaction_coa_id
44375 , p_accounting_coa_id => l_adr_accounting_coa_id
44376 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
44377 , p_adr_type_code => 'S'
44378 , p_component_type => l_component_type
44379 , p_component_code => l_component_code
44380 , p_component_type_code => l_component_type_code
44381 , p_component_appl_id => l_component_appl_id
44382 , p_amb_context_code => l_amb_context_code
44383 , p_side => 'NA'
44384 );
44385
44386
44387 --
44388 --
44389 END IF;
44390 --
44391 -- Bug 4922099
44392 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44393 (NVL(l_enc_upg_option, 'N') = 'O')
44394 ) AND
44395 (l_bflow_method_code = 'PRIOR_ENTRY')
44396 )
44397 THEN
44398 IF
44399 --
44400 1 = 2
44401 --
44402 THEN
44403 xla_accounting_err_pkg.build_message
44404 (p_appli_s_name => 'XLA'
44405 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44406 ,p_token_1 => 'LINE_NUMBER'
44407 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44408 ,p_token_2 => 'LINE_TYPE_NAME'
44409 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44410 l_component_type
44411 ,l_component_code
44412 ,l_component_type_code
44413 ,l_component_appl_id
44414 ,l_amb_context_code
44415 ,l_entity_code
44416 ,l_event_class_code
44417 )
44418 ,p_token_3 => 'OWNER'
44419 ,p_value_3 => xla_lookups_pkg.get_meaning(
44420 p_lookup_type => 'XLA_OWNER_TYPE'
44421 ,p_lookup_code => l_component_type_code
44422 )
44423 ,p_token_4 => 'PRODUCT_NAME'
44424 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44425 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44426 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44427 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44428 ,p_ae_header_id => NULL
44429 );
44430
44431 IF (C_LEVEL_ERROR>= g_log_level) THEN
44432 trace
44433 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44434 ,p_level => C_LEVEL_ERROR
44435 ,p_module => l_log_module);
44436 END IF;
44437 END IF;
44438 END IF;
44439 --
44440 --
44441 ------------------------------------------------------------------------------------------------
44442 -- 4219869 Business Flow
44443 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44444 -- Prior Entry. Currently, the following code is always generated.
44445 ------------------------------------------------------------------------------------------------
44446 XLA_AE_LINES_PKG.ValidateCurrentLine;
44447
44448 ------------------------------------------------------------------------------------
44449 -- 4219869 Business Flow
44450 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44451 ------------------------------------------------------------------------------------
44452 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44453
44454 ----------------------------------------------------------------------------------
44455 -- 4219869 Business Flow
44456 -- Update journal entry status -- Need to generate this within IF <condition>
44457 ----------------------------------------------------------------------------------
44458 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44459 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44460 ,p_balance_type_code => l_balance_type_code
44461 );
44462
44463 -------------------------------------------------------------------------------------------
44464 -- 4262811 - Generate the Accrual Reversal lines
44465 -------------------------------------------------------------------------------------------
44466 BEGIN
44467 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44468 (g_array_event(p_event_id).array_value_num('header_index'));
44469 IF l_acc_rev_flag IS NULL THEN
44470 l_acc_rev_flag := 'N';
44471 END IF;
44472 EXCEPTION
44473 WHEN OTHERS THEN
44474 l_acc_rev_flag := 'N';
44475 END;
44476 --
44477 IF (l_acc_rev_flag = 'Y') THEN
44478
44479 -- 4645092 ------------------------------------------------------------------------------
44480 -- To allow MPA report to determine if it should generate report process
44481 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44482 ------------------------------------------------------------------------------------------
44483
44484 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44485 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44486 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44487 -- call ADRs
44488 -- Bug 4922099
44489 --
44490 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44491 (NVL(l_actual_upg_option, 'N') = 'O') OR
44492 (NVL(l_enc_upg_option, 'N') = 'O')
44493 )
44494 THEN
44495 NULL;
44496 --
44497 --
44498
44499 l_ccid := AcctDerRule_12(
44500 p_application_id => p_application_id
44501 , p_ae_header_id => l_ae_header_id
44502 , p_source_23 => p_source_23
44503 , x_transaction_coa_id => l_adr_transaction_coa_id
44504 , x_accounting_coa_id => l_adr_accounting_coa_id
44505 , x_value_type_code => l_adr_value_type_code
44506 , p_side => 'NA'
44507 );
44508
44509 xla_ae_lines_pkg.set_ccid(
44510 p_code_combination_id => l_ccid
44511 , p_value_type_code => l_adr_value_type_code
44512 , p_transaction_coa_id => l_adr_transaction_coa_id
44513 , p_accounting_coa_id => l_adr_accounting_coa_id
44514 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
44515 , p_adr_type_code => 'S'
44516 , p_component_type => l_component_type
44517 , p_component_code => l_component_code
44518 , p_component_type_code => l_component_type_code
44519 , p_component_appl_id => l_component_appl_id
44520 , p_amb_context_code => l_amb_context_code
44521 , p_side => 'NA'
44522 );
44523
44524
44525 --
44526 --
44527 END IF;
44528
44529 --
44530 -- Update the line information that should be overwritten
44531 --
44532 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44533 p_header_num => 1);
44534 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44535
44536 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44537
44538 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44539 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44540 END IF;
44541
44542 --
44543 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44544 --
44545 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44546 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44547 ELSE
44548 ---------------------------------------------------------------------------------------------------
44549 -- 4262811a Switch Sign
44550 ---------------------------------------------------------------------------------------------------
44551 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44552 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44553 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44554 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44555 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44556 -- 5132302
44557 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44558 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44559
44560 END IF;
44561
44562 -- 4955764
44563 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44564 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44565
44566
44567 XLA_AE_LINES_PKG.ValidateCurrentLine;
44568 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44569
44570 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44571 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44572 ,p_balance_type_code => l_balance_type_code);
44573
44574 END IF;
44575
44576 -----------------------------------------------------------------------------------------
44577 -- 4262811 Multiperiod Accounting
44578 -----------------------------------------------------------------------------------------
44579 -- No MPA option is assigned.
44580
44581
44582 END IF;
44583 END IF;
44584 --
44585
44586 --
44587 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44588 trace
44589 (p_msg => 'END of AcctLineType_103'
44590 ,p_level => C_LEVEL_PROCEDURE
44591 ,p_module => l_log_module);
44592 END IF;
44593 --
44594 EXCEPTION
44595 WHEN xla_exceptions_pkg.application_exception THEN
44596 RAISE;
44597 WHEN OTHERS THEN
44598 xla_exceptions_pkg.raise_message
44599 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_103');
44600 END AcctLineType_103;
44601 --
44602
44603 ---------------------------------------
44604 --
44605 -- PRIVATE FUNCTION
44606 -- AcctLineType_104
44607 --
44608 ---------------------------------------
44609 PROCEDURE AcctLineType_104 (
44610 p_application_id IN NUMBER
44611 ,p_event_id IN NUMBER
44612 ,p_calculate_acctd_flag IN VARCHAR2
44613 ,p_calculate_g_l_flag IN VARCHAR2
44614 ,p_actual_flag IN OUT VARCHAR2
44615 ,p_balance_type_code OUT VARCHAR2
44616 ,p_gain_or_loss_ref OUT VARCHAR2
44617
44618 --TRANSACTION_ID
44619 , p_source_1 IN NUMBER
44620 --Item Concatenated Segments
44621 , p_source_2 IN VARCHAR2
44622 --Transaction Quantity
44623 , p_source_3 IN NUMBER
44624 --Transaction Unit of Measure Code
44625 , p_source_4 IN VARCHAR2
44626 --Inventory Transaction Type Description
44627 , p_source_5 IN VARCHAR2
44628 --Cost Management Default Account
44629 , p_source_11 IN NUMBER
44630 --DISTRIBUTION_IDENTIFIER
44631 , p_source_84 IN NUMBER
44632 --Distribution Type
44633 , p_source_85 IN VARCHAR2
44634 , p_source_85_meaning IN VARCHAR2
44635 --Entered Currency Code
44636 , p_source_88 IN VARCHAR2
44637 --Entered Amount
44638 , p_source_91 IN NUMBER
44639 --Currency Conversion Date
44640 , p_source_92 IN DATE
44641 --Currency Conversion Rate
44642 , p_source_93 IN NUMBER
44643 --Currency Conversion Type
44644 , p_source_94 IN VARCHAR2
44645 --Accounted Amount
44646 , p_source_95 IN NUMBER
44647 --Accounting Line Type
44648 , p_source_97 IN NUMBER
44649 )
44650 IS
44651
44652 l_component_type VARCHAR2(80);
44653 l_component_code VARCHAR2(30);
44654 l_component_type_code VARCHAR2(1);
44655 l_component_appl_id INTEGER;
44656 l_amb_context_code VARCHAR2(30);
44657 l_entity_code VARCHAR2(30);
44658 l_event_class_code VARCHAR2(30);
44659 l_ae_header_id NUMBER;
44660 l_event_type_code VARCHAR2(30);
44661 l_line_definition_code VARCHAR2(30);
44662 l_line_definition_owner_code VARCHAR2(1);
44663 --
44664 -- adr variables
44665 l_segment VARCHAR2(30);
44666 l_ccid NUMBER;
44667 l_adr_transaction_coa_id NUMBER;
44668 l_adr_accounting_coa_id NUMBER;
44669 l_adr_flexfield_segment_code VARCHAR2(30);
44670 l_adr_flex_value_set_id NUMBER;
44671 l_adr_value_type_code VARCHAR2(30);
44672 l_adr_value_combination_id NUMBER;
44673 l_adr_value_segment_code VARCHAR2(30);
44674
44675 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44676 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44677 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44678 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44679
44680 -- 4262811 Variables ------------------------------------------------------------------------------------------
44681 l_entered_amt_idx NUMBER;
44682 l_accted_amt_idx NUMBER;
44683 l_acc_rev_flag VARCHAR2(1);
44684 l_accrual_line_num NUMBER;
44685 l_tmp_amt NUMBER;
44686 l_acc_rev_natural_side_code VARCHAR2(1);
44687
44688 l_num_entries NUMBER;
44689 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44690 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44691 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44692 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44693 l_recog_line_1 NUMBER;
44694 l_recog_line_2 NUMBER;
44695
44696 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44697 l_bflow_applied_to_amt NUMBER; -- 5132302
44698 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44699
44700 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44701
44702 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44703 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44704
44705 ---------------------------------------------------------------------------------------------------------------
44706
44707
44708 --
44709 -- bulk performance
44710 --
44711 l_balance_type_code VARCHAR2(1);
44712 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44713 l_log_module VARCHAR2(240);
44714
44715 --
44716 -- Upgrade strategy
44717 --
44718 l_actual_upg_option VARCHAR2(1);
44719 l_enc_upg_option VARCHAR2(1);
44720
44721 --
44722 BEGIN
44723 --
44724 IF g_log_enabled THEN
44725 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_104';
44726 END IF;
44727 --
44728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44729
44730 trace
44731 (p_msg => 'BEGIN of AcctLineType_104'
44732 ,p_level => C_LEVEL_PROCEDURE
44733 ,p_module => l_log_module);
44734
44735 END IF;
44736 --
44737 l_component_type := 'AMB_JLT';
44738 l_component_code := 'COST_VARIANCE';
44739 l_component_type_code := 'S';
44740 l_component_appl_id := 707;
44741 l_amb_context_code := 'DEFAULT';
44742 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
44743 l_event_class_code := 'USER_DEFINE';
44744 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
44745 l_line_definition_owner_code := 'S';
44746 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
44747 --
44748 l_balance_type_code := 'A';
44749 l_segment := NULL;
44750 l_ccid := NULL;
44751 l_adr_transaction_coa_id := NULL;
44752 l_adr_accounting_coa_id := NULL;
44753 l_adr_flexfield_segment_code := NULL;
44754 l_adr_flex_value_set_id := NULL;
44755 l_adr_value_type_code := NULL;
44756 l_adr_value_combination_id := NULL;
44757 l_adr_value_segment_code := NULL;
44758
44759 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44760 l_bflow_class_code := ''; -- 4219869 Business Flow
44761 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44762 l_budgetary_control_flag := 'N';
44763
44764 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44765 l_bflow_applied_to_amt := NULL; -- 5132302
44766 l_entered_amt_idx := NULL; -- 4262811
44767 l_accted_amt_idx := NULL; -- 4262811
44768 l_acc_rev_flag := NULL; -- 4262811
44769 l_accrual_line_num := NULL; -- 4262811
44770 l_tmp_amt := NULL; -- 4262811
44771 --
44772
44773 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44774 l_balance_type_code <> 'B' THEN
44775 IF NVL(p_source_97,9E125) = 13
44776 THEN
44777
44778 --
44779 XLA_AE_LINES_PKG.SetNewLine;
44780
44781 p_balance_type_code := l_balance_type_code;
44782 -- set the flag so later we will know whether the gain loss line needs to be created
44783
44784 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44785 p_actual_flag :='A';
44786 END IF;
44787
44788 --
44789 -- bulk performance
44790 --
44791 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44792 p_header_num => 0); -- 4262811
44793 --
44794 -- set accounting line options
44795 --
44796 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44797 p_natural_side_code => 'D'
44798 , p_gain_or_loss_flag => 'N'
44799 , p_gl_transfer_mode_code => 'S'
44800 , p_acct_entry_type_code => 'A'
44801 , p_switch_side_flag => 'Y'
44802 , p_merge_duplicate_code => 'N'
44803 );
44804 --
44805 l_acc_rev_natural_side_code := 'C'; -- 4262811
44806 --
44807 --
44808 -- set accounting line type info
44809 --
44810 xla_ae_lines_pkg.SetAcctLineType
44811 (p_component_type => l_component_type
44812 ,p_event_type_code => l_event_type_code
44813 ,p_line_definition_owner_code => l_line_definition_owner_code
44814 ,p_line_definition_code => l_line_definition_code
44815 ,p_accounting_line_code => l_component_code
44816 ,p_accounting_line_type_code => l_component_type_code
44817 ,p_accounting_line_appl_id => l_component_appl_id
44818 ,p_amb_context_code => l_amb_context_code
44819 ,p_entity_code => l_entity_code
44820 ,p_event_class_code => l_event_class_code);
44821 --
44822 -- set accounting class
44823 --
44824 xla_ae_lines_pkg.SetAcctClass(
44825 p_accounting_class_code => 'COST_VARIANCE'
44826 , p_ae_header_id => l_ae_header_id
44827 );
44828
44829 --
44830 -- set rounding class
44831 --
44832 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44833 'COST_VARIANCE';
44834
44835 --
44836 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44837 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44838 --
44839 -- bulk performance
44840 --
44841 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44842
44843 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44844 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44845
44846 -- 4955764
44847 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44848 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44849
44850 -- 4458381 Public Sector Enh
44851
44852 --
44853 -- set accounting attributes for the line type
44854 --
44855 l_entered_amt_idx := 3;
44856 l_accted_amt_idx := 8;
44857 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44858 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
44859 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
44860 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
44861 l_rec_acct_attrs.array_char_value(2) := p_source_85;
44862 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
44863 l_rec_acct_attrs.array_num_value(3) := p_source_91;
44864 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
44865 l_rec_acct_attrs.array_char_value(4) := p_source_88;
44866 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
44867 l_rec_acct_attrs.array_date_value(5) := p_source_92;
44868 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
44869 l_rec_acct_attrs.array_num_value(6) := p_source_93;
44870 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
44871 l_rec_acct_attrs.array_char_value(7) := p_source_94;
44872 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
44873 l_rec_acct_attrs.array_num_value(8) := p_source_95;
44874
44875 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44876 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44877
44878 ---------------------------------------------------------------------------------------------------------------
44879 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44880 ---------------------------------------------------------------------------------------------------------------
44881 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44882
44883 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44884 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44885
44886 IF xla_accounting_cache_pkg.GetValueChar
44887 (p_source_code => 'LEDGER_CATEGORY_CODE'
44888 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44889 AND l_bflow_method_code = 'PRIOR_ENTRY'
44890 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44891 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44892 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44893 )
44894 THEN
44895 xla_ae_lines_pkg.BflowUpgEntry
44896 (p_business_method_code => l_bflow_method_code
44897 ,p_business_class_code => l_bflow_class_code
44898 ,p_balance_type => l_balance_type_code);
44899 ELSE
44900 NULL;
44901 -- No business flow processing for business flow method of NONE.
44902 END IF;
44903
44904 --
44905 -- call analytical criteria
44906 --
44907
44908 --
44909 -- call description
44910 --
44911
44912 xla_ae_lines_pkg.SetLineDescription(
44913 p_ae_header_id => l_ae_header_id
44914 ,p_description => Description_1 (
44915 p_application_id => p_application_id
44916 , p_ae_header_id => l_ae_header_id
44917 , p_source_1 => p_source_1
44918 , p_source_2 => p_source_2
44919 , p_source_3 => p_source_3
44920 , p_source_4 => p_source_4
44921 , p_source_5 => p_source_5
44922 )
44923 );
44924
44925
44926 --
44927 -- call ADRs
44928 -- Bug 4922099
44929 --
44930 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44931 (NVL(l_actual_upg_option, 'N') = 'O') OR
44932 (NVL(l_enc_upg_option, 'N') = 'O')
44933 )
44934 THEN
44935 NULL;
44936 --
44937 --
44938
44939 l_ccid := AcctDerRule_6(
44940 p_application_id => p_application_id
44941 , p_ae_header_id => l_ae_header_id
44942 , p_source_11 => p_source_11
44943 , x_transaction_coa_id => l_adr_transaction_coa_id
44944 , x_accounting_coa_id => l_adr_accounting_coa_id
44945 , x_value_type_code => l_adr_value_type_code
44946 , p_side => 'NA'
44947 );
44948
44949 xla_ae_lines_pkg.set_ccid(
44950 p_code_combination_id => l_ccid
44951 , p_value_type_code => l_adr_value_type_code
44952 , p_transaction_coa_id => l_adr_transaction_coa_id
44953 , p_accounting_coa_id => l_adr_accounting_coa_id
44954 , p_adr_code => 'CST_DEFAULT'
44955 , p_adr_type_code => 'S'
44956 , p_component_type => l_component_type
44957 , p_component_code => l_component_code
44958 , p_component_type_code => l_component_type_code
44959 , p_component_appl_id => l_component_appl_id
44960 , p_amb_context_code => l_amb_context_code
44961 , p_side => 'NA'
44962 );
44963
44964
44965 --
44966 --
44967 END IF;
44968 --
44969 -- Bug 4922099
44970 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44971 (NVL(l_enc_upg_option, 'N') = 'O')
44972 ) AND
44973 (l_bflow_method_code = 'PRIOR_ENTRY')
44974 )
44975 THEN
44976 IF
44977 --
44978 1 = 2
44979 --
44980 THEN
44981 xla_accounting_err_pkg.build_message
44982 (p_appli_s_name => 'XLA'
44983 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44984 ,p_token_1 => 'LINE_NUMBER'
44985 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44986 ,p_token_2 => 'LINE_TYPE_NAME'
44987 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44988 l_component_type
44989 ,l_component_code
44990 ,l_component_type_code
44991 ,l_component_appl_id
44992 ,l_amb_context_code
44993 ,l_entity_code
44994 ,l_event_class_code
44995 )
44996 ,p_token_3 => 'OWNER'
44997 ,p_value_3 => xla_lookups_pkg.get_meaning(
44998 p_lookup_type => 'XLA_OWNER_TYPE'
44999 ,p_lookup_code => l_component_type_code
45000 )
45001 ,p_token_4 => 'PRODUCT_NAME'
45002 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45003 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45004 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45005 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45006 ,p_ae_header_id => NULL
45007 );
45008
45009 IF (C_LEVEL_ERROR>= g_log_level) THEN
45010 trace
45011 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45012 ,p_level => C_LEVEL_ERROR
45013 ,p_module => l_log_module);
45014 END IF;
45015 END IF;
45016 END IF;
45017 --
45018 --
45019 ------------------------------------------------------------------------------------------------
45020 -- 4219869 Business Flow
45021 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45022 -- Prior Entry. Currently, the following code is always generated.
45023 ------------------------------------------------------------------------------------------------
45024 XLA_AE_LINES_PKG.ValidateCurrentLine;
45025
45026 ------------------------------------------------------------------------------------
45027 -- 4219869 Business Flow
45028 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45029 ------------------------------------------------------------------------------------
45030 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45031
45032 ----------------------------------------------------------------------------------
45033 -- 4219869 Business Flow
45034 -- Update journal entry status -- Need to generate this within IF <condition>
45035 ----------------------------------------------------------------------------------
45036 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45037 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45038 ,p_balance_type_code => l_balance_type_code
45039 );
45040
45041 -------------------------------------------------------------------------------------------
45042 -- 4262811 - Generate the Accrual Reversal lines
45043 -------------------------------------------------------------------------------------------
45044 BEGIN
45045 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45046 (g_array_event(p_event_id).array_value_num('header_index'));
45047 IF l_acc_rev_flag IS NULL THEN
45048 l_acc_rev_flag := 'N';
45049 END IF;
45050 EXCEPTION
45051 WHEN OTHERS THEN
45052 l_acc_rev_flag := 'N';
45053 END;
45054 --
45055 IF (l_acc_rev_flag = 'Y') THEN
45056
45057 -- 4645092 ------------------------------------------------------------------------------
45058 -- To allow MPA report to determine if it should generate report process
45059 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45060 ------------------------------------------------------------------------------------------
45061
45062 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45063 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45064 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45065 -- call ADRs
45066 -- Bug 4922099
45067 --
45068 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45069 (NVL(l_actual_upg_option, 'N') = 'O') OR
45070 (NVL(l_enc_upg_option, 'N') = 'O')
45071 )
45072 THEN
45073 NULL;
45074 --
45075 --
45076
45077 l_ccid := AcctDerRule_6(
45078 p_application_id => p_application_id
45079 , p_ae_header_id => l_ae_header_id
45080 , p_source_11 => p_source_11
45081 , x_transaction_coa_id => l_adr_transaction_coa_id
45082 , x_accounting_coa_id => l_adr_accounting_coa_id
45083 , x_value_type_code => l_adr_value_type_code
45084 , p_side => 'NA'
45085 );
45086
45087 xla_ae_lines_pkg.set_ccid(
45088 p_code_combination_id => l_ccid
45089 , p_value_type_code => l_adr_value_type_code
45090 , p_transaction_coa_id => l_adr_transaction_coa_id
45091 , p_accounting_coa_id => l_adr_accounting_coa_id
45092 , p_adr_code => 'CST_DEFAULT'
45093 , p_adr_type_code => 'S'
45094 , p_component_type => l_component_type
45095 , p_component_code => l_component_code
45096 , p_component_type_code => l_component_type_code
45097 , p_component_appl_id => l_component_appl_id
45098 , p_amb_context_code => l_amb_context_code
45099 , p_side => 'NA'
45100 );
45101
45102
45103 --
45104 --
45105 END IF;
45106
45107 --
45108 -- Update the line information that should be overwritten
45109 --
45110 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45111 p_header_num => 1);
45112 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45113
45114 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45115
45116 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45117 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45118 END IF;
45119
45120 --
45121 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45122 --
45123 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45124 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45125 ELSE
45126 ---------------------------------------------------------------------------------------------------
45127 -- 4262811a Switch Sign
45128 ---------------------------------------------------------------------------------------------------
45129 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45130 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45131 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45132 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45133 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45134 -- 5132302
45135 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45136 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45137
45138 END IF;
45139
45140 -- 4955764
45141 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45142 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45143
45144
45145 XLA_AE_LINES_PKG.ValidateCurrentLine;
45146 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45147
45148 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45149 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45150 ,p_balance_type_code => l_balance_type_code);
45151
45152 END IF;
45153
45154 -----------------------------------------------------------------------------------------
45155 -- 4262811 Multiperiod Accounting
45156 -----------------------------------------------------------------------------------------
45157 -- No MPA option is assigned.
45158
45159
45160 END IF;
45161 END IF;
45162 --
45163
45164 --
45165 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45166 trace
45167 (p_msg => 'END of AcctLineType_104'
45168 ,p_level => C_LEVEL_PROCEDURE
45169 ,p_module => l_log_module);
45170 END IF;
45171 --
45172 EXCEPTION
45173 WHEN xla_exceptions_pkg.application_exception THEN
45174 RAISE;
45175 WHEN OTHERS THEN
45176 xla_exceptions_pkg.raise_message
45177 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_104');
45178 END AcctLineType_104;
45179 --
45180
45181 ---------------------------------------
45182 --
45183 -- PRIVATE FUNCTION
45184 -- AcctLineType_105
45185 --
45186 ---------------------------------------
45187 PROCEDURE AcctLineType_105 (
45188 p_application_id IN NUMBER
45189 ,p_event_id IN NUMBER
45190 ,p_calculate_acctd_flag IN VARCHAR2
45191 ,p_calculate_g_l_flag IN VARCHAR2
45192 ,p_actual_flag IN OUT VARCHAR2
45193 ,p_balance_type_code OUT VARCHAR2
45194 ,p_gain_or_loss_ref OUT VARCHAR2
45195
45196 --TRANSACTION_ID
45197 , p_source_1 IN NUMBER
45198 --Item Concatenated Segments
45199 , p_source_2 IN VARCHAR2
45200 --Transaction Quantity
45201 , p_source_3 IN NUMBER
45202 --Transaction Unit of Measure Code
45203 , p_source_4 IN VARCHAR2
45204 --Inventory Transaction Type Description
45205 , p_source_5 IN VARCHAR2
45206 --Cost Management Default Account
45207 , p_source_11 IN NUMBER
45208 --DISTRIBUTION_IDENTIFIER
45209 , p_source_84 IN NUMBER
45210 --Distribution Type
45211 , p_source_85 IN VARCHAR2
45212 , p_source_85_meaning IN VARCHAR2
45213 --Entered Currency Code
45214 , p_source_88 IN VARCHAR2
45215 --Entered Amount
45216 , p_source_91 IN NUMBER
45217 --Currency Conversion Date
45218 , p_source_92 IN DATE
45219 --Currency Conversion Rate
45220 , p_source_93 IN NUMBER
45221 --Currency Conversion Type
45222 , p_source_94 IN VARCHAR2
45223 --Accounted Amount
45224 , p_source_95 IN NUMBER
45225 --Accounting Line Type
45226 , p_source_97 IN NUMBER
45227 )
45228 IS
45229
45230 l_component_type VARCHAR2(80);
45231 l_component_code VARCHAR2(30);
45232 l_component_type_code VARCHAR2(1);
45233 l_component_appl_id INTEGER;
45234 l_amb_context_code VARCHAR2(30);
45235 l_entity_code VARCHAR2(30);
45236 l_event_class_code VARCHAR2(30);
45237 l_ae_header_id NUMBER;
45238 l_event_type_code VARCHAR2(30);
45239 l_line_definition_code VARCHAR2(30);
45240 l_line_definition_owner_code VARCHAR2(1);
45241 --
45242 -- adr variables
45243 l_segment VARCHAR2(30);
45244 l_ccid NUMBER;
45245 l_adr_transaction_coa_id NUMBER;
45246 l_adr_accounting_coa_id NUMBER;
45247 l_adr_flexfield_segment_code VARCHAR2(30);
45248 l_adr_flex_value_set_id NUMBER;
45249 l_adr_value_type_code VARCHAR2(30);
45250 l_adr_value_combination_id NUMBER;
45251 l_adr_value_segment_code VARCHAR2(30);
45252
45253 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45254 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45255 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45256 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45257
45258 -- 4262811 Variables ------------------------------------------------------------------------------------------
45259 l_entered_amt_idx NUMBER;
45260 l_accted_amt_idx NUMBER;
45261 l_acc_rev_flag VARCHAR2(1);
45262 l_accrual_line_num NUMBER;
45263 l_tmp_amt NUMBER;
45264 l_acc_rev_natural_side_code VARCHAR2(1);
45265
45266 l_num_entries NUMBER;
45267 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45268 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45269 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45270 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45271 l_recog_line_1 NUMBER;
45272 l_recog_line_2 NUMBER;
45273
45274 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45275 l_bflow_applied_to_amt NUMBER; -- 5132302
45276 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45277
45278 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45279
45280 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45281 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45282
45283 ---------------------------------------------------------------------------------------------------------------
45284
45285
45286 --
45287 -- bulk performance
45288 --
45289 l_balance_type_code VARCHAR2(1);
45290 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45291 l_log_module VARCHAR2(240);
45292
45293 --
45294 -- Upgrade strategy
45295 --
45296 l_actual_upg_option VARCHAR2(1);
45297 l_enc_upg_option VARCHAR2(1);
45298
45299 --
45300 BEGIN
45301 --
45302 IF g_log_enabled THEN
45303 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_105';
45304 END IF;
45305 --
45306 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45307
45308 trace
45309 (p_msg => 'BEGIN of AcctLineType_105'
45310 ,p_level => C_LEVEL_PROCEDURE
45311 ,p_module => l_log_module);
45312
45313 END IF;
45314 --
45315 l_component_type := 'AMB_JLT';
45316 l_component_code := 'COST_VARIANCE';
45317 l_component_type_code := 'S';
45318 l_component_appl_id := 707;
45319 l_amb_context_code := 'DEFAULT';
45320 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
45321 l_event_class_code := 'USER_DEFINE';
45322 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
45323 l_line_definition_owner_code := 'S';
45324 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
45325 --
45326 l_balance_type_code := 'A';
45327 l_segment := NULL;
45328 l_ccid := NULL;
45329 l_adr_transaction_coa_id := NULL;
45330 l_adr_accounting_coa_id := NULL;
45331 l_adr_flexfield_segment_code := NULL;
45332 l_adr_flex_value_set_id := NULL;
45333 l_adr_value_type_code := NULL;
45334 l_adr_value_combination_id := NULL;
45335 l_adr_value_segment_code := NULL;
45336
45337 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45338 l_bflow_class_code := ''; -- 4219869 Business Flow
45339 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45340 l_budgetary_control_flag := 'N';
45341
45342 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45343 l_bflow_applied_to_amt := NULL; -- 5132302
45344 l_entered_amt_idx := NULL; -- 4262811
45345 l_accted_amt_idx := NULL; -- 4262811
45346 l_acc_rev_flag := NULL; -- 4262811
45347 l_accrual_line_num := NULL; -- 4262811
45348 l_tmp_amt := NULL; -- 4262811
45349 --
45350
45351 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45352 l_balance_type_code <> 'B' THEN
45353 IF NVL(p_source_97,9E125) = 13
45354 THEN
45355
45356 --
45357 XLA_AE_LINES_PKG.SetNewLine;
45358
45359 p_balance_type_code := l_balance_type_code;
45360 -- set the flag so later we will know whether the gain loss line needs to be created
45361
45362 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45363 p_actual_flag :='A';
45364 END IF;
45365
45366 --
45367 -- bulk performance
45368 --
45369 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45370 p_header_num => 0); -- 4262811
45371 --
45372 -- set accounting line options
45373 --
45374 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45375 p_natural_side_code => 'D'
45376 , p_gain_or_loss_flag => 'N'
45377 , p_gl_transfer_mode_code => 'S'
45378 , p_acct_entry_type_code => 'A'
45379 , p_switch_side_flag => 'Y'
45380 , p_merge_duplicate_code => 'N'
45381 );
45382 --
45383 l_acc_rev_natural_side_code := 'C'; -- 4262811
45384 --
45385 --
45386 -- set accounting line type info
45387 --
45388 xla_ae_lines_pkg.SetAcctLineType
45389 (p_component_type => l_component_type
45390 ,p_event_type_code => l_event_type_code
45391 ,p_line_definition_owner_code => l_line_definition_owner_code
45392 ,p_line_definition_code => l_line_definition_code
45393 ,p_accounting_line_code => l_component_code
45394 ,p_accounting_line_type_code => l_component_type_code
45395 ,p_accounting_line_appl_id => l_component_appl_id
45396 ,p_amb_context_code => l_amb_context_code
45397 ,p_entity_code => l_entity_code
45398 ,p_event_class_code => l_event_class_code);
45399 --
45400 -- set accounting class
45401 --
45402 xla_ae_lines_pkg.SetAcctClass(
45403 p_accounting_class_code => 'COST_VARIANCE'
45404 , p_ae_header_id => l_ae_header_id
45405 );
45406
45407 --
45408 -- set rounding class
45409 --
45410 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45411 'COST_VARIANCE';
45412
45413 --
45414 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45415 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45416 --
45417 -- bulk performance
45418 --
45419 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45420
45421 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
45422 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
45423
45424 -- 4955764
45425 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45426 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45427
45428 -- 4458381 Public Sector Enh
45429
45430 --
45431 -- set accounting attributes for the line type
45432 --
45433 l_entered_amt_idx := 3;
45434 l_accted_amt_idx := 8;
45435 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45436 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
45437 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
45438 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
45439 l_rec_acct_attrs.array_char_value(2) := p_source_85;
45440 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
45441 l_rec_acct_attrs.array_num_value(3) := p_source_91;
45442 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
45443 l_rec_acct_attrs.array_char_value(4) := p_source_88;
45444 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
45445 l_rec_acct_attrs.array_date_value(5) := p_source_92;
45446 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
45447 l_rec_acct_attrs.array_num_value(6) := p_source_93;
45448 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
45449 l_rec_acct_attrs.array_char_value(7) := p_source_94;
45450 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
45451 l_rec_acct_attrs.array_num_value(8) := p_source_95;
45452
45453 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45454 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45455
45456 ---------------------------------------------------------------------------------------------------------------
45457 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45458 ---------------------------------------------------------------------------------------------------------------
45459 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45460
45461 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45462 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45463
45464 IF xla_accounting_cache_pkg.GetValueChar
45465 (p_source_code => 'LEDGER_CATEGORY_CODE'
45466 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45467 AND l_bflow_method_code = 'PRIOR_ENTRY'
45468 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45469 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45470 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45471 )
45472 THEN
45473 xla_ae_lines_pkg.BflowUpgEntry
45474 (p_business_method_code => l_bflow_method_code
45475 ,p_business_class_code => l_bflow_class_code
45476 ,p_balance_type => l_balance_type_code);
45477 ELSE
45478 NULL;
45479 -- No business flow processing for business flow method of NONE.
45480 END IF;
45481
45482 --
45483 -- call analytical criteria
45484 --
45485
45486 --
45487 -- call description
45488 --
45489
45490 xla_ae_lines_pkg.SetLineDescription(
45491 p_ae_header_id => l_ae_header_id
45492 ,p_description => Description_1 (
45493 p_application_id => p_application_id
45494 , p_ae_header_id => l_ae_header_id
45495 , p_source_1 => p_source_1
45496 , p_source_2 => p_source_2
45497 , p_source_3 => p_source_3
45498 , p_source_4 => p_source_4
45499 , p_source_5 => p_source_5
45500 )
45501 );
45502
45503
45504 --
45505 -- call ADRs
45506 -- Bug 4922099
45507 --
45508 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45509 (NVL(l_actual_upg_option, 'N') = 'O') OR
45510 (NVL(l_enc_upg_option, 'N') = 'O')
45511 )
45512 THEN
45513 NULL;
45514 --
45515 --
45516
45517 l_ccid := AcctDerRule_6(
45518 p_application_id => p_application_id
45519 , p_ae_header_id => l_ae_header_id
45520 , p_source_11 => p_source_11
45521 , x_transaction_coa_id => l_adr_transaction_coa_id
45522 , x_accounting_coa_id => l_adr_accounting_coa_id
45523 , x_value_type_code => l_adr_value_type_code
45524 , p_side => 'NA'
45525 );
45526
45527 xla_ae_lines_pkg.set_ccid(
45528 p_code_combination_id => l_ccid
45529 , p_value_type_code => l_adr_value_type_code
45530 , p_transaction_coa_id => l_adr_transaction_coa_id
45531 , p_accounting_coa_id => l_adr_accounting_coa_id
45532 , p_adr_code => 'CST_DEFAULT'
45533 , p_adr_type_code => 'S'
45534 , p_component_type => l_component_type
45535 , p_component_code => l_component_code
45536 , p_component_type_code => l_component_type_code
45537 , p_component_appl_id => l_component_appl_id
45538 , p_amb_context_code => l_amb_context_code
45539 , p_side => 'NA'
45540 );
45541
45542
45543 --
45544 --
45545 END IF;
45546 --
45547 -- Bug 4922099
45548 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45549 (NVL(l_enc_upg_option, 'N') = 'O')
45550 ) AND
45551 (l_bflow_method_code = 'PRIOR_ENTRY')
45552 )
45553 THEN
45554 IF
45555 --
45556 1 = 2
45557 --
45558 THEN
45559 xla_accounting_err_pkg.build_message
45560 (p_appli_s_name => 'XLA'
45561 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45562 ,p_token_1 => 'LINE_NUMBER'
45563 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45564 ,p_token_2 => 'LINE_TYPE_NAME'
45565 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45566 l_component_type
45567 ,l_component_code
45568 ,l_component_type_code
45569 ,l_component_appl_id
45570 ,l_amb_context_code
45571 ,l_entity_code
45572 ,l_event_class_code
45573 )
45574 ,p_token_3 => 'OWNER'
45575 ,p_value_3 => xla_lookups_pkg.get_meaning(
45576 p_lookup_type => 'XLA_OWNER_TYPE'
45577 ,p_lookup_code => l_component_type_code
45578 )
45579 ,p_token_4 => 'PRODUCT_NAME'
45580 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45581 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45582 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45583 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45584 ,p_ae_header_id => NULL
45585 );
45586
45587 IF (C_LEVEL_ERROR>= g_log_level) THEN
45588 trace
45589 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45590 ,p_level => C_LEVEL_ERROR
45591 ,p_module => l_log_module);
45592 END IF;
45593 END IF;
45594 END IF;
45595 --
45596 --
45597 ------------------------------------------------------------------------------------------------
45598 -- 4219869 Business Flow
45599 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45600 -- Prior Entry. Currently, the following code is always generated.
45601 ------------------------------------------------------------------------------------------------
45602 XLA_AE_LINES_PKG.ValidateCurrentLine;
45603
45604 ------------------------------------------------------------------------------------
45605 -- 4219869 Business Flow
45606 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45607 ------------------------------------------------------------------------------------
45608 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45609
45610 ----------------------------------------------------------------------------------
45611 -- 4219869 Business Flow
45612 -- Update journal entry status -- Need to generate this within IF <condition>
45613 ----------------------------------------------------------------------------------
45614 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45615 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45616 ,p_balance_type_code => l_balance_type_code
45617 );
45618
45619 -------------------------------------------------------------------------------------------
45620 -- 4262811 - Generate the Accrual Reversal lines
45621 -------------------------------------------------------------------------------------------
45622 BEGIN
45623 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45624 (g_array_event(p_event_id).array_value_num('header_index'));
45625 IF l_acc_rev_flag IS NULL THEN
45626 l_acc_rev_flag := 'N';
45627 END IF;
45628 EXCEPTION
45629 WHEN OTHERS THEN
45630 l_acc_rev_flag := 'N';
45631 END;
45632 --
45633 IF (l_acc_rev_flag = 'Y') THEN
45634
45635 -- 4645092 ------------------------------------------------------------------------------
45636 -- To allow MPA report to determine if it should generate report process
45637 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45638 ------------------------------------------------------------------------------------------
45639
45640 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45641 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45642 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45643 -- call ADRs
45644 -- Bug 4922099
45645 --
45646 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45647 (NVL(l_actual_upg_option, 'N') = 'O') OR
45648 (NVL(l_enc_upg_option, 'N') = 'O')
45649 )
45650 THEN
45651 NULL;
45652 --
45653 --
45654
45655 l_ccid := AcctDerRule_6(
45656 p_application_id => p_application_id
45657 , p_ae_header_id => l_ae_header_id
45658 , p_source_11 => p_source_11
45659 , x_transaction_coa_id => l_adr_transaction_coa_id
45660 , x_accounting_coa_id => l_adr_accounting_coa_id
45661 , x_value_type_code => l_adr_value_type_code
45662 , p_side => 'NA'
45663 );
45664
45665 xla_ae_lines_pkg.set_ccid(
45666 p_code_combination_id => l_ccid
45667 , p_value_type_code => l_adr_value_type_code
45668 , p_transaction_coa_id => l_adr_transaction_coa_id
45669 , p_accounting_coa_id => l_adr_accounting_coa_id
45670 , p_adr_code => 'CST_DEFAULT'
45671 , p_adr_type_code => 'S'
45672 , p_component_type => l_component_type
45673 , p_component_code => l_component_code
45674 , p_component_type_code => l_component_type_code
45675 , p_component_appl_id => l_component_appl_id
45676 , p_amb_context_code => l_amb_context_code
45677 , p_side => 'NA'
45678 );
45679
45680
45681 --
45682 --
45683 END IF;
45684
45685 --
45686 -- Update the line information that should be overwritten
45687 --
45688 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45689 p_header_num => 1);
45690 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45691
45692 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45693
45694 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45695 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45696 END IF;
45697
45698 --
45699 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45700 --
45701 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45702 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45703 ELSE
45704 ---------------------------------------------------------------------------------------------------
45705 -- 4262811a Switch Sign
45706 ---------------------------------------------------------------------------------------------------
45707 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45708 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45709 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45710 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45711 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45712 -- 5132302
45713 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45714 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45715
45716 END IF;
45717
45718 -- 4955764
45719 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45720 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45721
45722
45723 XLA_AE_LINES_PKG.ValidateCurrentLine;
45724 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45725
45726 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45727 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45728 ,p_balance_type_code => l_balance_type_code);
45729
45730 END IF;
45731
45732 -----------------------------------------------------------------------------------------
45733 -- 4262811 Multiperiod Accounting
45734 -----------------------------------------------------------------------------------------
45735 -- No MPA option is assigned.
45736
45737
45738 END IF;
45739 END IF;
45740 --
45741
45742 --
45743 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45744 trace
45745 (p_msg => 'END of AcctLineType_105'
45746 ,p_level => C_LEVEL_PROCEDURE
45747 ,p_module => l_log_module);
45748 END IF;
45749 --
45750 EXCEPTION
45751 WHEN xla_exceptions_pkg.application_exception THEN
45752 RAISE;
45753 WHEN OTHERS THEN
45754 xla_exceptions_pkg.raise_message
45755 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_105');
45756 END AcctLineType_105;
45757 --
45758
45759 ---------------------------------------
45760 --
45761 -- PRIVATE FUNCTION
45762 -- AcctLineType_106
45763 --
45764 ---------------------------------------
45765 PROCEDURE AcctLineType_106 (
45766 p_application_id IN NUMBER
45767 ,p_event_id IN NUMBER
45768 ,p_calculate_acctd_flag IN VARCHAR2
45769 ,p_calculate_g_l_flag IN VARCHAR2
45770 ,p_actual_flag IN OUT VARCHAR2
45771 ,p_balance_type_code OUT VARCHAR2
45772 ,p_gain_or_loss_ref OUT VARCHAR2
45773
45774 --TRANSACTION_ID
45775 , p_source_1 IN NUMBER
45776 --Item Concatenated Segments
45777 , p_source_2 IN VARCHAR2
45778 --Transaction Quantity
45779 , p_source_3 IN NUMBER
45780 --Transaction Unit of Measure Code
45781 , p_source_4 IN VARCHAR2
45782 --Inventory Transaction Type Description
45783 , p_source_5 IN VARCHAR2
45784 --Cost Management Default Account
45785 , p_source_11 IN NUMBER
45786 --DISTRIBUTION_IDENTIFIER
45787 , p_source_84 IN NUMBER
45788 --Distribution Type
45789 , p_source_85 IN VARCHAR2
45790 , p_source_85_meaning IN VARCHAR2
45791 --Entered Currency Code
45792 , p_source_88 IN VARCHAR2
45793 --Entered Amount
45794 , p_source_91 IN NUMBER
45795 --Currency Conversion Date
45796 , p_source_92 IN DATE
45797 --Currency Conversion Rate
45798 , p_source_93 IN NUMBER
45799 --Currency Conversion Type
45800 , p_source_94 IN VARCHAR2
45801 --Accounted Amount
45802 , p_source_95 IN NUMBER
45803 --Accounting Line Type
45804 , p_source_97 IN NUMBER
45805 )
45806 IS
45807
45808 l_component_type VARCHAR2(80);
45809 l_component_code VARCHAR2(30);
45810 l_component_type_code VARCHAR2(1);
45811 l_component_appl_id INTEGER;
45812 l_amb_context_code VARCHAR2(30);
45813 l_entity_code VARCHAR2(30);
45814 l_event_class_code VARCHAR2(30);
45815 l_ae_header_id NUMBER;
45816 l_event_type_code VARCHAR2(30);
45817 l_line_definition_code VARCHAR2(30);
45818 l_line_definition_owner_code VARCHAR2(1);
45819 --
45820 -- adr variables
45821 l_segment VARCHAR2(30);
45822 l_ccid NUMBER;
45823 l_adr_transaction_coa_id NUMBER;
45824 l_adr_accounting_coa_id NUMBER;
45825 l_adr_flexfield_segment_code VARCHAR2(30);
45826 l_adr_flex_value_set_id NUMBER;
45827 l_adr_value_type_code VARCHAR2(30);
45828 l_adr_value_combination_id NUMBER;
45829 l_adr_value_segment_code VARCHAR2(30);
45830
45831 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45832 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45833 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45834 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45835
45836 -- 4262811 Variables ------------------------------------------------------------------------------------------
45837 l_entered_amt_idx NUMBER;
45838 l_accted_amt_idx NUMBER;
45839 l_acc_rev_flag VARCHAR2(1);
45840 l_accrual_line_num NUMBER;
45841 l_tmp_amt NUMBER;
45842 l_acc_rev_natural_side_code VARCHAR2(1);
45843
45844 l_num_entries NUMBER;
45845 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45846 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45847 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45848 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45849 l_recog_line_1 NUMBER;
45850 l_recog_line_2 NUMBER;
45851
45852 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45853 l_bflow_applied_to_amt NUMBER; -- 5132302
45854 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45855
45856 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45857
45858 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45859 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45860
45861 ---------------------------------------------------------------------------------------------------------------
45862
45863
45864 --
45865 -- bulk performance
45866 --
45867 l_balance_type_code VARCHAR2(1);
45868 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45869 l_log_module VARCHAR2(240);
45870
45871 --
45872 -- Upgrade strategy
45873 --
45874 l_actual_upg_option VARCHAR2(1);
45875 l_enc_upg_option VARCHAR2(1);
45876
45877 --
45878 BEGIN
45879 --
45880 IF g_log_enabled THEN
45881 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_106';
45882 END IF;
45883 --
45884 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45885
45886 trace
45887 (p_msg => 'BEGIN of AcctLineType_106'
45888 ,p_level => C_LEVEL_PROCEDURE
45889 ,p_module => l_log_module);
45890
45891 END IF;
45892 --
45893 l_component_type := 'AMB_JLT';
45894 l_component_code := 'COST_VARIANCE';
45895 l_component_type_code := 'S';
45896 l_component_appl_id := 707;
45897 l_amb_context_code := 'DEFAULT';
45898 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
45899 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
45900 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
45901 l_line_definition_owner_code := 'S';
45902 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
45903 --
45904 l_balance_type_code := 'A';
45905 l_segment := NULL;
45906 l_ccid := NULL;
45907 l_adr_transaction_coa_id := NULL;
45908 l_adr_accounting_coa_id := NULL;
45909 l_adr_flexfield_segment_code := NULL;
45910 l_adr_flex_value_set_id := NULL;
45911 l_adr_value_type_code := NULL;
45912 l_adr_value_combination_id := NULL;
45913 l_adr_value_segment_code := NULL;
45914
45915 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45916 l_bflow_class_code := ''; -- 4219869 Business Flow
45917 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45918 l_budgetary_control_flag := 'N';
45919
45920 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45921 l_bflow_applied_to_amt := NULL; -- 5132302
45922 l_entered_amt_idx := NULL; -- 4262811
45923 l_accted_amt_idx := NULL; -- 4262811
45924 l_acc_rev_flag := NULL; -- 4262811
45925 l_accrual_line_num := NULL; -- 4262811
45926 l_tmp_amt := NULL; -- 4262811
45927 --
45928
45929 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45930 l_balance_type_code <> 'B' THEN
45931 IF NVL(p_source_97,9E125) = 13
45932 THEN
45933
45934 --
45935 XLA_AE_LINES_PKG.SetNewLine;
45936
45937 p_balance_type_code := l_balance_type_code;
45938 -- set the flag so later we will know whether the gain loss line needs to be created
45939
45940 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45941 p_actual_flag :='A';
45942 END IF;
45943
45944 --
45945 -- bulk performance
45946 --
45947 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45948 p_header_num => 0); -- 4262811
45949 --
45950 -- set accounting line options
45951 --
45952 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45953 p_natural_side_code => 'D'
45954 , p_gain_or_loss_flag => 'N'
45955 , p_gl_transfer_mode_code => 'S'
45956 , p_acct_entry_type_code => 'A'
45957 , p_switch_side_flag => 'Y'
45958 , p_merge_duplicate_code => 'N'
45959 );
45960 --
45961 l_acc_rev_natural_side_code := 'C'; -- 4262811
45962 --
45963 --
45964 -- set accounting line type info
45965 --
45966 xla_ae_lines_pkg.SetAcctLineType
45967 (p_component_type => l_component_type
45968 ,p_event_type_code => l_event_type_code
45969 ,p_line_definition_owner_code => l_line_definition_owner_code
45970 ,p_line_definition_code => l_line_definition_code
45971 ,p_accounting_line_code => l_component_code
45972 ,p_accounting_line_type_code => l_component_type_code
45973 ,p_accounting_line_appl_id => l_component_appl_id
45974 ,p_amb_context_code => l_amb_context_code
45975 ,p_entity_code => l_entity_code
45976 ,p_event_class_code => l_event_class_code);
45977 --
45978 -- set accounting class
45979 --
45980 xla_ae_lines_pkg.SetAcctClass(
45981 p_accounting_class_code => 'COST_VARIANCE'
45982 , p_ae_header_id => l_ae_header_id
45983 );
45984
45985 --
45986 -- set rounding class
45987 --
45988 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45989 'COST_VARIANCE';
45990
45991 --
45992 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45993 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45994 --
45995 -- bulk performance
45996 --
45997 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45998
45999 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46000 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46001
46002 -- 4955764
46003 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46004 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46005
46006 -- 4458381 Public Sector Enh
46007
46008 --
46009 -- set accounting attributes for the line type
46010 --
46011 l_entered_amt_idx := 3;
46012 l_accted_amt_idx := 8;
46013 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46014 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
46015 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
46016 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
46017 l_rec_acct_attrs.array_char_value(2) := p_source_85;
46018 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
46019 l_rec_acct_attrs.array_num_value(3) := p_source_91;
46020 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
46021 l_rec_acct_attrs.array_char_value(4) := p_source_88;
46022 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
46023 l_rec_acct_attrs.array_date_value(5) := p_source_92;
46024 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
46025 l_rec_acct_attrs.array_num_value(6) := p_source_93;
46026 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
46027 l_rec_acct_attrs.array_char_value(7) := p_source_94;
46028 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
46029 l_rec_acct_attrs.array_num_value(8) := p_source_95;
46030
46031 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46032 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46033
46034 ---------------------------------------------------------------------------------------------------------------
46035 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46036 ---------------------------------------------------------------------------------------------------------------
46037 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46038
46039 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46040 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46041
46042 IF xla_accounting_cache_pkg.GetValueChar
46043 (p_source_code => 'LEDGER_CATEGORY_CODE'
46044 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46045 AND l_bflow_method_code = 'PRIOR_ENTRY'
46046 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46047 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46048 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46049 )
46050 THEN
46051 xla_ae_lines_pkg.BflowUpgEntry
46052 (p_business_method_code => l_bflow_method_code
46053 ,p_business_class_code => l_bflow_class_code
46054 ,p_balance_type => l_balance_type_code);
46055 ELSE
46056 NULL;
46057 -- No business flow processing for business flow method of NONE.
46058 END IF;
46059
46060 --
46061 -- call analytical criteria
46062 --
46063
46064 --
46065 -- call description
46066 --
46067
46068 xla_ae_lines_pkg.SetLineDescription(
46069 p_ae_header_id => l_ae_header_id
46070 ,p_description => Description_1 (
46071 p_application_id => p_application_id
46072 , p_ae_header_id => l_ae_header_id
46073 , p_source_1 => p_source_1
46074 , p_source_2 => p_source_2
46075 , p_source_3 => p_source_3
46076 , p_source_4 => p_source_4
46077 , p_source_5 => p_source_5
46078 )
46079 );
46080
46081
46082 --
46083 -- call ADRs
46084 -- Bug 4922099
46085 --
46086 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46087 (NVL(l_actual_upg_option, 'N') = 'O') OR
46088 (NVL(l_enc_upg_option, 'N') = 'O')
46089 )
46090 THEN
46091 NULL;
46092 --
46093 --
46094
46095 l_ccid := AcctDerRule_6(
46096 p_application_id => p_application_id
46097 , p_ae_header_id => l_ae_header_id
46098 , p_source_11 => p_source_11
46099 , x_transaction_coa_id => l_adr_transaction_coa_id
46100 , x_accounting_coa_id => l_adr_accounting_coa_id
46101 , x_value_type_code => l_adr_value_type_code
46102 , p_side => 'NA'
46103 );
46104
46105 xla_ae_lines_pkg.set_ccid(
46106 p_code_combination_id => l_ccid
46107 , p_value_type_code => l_adr_value_type_code
46108 , p_transaction_coa_id => l_adr_transaction_coa_id
46109 , p_accounting_coa_id => l_adr_accounting_coa_id
46110 , p_adr_code => 'CST_DEFAULT'
46111 , p_adr_type_code => 'S'
46112 , p_component_type => l_component_type
46113 , p_component_code => l_component_code
46114 , p_component_type_code => l_component_type_code
46115 , p_component_appl_id => l_component_appl_id
46116 , p_amb_context_code => l_amb_context_code
46117 , p_side => 'NA'
46118 );
46119
46120
46121 --
46122 --
46123 END IF;
46124 --
46125 -- Bug 4922099
46126 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46127 (NVL(l_enc_upg_option, 'N') = 'O')
46128 ) AND
46129 (l_bflow_method_code = 'PRIOR_ENTRY')
46130 )
46131 THEN
46132 IF
46133 --
46134 1 = 2
46135 --
46136 THEN
46137 xla_accounting_err_pkg.build_message
46138 (p_appli_s_name => 'XLA'
46139 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46140 ,p_token_1 => 'LINE_NUMBER'
46141 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46142 ,p_token_2 => 'LINE_TYPE_NAME'
46143 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46144 l_component_type
46145 ,l_component_code
46146 ,l_component_type_code
46147 ,l_component_appl_id
46148 ,l_amb_context_code
46149 ,l_entity_code
46150 ,l_event_class_code
46151 )
46152 ,p_token_3 => 'OWNER'
46153 ,p_value_3 => xla_lookups_pkg.get_meaning(
46154 p_lookup_type => 'XLA_OWNER_TYPE'
46155 ,p_lookup_code => l_component_type_code
46156 )
46157 ,p_token_4 => 'PRODUCT_NAME'
46158 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46159 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46160 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46161 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46162 ,p_ae_header_id => NULL
46163 );
46164
46165 IF (C_LEVEL_ERROR>= g_log_level) THEN
46166 trace
46167 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46168 ,p_level => C_LEVEL_ERROR
46169 ,p_module => l_log_module);
46170 END IF;
46171 END IF;
46172 END IF;
46173 --
46174 --
46175 ------------------------------------------------------------------------------------------------
46176 -- 4219869 Business Flow
46177 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46178 -- Prior Entry. Currently, the following code is always generated.
46179 ------------------------------------------------------------------------------------------------
46180 XLA_AE_LINES_PKG.ValidateCurrentLine;
46181
46182 ------------------------------------------------------------------------------------
46183 -- 4219869 Business Flow
46184 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46185 ------------------------------------------------------------------------------------
46186 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46187
46188 ----------------------------------------------------------------------------------
46189 -- 4219869 Business Flow
46190 -- Update journal entry status -- Need to generate this within IF <condition>
46191 ----------------------------------------------------------------------------------
46192 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46193 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46194 ,p_balance_type_code => l_balance_type_code
46195 );
46196
46197 -------------------------------------------------------------------------------------------
46198 -- 4262811 - Generate the Accrual Reversal lines
46199 -------------------------------------------------------------------------------------------
46200 BEGIN
46201 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46202 (g_array_event(p_event_id).array_value_num('header_index'));
46203 IF l_acc_rev_flag IS NULL THEN
46204 l_acc_rev_flag := 'N';
46205 END IF;
46206 EXCEPTION
46207 WHEN OTHERS THEN
46208 l_acc_rev_flag := 'N';
46209 END;
46210 --
46211 IF (l_acc_rev_flag = 'Y') THEN
46212
46213 -- 4645092 ------------------------------------------------------------------------------
46214 -- To allow MPA report to determine if it should generate report process
46215 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46216 ------------------------------------------------------------------------------------------
46217
46218 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46219 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46220 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46221 -- call ADRs
46222 -- Bug 4922099
46223 --
46224 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46225 (NVL(l_actual_upg_option, 'N') = 'O') OR
46226 (NVL(l_enc_upg_option, 'N') = 'O')
46227 )
46228 THEN
46229 NULL;
46230 --
46231 --
46232
46233 l_ccid := AcctDerRule_6(
46234 p_application_id => p_application_id
46235 , p_ae_header_id => l_ae_header_id
46236 , p_source_11 => p_source_11
46237 , x_transaction_coa_id => l_adr_transaction_coa_id
46238 , x_accounting_coa_id => l_adr_accounting_coa_id
46239 , x_value_type_code => l_adr_value_type_code
46240 , p_side => 'NA'
46241 );
46242
46243 xla_ae_lines_pkg.set_ccid(
46244 p_code_combination_id => l_ccid
46245 , p_value_type_code => l_adr_value_type_code
46246 , p_transaction_coa_id => l_adr_transaction_coa_id
46247 , p_accounting_coa_id => l_adr_accounting_coa_id
46248 , p_adr_code => 'CST_DEFAULT'
46249 , p_adr_type_code => 'S'
46250 , p_component_type => l_component_type
46251 , p_component_code => l_component_code
46252 , p_component_type_code => l_component_type_code
46253 , p_component_appl_id => l_component_appl_id
46254 , p_amb_context_code => l_amb_context_code
46255 , p_side => 'NA'
46256 );
46257
46258
46259 --
46260 --
46261 END IF;
46262
46263 --
46264 -- Update the line information that should be overwritten
46265 --
46266 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46267 p_header_num => 1);
46268 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46269
46270 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46271
46272 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46273 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46274 END IF;
46275
46276 --
46277 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46278 --
46279 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46280 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46281 ELSE
46282 ---------------------------------------------------------------------------------------------------
46283 -- 4262811a Switch Sign
46284 ---------------------------------------------------------------------------------------------------
46285 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46286 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46287 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46288 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46289 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46290 -- 5132302
46291 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46292 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46293
46294 END IF;
46295
46296 -- 4955764
46297 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46298 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46299
46300
46301 XLA_AE_LINES_PKG.ValidateCurrentLine;
46302 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46303
46304 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46305 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46306 ,p_balance_type_code => l_balance_type_code);
46307
46308 END IF;
46309
46310 -----------------------------------------------------------------------------------------
46311 -- 4262811 Multiperiod Accounting
46312 -----------------------------------------------------------------------------------------
46313 -- No MPA option is assigned.
46314
46315
46316 END IF;
46317 END IF;
46318 --
46319
46320 --
46321 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46322 trace
46323 (p_msg => 'END of AcctLineType_106'
46324 ,p_level => C_LEVEL_PROCEDURE
46325 ,p_module => l_log_module);
46326 END IF;
46327 --
46328 EXCEPTION
46329 WHEN xla_exceptions_pkg.application_exception THEN
46330 RAISE;
46331 WHEN OTHERS THEN
46332 xla_exceptions_pkg.raise_message
46333 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_106');
46334 END AcctLineType_106;
46335 --
46336
46337 ---------------------------------------
46338 --
46339 -- PRIVATE FUNCTION
46340 -- AcctLineType_107
46341 --
46342 ---------------------------------------
46343 PROCEDURE AcctLineType_107 (
46344 p_application_id IN NUMBER
46345 ,p_event_id IN NUMBER
46346 ,p_calculate_acctd_flag IN VARCHAR2
46347 ,p_calculate_g_l_flag IN VARCHAR2
46348 ,p_actual_flag IN OUT VARCHAR2
46349 ,p_balance_type_code OUT VARCHAR2
46350 ,p_gain_or_loss_ref OUT VARCHAR2
46351
46352 --TRANSACTION_ID
46353 , p_source_1 IN NUMBER
46354 --Item Concatenated Segments
46355 , p_source_2 IN VARCHAR2
46356 --Transaction Quantity
46357 , p_source_3 IN NUMBER
46358 --Transaction Unit of Measure Code
46359 , p_source_4 IN VARCHAR2
46360 --Inventory Transaction Type Description
46361 , p_source_5 IN VARCHAR2
46362 --Cost Management Default Account
46363 , p_source_11 IN NUMBER
46364 --Applied to Application ID
46365 , p_source_79 IN NUMBER
46366 --Applied to Distribution Link Type
46367 , p_source_80 IN VARCHAR2
46368 --Applied to Entity Code
46369 , p_source_81 IN VARCHAR2
46370 --Applied To Purchase Document Identifier
46371 , p_source_83 IN NUMBER
46372 --DISTRIBUTION_IDENTIFIER
46373 , p_source_84 IN NUMBER
46374 --Distribution Type
46375 , p_source_85 IN VARCHAR2
46376 , p_source_85_meaning IN VARCHAR2
46377 --PO Budget Account
46378 , p_source_86 IN NUMBER
46379 --Encumbrance Reversal Amount Entered
46380 , p_source_87 IN NUMBER
46381 --Entered Currency Code
46382 , p_source_88 IN VARCHAR2
46383 --Transaction Encumbrance Reversal Amount
46384 , p_source_89 IN NUMBER
46385 --Entered Amount
46386 , p_source_91 IN NUMBER
46387 --Currency Conversion Date
46388 , p_source_92 IN DATE
46389 --Currency Conversion Rate
46390 , p_source_93 IN NUMBER
46391 --Currency Conversion Type
46392 , p_source_94 IN VARCHAR2
46393 --Accounted Amount
46394 , p_source_95 IN NUMBER
46395 --Purchasing Encumbrance Type Identifier
46396 , p_source_96 IN NUMBER
46397 --Accounting Line Type
46398 , p_source_97 IN NUMBER
46399 --Costing Encumbrance Upgrade Option
46400 , p_source_100 IN VARCHAR2
46401 --TXN_PO_DISTRIBUTION_ID
46402 , p_source_101 IN NUMBER
46403 )
46404 IS
46405
46406 l_component_type VARCHAR2(80);
46407 l_component_code VARCHAR2(30);
46408 l_component_type_code VARCHAR2(1);
46409 l_component_appl_id INTEGER;
46410 l_amb_context_code VARCHAR2(30);
46411 l_entity_code VARCHAR2(30);
46412 l_event_class_code VARCHAR2(30);
46413 l_ae_header_id NUMBER;
46414 l_event_type_code VARCHAR2(30);
46415 l_line_definition_code VARCHAR2(30);
46416 l_line_definition_owner_code VARCHAR2(1);
46417 --
46418 -- adr variables
46419 l_segment VARCHAR2(30);
46420 l_ccid NUMBER;
46421 l_adr_transaction_coa_id NUMBER;
46422 l_adr_accounting_coa_id NUMBER;
46423 l_adr_flexfield_segment_code VARCHAR2(30);
46424 l_adr_flex_value_set_id NUMBER;
46425 l_adr_value_type_code VARCHAR2(30);
46426 l_adr_value_combination_id NUMBER;
46427 l_adr_value_segment_code VARCHAR2(30);
46428
46429 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
46430 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
46431 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
46432 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
46433
46434 -- 4262811 Variables ------------------------------------------------------------------------------------------
46435 l_entered_amt_idx NUMBER;
46436 l_accted_amt_idx NUMBER;
46437 l_acc_rev_flag VARCHAR2(1);
46438 l_accrual_line_num NUMBER;
46439 l_tmp_amt NUMBER;
46440 l_acc_rev_natural_side_code VARCHAR2(1);
46441
46442 l_num_entries NUMBER;
46443 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
46444 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
46445 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
46446 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
46447 l_recog_line_1 NUMBER;
46448 l_recog_line_2 NUMBER;
46449
46450 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
46451 l_bflow_applied_to_amt NUMBER; -- 5132302
46452 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
46453
46454 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
46455
46456 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
46457 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
46458
46459 ---------------------------------------------------------------------------------------------------------------
46460
46461
46462 --
46463 -- bulk performance
46464 --
46465 l_balance_type_code VARCHAR2(1);
46466 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
46467 l_log_module VARCHAR2(240);
46468
46469 --
46470 -- Upgrade strategy
46471 --
46472 l_actual_upg_option VARCHAR2(1);
46473 l_enc_upg_option VARCHAR2(1);
46474
46475 --
46476 BEGIN
46477 --
46478 IF g_log_enabled THEN
46479 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_107';
46480 END IF;
46481 --
46482 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46483
46484 trace
46485 (p_msg => 'BEGIN of AcctLineType_107'
46486 ,p_level => C_LEVEL_PROCEDURE
46487 ,p_module => l_log_module);
46488
46489 END IF;
46490 --
46491 l_component_type := 'AMB_JLT';
46492 l_component_code := 'COST_VARIANCE';
46493 l_component_type_code := 'S';
46494 l_component_appl_id := 707;
46495 l_amb_context_code := 'DEFAULT';
46496 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
46497 l_event_class_code := 'PURCHASE_ORDER';
46498 l_event_type_code := 'LOG_PO_DEL_INV';
46499 l_line_definition_owner_code := 'S';
46500 l_line_definition_code := 'PI_LOG_DEL_INV';
46501 --
46502 l_balance_type_code := 'A';
46503 l_segment := NULL;
46504 l_ccid := NULL;
46505 l_adr_transaction_coa_id := NULL;
46506 l_adr_accounting_coa_id := NULL;
46507 l_adr_flexfield_segment_code := NULL;
46508 l_adr_flex_value_set_id := NULL;
46509 l_adr_value_type_code := NULL;
46510 l_adr_value_combination_id := NULL;
46511 l_adr_value_segment_code := NULL;
46512
46513 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
46514 l_bflow_class_code := ''; -- 4219869 Business Flow
46515 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46516 l_budgetary_control_flag := 'N';
46517
46518 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46519 l_bflow_applied_to_amt := NULL; -- 5132302
46520 l_entered_amt_idx := NULL; -- 4262811
46521 l_accted_amt_idx := NULL; -- 4262811
46522 l_acc_rev_flag := NULL; -- 4262811
46523 l_accrual_line_num := NULL; -- 4262811
46524 l_tmp_amt := NULL; -- 4262811
46525 --
46526
46527 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46528 l_balance_type_code <> 'B' THEN
46529 IF NVL(p_source_97,9E125) = 13
46530 THEN
46531
46532 --
46533 XLA_AE_LINES_PKG.SetNewLine;
46534
46535 p_balance_type_code := l_balance_type_code;
46536 -- set the flag so later we will know whether the gain loss line needs to be created
46537
46538 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46539 p_actual_flag :='A';
46540 END IF;
46541
46542 --
46543 -- bulk performance
46544 --
46545 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46546 p_header_num => 0); -- 4262811
46547 --
46548 -- set accounting line options
46549 --
46550 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46551 p_natural_side_code => 'D'
46552 , p_gain_or_loss_flag => 'N'
46553 , p_gl_transfer_mode_code => 'S'
46554 , p_acct_entry_type_code => 'A'
46555 , p_switch_side_flag => 'Y'
46556 , p_merge_duplicate_code => 'N'
46557 );
46558 --
46559 l_acc_rev_natural_side_code := 'C'; -- 4262811
46560 --
46561 --
46562 -- set accounting line type info
46563 --
46564 xla_ae_lines_pkg.SetAcctLineType
46565 (p_component_type => l_component_type
46566 ,p_event_type_code => l_event_type_code
46567 ,p_line_definition_owner_code => l_line_definition_owner_code
46568 ,p_line_definition_code => l_line_definition_code
46569 ,p_accounting_line_code => l_component_code
46570 ,p_accounting_line_type_code => l_component_type_code
46571 ,p_accounting_line_appl_id => l_component_appl_id
46572 ,p_amb_context_code => l_amb_context_code
46573 ,p_entity_code => l_entity_code
46574 ,p_event_class_code => l_event_class_code);
46575 --
46576 -- set accounting class
46577 --
46578 xla_ae_lines_pkg.SetAcctClass(
46579 p_accounting_class_code => 'COST_VARIANCE'
46580 , p_ae_header_id => l_ae_header_id
46581 );
46582
46583 --
46584 -- set rounding class
46585 --
46586 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46587 'COST_VARIANCE';
46588
46589 --
46590 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46591 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46592 --
46593 -- bulk performance
46594 --
46595 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46596
46597 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46598 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46599
46600 -- 4955764
46601 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46602 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46603
46604 -- 4458381 Public Sector Enh
46605
46606 --
46607 -- set accounting attributes for the line type
46608 --
46609 l_entered_amt_idx := 17;
46610 l_accted_amt_idx := 22;
46611 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46612 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
46613 l_rec_acct_attrs.array_num_value(1) := p_source_79;
46614 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
46615 l_rec_acct_attrs.array_char_value(2) := p_source_80;
46616 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
46617 l_rec_acct_attrs.array_char_value(3) := p_source_81;
46618 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
46619 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
46620 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
46621 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
46622 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
46623 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
46624 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
46625 l_rec_acct_attrs.array_char_value(7) := p_source_85;
46626 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
46627 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
46628 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
46629 l_rec_acct_attrs.array_num_value(9) := p_source_87;
46630 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
46631 l_rec_acct_attrs.array_char_value(10) := p_source_88;
46632 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
46633 l_rec_acct_attrs.array_num_value(11) := p_source_89;
46634 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
46635 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
46636 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
46637 l_rec_acct_attrs.array_num_value(13) := p_source_87;
46638 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
46639 l_rec_acct_attrs.array_char_value(14) := p_source_88;
46640 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
46641 l_rec_acct_attrs.array_num_value(15) := p_source_89;
46642 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
46643 l_rec_acct_attrs.array_char_value(16) := p_source_100;
46644 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
46645 l_rec_acct_attrs.array_num_value(17) := p_source_91;
46646 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
46647 l_rec_acct_attrs.array_char_value(18) := p_source_88;
46648 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
46649 l_rec_acct_attrs.array_date_value(19) := p_source_92;
46650 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
46651 l_rec_acct_attrs.array_num_value(20) := p_source_93;
46652 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
46653 l_rec_acct_attrs.array_char_value(21) := p_source_94;
46654 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
46655 l_rec_acct_attrs.array_num_value(22) := p_source_95;
46656 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
46657 l_rec_acct_attrs.array_num_value(23) := p_source_96;
46658 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
46659 l_rec_acct_attrs.array_num_value(24) := p_source_96;
46660
46661 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46662 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46663
46664 ---------------------------------------------------------------------------------------------------------------
46665 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46666 ---------------------------------------------------------------------------------------------------------------
46667 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46668
46669 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46670 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46671
46672 IF xla_accounting_cache_pkg.GetValueChar
46673 (p_source_code => 'LEDGER_CATEGORY_CODE'
46674 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46675 AND l_bflow_method_code = 'PRIOR_ENTRY'
46676 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46677 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46678 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46679 )
46680 THEN
46681 xla_ae_lines_pkg.BflowUpgEntry
46682 (p_business_method_code => l_bflow_method_code
46683 ,p_business_class_code => l_bflow_class_code
46684 ,p_balance_type => l_balance_type_code);
46685 ELSE
46686 NULL;
46687 -- No business flow processing for business flow method of NONE.
46688 END IF;
46689
46690 --
46691 -- call analytical criteria
46692 --
46693
46694 --
46695 -- call description
46696 --
46697
46698 xla_ae_lines_pkg.SetLineDescription(
46699 p_ae_header_id => l_ae_header_id
46700 ,p_description => Description_1 (
46701 p_application_id => p_application_id
46702 , p_ae_header_id => l_ae_header_id
46703 , p_source_1 => p_source_1
46704 , p_source_2 => p_source_2
46705 , p_source_3 => p_source_3
46706 , p_source_4 => p_source_4
46707 , p_source_5 => p_source_5
46708 )
46709 );
46710
46711
46712 --
46713 -- call ADRs
46714 -- Bug 4922099
46715 --
46716 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46717 (NVL(l_actual_upg_option, 'N') = 'O') OR
46718 (NVL(l_enc_upg_option, 'N') = 'O')
46719 )
46720 THEN
46721 NULL;
46722 --
46723 --
46724
46725 l_ccid := AcctDerRule_6(
46726 p_application_id => p_application_id
46727 , p_ae_header_id => l_ae_header_id
46728 , p_source_11 => p_source_11
46729 , x_transaction_coa_id => l_adr_transaction_coa_id
46730 , x_accounting_coa_id => l_adr_accounting_coa_id
46731 , x_value_type_code => l_adr_value_type_code
46732 , p_side => 'NA'
46733 );
46734
46735 xla_ae_lines_pkg.set_ccid(
46736 p_code_combination_id => l_ccid
46737 , p_value_type_code => l_adr_value_type_code
46738 , p_transaction_coa_id => l_adr_transaction_coa_id
46739 , p_accounting_coa_id => l_adr_accounting_coa_id
46740 , p_adr_code => 'CST_DEFAULT'
46741 , p_adr_type_code => 'S'
46742 , p_component_type => l_component_type
46743 , p_component_code => l_component_code
46744 , p_component_type_code => l_component_type_code
46745 , p_component_appl_id => l_component_appl_id
46746 , p_amb_context_code => l_amb_context_code
46747 , p_side => 'NA'
46748 );
46749
46750
46751 --
46752 --
46753 END IF;
46754 --
46755 -- Bug 4922099
46756 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46757 (NVL(l_enc_upg_option, 'N') = 'O')
46758 ) AND
46759 (l_bflow_method_code = 'PRIOR_ENTRY')
46760 )
46761 THEN
46762 IF
46763 --
46764 1 = 2
46765 --
46766 THEN
46767 xla_accounting_err_pkg.build_message
46768 (p_appli_s_name => 'XLA'
46769 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46770 ,p_token_1 => 'LINE_NUMBER'
46771 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46772 ,p_token_2 => 'LINE_TYPE_NAME'
46773 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46774 l_component_type
46775 ,l_component_code
46776 ,l_component_type_code
46777 ,l_component_appl_id
46778 ,l_amb_context_code
46779 ,l_entity_code
46780 ,l_event_class_code
46781 )
46782 ,p_token_3 => 'OWNER'
46783 ,p_value_3 => xla_lookups_pkg.get_meaning(
46784 p_lookup_type => 'XLA_OWNER_TYPE'
46785 ,p_lookup_code => l_component_type_code
46786 )
46787 ,p_token_4 => 'PRODUCT_NAME'
46788 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46789 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46790 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46791 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46792 ,p_ae_header_id => NULL
46793 );
46794
46795 IF (C_LEVEL_ERROR>= g_log_level) THEN
46796 trace
46797 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46798 ,p_level => C_LEVEL_ERROR
46799 ,p_module => l_log_module);
46800 END IF;
46801 END IF;
46802 END IF;
46803 --
46804 --
46805 ------------------------------------------------------------------------------------------------
46806 -- 4219869 Business Flow
46807 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46808 -- Prior Entry. Currently, the following code is always generated.
46809 ------------------------------------------------------------------------------------------------
46810 XLA_AE_LINES_PKG.ValidateCurrentLine;
46811
46812 ------------------------------------------------------------------------------------
46813 -- 4219869 Business Flow
46814 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46815 ------------------------------------------------------------------------------------
46816 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46817
46818 ----------------------------------------------------------------------------------
46819 -- 4219869 Business Flow
46820 -- Update journal entry status -- Need to generate this within IF <condition>
46821 ----------------------------------------------------------------------------------
46822 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46823 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46824 ,p_balance_type_code => l_balance_type_code
46825 );
46826
46827 -------------------------------------------------------------------------------------------
46828 -- 4262811 - Generate the Accrual Reversal lines
46829 -------------------------------------------------------------------------------------------
46830 BEGIN
46831 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46832 (g_array_event(p_event_id).array_value_num('header_index'));
46833 IF l_acc_rev_flag IS NULL THEN
46834 l_acc_rev_flag := 'N';
46835 END IF;
46836 EXCEPTION
46837 WHEN OTHERS THEN
46838 l_acc_rev_flag := 'N';
46839 END;
46840 --
46841 IF (l_acc_rev_flag = 'Y') THEN
46842
46843 -- 4645092 ------------------------------------------------------------------------------
46844 -- To allow MPA report to determine if it should generate report process
46845 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46846 ------------------------------------------------------------------------------------------
46847
46848 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46849 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46850 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46851 -- call ADRs
46852 -- Bug 4922099
46853 --
46854 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46855 (NVL(l_actual_upg_option, 'N') = 'O') OR
46856 (NVL(l_enc_upg_option, 'N') = 'O')
46857 )
46858 THEN
46859 NULL;
46860 --
46861 --
46862
46863 l_ccid := AcctDerRule_6(
46864 p_application_id => p_application_id
46865 , p_ae_header_id => l_ae_header_id
46866 , p_source_11 => p_source_11
46867 , x_transaction_coa_id => l_adr_transaction_coa_id
46868 , x_accounting_coa_id => l_adr_accounting_coa_id
46869 , x_value_type_code => l_adr_value_type_code
46870 , p_side => 'NA'
46871 );
46872
46873 xla_ae_lines_pkg.set_ccid(
46874 p_code_combination_id => l_ccid
46875 , p_value_type_code => l_adr_value_type_code
46876 , p_transaction_coa_id => l_adr_transaction_coa_id
46877 , p_accounting_coa_id => l_adr_accounting_coa_id
46878 , p_adr_code => 'CST_DEFAULT'
46879 , p_adr_type_code => 'S'
46880 , p_component_type => l_component_type
46881 , p_component_code => l_component_code
46882 , p_component_type_code => l_component_type_code
46883 , p_component_appl_id => l_component_appl_id
46884 , p_amb_context_code => l_amb_context_code
46885 , p_side => 'NA'
46886 );
46887
46888
46889 --
46890 --
46891 END IF;
46892
46893 --
46894 -- Update the line information that should be overwritten
46895 --
46896 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46897 p_header_num => 1);
46898 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46899
46900 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46901
46902 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46903 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46904 END IF;
46905
46906 --
46907 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46908 --
46909 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46910 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46911 ELSE
46912 ---------------------------------------------------------------------------------------------------
46913 -- 4262811a Switch Sign
46914 ---------------------------------------------------------------------------------------------------
46915 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46916 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46917 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46918 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46919 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46920 -- 5132302
46921 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46922 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46923
46924 END IF;
46925
46926 -- 4955764
46927 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46928 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46929
46930
46931 XLA_AE_LINES_PKG.ValidateCurrentLine;
46932 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46933
46934 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46935 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46936 ,p_balance_type_code => l_balance_type_code);
46937
46938 END IF;
46939
46940 -----------------------------------------------------------------------------------------
46941 -- 4262811 Multiperiod Accounting
46942 -----------------------------------------------------------------------------------------
46943 -- No MPA option is assigned.
46944
46945
46946 END IF;
46947 END IF;
46948 --
46949
46950 --
46951 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46952 trace
46953 (p_msg => 'END of AcctLineType_107'
46954 ,p_level => C_LEVEL_PROCEDURE
46955 ,p_module => l_log_module);
46956 END IF;
46957 --
46958 EXCEPTION
46959 WHEN xla_exceptions_pkg.application_exception THEN
46960 RAISE;
46961 WHEN OTHERS THEN
46962 xla_exceptions_pkg.raise_message
46963 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_107');
46964 END AcctLineType_107;
46965 --
46966
46967 ---------------------------------------
46968 --
46969 -- PRIVATE FUNCTION
46970 -- AcctLineType_108
46971 --
46972 ---------------------------------------
46973 PROCEDURE AcctLineType_108 (
46974 p_application_id IN NUMBER
46975 ,p_event_id IN NUMBER
46976 ,p_calculate_acctd_flag IN VARCHAR2
46977 ,p_calculate_g_l_flag IN VARCHAR2
46978 ,p_actual_flag IN OUT VARCHAR2
46979 ,p_balance_type_code OUT VARCHAR2
46980 ,p_gain_or_loss_ref OUT VARCHAR2
46981
46982 --TRANSACTION_ID
46983 , p_source_1 IN NUMBER
46984 --Item Concatenated Segments
46985 , p_source_2 IN VARCHAR2
46986 --Transaction Quantity
46987 , p_source_3 IN NUMBER
46988 --Transaction Unit of Measure Code
46989 , p_source_4 IN VARCHAR2
46990 --Inventory Transaction Type Description
46991 , p_source_5 IN VARCHAR2
46992 --Cost Management Default Account
46993 , p_source_11 IN NUMBER
46994 --DISTRIBUTION_IDENTIFIER
46995 , p_source_84 IN NUMBER
46996 --Distribution Type
46997 , p_source_85 IN VARCHAR2
46998 , p_source_85_meaning IN VARCHAR2
46999 --Entered Currency Code
47000 , p_source_88 IN VARCHAR2
47001 --Entered Amount
47002 , p_source_91 IN NUMBER
47003 --Currency Conversion Date
47004 , p_source_92 IN DATE
47005 --Currency Conversion Rate
47006 , p_source_93 IN NUMBER
47007 --Currency Conversion Type
47008 , p_source_94 IN VARCHAR2
47009 --Accounted Amount
47010 , p_source_95 IN NUMBER
47011 --Accounting Line Type
47012 , p_source_97 IN NUMBER
47013 )
47014 IS
47015
47016 l_component_type VARCHAR2(80);
47017 l_component_code VARCHAR2(30);
47018 l_component_type_code VARCHAR2(1);
47019 l_component_appl_id INTEGER;
47020 l_amb_context_code VARCHAR2(30);
47021 l_entity_code VARCHAR2(30);
47022 l_event_class_code VARCHAR2(30);
47023 l_ae_header_id NUMBER;
47024 l_event_type_code VARCHAR2(30);
47025 l_line_definition_code VARCHAR2(30);
47026 l_line_definition_owner_code VARCHAR2(1);
47027 --
47028 -- adr variables
47029 l_segment VARCHAR2(30);
47030 l_ccid NUMBER;
47031 l_adr_transaction_coa_id NUMBER;
47032 l_adr_accounting_coa_id NUMBER;
47033 l_adr_flexfield_segment_code VARCHAR2(30);
47034 l_adr_flex_value_set_id NUMBER;
47035 l_adr_value_type_code VARCHAR2(30);
47036 l_adr_value_combination_id NUMBER;
47037 l_adr_value_segment_code VARCHAR2(30);
47038
47039 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47040 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47041 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47042 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47043
47044 -- 4262811 Variables ------------------------------------------------------------------------------------------
47045 l_entered_amt_idx NUMBER;
47046 l_accted_amt_idx NUMBER;
47047 l_acc_rev_flag VARCHAR2(1);
47048 l_accrual_line_num NUMBER;
47049 l_tmp_amt NUMBER;
47050 l_acc_rev_natural_side_code VARCHAR2(1);
47051
47052 l_num_entries NUMBER;
47053 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47054 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47055 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47056 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47057 l_recog_line_1 NUMBER;
47058 l_recog_line_2 NUMBER;
47059
47060 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47061 l_bflow_applied_to_amt NUMBER; -- 5132302
47062 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47063
47064 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47065
47066 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47067 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47068
47069 ---------------------------------------------------------------------------------------------------------------
47070
47071
47072 --
47073 -- bulk performance
47074 --
47075 l_balance_type_code VARCHAR2(1);
47076 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47077 l_log_module VARCHAR2(240);
47078
47079 --
47080 -- Upgrade strategy
47081 --
47082 l_actual_upg_option VARCHAR2(1);
47083 l_enc_upg_option VARCHAR2(1);
47084
47085 --
47086 BEGIN
47087 --
47088 IF g_log_enabled THEN
47089 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_108';
47090 END IF;
47091 --
47092 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47093
47094 trace
47095 (p_msg => 'BEGIN of AcctLineType_108'
47096 ,p_level => C_LEVEL_PROCEDURE
47097 ,p_module => l_log_module);
47098
47099 END IF;
47100 --
47101 l_component_type := 'AMB_JLT';
47102 l_component_code := 'COST_VARIANCE';
47103 l_component_type_code := 'S';
47104 l_component_appl_id := 707;
47105 l_amb_context_code := 'DEFAULT';
47106 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
47107 l_event_class_code := 'SALES_ORDER';
47108 l_event_type_code := 'RMA_RETURN';
47109 l_line_definition_owner_code := 'S';
47110 l_line_definition_code := 'PI_RMA_RETURN';
47111 --
47112 l_balance_type_code := 'A';
47113 l_segment := NULL;
47114 l_ccid := NULL;
47115 l_adr_transaction_coa_id := NULL;
47116 l_adr_accounting_coa_id := NULL;
47117 l_adr_flexfield_segment_code := NULL;
47118 l_adr_flex_value_set_id := NULL;
47119 l_adr_value_type_code := NULL;
47120 l_adr_value_combination_id := NULL;
47121 l_adr_value_segment_code := NULL;
47122
47123 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47124 l_bflow_class_code := ''; -- 4219869 Business Flow
47125 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47126 l_budgetary_control_flag := 'N';
47127
47128 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47129 l_bflow_applied_to_amt := NULL; -- 5132302
47130 l_entered_amt_idx := NULL; -- 4262811
47131 l_accted_amt_idx := NULL; -- 4262811
47132 l_acc_rev_flag := NULL; -- 4262811
47133 l_accrual_line_num := NULL; -- 4262811
47134 l_tmp_amt := NULL; -- 4262811
47135 --
47136
47137 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47138 l_balance_type_code <> 'B' THEN
47139 IF NVL(p_source_97,9E125) = 13
47140 THEN
47141
47142 --
47143 XLA_AE_LINES_PKG.SetNewLine;
47144
47145 p_balance_type_code := l_balance_type_code;
47146 -- set the flag so later we will know whether the gain loss line needs to be created
47147
47148 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47149 p_actual_flag :='A';
47150 END IF;
47151
47152 --
47153 -- bulk performance
47154 --
47155 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47156 p_header_num => 0); -- 4262811
47157 --
47158 -- set accounting line options
47159 --
47160 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47161 p_natural_side_code => 'D'
47162 , p_gain_or_loss_flag => 'N'
47163 , p_gl_transfer_mode_code => 'S'
47164 , p_acct_entry_type_code => 'A'
47165 , p_switch_side_flag => 'Y'
47166 , p_merge_duplicate_code => 'N'
47167 );
47168 --
47169 l_acc_rev_natural_side_code := 'C'; -- 4262811
47170 --
47171 --
47172 -- set accounting line type info
47173 --
47174 xla_ae_lines_pkg.SetAcctLineType
47175 (p_component_type => l_component_type
47176 ,p_event_type_code => l_event_type_code
47177 ,p_line_definition_owner_code => l_line_definition_owner_code
47178 ,p_line_definition_code => l_line_definition_code
47179 ,p_accounting_line_code => l_component_code
47180 ,p_accounting_line_type_code => l_component_type_code
47181 ,p_accounting_line_appl_id => l_component_appl_id
47182 ,p_amb_context_code => l_amb_context_code
47183 ,p_entity_code => l_entity_code
47184 ,p_event_class_code => l_event_class_code);
47185 --
47186 -- set accounting class
47187 --
47188 xla_ae_lines_pkg.SetAcctClass(
47189 p_accounting_class_code => 'COST_VARIANCE'
47190 , p_ae_header_id => l_ae_header_id
47191 );
47192
47193 --
47194 -- set rounding class
47195 --
47196 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47197 'COST_VARIANCE';
47198
47199 --
47200 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47201 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47202 --
47203 -- bulk performance
47204 --
47205 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47206
47207 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47208 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47209
47210 -- 4955764
47211 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47212 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47213
47214 -- 4458381 Public Sector Enh
47215
47216 --
47217 -- set accounting attributes for the line type
47218 --
47219 l_entered_amt_idx := 3;
47220 l_accted_amt_idx := 8;
47221 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47222 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47223 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
47224 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47225 l_rec_acct_attrs.array_char_value(2) := p_source_85;
47226 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47227 l_rec_acct_attrs.array_num_value(3) := p_source_91;
47228 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47229 l_rec_acct_attrs.array_char_value(4) := p_source_88;
47230 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47231 l_rec_acct_attrs.array_date_value(5) := p_source_92;
47232 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47233 l_rec_acct_attrs.array_num_value(6) := p_source_93;
47234 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47235 l_rec_acct_attrs.array_char_value(7) := p_source_94;
47236 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47237 l_rec_acct_attrs.array_num_value(8) := p_source_95;
47238
47239 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47240 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47241
47242 ---------------------------------------------------------------------------------------------------------------
47243 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47244 ---------------------------------------------------------------------------------------------------------------
47245 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47246
47247 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47248 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47249
47250 IF xla_accounting_cache_pkg.GetValueChar
47251 (p_source_code => 'LEDGER_CATEGORY_CODE'
47252 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47253 AND l_bflow_method_code = 'PRIOR_ENTRY'
47254 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47255 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47256 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47257 )
47258 THEN
47259 xla_ae_lines_pkg.BflowUpgEntry
47260 (p_business_method_code => l_bflow_method_code
47261 ,p_business_class_code => l_bflow_class_code
47262 ,p_balance_type => l_balance_type_code);
47263 ELSE
47264 NULL;
47265 -- No business flow processing for business flow method of NONE.
47266 END IF;
47267
47268 --
47269 -- call analytical criteria
47270 --
47271
47272 --
47273 -- call description
47274 --
47275
47276 xla_ae_lines_pkg.SetLineDescription(
47277 p_ae_header_id => l_ae_header_id
47278 ,p_description => Description_1 (
47279 p_application_id => p_application_id
47280 , p_ae_header_id => l_ae_header_id
47281 , p_source_1 => p_source_1
47282 , p_source_2 => p_source_2
47283 , p_source_3 => p_source_3
47284 , p_source_4 => p_source_4
47285 , p_source_5 => p_source_5
47286 )
47287 );
47288
47289
47290 --
47291 -- call ADRs
47292 -- Bug 4922099
47293 --
47294 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47295 (NVL(l_actual_upg_option, 'N') = 'O') OR
47296 (NVL(l_enc_upg_option, 'N') = 'O')
47297 )
47298 THEN
47299 NULL;
47300 --
47301 --
47302
47303 l_ccid := AcctDerRule_6(
47304 p_application_id => p_application_id
47305 , p_ae_header_id => l_ae_header_id
47306 , p_source_11 => p_source_11
47307 , x_transaction_coa_id => l_adr_transaction_coa_id
47308 , x_accounting_coa_id => l_adr_accounting_coa_id
47309 , x_value_type_code => l_adr_value_type_code
47310 , p_side => 'NA'
47311 );
47312
47313 xla_ae_lines_pkg.set_ccid(
47314 p_code_combination_id => l_ccid
47315 , p_value_type_code => l_adr_value_type_code
47316 , p_transaction_coa_id => l_adr_transaction_coa_id
47317 , p_accounting_coa_id => l_adr_accounting_coa_id
47318 , p_adr_code => 'CST_DEFAULT'
47319 , p_adr_type_code => 'S'
47320 , p_component_type => l_component_type
47321 , p_component_code => l_component_code
47322 , p_component_type_code => l_component_type_code
47323 , p_component_appl_id => l_component_appl_id
47324 , p_amb_context_code => l_amb_context_code
47325 , p_side => 'NA'
47326 );
47327
47328
47329 --
47330 --
47331 END IF;
47332 --
47333 -- Bug 4922099
47334 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47335 (NVL(l_enc_upg_option, 'N') = 'O')
47336 ) AND
47337 (l_bflow_method_code = 'PRIOR_ENTRY')
47338 )
47339 THEN
47340 IF
47341 --
47342 1 = 2
47343 --
47344 THEN
47345 xla_accounting_err_pkg.build_message
47346 (p_appli_s_name => 'XLA'
47347 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47348 ,p_token_1 => 'LINE_NUMBER'
47349 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47350 ,p_token_2 => 'LINE_TYPE_NAME'
47351 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47352 l_component_type
47353 ,l_component_code
47354 ,l_component_type_code
47355 ,l_component_appl_id
47356 ,l_amb_context_code
47357 ,l_entity_code
47358 ,l_event_class_code
47359 )
47360 ,p_token_3 => 'OWNER'
47361 ,p_value_3 => xla_lookups_pkg.get_meaning(
47362 p_lookup_type => 'XLA_OWNER_TYPE'
47363 ,p_lookup_code => l_component_type_code
47364 )
47365 ,p_token_4 => 'PRODUCT_NAME'
47366 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47367 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47368 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47369 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47370 ,p_ae_header_id => NULL
47371 );
47372
47373 IF (C_LEVEL_ERROR>= g_log_level) THEN
47374 trace
47375 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47376 ,p_level => C_LEVEL_ERROR
47377 ,p_module => l_log_module);
47378 END IF;
47379 END IF;
47380 END IF;
47381 --
47382 --
47383 ------------------------------------------------------------------------------------------------
47384 -- 4219869 Business Flow
47385 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47386 -- Prior Entry. Currently, the following code is always generated.
47387 ------------------------------------------------------------------------------------------------
47388 XLA_AE_LINES_PKG.ValidateCurrentLine;
47389
47390 ------------------------------------------------------------------------------------
47391 -- 4219869 Business Flow
47392 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47393 ------------------------------------------------------------------------------------
47394 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47395
47396 ----------------------------------------------------------------------------------
47397 -- 4219869 Business Flow
47398 -- Update journal entry status -- Need to generate this within IF <condition>
47399 ----------------------------------------------------------------------------------
47400 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47401 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47402 ,p_balance_type_code => l_balance_type_code
47403 );
47404
47405 -------------------------------------------------------------------------------------------
47406 -- 4262811 - Generate the Accrual Reversal lines
47407 -------------------------------------------------------------------------------------------
47408 BEGIN
47409 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47410 (g_array_event(p_event_id).array_value_num('header_index'));
47411 IF l_acc_rev_flag IS NULL THEN
47412 l_acc_rev_flag := 'N';
47413 END IF;
47414 EXCEPTION
47415 WHEN OTHERS THEN
47416 l_acc_rev_flag := 'N';
47417 END;
47418 --
47419 IF (l_acc_rev_flag = 'Y') THEN
47420
47421 -- 4645092 ------------------------------------------------------------------------------
47422 -- To allow MPA report to determine if it should generate report process
47423 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47424 ------------------------------------------------------------------------------------------
47425
47426 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47427 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47428 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47429 -- call ADRs
47430 -- Bug 4922099
47431 --
47432 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47433 (NVL(l_actual_upg_option, 'N') = 'O') OR
47434 (NVL(l_enc_upg_option, 'N') = 'O')
47435 )
47436 THEN
47437 NULL;
47438 --
47439 --
47440
47441 l_ccid := AcctDerRule_6(
47442 p_application_id => p_application_id
47443 , p_ae_header_id => l_ae_header_id
47444 , p_source_11 => p_source_11
47445 , x_transaction_coa_id => l_adr_transaction_coa_id
47446 , x_accounting_coa_id => l_adr_accounting_coa_id
47447 , x_value_type_code => l_adr_value_type_code
47448 , p_side => 'NA'
47449 );
47450
47451 xla_ae_lines_pkg.set_ccid(
47452 p_code_combination_id => l_ccid
47453 , p_value_type_code => l_adr_value_type_code
47454 , p_transaction_coa_id => l_adr_transaction_coa_id
47455 , p_accounting_coa_id => l_adr_accounting_coa_id
47456 , p_adr_code => 'CST_DEFAULT'
47457 , p_adr_type_code => 'S'
47458 , p_component_type => l_component_type
47459 , p_component_code => l_component_code
47460 , p_component_type_code => l_component_type_code
47461 , p_component_appl_id => l_component_appl_id
47462 , p_amb_context_code => l_amb_context_code
47463 , p_side => 'NA'
47464 );
47465
47466
47467 --
47468 --
47469 END IF;
47470
47471 --
47472 -- Update the line information that should be overwritten
47473 --
47474 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
47475 p_header_num => 1);
47476 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
47477
47478 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
47479
47480 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
47481 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
47482 END IF;
47483
47484 --
47485 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
47486 --
47487 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
47488 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
47489 ELSE
47490 ---------------------------------------------------------------------------------------------------
47491 -- 4262811a Switch Sign
47492 ---------------------------------------------------------------------------------------------------
47493 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
47494 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47495 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47496 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47497 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47498 -- 5132302
47499 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
47500 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47501
47502 END IF;
47503
47504 -- 4955764
47505 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47506 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
47507
47508
47509 XLA_AE_LINES_PKG.ValidateCurrentLine;
47510 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47511
47512 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47513 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
47514 ,p_balance_type_code => l_balance_type_code);
47515
47516 END IF;
47517
47518 -----------------------------------------------------------------------------------------
47519 -- 4262811 Multiperiod Accounting
47520 -----------------------------------------------------------------------------------------
47521 -- No MPA option is assigned.
47522
47523
47524 END IF;
47525 END IF;
47526 --
47527
47528 --
47529 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47530 trace
47531 (p_msg => 'END of AcctLineType_108'
47532 ,p_level => C_LEVEL_PROCEDURE
47533 ,p_module => l_log_module);
47534 END IF;
47535 --
47536 EXCEPTION
47537 WHEN xla_exceptions_pkg.application_exception THEN
47538 RAISE;
47539 WHEN OTHERS THEN
47540 xla_exceptions_pkg.raise_message
47541 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_108');
47542 END AcctLineType_108;
47543 --
47544
47545 ---------------------------------------
47546 --
47547 -- PRIVATE FUNCTION
47548 -- AcctLineType_109
47549 --
47550 ---------------------------------------
47551 PROCEDURE AcctLineType_109 (
47552 p_application_id IN NUMBER
47553 ,p_event_id IN NUMBER
47554 ,p_calculate_acctd_flag IN VARCHAR2
47555 ,p_calculate_g_l_flag IN VARCHAR2
47556 ,p_actual_flag IN OUT VARCHAR2
47557 ,p_balance_type_code OUT VARCHAR2
47558 ,p_gain_or_loss_ref OUT VARCHAR2
47559
47560 --TRANSACTION_ID
47561 , p_source_1 IN NUMBER
47562 --Item Concatenated Segments
47563 , p_source_2 IN VARCHAR2
47564 --Transaction Quantity
47565 , p_source_3 IN NUMBER
47566 --Transaction Unit of Measure Code
47567 , p_source_4 IN VARCHAR2
47568 --Inventory Transaction Type Description
47569 , p_source_5 IN VARCHAR2
47570 --Cost Management Default Account
47571 , p_source_11 IN NUMBER
47572 --DISTRIBUTION_IDENTIFIER
47573 , p_source_84 IN NUMBER
47574 --Distribution Type
47575 , p_source_85 IN VARCHAR2
47576 , p_source_85_meaning IN VARCHAR2
47577 --Entered Currency Code
47578 , p_source_88 IN VARCHAR2
47579 --Entered Amount
47580 , p_source_91 IN NUMBER
47581 --Currency Conversion Date
47582 , p_source_92 IN DATE
47583 --Currency Conversion Rate
47584 , p_source_93 IN NUMBER
47585 --Currency Conversion Type
47586 , p_source_94 IN VARCHAR2
47587 --Accounted Amount
47588 , p_source_95 IN NUMBER
47589 --Accounting Line Type
47590 , p_source_97 IN NUMBER
47591 )
47592 IS
47593
47594 l_component_type VARCHAR2(80);
47595 l_component_code VARCHAR2(30);
47596 l_component_type_code VARCHAR2(1);
47597 l_component_appl_id INTEGER;
47598 l_amb_context_code VARCHAR2(30);
47599 l_entity_code VARCHAR2(30);
47600 l_event_class_code VARCHAR2(30);
47601 l_ae_header_id NUMBER;
47602 l_event_type_code VARCHAR2(30);
47603 l_line_definition_code VARCHAR2(30);
47604 l_line_definition_owner_code VARCHAR2(1);
47605 --
47606 -- adr variables
47607 l_segment VARCHAR2(30);
47608 l_ccid NUMBER;
47609 l_adr_transaction_coa_id NUMBER;
47610 l_adr_accounting_coa_id NUMBER;
47611 l_adr_flexfield_segment_code VARCHAR2(30);
47612 l_adr_flex_value_set_id NUMBER;
47613 l_adr_value_type_code VARCHAR2(30);
47614 l_adr_value_combination_id NUMBER;
47615 l_adr_value_segment_code VARCHAR2(30);
47616
47617 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47618 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47619 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47620 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47621
47622 -- 4262811 Variables ------------------------------------------------------------------------------------------
47623 l_entered_amt_idx NUMBER;
47624 l_accted_amt_idx NUMBER;
47625 l_acc_rev_flag VARCHAR2(1);
47626 l_accrual_line_num NUMBER;
47627 l_tmp_amt NUMBER;
47628 l_acc_rev_natural_side_code VARCHAR2(1);
47629
47630 l_num_entries NUMBER;
47631 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47632 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47633 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47634 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47635 l_recog_line_1 NUMBER;
47636 l_recog_line_2 NUMBER;
47637
47638 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47639 l_bflow_applied_to_amt NUMBER; -- 5132302
47640 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47641
47642 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47643
47644 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47645 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47646
47647 ---------------------------------------------------------------------------------------------------------------
47648
47649
47650 --
47651 -- bulk performance
47652 --
47653 l_balance_type_code VARCHAR2(1);
47654 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47655 l_log_module VARCHAR2(240);
47656
47657 --
47658 -- Upgrade strategy
47659 --
47660 l_actual_upg_option VARCHAR2(1);
47661 l_enc_upg_option VARCHAR2(1);
47662
47663 --
47664 BEGIN
47665 --
47666 IF g_log_enabled THEN
47667 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_109';
47668 END IF;
47669 --
47670 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47671
47672 trace
47673 (p_msg => 'BEGIN of AcctLineType_109'
47674 ,p_level => C_LEVEL_PROCEDURE
47675 ,p_module => l_log_module);
47676
47677 END IF;
47678 --
47679 l_component_type := 'AMB_JLT';
47680 l_component_code := 'COST_VARIANCE';
47681 l_component_type_code := 'S';
47682 l_component_appl_id := 707;
47683 l_amb_context_code := 'DEFAULT';
47684 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
47685 l_event_class_code := 'SALES_ORDER';
47686 l_event_type_code := 'SO_ISSUE';
47687 l_line_definition_owner_code := 'S';
47688 l_line_definition_code := 'PI_SO_ISSUE';
47689 --
47690 l_balance_type_code := 'A';
47691 l_segment := NULL;
47692 l_ccid := NULL;
47693 l_adr_transaction_coa_id := NULL;
47694 l_adr_accounting_coa_id := NULL;
47695 l_adr_flexfield_segment_code := NULL;
47696 l_adr_flex_value_set_id := NULL;
47697 l_adr_value_type_code := NULL;
47698 l_adr_value_combination_id := NULL;
47699 l_adr_value_segment_code := NULL;
47700
47701 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47702 l_bflow_class_code := ''; -- 4219869 Business Flow
47703 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47704 l_budgetary_control_flag := 'N';
47705
47706 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47707 l_bflow_applied_to_amt := NULL; -- 5132302
47708 l_entered_amt_idx := NULL; -- 4262811
47709 l_accted_amt_idx := NULL; -- 4262811
47710 l_acc_rev_flag := NULL; -- 4262811
47711 l_accrual_line_num := NULL; -- 4262811
47712 l_tmp_amt := NULL; -- 4262811
47713 --
47714
47715 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47716 l_balance_type_code <> 'B' THEN
47717 IF NVL(p_source_97,9E125) = 13
47718 THEN
47719
47720 --
47721 XLA_AE_LINES_PKG.SetNewLine;
47722
47723 p_balance_type_code := l_balance_type_code;
47724 -- set the flag so later we will know whether the gain loss line needs to be created
47725
47726 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47727 p_actual_flag :='A';
47728 END IF;
47729
47730 --
47731 -- bulk performance
47732 --
47733 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47734 p_header_num => 0); -- 4262811
47735 --
47736 -- set accounting line options
47737 --
47738 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47739 p_natural_side_code => 'D'
47740 , p_gain_or_loss_flag => 'N'
47741 , p_gl_transfer_mode_code => 'S'
47742 , p_acct_entry_type_code => 'A'
47743 , p_switch_side_flag => 'Y'
47744 , p_merge_duplicate_code => 'N'
47745 );
47746 --
47747 l_acc_rev_natural_side_code := 'C'; -- 4262811
47748 --
47749 --
47750 -- set accounting line type info
47751 --
47752 xla_ae_lines_pkg.SetAcctLineType
47753 (p_component_type => l_component_type
47754 ,p_event_type_code => l_event_type_code
47755 ,p_line_definition_owner_code => l_line_definition_owner_code
47756 ,p_line_definition_code => l_line_definition_code
47757 ,p_accounting_line_code => l_component_code
47758 ,p_accounting_line_type_code => l_component_type_code
47759 ,p_accounting_line_appl_id => l_component_appl_id
47760 ,p_amb_context_code => l_amb_context_code
47761 ,p_entity_code => l_entity_code
47762 ,p_event_class_code => l_event_class_code);
47763 --
47764 -- set accounting class
47765 --
47766 xla_ae_lines_pkg.SetAcctClass(
47767 p_accounting_class_code => 'COST_VARIANCE'
47768 , p_ae_header_id => l_ae_header_id
47769 );
47770
47771 --
47772 -- set rounding class
47773 --
47774 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47775 'COST_VARIANCE';
47776
47777 --
47778 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47779 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47780 --
47781 -- bulk performance
47782 --
47783 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47784
47785 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47786 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47787
47788 -- 4955764
47789 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47790 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47791
47792 -- 4458381 Public Sector Enh
47793
47794 --
47795 -- set accounting attributes for the line type
47796 --
47797 l_entered_amt_idx := 3;
47798 l_accted_amt_idx := 8;
47799 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47800 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47801 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
47802 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47803 l_rec_acct_attrs.array_char_value(2) := p_source_85;
47804 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47805 l_rec_acct_attrs.array_num_value(3) := p_source_91;
47806 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47807 l_rec_acct_attrs.array_char_value(4) := p_source_88;
47808 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47809 l_rec_acct_attrs.array_date_value(5) := p_source_92;
47810 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47811 l_rec_acct_attrs.array_num_value(6) := p_source_93;
47812 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47813 l_rec_acct_attrs.array_char_value(7) := p_source_94;
47814 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47815 l_rec_acct_attrs.array_num_value(8) := p_source_95;
47816
47817 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47818 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47819
47820 ---------------------------------------------------------------------------------------------------------------
47821 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47822 ---------------------------------------------------------------------------------------------------------------
47823 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47824
47825 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47826 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47827
47828 IF xla_accounting_cache_pkg.GetValueChar
47829 (p_source_code => 'LEDGER_CATEGORY_CODE'
47830 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47831 AND l_bflow_method_code = 'PRIOR_ENTRY'
47832 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47833 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47834 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47835 )
47836 THEN
47837 xla_ae_lines_pkg.BflowUpgEntry
47838 (p_business_method_code => l_bflow_method_code
47839 ,p_business_class_code => l_bflow_class_code
47840 ,p_balance_type => l_balance_type_code);
47841 ELSE
47842 NULL;
47843 -- No business flow processing for business flow method of NONE.
47844 END IF;
47845
47846 --
47847 -- call analytical criteria
47848 --
47849
47850 --
47851 -- call description
47852 --
47853
47854 xla_ae_lines_pkg.SetLineDescription(
47855 p_ae_header_id => l_ae_header_id
47856 ,p_description => Description_1 (
47857 p_application_id => p_application_id
47858 , p_ae_header_id => l_ae_header_id
47859 , p_source_1 => p_source_1
47860 , p_source_2 => p_source_2
47861 , p_source_3 => p_source_3
47862 , p_source_4 => p_source_4
47863 , p_source_5 => p_source_5
47864 )
47865 );
47866
47867
47868 --
47869 -- call ADRs
47870 -- Bug 4922099
47871 --
47872 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47873 (NVL(l_actual_upg_option, 'N') = 'O') OR
47874 (NVL(l_enc_upg_option, 'N') = 'O')
47875 )
47876 THEN
47877 NULL;
47878 --
47879 --
47880
47881 l_ccid := AcctDerRule_6(
47882 p_application_id => p_application_id
47883 , p_ae_header_id => l_ae_header_id
47884 , p_source_11 => p_source_11
47885 , x_transaction_coa_id => l_adr_transaction_coa_id
47886 , x_accounting_coa_id => l_adr_accounting_coa_id
47887 , x_value_type_code => l_adr_value_type_code
47888 , p_side => 'NA'
47889 );
47890
47891 xla_ae_lines_pkg.set_ccid(
47892 p_code_combination_id => l_ccid
47893 , p_value_type_code => l_adr_value_type_code
47894 , p_transaction_coa_id => l_adr_transaction_coa_id
47895 , p_accounting_coa_id => l_adr_accounting_coa_id
47896 , p_adr_code => 'CST_DEFAULT'
47897 , p_adr_type_code => 'S'
47898 , p_component_type => l_component_type
47899 , p_component_code => l_component_code
47900 , p_component_type_code => l_component_type_code
47901 , p_component_appl_id => l_component_appl_id
47902 , p_amb_context_code => l_amb_context_code
47903 , p_side => 'NA'
47904 );
47905
47906
47907 --
47908 --
47909 END IF;
47910 --
47911 -- Bug 4922099
47912 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47913 (NVL(l_enc_upg_option, 'N') = 'O')
47914 ) AND
47915 (l_bflow_method_code = 'PRIOR_ENTRY')
47916 )
47917 THEN
47918 IF
47919 --
47920 1 = 2
47921 --
47922 THEN
47923 xla_accounting_err_pkg.build_message
47924 (p_appli_s_name => 'XLA'
47925 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47926 ,p_token_1 => 'LINE_NUMBER'
47927 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47928 ,p_token_2 => 'LINE_TYPE_NAME'
47929 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47930 l_component_type
47931 ,l_component_code
47932 ,l_component_type_code
47933 ,l_component_appl_id
47934 ,l_amb_context_code
47935 ,l_entity_code
47936 ,l_event_class_code
47937 )
47938 ,p_token_3 => 'OWNER'
47939 ,p_value_3 => xla_lookups_pkg.get_meaning(
47940 p_lookup_type => 'XLA_OWNER_TYPE'
47941 ,p_lookup_code => l_component_type_code
47942 )
47943 ,p_token_4 => 'PRODUCT_NAME'
47944 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47945 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47946 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47947 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47948 ,p_ae_header_id => NULL
47949 );
47950
47951 IF (C_LEVEL_ERROR>= g_log_level) THEN
47952 trace
47953 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47954 ,p_level => C_LEVEL_ERROR
47955 ,p_module => l_log_module);
47956 END IF;
47957 END IF;
47958 END IF;
47959 --
47960 --
47961 ------------------------------------------------------------------------------------------------
47962 -- 4219869 Business Flow
47963 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47964 -- Prior Entry. Currently, the following code is always generated.
47965 ------------------------------------------------------------------------------------------------
47966 XLA_AE_LINES_PKG.ValidateCurrentLine;
47967
47968 ------------------------------------------------------------------------------------
47969 -- 4219869 Business Flow
47970 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47971 ------------------------------------------------------------------------------------
47972 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47973
47974 ----------------------------------------------------------------------------------
47975 -- 4219869 Business Flow
47976 -- Update journal entry status -- Need to generate this within IF <condition>
47977 ----------------------------------------------------------------------------------
47978 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47979 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47980 ,p_balance_type_code => l_balance_type_code
47981 );
47982
47983 -------------------------------------------------------------------------------------------
47984 -- 4262811 - Generate the Accrual Reversal lines
47985 -------------------------------------------------------------------------------------------
47986 BEGIN
47987 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47988 (g_array_event(p_event_id).array_value_num('header_index'));
47989 IF l_acc_rev_flag IS NULL THEN
47990 l_acc_rev_flag := 'N';
47991 END IF;
47992 EXCEPTION
47993 WHEN OTHERS THEN
47994 l_acc_rev_flag := 'N';
47995 END;
47996 --
47997 IF (l_acc_rev_flag = 'Y') THEN
47998
47999 -- 4645092 ------------------------------------------------------------------------------
48000 -- To allow MPA report to determine if it should generate report process
48001 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
48002 ------------------------------------------------------------------------------------------
48003
48004 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
48005 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
48006 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
48007 -- call ADRs
48008 -- Bug 4922099
48009 --
48010 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48011 (NVL(l_actual_upg_option, 'N') = 'O') OR
48012 (NVL(l_enc_upg_option, 'N') = 'O')
48013 )
48014 THEN
48015 NULL;
48016 --
48017 --
48018
48019 l_ccid := AcctDerRule_6(
48020 p_application_id => p_application_id
48021 , p_ae_header_id => l_ae_header_id
48022 , p_source_11 => p_source_11
48023 , x_transaction_coa_id => l_adr_transaction_coa_id
48024 , x_accounting_coa_id => l_adr_accounting_coa_id
48025 , x_value_type_code => l_adr_value_type_code
48026 , p_side => 'NA'
48027 );
48028
48029 xla_ae_lines_pkg.set_ccid(
48030 p_code_combination_id => l_ccid
48031 , p_value_type_code => l_adr_value_type_code
48032 , p_transaction_coa_id => l_adr_transaction_coa_id
48033 , p_accounting_coa_id => l_adr_accounting_coa_id
48034 , p_adr_code => 'CST_DEFAULT'
48035 , p_adr_type_code => 'S'
48036 , p_component_type => l_component_type
48037 , p_component_code => l_component_code
48038 , p_component_type_code => l_component_type_code
48039 , p_component_appl_id => l_component_appl_id
48040 , p_amb_context_code => l_amb_context_code
48041 , p_side => 'NA'
48042 );
48043
48044
48045 --
48046 --
48047 END IF;
48048
48049 --
48050 -- Update the line information that should be overwritten
48051 --
48052 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48053 p_header_num => 1);
48054 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48055
48056 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48057
48058 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48059 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48060 END IF;
48061
48062 --
48063 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48064 --
48065 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48066 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48067 ELSE
48068 ---------------------------------------------------------------------------------------------------
48069 -- 4262811a Switch Sign
48070 ---------------------------------------------------------------------------------------------------
48071 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48072 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48073 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48074 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48075 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48076 -- 5132302
48077 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48078 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48079
48080 END IF;
48081
48082 -- 4955764
48083 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48084 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48085
48086
48087 XLA_AE_LINES_PKG.ValidateCurrentLine;
48088 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48089
48090 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48091 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48092 ,p_balance_type_code => l_balance_type_code);
48093
48094 END IF;
48095
48096 -----------------------------------------------------------------------------------------
48097 -- 4262811 Multiperiod Accounting
48098 -----------------------------------------------------------------------------------------
48099 -- No MPA option is assigned.
48100
48101
48102 END IF;
48103 END IF;
48104 --
48105
48106 --
48107 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48108 trace
48109 (p_msg => 'END of AcctLineType_109'
48110 ,p_level => C_LEVEL_PROCEDURE
48111 ,p_module => l_log_module);
48112 END IF;
48113 --
48114 EXCEPTION
48115 WHEN xla_exceptions_pkg.application_exception THEN
48116 RAISE;
48117 WHEN OTHERS THEN
48118 xla_exceptions_pkg.raise_message
48119 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_109');
48120 END AcctLineType_109;
48121 --
48122
48123 ---------------------------------------
48124 --
48125 -- PRIVATE FUNCTION
48126 -- AcctLineType_110
48127 --
48128 ---------------------------------------
48129 PROCEDURE AcctLineType_110 (
48130 p_application_id IN NUMBER
48131 ,p_event_id IN NUMBER
48132 ,p_calculate_acctd_flag IN VARCHAR2
48133 ,p_calculate_g_l_flag IN VARCHAR2
48134 ,p_actual_flag IN OUT VARCHAR2
48135 ,p_balance_type_code OUT VARCHAR2
48136 ,p_gain_or_loss_ref OUT VARCHAR2
48137
48138 --TRANSACTION_ID
48139 , p_source_1 IN NUMBER
48140 --Item Concatenated Segments
48141 , p_source_2 IN VARCHAR2
48142 --Transaction Quantity
48143 , p_source_3 IN NUMBER
48144 --Transaction Unit of Measure Code
48145 , p_source_4 IN VARCHAR2
48146 --Inventory Transaction Type Description
48147 , p_source_5 IN VARCHAR2
48148 --Product Line Accounting Category Average Cost Variance Account
48149 , p_source_23 IN NUMBER
48150 --DISTRIBUTION_IDENTIFIER
48151 , p_source_84 IN NUMBER
48152 --Distribution Type
48153 , p_source_85 IN VARCHAR2
48154 , p_source_85_meaning IN VARCHAR2
48155 --Entered Currency Code
48156 , p_source_88 IN VARCHAR2
48157 --Entered Amount
48158 , p_source_91 IN NUMBER
48159 --Currency Conversion Date
48160 , p_source_92 IN DATE
48161 --Currency Conversion Rate
48162 , p_source_93 IN NUMBER
48163 --Currency Conversion Type
48164 , p_source_94 IN VARCHAR2
48165 --Accounted Amount
48166 , p_source_95 IN NUMBER
48167 --Accounting Line Type
48168 , p_source_97 IN NUMBER
48169 )
48170 IS
48171
48172 l_component_type VARCHAR2(80);
48173 l_component_code VARCHAR2(30);
48174 l_component_type_code VARCHAR2(1);
48175 l_component_appl_id INTEGER;
48176 l_amb_context_code VARCHAR2(30);
48177 l_entity_code VARCHAR2(30);
48178 l_event_class_code VARCHAR2(30);
48179 l_ae_header_id NUMBER;
48180 l_event_type_code VARCHAR2(30);
48181 l_line_definition_code VARCHAR2(30);
48182 l_line_definition_owner_code VARCHAR2(1);
48183 --
48184 -- adr variables
48185 l_segment VARCHAR2(30);
48186 l_ccid NUMBER;
48187 l_adr_transaction_coa_id NUMBER;
48188 l_adr_accounting_coa_id NUMBER;
48189 l_adr_flexfield_segment_code VARCHAR2(30);
48190 l_adr_flex_value_set_id NUMBER;
48191 l_adr_value_type_code VARCHAR2(30);
48192 l_adr_value_combination_id NUMBER;
48193 l_adr_value_segment_code VARCHAR2(30);
48194
48195 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48196 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48197 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48198 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48199
48200 -- 4262811 Variables ------------------------------------------------------------------------------------------
48201 l_entered_amt_idx NUMBER;
48202 l_accted_amt_idx NUMBER;
48203 l_acc_rev_flag VARCHAR2(1);
48204 l_accrual_line_num NUMBER;
48205 l_tmp_amt NUMBER;
48206 l_acc_rev_natural_side_code VARCHAR2(1);
48207
48208 l_num_entries NUMBER;
48209 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48210 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48211 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48212 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48213 l_recog_line_1 NUMBER;
48214 l_recog_line_2 NUMBER;
48215
48216 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48217 l_bflow_applied_to_amt NUMBER; -- 5132302
48218 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48219
48220 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48221
48222 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48223 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48224
48225 ---------------------------------------------------------------------------------------------------------------
48226
48227
48228 --
48229 -- bulk performance
48230 --
48231 l_balance_type_code VARCHAR2(1);
48232 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48233 l_log_module VARCHAR2(240);
48234
48235 --
48236 -- Upgrade strategy
48237 --
48238 l_actual_upg_option VARCHAR2(1);
48239 l_enc_upg_option VARCHAR2(1);
48240
48241 --
48242 BEGIN
48243 --
48244 IF g_log_enabled THEN
48245 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_110';
48246 END IF;
48247 --
48248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48249
48250 trace
48251 (p_msg => 'BEGIN of AcctLineType_110'
48252 ,p_level => C_LEVEL_PROCEDURE
48253 ,p_module => l_log_module);
48254
48255 END IF;
48256 --
48257 l_component_type := 'AMB_JLT';
48258 l_component_code := 'COST_VARIANCE';
48259 l_component_type_code := 'S';
48260 l_component_appl_id := 707;
48261 l_amb_context_code := 'DEFAULT';
48262 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
48263 l_event_class_code := 'USER_DEFINE';
48264 l_event_type_code := 'UAVG_COST_UPD';
48265 l_line_definition_owner_code := 'S';
48266 l_line_definition_code := 'PI_COST_UPD';
48267 --
48268 l_balance_type_code := 'A';
48269 l_segment := NULL;
48270 l_ccid := NULL;
48271 l_adr_transaction_coa_id := NULL;
48272 l_adr_accounting_coa_id := NULL;
48273 l_adr_flexfield_segment_code := NULL;
48274 l_adr_flex_value_set_id := NULL;
48275 l_adr_value_type_code := NULL;
48276 l_adr_value_combination_id := NULL;
48277 l_adr_value_segment_code := NULL;
48278
48279 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48280 l_bflow_class_code := ''; -- 4219869 Business Flow
48281 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48282 l_budgetary_control_flag := 'N';
48283
48284 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48285 l_bflow_applied_to_amt := NULL; -- 5132302
48286 l_entered_amt_idx := NULL; -- 4262811
48287 l_accted_amt_idx := NULL; -- 4262811
48288 l_acc_rev_flag := NULL; -- 4262811
48289 l_accrual_line_num := NULL; -- 4262811
48290 l_tmp_amt := NULL; -- 4262811
48291 --
48292
48293 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48294 l_balance_type_code <> 'B' THEN
48295 IF NVL(p_source_97,9E125) = 13
48296 THEN
48297
48298 --
48299 XLA_AE_LINES_PKG.SetNewLine;
48300
48301 p_balance_type_code := l_balance_type_code;
48302 -- set the flag so later we will know whether the gain loss line needs to be created
48303
48304 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48305 p_actual_flag :='A';
48306 END IF;
48307
48308 --
48309 -- bulk performance
48310 --
48311 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48312 p_header_num => 0); -- 4262811
48313 --
48314 -- set accounting line options
48315 --
48316 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48317 p_natural_side_code => 'D'
48318 , p_gain_or_loss_flag => 'N'
48319 , p_gl_transfer_mode_code => 'S'
48320 , p_acct_entry_type_code => 'A'
48321 , p_switch_side_flag => 'Y'
48322 , p_merge_duplicate_code => 'N'
48323 );
48324 --
48325 l_acc_rev_natural_side_code := 'C'; -- 4262811
48326 --
48327 --
48328 -- set accounting line type info
48329 --
48330 xla_ae_lines_pkg.SetAcctLineType
48331 (p_component_type => l_component_type
48332 ,p_event_type_code => l_event_type_code
48333 ,p_line_definition_owner_code => l_line_definition_owner_code
48334 ,p_line_definition_code => l_line_definition_code
48335 ,p_accounting_line_code => l_component_code
48336 ,p_accounting_line_type_code => l_component_type_code
48337 ,p_accounting_line_appl_id => l_component_appl_id
48338 ,p_amb_context_code => l_amb_context_code
48339 ,p_entity_code => l_entity_code
48340 ,p_event_class_code => l_event_class_code);
48341 --
48342 -- set accounting class
48343 --
48344 xla_ae_lines_pkg.SetAcctClass(
48345 p_accounting_class_code => 'COST_VARIANCE'
48346 , p_ae_header_id => l_ae_header_id
48347 );
48348
48349 --
48350 -- set rounding class
48351 --
48352 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48353 'COST_VARIANCE';
48354
48355 --
48356 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48357 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48358 --
48359 -- bulk performance
48360 --
48361 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48362
48363 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48364 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48365
48366 -- 4955764
48367 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48368 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48369
48370 -- 4458381 Public Sector Enh
48371
48372 --
48373 -- set accounting attributes for the line type
48374 --
48375 l_entered_amt_idx := 3;
48376 l_accted_amt_idx := 8;
48377 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48378 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
48379 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
48380 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
48381 l_rec_acct_attrs.array_char_value(2) := p_source_85;
48382 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
48383 l_rec_acct_attrs.array_num_value(3) := p_source_91;
48384 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
48385 l_rec_acct_attrs.array_char_value(4) := p_source_88;
48386 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
48387 l_rec_acct_attrs.array_date_value(5) := p_source_92;
48388 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
48389 l_rec_acct_attrs.array_num_value(6) := p_source_93;
48390 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
48391 l_rec_acct_attrs.array_char_value(7) := p_source_94;
48392 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
48393 l_rec_acct_attrs.array_num_value(8) := p_source_95;
48394
48395 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48396 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48397
48398 ---------------------------------------------------------------------------------------------------------------
48399 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48400 ---------------------------------------------------------------------------------------------------------------
48401 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48402
48403 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48404 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48405
48406 IF xla_accounting_cache_pkg.GetValueChar
48407 (p_source_code => 'LEDGER_CATEGORY_CODE'
48408 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48409 AND l_bflow_method_code = 'PRIOR_ENTRY'
48410 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48411 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48412 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48413 )
48414 THEN
48415 xla_ae_lines_pkg.BflowUpgEntry
48416 (p_business_method_code => l_bflow_method_code
48417 ,p_business_class_code => l_bflow_class_code
48418 ,p_balance_type => l_balance_type_code);
48419 ELSE
48420 NULL;
48421 -- No business flow processing for business flow method of NONE.
48422 END IF;
48423
48424 --
48425 -- call analytical criteria
48426 --
48427
48428 --
48429 -- call description
48430 --
48431
48432 xla_ae_lines_pkg.SetLineDescription(
48433 p_ae_header_id => l_ae_header_id
48434 ,p_description => Description_1 (
48435 p_application_id => p_application_id
48436 , p_ae_header_id => l_ae_header_id
48437 , p_source_1 => p_source_1
48438 , p_source_2 => p_source_2
48439 , p_source_3 => p_source_3
48440 , p_source_4 => p_source_4
48441 , p_source_5 => p_source_5
48442 )
48443 );
48444
48445
48446 --
48447 -- call ADRs
48448 -- Bug 4922099
48449 --
48450 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48451 (NVL(l_actual_upg_option, 'N') = 'O') OR
48452 (NVL(l_enc_upg_option, 'N') = 'O')
48453 )
48454 THEN
48455 NULL;
48456 --
48457 --
48458
48459 l_ccid := AcctDerRule_12(
48460 p_application_id => p_application_id
48461 , p_ae_header_id => l_ae_header_id
48462 , p_source_23 => p_source_23
48463 , x_transaction_coa_id => l_adr_transaction_coa_id
48464 , x_accounting_coa_id => l_adr_accounting_coa_id
48465 , x_value_type_code => l_adr_value_type_code
48466 , p_side => 'NA'
48467 );
48468
48469 xla_ae_lines_pkg.set_ccid(
48470 p_code_combination_id => l_ccid
48471 , p_value_type_code => l_adr_value_type_code
48472 , p_transaction_coa_id => l_adr_transaction_coa_id
48473 , p_accounting_coa_id => l_adr_accounting_coa_id
48474 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
48475 , p_adr_type_code => 'S'
48476 , p_component_type => l_component_type
48477 , p_component_code => l_component_code
48478 , p_component_type_code => l_component_type_code
48479 , p_component_appl_id => l_component_appl_id
48480 , p_amb_context_code => l_amb_context_code
48481 , p_side => 'NA'
48482 );
48483
48484
48485 --
48486 --
48487 END IF;
48488 --
48489 -- Bug 4922099
48490 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
48491 (NVL(l_enc_upg_option, 'N') = 'O')
48492 ) AND
48493 (l_bflow_method_code = 'PRIOR_ENTRY')
48494 )
48495 THEN
48496 IF
48497 --
48498 1 = 2
48499 --
48500 THEN
48501 xla_accounting_err_pkg.build_message
48502 (p_appli_s_name => 'XLA'
48503 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48504 ,p_token_1 => 'LINE_NUMBER'
48505 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
48506 ,p_token_2 => 'LINE_TYPE_NAME'
48507 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
48508 l_component_type
48509 ,l_component_code
48510 ,l_component_type_code
48511 ,l_component_appl_id
48512 ,l_amb_context_code
48513 ,l_entity_code
48514 ,l_event_class_code
48515 )
48516 ,p_token_3 => 'OWNER'
48517 ,p_value_3 => xla_lookups_pkg.get_meaning(
48518 p_lookup_type => 'XLA_OWNER_TYPE'
48519 ,p_lookup_code => l_component_type_code
48520 )
48521 ,p_token_4 => 'PRODUCT_NAME'
48522 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
48523 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
48524 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
48525 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
48526 ,p_ae_header_id => NULL
48527 );
48528
48529 IF (C_LEVEL_ERROR>= g_log_level) THEN
48530 trace
48531 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48532 ,p_level => C_LEVEL_ERROR
48533 ,p_module => l_log_module);
48534 END IF;
48535 END IF;
48536 END IF;
48537 --
48538 --
48539 ------------------------------------------------------------------------------------------------
48540 -- 4219869 Business Flow
48541 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
48542 -- Prior Entry. Currently, the following code is always generated.
48543 ------------------------------------------------------------------------------------------------
48544 XLA_AE_LINES_PKG.ValidateCurrentLine;
48545
48546 ------------------------------------------------------------------------------------
48547 -- 4219869 Business Flow
48548 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
48549 ------------------------------------------------------------------------------------
48550 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48551
48552 ----------------------------------------------------------------------------------
48553 -- 4219869 Business Flow
48554 -- Update journal entry status -- Need to generate this within IF <condition>
48555 ----------------------------------------------------------------------------------
48556 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48557 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
48558 ,p_balance_type_code => l_balance_type_code
48559 );
48560
48561 -------------------------------------------------------------------------------------------
48562 -- 4262811 - Generate the Accrual Reversal lines
48563 -------------------------------------------------------------------------------------------
48564 BEGIN
48565 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
48566 (g_array_event(p_event_id).array_value_num('header_index'));
48567 IF l_acc_rev_flag IS NULL THEN
48568 l_acc_rev_flag := 'N';
48569 END IF;
48570 EXCEPTION
48571 WHEN OTHERS THEN
48572 l_acc_rev_flag := 'N';
48573 END;
48574 --
48575 IF (l_acc_rev_flag = 'Y') THEN
48576
48577 -- 4645092 ------------------------------------------------------------------------------
48578 -- To allow MPA report to determine if it should generate report process
48579 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
48580 ------------------------------------------------------------------------------------------
48581
48582 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
48583 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
48584 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
48585 -- call ADRs
48586 -- Bug 4922099
48587 --
48588 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48589 (NVL(l_actual_upg_option, 'N') = 'O') OR
48590 (NVL(l_enc_upg_option, 'N') = 'O')
48591 )
48592 THEN
48593 NULL;
48594 --
48595 --
48596
48597 l_ccid := AcctDerRule_12(
48598 p_application_id => p_application_id
48599 , p_ae_header_id => l_ae_header_id
48600 , p_source_23 => p_source_23
48601 , x_transaction_coa_id => l_adr_transaction_coa_id
48602 , x_accounting_coa_id => l_adr_accounting_coa_id
48603 , x_value_type_code => l_adr_value_type_code
48604 , p_side => 'NA'
48605 );
48606
48607 xla_ae_lines_pkg.set_ccid(
48608 p_code_combination_id => l_ccid
48609 , p_value_type_code => l_adr_value_type_code
48610 , p_transaction_coa_id => l_adr_transaction_coa_id
48611 , p_accounting_coa_id => l_adr_accounting_coa_id
48612 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
48613 , p_adr_type_code => 'S'
48614 , p_component_type => l_component_type
48615 , p_component_code => l_component_code
48616 , p_component_type_code => l_component_type_code
48617 , p_component_appl_id => l_component_appl_id
48618 , p_amb_context_code => l_amb_context_code
48619 , p_side => 'NA'
48620 );
48621
48622
48623 --
48624 --
48625 END IF;
48626
48627 --
48628 -- Update the line information that should be overwritten
48629 --
48630 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48631 p_header_num => 1);
48632 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48633
48634 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48635
48636 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48637 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48638 END IF;
48639
48640 --
48641 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48642 --
48643 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48644 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48645 ELSE
48646 ---------------------------------------------------------------------------------------------------
48647 -- 4262811a Switch Sign
48648 ---------------------------------------------------------------------------------------------------
48649 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48650 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48652 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48653 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48654 -- 5132302
48655 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48656 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48657
48658 END IF;
48659
48660 -- 4955764
48661 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48662 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48663
48664
48665 XLA_AE_LINES_PKG.ValidateCurrentLine;
48666 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48667
48668 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48669 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48670 ,p_balance_type_code => l_balance_type_code);
48671
48672 END IF;
48673
48674 -----------------------------------------------------------------------------------------
48675 -- 4262811 Multiperiod Accounting
48676 -----------------------------------------------------------------------------------------
48677 -- No MPA option is assigned.
48678
48679
48680 END IF;
48681 END IF;
48682 --
48683
48684 --
48685 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48686 trace
48687 (p_msg => 'END of AcctLineType_110'
48688 ,p_level => C_LEVEL_PROCEDURE
48689 ,p_module => l_log_module);
48690 END IF;
48691 --
48692 EXCEPTION
48693 WHEN xla_exceptions_pkg.application_exception THEN
48694 RAISE;
48695 WHEN OTHERS THEN
48696 xla_exceptions_pkg.raise_message
48697 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_110');
48698 END AcctLineType_110;
48699 --
48700
48701 ---------------------------------------
48702 --
48703 -- PRIVATE FUNCTION
48704 -- AcctLineType_111
48705 --
48706 ---------------------------------------
48707 PROCEDURE AcctLineType_111 (
48708 p_application_id IN NUMBER
48709 ,p_event_id IN NUMBER
48710 ,p_calculate_acctd_flag IN VARCHAR2
48711 ,p_calculate_g_l_flag IN VARCHAR2
48712 ,p_actual_flag IN OUT VARCHAR2
48713 ,p_balance_type_code OUT VARCHAR2
48714 ,p_gain_or_loss_ref OUT VARCHAR2
48715
48716 --TRANSACTION_ID
48717 , p_source_1 IN NUMBER
48718 --Item Concatenated Segments
48719 , p_source_2 IN VARCHAR2
48720 --Transaction Quantity
48721 , p_source_3 IN NUMBER
48722 --Transaction Unit of Measure Code
48723 , p_source_4 IN VARCHAR2
48724 --Inventory Transaction Type Description
48725 , p_source_5 IN VARCHAR2
48726 --Product Line Accounting Category Average Cost Variance Account
48727 , p_source_23 IN NUMBER
48728 --DISTRIBUTION_IDENTIFIER
48729 , p_source_84 IN NUMBER
48730 --Distribution Type
48731 , p_source_85 IN VARCHAR2
48732 , p_source_85_meaning IN VARCHAR2
48733 --Entered Currency Code
48734 , p_source_88 IN VARCHAR2
48735 --Entered Amount
48736 , p_source_91 IN NUMBER
48737 --Currency Conversion Date
48738 , p_source_92 IN DATE
48739 --Currency Conversion Rate
48740 , p_source_93 IN NUMBER
48741 --Currency Conversion Type
48742 , p_source_94 IN VARCHAR2
48743 --Accounted Amount
48744 , p_source_95 IN NUMBER
48745 --Accounting Line Type
48746 , p_source_97 IN NUMBER
48747 )
48748 IS
48749
48750 l_component_type VARCHAR2(80);
48751 l_component_code VARCHAR2(30);
48752 l_component_type_code VARCHAR2(1);
48753 l_component_appl_id INTEGER;
48754 l_amb_context_code VARCHAR2(30);
48755 l_entity_code VARCHAR2(30);
48756 l_event_class_code VARCHAR2(30);
48757 l_ae_header_id NUMBER;
48758 l_event_type_code VARCHAR2(30);
48759 l_line_definition_code VARCHAR2(30);
48760 l_line_definition_owner_code VARCHAR2(1);
48761 --
48762 -- adr variables
48763 l_segment VARCHAR2(30);
48764 l_ccid NUMBER;
48765 l_adr_transaction_coa_id NUMBER;
48766 l_adr_accounting_coa_id NUMBER;
48767 l_adr_flexfield_segment_code VARCHAR2(30);
48768 l_adr_flex_value_set_id NUMBER;
48769 l_adr_value_type_code VARCHAR2(30);
48770 l_adr_value_combination_id NUMBER;
48771 l_adr_value_segment_code VARCHAR2(30);
48772
48773 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48774 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48775 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48776 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48777
48778 -- 4262811 Variables ------------------------------------------------------------------------------------------
48779 l_entered_amt_idx NUMBER;
48780 l_accted_amt_idx NUMBER;
48781 l_acc_rev_flag VARCHAR2(1);
48782 l_accrual_line_num NUMBER;
48783 l_tmp_amt NUMBER;
48784 l_acc_rev_natural_side_code VARCHAR2(1);
48785
48786 l_num_entries NUMBER;
48787 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48788 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48789 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48790 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48791 l_recog_line_1 NUMBER;
48792 l_recog_line_2 NUMBER;
48793
48794 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48795 l_bflow_applied_to_amt NUMBER; -- 5132302
48796 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48797
48798 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48799
48800 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48801 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48802
48803 ---------------------------------------------------------------------------------------------------------------
48804
48805
48806 --
48807 -- bulk performance
48808 --
48809 l_balance_type_code VARCHAR2(1);
48810 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48811 l_log_module VARCHAR2(240);
48812
48813 --
48814 -- Upgrade strategy
48815 --
48816 l_actual_upg_option VARCHAR2(1);
48817 l_enc_upg_option VARCHAR2(1);
48818
48819 --
48820 BEGIN
48821 --
48822 IF g_log_enabled THEN
48823 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_111';
48824 END IF;
48825 --
48826 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48827
48828 trace
48829 (p_msg => 'BEGIN of AcctLineType_111'
48830 ,p_level => C_LEVEL_PROCEDURE
48831 ,p_module => l_log_module);
48832
48833 END IF;
48834 --
48835 l_component_type := 'AMB_JLT';
48836 l_component_code := 'COST_VARIANCE';
48837 l_component_type_code := 'S';
48838 l_component_appl_id := 707;
48839 l_amb_context_code := 'DEFAULT';
48840 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
48841 l_event_class_code := 'USER_DEFINE';
48842 l_event_type_code := 'UIPV_TXFR';
48843 l_line_definition_owner_code := 'S';
48844 l_line_definition_code := 'PI_IPV_TXFR';
48845 --
48846 l_balance_type_code := 'A';
48847 l_segment := NULL;
48848 l_ccid := NULL;
48849 l_adr_transaction_coa_id := NULL;
48850 l_adr_accounting_coa_id := NULL;
48851 l_adr_flexfield_segment_code := NULL;
48852 l_adr_flex_value_set_id := NULL;
48853 l_adr_value_type_code := NULL;
48854 l_adr_value_combination_id := NULL;
48855 l_adr_value_segment_code := NULL;
48856
48857 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48858 l_bflow_class_code := ''; -- 4219869 Business Flow
48859 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48860 l_budgetary_control_flag := 'N';
48861
48862 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48863 l_bflow_applied_to_amt := NULL; -- 5132302
48864 l_entered_amt_idx := NULL; -- 4262811
48865 l_accted_amt_idx := NULL; -- 4262811
48866 l_acc_rev_flag := NULL; -- 4262811
48867 l_accrual_line_num := NULL; -- 4262811
48868 l_tmp_amt := NULL; -- 4262811
48869 --
48870
48871 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48872 l_balance_type_code <> 'B' THEN
48873 IF NVL(p_source_97,9E125) = 13
48874 THEN
48875
48876 --
48877 XLA_AE_LINES_PKG.SetNewLine;
48878
48879 p_balance_type_code := l_balance_type_code;
48880 -- set the flag so later we will know whether the gain loss line needs to be created
48881
48882 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48883 p_actual_flag :='A';
48884 END IF;
48885
48886 --
48887 -- bulk performance
48888 --
48889 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48890 p_header_num => 0); -- 4262811
48891 --
48892 -- set accounting line options
48893 --
48894 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48895 p_natural_side_code => 'D'
48896 , p_gain_or_loss_flag => 'N'
48897 , p_gl_transfer_mode_code => 'S'
48898 , p_acct_entry_type_code => 'A'
48899 , p_switch_side_flag => 'Y'
48900 , p_merge_duplicate_code => 'N'
48901 );
48902 --
48903 l_acc_rev_natural_side_code := 'C'; -- 4262811
48904 --
48905 --
48906 -- set accounting line type info
48907 --
48908 xla_ae_lines_pkg.SetAcctLineType
48909 (p_component_type => l_component_type
48910 ,p_event_type_code => l_event_type_code
48911 ,p_line_definition_owner_code => l_line_definition_owner_code
48912 ,p_line_definition_code => l_line_definition_code
48913 ,p_accounting_line_code => l_component_code
48914 ,p_accounting_line_type_code => l_component_type_code
48915 ,p_accounting_line_appl_id => l_component_appl_id
48916 ,p_amb_context_code => l_amb_context_code
48917 ,p_entity_code => l_entity_code
48918 ,p_event_class_code => l_event_class_code);
48919 --
48920 -- set accounting class
48921 --
48922 xla_ae_lines_pkg.SetAcctClass(
48923 p_accounting_class_code => 'COST_VARIANCE'
48924 , p_ae_header_id => l_ae_header_id
48925 );
48926
48927 --
48928 -- set rounding class
48929 --
48930 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48931 'COST_VARIANCE';
48932
48933 --
48934 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48935 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48936 --
48937 -- bulk performance
48938 --
48939 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48940
48941 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48942 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48943
48944 -- 4955764
48945 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48946 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48947
48948 -- 4458381 Public Sector Enh
48949
48950 --
48951 -- set accounting attributes for the line type
48952 --
48953 l_entered_amt_idx := 3;
48954 l_accted_amt_idx := 8;
48955 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48956 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
48957 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
48958 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
48959 l_rec_acct_attrs.array_char_value(2) := p_source_85;
48960 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
48961 l_rec_acct_attrs.array_num_value(3) := p_source_91;
48962 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
48963 l_rec_acct_attrs.array_char_value(4) := p_source_88;
48964 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
48965 l_rec_acct_attrs.array_date_value(5) := p_source_92;
48966 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
48967 l_rec_acct_attrs.array_num_value(6) := p_source_93;
48968 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
48969 l_rec_acct_attrs.array_char_value(7) := p_source_94;
48970 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
48971 l_rec_acct_attrs.array_num_value(8) := p_source_95;
48972
48973 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48974 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48975
48976 ---------------------------------------------------------------------------------------------------------------
48977 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48978 ---------------------------------------------------------------------------------------------------------------
48979 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48980
48981 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48982 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48983
48984 IF xla_accounting_cache_pkg.GetValueChar
48985 (p_source_code => 'LEDGER_CATEGORY_CODE'
48986 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48987 AND l_bflow_method_code = 'PRIOR_ENTRY'
48988 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48989 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48990 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48991 )
48992 THEN
48993 xla_ae_lines_pkg.BflowUpgEntry
48994 (p_business_method_code => l_bflow_method_code
48995 ,p_business_class_code => l_bflow_class_code
48996 ,p_balance_type => l_balance_type_code);
48997 ELSE
48998 NULL;
48999 -- No business flow processing for business flow method of NONE.
49000 END IF;
49001
49002 --
49003 -- call analytical criteria
49004 --
49005
49006 --
49007 -- call description
49008 --
49009
49010 xla_ae_lines_pkg.SetLineDescription(
49011 p_ae_header_id => l_ae_header_id
49012 ,p_description => Description_1 (
49013 p_application_id => p_application_id
49014 , p_ae_header_id => l_ae_header_id
49015 , p_source_1 => p_source_1
49016 , p_source_2 => p_source_2
49017 , p_source_3 => p_source_3
49018 , p_source_4 => p_source_4
49019 , p_source_5 => p_source_5
49020 )
49021 );
49022
49023
49024 --
49025 -- call ADRs
49026 -- Bug 4922099
49027 --
49028 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49029 (NVL(l_actual_upg_option, 'N') = 'O') OR
49030 (NVL(l_enc_upg_option, 'N') = 'O')
49031 )
49032 THEN
49033 NULL;
49034 --
49035 --
49036
49037 l_ccid := AcctDerRule_12(
49038 p_application_id => p_application_id
49039 , p_ae_header_id => l_ae_header_id
49040 , p_source_23 => p_source_23
49041 , x_transaction_coa_id => l_adr_transaction_coa_id
49042 , x_accounting_coa_id => l_adr_accounting_coa_id
49043 , x_value_type_code => l_adr_value_type_code
49044 , p_side => 'NA'
49045 );
49046
49047 xla_ae_lines_pkg.set_ccid(
49048 p_code_combination_id => l_ccid
49049 , p_value_type_code => l_adr_value_type_code
49050 , p_transaction_coa_id => l_adr_transaction_coa_id
49051 , p_accounting_coa_id => l_adr_accounting_coa_id
49052 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
49053 , p_adr_type_code => 'S'
49054 , p_component_type => l_component_type
49055 , p_component_code => l_component_code
49056 , p_component_type_code => l_component_type_code
49057 , p_component_appl_id => l_component_appl_id
49058 , p_amb_context_code => l_amb_context_code
49059 , p_side => 'NA'
49060 );
49061
49062
49063 --
49064 --
49065 END IF;
49066 --
49067 -- Bug 4922099
49068 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49069 (NVL(l_enc_upg_option, 'N') = 'O')
49070 ) AND
49071 (l_bflow_method_code = 'PRIOR_ENTRY')
49072 )
49073 THEN
49074 IF
49075 --
49076 1 = 2
49077 --
49078 THEN
49079 xla_accounting_err_pkg.build_message
49080 (p_appli_s_name => 'XLA'
49081 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49082 ,p_token_1 => 'LINE_NUMBER'
49083 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49084 ,p_token_2 => 'LINE_TYPE_NAME'
49085 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49086 l_component_type
49087 ,l_component_code
49088 ,l_component_type_code
49089 ,l_component_appl_id
49090 ,l_amb_context_code
49091 ,l_entity_code
49092 ,l_event_class_code
49093 )
49094 ,p_token_3 => 'OWNER'
49095 ,p_value_3 => xla_lookups_pkg.get_meaning(
49096 p_lookup_type => 'XLA_OWNER_TYPE'
49097 ,p_lookup_code => l_component_type_code
49098 )
49099 ,p_token_4 => 'PRODUCT_NAME'
49100 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49101 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49102 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49103 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49104 ,p_ae_header_id => NULL
49105 );
49106
49107 IF (C_LEVEL_ERROR>= g_log_level) THEN
49108 trace
49109 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49110 ,p_level => C_LEVEL_ERROR
49111 ,p_module => l_log_module);
49112 END IF;
49113 END IF;
49114 END IF;
49115 --
49116 --
49117 ------------------------------------------------------------------------------------------------
49118 -- 4219869 Business Flow
49119 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49120 -- Prior Entry. Currently, the following code is always generated.
49121 ------------------------------------------------------------------------------------------------
49122 XLA_AE_LINES_PKG.ValidateCurrentLine;
49123
49124 ------------------------------------------------------------------------------------
49125 -- 4219869 Business Flow
49126 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49127 ------------------------------------------------------------------------------------
49128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49129
49130 ----------------------------------------------------------------------------------
49131 -- 4219869 Business Flow
49132 -- Update journal entry status -- Need to generate this within IF <condition>
49133 ----------------------------------------------------------------------------------
49134 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49135 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49136 ,p_balance_type_code => l_balance_type_code
49137 );
49138
49139 -------------------------------------------------------------------------------------------
49140 -- 4262811 - Generate the Accrual Reversal lines
49141 -------------------------------------------------------------------------------------------
49142 BEGIN
49143 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49144 (g_array_event(p_event_id).array_value_num('header_index'));
49145 IF l_acc_rev_flag IS NULL THEN
49146 l_acc_rev_flag := 'N';
49147 END IF;
49148 EXCEPTION
49149 WHEN OTHERS THEN
49150 l_acc_rev_flag := 'N';
49151 END;
49152 --
49153 IF (l_acc_rev_flag = 'Y') THEN
49154
49155 -- 4645092 ------------------------------------------------------------------------------
49156 -- To allow MPA report to determine if it should generate report process
49157 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49158 ------------------------------------------------------------------------------------------
49159
49160 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49161 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49162 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49163 -- call ADRs
49164 -- Bug 4922099
49165 --
49166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49167 (NVL(l_actual_upg_option, 'N') = 'O') OR
49168 (NVL(l_enc_upg_option, 'N') = 'O')
49169 )
49170 THEN
49171 NULL;
49172 --
49173 --
49174
49175 l_ccid := AcctDerRule_12(
49176 p_application_id => p_application_id
49177 , p_ae_header_id => l_ae_header_id
49178 , p_source_23 => p_source_23
49179 , x_transaction_coa_id => l_adr_transaction_coa_id
49180 , x_accounting_coa_id => l_adr_accounting_coa_id
49181 , x_value_type_code => l_adr_value_type_code
49182 , p_side => 'NA'
49183 );
49184
49185 xla_ae_lines_pkg.set_ccid(
49186 p_code_combination_id => l_ccid
49187 , p_value_type_code => l_adr_value_type_code
49188 , p_transaction_coa_id => l_adr_transaction_coa_id
49189 , p_accounting_coa_id => l_adr_accounting_coa_id
49190 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
49191 , p_adr_type_code => 'S'
49192 , p_component_type => l_component_type
49193 , p_component_code => l_component_code
49194 , p_component_type_code => l_component_type_code
49195 , p_component_appl_id => l_component_appl_id
49196 , p_amb_context_code => l_amb_context_code
49197 , p_side => 'NA'
49198 );
49199
49200
49201 --
49202 --
49203 END IF;
49204
49205 --
49206 -- Update the line information that should be overwritten
49207 --
49208 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49209 p_header_num => 1);
49210 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49211
49212 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49213
49214 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49215 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49216 END IF;
49217
49218 --
49219 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49220 --
49221 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49222 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49223 ELSE
49224 ---------------------------------------------------------------------------------------------------
49225 -- 4262811a Switch Sign
49226 ---------------------------------------------------------------------------------------------------
49227 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49229 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49230 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49231 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49232 -- 5132302
49233 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49234 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49235
49236 END IF;
49237
49238 -- 4955764
49239 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49240 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49241
49242
49243 XLA_AE_LINES_PKG.ValidateCurrentLine;
49244 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49245
49246 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49247 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49248 ,p_balance_type_code => l_balance_type_code);
49249
49250 END IF;
49251
49252 -----------------------------------------------------------------------------------------
49253 -- 4262811 Multiperiod Accounting
49254 -----------------------------------------------------------------------------------------
49255 -- No MPA option is assigned.
49256
49257
49258 END IF;
49259 END IF;
49260 --
49261
49262 --
49263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49264 trace
49265 (p_msg => 'END of AcctLineType_111'
49266 ,p_level => C_LEVEL_PROCEDURE
49267 ,p_module => l_log_module);
49268 END IF;
49269 --
49270 EXCEPTION
49271 WHEN xla_exceptions_pkg.application_exception THEN
49272 RAISE;
49273 WHEN OTHERS THEN
49274 xla_exceptions_pkg.raise_message
49275 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_111');
49276 END AcctLineType_111;
49277 --
49278
49279 ---------------------------------------
49280 --
49281 -- PRIVATE FUNCTION
49282 -- AcctLineType_112
49283 --
49284 ---------------------------------------
49285 PROCEDURE AcctLineType_112 (
49286 p_application_id IN NUMBER
49287 ,p_event_id IN NUMBER
49288 ,p_calculate_acctd_flag IN VARCHAR2
49289 ,p_calculate_g_l_flag IN VARCHAR2
49290 ,p_actual_flag IN OUT VARCHAR2
49291 ,p_balance_type_code OUT VARCHAR2
49292 ,p_gain_or_loss_ref OUT VARCHAR2
49293
49294 --Product Line Accounting Category Average Cost Variance Account
49295 , p_source_23 IN NUMBER
49296 --DISTRIBUTION_IDENTIFIER
49297 , p_source_84 IN NUMBER
49298 --Distribution Type
49299 , p_source_85 IN VARCHAR2
49300 , p_source_85_meaning IN VARCHAR2
49301 --Entered Currency Code
49302 , p_source_88 IN VARCHAR2
49303 --Entered Amount
49304 , p_source_91 IN NUMBER
49305 --Currency Conversion Date
49306 , p_source_92 IN DATE
49307 --Currency Conversion Rate
49308 , p_source_93 IN NUMBER
49309 --Currency Conversion Type
49310 , p_source_94 IN VARCHAR2
49311 --Accounted Amount
49312 , p_source_95 IN NUMBER
49313 --Accounting Line Type
49314 , p_source_97 IN NUMBER
49315 )
49316 IS
49317
49318 l_component_type VARCHAR2(80);
49319 l_component_code VARCHAR2(30);
49320 l_component_type_code VARCHAR2(1);
49321 l_component_appl_id INTEGER;
49322 l_amb_context_code VARCHAR2(30);
49323 l_entity_code VARCHAR2(30);
49324 l_event_class_code VARCHAR2(30);
49325 l_ae_header_id NUMBER;
49326 l_event_type_code VARCHAR2(30);
49327 l_line_definition_code VARCHAR2(30);
49328 l_line_definition_owner_code VARCHAR2(1);
49329 --
49330 -- adr variables
49331 l_segment VARCHAR2(30);
49332 l_ccid NUMBER;
49333 l_adr_transaction_coa_id NUMBER;
49334 l_adr_accounting_coa_id NUMBER;
49335 l_adr_flexfield_segment_code VARCHAR2(30);
49336 l_adr_flex_value_set_id NUMBER;
49337 l_adr_value_type_code VARCHAR2(30);
49338 l_adr_value_combination_id NUMBER;
49339 l_adr_value_segment_code VARCHAR2(30);
49340
49341 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49342 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49343 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49344 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49345
49346 -- 4262811 Variables ------------------------------------------------------------------------------------------
49347 l_entered_amt_idx NUMBER;
49348 l_accted_amt_idx NUMBER;
49349 l_acc_rev_flag VARCHAR2(1);
49350 l_accrual_line_num NUMBER;
49351 l_tmp_amt NUMBER;
49352 l_acc_rev_natural_side_code VARCHAR2(1);
49353
49354 l_num_entries NUMBER;
49355 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49356 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49357 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49358 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49359 l_recog_line_1 NUMBER;
49360 l_recog_line_2 NUMBER;
49361
49362 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49363 l_bflow_applied_to_amt NUMBER; -- 5132302
49364 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49365
49366 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49367
49368 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49369 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49370
49371 ---------------------------------------------------------------------------------------------------------------
49372
49373
49374 --
49375 -- bulk performance
49376 --
49377 l_balance_type_code VARCHAR2(1);
49378 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49379 l_log_module VARCHAR2(240);
49380
49381 --
49382 -- Upgrade strategy
49383 --
49384 l_actual_upg_option VARCHAR2(1);
49385 l_enc_upg_option VARCHAR2(1);
49386
49387 --
49388 BEGIN
49389 --
49390 IF g_log_enabled THEN
49391 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_112';
49392 END IF;
49393 --
49394 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49395
49396 trace
49397 (p_msg => 'BEGIN of AcctLineType_112'
49398 ,p_level => C_LEVEL_PROCEDURE
49399 ,p_module => l_log_module);
49400
49401 END IF;
49402 --
49403 l_component_type := 'AMB_JLT';
49404 l_component_code := 'COST_VARIANCE';
49405 l_component_type_code := 'S';
49406 l_component_appl_id := 707;
49407 l_amb_context_code := 'DEFAULT';
49408 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
49409 l_event_class_code := 'USER_DEFINE';
49410 l_event_type_code := 'UMISC_RCPT';
49411 l_line_definition_owner_code := 'S';
49412 l_line_definition_code := 'PI_USER_RCPT';
49413 --
49414 l_balance_type_code := 'A';
49415 l_segment := NULL;
49416 l_ccid := NULL;
49417 l_adr_transaction_coa_id := NULL;
49418 l_adr_accounting_coa_id := NULL;
49419 l_adr_flexfield_segment_code := NULL;
49420 l_adr_flex_value_set_id := NULL;
49421 l_adr_value_type_code := NULL;
49422 l_adr_value_combination_id := NULL;
49423 l_adr_value_segment_code := NULL;
49424
49425 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49426 l_bflow_class_code := ''; -- 4219869 Business Flow
49427 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49428 l_budgetary_control_flag := 'N';
49429
49430 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49431 l_bflow_applied_to_amt := NULL; -- 5132302
49432 l_entered_amt_idx := NULL; -- 4262811
49433 l_accted_amt_idx := NULL; -- 4262811
49434 l_acc_rev_flag := NULL; -- 4262811
49435 l_accrual_line_num := NULL; -- 4262811
49436 l_tmp_amt := NULL; -- 4262811
49437 --
49438
49439 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
49440 l_balance_type_code <> 'B' THEN
49441 IF NVL(p_source_97,9E125) = 13
49442 THEN
49443
49444 --
49445 XLA_AE_LINES_PKG.SetNewLine;
49446
49447 p_balance_type_code := l_balance_type_code;
49448 -- set the flag so later we will know whether the gain loss line needs to be created
49449
49450 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
49451 p_actual_flag :='A';
49452 END IF;
49453
49454 --
49455 -- bulk performance
49456 --
49457 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
49458 p_header_num => 0); -- 4262811
49459 --
49460 -- set accounting line options
49461 --
49462 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
49463 p_natural_side_code => 'D'
49464 , p_gain_or_loss_flag => 'N'
49465 , p_gl_transfer_mode_code => 'S'
49466 , p_acct_entry_type_code => 'A'
49467 , p_switch_side_flag => 'Y'
49468 , p_merge_duplicate_code => 'N'
49469 );
49470 --
49471 l_acc_rev_natural_side_code := 'C'; -- 4262811
49472 --
49473 --
49474 -- set accounting line type info
49475 --
49476 xla_ae_lines_pkg.SetAcctLineType
49477 (p_component_type => l_component_type
49478 ,p_event_type_code => l_event_type_code
49479 ,p_line_definition_owner_code => l_line_definition_owner_code
49480 ,p_line_definition_code => l_line_definition_code
49481 ,p_accounting_line_code => l_component_code
49482 ,p_accounting_line_type_code => l_component_type_code
49483 ,p_accounting_line_appl_id => l_component_appl_id
49484 ,p_amb_context_code => l_amb_context_code
49485 ,p_entity_code => l_entity_code
49486 ,p_event_class_code => l_event_class_code);
49487 --
49488 -- set accounting class
49489 --
49490 xla_ae_lines_pkg.SetAcctClass(
49491 p_accounting_class_code => 'COST_VARIANCE'
49492 , p_ae_header_id => l_ae_header_id
49493 );
49494
49495 --
49496 -- set rounding class
49497 --
49498 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
49499 'COST_VARIANCE';
49500
49501 --
49502 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
49503 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
49504 --
49505 -- bulk performance
49506 --
49507 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
49508
49509 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
49510 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
49511
49512 -- 4955764
49513 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49514 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
49515
49516 -- 4458381 Public Sector Enh
49517
49518 --
49519 -- set accounting attributes for the line type
49520 --
49521 l_entered_amt_idx := 3;
49522 l_accted_amt_idx := 8;
49523 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49524 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
49525 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
49526 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
49527 l_rec_acct_attrs.array_char_value(2) := p_source_85;
49528 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
49529 l_rec_acct_attrs.array_num_value(3) := p_source_91;
49530 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
49531 l_rec_acct_attrs.array_char_value(4) := p_source_88;
49532 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
49533 l_rec_acct_attrs.array_date_value(5) := p_source_92;
49534 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
49535 l_rec_acct_attrs.array_num_value(6) := p_source_93;
49536 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
49537 l_rec_acct_attrs.array_char_value(7) := p_source_94;
49538 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
49539 l_rec_acct_attrs.array_num_value(8) := p_source_95;
49540
49541 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
49542 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
49543
49544 ---------------------------------------------------------------------------------------------------------------
49545 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
49546 ---------------------------------------------------------------------------------------------------------------
49547 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
49548
49549 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49550 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49551
49552 IF xla_accounting_cache_pkg.GetValueChar
49553 (p_source_code => 'LEDGER_CATEGORY_CODE'
49554 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
49555 AND l_bflow_method_code = 'PRIOR_ENTRY'
49556 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
49557 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
49558 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
49559 )
49560 THEN
49561 xla_ae_lines_pkg.BflowUpgEntry
49562 (p_business_method_code => l_bflow_method_code
49563 ,p_business_class_code => l_bflow_class_code
49564 ,p_balance_type => l_balance_type_code);
49565 ELSE
49566 NULL;
49567 -- No business flow processing for business flow method of NONE.
49568 END IF;
49569
49570 --
49571 -- call analytical criteria
49572 --
49573
49574 --
49575 -- call description
49576 --
49577 -- No description or it is inherited.
49578 --
49579 -- call ADRs
49580 -- Bug 4922099
49581 --
49582 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49583 (NVL(l_actual_upg_option, 'N') = 'O') OR
49584 (NVL(l_enc_upg_option, 'N') = 'O')
49585 )
49586 THEN
49587 NULL;
49588 --
49589 --
49590
49591 l_ccid := AcctDerRule_12(
49592 p_application_id => p_application_id
49593 , p_ae_header_id => l_ae_header_id
49594 , p_source_23 => p_source_23
49595 , x_transaction_coa_id => l_adr_transaction_coa_id
49596 , x_accounting_coa_id => l_adr_accounting_coa_id
49597 , x_value_type_code => l_adr_value_type_code
49598 , p_side => 'NA'
49599 );
49600
49601 xla_ae_lines_pkg.set_ccid(
49602 p_code_combination_id => l_ccid
49603 , p_value_type_code => l_adr_value_type_code
49604 , p_transaction_coa_id => l_adr_transaction_coa_id
49605 , p_accounting_coa_id => l_adr_accounting_coa_id
49606 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
49607 , p_adr_type_code => 'S'
49608 , p_component_type => l_component_type
49609 , p_component_code => l_component_code
49610 , p_component_type_code => l_component_type_code
49611 , p_component_appl_id => l_component_appl_id
49612 , p_amb_context_code => l_amb_context_code
49613 , p_side => 'NA'
49614 );
49615
49616
49617 --
49618 --
49619 END IF;
49620 --
49621 -- Bug 4922099
49622 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49623 (NVL(l_enc_upg_option, 'N') = 'O')
49624 ) AND
49625 (l_bflow_method_code = 'PRIOR_ENTRY')
49626 )
49627 THEN
49628 IF
49629 --
49630 1 = 2
49631 --
49632 THEN
49633 xla_accounting_err_pkg.build_message
49634 (p_appli_s_name => 'XLA'
49635 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49636 ,p_token_1 => 'LINE_NUMBER'
49637 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49638 ,p_token_2 => 'LINE_TYPE_NAME'
49639 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49640 l_component_type
49641 ,l_component_code
49642 ,l_component_type_code
49643 ,l_component_appl_id
49644 ,l_amb_context_code
49645 ,l_entity_code
49646 ,l_event_class_code
49647 )
49648 ,p_token_3 => 'OWNER'
49649 ,p_value_3 => xla_lookups_pkg.get_meaning(
49650 p_lookup_type => 'XLA_OWNER_TYPE'
49651 ,p_lookup_code => l_component_type_code
49652 )
49653 ,p_token_4 => 'PRODUCT_NAME'
49654 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49655 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49656 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49657 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49658 ,p_ae_header_id => NULL
49659 );
49660
49661 IF (C_LEVEL_ERROR>= g_log_level) THEN
49662 trace
49663 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49664 ,p_level => C_LEVEL_ERROR
49665 ,p_module => l_log_module);
49666 END IF;
49667 END IF;
49668 END IF;
49669 --
49670 --
49671 ------------------------------------------------------------------------------------------------
49672 -- 4219869 Business Flow
49673 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49674 -- Prior Entry. Currently, the following code is always generated.
49675 ------------------------------------------------------------------------------------------------
49676 XLA_AE_LINES_PKG.ValidateCurrentLine;
49677
49678 ------------------------------------------------------------------------------------
49679 -- 4219869 Business Flow
49680 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49681 ------------------------------------------------------------------------------------
49682 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49683
49684 ----------------------------------------------------------------------------------
49685 -- 4219869 Business Flow
49686 -- Update journal entry status -- Need to generate this within IF <condition>
49687 ----------------------------------------------------------------------------------
49688 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49689 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49690 ,p_balance_type_code => l_balance_type_code
49691 );
49692
49693 -------------------------------------------------------------------------------------------
49694 -- 4262811 - Generate the Accrual Reversal lines
49695 -------------------------------------------------------------------------------------------
49696 BEGIN
49697 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49698 (g_array_event(p_event_id).array_value_num('header_index'));
49699 IF l_acc_rev_flag IS NULL THEN
49700 l_acc_rev_flag := 'N';
49701 END IF;
49702 EXCEPTION
49703 WHEN OTHERS THEN
49704 l_acc_rev_flag := 'N';
49705 END;
49706 --
49707 IF (l_acc_rev_flag = 'Y') THEN
49708
49709 -- 4645092 ------------------------------------------------------------------------------
49710 -- To allow MPA report to determine if it should generate report process
49711 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49712 ------------------------------------------------------------------------------------------
49713
49714 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49715 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49716 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49717 -- call ADRs
49718 -- Bug 4922099
49719 --
49720 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49721 (NVL(l_actual_upg_option, 'N') = 'O') OR
49722 (NVL(l_enc_upg_option, 'N') = 'O')
49723 )
49724 THEN
49725 NULL;
49726 --
49727 --
49728
49729 l_ccid := AcctDerRule_12(
49730 p_application_id => p_application_id
49731 , p_ae_header_id => l_ae_header_id
49732 , p_source_23 => p_source_23
49733 , x_transaction_coa_id => l_adr_transaction_coa_id
49734 , x_accounting_coa_id => l_adr_accounting_coa_id
49735 , x_value_type_code => l_adr_value_type_code
49736 , p_side => 'NA'
49737 );
49738
49739 xla_ae_lines_pkg.set_ccid(
49740 p_code_combination_id => l_ccid
49741 , p_value_type_code => l_adr_value_type_code
49742 , p_transaction_coa_id => l_adr_transaction_coa_id
49743 , p_accounting_coa_id => l_adr_accounting_coa_id
49744 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
49745 , p_adr_type_code => 'S'
49746 , p_component_type => l_component_type
49747 , p_component_code => l_component_code
49748 , p_component_type_code => l_component_type_code
49749 , p_component_appl_id => l_component_appl_id
49750 , p_amb_context_code => l_amb_context_code
49751 , p_side => 'NA'
49752 );
49753
49754
49755 --
49756 --
49757 END IF;
49758
49759 --
49760 -- Update the line information that should be overwritten
49761 --
49762 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49763 p_header_num => 1);
49764 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49765
49766 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49767
49768 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49769 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49770 END IF;
49771
49772 --
49773 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49774 --
49775 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49776 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49777 ELSE
49778 ---------------------------------------------------------------------------------------------------
49779 -- 4262811a Switch Sign
49780 ---------------------------------------------------------------------------------------------------
49781 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49782 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49783 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49784 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49785 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49786 -- 5132302
49787 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49788 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49789
49790 END IF;
49791
49792 -- 4955764
49793 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49794 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49795
49796
49797 XLA_AE_LINES_PKG.ValidateCurrentLine;
49798 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49799
49800 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49801 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49802 ,p_balance_type_code => l_balance_type_code);
49803
49804 END IF;
49805
49806 -----------------------------------------------------------------------------------------
49807 -- 4262811 Multiperiod Accounting
49808 -----------------------------------------------------------------------------------------
49809 -- No MPA option is assigned.
49810
49811
49812 END IF;
49813 END IF;
49814 --
49815
49816 --
49817 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49818 trace
49819 (p_msg => 'END of AcctLineType_112'
49820 ,p_level => C_LEVEL_PROCEDURE
49821 ,p_module => l_log_module);
49822 END IF;
49823 --
49824 EXCEPTION
49825 WHEN xla_exceptions_pkg.application_exception THEN
49826 RAISE;
49827 WHEN OTHERS THEN
49828 xla_exceptions_pkg.raise_message
49829 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_112');
49830 END AcctLineType_112;
49831 --
49832
49833 ---------------------------------------
49834 --
49835 -- PRIVATE FUNCTION
49836 -- AcctLineType_113
49837 --
49838 ---------------------------------------
49839 PROCEDURE AcctLineType_113 (
49840 p_application_id IN NUMBER
49841 ,p_event_id IN NUMBER
49842 ,p_calculate_acctd_flag IN VARCHAR2
49843 ,p_calculate_g_l_flag IN VARCHAR2
49844 ,p_actual_flag IN OUT VARCHAR2
49845 ,p_balance_type_code OUT VARCHAR2
49846 ,p_gain_or_loss_ref OUT VARCHAR2
49847
49848 --TRANSACTION_ID
49849 , p_source_1 IN NUMBER
49850 --Item Concatenated Segments
49851 , p_source_2 IN VARCHAR2
49852 --Transaction Quantity
49853 , p_source_3 IN NUMBER
49854 --Transaction Unit of Measure Code
49855 , p_source_4 IN VARCHAR2
49856 --Inventory Transaction Type Description
49857 , p_source_5 IN VARCHAR2
49858 --Product Line Accounting Category Average Cost Variance Account
49859 , p_source_23 IN NUMBER
49860 --DISTRIBUTION_IDENTIFIER
49861 , p_source_84 IN NUMBER
49862 --Distribution Type
49863 , p_source_85 IN VARCHAR2
49864 , p_source_85_meaning IN VARCHAR2
49865 --Entered Currency Code
49866 , p_source_88 IN VARCHAR2
49867 --Entered Amount
49868 , p_source_91 IN NUMBER
49869 --Currency Conversion Date
49870 , p_source_92 IN DATE
49871 --Currency Conversion Rate
49872 , p_source_93 IN NUMBER
49873 --Currency Conversion Type
49874 , p_source_94 IN VARCHAR2
49875 --Accounted Amount
49876 , p_source_95 IN NUMBER
49877 --Accounting Line Type
49878 , p_source_97 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_113';
49956 END IF;
49957 --
49958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49959
49960 trace
49961 (p_msg => 'BEGIN of AcctLineType_113'
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 := 'COST_VARIANCE';
49969 l_component_type_code := 'S';
49970 l_component_appl_id := 707;
49971 l_amb_context_code := 'DEFAULT';
49972 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
49973 l_event_class_code := 'USER_DEFINE';
49974 l_event_type_code := 'USUB_TXFR';
49975 l_line_definition_owner_code := 'S';
49976 l_line_definition_code := 'PI_INTRAORG_TXFR';
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_97,9E125) = 13
50006 THEN
50007
50008 --
50009 XLA_AE_LINES_PKG.SetNewLine;
50010
50011 p_balance_type_code := l_balance_type_code;
50012 -- set the flag so later we will know whether the gain loss line needs to be created
50013
50014 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50015 p_actual_flag :='A';
50016 END IF;
50017
50018 --
50019 -- bulk performance
50020 --
50021 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50022 p_header_num => 0); -- 4262811
50023 --
50024 -- set accounting line options
50025 --
50026 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50027 p_natural_side_code => 'D'
50028 , p_gain_or_loss_flag => 'N'
50029 , p_gl_transfer_mode_code => 'S'
50030 , p_acct_entry_type_code => 'A'
50031 , p_switch_side_flag => 'Y'
50032 , p_merge_duplicate_code => 'N'
50033 );
50034 --
50035 l_acc_rev_natural_side_code := 'C'; -- 4262811
50036 --
50037 --
50038 -- set accounting line type info
50039 --
50040 xla_ae_lines_pkg.SetAcctLineType
50041 (p_component_type => l_component_type
50042 ,p_event_type_code => l_event_type_code
50043 ,p_line_definition_owner_code => l_line_definition_owner_code
50044 ,p_line_definition_code => l_line_definition_code
50045 ,p_accounting_line_code => l_component_code
50046 ,p_accounting_line_type_code => l_component_type_code
50047 ,p_accounting_line_appl_id => l_component_appl_id
50048 ,p_amb_context_code => l_amb_context_code
50049 ,p_entity_code => l_entity_code
50050 ,p_event_class_code => l_event_class_code);
50051 --
50052 -- set accounting class
50053 --
50054 xla_ae_lines_pkg.SetAcctClass(
50055 p_accounting_class_code => 'COST_VARIANCE'
50056 , p_ae_header_id => l_ae_header_id
50057 );
50058
50059 --
50060 -- set rounding class
50061 --
50062 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50063 'COST_VARIANCE';
50064
50065 --
50066 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50067 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50068 --
50069 -- bulk performance
50070 --
50071 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50072
50073 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50074 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50075
50076 -- 4955764
50077 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50078 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50079
50080 -- 4458381 Public Sector Enh
50081
50082 --
50083 -- set accounting attributes for the line type
50084 --
50085 l_entered_amt_idx := 3;
50086 l_accted_amt_idx := 8;
50087 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50088 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
50089 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
50090 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
50091 l_rec_acct_attrs.array_char_value(2) := p_source_85;
50092 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
50093 l_rec_acct_attrs.array_num_value(3) := p_source_91;
50094 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
50095 l_rec_acct_attrs.array_char_value(4) := p_source_88;
50096 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
50097 l_rec_acct_attrs.array_date_value(5) := p_source_92;
50098 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
50099 l_rec_acct_attrs.array_num_value(6) := p_source_93;
50100 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
50101 l_rec_acct_attrs.array_char_value(7) := p_source_94;
50102 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
50103 l_rec_acct_attrs.array_num_value(8) := p_source_95;
50104
50105 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50106 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50107
50108 ---------------------------------------------------------------------------------------------------------------
50109 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50110 ---------------------------------------------------------------------------------------------------------------
50111 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50112
50113 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50114 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50115
50116 IF xla_accounting_cache_pkg.GetValueChar
50117 (p_source_code => 'LEDGER_CATEGORY_CODE'
50118 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50119 AND l_bflow_method_code = 'PRIOR_ENTRY'
50120 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50121 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50122 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50123 )
50124 THEN
50125 xla_ae_lines_pkg.BflowUpgEntry
50126 (p_business_method_code => l_bflow_method_code
50127 ,p_business_class_code => l_bflow_class_code
50128 ,p_balance_type => l_balance_type_code);
50129 ELSE
50130 NULL;
50131 -- No business flow processing for business flow method of NONE.
50132 END IF;
50133
50134 --
50135 -- call analytical criteria
50136 --
50137
50138 --
50139 -- call description
50140 --
50141
50142 xla_ae_lines_pkg.SetLineDescription(
50143 p_ae_header_id => l_ae_header_id
50144 ,p_description => Description_1 (
50145 p_application_id => p_application_id
50146 , p_ae_header_id => l_ae_header_id
50147 , p_source_1 => p_source_1
50148 , p_source_2 => p_source_2
50149 , p_source_3 => p_source_3
50150 , p_source_4 => p_source_4
50151 , p_source_5 => p_source_5
50152 )
50153 );
50154
50155
50156 --
50157 -- call ADRs
50158 -- Bug 4922099
50159 --
50160 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50161 (NVL(l_actual_upg_option, 'N') = 'O') OR
50162 (NVL(l_enc_upg_option, 'N') = 'O')
50163 )
50164 THEN
50165 NULL;
50166 --
50167 --
50168
50169 l_ccid := AcctDerRule_12(
50170 p_application_id => p_application_id
50171 , p_ae_header_id => l_ae_header_id
50172 , p_source_23 => p_source_23
50173 , x_transaction_coa_id => l_adr_transaction_coa_id
50174 , x_accounting_coa_id => l_adr_accounting_coa_id
50175 , x_value_type_code => l_adr_value_type_code
50176 , p_side => 'NA'
50177 );
50178
50179 xla_ae_lines_pkg.set_ccid(
50180 p_code_combination_id => l_ccid
50181 , p_value_type_code => l_adr_value_type_code
50182 , p_transaction_coa_id => l_adr_transaction_coa_id
50183 , p_accounting_coa_id => l_adr_accounting_coa_id
50184 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
50185 , p_adr_type_code => 'S'
50186 , p_component_type => l_component_type
50187 , p_component_code => l_component_code
50188 , p_component_type_code => l_component_type_code
50189 , p_component_appl_id => l_component_appl_id
50190 , p_amb_context_code => l_amb_context_code
50191 , p_side => 'NA'
50192 );
50193
50194
50195 --
50196 --
50197 END IF;
50198 --
50199 -- Bug 4922099
50200 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50201 (NVL(l_enc_upg_option, 'N') = 'O')
50202 ) AND
50203 (l_bflow_method_code = 'PRIOR_ENTRY')
50204 )
50205 THEN
50206 IF
50207 --
50208 1 = 2
50209 --
50210 THEN
50211 xla_accounting_err_pkg.build_message
50212 (p_appli_s_name => 'XLA'
50213 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50214 ,p_token_1 => 'LINE_NUMBER'
50215 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50216 ,p_token_2 => 'LINE_TYPE_NAME'
50217 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50218 l_component_type
50219 ,l_component_code
50220 ,l_component_type_code
50221 ,l_component_appl_id
50222 ,l_amb_context_code
50223 ,l_entity_code
50224 ,l_event_class_code
50225 )
50226 ,p_token_3 => 'OWNER'
50227 ,p_value_3 => xla_lookups_pkg.get_meaning(
50228 p_lookup_type => 'XLA_OWNER_TYPE'
50229 ,p_lookup_code => l_component_type_code
50230 )
50231 ,p_token_4 => 'PRODUCT_NAME'
50232 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50233 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50234 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50235 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50236 ,p_ae_header_id => NULL
50237 );
50238
50239 IF (C_LEVEL_ERROR>= g_log_level) THEN
50240 trace
50241 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50242 ,p_level => C_LEVEL_ERROR
50243 ,p_module => l_log_module);
50244 END IF;
50245 END IF;
50246 END IF;
50247 --
50248 --
50249 ------------------------------------------------------------------------------------------------
50250 -- 4219869 Business Flow
50251 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50252 -- Prior Entry. Currently, the following code is always generated.
50253 ------------------------------------------------------------------------------------------------
50254 XLA_AE_LINES_PKG.ValidateCurrentLine;
50255
50256 ------------------------------------------------------------------------------------
50257 -- 4219869 Business Flow
50258 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50259 ------------------------------------------------------------------------------------
50260 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50261
50262 ----------------------------------------------------------------------------------
50263 -- 4219869 Business Flow
50264 -- Update journal entry status -- Need to generate this within IF <condition>
50265 ----------------------------------------------------------------------------------
50266 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50267 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50268 ,p_balance_type_code => l_balance_type_code
50269 );
50270
50271 -------------------------------------------------------------------------------------------
50272 -- 4262811 - Generate the Accrual Reversal lines
50273 -------------------------------------------------------------------------------------------
50274 BEGIN
50275 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50276 (g_array_event(p_event_id).array_value_num('header_index'));
50277 IF l_acc_rev_flag IS NULL THEN
50278 l_acc_rev_flag := 'N';
50279 END IF;
50280 EXCEPTION
50281 WHEN OTHERS THEN
50282 l_acc_rev_flag := 'N';
50283 END;
50284 --
50285 IF (l_acc_rev_flag = 'Y') THEN
50286
50287 -- 4645092 ------------------------------------------------------------------------------
50288 -- To allow MPA report to determine if it should generate report process
50289 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50290 ------------------------------------------------------------------------------------------
50291
50292 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50293 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50294 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50295 -- call ADRs
50296 -- Bug 4922099
50297 --
50298 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50299 (NVL(l_actual_upg_option, 'N') = 'O') OR
50300 (NVL(l_enc_upg_option, 'N') = 'O')
50301 )
50302 THEN
50303 NULL;
50304 --
50305 --
50306
50307 l_ccid := AcctDerRule_12(
50308 p_application_id => p_application_id
50309 , p_ae_header_id => l_ae_header_id
50310 , p_source_23 => p_source_23
50311 , x_transaction_coa_id => l_adr_transaction_coa_id
50312 , x_accounting_coa_id => l_adr_accounting_coa_id
50313 , x_value_type_code => l_adr_value_type_code
50314 , p_side => 'NA'
50315 );
50316
50317 xla_ae_lines_pkg.set_ccid(
50318 p_code_combination_id => l_ccid
50319 , p_value_type_code => l_adr_value_type_code
50320 , p_transaction_coa_id => l_adr_transaction_coa_id
50321 , p_accounting_coa_id => l_adr_accounting_coa_id
50322 , p_adr_code => 'PI_CATEGORY_ACV_ADR'
50323 , p_adr_type_code => 'S'
50324 , p_component_type => l_component_type
50325 , p_component_code => l_component_code
50326 , p_component_type_code => l_component_type_code
50327 , p_component_appl_id => l_component_appl_id
50328 , p_amb_context_code => l_amb_context_code
50329 , p_side => 'NA'
50330 );
50331
50332
50333 --
50334 --
50335 END IF;
50336
50337 --
50338 -- Update the line information that should be overwritten
50339 --
50340 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50341 p_header_num => 1);
50342 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50343
50344 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50345
50346 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50347 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50348 END IF;
50349
50350 --
50351 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50352 --
50353 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50354 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50355 ELSE
50356 ---------------------------------------------------------------------------------------------------
50357 -- 4262811a Switch Sign
50358 ---------------------------------------------------------------------------------------------------
50359 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50360 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50361 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50362 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50363 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50364 -- 5132302
50365 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50366 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50367
50368 END IF;
50369
50370 -- 4955764
50371 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50372 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50373
50374
50375 XLA_AE_LINES_PKG.ValidateCurrentLine;
50376 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50377
50378 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50379 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50380 ,p_balance_type_code => l_balance_type_code);
50381
50382 END IF;
50383
50384 -----------------------------------------------------------------------------------------
50385 -- 4262811 Multiperiod Accounting
50386 -----------------------------------------------------------------------------------------
50387 -- No MPA option is assigned.
50388
50389
50390 END IF;
50391 END IF;
50392 --
50393
50394 --
50395 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50396 trace
50397 (p_msg => 'END of AcctLineType_113'
50398 ,p_level => C_LEVEL_PROCEDURE
50399 ,p_module => l_log_module);
50400 END IF;
50401 --
50402 EXCEPTION
50403 WHEN xla_exceptions_pkg.application_exception THEN
50404 RAISE;
50405 WHEN OTHERS THEN
50406 xla_exceptions_pkg.raise_message
50407 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_113');
50408 END AcctLineType_113;
50409 --
50410
50411 ---------------------------------------
50412 --
50413 -- PRIVATE FUNCTION
50414 -- AcctLineType_114
50415 --
50416 ---------------------------------------
50417 PROCEDURE AcctLineType_114 (
50418 p_application_id IN NUMBER
50419 ,p_event_id IN NUMBER
50420 ,p_calculate_acctd_flag IN VARCHAR2
50421 ,p_calculate_g_l_flag IN VARCHAR2
50422 ,p_actual_flag IN OUT VARCHAR2
50423 ,p_balance_type_code OUT VARCHAR2
50424 ,p_gain_or_loss_ref OUT VARCHAR2
50425
50426 --TRANSACTION_ID
50427 , p_source_1 IN NUMBER
50428 --Item Concatenated Segments
50429 , p_source_2 IN VARCHAR2
50430 --Transaction Quantity
50431 , p_source_3 IN NUMBER
50432 --Transaction Unit of Measure Code
50433 , p_source_4 IN VARCHAR2
50434 --Inventory Transaction Type Description
50435 , p_source_5 IN VARCHAR2
50436 --Cost Management Default Account
50437 , p_source_11 IN NUMBER
50438 --DISTRIBUTION_IDENTIFIER
50439 , p_source_84 IN NUMBER
50440 --Distribution Type
50441 , p_source_85 IN VARCHAR2
50442 , p_source_85_meaning IN VARCHAR2
50443 --Entered Currency Code
50444 , p_source_88 IN VARCHAR2
50445 --Entered Amount
50446 , p_source_91 IN NUMBER
50447 --Currency Conversion Date
50448 , p_source_92 IN DATE
50449 --Currency Conversion Rate
50450 , p_source_93 IN NUMBER
50451 --Currency Conversion Type
50452 , p_source_94 IN VARCHAR2
50453 --Accounted Amount
50454 , p_source_95 IN NUMBER
50455 --Accounting Line Type
50456 , p_source_97 IN NUMBER
50457 )
50458 IS
50459
50460 l_component_type VARCHAR2(80);
50461 l_component_code VARCHAR2(30);
50462 l_component_type_code VARCHAR2(1);
50463 l_component_appl_id INTEGER;
50464 l_amb_context_code VARCHAR2(30);
50465 l_entity_code VARCHAR2(30);
50466 l_event_class_code VARCHAR2(30);
50467 l_ae_header_id NUMBER;
50468 l_event_type_code VARCHAR2(30);
50469 l_line_definition_code VARCHAR2(30);
50470 l_line_definition_owner_code VARCHAR2(1);
50471 --
50472 -- adr variables
50473 l_segment VARCHAR2(30);
50474 l_ccid NUMBER;
50475 l_adr_transaction_coa_id NUMBER;
50476 l_adr_accounting_coa_id NUMBER;
50477 l_adr_flexfield_segment_code VARCHAR2(30);
50478 l_adr_flex_value_set_id NUMBER;
50479 l_adr_value_type_code VARCHAR2(30);
50480 l_adr_value_combination_id NUMBER;
50481 l_adr_value_segment_code VARCHAR2(30);
50482
50483 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
50484 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
50485 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
50486 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
50487
50488 -- 4262811 Variables ------------------------------------------------------------------------------------------
50489 l_entered_amt_idx NUMBER;
50490 l_accted_amt_idx NUMBER;
50491 l_acc_rev_flag VARCHAR2(1);
50492 l_accrual_line_num NUMBER;
50493 l_tmp_amt NUMBER;
50494 l_acc_rev_natural_side_code VARCHAR2(1);
50495
50496 l_num_entries NUMBER;
50497 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
50498 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
50499 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
50500 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
50501 l_recog_line_1 NUMBER;
50502 l_recog_line_2 NUMBER;
50503
50504 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
50505 l_bflow_applied_to_amt NUMBER; -- 5132302
50506 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
50507
50508 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
50509
50510 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
50511 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
50512
50513 ---------------------------------------------------------------------------------------------------------------
50514
50515
50516 --
50517 -- bulk performance
50518 --
50519 l_balance_type_code VARCHAR2(1);
50520 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
50521 l_log_module VARCHAR2(240);
50522
50523 --
50524 -- Upgrade strategy
50525 --
50526 l_actual_upg_option VARCHAR2(1);
50527 l_enc_upg_option VARCHAR2(1);
50528
50529 --
50530 BEGIN
50531 --
50532 IF g_log_enabled THEN
50533 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_114';
50534 END IF;
50535 --
50536 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50537
50538 trace
50539 (p_msg => 'BEGIN of AcctLineType_114'
50540 ,p_level => C_LEVEL_PROCEDURE
50541 ,p_module => l_log_module);
50542
50543 END IF;
50544 --
50545 l_component_type := 'AMB_JLT';
50546 l_component_code := 'COST_VARIANCE';
50547 l_component_type_code := 'S';
50548 l_component_appl_id := 707;
50549 l_amb_context_code := 'DEFAULT';
50550 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
50551 l_event_class_code := 'WIP_MTL';
50552 l_event_type_code := 'WIP_NEG_COMP_RETURN';
50553 l_line_definition_owner_code := 'S';
50554 l_line_definition_code := 'PI_WIP_NEG_COMP_RETURN';
50555 --
50556 l_balance_type_code := 'A';
50557 l_segment := NULL;
50558 l_ccid := NULL;
50559 l_adr_transaction_coa_id := NULL;
50560 l_adr_accounting_coa_id := NULL;
50561 l_adr_flexfield_segment_code := NULL;
50562 l_adr_flex_value_set_id := NULL;
50563 l_adr_value_type_code := NULL;
50564 l_adr_value_combination_id := NULL;
50565 l_adr_value_segment_code := NULL;
50566
50567 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
50568 l_bflow_class_code := ''; -- 4219869 Business Flow
50569 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
50570 l_budgetary_control_flag := 'N';
50571
50572 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50573 l_bflow_applied_to_amt := NULL; -- 5132302
50574 l_entered_amt_idx := NULL; -- 4262811
50575 l_accted_amt_idx := NULL; -- 4262811
50576 l_acc_rev_flag := NULL; -- 4262811
50577 l_accrual_line_num := NULL; -- 4262811
50578 l_tmp_amt := NULL; -- 4262811
50579 --
50580
50581 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50582 l_balance_type_code <> 'B' THEN
50583 IF NVL(p_source_97,9E125) = 13
50584 THEN
50585
50586 --
50587 XLA_AE_LINES_PKG.SetNewLine;
50588
50589 p_balance_type_code := l_balance_type_code;
50590 -- set the flag so later we will know whether the gain loss line needs to be created
50591
50592 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50593 p_actual_flag :='A';
50594 END IF;
50595
50596 --
50597 -- bulk performance
50598 --
50599 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50600 p_header_num => 0); -- 4262811
50601 --
50602 -- set accounting line options
50603 --
50604 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50605 p_natural_side_code => 'D'
50606 , p_gain_or_loss_flag => 'N'
50607 , p_gl_transfer_mode_code => 'S'
50608 , p_acct_entry_type_code => 'A'
50609 , p_switch_side_flag => 'Y'
50610 , p_merge_duplicate_code => 'N'
50611 );
50612 --
50613 l_acc_rev_natural_side_code := 'C'; -- 4262811
50614 --
50615 --
50616 -- set accounting line type info
50617 --
50618 xla_ae_lines_pkg.SetAcctLineType
50619 (p_component_type => l_component_type
50620 ,p_event_type_code => l_event_type_code
50621 ,p_line_definition_owner_code => l_line_definition_owner_code
50622 ,p_line_definition_code => l_line_definition_code
50623 ,p_accounting_line_code => l_component_code
50624 ,p_accounting_line_type_code => l_component_type_code
50625 ,p_accounting_line_appl_id => l_component_appl_id
50626 ,p_amb_context_code => l_amb_context_code
50627 ,p_entity_code => l_entity_code
50628 ,p_event_class_code => l_event_class_code);
50629 --
50630 -- set accounting class
50631 --
50632 xla_ae_lines_pkg.SetAcctClass(
50633 p_accounting_class_code => 'COST_VARIANCE'
50634 , p_ae_header_id => l_ae_header_id
50635 );
50636
50637 --
50638 -- set rounding class
50639 --
50640 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50641 'COST_VARIANCE';
50642
50643 --
50644 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50645 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50646 --
50647 -- bulk performance
50648 --
50649 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50650
50651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50652 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50653
50654 -- 4955764
50655 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50656 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50657
50658 -- 4458381 Public Sector Enh
50659
50660 --
50661 -- set accounting attributes for the line type
50662 --
50663 l_entered_amt_idx := 3;
50664 l_accted_amt_idx := 8;
50665 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50666 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
50667 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
50668 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
50669 l_rec_acct_attrs.array_char_value(2) := p_source_85;
50670 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
50671 l_rec_acct_attrs.array_num_value(3) := p_source_91;
50672 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
50673 l_rec_acct_attrs.array_char_value(4) := p_source_88;
50674 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
50675 l_rec_acct_attrs.array_date_value(5) := p_source_92;
50676 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
50677 l_rec_acct_attrs.array_num_value(6) := p_source_93;
50678 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
50679 l_rec_acct_attrs.array_char_value(7) := p_source_94;
50680 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
50681 l_rec_acct_attrs.array_num_value(8) := p_source_95;
50682
50683 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50684 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50685
50686 ---------------------------------------------------------------------------------------------------------------
50687 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50688 ---------------------------------------------------------------------------------------------------------------
50689 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50690
50691 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50692 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50693
50694 IF xla_accounting_cache_pkg.GetValueChar
50695 (p_source_code => 'LEDGER_CATEGORY_CODE'
50696 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50697 AND l_bflow_method_code = 'PRIOR_ENTRY'
50698 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50699 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50700 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50701 )
50702 THEN
50703 xla_ae_lines_pkg.BflowUpgEntry
50704 (p_business_method_code => l_bflow_method_code
50705 ,p_business_class_code => l_bflow_class_code
50706 ,p_balance_type => l_balance_type_code);
50707 ELSE
50708 NULL;
50709 -- No business flow processing for business flow method of NONE.
50710 END IF;
50711
50712 --
50713 -- call analytical criteria
50714 --
50715
50716 --
50717 -- call description
50718 --
50719
50720 xla_ae_lines_pkg.SetLineDescription(
50721 p_ae_header_id => l_ae_header_id
50722 ,p_description => Description_1 (
50723 p_application_id => p_application_id
50724 , p_ae_header_id => l_ae_header_id
50725 , p_source_1 => p_source_1
50726 , p_source_2 => p_source_2
50727 , p_source_3 => p_source_3
50728 , p_source_4 => p_source_4
50729 , p_source_5 => p_source_5
50730 )
50731 );
50732
50733
50734 --
50735 -- call ADRs
50736 -- Bug 4922099
50737 --
50738 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50739 (NVL(l_actual_upg_option, 'N') = 'O') OR
50740 (NVL(l_enc_upg_option, 'N') = 'O')
50741 )
50742 THEN
50743 NULL;
50744 --
50745 --
50746
50747 l_ccid := AcctDerRule_6(
50748 p_application_id => p_application_id
50749 , p_ae_header_id => l_ae_header_id
50750 , p_source_11 => p_source_11
50751 , x_transaction_coa_id => l_adr_transaction_coa_id
50752 , x_accounting_coa_id => l_adr_accounting_coa_id
50753 , x_value_type_code => l_adr_value_type_code
50754 , p_side => 'NA'
50755 );
50756
50757 xla_ae_lines_pkg.set_ccid(
50758 p_code_combination_id => l_ccid
50759 , p_value_type_code => l_adr_value_type_code
50760 , p_transaction_coa_id => l_adr_transaction_coa_id
50761 , p_accounting_coa_id => l_adr_accounting_coa_id
50762 , p_adr_code => 'CST_DEFAULT'
50763 , p_adr_type_code => 'S'
50764 , p_component_type => l_component_type
50765 , p_component_code => l_component_code
50766 , p_component_type_code => l_component_type_code
50767 , p_component_appl_id => l_component_appl_id
50768 , p_amb_context_code => l_amb_context_code
50769 , p_side => 'NA'
50770 );
50771
50772
50773 --
50774 --
50775 END IF;
50776 --
50777 -- Bug 4922099
50778 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50779 (NVL(l_enc_upg_option, 'N') = 'O')
50780 ) AND
50781 (l_bflow_method_code = 'PRIOR_ENTRY')
50782 )
50783 THEN
50784 IF
50785 --
50786 1 = 2
50787 --
50788 THEN
50789 xla_accounting_err_pkg.build_message
50790 (p_appli_s_name => 'XLA'
50791 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50792 ,p_token_1 => 'LINE_NUMBER'
50793 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50794 ,p_token_2 => 'LINE_TYPE_NAME'
50795 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50796 l_component_type
50797 ,l_component_code
50798 ,l_component_type_code
50799 ,l_component_appl_id
50800 ,l_amb_context_code
50801 ,l_entity_code
50802 ,l_event_class_code
50803 )
50804 ,p_token_3 => 'OWNER'
50805 ,p_value_3 => xla_lookups_pkg.get_meaning(
50806 p_lookup_type => 'XLA_OWNER_TYPE'
50807 ,p_lookup_code => l_component_type_code
50808 )
50809 ,p_token_4 => 'PRODUCT_NAME'
50810 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50811 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50812 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50813 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50814 ,p_ae_header_id => NULL
50815 );
50816
50817 IF (C_LEVEL_ERROR>= g_log_level) THEN
50818 trace
50819 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50820 ,p_level => C_LEVEL_ERROR
50821 ,p_module => l_log_module);
50822 END IF;
50823 END IF;
50824 END IF;
50825 --
50826 --
50827 ------------------------------------------------------------------------------------------------
50828 -- 4219869 Business Flow
50829 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50830 -- Prior Entry. Currently, the following code is always generated.
50831 ------------------------------------------------------------------------------------------------
50832 XLA_AE_LINES_PKG.ValidateCurrentLine;
50833
50834 ------------------------------------------------------------------------------------
50835 -- 4219869 Business Flow
50836 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50837 ------------------------------------------------------------------------------------
50838 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50839
50840 ----------------------------------------------------------------------------------
50841 -- 4219869 Business Flow
50842 -- Update journal entry status -- Need to generate this within IF <condition>
50843 ----------------------------------------------------------------------------------
50844 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50845 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50846 ,p_balance_type_code => l_balance_type_code
50847 );
50848
50849 -------------------------------------------------------------------------------------------
50850 -- 4262811 - Generate the Accrual Reversal lines
50851 -------------------------------------------------------------------------------------------
50852 BEGIN
50853 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50854 (g_array_event(p_event_id).array_value_num('header_index'));
50855 IF l_acc_rev_flag IS NULL THEN
50856 l_acc_rev_flag := 'N';
50857 END IF;
50858 EXCEPTION
50859 WHEN OTHERS THEN
50860 l_acc_rev_flag := 'N';
50861 END;
50862 --
50863 IF (l_acc_rev_flag = 'Y') THEN
50864
50865 -- 4645092 ------------------------------------------------------------------------------
50866 -- To allow MPA report to determine if it should generate report process
50867 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50868 ------------------------------------------------------------------------------------------
50869
50870 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50871 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50872 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50873 -- call ADRs
50874 -- Bug 4922099
50875 --
50876 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50877 (NVL(l_actual_upg_option, 'N') = 'O') OR
50878 (NVL(l_enc_upg_option, 'N') = 'O')
50879 )
50880 THEN
50881 NULL;
50882 --
50883 --
50884
50885 l_ccid := AcctDerRule_6(
50886 p_application_id => p_application_id
50887 , p_ae_header_id => l_ae_header_id
50888 , p_source_11 => p_source_11
50889 , x_transaction_coa_id => l_adr_transaction_coa_id
50890 , x_accounting_coa_id => l_adr_accounting_coa_id
50891 , x_value_type_code => l_adr_value_type_code
50892 , p_side => 'NA'
50893 );
50894
50895 xla_ae_lines_pkg.set_ccid(
50896 p_code_combination_id => l_ccid
50897 , p_value_type_code => l_adr_value_type_code
50898 , p_transaction_coa_id => l_adr_transaction_coa_id
50899 , p_accounting_coa_id => l_adr_accounting_coa_id
50900 , p_adr_code => 'CST_DEFAULT'
50901 , p_adr_type_code => 'S'
50902 , p_component_type => l_component_type
50903 , p_component_code => l_component_code
50904 , p_component_type_code => l_component_type_code
50905 , p_component_appl_id => l_component_appl_id
50906 , p_amb_context_code => l_amb_context_code
50907 , p_side => 'NA'
50908 );
50909
50910
50911 --
50912 --
50913 END IF;
50914
50915 --
50916 -- Update the line information that should be overwritten
50917 --
50918 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50919 p_header_num => 1);
50920 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50921
50922 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50923
50924 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50925 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50926 END IF;
50927
50928 --
50929 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50930 --
50931 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50932 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50933 ELSE
50934 ---------------------------------------------------------------------------------------------------
50935 -- 4262811a Switch Sign
50936 ---------------------------------------------------------------------------------------------------
50937 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50938 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50939 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50940 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50941 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50942 -- 5132302
50943 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50944 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50945
50946 END IF;
50947
50948 -- 4955764
50949 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50950 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50951
50952
50953 XLA_AE_LINES_PKG.ValidateCurrentLine;
50954 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50955
50956 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50957 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50958 ,p_balance_type_code => l_balance_type_code);
50959
50960 END IF;
50961
50962 -----------------------------------------------------------------------------------------
50963 -- 4262811 Multiperiod Accounting
50964 -----------------------------------------------------------------------------------------
50965 -- No MPA option is assigned.
50966
50967
50968 END IF;
50969 END IF;
50970 --
50971
50972 --
50973 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50974 trace
50975 (p_msg => 'END of AcctLineType_114'
50976 ,p_level => C_LEVEL_PROCEDURE
50977 ,p_module => l_log_module);
50978 END IF;
50979 --
50980 EXCEPTION
50981 WHEN xla_exceptions_pkg.application_exception THEN
50982 RAISE;
50983 WHEN OTHERS THEN
50984 xla_exceptions_pkg.raise_message
50985 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_114');
50986 END AcctLineType_114;
50987 --
50988
50989 ---------------------------------------
50990 --
50991 -- PRIVATE FUNCTION
50992 -- AcctLineType_115
50993 --
50994 ---------------------------------------
50995 PROCEDURE AcctLineType_115 (
50996 p_application_id IN NUMBER
50997 ,p_event_id IN NUMBER
50998 ,p_calculate_acctd_flag IN VARCHAR2
50999 ,p_calculate_g_l_flag IN VARCHAR2
51000 ,p_actual_flag IN OUT VARCHAR2
51001 ,p_balance_type_code OUT VARCHAR2
51002 ,p_gain_or_loss_ref OUT VARCHAR2
51003
51004 --TRANSACTION_ID
51005 , p_source_1 IN NUMBER
51006 --Item Concatenated Segments
51007 , p_source_2 IN VARCHAR2
51008 --Transaction Quantity
51009 , p_source_3 IN NUMBER
51010 --Transaction Unit of Measure Code
51011 , p_source_4 IN VARCHAR2
51012 --Inventory Transaction Type Description
51013 , p_source_5 IN VARCHAR2
51014 --Inventory Organization Average Cost Variance Account
51015 , p_source_21 IN NUMBER
51016 --DISTRIBUTION_IDENTIFIER
51017 , p_source_84 IN NUMBER
51018 --Distribution Type
51019 , p_source_85 IN VARCHAR2
51020 , p_source_85_meaning IN VARCHAR2
51021 --Entered Currency Code
51022 , p_source_88 IN VARCHAR2
51023 --Entered Amount
51024 , p_source_91 IN NUMBER
51025 --Currency Conversion Date
51026 , p_source_92 IN DATE
51027 --Currency Conversion Rate
51028 , p_source_93 IN NUMBER
51029 --Currency Conversion Type
51030 , p_source_94 IN VARCHAR2
51031 --Accounted Amount
51032 , p_source_95 IN NUMBER
51033 --Accounting Line Type
51034 , p_source_97 IN NUMBER
51035 )
51036 IS
51037
51038 l_component_type VARCHAR2(80);
51039 l_component_code VARCHAR2(30);
51040 l_component_type_code VARCHAR2(1);
51041 l_component_appl_id INTEGER;
51042 l_amb_context_code VARCHAR2(30);
51043 l_entity_code VARCHAR2(30);
51044 l_event_class_code VARCHAR2(30);
51045 l_ae_header_id NUMBER;
51046 l_event_type_code VARCHAR2(30);
51047 l_line_definition_code VARCHAR2(30);
51048 l_line_definition_owner_code VARCHAR2(1);
51049 --
51050 -- adr variables
51051 l_segment VARCHAR2(30);
51052 l_ccid NUMBER;
51053 l_adr_transaction_coa_id NUMBER;
51054 l_adr_accounting_coa_id NUMBER;
51055 l_adr_flexfield_segment_code VARCHAR2(30);
51056 l_adr_flex_value_set_id NUMBER;
51057 l_adr_value_type_code VARCHAR2(30);
51058 l_adr_value_combination_id NUMBER;
51059 l_adr_value_segment_code VARCHAR2(30);
51060
51061 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51062 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51063 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51064 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51065
51066 -- 4262811 Variables ------------------------------------------------------------------------------------------
51067 l_entered_amt_idx NUMBER;
51068 l_accted_amt_idx NUMBER;
51069 l_acc_rev_flag VARCHAR2(1);
51070 l_accrual_line_num NUMBER;
51071 l_tmp_amt NUMBER;
51072 l_acc_rev_natural_side_code VARCHAR2(1);
51073
51074 l_num_entries NUMBER;
51075 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51076 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51077 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51078 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51079 l_recog_line_1 NUMBER;
51080 l_recog_line_2 NUMBER;
51081
51082 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51083 l_bflow_applied_to_amt NUMBER; -- 5132302
51084 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51085
51086 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51087
51088 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51089 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51090
51091 ---------------------------------------------------------------------------------------------------------------
51092
51093
51094 --
51095 -- bulk performance
51096 --
51097 l_balance_type_code VARCHAR2(1);
51098 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51099 l_log_module VARCHAR2(240);
51100
51101 --
51102 -- Upgrade strategy
51103 --
51104 l_actual_upg_option VARCHAR2(1);
51105 l_enc_upg_option VARCHAR2(1);
51106
51107 --
51108 BEGIN
51109 --
51110 IF g_log_enabled THEN
51111 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_115';
51112 END IF;
51113 --
51114 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51115
51116 trace
51117 (p_msg => 'BEGIN of AcctLineType_115'
51118 ,p_level => C_LEVEL_PROCEDURE
51119 ,p_module => l_log_module);
51120
51121 END IF;
51122 --
51123 l_component_type := 'AMB_JLT';
51124 l_component_code := 'COST_VARIANCE';
51125 l_component_type_code := 'S';
51126 l_component_appl_id := 707;
51127 l_amb_context_code := 'DEFAULT';
51128 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
51129 l_event_class_code := 'CON_INV_OWNR_TXFR';
51130 l_event_type_code := 'CON_INV_OWNR_TXFR_ALL';
51131 l_line_definition_owner_code := 'S';
51132 l_line_definition_code := 'PI_CON_INV_OWNR_TRFR';
51133 --
51134 l_balance_type_code := 'A';
51135 l_segment := NULL;
51136 l_ccid := NULL;
51137 l_adr_transaction_coa_id := NULL;
51138 l_adr_accounting_coa_id := NULL;
51139 l_adr_flexfield_segment_code := NULL;
51140 l_adr_flex_value_set_id := NULL;
51141 l_adr_value_type_code := NULL;
51142 l_adr_value_combination_id := NULL;
51143 l_adr_value_segment_code := NULL;
51144
51145 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51146 l_bflow_class_code := ''; -- 4219869 Business Flow
51147 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51148 l_budgetary_control_flag := 'N';
51149
51150 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51151 l_bflow_applied_to_amt := NULL; -- 5132302
51152 l_entered_amt_idx := NULL; -- 4262811
51153 l_accted_amt_idx := NULL; -- 4262811
51154 l_acc_rev_flag := NULL; -- 4262811
51155 l_accrual_line_num := NULL; -- 4262811
51156 l_tmp_amt := NULL; -- 4262811
51157 --
51158
51159 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51160 l_balance_type_code <> 'B' THEN
51161 IF NVL(p_source_97,9E125) = 13
51162 THEN
51163
51164 --
51165 XLA_AE_LINES_PKG.SetNewLine;
51166
51167 p_balance_type_code := l_balance_type_code;
51168 -- set the flag so later we will know whether the gain loss line needs to be created
51169
51170 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51171 p_actual_flag :='A';
51172 END IF;
51173
51174 --
51175 -- bulk performance
51176 --
51177 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51178 p_header_num => 0); -- 4262811
51179 --
51180 -- set accounting line options
51181 --
51182 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51183 p_natural_side_code => 'D'
51184 , p_gain_or_loss_flag => 'N'
51185 , p_gl_transfer_mode_code => 'S'
51186 , p_acct_entry_type_code => 'A'
51187 , p_switch_side_flag => 'Y'
51188 , p_merge_duplicate_code => 'N'
51189 );
51190 --
51191 l_acc_rev_natural_side_code := 'C'; -- 4262811
51192 --
51193 --
51194 -- set accounting line type info
51195 --
51196 xla_ae_lines_pkg.SetAcctLineType
51197 (p_component_type => l_component_type
51198 ,p_event_type_code => l_event_type_code
51199 ,p_line_definition_owner_code => l_line_definition_owner_code
51200 ,p_line_definition_code => l_line_definition_code
51201 ,p_accounting_line_code => l_component_code
51202 ,p_accounting_line_type_code => l_component_type_code
51203 ,p_accounting_line_appl_id => l_component_appl_id
51204 ,p_amb_context_code => l_amb_context_code
51205 ,p_entity_code => l_entity_code
51206 ,p_event_class_code => l_event_class_code);
51207 --
51208 -- set accounting class
51209 --
51210 xla_ae_lines_pkg.SetAcctClass(
51211 p_accounting_class_code => 'COST_VARIANCE'
51212 , p_ae_header_id => l_ae_header_id
51213 );
51214
51215 --
51216 -- set rounding class
51217 --
51218 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51219 'COST_VARIANCE';
51220
51221 --
51222 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51223 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51224 --
51225 -- bulk performance
51226 --
51227 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51228
51229 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51230 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51231
51232 -- 4955764
51233 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51234 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51235
51236 -- 4458381 Public Sector Enh
51237
51238 --
51239 -- set accounting attributes for the line type
51240 --
51241 l_entered_amt_idx := 3;
51242 l_accted_amt_idx := 8;
51243 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51244 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
51245 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
51246 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
51247 l_rec_acct_attrs.array_char_value(2) := p_source_85;
51248 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
51249 l_rec_acct_attrs.array_num_value(3) := p_source_91;
51250 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
51251 l_rec_acct_attrs.array_char_value(4) := p_source_88;
51252 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
51253 l_rec_acct_attrs.array_date_value(5) := p_source_92;
51254 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
51255 l_rec_acct_attrs.array_num_value(6) := p_source_93;
51256 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
51257 l_rec_acct_attrs.array_char_value(7) := p_source_94;
51258 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
51259 l_rec_acct_attrs.array_num_value(8) := p_source_95;
51260
51261 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51262 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51263
51264 ---------------------------------------------------------------------------------------------------------------
51265 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51266 ---------------------------------------------------------------------------------------------------------------
51267 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51268
51269 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51270 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51271
51272 IF xla_accounting_cache_pkg.GetValueChar
51273 (p_source_code => 'LEDGER_CATEGORY_CODE'
51274 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51275 AND l_bflow_method_code = 'PRIOR_ENTRY'
51276 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51277 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51278 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51279 )
51280 THEN
51281 xla_ae_lines_pkg.BflowUpgEntry
51282 (p_business_method_code => l_bflow_method_code
51283 ,p_business_class_code => l_bflow_class_code
51284 ,p_balance_type => l_balance_type_code);
51285 ELSE
51286 NULL;
51287 -- No business flow processing for business flow method of NONE.
51288 END IF;
51289
51290 --
51291 -- call analytical criteria
51292 --
51293
51294 --
51295 -- call description
51296 --
51297
51298 xla_ae_lines_pkg.SetLineDescription(
51299 p_ae_header_id => l_ae_header_id
51300 ,p_description => Description_1 (
51301 p_application_id => p_application_id
51302 , p_ae_header_id => l_ae_header_id
51303 , p_source_1 => p_source_1
51304 , p_source_2 => p_source_2
51305 , p_source_3 => p_source_3
51306 , p_source_4 => p_source_4
51307 , p_source_5 => p_source_5
51308 )
51309 );
51310
51311
51312 --
51313 -- call ADRs
51314 -- Bug 4922099
51315 --
51316 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51317 (NVL(l_actual_upg_option, 'N') = 'O') OR
51318 (NVL(l_enc_upg_option, 'N') = 'O')
51319 )
51320 THEN
51321 NULL;
51322 --
51323 --
51324
51325 l_ccid := AcctDerRule_10(
51326 p_application_id => p_application_id
51327 , p_ae_header_id => l_ae_header_id
51328 , p_source_21 => p_source_21
51329 , x_transaction_coa_id => l_adr_transaction_coa_id
51330 , x_accounting_coa_id => l_adr_accounting_coa_id
51331 , x_value_type_code => l_adr_value_type_code
51332 , p_side => 'NA'
51333 );
51334
51335 xla_ae_lines_pkg.set_ccid(
51336 p_code_combination_id => l_ccid
51337 , p_value_type_code => l_adr_value_type_code
51338 , p_transaction_coa_id => l_adr_transaction_coa_id
51339 , p_accounting_coa_id => l_adr_accounting_coa_id
51340 , p_adr_code => 'PI_AVG_CST_VARIANCE'
51341 , p_adr_type_code => 'S'
51342 , p_component_type => l_component_type
51343 , p_component_code => l_component_code
51344 , p_component_type_code => l_component_type_code
51345 , p_component_appl_id => l_component_appl_id
51346 , p_amb_context_code => l_amb_context_code
51347 , p_side => 'NA'
51348 );
51349
51350
51351 --
51352 --
51353 END IF;
51354 --
51355 -- Bug 4922099
51356 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51357 (NVL(l_enc_upg_option, 'N') = 'O')
51358 ) AND
51359 (l_bflow_method_code = 'PRIOR_ENTRY')
51360 )
51361 THEN
51362 IF
51363 --
51364 1 = 2
51365 --
51366 THEN
51367 xla_accounting_err_pkg.build_message
51368 (p_appli_s_name => 'XLA'
51369 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51370 ,p_token_1 => 'LINE_NUMBER'
51371 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
51372 ,p_token_2 => 'LINE_TYPE_NAME'
51373 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
51374 l_component_type
51375 ,l_component_code
51376 ,l_component_type_code
51377 ,l_component_appl_id
51378 ,l_amb_context_code
51379 ,l_entity_code
51380 ,l_event_class_code
51381 )
51382 ,p_token_3 => 'OWNER'
51383 ,p_value_3 => xla_lookups_pkg.get_meaning(
51384 p_lookup_type => 'XLA_OWNER_TYPE'
51385 ,p_lookup_code => l_component_type_code
51386 )
51387 ,p_token_4 => 'PRODUCT_NAME'
51388 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
51389 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
51390 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
51391 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
51392 ,p_ae_header_id => NULL
51393 );
51394
51395 IF (C_LEVEL_ERROR>= g_log_level) THEN
51396 trace
51397 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51398 ,p_level => C_LEVEL_ERROR
51399 ,p_module => l_log_module);
51400 END IF;
51401 END IF;
51402 END IF;
51403 --
51404 --
51405 ------------------------------------------------------------------------------------------------
51406 -- 4219869 Business Flow
51407 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
51408 -- Prior Entry. Currently, the following code is always generated.
51409 ------------------------------------------------------------------------------------------------
51410 XLA_AE_LINES_PKG.ValidateCurrentLine;
51411
51412 ------------------------------------------------------------------------------------
51413 -- 4219869 Business Flow
51414 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
51415 ------------------------------------------------------------------------------------
51416 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51417
51418 ----------------------------------------------------------------------------------
51419 -- 4219869 Business Flow
51420 -- Update journal entry status -- Need to generate this within IF <condition>
51421 ----------------------------------------------------------------------------------
51422 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51423 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
51424 ,p_balance_type_code => l_balance_type_code
51425 );
51426
51427 -------------------------------------------------------------------------------------------
51428 -- 4262811 - Generate the Accrual Reversal lines
51429 -------------------------------------------------------------------------------------------
51430 BEGIN
51431 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51432 (g_array_event(p_event_id).array_value_num('header_index'));
51433 IF l_acc_rev_flag IS NULL THEN
51434 l_acc_rev_flag := 'N';
51435 END IF;
51436 EXCEPTION
51437 WHEN OTHERS THEN
51438 l_acc_rev_flag := 'N';
51439 END;
51440 --
51441 IF (l_acc_rev_flag = 'Y') THEN
51442
51443 -- 4645092 ------------------------------------------------------------------------------
51444 -- To allow MPA report to determine if it should generate report process
51445 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
51446 ------------------------------------------------------------------------------------------
51447
51448 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
51449 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
51450 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
51451 -- call ADRs
51452 -- Bug 4922099
51453 --
51454 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51455 (NVL(l_actual_upg_option, 'N') = 'O') OR
51456 (NVL(l_enc_upg_option, 'N') = 'O')
51457 )
51458 THEN
51459 NULL;
51460 --
51461 --
51462
51463 l_ccid := AcctDerRule_10(
51464 p_application_id => p_application_id
51465 , p_ae_header_id => l_ae_header_id
51466 , p_source_21 => p_source_21
51467 , x_transaction_coa_id => l_adr_transaction_coa_id
51468 , x_accounting_coa_id => l_adr_accounting_coa_id
51469 , x_value_type_code => l_adr_value_type_code
51470 , p_side => 'NA'
51471 );
51472
51473 xla_ae_lines_pkg.set_ccid(
51474 p_code_combination_id => l_ccid
51475 , p_value_type_code => l_adr_value_type_code
51476 , p_transaction_coa_id => l_adr_transaction_coa_id
51477 , p_accounting_coa_id => l_adr_accounting_coa_id
51478 , p_adr_code => 'PI_AVG_CST_VARIANCE'
51479 , p_adr_type_code => 'S'
51480 , p_component_type => l_component_type
51481 , p_component_code => l_component_code
51482 , p_component_type_code => l_component_type_code
51483 , p_component_appl_id => l_component_appl_id
51484 , p_amb_context_code => l_amb_context_code
51485 , p_side => 'NA'
51486 );
51487
51488
51489 --
51490 --
51491 END IF;
51492
51493 --
51494 -- Update the line information that should be overwritten
51495 --
51496 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51497 p_header_num => 1);
51498 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51499
51500 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51501
51502 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51503 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51504 END IF;
51505
51506 --
51507 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51508 --
51509 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51510 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51511 ELSE
51512 ---------------------------------------------------------------------------------------------------
51513 -- 4262811a Switch Sign
51514 ---------------------------------------------------------------------------------------------------
51515 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51516 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51517 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51518 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51519 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51520 -- 5132302
51521 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51522 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51523
51524 END IF;
51525
51526 -- 4955764
51527 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51528 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51529
51530
51531 XLA_AE_LINES_PKG.ValidateCurrentLine;
51532 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51533
51534 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51535 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51536 ,p_balance_type_code => l_balance_type_code);
51537
51538 END IF;
51539
51540 -----------------------------------------------------------------------------------------
51541 -- 4262811 Multiperiod Accounting
51542 -----------------------------------------------------------------------------------------
51543 -- No MPA option is assigned.
51544
51545
51546 END IF;
51547 END IF;
51548 --
51549
51550 --
51551 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51552 trace
51553 (p_msg => 'END of AcctLineType_115'
51554 ,p_level => C_LEVEL_PROCEDURE
51555 ,p_module => l_log_module);
51556 END IF;
51557 --
51558 EXCEPTION
51559 WHEN xla_exceptions_pkg.application_exception THEN
51560 RAISE;
51561 WHEN OTHERS THEN
51562 xla_exceptions_pkg.raise_message
51563 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_115');
51564 END AcctLineType_115;
51565 --
51566
51567 ---------------------------------------
51568 --
51569 -- PRIVATE FUNCTION
51570 -- AcctLineType_116
51571 --
51572 ---------------------------------------
51573 PROCEDURE AcctLineType_116 (
51574 p_application_id IN NUMBER
51575 ,p_event_id IN NUMBER
51576 ,p_calculate_acctd_flag IN VARCHAR2
51577 ,p_calculate_g_l_flag IN VARCHAR2
51578 ,p_actual_flag IN OUT VARCHAR2
51579 ,p_balance_type_code OUT VARCHAR2
51580 ,p_gain_or_loss_ref OUT VARCHAR2
51581
51582 --Cost Management Default Account
51583 , p_source_11 IN NUMBER
51584 --DISTRIBUTION_IDENTIFIER
51585 , p_source_84 IN NUMBER
51586 --Distribution Type
51587 , p_source_85 IN VARCHAR2
51588 , p_source_85_meaning IN VARCHAR2
51589 --Entered Currency Code
51590 , p_source_88 IN VARCHAR2
51591 --Entered Amount
51592 , p_source_91 IN NUMBER
51593 --Currency Conversion Date
51594 , p_source_92 IN DATE
51595 --Currency Conversion Rate
51596 , p_source_93 IN NUMBER
51597 --Currency Conversion Type
51598 , p_source_94 IN VARCHAR2
51599 --Accounted Amount
51600 , p_source_95 IN NUMBER
51601 --Accounting Line Type
51602 , p_source_97 IN NUMBER
51603 )
51604 IS
51605
51606 l_component_type VARCHAR2(80);
51607 l_component_code VARCHAR2(30);
51608 l_component_type_code VARCHAR2(1);
51609 l_component_appl_id INTEGER;
51610 l_amb_context_code VARCHAR2(30);
51611 l_entity_code VARCHAR2(30);
51612 l_event_class_code VARCHAR2(30);
51613 l_ae_header_id NUMBER;
51614 l_event_type_code VARCHAR2(30);
51615 l_line_definition_code VARCHAR2(30);
51616 l_line_definition_owner_code VARCHAR2(1);
51617 --
51618 -- adr variables
51619 l_segment VARCHAR2(30);
51620 l_ccid NUMBER;
51621 l_adr_transaction_coa_id NUMBER;
51622 l_adr_accounting_coa_id NUMBER;
51623 l_adr_flexfield_segment_code VARCHAR2(30);
51624 l_adr_flex_value_set_id NUMBER;
51625 l_adr_value_type_code VARCHAR2(30);
51626 l_adr_value_combination_id NUMBER;
51627 l_adr_value_segment_code VARCHAR2(30);
51628
51629 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51630 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51631 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51632 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51633
51634 -- 4262811 Variables ------------------------------------------------------------------------------------------
51635 l_entered_amt_idx NUMBER;
51636 l_accted_amt_idx NUMBER;
51637 l_acc_rev_flag VARCHAR2(1);
51638 l_accrual_line_num NUMBER;
51639 l_tmp_amt NUMBER;
51640 l_acc_rev_natural_side_code VARCHAR2(1);
51641
51642 l_num_entries NUMBER;
51643 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51644 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51645 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51646 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51647 l_recog_line_1 NUMBER;
51648 l_recog_line_2 NUMBER;
51649
51650 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51651 l_bflow_applied_to_amt NUMBER; -- 5132302
51652 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51653
51654 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51655
51656 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51657 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51658
51659 ---------------------------------------------------------------------------------------------------------------
51660
51661
51662 --
51663 -- bulk performance
51664 --
51665 l_balance_type_code VARCHAR2(1);
51666 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51667 l_log_module VARCHAR2(240);
51668
51669 --
51670 -- Upgrade strategy
51671 --
51672 l_actual_upg_option VARCHAR2(1);
51673 l_enc_upg_option VARCHAR2(1);
51674
51675 --
51676 BEGIN
51677 --
51678 IF g_log_enabled THEN
51679 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_116';
51680 END IF;
51681 --
51682 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51683
51684 trace
51685 (p_msg => 'BEGIN of AcctLineType_116'
51686 ,p_level => C_LEVEL_PROCEDURE
51687 ,p_module => l_log_module);
51688
51689 END IF;
51690 --
51691 l_component_type := 'AMB_JLT';
51692 l_component_code := 'DEFERRED_COGS';
51693 l_component_type_code := 'S';
51694 l_component_appl_id := 707;
51695 l_amb_context_code := 'DEFAULT';
51696 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
51697 l_event_class_code := 'SALES_ORDER';
51698 l_event_type_code := 'COGS_RECOGNITION';
51699 l_line_definition_owner_code := 'S';
51700 l_line_definition_code := 'PI_COGS_RECOGNITION';
51701 --
51702 l_balance_type_code := 'A';
51703 l_segment := NULL;
51704 l_ccid := NULL;
51705 l_adr_transaction_coa_id := NULL;
51706 l_adr_accounting_coa_id := NULL;
51707 l_adr_flexfield_segment_code := NULL;
51708 l_adr_flex_value_set_id := NULL;
51709 l_adr_value_type_code := NULL;
51710 l_adr_value_combination_id := NULL;
51711 l_adr_value_segment_code := NULL;
51712
51713 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51714 l_bflow_class_code := ''; -- 4219869 Business Flow
51715 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51716 l_budgetary_control_flag := 'N';
51717
51718 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51719 l_bflow_applied_to_amt := NULL; -- 5132302
51720 l_entered_amt_idx := NULL; -- 4262811
51721 l_accted_amt_idx := NULL; -- 4262811
51722 l_acc_rev_flag := NULL; -- 4262811
51723 l_accrual_line_num := NULL; -- 4262811
51724 l_tmp_amt := NULL; -- 4262811
51725 --
51726
51727 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51728 l_balance_type_code <> 'B' THEN
51729 IF NVL(p_source_97,9E125) = 36
51730 THEN
51731
51732 --
51733 XLA_AE_LINES_PKG.SetNewLine;
51734
51735 p_balance_type_code := l_balance_type_code;
51736 -- set the flag so later we will know whether the gain loss line needs to be created
51737
51738 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51739 p_actual_flag :='A';
51740 END IF;
51741
51742 --
51743 -- bulk performance
51744 --
51745 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51746 p_header_num => 0); -- 4262811
51747 --
51748 -- set accounting line options
51749 --
51750 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51751 p_natural_side_code => 'D'
51752 , p_gain_or_loss_flag => 'N'
51753 , p_gl_transfer_mode_code => 'S'
51754 , p_acct_entry_type_code => 'A'
51755 , p_switch_side_flag => 'Y'
51756 , p_merge_duplicate_code => 'N'
51757 );
51758 --
51759 l_acc_rev_natural_side_code := 'C'; -- 4262811
51760 --
51761 --
51762 -- set accounting line type info
51763 --
51764 xla_ae_lines_pkg.SetAcctLineType
51765 (p_component_type => l_component_type
51766 ,p_event_type_code => l_event_type_code
51767 ,p_line_definition_owner_code => l_line_definition_owner_code
51768 ,p_line_definition_code => l_line_definition_code
51769 ,p_accounting_line_code => l_component_code
51770 ,p_accounting_line_type_code => l_component_type_code
51771 ,p_accounting_line_appl_id => l_component_appl_id
51772 ,p_amb_context_code => l_amb_context_code
51773 ,p_entity_code => l_entity_code
51774 ,p_event_class_code => l_event_class_code);
51775 --
51776 -- set accounting class
51777 --
51778 xla_ae_lines_pkg.SetAcctClass(
51779 p_accounting_class_code => 'DEFERRED_COGS'
51780 , p_ae_header_id => l_ae_header_id
51781 );
51782
51783 --
51784 -- set rounding class
51785 --
51786 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51787 'DEFERRED_COGS';
51788
51789 --
51790 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51791 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51792 --
51793 -- bulk performance
51794 --
51795 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51796
51797 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51798 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51799
51800 -- 4955764
51801 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51802 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51803
51804 -- 4458381 Public Sector Enh
51805
51806 --
51807 -- set accounting attributes for the line type
51808 --
51809 l_entered_amt_idx := 3;
51810 l_accted_amt_idx := 8;
51811 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51812 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
51813 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
51814 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
51815 l_rec_acct_attrs.array_char_value(2) := p_source_85;
51816 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
51817 l_rec_acct_attrs.array_num_value(3) := p_source_91;
51818 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
51819 l_rec_acct_attrs.array_char_value(4) := p_source_88;
51820 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
51821 l_rec_acct_attrs.array_date_value(5) := p_source_92;
51822 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
51823 l_rec_acct_attrs.array_num_value(6) := p_source_93;
51824 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
51825 l_rec_acct_attrs.array_char_value(7) := p_source_94;
51826 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
51827 l_rec_acct_attrs.array_num_value(8) := p_source_95;
51828
51829 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51830 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51831
51832 ---------------------------------------------------------------------------------------------------------------
51833 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51834 ---------------------------------------------------------------------------------------------------------------
51835 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51836
51837 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51838 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51839
51840 IF xla_accounting_cache_pkg.GetValueChar
51841 (p_source_code => 'LEDGER_CATEGORY_CODE'
51842 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51843 AND l_bflow_method_code = 'PRIOR_ENTRY'
51844 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51845 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51846 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51847 )
51848 THEN
51849 xla_ae_lines_pkg.BflowUpgEntry
51850 (p_business_method_code => l_bflow_method_code
51851 ,p_business_class_code => l_bflow_class_code
51852 ,p_balance_type => l_balance_type_code);
51853 ELSE
51854 NULL;
51855 -- No business flow processing for business flow method of NONE.
51856 END IF;
51857
51858 --
51859 -- call analytical criteria
51860 --
51861
51862 --
51863 -- call description
51864 --
51865 -- No description or it is inherited.
51866 --
51867 -- call ADRs
51868 -- Bug 4922099
51869 --
51870 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51871 (NVL(l_actual_upg_option, 'N') = 'O') OR
51872 (NVL(l_enc_upg_option, 'N') = 'O')
51873 )
51874 THEN
51875 NULL;
51876 --
51877 --
51878
51879 l_ccid := AcctDerRule_6(
51880 p_application_id => p_application_id
51881 , p_ae_header_id => l_ae_header_id
51882 , p_source_11 => p_source_11
51883 , x_transaction_coa_id => l_adr_transaction_coa_id
51884 , x_accounting_coa_id => l_adr_accounting_coa_id
51885 , x_value_type_code => l_adr_value_type_code
51886 , p_side => 'NA'
51887 );
51888
51889 xla_ae_lines_pkg.set_ccid(
51890 p_code_combination_id => l_ccid
51891 , p_value_type_code => l_adr_value_type_code
51892 , p_transaction_coa_id => l_adr_transaction_coa_id
51893 , p_accounting_coa_id => l_adr_accounting_coa_id
51894 , p_adr_code => 'CST_DEFAULT'
51895 , p_adr_type_code => 'S'
51896 , p_component_type => l_component_type
51897 , p_component_code => l_component_code
51898 , p_component_type_code => l_component_type_code
51899 , p_component_appl_id => l_component_appl_id
51900 , p_amb_context_code => l_amb_context_code
51901 , p_side => 'NA'
51902 );
51903
51904
51905 --
51906 --
51907 END IF;
51908 --
51909 -- Bug 4922099
51910 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51911 (NVL(l_enc_upg_option, 'N') = 'O')
51912 ) AND
51913 (l_bflow_method_code = 'PRIOR_ENTRY')
51914 )
51915 THEN
51916 IF
51917 --
51918 1 = 2
51919 --
51920 THEN
51921 xla_accounting_err_pkg.build_message
51922 (p_appli_s_name => 'XLA'
51923 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51924 ,p_token_1 => 'LINE_NUMBER'
51925 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
51926 ,p_token_2 => 'LINE_TYPE_NAME'
51927 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
51928 l_component_type
51929 ,l_component_code
51930 ,l_component_type_code
51931 ,l_component_appl_id
51932 ,l_amb_context_code
51933 ,l_entity_code
51934 ,l_event_class_code
51935 )
51936 ,p_token_3 => 'OWNER'
51937 ,p_value_3 => xla_lookups_pkg.get_meaning(
51938 p_lookup_type => 'XLA_OWNER_TYPE'
51939 ,p_lookup_code => l_component_type_code
51940 )
51941 ,p_token_4 => 'PRODUCT_NAME'
51942 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
51943 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
51944 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
51945 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
51946 ,p_ae_header_id => NULL
51947 );
51948
51949 IF (C_LEVEL_ERROR>= g_log_level) THEN
51950 trace
51951 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51952 ,p_level => C_LEVEL_ERROR
51953 ,p_module => l_log_module);
51954 END IF;
51955 END IF;
51956 END IF;
51957 --
51958 --
51959 ------------------------------------------------------------------------------------------------
51960 -- 4219869 Business Flow
51961 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
51962 -- Prior Entry. Currently, the following code is always generated.
51963 ------------------------------------------------------------------------------------------------
51964 XLA_AE_LINES_PKG.ValidateCurrentLine;
51965
51966 ------------------------------------------------------------------------------------
51967 -- 4219869 Business Flow
51968 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
51969 ------------------------------------------------------------------------------------
51970 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51971
51972 ----------------------------------------------------------------------------------
51973 -- 4219869 Business Flow
51974 -- Update journal entry status -- Need to generate this within IF <condition>
51975 ----------------------------------------------------------------------------------
51976 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51977 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
51978 ,p_balance_type_code => l_balance_type_code
51979 );
51980
51981 -------------------------------------------------------------------------------------------
51982 -- 4262811 - Generate the Accrual Reversal lines
51983 -------------------------------------------------------------------------------------------
51984 BEGIN
51985 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51986 (g_array_event(p_event_id).array_value_num('header_index'));
51987 IF l_acc_rev_flag IS NULL THEN
51988 l_acc_rev_flag := 'N';
51989 END IF;
51990 EXCEPTION
51991 WHEN OTHERS THEN
51992 l_acc_rev_flag := 'N';
51993 END;
51994 --
51995 IF (l_acc_rev_flag = 'Y') THEN
51996
51997 -- 4645092 ------------------------------------------------------------------------------
51998 -- To allow MPA report to determine if it should generate report process
51999 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52000 ------------------------------------------------------------------------------------------
52001
52002 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52003 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52004 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52005 -- call ADRs
52006 -- Bug 4922099
52007 --
52008 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52009 (NVL(l_actual_upg_option, 'N') = 'O') OR
52010 (NVL(l_enc_upg_option, 'N') = 'O')
52011 )
52012 THEN
52013 NULL;
52014 --
52015 --
52016
52017 l_ccid := AcctDerRule_6(
52018 p_application_id => p_application_id
52019 , p_ae_header_id => l_ae_header_id
52020 , p_source_11 => p_source_11
52021 , x_transaction_coa_id => l_adr_transaction_coa_id
52022 , x_accounting_coa_id => l_adr_accounting_coa_id
52023 , x_value_type_code => l_adr_value_type_code
52024 , p_side => 'NA'
52025 );
52026
52027 xla_ae_lines_pkg.set_ccid(
52028 p_code_combination_id => l_ccid
52029 , p_value_type_code => l_adr_value_type_code
52030 , p_transaction_coa_id => l_adr_transaction_coa_id
52031 , p_accounting_coa_id => l_adr_accounting_coa_id
52032 , p_adr_code => 'CST_DEFAULT'
52033 , p_adr_type_code => 'S'
52034 , p_component_type => l_component_type
52035 , p_component_code => l_component_code
52036 , p_component_type_code => l_component_type_code
52037 , p_component_appl_id => l_component_appl_id
52038 , p_amb_context_code => l_amb_context_code
52039 , p_side => 'NA'
52040 );
52041
52042
52043 --
52044 --
52045 END IF;
52046
52047 --
52048 -- Update the line information that should be overwritten
52049 --
52050 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52051 p_header_num => 1);
52052 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52053
52054 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52055
52056 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52057 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52058 END IF;
52059
52060 --
52061 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52062 --
52063 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52064 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52065 ELSE
52066 ---------------------------------------------------------------------------------------------------
52067 -- 4262811a Switch Sign
52068 ---------------------------------------------------------------------------------------------------
52069 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52070 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52071 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52072 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52073 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52074 -- 5132302
52075 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52076 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52077
52078 END IF;
52079
52080 -- 4955764
52081 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52082 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52083
52084
52085 XLA_AE_LINES_PKG.ValidateCurrentLine;
52086 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52087
52088 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52089 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52090 ,p_balance_type_code => l_balance_type_code);
52091
52092 END IF;
52093
52094 -----------------------------------------------------------------------------------------
52095 -- 4262811 Multiperiod Accounting
52096 -----------------------------------------------------------------------------------------
52097 -- No MPA option is assigned.
52098
52099
52100 END IF;
52101 END IF;
52102 --
52103
52104 --
52105 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52106 trace
52107 (p_msg => 'END of AcctLineType_116'
52108 ,p_level => C_LEVEL_PROCEDURE
52109 ,p_module => l_log_module);
52110 END IF;
52111 --
52112 EXCEPTION
52113 WHEN xla_exceptions_pkg.application_exception THEN
52114 RAISE;
52115 WHEN OTHERS THEN
52116 xla_exceptions_pkg.raise_message
52117 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_116');
52118 END AcctLineType_116;
52119 --
52120
52121 ---------------------------------------
52122 --
52123 -- PRIVATE FUNCTION
52124 -- AcctLineType_117
52125 --
52126 ---------------------------------------
52127 PROCEDURE AcctLineType_117 (
52128 p_application_id IN NUMBER
52129 ,p_event_id IN NUMBER
52130 ,p_calculate_acctd_flag IN VARCHAR2
52131 ,p_calculate_g_l_flag IN VARCHAR2
52132 ,p_actual_flag IN OUT VARCHAR2
52133 ,p_balance_type_code OUT VARCHAR2
52134 ,p_gain_or_loss_ref OUT VARCHAR2
52135
52136 --Cost Management Default Account
52137 , p_source_11 IN NUMBER
52138 --DISTRIBUTION_IDENTIFIER
52139 , p_source_84 IN NUMBER
52140 --Distribution Type
52141 , p_source_85 IN VARCHAR2
52142 , p_source_85_meaning IN VARCHAR2
52143 --Entered Currency Code
52144 , p_source_88 IN VARCHAR2
52145 --Entered Amount
52146 , p_source_91 IN NUMBER
52147 --Currency Conversion Date
52148 , p_source_92 IN DATE
52149 --Currency Conversion Rate
52150 , p_source_93 IN NUMBER
52151 --Currency Conversion Type
52152 , p_source_94 IN VARCHAR2
52153 --Accounted Amount
52154 , p_source_95 IN NUMBER
52155 --Accounting Line Type
52156 , p_source_97 IN NUMBER
52157 )
52158 IS
52159
52160 l_component_type VARCHAR2(80);
52161 l_component_code VARCHAR2(30);
52162 l_component_type_code VARCHAR2(1);
52163 l_component_appl_id INTEGER;
52164 l_amb_context_code VARCHAR2(30);
52165 l_entity_code VARCHAR2(30);
52166 l_event_class_code VARCHAR2(30);
52167 l_ae_header_id NUMBER;
52168 l_event_type_code VARCHAR2(30);
52169 l_line_definition_code VARCHAR2(30);
52170 l_line_definition_owner_code VARCHAR2(1);
52171 --
52172 -- adr variables
52173 l_segment VARCHAR2(30);
52174 l_ccid NUMBER;
52175 l_adr_transaction_coa_id NUMBER;
52176 l_adr_accounting_coa_id NUMBER;
52177 l_adr_flexfield_segment_code VARCHAR2(30);
52178 l_adr_flex_value_set_id NUMBER;
52179 l_adr_value_type_code VARCHAR2(30);
52180 l_adr_value_combination_id NUMBER;
52181 l_adr_value_segment_code VARCHAR2(30);
52182
52183 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52184 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52185 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52186 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52187
52188 -- 4262811 Variables ------------------------------------------------------------------------------------------
52189 l_entered_amt_idx NUMBER;
52190 l_accted_amt_idx NUMBER;
52191 l_acc_rev_flag VARCHAR2(1);
52192 l_accrual_line_num NUMBER;
52193 l_tmp_amt NUMBER;
52194 l_acc_rev_natural_side_code VARCHAR2(1);
52195
52196 l_num_entries NUMBER;
52197 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52198 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52199 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52200 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52201 l_recog_line_1 NUMBER;
52202 l_recog_line_2 NUMBER;
52203
52204 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52205 l_bflow_applied_to_amt NUMBER; -- 5132302
52206 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52207
52208 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52209
52210 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52211 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52212
52213 ---------------------------------------------------------------------------------------------------------------
52214
52215
52216 --
52217 -- bulk performance
52218 --
52219 l_balance_type_code VARCHAR2(1);
52220 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52221 l_log_module VARCHAR2(240);
52222
52223 --
52224 -- Upgrade strategy
52225 --
52226 l_actual_upg_option VARCHAR2(1);
52227 l_enc_upg_option VARCHAR2(1);
52228
52229 --
52230 BEGIN
52231 --
52232 IF g_log_enabled THEN
52233 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_117';
52234 END IF;
52235 --
52236 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52237
52238 trace
52239 (p_msg => 'BEGIN of AcctLineType_117'
52240 ,p_level => C_LEVEL_PROCEDURE
52241 ,p_module => l_log_module);
52242
52243 END IF;
52244 --
52245 l_component_type := 'AMB_JLT';
52246 l_component_code := 'DEFERRED_COGS';
52247 l_component_type_code := 'S';
52248 l_component_appl_id := 707;
52249 l_amb_context_code := 'DEFAULT';
52250 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
52251 l_event_class_code := 'SALES_ORDER';
52252 l_event_type_code := 'COGS_RECOGNITION_ADJ';
52253 l_line_definition_owner_code := 'S';
52254 l_line_definition_code := 'PI_COGS_RECOGNITION_ADJ';
52255 --
52256 l_balance_type_code := 'A';
52257 l_segment := NULL;
52258 l_ccid := NULL;
52259 l_adr_transaction_coa_id := NULL;
52260 l_adr_accounting_coa_id := NULL;
52261 l_adr_flexfield_segment_code := NULL;
52262 l_adr_flex_value_set_id := NULL;
52263 l_adr_value_type_code := NULL;
52264 l_adr_value_combination_id := NULL;
52265 l_adr_value_segment_code := NULL;
52266
52267 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52268 l_bflow_class_code := ''; -- 4219869 Business Flow
52269 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52270 l_budgetary_control_flag := 'N';
52271
52272 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52273 l_bflow_applied_to_amt := NULL; -- 5132302
52274 l_entered_amt_idx := NULL; -- 4262811
52275 l_accted_amt_idx := NULL; -- 4262811
52276 l_acc_rev_flag := NULL; -- 4262811
52277 l_accrual_line_num := NULL; -- 4262811
52278 l_tmp_amt := NULL; -- 4262811
52279 --
52280
52281 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52282 l_balance_type_code <> 'B' THEN
52283 IF NVL(p_source_97,9E125) = 36
52284 THEN
52285
52286 --
52287 XLA_AE_LINES_PKG.SetNewLine;
52288
52289 p_balance_type_code := l_balance_type_code;
52290 -- set the flag so later we will know whether the gain loss line needs to be created
52291
52292 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52293 p_actual_flag :='A';
52294 END IF;
52295
52296 --
52297 -- bulk performance
52298 --
52299 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52300 p_header_num => 0); -- 4262811
52301 --
52302 -- set accounting line options
52303 --
52304 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52305 p_natural_side_code => 'D'
52306 , p_gain_or_loss_flag => 'N'
52307 , p_gl_transfer_mode_code => 'S'
52308 , p_acct_entry_type_code => 'A'
52309 , p_switch_side_flag => 'Y'
52310 , p_merge_duplicate_code => 'N'
52311 );
52312 --
52313 l_acc_rev_natural_side_code := 'C'; -- 4262811
52314 --
52315 --
52316 -- set accounting line type info
52317 --
52318 xla_ae_lines_pkg.SetAcctLineType
52319 (p_component_type => l_component_type
52320 ,p_event_type_code => l_event_type_code
52321 ,p_line_definition_owner_code => l_line_definition_owner_code
52322 ,p_line_definition_code => l_line_definition_code
52323 ,p_accounting_line_code => l_component_code
52324 ,p_accounting_line_type_code => l_component_type_code
52325 ,p_accounting_line_appl_id => l_component_appl_id
52326 ,p_amb_context_code => l_amb_context_code
52327 ,p_entity_code => l_entity_code
52328 ,p_event_class_code => l_event_class_code);
52329 --
52330 -- set accounting class
52331 --
52332 xla_ae_lines_pkg.SetAcctClass(
52333 p_accounting_class_code => 'DEFERRED_COGS'
52334 , p_ae_header_id => l_ae_header_id
52335 );
52336
52337 --
52338 -- set rounding class
52339 --
52340 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52341 'DEFERRED_COGS';
52342
52343 --
52344 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52345 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52346 --
52347 -- bulk performance
52348 --
52349 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52350
52351 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52352 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52353
52354 -- 4955764
52355 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52356 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52357
52358 -- 4458381 Public Sector Enh
52359
52360 --
52361 -- set accounting attributes for the line type
52362 --
52363 l_entered_amt_idx := 3;
52364 l_accted_amt_idx := 8;
52365 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52366 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
52367 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
52368 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
52369 l_rec_acct_attrs.array_char_value(2) := p_source_85;
52370 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
52371 l_rec_acct_attrs.array_num_value(3) := p_source_91;
52372 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
52373 l_rec_acct_attrs.array_char_value(4) := p_source_88;
52374 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
52375 l_rec_acct_attrs.array_date_value(5) := p_source_92;
52376 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
52377 l_rec_acct_attrs.array_num_value(6) := p_source_93;
52378 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
52379 l_rec_acct_attrs.array_char_value(7) := p_source_94;
52380 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
52381 l_rec_acct_attrs.array_num_value(8) := p_source_95;
52382
52383 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52384 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52385
52386 ---------------------------------------------------------------------------------------------------------------
52387 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52388 ---------------------------------------------------------------------------------------------------------------
52389 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52390
52391 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52392 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52393
52394 IF xla_accounting_cache_pkg.GetValueChar
52395 (p_source_code => 'LEDGER_CATEGORY_CODE'
52396 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52397 AND l_bflow_method_code = 'PRIOR_ENTRY'
52398 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52399 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52400 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52401 )
52402 THEN
52403 xla_ae_lines_pkg.BflowUpgEntry
52404 (p_business_method_code => l_bflow_method_code
52405 ,p_business_class_code => l_bflow_class_code
52406 ,p_balance_type => l_balance_type_code);
52407 ELSE
52408 NULL;
52409 -- No business flow processing for business flow method of NONE.
52410 END IF;
52411
52412 --
52413 -- call analytical criteria
52414 --
52415
52416 --
52417 -- call description
52418 --
52419 -- No description or it is inherited.
52420 --
52421 -- call ADRs
52422 -- Bug 4922099
52423 --
52424 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52425 (NVL(l_actual_upg_option, 'N') = 'O') OR
52426 (NVL(l_enc_upg_option, 'N') = 'O')
52427 )
52428 THEN
52429 NULL;
52430 --
52431 --
52432
52433 l_ccid := AcctDerRule_6(
52434 p_application_id => p_application_id
52435 , p_ae_header_id => l_ae_header_id
52436 , p_source_11 => p_source_11
52437 , x_transaction_coa_id => l_adr_transaction_coa_id
52438 , x_accounting_coa_id => l_adr_accounting_coa_id
52439 , x_value_type_code => l_adr_value_type_code
52440 , p_side => 'NA'
52441 );
52442
52443 xla_ae_lines_pkg.set_ccid(
52444 p_code_combination_id => l_ccid
52445 , p_value_type_code => l_adr_value_type_code
52446 , p_transaction_coa_id => l_adr_transaction_coa_id
52447 , p_accounting_coa_id => l_adr_accounting_coa_id
52448 , p_adr_code => 'CST_DEFAULT'
52449 , p_adr_type_code => 'S'
52450 , p_component_type => l_component_type
52451 , p_component_code => l_component_code
52452 , p_component_type_code => l_component_type_code
52453 , p_component_appl_id => l_component_appl_id
52454 , p_amb_context_code => l_amb_context_code
52455 , p_side => 'NA'
52456 );
52457
52458
52459 --
52460 --
52461 END IF;
52462 --
52463 -- Bug 4922099
52464 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52465 (NVL(l_enc_upg_option, 'N') = 'O')
52466 ) AND
52467 (l_bflow_method_code = 'PRIOR_ENTRY')
52468 )
52469 THEN
52470 IF
52471 --
52472 1 = 2
52473 --
52474 THEN
52475 xla_accounting_err_pkg.build_message
52476 (p_appli_s_name => 'XLA'
52477 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52478 ,p_token_1 => 'LINE_NUMBER'
52479 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52480 ,p_token_2 => 'LINE_TYPE_NAME'
52481 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52482 l_component_type
52483 ,l_component_code
52484 ,l_component_type_code
52485 ,l_component_appl_id
52486 ,l_amb_context_code
52487 ,l_entity_code
52488 ,l_event_class_code
52489 )
52490 ,p_token_3 => 'OWNER'
52491 ,p_value_3 => xla_lookups_pkg.get_meaning(
52492 p_lookup_type => 'XLA_OWNER_TYPE'
52493 ,p_lookup_code => l_component_type_code
52494 )
52495 ,p_token_4 => 'PRODUCT_NAME'
52496 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52497 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52498 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52499 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52500 ,p_ae_header_id => NULL
52501 );
52502
52503 IF (C_LEVEL_ERROR>= g_log_level) THEN
52504 trace
52505 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52506 ,p_level => C_LEVEL_ERROR
52507 ,p_module => l_log_module);
52508 END IF;
52509 END IF;
52510 END IF;
52511 --
52512 --
52513 ------------------------------------------------------------------------------------------------
52514 -- 4219869 Business Flow
52515 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52516 -- Prior Entry. Currently, the following code is always generated.
52517 ------------------------------------------------------------------------------------------------
52518 XLA_AE_LINES_PKG.ValidateCurrentLine;
52519
52520 ------------------------------------------------------------------------------------
52521 -- 4219869 Business Flow
52522 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52523 ------------------------------------------------------------------------------------
52524 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52525
52526 ----------------------------------------------------------------------------------
52527 -- 4219869 Business Flow
52528 -- Update journal entry status -- Need to generate this within IF <condition>
52529 ----------------------------------------------------------------------------------
52530 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52531 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52532 ,p_balance_type_code => l_balance_type_code
52533 );
52534
52535 -------------------------------------------------------------------------------------------
52536 -- 4262811 - Generate the Accrual Reversal lines
52537 -------------------------------------------------------------------------------------------
52538 BEGIN
52539 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52540 (g_array_event(p_event_id).array_value_num('header_index'));
52541 IF l_acc_rev_flag IS NULL THEN
52542 l_acc_rev_flag := 'N';
52543 END IF;
52544 EXCEPTION
52545 WHEN OTHERS THEN
52546 l_acc_rev_flag := 'N';
52547 END;
52548 --
52549 IF (l_acc_rev_flag = 'Y') THEN
52550
52551 -- 4645092 ------------------------------------------------------------------------------
52552 -- To allow MPA report to determine if it should generate report process
52553 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52554 ------------------------------------------------------------------------------------------
52555
52556 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52557 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52558 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52559 -- call ADRs
52560 -- Bug 4922099
52561 --
52562 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52563 (NVL(l_actual_upg_option, 'N') = 'O') OR
52564 (NVL(l_enc_upg_option, 'N') = 'O')
52565 )
52566 THEN
52567 NULL;
52568 --
52569 --
52570
52571 l_ccid := AcctDerRule_6(
52572 p_application_id => p_application_id
52573 , p_ae_header_id => l_ae_header_id
52574 , p_source_11 => p_source_11
52575 , x_transaction_coa_id => l_adr_transaction_coa_id
52576 , x_accounting_coa_id => l_adr_accounting_coa_id
52577 , x_value_type_code => l_adr_value_type_code
52578 , p_side => 'NA'
52579 );
52580
52581 xla_ae_lines_pkg.set_ccid(
52582 p_code_combination_id => l_ccid
52583 , p_value_type_code => l_adr_value_type_code
52584 , p_transaction_coa_id => l_adr_transaction_coa_id
52585 , p_accounting_coa_id => l_adr_accounting_coa_id
52586 , p_adr_code => 'CST_DEFAULT'
52587 , p_adr_type_code => 'S'
52588 , p_component_type => l_component_type
52589 , p_component_code => l_component_code
52590 , p_component_type_code => l_component_type_code
52591 , p_component_appl_id => l_component_appl_id
52592 , p_amb_context_code => l_amb_context_code
52593 , p_side => 'NA'
52594 );
52595
52596
52597 --
52598 --
52599 END IF;
52600
52601 --
52602 -- Update the line information that should be overwritten
52603 --
52604 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52605 p_header_num => 1);
52606 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52607
52608 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52609
52610 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52611 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52612 END IF;
52613
52614 --
52615 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52616 --
52617 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52618 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52619 ELSE
52620 ---------------------------------------------------------------------------------------------------
52621 -- 4262811a Switch Sign
52622 ---------------------------------------------------------------------------------------------------
52623 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52624 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52625 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52626 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52627 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52628 -- 5132302
52629 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52630 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52631
52632 END IF;
52633
52634 -- 4955764
52635 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52636 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52637
52638
52639 XLA_AE_LINES_PKG.ValidateCurrentLine;
52640 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52641
52642 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52643 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52644 ,p_balance_type_code => l_balance_type_code);
52645
52646 END IF;
52647
52648 -----------------------------------------------------------------------------------------
52649 -- 4262811 Multiperiod Accounting
52650 -----------------------------------------------------------------------------------------
52651 -- No MPA option is assigned.
52652
52653
52654 END IF;
52655 END IF;
52656 --
52657
52658 --
52659 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52660 trace
52661 (p_msg => 'END of AcctLineType_117'
52662 ,p_level => C_LEVEL_PROCEDURE
52663 ,p_module => l_log_module);
52664 END IF;
52665 --
52666 EXCEPTION
52667 WHEN xla_exceptions_pkg.application_exception THEN
52668 RAISE;
52669 WHEN OTHERS THEN
52670 xla_exceptions_pkg.raise_message
52671 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_117');
52672 END AcctLineType_117;
52673 --
52674
52675 ---------------------------------------
52676 --
52677 -- PRIVATE FUNCTION
52678 -- AcctLineType_118
52679 --
52680 ---------------------------------------
52681 PROCEDURE AcctLineType_118 (
52682 p_application_id IN NUMBER
52683 ,p_event_id IN NUMBER
52684 ,p_calculate_acctd_flag IN VARCHAR2
52685 ,p_calculate_g_l_flag IN VARCHAR2
52686 ,p_actual_flag IN OUT VARCHAR2
52687 ,p_balance_type_code OUT VARCHAR2
52688 ,p_gain_or_loss_ref OUT VARCHAR2
52689
52690 --TRANSACTION_ID
52691 , p_source_1 IN NUMBER
52692 --Item Concatenated Segments
52693 , p_source_2 IN VARCHAR2
52694 --Transaction Quantity
52695 , p_source_3 IN NUMBER
52696 --Transaction Unit of Measure Code
52697 , p_source_4 IN VARCHAR2
52698 --Inventory Transaction Type Description
52699 , p_source_5 IN VARCHAR2
52700 --Cost Management Default Account
52701 , p_source_11 IN NUMBER
52702 --DISTRIBUTION_IDENTIFIER
52703 , p_source_84 IN NUMBER
52704 --Distribution Type
52705 , p_source_85 IN VARCHAR2
52706 , p_source_85_meaning IN VARCHAR2
52707 --Entered Currency Code
52708 , p_source_88 IN VARCHAR2
52709 --Entered Amount
52710 , p_source_91 IN NUMBER
52711 --Currency Conversion Date
52712 , p_source_92 IN DATE
52713 --Currency Conversion Rate
52714 , p_source_93 IN NUMBER
52715 --Currency Conversion Type
52716 , p_source_94 IN VARCHAR2
52717 --Accounted Amount
52718 , p_source_95 IN NUMBER
52719 --Accounting Line Type
52720 , p_source_97 IN NUMBER
52721 )
52722 IS
52723
52724 l_component_type VARCHAR2(80);
52725 l_component_code VARCHAR2(30);
52726 l_component_type_code VARCHAR2(1);
52727 l_component_appl_id INTEGER;
52728 l_amb_context_code VARCHAR2(30);
52729 l_entity_code VARCHAR2(30);
52730 l_event_class_code VARCHAR2(30);
52731 l_ae_header_id NUMBER;
52732 l_event_type_code VARCHAR2(30);
52733 l_line_definition_code VARCHAR2(30);
52734 l_line_definition_owner_code VARCHAR2(1);
52735 --
52736 -- adr variables
52737 l_segment VARCHAR2(30);
52738 l_ccid NUMBER;
52739 l_adr_transaction_coa_id NUMBER;
52740 l_adr_accounting_coa_id NUMBER;
52741 l_adr_flexfield_segment_code VARCHAR2(30);
52742 l_adr_flex_value_set_id NUMBER;
52743 l_adr_value_type_code VARCHAR2(30);
52744 l_adr_value_combination_id NUMBER;
52745 l_adr_value_segment_code VARCHAR2(30);
52746
52747 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52748 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52749 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52750 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52751
52752 -- 4262811 Variables ------------------------------------------------------------------------------------------
52753 l_entered_amt_idx NUMBER;
52754 l_accted_amt_idx NUMBER;
52755 l_acc_rev_flag VARCHAR2(1);
52756 l_accrual_line_num NUMBER;
52757 l_tmp_amt NUMBER;
52758 l_acc_rev_natural_side_code VARCHAR2(1);
52759
52760 l_num_entries NUMBER;
52761 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52762 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52763 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52764 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52765 l_recog_line_1 NUMBER;
52766 l_recog_line_2 NUMBER;
52767
52768 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52769 l_bflow_applied_to_amt NUMBER; -- 5132302
52770 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52771
52772 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52773
52774 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52775 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52776
52777 ---------------------------------------------------------------------------------------------------------------
52778
52779
52780 --
52781 -- bulk performance
52782 --
52783 l_balance_type_code VARCHAR2(1);
52784 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52785 l_log_module VARCHAR2(240);
52786
52787 --
52788 -- Upgrade strategy
52789 --
52790 l_actual_upg_option VARCHAR2(1);
52791 l_enc_upg_option VARCHAR2(1);
52792
52793 --
52794 BEGIN
52795 --
52796 IF g_log_enabled THEN
52797 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_118';
52798 END IF;
52799 --
52800 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52801
52802 trace
52803 (p_msg => 'BEGIN of AcctLineType_118'
52804 ,p_level => C_LEVEL_PROCEDURE
52805 ,p_module => l_log_module);
52806
52807 END IF;
52808 --
52809 l_component_type := 'AMB_JLT';
52810 l_component_code := 'DEFERRED_COGS';
52811 l_component_type_code := 'S';
52812 l_component_appl_id := 707;
52813 l_amb_context_code := 'DEFAULT';
52814 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
52815 l_event_class_code := 'SALES_ORDER';
52816 l_event_type_code := 'LOG_SO_ISSUE';
52817 l_line_definition_owner_code := 'S';
52818 l_line_definition_code := 'PI_LOG_SO_ISSUE';
52819 --
52820 l_balance_type_code := 'A';
52821 l_segment := NULL;
52822 l_ccid := NULL;
52823 l_adr_transaction_coa_id := NULL;
52824 l_adr_accounting_coa_id := NULL;
52825 l_adr_flexfield_segment_code := NULL;
52826 l_adr_flex_value_set_id := NULL;
52827 l_adr_value_type_code := NULL;
52828 l_adr_value_combination_id := NULL;
52829 l_adr_value_segment_code := NULL;
52830
52831 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52832 l_bflow_class_code := ''; -- 4219869 Business Flow
52833 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52834 l_budgetary_control_flag := 'N';
52835
52836 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52837 l_bflow_applied_to_amt := NULL; -- 5132302
52838 l_entered_amt_idx := NULL; -- 4262811
52839 l_accted_amt_idx := NULL; -- 4262811
52840 l_acc_rev_flag := NULL; -- 4262811
52841 l_accrual_line_num := NULL; -- 4262811
52842 l_tmp_amt := NULL; -- 4262811
52843 --
52844
52845 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52846 l_balance_type_code <> 'B' THEN
52847 IF NVL(p_source_97,9E125) = 36
52848 THEN
52849
52850 --
52851 XLA_AE_LINES_PKG.SetNewLine;
52852
52853 p_balance_type_code := l_balance_type_code;
52854 -- set the flag so later we will know whether the gain loss line needs to be created
52855
52856 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52857 p_actual_flag :='A';
52858 END IF;
52859
52860 --
52861 -- bulk performance
52862 --
52863 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52864 p_header_num => 0); -- 4262811
52865 --
52866 -- set accounting line options
52867 --
52868 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52869 p_natural_side_code => 'D'
52870 , p_gain_or_loss_flag => 'N'
52871 , p_gl_transfer_mode_code => 'S'
52872 , p_acct_entry_type_code => 'A'
52873 , p_switch_side_flag => 'Y'
52874 , p_merge_duplicate_code => 'N'
52875 );
52876 --
52877 l_acc_rev_natural_side_code := 'C'; -- 4262811
52878 --
52879 --
52880 -- set accounting line type info
52881 --
52882 xla_ae_lines_pkg.SetAcctLineType
52883 (p_component_type => l_component_type
52884 ,p_event_type_code => l_event_type_code
52885 ,p_line_definition_owner_code => l_line_definition_owner_code
52886 ,p_line_definition_code => l_line_definition_code
52887 ,p_accounting_line_code => l_component_code
52888 ,p_accounting_line_type_code => l_component_type_code
52889 ,p_accounting_line_appl_id => l_component_appl_id
52890 ,p_amb_context_code => l_amb_context_code
52891 ,p_entity_code => l_entity_code
52892 ,p_event_class_code => l_event_class_code);
52893 --
52894 -- set accounting class
52895 --
52896 xla_ae_lines_pkg.SetAcctClass(
52897 p_accounting_class_code => 'DEFERRED_COGS'
52898 , p_ae_header_id => l_ae_header_id
52899 );
52900
52901 --
52902 -- set rounding class
52903 --
52904 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52905 'DEFERRED_COGS';
52906
52907 --
52908 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52909 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52910 --
52911 -- bulk performance
52912 --
52913 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52914
52915 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52916 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52917
52918 -- 4955764
52919 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52920 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52921
52922 -- 4458381 Public Sector Enh
52923
52924 --
52925 -- set accounting attributes for the line type
52926 --
52927 l_entered_amt_idx := 3;
52928 l_accted_amt_idx := 8;
52929 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52930 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
52931 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
52932 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
52933 l_rec_acct_attrs.array_char_value(2) := p_source_85;
52934 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
52935 l_rec_acct_attrs.array_num_value(3) := p_source_91;
52936 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
52937 l_rec_acct_attrs.array_char_value(4) := p_source_88;
52938 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
52939 l_rec_acct_attrs.array_date_value(5) := p_source_92;
52940 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
52941 l_rec_acct_attrs.array_num_value(6) := p_source_93;
52942 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
52943 l_rec_acct_attrs.array_char_value(7) := p_source_94;
52944 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
52945 l_rec_acct_attrs.array_num_value(8) := p_source_95;
52946
52947 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52948 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52949
52950 ---------------------------------------------------------------------------------------------------------------
52951 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52952 ---------------------------------------------------------------------------------------------------------------
52953 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52954
52955 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52956 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52957
52958 IF xla_accounting_cache_pkg.GetValueChar
52959 (p_source_code => 'LEDGER_CATEGORY_CODE'
52960 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52961 AND l_bflow_method_code = 'PRIOR_ENTRY'
52962 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52963 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52964 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52965 )
52966 THEN
52967 xla_ae_lines_pkg.BflowUpgEntry
52968 (p_business_method_code => l_bflow_method_code
52969 ,p_business_class_code => l_bflow_class_code
52970 ,p_balance_type => l_balance_type_code);
52971 ELSE
52972 NULL;
52973 -- No business flow processing for business flow method of NONE.
52974 END IF;
52975
52976 --
52977 -- call analytical criteria
52978 --
52979
52980 --
52981 -- call description
52982 --
52983
52984 xla_ae_lines_pkg.SetLineDescription(
52985 p_ae_header_id => l_ae_header_id
52986 ,p_description => Description_1 (
52987 p_application_id => p_application_id
52988 , p_ae_header_id => l_ae_header_id
52989 , p_source_1 => p_source_1
52990 , p_source_2 => p_source_2
52991 , p_source_3 => p_source_3
52992 , p_source_4 => p_source_4
52993 , p_source_5 => p_source_5
52994 )
52995 );
52996
52997
52998 --
52999 -- call ADRs
53000 -- Bug 4922099
53001 --
53002 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53003 (NVL(l_actual_upg_option, 'N') = 'O') OR
53004 (NVL(l_enc_upg_option, 'N') = 'O')
53005 )
53006 THEN
53007 NULL;
53008 --
53009 --
53010
53011 l_ccid := AcctDerRule_6(
53012 p_application_id => p_application_id
53013 , p_ae_header_id => l_ae_header_id
53014 , p_source_11 => p_source_11
53015 , x_transaction_coa_id => l_adr_transaction_coa_id
53016 , x_accounting_coa_id => l_adr_accounting_coa_id
53017 , x_value_type_code => l_adr_value_type_code
53018 , p_side => 'NA'
53019 );
53020
53021 xla_ae_lines_pkg.set_ccid(
53022 p_code_combination_id => l_ccid
53023 , p_value_type_code => l_adr_value_type_code
53024 , p_transaction_coa_id => l_adr_transaction_coa_id
53025 , p_accounting_coa_id => l_adr_accounting_coa_id
53026 , p_adr_code => 'CST_DEFAULT'
53027 , p_adr_type_code => 'S'
53028 , p_component_type => l_component_type
53029 , p_component_code => l_component_code
53030 , p_component_type_code => l_component_type_code
53031 , p_component_appl_id => l_component_appl_id
53032 , p_amb_context_code => l_amb_context_code
53033 , p_side => 'NA'
53034 );
53035
53036
53037 --
53038 --
53039 END IF;
53040 --
53041 -- Bug 4922099
53042 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
53043 (NVL(l_enc_upg_option, 'N') = 'O')
53044 ) AND
53045 (l_bflow_method_code = 'PRIOR_ENTRY')
53046 )
53047 THEN
53048 IF
53049 --
53050 1 = 2
53051 --
53052 THEN
53053 xla_accounting_err_pkg.build_message
53054 (p_appli_s_name => 'XLA'
53055 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53056 ,p_token_1 => 'LINE_NUMBER'
53057 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
53058 ,p_token_2 => 'LINE_TYPE_NAME'
53059 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
53060 l_component_type
53061 ,l_component_code
53062 ,l_component_type_code
53063 ,l_component_appl_id
53064 ,l_amb_context_code
53065 ,l_entity_code
53066 ,l_event_class_code
53067 )
53068 ,p_token_3 => 'OWNER'
53069 ,p_value_3 => xla_lookups_pkg.get_meaning(
53070 p_lookup_type => 'XLA_OWNER_TYPE'
53071 ,p_lookup_code => l_component_type_code
53072 )
53073 ,p_token_4 => 'PRODUCT_NAME'
53074 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
53075 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
53076 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
53077 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
53078 ,p_ae_header_id => NULL
53079 );
53080
53081 IF (C_LEVEL_ERROR>= g_log_level) THEN
53082 trace
53083 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53084 ,p_level => C_LEVEL_ERROR
53085 ,p_module => l_log_module);
53086 END IF;
53087 END IF;
53088 END IF;
53089 --
53090 --
53091 ------------------------------------------------------------------------------------------------
53092 -- 4219869 Business Flow
53093 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
53094 -- Prior Entry. Currently, the following code is always generated.
53095 ------------------------------------------------------------------------------------------------
53096 XLA_AE_LINES_PKG.ValidateCurrentLine;
53097
53098 ------------------------------------------------------------------------------------
53099 -- 4219869 Business Flow
53100 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
53101 ------------------------------------------------------------------------------------
53102 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53103
53104 ----------------------------------------------------------------------------------
53105 -- 4219869 Business Flow
53106 -- Update journal entry status -- Need to generate this within IF <condition>
53107 ----------------------------------------------------------------------------------
53108 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53109 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
53110 ,p_balance_type_code => l_balance_type_code
53111 );
53112
53113 -------------------------------------------------------------------------------------------
53114 -- 4262811 - Generate the Accrual Reversal lines
53115 -------------------------------------------------------------------------------------------
53116 BEGIN
53117 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
53118 (g_array_event(p_event_id).array_value_num('header_index'));
53119 IF l_acc_rev_flag IS NULL THEN
53120 l_acc_rev_flag := 'N';
53121 END IF;
53122 EXCEPTION
53123 WHEN OTHERS THEN
53124 l_acc_rev_flag := 'N';
53125 END;
53126 --
53127 IF (l_acc_rev_flag = 'Y') THEN
53128
53129 -- 4645092 ------------------------------------------------------------------------------
53130 -- To allow MPA report to determine if it should generate report process
53131 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
53132 ------------------------------------------------------------------------------------------
53133
53134 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
53135 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
53136 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
53137 -- call ADRs
53138 -- Bug 4922099
53139 --
53140 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53141 (NVL(l_actual_upg_option, 'N') = 'O') OR
53142 (NVL(l_enc_upg_option, 'N') = 'O')
53143 )
53144 THEN
53145 NULL;
53146 --
53147 --
53148
53149 l_ccid := AcctDerRule_6(
53150 p_application_id => p_application_id
53151 , p_ae_header_id => l_ae_header_id
53152 , p_source_11 => p_source_11
53153 , x_transaction_coa_id => l_adr_transaction_coa_id
53154 , x_accounting_coa_id => l_adr_accounting_coa_id
53155 , x_value_type_code => l_adr_value_type_code
53156 , p_side => 'NA'
53157 );
53158
53159 xla_ae_lines_pkg.set_ccid(
53160 p_code_combination_id => l_ccid
53161 , p_value_type_code => l_adr_value_type_code
53162 , p_transaction_coa_id => l_adr_transaction_coa_id
53163 , p_accounting_coa_id => l_adr_accounting_coa_id
53164 , p_adr_code => 'CST_DEFAULT'
53165 , p_adr_type_code => 'S'
53166 , p_component_type => l_component_type
53167 , p_component_code => l_component_code
53168 , p_component_type_code => l_component_type_code
53169 , p_component_appl_id => l_component_appl_id
53170 , p_amb_context_code => l_amb_context_code
53171 , p_side => 'NA'
53172 );
53173
53174
53175 --
53176 --
53177 END IF;
53178
53179 --
53180 -- Update the line information that should be overwritten
53181 --
53182 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53183 p_header_num => 1);
53184 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53185
53186 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53187
53188 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53189 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53190 END IF;
53191
53192 --
53193 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53194 --
53195 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53196 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53197 ELSE
53198 ---------------------------------------------------------------------------------------------------
53199 -- 4262811a Switch Sign
53200 ---------------------------------------------------------------------------------------------------
53201 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53202 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53203 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53204 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53205 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53206 -- 5132302
53207 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53208 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53209
53210 END IF;
53211
53212 -- 4955764
53213 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53214 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53215
53216
53217 XLA_AE_LINES_PKG.ValidateCurrentLine;
53218 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53219
53220 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53221 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53222 ,p_balance_type_code => l_balance_type_code);
53223
53224 END IF;
53225
53226 -----------------------------------------------------------------------------------------
53227 -- 4262811 Multiperiod Accounting
53228 -----------------------------------------------------------------------------------------
53229 -- No MPA option is assigned.
53230
53231
53232 END IF;
53233 END IF;
53234 --
53235
53236 --
53237 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53238 trace
53239 (p_msg => 'END of AcctLineType_118'
53240 ,p_level => C_LEVEL_PROCEDURE
53241 ,p_module => l_log_module);
53242 END IF;
53243 --
53244 EXCEPTION
53245 WHEN xla_exceptions_pkg.application_exception THEN
53246 RAISE;
53247 WHEN OTHERS THEN
53248 xla_exceptions_pkg.raise_message
53249 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_118');
53250 END AcctLineType_118;
53251 --
53252
53253 ---------------------------------------
53254 --
53255 -- PRIVATE FUNCTION
53256 -- AcctLineType_119
53257 --
53258 ---------------------------------------
53259 PROCEDURE AcctLineType_119 (
53260 p_application_id IN NUMBER
53261 ,p_event_id IN NUMBER
53262 ,p_calculate_acctd_flag IN VARCHAR2
53263 ,p_calculate_g_l_flag IN VARCHAR2
53264 ,p_actual_flag IN OUT VARCHAR2
53265 ,p_balance_type_code OUT VARCHAR2
53266 ,p_gain_or_loss_ref OUT VARCHAR2
53267
53268 --TRANSACTION_ID
53269 , p_source_1 IN NUMBER
53270 --Item Concatenated Segments
53271 , p_source_2 IN VARCHAR2
53272 --Transaction Quantity
53273 , p_source_3 IN NUMBER
53274 --Transaction Unit of Measure Code
53275 , p_source_4 IN VARCHAR2
53276 --Inventory Transaction Type Description
53277 , p_source_5 IN VARCHAR2
53278 --Cost Management Default Account
53279 , p_source_11 IN NUMBER
53280 --DISTRIBUTION_IDENTIFIER
53281 , p_source_84 IN NUMBER
53282 --Distribution Type
53283 , p_source_85 IN VARCHAR2
53284 , p_source_85_meaning IN VARCHAR2
53285 --Entered Currency Code
53286 , p_source_88 IN VARCHAR2
53287 --Entered Amount
53288 , p_source_91 IN NUMBER
53289 --Currency Conversion Date
53290 , p_source_92 IN DATE
53291 --Currency Conversion Rate
53292 , p_source_93 IN NUMBER
53293 --Currency Conversion Type
53294 , p_source_94 IN VARCHAR2
53295 --Accounted Amount
53296 , p_source_95 IN NUMBER
53297 --Accounting Line Type
53298 , p_source_97 IN NUMBER
53299 )
53300 IS
53301
53302 l_component_type VARCHAR2(80);
53303 l_component_code VARCHAR2(30);
53304 l_component_type_code VARCHAR2(1);
53305 l_component_appl_id INTEGER;
53306 l_amb_context_code VARCHAR2(30);
53307 l_entity_code VARCHAR2(30);
53308 l_event_class_code VARCHAR2(30);
53309 l_ae_header_id NUMBER;
53310 l_event_type_code VARCHAR2(30);
53311 l_line_definition_code VARCHAR2(30);
53312 l_line_definition_owner_code VARCHAR2(1);
53313 --
53314 -- adr variables
53315 l_segment VARCHAR2(30);
53316 l_ccid NUMBER;
53317 l_adr_transaction_coa_id NUMBER;
53318 l_adr_accounting_coa_id NUMBER;
53319 l_adr_flexfield_segment_code VARCHAR2(30);
53320 l_adr_flex_value_set_id NUMBER;
53321 l_adr_value_type_code VARCHAR2(30);
53322 l_adr_value_combination_id NUMBER;
53323 l_adr_value_segment_code VARCHAR2(30);
53324
53325 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
53326 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
53327 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
53328 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
53329
53330 -- 4262811 Variables ------------------------------------------------------------------------------------------
53331 l_entered_amt_idx NUMBER;
53332 l_accted_amt_idx NUMBER;
53333 l_acc_rev_flag VARCHAR2(1);
53334 l_accrual_line_num NUMBER;
53335 l_tmp_amt NUMBER;
53336 l_acc_rev_natural_side_code VARCHAR2(1);
53337
53338 l_num_entries NUMBER;
53339 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
53340 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
53341 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
53342 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
53343 l_recog_line_1 NUMBER;
53344 l_recog_line_2 NUMBER;
53345
53346 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
53347 l_bflow_applied_to_amt NUMBER; -- 5132302
53348 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
53349
53350 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
53351
53352 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
53353 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
53354
53355 ---------------------------------------------------------------------------------------------------------------
53356
53357
53358 --
53359 -- bulk performance
53360 --
53361 l_balance_type_code VARCHAR2(1);
53362 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53363 l_log_module VARCHAR2(240);
53364
53365 --
53366 -- Upgrade strategy
53367 --
53368 l_actual_upg_option VARCHAR2(1);
53369 l_enc_upg_option VARCHAR2(1);
53370
53371 --
53372 BEGIN
53373 --
53374 IF g_log_enabled THEN
53375 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_119';
53376 END IF;
53377 --
53378 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53379
53380 trace
53381 (p_msg => 'BEGIN of AcctLineType_119'
53382 ,p_level => C_LEVEL_PROCEDURE
53383 ,p_module => l_log_module);
53384
53385 END IF;
53386 --
53387 l_component_type := 'AMB_JLT';
53388 l_component_code := 'DEFERRED_COGS';
53389 l_component_type_code := 'S';
53390 l_component_appl_id := 707;
53391 l_amb_context_code := 'DEFAULT';
53392 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
53393 l_event_class_code := 'SALES_ORDER';
53394 l_event_type_code := 'SO_ISSUE';
53395 l_line_definition_owner_code := 'S';
53396 l_line_definition_code := 'PI_SO_ISSUE';
53397 --
53398 l_balance_type_code := 'A';
53399 l_segment := NULL;
53400 l_ccid := NULL;
53401 l_adr_transaction_coa_id := NULL;
53402 l_adr_accounting_coa_id := NULL;
53403 l_adr_flexfield_segment_code := NULL;
53404 l_adr_flex_value_set_id := NULL;
53405 l_adr_value_type_code := NULL;
53406 l_adr_value_combination_id := NULL;
53407 l_adr_value_segment_code := NULL;
53408
53409 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
53410 l_bflow_class_code := ''; -- 4219869 Business Flow
53411 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
53412 l_budgetary_control_flag := 'N';
53413
53414 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53415 l_bflow_applied_to_amt := NULL; -- 5132302
53416 l_entered_amt_idx := NULL; -- 4262811
53417 l_accted_amt_idx := NULL; -- 4262811
53418 l_acc_rev_flag := NULL; -- 4262811
53419 l_accrual_line_num := NULL; -- 4262811
53420 l_tmp_amt := NULL; -- 4262811
53421 --
53422
53423 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
53424 l_balance_type_code <> 'B' THEN
53425 IF NVL(p_source_97,9E125) = 36
53426 THEN
53427
53428 --
53429 XLA_AE_LINES_PKG.SetNewLine;
53430
53431 p_balance_type_code := l_balance_type_code;
53432 -- set the flag so later we will know whether the gain loss line needs to be created
53433
53434 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
53435 p_actual_flag :='A';
53436 END IF;
53437
53438 --
53439 -- bulk performance
53440 --
53441 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
53442 p_header_num => 0); -- 4262811
53443 --
53444 -- set accounting line options
53445 --
53446 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
53447 p_natural_side_code => 'D'
53448 , p_gain_or_loss_flag => 'N'
53449 , p_gl_transfer_mode_code => 'S'
53450 , p_acct_entry_type_code => 'A'
53451 , p_switch_side_flag => 'Y'
53452 , p_merge_duplicate_code => 'N'
53453 );
53454 --
53455 l_acc_rev_natural_side_code := 'C'; -- 4262811
53456 --
53457 --
53458 -- set accounting line type info
53459 --
53460 xla_ae_lines_pkg.SetAcctLineType
53461 (p_component_type => l_component_type
53462 ,p_event_type_code => l_event_type_code
53463 ,p_line_definition_owner_code => l_line_definition_owner_code
53464 ,p_line_definition_code => l_line_definition_code
53465 ,p_accounting_line_code => l_component_code
53466 ,p_accounting_line_type_code => l_component_type_code
53467 ,p_accounting_line_appl_id => l_component_appl_id
53468 ,p_amb_context_code => l_amb_context_code
53469 ,p_entity_code => l_entity_code
53470 ,p_event_class_code => l_event_class_code);
53471 --
53472 -- set accounting class
53473 --
53474 xla_ae_lines_pkg.SetAcctClass(
53475 p_accounting_class_code => 'DEFERRED_COGS'
53476 , p_ae_header_id => l_ae_header_id
53477 );
53478
53479 --
53480 -- set rounding class
53481 --
53482 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
53483 'DEFERRED_COGS';
53484
53485 --
53486 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
53487 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
53488 --
53489 -- bulk performance
53490 --
53491 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
53492
53493 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
53494 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
53495
53496 -- 4955764
53497 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53498 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
53499
53500 -- 4458381 Public Sector Enh
53501
53502 --
53503 -- set accounting attributes for the line type
53504 --
53505 l_entered_amt_idx := 3;
53506 l_accted_amt_idx := 8;
53507 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53508 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
53509 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
53510 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
53511 l_rec_acct_attrs.array_char_value(2) := p_source_85;
53512 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
53513 l_rec_acct_attrs.array_num_value(3) := p_source_91;
53514 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
53515 l_rec_acct_attrs.array_char_value(4) := p_source_88;
53516 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
53517 l_rec_acct_attrs.array_date_value(5) := p_source_92;
53518 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
53519 l_rec_acct_attrs.array_num_value(6) := p_source_93;
53520 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
53521 l_rec_acct_attrs.array_char_value(7) := p_source_94;
53522 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
53523 l_rec_acct_attrs.array_num_value(8) := p_source_95;
53524
53525 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
53526 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
53527
53528 ---------------------------------------------------------------------------------------------------------------
53529 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
53530 ---------------------------------------------------------------------------------------------------------------
53531 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
53532
53533 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53534 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53535
53536 IF xla_accounting_cache_pkg.GetValueChar
53537 (p_source_code => 'LEDGER_CATEGORY_CODE'
53538 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
53539 AND l_bflow_method_code = 'PRIOR_ENTRY'
53540 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
53541 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
53542 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
53543 )
53544 THEN
53545 xla_ae_lines_pkg.BflowUpgEntry
53546 (p_business_method_code => l_bflow_method_code
53547 ,p_business_class_code => l_bflow_class_code
53548 ,p_balance_type => l_balance_type_code);
53549 ELSE
53550 NULL;
53551 -- No business flow processing for business flow method of NONE.
53552 END IF;
53553
53554 --
53555 -- call analytical criteria
53556 --
53557
53558 --
53559 -- call description
53560 --
53561
53562 xla_ae_lines_pkg.SetLineDescription(
53563 p_ae_header_id => l_ae_header_id
53564 ,p_description => Description_1 (
53565 p_application_id => p_application_id
53566 , p_ae_header_id => l_ae_header_id
53567 , p_source_1 => p_source_1
53568 , p_source_2 => p_source_2
53569 , p_source_3 => p_source_3
53570 , p_source_4 => p_source_4
53571 , p_source_5 => p_source_5
53572 )
53573 );
53574
53575
53576 --
53577 -- call ADRs
53578 -- Bug 4922099
53579 --
53580 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53581 (NVL(l_actual_upg_option, 'N') = 'O') OR
53582 (NVL(l_enc_upg_option, 'N') = 'O')
53583 )
53584 THEN
53585 NULL;
53586 --
53587 --
53588
53589 l_ccid := AcctDerRule_6(
53590 p_application_id => p_application_id
53591 , p_ae_header_id => l_ae_header_id
53592 , p_source_11 => p_source_11
53593 , x_transaction_coa_id => l_adr_transaction_coa_id
53594 , x_accounting_coa_id => l_adr_accounting_coa_id
53595 , x_value_type_code => l_adr_value_type_code
53596 , p_side => 'NA'
53597 );
53598
53599 xla_ae_lines_pkg.set_ccid(
53600 p_code_combination_id => l_ccid
53601 , p_value_type_code => l_adr_value_type_code
53602 , p_transaction_coa_id => l_adr_transaction_coa_id
53603 , p_accounting_coa_id => l_adr_accounting_coa_id
53604 , p_adr_code => 'CST_DEFAULT'
53605 , p_adr_type_code => 'S'
53606 , p_component_type => l_component_type
53607 , p_component_code => l_component_code
53608 , p_component_type_code => l_component_type_code
53609 , p_component_appl_id => l_component_appl_id
53610 , p_amb_context_code => l_amb_context_code
53611 , p_side => 'NA'
53612 );
53613
53614
53615 --
53616 --
53617 END IF;
53618 --
53619 -- Bug 4922099
53620 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
53621 (NVL(l_enc_upg_option, 'N') = 'O')
53622 ) AND
53623 (l_bflow_method_code = 'PRIOR_ENTRY')
53624 )
53625 THEN
53626 IF
53627 --
53628 1 = 2
53629 --
53630 THEN
53631 xla_accounting_err_pkg.build_message
53632 (p_appli_s_name => 'XLA'
53633 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53634 ,p_token_1 => 'LINE_NUMBER'
53635 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
53636 ,p_token_2 => 'LINE_TYPE_NAME'
53637 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
53638 l_component_type
53639 ,l_component_code
53640 ,l_component_type_code
53641 ,l_component_appl_id
53642 ,l_amb_context_code
53643 ,l_entity_code
53644 ,l_event_class_code
53645 )
53646 ,p_token_3 => 'OWNER'
53647 ,p_value_3 => xla_lookups_pkg.get_meaning(
53648 p_lookup_type => 'XLA_OWNER_TYPE'
53649 ,p_lookup_code => l_component_type_code
53650 )
53651 ,p_token_4 => 'PRODUCT_NAME'
53652 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
53653 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
53654 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
53655 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
53656 ,p_ae_header_id => NULL
53657 );
53658
53659 IF (C_LEVEL_ERROR>= g_log_level) THEN
53660 trace
53661 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53662 ,p_level => C_LEVEL_ERROR
53663 ,p_module => l_log_module);
53664 END IF;
53665 END IF;
53666 END IF;
53667 --
53668 --
53669 ------------------------------------------------------------------------------------------------
53670 -- 4219869 Business Flow
53671 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
53672 -- Prior Entry. Currently, the following code is always generated.
53673 ------------------------------------------------------------------------------------------------
53674 XLA_AE_LINES_PKG.ValidateCurrentLine;
53675
53676 ------------------------------------------------------------------------------------
53677 -- 4219869 Business Flow
53678 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
53679 ------------------------------------------------------------------------------------
53680 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53681
53682 ----------------------------------------------------------------------------------
53683 -- 4219869 Business Flow
53684 -- Update journal entry status -- Need to generate this within IF <condition>
53685 ----------------------------------------------------------------------------------
53686 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53687 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
53688 ,p_balance_type_code => l_balance_type_code
53689 );
53690
53691 -------------------------------------------------------------------------------------------
53692 -- 4262811 - Generate the Accrual Reversal lines
53693 -------------------------------------------------------------------------------------------
53694 BEGIN
53695 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
53696 (g_array_event(p_event_id).array_value_num('header_index'));
53697 IF l_acc_rev_flag IS NULL THEN
53698 l_acc_rev_flag := 'N';
53699 END IF;
53700 EXCEPTION
53701 WHEN OTHERS THEN
53702 l_acc_rev_flag := 'N';
53703 END;
53704 --
53705 IF (l_acc_rev_flag = 'Y') THEN
53706
53707 -- 4645092 ------------------------------------------------------------------------------
53708 -- To allow MPA report to determine if it should generate report process
53709 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
53710 ------------------------------------------------------------------------------------------
53711
53712 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
53713 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
53714 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
53715 -- call ADRs
53716 -- Bug 4922099
53717 --
53718 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53719 (NVL(l_actual_upg_option, 'N') = 'O') OR
53720 (NVL(l_enc_upg_option, 'N') = 'O')
53721 )
53722 THEN
53723 NULL;
53724 --
53725 --
53726
53727 l_ccid := AcctDerRule_6(
53728 p_application_id => p_application_id
53729 , p_ae_header_id => l_ae_header_id
53730 , p_source_11 => p_source_11
53731 , x_transaction_coa_id => l_adr_transaction_coa_id
53732 , x_accounting_coa_id => l_adr_accounting_coa_id
53733 , x_value_type_code => l_adr_value_type_code
53734 , p_side => 'NA'
53735 );
53736
53737 xla_ae_lines_pkg.set_ccid(
53738 p_code_combination_id => l_ccid
53739 , p_value_type_code => l_adr_value_type_code
53740 , p_transaction_coa_id => l_adr_transaction_coa_id
53741 , p_accounting_coa_id => l_adr_accounting_coa_id
53742 , p_adr_code => 'CST_DEFAULT'
53743 , p_adr_type_code => 'S'
53744 , p_component_type => l_component_type
53745 , p_component_code => l_component_code
53746 , p_component_type_code => l_component_type_code
53747 , p_component_appl_id => l_component_appl_id
53748 , p_amb_context_code => l_amb_context_code
53749 , p_side => 'NA'
53750 );
53751
53752
53753 --
53754 --
53755 END IF;
53756
53757 --
53758 -- Update the line information that should be overwritten
53759 --
53760 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53761 p_header_num => 1);
53762 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53763
53764 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53765
53766 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53767 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53768 END IF;
53769
53770 --
53771 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53772 --
53773 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53774 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53775 ELSE
53776 ---------------------------------------------------------------------------------------------------
53777 -- 4262811a Switch Sign
53778 ---------------------------------------------------------------------------------------------------
53779 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53780 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53781 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53782 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53783 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53784 -- 5132302
53785 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53786 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53787
53788 END IF;
53789
53790 -- 4955764
53791 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53792 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53793
53794
53795 XLA_AE_LINES_PKG.ValidateCurrentLine;
53796 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53797
53798 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53799 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53800 ,p_balance_type_code => l_balance_type_code);
53801
53802 END IF;
53803
53804 -----------------------------------------------------------------------------------------
53805 -- 4262811 Multiperiod Accounting
53806 -----------------------------------------------------------------------------------------
53807 -- No MPA option is assigned.
53808
53809
53810 END IF;
53811 END IF;
53812 --
53813
53814 --
53815 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53816 trace
53817 (p_msg => 'END of AcctLineType_119'
53818 ,p_level => C_LEVEL_PROCEDURE
53819 ,p_module => l_log_module);
53820 END IF;
53821 --
53822 EXCEPTION
53823 WHEN xla_exceptions_pkg.application_exception THEN
53824 RAISE;
53825 WHEN OTHERS THEN
53826 xla_exceptions_pkg.raise_message
53827 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_119');
53828 END AcctLineType_119;
53829 --
53830
53831 ---------------------------------------
53832 --
53833 -- PRIVATE FUNCTION
53834 -- AcctLineType_120
53835 --
53836 ---------------------------------------
53837 PROCEDURE AcctLineType_120 (
53838 p_application_id IN NUMBER
53839 ,p_event_id IN NUMBER
53840 ,p_calculate_acctd_flag IN VARCHAR2
53841 ,p_calculate_g_l_flag IN VARCHAR2
53842 ,p_actual_flag IN OUT VARCHAR2
53843 ,p_balance_type_code OUT VARCHAR2
53844 ,p_gain_or_loss_ref OUT VARCHAR2
53845
53846 --TRANSACTION_ID
53847 , p_source_1 IN NUMBER
53848 --Item Concatenated Segments
53849 , p_source_2 IN VARCHAR2
53850 --Transaction Quantity
53851 , p_source_3 IN NUMBER
53852 --Transaction Unit of Measure Code
53853 , p_source_4 IN VARCHAR2
53854 --Inventory Transaction Type Description
53855 , p_source_5 IN VARCHAR2
53856 --Cost Management Default Account
53857 , p_source_11 IN NUMBER
53858 --DISTRIBUTION_IDENTIFIER
53859 , p_source_84 IN NUMBER
53860 --Distribution Type
53861 , p_source_85 IN VARCHAR2
53862 , p_source_85_meaning IN VARCHAR2
53863 --Entered Currency Code
53864 , p_source_88 IN VARCHAR2
53865 --Entered Amount
53866 , p_source_91 IN NUMBER
53867 --Currency Conversion Date
53868 , p_source_92 IN DATE
53869 --Currency Conversion Rate
53870 , p_source_93 IN NUMBER
53871 --Currency Conversion Type
53872 , p_source_94 IN VARCHAR2
53873 --Accounted Amount
53874 , p_source_95 IN NUMBER
53875 --Accounting Line Type
53876 , p_source_97 IN NUMBER
53877 )
53878 IS
53879
53880 l_component_type VARCHAR2(80);
53881 l_component_code VARCHAR2(30);
53882 l_component_type_code VARCHAR2(1);
53883 l_component_appl_id INTEGER;
53884 l_amb_context_code VARCHAR2(30);
53885 l_entity_code VARCHAR2(30);
53886 l_event_class_code VARCHAR2(30);
53887 l_ae_header_id NUMBER;
53888 l_event_type_code VARCHAR2(30);
53889 l_line_definition_code VARCHAR2(30);
53890 l_line_definition_owner_code VARCHAR2(1);
53891 --
53892 -- adr variables
53893 l_segment VARCHAR2(30);
53894 l_ccid NUMBER;
53895 l_adr_transaction_coa_id NUMBER;
53896 l_adr_accounting_coa_id NUMBER;
53897 l_adr_flexfield_segment_code VARCHAR2(30);
53898 l_adr_flex_value_set_id NUMBER;
53899 l_adr_value_type_code VARCHAR2(30);
53900 l_adr_value_combination_id NUMBER;
53901 l_adr_value_segment_code VARCHAR2(30);
53902
53903 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
53904 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
53905 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
53906 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
53907
53908 -- 4262811 Variables ------------------------------------------------------------------------------------------
53909 l_entered_amt_idx NUMBER;
53910 l_accted_amt_idx NUMBER;
53911 l_acc_rev_flag VARCHAR2(1);
53912 l_accrual_line_num NUMBER;
53913 l_tmp_amt NUMBER;
53914 l_acc_rev_natural_side_code VARCHAR2(1);
53915
53916 l_num_entries NUMBER;
53917 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
53918 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
53919 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
53920 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
53921 l_recog_line_1 NUMBER;
53922 l_recog_line_2 NUMBER;
53923
53924 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
53925 l_bflow_applied_to_amt NUMBER; -- 5132302
53926 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
53927
53928 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
53929
53930 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
53931 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
53932
53933 ---------------------------------------------------------------------------------------------------------------
53934
53935
53936 --
53937 -- bulk performance
53938 --
53939 l_balance_type_code VARCHAR2(1);
53940 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53941 l_log_module VARCHAR2(240);
53942
53943 --
53944 -- Upgrade strategy
53945 --
53946 l_actual_upg_option VARCHAR2(1);
53947 l_enc_upg_option VARCHAR2(1);
53948
53949 --
53950 BEGIN
53951 --
53952 IF g_log_enabled THEN
53953 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_120';
53954 END IF;
53955 --
53956 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53957
53958 trace
53959 (p_msg => 'BEGIN of AcctLineType_120'
53960 ,p_level => C_LEVEL_PROCEDURE
53961 ,p_module => l_log_module);
53962
53963 END IF;
53964 --
53965 l_component_type := 'AMB_JLT';
53966 l_component_code := 'DEFERRED_COGS';
53967 l_component_type_code := 'S';
53968 l_component_appl_id := 707;
53969 l_amb_context_code := 'DEFAULT';
53970 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
53971 l_event_class_code := 'SALES_ORDER';
53972 l_event_type_code := 'RMA_RCPT';
53973 l_line_definition_owner_code := 'S';
53974 l_line_definition_code := 'PI_RMA_RCPT';
53975 --
53976 l_balance_type_code := 'A';
53977 l_segment := NULL;
53978 l_ccid := NULL;
53979 l_adr_transaction_coa_id := NULL;
53980 l_adr_accounting_coa_id := NULL;
53981 l_adr_flexfield_segment_code := NULL;
53982 l_adr_flex_value_set_id := NULL;
53983 l_adr_value_type_code := NULL;
53984 l_adr_value_combination_id := NULL;
53985 l_adr_value_segment_code := NULL;
53986
53987 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
53988 l_bflow_class_code := ''; -- 4219869 Business Flow
53989 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
53990 l_budgetary_control_flag := 'N';
53991
53992 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53993 l_bflow_applied_to_amt := NULL; -- 5132302
53994 l_entered_amt_idx := NULL; -- 4262811
53995 l_accted_amt_idx := NULL; -- 4262811
53996 l_acc_rev_flag := NULL; -- 4262811
53997 l_accrual_line_num := NULL; -- 4262811
53998 l_tmp_amt := NULL; -- 4262811
53999 --
54000
54001 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
54002 l_balance_type_code <> 'B' THEN
54003 IF NVL(p_source_97,9E125) = 36
54004 THEN
54005
54006 --
54007 XLA_AE_LINES_PKG.SetNewLine;
54008
54009 p_balance_type_code := l_balance_type_code;
54010 -- set the flag so later we will know whether the gain loss line needs to be created
54011
54012 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
54013 p_actual_flag :='A';
54014 END IF;
54015
54016 --
54017 -- bulk performance
54018 --
54019 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
54020 p_header_num => 0); -- 4262811
54021 --
54022 -- set accounting line options
54023 --
54024 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
54025 p_natural_side_code => 'D'
54026 , p_gain_or_loss_flag => 'N'
54027 , p_gl_transfer_mode_code => 'S'
54028 , p_acct_entry_type_code => 'A'
54029 , p_switch_side_flag => 'Y'
54030 , p_merge_duplicate_code => 'N'
54031 );
54032 --
54033 l_acc_rev_natural_side_code := 'C'; -- 4262811
54034 --
54035 --
54036 -- set accounting line type info
54037 --
54038 xla_ae_lines_pkg.SetAcctLineType
54039 (p_component_type => l_component_type
54040 ,p_event_type_code => l_event_type_code
54041 ,p_line_definition_owner_code => l_line_definition_owner_code
54042 ,p_line_definition_code => l_line_definition_code
54043 ,p_accounting_line_code => l_component_code
54044 ,p_accounting_line_type_code => l_component_type_code
54045 ,p_accounting_line_appl_id => l_component_appl_id
54046 ,p_amb_context_code => l_amb_context_code
54047 ,p_entity_code => l_entity_code
54048 ,p_event_class_code => l_event_class_code);
54049 --
54050 -- set accounting class
54051 --
54052 xla_ae_lines_pkg.SetAcctClass(
54053 p_accounting_class_code => 'DEFERRED_COGS'
54054 , p_ae_header_id => l_ae_header_id
54055 );
54056
54057 --
54058 -- set rounding class
54059 --
54060 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
54061 'DEFERRED_COGS';
54062
54063 --
54064 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
54065 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
54066 --
54067 -- bulk performance
54068 --
54069 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
54070
54071 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
54072 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
54073
54074 -- 4955764
54075 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54076 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
54077
54078 -- 4458381 Public Sector Enh
54079
54080 --
54081 -- set accounting attributes for the line type
54082 --
54083 l_entered_amt_idx := 3;
54084 l_accted_amt_idx := 8;
54085 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54086 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
54087 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
54088 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
54089 l_rec_acct_attrs.array_char_value(2) := p_source_85;
54090 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
54091 l_rec_acct_attrs.array_num_value(3) := p_source_91;
54092 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
54093 l_rec_acct_attrs.array_char_value(4) := p_source_88;
54094 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
54095 l_rec_acct_attrs.array_date_value(5) := p_source_92;
54096 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
54097 l_rec_acct_attrs.array_num_value(6) := p_source_93;
54098 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
54099 l_rec_acct_attrs.array_char_value(7) := p_source_94;
54100 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
54101 l_rec_acct_attrs.array_num_value(8) := p_source_95;
54102
54103 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
54104 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
54105
54106 ---------------------------------------------------------------------------------------------------------------
54107 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
54108 ---------------------------------------------------------------------------------------------------------------
54109 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
54110
54111 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54112 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54113
54114 IF xla_accounting_cache_pkg.GetValueChar
54115 (p_source_code => 'LEDGER_CATEGORY_CODE'
54116 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
54117 AND l_bflow_method_code = 'PRIOR_ENTRY'
54118 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
54119 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
54120 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
54121 )
54122 THEN
54123 xla_ae_lines_pkg.BflowUpgEntry
54124 (p_business_method_code => l_bflow_method_code
54125 ,p_business_class_code => l_bflow_class_code
54126 ,p_balance_type => l_balance_type_code);
54127 ELSE
54128 NULL;
54129 -- No business flow processing for business flow method of NONE.
54130 END IF;
54131
54132 --
54133 -- call analytical criteria
54134 --
54135
54136 --
54137 -- call description
54138 --
54139
54140 xla_ae_lines_pkg.SetLineDescription(
54141 p_ae_header_id => l_ae_header_id
54142 ,p_description => Description_1 (
54143 p_application_id => p_application_id
54144 , p_ae_header_id => l_ae_header_id
54145 , p_source_1 => p_source_1
54146 , p_source_2 => p_source_2
54147 , p_source_3 => p_source_3
54148 , p_source_4 => p_source_4
54149 , p_source_5 => p_source_5
54150 )
54151 );
54152
54153
54154 --
54155 -- call ADRs
54156 -- Bug 4922099
54157 --
54158 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54159 (NVL(l_actual_upg_option, 'N') = 'O') OR
54160 (NVL(l_enc_upg_option, 'N') = 'O')
54161 )
54162 THEN
54163 NULL;
54164 --
54165 --
54166
54167 l_ccid := AcctDerRule_6(
54168 p_application_id => p_application_id
54169 , p_ae_header_id => l_ae_header_id
54170 , p_source_11 => p_source_11
54171 , x_transaction_coa_id => l_adr_transaction_coa_id
54172 , x_accounting_coa_id => l_adr_accounting_coa_id
54173 , x_value_type_code => l_adr_value_type_code
54174 , p_side => 'NA'
54175 );
54176
54177 xla_ae_lines_pkg.set_ccid(
54178 p_code_combination_id => l_ccid
54179 , p_value_type_code => l_adr_value_type_code
54180 , p_transaction_coa_id => l_adr_transaction_coa_id
54181 , p_accounting_coa_id => l_adr_accounting_coa_id
54182 , p_adr_code => 'CST_DEFAULT'
54183 , p_adr_type_code => 'S'
54184 , p_component_type => l_component_type
54185 , p_component_code => l_component_code
54186 , p_component_type_code => l_component_type_code
54187 , p_component_appl_id => l_component_appl_id
54188 , p_amb_context_code => l_amb_context_code
54189 , p_side => 'NA'
54190 );
54191
54192
54193 --
54194 --
54195 END IF;
54196 --
54197 -- Bug 4922099
54198 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54199 (NVL(l_enc_upg_option, 'N') = 'O')
54200 ) AND
54201 (l_bflow_method_code = 'PRIOR_ENTRY')
54202 )
54203 THEN
54204 IF
54205 --
54206 1 = 2
54207 --
54208 THEN
54209 xla_accounting_err_pkg.build_message
54210 (p_appli_s_name => 'XLA'
54211 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54212 ,p_token_1 => 'LINE_NUMBER'
54213 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54214 ,p_token_2 => 'LINE_TYPE_NAME'
54215 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54216 l_component_type
54217 ,l_component_code
54218 ,l_component_type_code
54219 ,l_component_appl_id
54220 ,l_amb_context_code
54221 ,l_entity_code
54222 ,l_event_class_code
54223 )
54224 ,p_token_3 => 'OWNER'
54225 ,p_value_3 => xla_lookups_pkg.get_meaning(
54226 p_lookup_type => 'XLA_OWNER_TYPE'
54227 ,p_lookup_code => l_component_type_code
54228 )
54229 ,p_token_4 => 'PRODUCT_NAME'
54230 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54231 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54232 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54233 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54234 ,p_ae_header_id => NULL
54235 );
54236
54237 IF (C_LEVEL_ERROR>= g_log_level) THEN
54238 trace
54239 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54240 ,p_level => C_LEVEL_ERROR
54241 ,p_module => l_log_module);
54242 END IF;
54243 END IF;
54244 END IF;
54245 --
54246 --
54247 ------------------------------------------------------------------------------------------------
54248 -- 4219869 Business Flow
54249 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
54250 -- Prior Entry. Currently, the following code is always generated.
54251 ------------------------------------------------------------------------------------------------
54252 XLA_AE_LINES_PKG.ValidateCurrentLine;
54253
54254 ------------------------------------------------------------------------------------
54255 -- 4219869 Business Flow
54256 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
54257 ------------------------------------------------------------------------------------
54258 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54259
54260 ----------------------------------------------------------------------------------
54261 -- 4219869 Business Flow
54262 -- Update journal entry status -- Need to generate this within IF <condition>
54263 ----------------------------------------------------------------------------------
54264 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54265 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
54266 ,p_balance_type_code => l_balance_type_code
54267 );
54268
54269 -------------------------------------------------------------------------------------------
54270 -- 4262811 - Generate the Accrual Reversal lines
54271 -------------------------------------------------------------------------------------------
54272 BEGIN
54273 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
54274 (g_array_event(p_event_id).array_value_num('header_index'));
54275 IF l_acc_rev_flag IS NULL THEN
54276 l_acc_rev_flag := 'N';
54277 END IF;
54278 EXCEPTION
54279 WHEN OTHERS THEN
54280 l_acc_rev_flag := 'N';
54281 END;
54282 --
54283 IF (l_acc_rev_flag = 'Y') THEN
54284
54285 -- 4645092 ------------------------------------------------------------------------------
54286 -- To allow MPA report to determine if it should generate report process
54287 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
54288 ------------------------------------------------------------------------------------------
54289
54290 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
54291 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
54292 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
54293 -- call ADRs
54294 -- Bug 4922099
54295 --
54296 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54297 (NVL(l_actual_upg_option, 'N') = 'O') OR
54298 (NVL(l_enc_upg_option, 'N') = 'O')
54299 )
54300 THEN
54301 NULL;
54302 --
54303 --
54304
54305 l_ccid := AcctDerRule_6(
54306 p_application_id => p_application_id
54307 , p_ae_header_id => l_ae_header_id
54308 , p_source_11 => p_source_11
54309 , x_transaction_coa_id => l_adr_transaction_coa_id
54310 , x_accounting_coa_id => l_adr_accounting_coa_id
54311 , x_value_type_code => l_adr_value_type_code
54312 , p_side => 'NA'
54313 );
54314
54315 xla_ae_lines_pkg.set_ccid(
54316 p_code_combination_id => l_ccid
54317 , p_value_type_code => l_adr_value_type_code
54318 , p_transaction_coa_id => l_adr_transaction_coa_id
54319 , p_accounting_coa_id => l_adr_accounting_coa_id
54320 , p_adr_code => 'CST_DEFAULT'
54321 , p_adr_type_code => 'S'
54322 , p_component_type => l_component_type
54323 , p_component_code => l_component_code
54324 , p_component_type_code => l_component_type_code
54325 , p_component_appl_id => l_component_appl_id
54326 , p_amb_context_code => l_amb_context_code
54327 , p_side => 'NA'
54328 );
54329
54330
54331 --
54332 --
54333 END IF;
54334
54335 --
54336 -- Update the line information that should be overwritten
54337 --
54338 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
54339 p_header_num => 1);
54340 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
54341
54342 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
54343
54344 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
54345 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
54346 END IF;
54347
54348 --
54349 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
54350 --
54351 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
54352 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
54353 ELSE
54354 ---------------------------------------------------------------------------------------------------
54355 -- 4262811a Switch Sign
54356 ---------------------------------------------------------------------------------------------------
54357 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
54358 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54359 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54360 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54361 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54362 -- 5132302
54363 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
54364 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54365
54366 END IF;
54367
54368 -- 4955764
54369 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54370 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
54371
54372
54373 XLA_AE_LINES_PKG.ValidateCurrentLine;
54374 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54375
54376 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54377 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
54378 ,p_balance_type_code => l_balance_type_code);
54379
54380 END IF;
54381
54382 -----------------------------------------------------------------------------------------
54383 -- 4262811 Multiperiod Accounting
54384 -----------------------------------------------------------------------------------------
54385 -- No MPA option is assigned.
54386
54387
54388 END IF;
54389 END IF;
54390 --
54391
54392 --
54393 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54394 trace
54395 (p_msg => 'END of AcctLineType_120'
54396 ,p_level => C_LEVEL_PROCEDURE
54397 ,p_module => l_log_module);
54398 END IF;
54399 --
54400 EXCEPTION
54401 WHEN xla_exceptions_pkg.application_exception THEN
54402 RAISE;
54403 WHEN OTHERS THEN
54404 xla_exceptions_pkg.raise_message
54405 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_120');
54406 END AcctLineType_120;
54407 --
54408
54409 ---------------------------------------
54410 --
54411 -- PRIVATE FUNCTION
54412 -- AcctLineType_121
54413 --
54414 ---------------------------------------
54415 PROCEDURE AcctLineType_121 (
54416 p_application_id IN NUMBER
54417 ,p_event_id IN NUMBER
54418 ,p_calculate_acctd_flag IN VARCHAR2
54419 ,p_calculate_g_l_flag IN VARCHAR2
54420 ,p_actual_flag IN OUT VARCHAR2
54421 ,p_balance_type_code OUT VARCHAR2
54422 ,p_gain_or_loss_ref OUT VARCHAR2
54423
54424 --TRANSACTION_ID
54425 , p_source_1 IN NUMBER
54426 --Item Concatenated Segments
54427 , p_source_2 IN VARCHAR2
54428 --Transaction Quantity
54429 , p_source_3 IN NUMBER
54430 --Transaction Unit of Measure Code
54431 , p_source_4 IN VARCHAR2
54432 --Inventory Transaction Type Description
54433 , p_source_5 IN VARCHAR2
54434 --Cost Management Default Account
54435 , p_source_11 IN NUMBER
54436 --DISTRIBUTION_IDENTIFIER
54437 , p_source_84 IN NUMBER
54438 --Distribution Type
54439 , p_source_85 IN VARCHAR2
54440 , p_source_85_meaning IN VARCHAR2
54441 --Entered Currency Code
54442 , p_source_88 IN VARCHAR2
54443 --Entered Amount
54444 , p_source_91 IN NUMBER
54445 --Currency Conversion Date
54446 , p_source_92 IN DATE
54447 --Currency Conversion Rate
54448 , p_source_93 IN NUMBER
54449 --Currency Conversion Type
54450 , p_source_94 IN VARCHAR2
54451 --Accounted Amount
54452 , p_source_95 IN NUMBER
54453 --Accounting Line Type
54454 , p_source_97 IN NUMBER
54455 )
54456 IS
54457
54458 l_component_type VARCHAR2(80);
54459 l_component_code VARCHAR2(30);
54460 l_component_type_code VARCHAR2(1);
54461 l_component_appl_id INTEGER;
54462 l_amb_context_code VARCHAR2(30);
54463 l_entity_code VARCHAR2(30);
54464 l_event_class_code VARCHAR2(30);
54465 l_ae_header_id NUMBER;
54466 l_event_type_code VARCHAR2(30);
54467 l_line_definition_code VARCHAR2(30);
54468 l_line_definition_owner_code VARCHAR2(1);
54469 --
54470 -- adr variables
54471 l_segment VARCHAR2(30);
54472 l_ccid NUMBER;
54473 l_adr_transaction_coa_id NUMBER;
54474 l_adr_accounting_coa_id NUMBER;
54475 l_adr_flexfield_segment_code VARCHAR2(30);
54476 l_adr_flex_value_set_id NUMBER;
54477 l_adr_value_type_code VARCHAR2(30);
54478 l_adr_value_combination_id NUMBER;
54479 l_adr_value_segment_code VARCHAR2(30);
54480
54481 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
54482 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
54483 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
54484 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
54485
54486 -- 4262811 Variables ------------------------------------------------------------------------------------------
54487 l_entered_amt_idx NUMBER;
54488 l_accted_amt_idx NUMBER;
54489 l_acc_rev_flag VARCHAR2(1);
54490 l_accrual_line_num NUMBER;
54491 l_tmp_amt NUMBER;
54492 l_acc_rev_natural_side_code VARCHAR2(1);
54493
54494 l_num_entries NUMBER;
54495 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
54496 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
54497 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
54498 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
54499 l_recog_line_1 NUMBER;
54500 l_recog_line_2 NUMBER;
54501
54502 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
54503 l_bflow_applied_to_amt NUMBER; -- 5132302
54504 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
54505
54506 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
54507
54508 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
54509 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
54510
54511 ---------------------------------------------------------------------------------------------------------------
54512
54513
54514 --
54515 -- bulk performance
54516 --
54517 l_balance_type_code VARCHAR2(1);
54518 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54519 l_log_module VARCHAR2(240);
54520
54521 --
54522 -- Upgrade strategy
54523 --
54524 l_actual_upg_option VARCHAR2(1);
54525 l_enc_upg_option VARCHAR2(1);
54526
54527 --
54528 BEGIN
54529 --
54530 IF g_log_enabled THEN
54531 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_121';
54532 END IF;
54533 --
54534 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54535
54536 trace
54537 (p_msg => 'BEGIN of AcctLineType_121'
54538 ,p_level => C_LEVEL_PROCEDURE
54539 ,p_module => l_log_module);
54540
54541 END IF;
54542 --
54543 l_component_type := 'AMB_JLT';
54544 l_component_code := 'DEFERRED_COGS';
54545 l_component_type_code := 'S';
54546 l_component_appl_id := 707;
54547 l_amb_context_code := 'DEFAULT';
54548 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
54549 l_event_class_code := 'SALES_ORDER';
54550 l_event_type_code := 'RMA_RETURN';
54551 l_line_definition_owner_code := 'S';
54552 l_line_definition_code := 'PI_RMA_RETURN';
54553 --
54554 l_balance_type_code := 'A';
54555 l_segment := NULL;
54556 l_ccid := NULL;
54557 l_adr_transaction_coa_id := NULL;
54558 l_adr_accounting_coa_id := NULL;
54559 l_adr_flexfield_segment_code := NULL;
54560 l_adr_flex_value_set_id := NULL;
54561 l_adr_value_type_code := NULL;
54562 l_adr_value_combination_id := NULL;
54563 l_adr_value_segment_code := NULL;
54564
54565 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
54566 l_bflow_class_code := ''; -- 4219869 Business Flow
54567 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
54568 l_budgetary_control_flag := 'N';
54569
54570 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54571 l_bflow_applied_to_amt := NULL; -- 5132302
54572 l_entered_amt_idx := NULL; -- 4262811
54573 l_accted_amt_idx := NULL; -- 4262811
54574 l_acc_rev_flag := NULL; -- 4262811
54575 l_accrual_line_num := NULL; -- 4262811
54576 l_tmp_amt := NULL; -- 4262811
54577 --
54578
54579 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
54580 l_balance_type_code <> 'B' THEN
54581 IF NVL(p_source_97,9E125) = 36
54582 THEN
54583
54584 --
54585 XLA_AE_LINES_PKG.SetNewLine;
54586
54587 p_balance_type_code := l_balance_type_code;
54588 -- set the flag so later we will know whether the gain loss line needs to be created
54589
54590 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
54591 p_actual_flag :='A';
54592 END IF;
54593
54594 --
54595 -- bulk performance
54596 --
54597 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
54598 p_header_num => 0); -- 4262811
54599 --
54600 -- set accounting line options
54601 --
54602 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
54603 p_natural_side_code => 'D'
54604 , p_gain_or_loss_flag => 'N'
54605 , p_gl_transfer_mode_code => 'S'
54606 , p_acct_entry_type_code => 'A'
54607 , p_switch_side_flag => 'Y'
54608 , p_merge_duplicate_code => 'N'
54609 );
54610 --
54611 l_acc_rev_natural_side_code := 'C'; -- 4262811
54612 --
54613 --
54614 -- set accounting line type info
54615 --
54616 xla_ae_lines_pkg.SetAcctLineType
54617 (p_component_type => l_component_type
54618 ,p_event_type_code => l_event_type_code
54619 ,p_line_definition_owner_code => l_line_definition_owner_code
54620 ,p_line_definition_code => l_line_definition_code
54621 ,p_accounting_line_code => l_component_code
54622 ,p_accounting_line_type_code => l_component_type_code
54623 ,p_accounting_line_appl_id => l_component_appl_id
54624 ,p_amb_context_code => l_amb_context_code
54625 ,p_entity_code => l_entity_code
54626 ,p_event_class_code => l_event_class_code);
54627 --
54628 -- set accounting class
54629 --
54630 xla_ae_lines_pkg.SetAcctClass(
54631 p_accounting_class_code => 'DEFERRED_COGS'
54632 , p_ae_header_id => l_ae_header_id
54633 );
54634
54635 --
54636 -- set rounding class
54637 --
54638 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
54639 'DEFERRED_COGS';
54640
54641 --
54642 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
54643 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
54644 --
54645 -- bulk performance
54646 --
54647 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
54648
54649 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
54650 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
54651
54652 -- 4955764
54653 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54654 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
54655
54656 -- 4458381 Public Sector Enh
54657
54658 --
54659 -- set accounting attributes for the line type
54660 --
54661 l_entered_amt_idx := 3;
54662 l_accted_amt_idx := 8;
54663 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54664 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
54665 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
54666 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
54667 l_rec_acct_attrs.array_char_value(2) := p_source_85;
54668 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
54669 l_rec_acct_attrs.array_num_value(3) := p_source_91;
54670 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
54671 l_rec_acct_attrs.array_char_value(4) := p_source_88;
54672 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
54673 l_rec_acct_attrs.array_date_value(5) := p_source_92;
54674 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
54675 l_rec_acct_attrs.array_num_value(6) := p_source_93;
54676 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
54677 l_rec_acct_attrs.array_char_value(7) := p_source_94;
54678 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
54679 l_rec_acct_attrs.array_num_value(8) := p_source_95;
54680
54681 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
54682 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
54683
54684 ---------------------------------------------------------------------------------------------------------------
54685 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
54686 ---------------------------------------------------------------------------------------------------------------
54687 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
54688
54689 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54690 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54691
54692 IF xla_accounting_cache_pkg.GetValueChar
54693 (p_source_code => 'LEDGER_CATEGORY_CODE'
54694 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
54695 AND l_bflow_method_code = 'PRIOR_ENTRY'
54696 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
54697 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
54698 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
54699 )
54700 THEN
54701 xla_ae_lines_pkg.BflowUpgEntry
54702 (p_business_method_code => l_bflow_method_code
54703 ,p_business_class_code => l_bflow_class_code
54704 ,p_balance_type => l_balance_type_code);
54705 ELSE
54706 NULL;
54707 -- No business flow processing for business flow method of NONE.
54708 END IF;
54709
54710 --
54711 -- call analytical criteria
54712 --
54713
54714 --
54715 -- call description
54716 --
54717
54718 xla_ae_lines_pkg.SetLineDescription(
54719 p_ae_header_id => l_ae_header_id
54720 ,p_description => Description_1 (
54721 p_application_id => p_application_id
54722 , p_ae_header_id => l_ae_header_id
54723 , p_source_1 => p_source_1
54724 , p_source_2 => p_source_2
54725 , p_source_3 => p_source_3
54726 , p_source_4 => p_source_4
54727 , p_source_5 => p_source_5
54728 )
54729 );
54730
54731
54732 --
54733 -- call ADRs
54734 -- Bug 4922099
54735 --
54736 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54737 (NVL(l_actual_upg_option, 'N') = 'O') OR
54738 (NVL(l_enc_upg_option, 'N') = 'O')
54739 )
54740 THEN
54741 NULL;
54742 --
54743 --
54744
54745 l_ccid := AcctDerRule_6(
54746 p_application_id => p_application_id
54747 , p_ae_header_id => l_ae_header_id
54748 , p_source_11 => p_source_11
54749 , x_transaction_coa_id => l_adr_transaction_coa_id
54750 , x_accounting_coa_id => l_adr_accounting_coa_id
54751 , x_value_type_code => l_adr_value_type_code
54752 , p_side => 'NA'
54753 );
54754
54755 xla_ae_lines_pkg.set_ccid(
54756 p_code_combination_id => l_ccid
54757 , p_value_type_code => l_adr_value_type_code
54758 , p_transaction_coa_id => l_adr_transaction_coa_id
54759 , p_accounting_coa_id => l_adr_accounting_coa_id
54760 , p_adr_code => 'CST_DEFAULT'
54761 , p_adr_type_code => 'S'
54762 , p_component_type => l_component_type
54763 , p_component_code => l_component_code
54764 , p_component_type_code => l_component_type_code
54765 , p_component_appl_id => l_component_appl_id
54766 , p_amb_context_code => l_amb_context_code
54767 , p_side => 'NA'
54768 );
54769
54770
54771 --
54772 --
54773 END IF;
54774 --
54775 -- Bug 4922099
54776 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54777 (NVL(l_enc_upg_option, 'N') = 'O')
54778 ) AND
54779 (l_bflow_method_code = 'PRIOR_ENTRY')
54780 )
54781 THEN
54782 IF
54783 --
54784 1 = 2
54785 --
54786 THEN
54787 xla_accounting_err_pkg.build_message
54788 (p_appli_s_name => 'XLA'
54789 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54790 ,p_token_1 => 'LINE_NUMBER'
54791 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54792 ,p_token_2 => 'LINE_TYPE_NAME'
54793 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54794 l_component_type
54795 ,l_component_code
54796 ,l_component_type_code
54797 ,l_component_appl_id
54798 ,l_amb_context_code
54799 ,l_entity_code
54800 ,l_event_class_code
54801 )
54802 ,p_token_3 => 'OWNER'
54803 ,p_value_3 => xla_lookups_pkg.get_meaning(
54804 p_lookup_type => 'XLA_OWNER_TYPE'
54805 ,p_lookup_code => l_component_type_code
54806 )
54807 ,p_token_4 => 'PRODUCT_NAME'
54808 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54809 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54810 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54811 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54812 ,p_ae_header_id => NULL
54813 );
54814
54815 IF (C_LEVEL_ERROR>= g_log_level) THEN
54816 trace
54817 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54818 ,p_level => C_LEVEL_ERROR
54819 ,p_module => l_log_module);
54820 END IF;
54821 END IF;
54822 END IF;
54823 --
54824 --
54825 ------------------------------------------------------------------------------------------------
54826 -- 4219869 Business Flow
54827 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
54828 -- Prior Entry. Currently, the following code is always generated.
54829 ------------------------------------------------------------------------------------------------
54830 XLA_AE_LINES_PKG.ValidateCurrentLine;
54831
54832 ------------------------------------------------------------------------------------
54833 -- 4219869 Business Flow
54834 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
54835 ------------------------------------------------------------------------------------
54836 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54837
54838 ----------------------------------------------------------------------------------
54839 -- 4219869 Business Flow
54840 -- Update journal entry status -- Need to generate this within IF <condition>
54841 ----------------------------------------------------------------------------------
54842 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54843 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
54844 ,p_balance_type_code => l_balance_type_code
54845 );
54846
54847 -------------------------------------------------------------------------------------------
54848 -- 4262811 - Generate the Accrual Reversal lines
54849 -------------------------------------------------------------------------------------------
54850 BEGIN
54851 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
54852 (g_array_event(p_event_id).array_value_num('header_index'));
54853 IF l_acc_rev_flag IS NULL THEN
54854 l_acc_rev_flag := 'N';
54855 END IF;
54856 EXCEPTION
54857 WHEN OTHERS THEN
54858 l_acc_rev_flag := 'N';
54859 END;
54860 --
54861 IF (l_acc_rev_flag = 'Y') THEN
54862
54863 -- 4645092 ------------------------------------------------------------------------------
54864 -- To allow MPA report to determine if it should generate report process
54865 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
54866 ------------------------------------------------------------------------------------------
54867
54868 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
54869 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
54870 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
54871 -- call ADRs
54872 -- Bug 4922099
54873 --
54874 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54875 (NVL(l_actual_upg_option, 'N') = 'O') OR
54876 (NVL(l_enc_upg_option, 'N') = 'O')
54877 )
54878 THEN
54879 NULL;
54880 --
54881 --
54882
54883 l_ccid := AcctDerRule_6(
54884 p_application_id => p_application_id
54885 , p_ae_header_id => l_ae_header_id
54886 , p_source_11 => p_source_11
54887 , x_transaction_coa_id => l_adr_transaction_coa_id
54888 , x_accounting_coa_id => l_adr_accounting_coa_id
54889 , x_value_type_code => l_adr_value_type_code
54890 , p_side => 'NA'
54891 );
54892
54893 xla_ae_lines_pkg.set_ccid(
54894 p_code_combination_id => l_ccid
54895 , p_value_type_code => l_adr_value_type_code
54896 , p_transaction_coa_id => l_adr_transaction_coa_id
54897 , p_accounting_coa_id => l_adr_accounting_coa_id
54898 , p_adr_code => 'CST_DEFAULT'
54899 , p_adr_type_code => 'S'
54900 , p_component_type => l_component_type
54901 , p_component_code => l_component_code
54902 , p_component_type_code => l_component_type_code
54903 , p_component_appl_id => l_component_appl_id
54904 , p_amb_context_code => l_amb_context_code
54905 , p_side => 'NA'
54906 );
54907
54908
54909 --
54910 --
54911 END IF;
54912
54913 --
54914 -- Update the line information that should be overwritten
54915 --
54916 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
54917 p_header_num => 1);
54918 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
54919
54920 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
54921
54922 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
54923 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
54924 END IF;
54925
54926 --
54927 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
54928 --
54929 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
54930 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
54931 ELSE
54932 ---------------------------------------------------------------------------------------------------
54933 -- 4262811a Switch Sign
54934 ---------------------------------------------------------------------------------------------------
54935 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
54936 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54937 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54938 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54939 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54940 -- 5132302
54941 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
54942 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54943
54944 END IF;
54945
54946 -- 4955764
54947 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54948 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
54949
54950
54951 XLA_AE_LINES_PKG.ValidateCurrentLine;
54952 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54953
54954 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54955 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
54956 ,p_balance_type_code => l_balance_type_code);
54957
54958 END IF;
54959
54960 -----------------------------------------------------------------------------------------
54961 -- 4262811 Multiperiod Accounting
54962 -----------------------------------------------------------------------------------------
54963 -- No MPA option is assigned.
54964
54965
54966 END IF;
54967 END IF;
54968 --
54969
54970 --
54971 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54972 trace
54973 (p_msg => 'END of AcctLineType_121'
54974 ,p_level => C_LEVEL_PROCEDURE
54975 ,p_module => l_log_module);
54976 END IF;
54977 --
54978 EXCEPTION
54979 WHEN xla_exceptions_pkg.application_exception THEN
54980 RAISE;
54981 WHEN OTHERS THEN
54982 xla_exceptions_pkg.raise_message
54983 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_121');
54984 END AcctLineType_121;
54985 --
54986
54987 ---------------------------------------
54988 --
54989 -- PRIVATE FUNCTION
54990 -- AcctLineType_122
54991 --
54992 ---------------------------------------
54993 PROCEDURE AcctLineType_122 (
54994 p_application_id IN NUMBER
54995 ,p_event_id IN NUMBER
54996 ,p_calculate_acctd_flag IN VARCHAR2
54997 ,p_calculate_g_l_flag IN VARCHAR2
54998 ,p_actual_flag IN OUT VARCHAR2
54999 ,p_balance_type_code OUT VARCHAR2
55000 ,p_gain_or_loss_ref OUT VARCHAR2
55001
55002 --TRANSACTION_ID
55003 , p_source_1 IN NUMBER
55004 --Item Concatenated Segments
55005 , p_source_2 IN VARCHAR2
55006 --Transaction Quantity
55007 , p_source_3 IN NUMBER
55008 --Transaction Unit of Measure Code
55009 , p_source_4 IN VARCHAR2
55010 --Inventory Transaction Type Description
55011 , p_source_5 IN VARCHAR2
55012 --Cost Management Default Account
55013 , p_source_11 IN NUMBER
55014 --DISTRIBUTION_IDENTIFIER
55015 , p_source_84 IN NUMBER
55016 --Distribution Type
55017 , p_source_85 IN VARCHAR2
55018 , p_source_85_meaning IN VARCHAR2
55019 --Entered Currency Code
55020 , p_source_88 IN VARCHAR2
55021 --Entered Amount
55022 , p_source_91 IN NUMBER
55023 --Currency Conversion Date
55024 , p_source_92 IN DATE
55025 --Currency Conversion Rate
55026 , p_source_93 IN NUMBER
55027 --Currency Conversion Type
55028 , p_source_94 IN VARCHAR2
55029 --Accounted Amount
55030 , p_source_95 IN NUMBER
55031 --Accounting Line Type
55032 , p_source_97 IN NUMBER
55033 )
55034 IS
55035
55036 l_component_type VARCHAR2(80);
55037 l_component_code VARCHAR2(30);
55038 l_component_type_code VARCHAR2(1);
55039 l_component_appl_id INTEGER;
55040 l_amb_context_code VARCHAR2(30);
55041 l_entity_code VARCHAR2(30);
55042 l_event_class_code VARCHAR2(30);
55043 l_ae_header_id NUMBER;
55044 l_event_type_code VARCHAR2(30);
55045 l_line_definition_code VARCHAR2(30);
55046 l_line_definition_owner_code VARCHAR2(1);
55047 --
55048 -- adr variables
55049 l_segment VARCHAR2(30);
55050 l_ccid NUMBER;
55051 l_adr_transaction_coa_id NUMBER;
55052 l_adr_accounting_coa_id NUMBER;
55053 l_adr_flexfield_segment_code VARCHAR2(30);
55054 l_adr_flex_value_set_id NUMBER;
55055 l_adr_value_type_code VARCHAR2(30);
55056 l_adr_value_combination_id NUMBER;
55057 l_adr_value_segment_code VARCHAR2(30);
55058
55059 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
55060 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
55061 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
55062 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
55063
55064 -- 4262811 Variables ------------------------------------------------------------------------------------------
55065 l_entered_amt_idx NUMBER;
55066 l_accted_amt_idx NUMBER;
55067 l_acc_rev_flag VARCHAR2(1);
55068 l_accrual_line_num NUMBER;
55069 l_tmp_amt NUMBER;
55070 l_acc_rev_natural_side_code VARCHAR2(1);
55071
55072 l_num_entries NUMBER;
55073 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
55074 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
55075 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
55076 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
55077 l_recog_line_1 NUMBER;
55078 l_recog_line_2 NUMBER;
55079
55080 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
55081 l_bflow_applied_to_amt NUMBER; -- 5132302
55082 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
55083
55084 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
55085
55086 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
55087 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
55088
55089 ---------------------------------------------------------------------------------------------------------------
55090
55091
55092 --
55093 -- bulk performance
55094 --
55095 l_balance_type_code VARCHAR2(1);
55096 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
55097 l_log_module VARCHAR2(240);
55098
55099 --
55100 -- Upgrade strategy
55101 --
55102 l_actual_upg_option VARCHAR2(1);
55103 l_enc_upg_option VARCHAR2(1);
55104
55105 --
55106 BEGIN
55107 --
55108 IF g_log_enabled THEN
55109 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_122';
55110 END IF;
55111 --
55112 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55113
55114 trace
55115 (p_msg => 'BEGIN of AcctLineType_122'
55116 ,p_level => C_LEVEL_PROCEDURE
55117 ,p_module => l_log_module);
55118
55119 END IF;
55120 --
55121 l_component_type := 'AMB_JLT';
55122 l_component_code := 'DEFERRED_COGS';
55123 l_component_type_code := 'S';
55124 l_component_appl_id := 707;
55125 l_amb_context_code := 'DEFAULT';
55126 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
55127 l_event_class_code := 'SALES_ORDER';
55128 l_event_type_code := 'LOG_RMA_RCPT';
55129 l_line_definition_owner_code := 'S';
55130 l_line_definition_code := 'PI_LOG_RMA_RCPT';
55131 --
55132 l_balance_type_code := 'A';
55133 l_segment := NULL;
55134 l_ccid := NULL;
55135 l_adr_transaction_coa_id := NULL;
55136 l_adr_accounting_coa_id := NULL;
55137 l_adr_flexfield_segment_code := NULL;
55138 l_adr_flex_value_set_id := NULL;
55139 l_adr_value_type_code := NULL;
55140 l_adr_value_combination_id := NULL;
55141 l_adr_value_segment_code := NULL;
55142
55143 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55144 l_bflow_class_code := ''; -- 4219869 Business Flow
55145 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55146 l_budgetary_control_flag := 'N';
55147
55148 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55149 l_bflow_applied_to_amt := NULL; -- 5132302
55150 l_entered_amt_idx := NULL; -- 4262811
55151 l_accted_amt_idx := NULL; -- 4262811
55152 l_acc_rev_flag := NULL; -- 4262811
55153 l_accrual_line_num := NULL; -- 4262811
55154 l_tmp_amt := NULL; -- 4262811
55155 --
55156
55157 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55158 l_balance_type_code <> 'B' THEN
55159 IF NVL(p_source_97,9E125) = 36
55160 THEN
55161
55162 --
55163 XLA_AE_LINES_PKG.SetNewLine;
55164
55165 p_balance_type_code := l_balance_type_code;
55166 -- set the flag so later we will know whether the gain loss line needs to be created
55167
55168 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55169 p_actual_flag :='A';
55170 END IF;
55171
55172 --
55173 -- bulk performance
55174 --
55175 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55176 p_header_num => 0); -- 4262811
55177 --
55178 -- set accounting line options
55179 --
55180 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55181 p_natural_side_code => 'D'
55182 , p_gain_or_loss_flag => 'N'
55183 , p_gl_transfer_mode_code => 'S'
55184 , p_acct_entry_type_code => 'A'
55185 , p_switch_side_flag => 'Y'
55186 , p_merge_duplicate_code => 'N'
55187 );
55188 --
55189 l_acc_rev_natural_side_code := 'C'; -- 4262811
55190 --
55191 --
55192 -- set accounting line type info
55193 --
55194 xla_ae_lines_pkg.SetAcctLineType
55195 (p_component_type => l_component_type
55196 ,p_event_type_code => l_event_type_code
55197 ,p_line_definition_owner_code => l_line_definition_owner_code
55198 ,p_line_definition_code => l_line_definition_code
55199 ,p_accounting_line_code => l_component_code
55200 ,p_accounting_line_type_code => l_component_type_code
55201 ,p_accounting_line_appl_id => l_component_appl_id
55202 ,p_amb_context_code => l_amb_context_code
55203 ,p_entity_code => l_entity_code
55204 ,p_event_class_code => l_event_class_code);
55205 --
55206 -- set accounting class
55207 --
55208 xla_ae_lines_pkg.SetAcctClass(
55209 p_accounting_class_code => 'DEFERRED_COGS'
55210 , p_ae_header_id => l_ae_header_id
55211 );
55212
55213 --
55214 -- set rounding class
55215 --
55216 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55217 'DEFERRED_COGS';
55218
55219 --
55220 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
55221 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
55222 --
55223 -- bulk performance
55224 --
55225 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
55226
55227 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
55228 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
55229
55230 -- 4955764
55231 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55232 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
55233
55234 -- 4458381 Public Sector Enh
55235
55236 --
55237 -- set accounting attributes for the line type
55238 --
55239 l_entered_amt_idx := 3;
55240 l_accted_amt_idx := 8;
55241 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55242 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
55243 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
55244 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
55245 l_rec_acct_attrs.array_char_value(2) := p_source_85;
55246 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
55247 l_rec_acct_attrs.array_num_value(3) := p_source_91;
55248 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
55249 l_rec_acct_attrs.array_char_value(4) := p_source_88;
55250 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
55251 l_rec_acct_attrs.array_date_value(5) := p_source_92;
55252 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
55253 l_rec_acct_attrs.array_num_value(6) := p_source_93;
55254 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
55255 l_rec_acct_attrs.array_char_value(7) := p_source_94;
55256 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
55257 l_rec_acct_attrs.array_num_value(8) := p_source_95;
55258
55259 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
55260 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
55261
55262 ---------------------------------------------------------------------------------------------------------------
55263 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
55264 ---------------------------------------------------------------------------------------------------------------
55265 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
55266
55267 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55268 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55269
55270 IF xla_accounting_cache_pkg.GetValueChar
55271 (p_source_code => 'LEDGER_CATEGORY_CODE'
55272 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
55273 AND l_bflow_method_code = 'PRIOR_ENTRY'
55274 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
55275 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
55276 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
55277 )
55278 THEN
55279 xla_ae_lines_pkg.BflowUpgEntry
55280 (p_business_method_code => l_bflow_method_code
55281 ,p_business_class_code => l_bflow_class_code
55282 ,p_balance_type => l_balance_type_code);
55283 ELSE
55284 NULL;
55285 -- No business flow processing for business flow method of NONE.
55286 END IF;
55287
55288 --
55289 -- call analytical criteria
55290 --
55291
55292 --
55293 -- call description
55294 --
55295
55296 xla_ae_lines_pkg.SetLineDescription(
55297 p_ae_header_id => l_ae_header_id
55298 ,p_description => Description_1 (
55299 p_application_id => p_application_id
55300 , p_ae_header_id => l_ae_header_id
55301 , p_source_1 => p_source_1
55302 , p_source_2 => p_source_2
55303 , p_source_3 => p_source_3
55304 , p_source_4 => p_source_4
55305 , p_source_5 => p_source_5
55306 )
55307 );
55308
55309
55310 --
55311 -- call ADRs
55312 -- Bug 4922099
55313 --
55314 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55315 (NVL(l_actual_upg_option, 'N') = 'O') OR
55316 (NVL(l_enc_upg_option, 'N') = 'O')
55317 )
55318 THEN
55319 NULL;
55320 --
55321 --
55322
55323 l_ccid := AcctDerRule_6(
55324 p_application_id => p_application_id
55325 , p_ae_header_id => l_ae_header_id
55326 , p_source_11 => p_source_11
55327 , x_transaction_coa_id => l_adr_transaction_coa_id
55328 , x_accounting_coa_id => l_adr_accounting_coa_id
55329 , x_value_type_code => l_adr_value_type_code
55330 , p_side => 'NA'
55331 );
55332
55333 xla_ae_lines_pkg.set_ccid(
55334 p_code_combination_id => l_ccid
55335 , p_value_type_code => l_adr_value_type_code
55336 , p_transaction_coa_id => l_adr_transaction_coa_id
55337 , p_accounting_coa_id => l_adr_accounting_coa_id
55338 , p_adr_code => 'CST_DEFAULT'
55339 , p_adr_type_code => 'S'
55340 , p_component_type => l_component_type
55341 , p_component_code => l_component_code
55342 , p_component_type_code => l_component_type_code
55343 , p_component_appl_id => l_component_appl_id
55344 , p_amb_context_code => l_amb_context_code
55345 , p_side => 'NA'
55346 );
55347
55348
55349 --
55350 --
55351 END IF;
55352 --
55353 -- Bug 4922099
55354 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
55355 (NVL(l_enc_upg_option, 'N') = 'O')
55356 ) AND
55357 (l_bflow_method_code = 'PRIOR_ENTRY')
55358 )
55359 THEN
55360 IF
55361 --
55362 1 = 2
55363 --
55364 THEN
55365 xla_accounting_err_pkg.build_message
55366 (p_appli_s_name => 'XLA'
55367 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55368 ,p_token_1 => 'LINE_NUMBER'
55369 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
55370 ,p_token_2 => 'LINE_TYPE_NAME'
55371 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
55372 l_component_type
55373 ,l_component_code
55374 ,l_component_type_code
55375 ,l_component_appl_id
55376 ,l_amb_context_code
55377 ,l_entity_code
55378 ,l_event_class_code
55379 )
55380 ,p_token_3 => 'OWNER'
55381 ,p_value_3 => xla_lookups_pkg.get_meaning(
55382 p_lookup_type => 'XLA_OWNER_TYPE'
55383 ,p_lookup_code => l_component_type_code
55384 )
55385 ,p_token_4 => 'PRODUCT_NAME'
55386 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
55387 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
55388 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
55389 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
55390 ,p_ae_header_id => NULL
55391 );
55392
55393 IF (C_LEVEL_ERROR>= g_log_level) THEN
55394 trace
55395 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55396 ,p_level => C_LEVEL_ERROR
55397 ,p_module => l_log_module);
55398 END IF;
55399 END IF;
55400 END IF;
55401 --
55402 --
55403 ------------------------------------------------------------------------------------------------
55404 -- 4219869 Business Flow
55405 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55406 -- Prior Entry. Currently, the following code is always generated.
55407 ------------------------------------------------------------------------------------------------
55408 XLA_AE_LINES_PKG.ValidateCurrentLine;
55409
55410 ------------------------------------------------------------------------------------
55411 -- 4219869 Business Flow
55412 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55413 ------------------------------------------------------------------------------------
55414 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55415
55416 ----------------------------------------------------------------------------------
55417 -- 4219869 Business Flow
55418 -- Update journal entry status -- Need to generate this within IF <condition>
55419 ----------------------------------------------------------------------------------
55420 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55421 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55422 ,p_balance_type_code => l_balance_type_code
55423 );
55424
55425 -------------------------------------------------------------------------------------------
55426 -- 4262811 - Generate the Accrual Reversal lines
55427 -------------------------------------------------------------------------------------------
55428 BEGIN
55429 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55430 (g_array_event(p_event_id).array_value_num('header_index'));
55431 IF l_acc_rev_flag IS NULL THEN
55432 l_acc_rev_flag := 'N';
55433 END IF;
55434 EXCEPTION
55435 WHEN OTHERS THEN
55436 l_acc_rev_flag := 'N';
55437 END;
55438 --
55439 IF (l_acc_rev_flag = 'Y') THEN
55440
55441 -- 4645092 ------------------------------------------------------------------------------
55442 -- To allow MPA report to determine if it should generate report process
55443 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55444 ------------------------------------------------------------------------------------------
55445
55446 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
55447 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
55448 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
55449 -- call ADRs
55450 -- Bug 4922099
55451 --
55452 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55453 (NVL(l_actual_upg_option, 'N') = 'O') OR
55454 (NVL(l_enc_upg_option, 'N') = 'O')
55455 )
55456 THEN
55457 NULL;
55458 --
55459 --
55460
55461 l_ccid := AcctDerRule_6(
55462 p_application_id => p_application_id
55463 , p_ae_header_id => l_ae_header_id
55464 , p_source_11 => p_source_11
55465 , x_transaction_coa_id => l_adr_transaction_coa_id
55466 , x_accounting_coa_id => l_adr_accounting_coa_id
55467 , x_value_type_code => l_adr_value_type_code
55468 , p_side => 'NA'
55469 );
55470
55471 xla_ae_lines_pkg.set_ccid(
55472 p_code_combination_id => l_ccid
55473 , p_value_type_code => l_adr_value_type_code
55474 , p_transaction_coa_id => l_adr_transaction_coa_id
55475 , p_accounting_coa_id => l_adr_accounting_coa_id
55476 , p_adr_code => 'CST_DEFAULT'
55477 , p_adr_type_code => 'S'
55478 , p_component_type => l_component_type
55479 , p_component_code => l_component_code
55480 , p_component_type_code => l_component_type_code
55481 , p_component_appl_id => l_component_appl_id
55482 , p_amb_context_code => l_amb_context_code
55483 , p_side => 'NA'
55484 );
55485
55486
55487 --
55488 --
55489 END IF;
55490
55491 --
55492 -- Update the line information that should be overwritten
55493 --
55494 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
55495 p_header_num => 1);
55496 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
55497
55498 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
55499
55500 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
55501 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
55502 END IF;
55503
55504 --
55505 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
55506 --
55507 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
55508 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
55509 ELSE
55510 ---------------------------------------------------------------------------------------------------
55511 -- 4262811a Switch Sign
55512 ---------------------------------------------------------------------------------------------------
55513 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
55514 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55515 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55516 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55517 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55518 -- 5132302
55519 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
55520 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55521
55522 END IF;
55523
55524 -- 4955764
55525 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55526 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
55527
55528
55529 XLA_AE_LINES_PKG.ValidateCurrentLine;
55530 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55531
55532 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55533 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
55534 ,p_balance_type_code => l_balance_type_code);
55535
55536 END IF;
55537
55538 -----------------------------------------------------------------------------------------
55539 -- 4262811 Multiperiod Accounting
55540 -----------------------------------------------------------------------------------------
55541 -- No MPA option is assigned.
55542
55543
55544 END IF;
55545 END IF;
55546 --
55547
55548 --
55549 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55550 trace
55551 (p_msg => 'END of AcctLineType_122'
55552 ,p_level => C_LEVEL_PROCEDURE
55553 ,p_module => l_log_module);
55554 END IF;
55555 --
55556 EXCEPTION
55557 WHEN xla_exceptions_pkg.application_exception THEN
55558 RAISE;
55559 WHEN OTHERS THEN
55560 xla_exceptions_pkg.raise_message
55561 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_122');
55562 END AcctLineType_122;
55563 --
55564
55565 ---------------------------------------
55566 --
55567 -- PRIVATE FUNCTION
55568 -- AcctLineType_123
55569 --
55570 ---------------------------------------
55571 PROCEDURE AcctLineType_123 (
55572 p_application_id IN NUMBER
55573 ,p_event_id IN NUMBER
55574 ,p_calculate_acctd_flag IN VARCHAR2
55575 ,p_calculate_g_l_flag IN VARCHAR2
55576 ,p_actual_flag IN OUT VARCHAR2
55577 ,p_balance_type_code OUT VARCHAR2
55578 ,p_gain_or_loss_ref OUT VARCHAR2
55579
55580 --Cost Management Default Account
55581 , p_source_11 IN NUMBER
55582 --DISTRIBUTION_IDENTIFIER
55583 , p_source_84 IN NUMBER
55584 --Distribution Type
55585 , p_source_85 IN VARCHAR2
55586 , p_source_85_meaning IN VARCHAR2
55587 --Entered Currency Code
55588 , p_source_88 IN VARCHAR2
55589 --Entered Amount
55590 , p_source_91 IN NUMBER
55591 --Currency Conversion Date
55592 , p_source_92 IN DATE
55593 --Currency Conversion Rate
55594 , p_source_93 IN NUMBER
55595 --Currency Conversion Type
55596 , p_source_94 IN VARCHAR2
55597 --Accounted Amount
55598 , p_source_95 IN NUMBER
55599 --Accounting Line Type
55600 , p_source_97 IN NUMBER
55601 )
55602 IS
55603
55604 l_component_type VARCHAR2(80);
55605 l_component_code VARCHAR2(30);
55606 l_component_type_code VARCHAR2(1);
55607 l_component_appl_id INTEGER;
55608 l_amb_context_code VARCHAR2(30);
55609 l_entity_code VARCHAR2(30);
55610 l_event_class_code VARCHAR2(30);
55611 l_ae_header_id NUMBER;
55612 l_event_type_code VARCHAR2(30);
55613 l_line_definition_code VARCHAR2(30);
55614 l_line_definition_owner_code VARCHAR2(1);
55615 --
55616 -- adr variables
55617 l_segment VARCHAR2(30);
55618 l_ccid NUMBER;
55619 l_adr_transaction_coa_id NUMBER;
55620 l_adr_accounting_coa_id NUMBER;
55621 l_adr_flexfield_segment_code VARCHAR2(30);
55622 l_adr_flex_value_set_id NUMBER;
55623 l_adr_value_type_code VARCHAR2(30);
55624 l_adr_value_combination_id NUMBER;
55625 l_adr_value_segment_code VARCHAR2(30);
55626
55627 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
55628 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
55629 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
55630 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
55631
55632 -- 4262811 Variables ------------------------------------------------------------------------------------------
55633 l_entered_amt_idx NUMBER;
55634 l_accted_amt_idx NUMBER;
55635 l_acc_rev_flag VARCHAR2(1);
55636 l_accrual_line_num NUMBER;
55637 l_tmp_amt NUMBER;
55638 l_acc_rev_natural_side_code VARCHAR2(1);
55639
55640 l_num_entries NUMBER;
55641 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
55642 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
55643 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
55644 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
55645 l_recog_line_1 NUMBER;
55646 l_recog_line_2 NUMBER;
55647
55648 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
55649 l_bflow_applied_to_amt NUMBER; -- 5132302
55650 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
55651
55652 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
55653
55654 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
55655 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
55656
55657 ---------------------------------------------------------------------------------------------------------------
55658
55659
55660 --
55661 -- bulk performance
55662 --
55663 l_balance_type_code VARCHAR2(1);
55664 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
55665 l_log_module VARCHAR2(240);
55666
55667 --
55668 -- Upgrade strategy
55669 --
55670 l_actual_upg_option VARCHAR2(1);
55671 l_enc_upg_option VARCHAR2(1);
55672
55673 --
55674 BEGIN
55675 --
55676 IF g_log_enabled THEN
55677 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_123';
55678 END IF;
55679 --
55680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55681
55682 trace
55683 (p_msg => 'BEGIN of AcctLineType_123'
55684 ,p_level => C_LEVEL_PROCEDURE
55685 ,p_module => l_log_module);
55686
55687 END IF;
55688 --
55689 l_component_type := 'AMB_JLT';
55690 l_component_code := 'EST_SCRAP_ABSORPTION';
55691 l_component_type_code := 'S';
55692 l_component_appl_id := 707;
55693 l_amb_context_code := 'DEFAULT';
55694 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
55695 l_event_class_code := 'ABSORPTION';
55696 l_event_type_code := 'ABSORPTION_ALL';
55697 l_line_definition_owner_code := 'S';
55698 l_line_definition_code := 'ABSORPTION';
55699 --
55700 l_balance_type_code := 'A';
55701 l_segment := NULL;
55702 l_ccid := NULL;
55703 l_adr_transaction_coa_id := NULL;
55704 l_adr_accounting_coa_id := NULL;
55705 l_adr_flexfield_segment_code := NULL;
55706 l_adr_flex_value_set_id := NULL;
55707 l_adr_value_type_code := NULL;
55708 l_adr_value_combination_id := NULL;
55709 l_adr_value_segment_code := NULL;
55710
55711 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55712 l_bflow_class_code := ''; -- 4219869 Business Flow
55713 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55714 l_budgetary_control_flag := 'N';
55715
55716 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55717 l_bflow_applied_to_amt := NULL; -- 5132302
55718 l_entered_amt_idx := NULL; -- 4262811
55719 l_accted_amt_idx := NULL; -- 4262811
55720 l_acc_rev_flag := NULL; -- 4262811
55721 l_accrual_line_num := NULL; -- 4262811
55722 l_tmp_amt := NULL; -- 4262811
55723 --
55724
55725 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55726 l_balance_type_code <> 'B' THEN
55727 IF NVL(p_source_97,9E125) = 29
55728 THEN
55729
55730 --
55731 XLA_AE_LINES_PKG.SetNewLine;
55732
55733 p_balance_type_code := l_balance_type_code;
55734 -- set the flag so later we will know whether the gain loss line needs to be created
55735
55736 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55737 p_actual_flag :='A';
55738 END IF;
55739
55740 --
55741 -- bulk performance
55742 --
55743 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55744 p_header_num => 0); -- 4262811
55745 --
55746 -- set accounting line options
55747 --
55748 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55749 p_natural_side_code => 'D'
55750 , p_gain_or_loss_flag => 'N'
55751 , p_gl_transfer_mode_code => 'S'
55752 , p_acct_entry_type_code => 'A'
55753 , p_switch_side_flag => 'Y'
55754 , p_merge_duplicate_code => 'N'
55755 );
55756 --
55757 l_acc_rev_natural_side_code := 'C'; -- 4262811
55758 --
55759 --
55760 -- set accounting line type info
55761 --
55762 xla_ae_lines_pkg.SetAcctLineType
55763 (p_component_type => l_component_type
55764 ,p_event_type_code => l_event_type_code
55765 ,p_line_definition_owner_code => l_line_definition_owner_code
55766 ,p_line_definition_code => l_line_definition_code
55767 ,p_accounting_line_code => l_component_code
55768 ,p_accounting_line_type_code => l_component_type_code
55769 ,p_accounting_line_appl_id => l_component_appl_id
55770 ,p_amb_context_code => l_amb_context_code
55771 ,p_entity_code => l_entity_code
55772 ,p_event_class_code => l_event_class_code);
55773 --
55774 -- set accounting class
55775 --
55776 xla_ae_lines_pkg.SetAcctClass(
55777 p_accounting_class_code => 'ESTIMATED_SCRAP_ABSORPTION'
55778 , p_ae_header_id => l_ae_header_id
55779 );
55780
55781 --
55782 -- set rounding class
55783 --
55784 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55785 'ESTIMATED_SCRAP_ABSORPTION';
55786
55787 --
55788 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
55789 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
55790 --
55791 -- bulk performance
55792 --
55793 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
55794
55795 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
55796 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
55797
55798 -- 4955764
55799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
55801
55802 -- 4458381 Public Sector Enh
55803
55804 --
55805 -- set accounting attributes for the line type
55806 --
55807 l_entered_amt_idx := 3;
55808 l_accted_amt_idx := 8;
55809 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55810 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
55811 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
55812 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
55813 l_rec_acct_attrs.array_char_value(2) := p_source_85;
55814 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
55815 l_rec_acct_attrs.array_num_value(3) := p_source_91;
55816 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
55817 l_rec_acct_attrs.array_char_value(4) := p_source_88;
55818 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
55819 l_rec_acct_attrs.array_date_value(5) := p_source_92;
55820 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
55821 l_rec_acct_attrs.array_num_value(6) := p_source_93;
55822 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
55823 l_rec_acct_attrs.array_char_value(7) := p_source_94;
55824 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
55825 l_rec_acct_attrs.array_num_value(8) := p_source_95;
55826
55827 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
55828 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
55829
55830 ---------------------------------------------------------------------------------------------------------------
55831 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
55832 ---------------------------------------------------------------------------------------------------------------
55833 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
55834
55835 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55836 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55837
55838 IF xla_accounting_cache_pkg.GetValueChar
55839 (p_source_code => 'LEDGER_CATEGORY_CODE'
55840 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
55841 AND l_bflow_method_code = 'PRIOR_ENTRY'
55842 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
55843 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
55844 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
55845 )
55846 THEN
55847 xla_ae_lines_pkg.BflowUpgEntry
55848 (p_business_method_code => l_bflow_method_code
55849 ,p_business_class_code => l_bflow_class_code
55850 ,p_balance_type => l_balance_type_code);
55851 ELSE
55852 NULL;
55853 -- No business flow processing for business flow method of NONE.
55854 END IF;
55855
55856 --
55857 -- call analytical criteria
55858 --
55859
55860 --
55861 -- call description
55862 --
55863 -- No description or it is inherited.
55864 --
55865 -- call ADRs
55866 -- Bug 4922099
55867 --
55868 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55869 (NVL(l_actual_upg_option, 'N') = 'O') OR
55870 (NVL(l_enc_upg_option, 'N') = 'O')
55871 )
55872 THEN
55873 NULL;
55874 --
55875 --
55876
55877 l_ccid := AcctDerRule_6(
55878 p_application_id => p_application_id
55879 , p_ae_header_id => l_ae_header_id
55880 , p_source_11 => p_source_11
55881 , x_transaction_coa_id => l_adr_transaction_coa_id
55882 , x_accounting_coa_id => l_adr_accounting_coa_id
55883 , x_value_type_code => l_adr_value_type_code
55884 , p_side => 'NA'
55885 );
55886
55887 xla_ae_lines_pkg.set_ccid(
55888 p_code_combination_id => l_ccid
55889 , p_value_type_code => l_adr_value_type_code
55890 , p_transaction_coa_id => l_adr_transaction_coa_id
55891 , p_accounting_coa_id => l_adr_accounting_coa_id
55892 , p_adr_code => 'CST_DEFAULT'
55893 , p_adr_type_code => 'S'
55894 , p_component_type => l_component_type
55895 , p_component_code => l_component_code
55896 , p_component_type_code => l_component_type_code
55897 , p_component_appl_id => l_component_appl_id
55898 , p_amb_context_code => l_amb_context_code
55899 , p_side => 'NA'
55900 );
55901
55902
55903 --
55904 --
55905 END IF;
55906 --
55907 -- Bug 4922099
55908 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
55909 (NVL(l_enc_upg_option, 'N') = 'O')
55910 ) AND
55911 (l_bflow_method_code = 'PRIOR_ENTRY')
55912 )
55913 THEN
55914 IF
55915 --
55916 1 = 2
55917 --
55918 THEN
55919 xla_accounting_err_pkg.build_message
55920 (p_appli_s_name => 'XLA'
55921 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55922 ,p_token_1 => 'LINE_NUMBER'
55923 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
55924 ,p_token_2 => 'LINE_TYPE_NAME'
55925 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
55926 l_component_type
55927 ,l_component_code
55928 ,l_component_type_code
55929 ,l_component_appl_id
55930 ,l_amb_context_code
55931 ,l_entity_code
55932 ,l_event_class_code
55933 )
55934 ,p_token_3 => 'OWNER'
55935 ,p_value_3 => xla_lookups_pkg.get_meaning(
55936 p_lookup_type => 'XLA_OWNER_TYPE'
55937 ,p_lookup_code => l_component_type_code
55938 )
55939 ,p_token_4 => 'PRODUCT_NAME'
55940 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
55941 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
55942 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
55943 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
55944 ,p_ae_header_id => NULL
55945 );
55946
55947 IF (C_LEVEL_ERROR>= g_log_level) THEN
55948 trace
55949 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55950 ,p_level => C_LEVEL_ERROR
55951 ,p_module => l_log_module);
55952 END IF;
55953 END IF;
55954 END IF;
55955 --
55956 --
55957 ------------------------------------------------------------------------------------------------
55958 -- 4219869 Business Flow
55959 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55960 -- Prior Entry. Currently, the following code is always generated.
55961 ------------------------------------------------------------------------------------------------
55962 XLA_AE_LINES_PKG.ValidateCurrentLine;
55963
55964 ------------------------------------------------------------------------------------
55965 -- 4219869 Business Flow
55966 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55967 ------------------------------------------------------------------------------------
55968 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55969
55970 ----------------------------------------------------------------------------------
55971 -- 4219869 Business Flow
55972 -- Update journal entry status -- Need to generate this within IF <condition>
55973 ----------------------------------------------------------------------------------
55974 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55975 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55976 ,p_balance_type_code => l_balance_type_code
55977 );
55978
55979 -------------------------------------------------------------------------------------------
55980 -- 4262811 - Generate the Accrual Reversal lines
55981 -------------------------------------------------------------------------------------------
55982 BEGIN
55983 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55984 (g_array_event(p_event_id).array_value_num('header_index'));
55985 IF l_acc_rev_flag IS NULL THEN
55986 l_acc_rev_flag := 'N';
55987 END IF;
55988 EXCEPTION
55989 WHEN OTHERS THEN
55990 l_acc_rev_flag := 'N';
55991 END;
55992 --
55993 IF (l_acc_rev_flag = 'Y') THEN
55994
55995 -- 4645092 ------------------------------------------------------------------------------
55996 -- To allow MPA report to determine if it should generate report process
55997 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55998 ------------------------------------------------------------------------------------------
55999
56000 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
56001 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
56002 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
56003 -- call ADRs
56004 -- Bug 4922099
56005 --
56006 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56007 (NVL(l_actual_upg_option, 'N') = 'O') OR
56008 (NVL(l_enc_upg_option, 'N') = 'O')
56009 )
56010 THEN
56011 NULL;
56012 --
56013 --
56014
56015 l_ccid := AcctDerRule_6(
56016 p_application_id => p_application_id
56017 , p_ae_header_id => l_ae_header_id
56018 , p_source_11 => p_source_11
56019 , x_transaction_coa_id => l_adr_transaction_coa_id
56020 , x_accounting_coa_id => l_adr_accounting_coa_id
56021 , x_value_type_code => l_adr_value_type_code
56022 , p_side => 'NA'
56023 );
56024
56025 xla_ae_lines_pkg.set_ccid(
56026 p_code_combination_id => l_ccid
56027 , p_value_type_code => l_adr_value_type_code
56028 , p_transaction_coa_id => l_adr_transaction_coa_id
56029 , p_accounting_coa_id => l_adr_accounting_coa_id
56030 , p_adr_code => 'CST_DEFAULT'
56031 , p_adr_type_code => 'S'
56032 , p_component_type => l_component_type
56033 , p_component_code => l_component_code
56034 , p_component_type_code => l_component_type_code
56035 , p_component_appl_id => l_component_appl_id
56036 , p_amb_context_code => l_amb_context_code
56037 , p_side => 'NA'
56038 );
56039
56040
56041 --
56042 --
56043 END IF;
56044
56045 --
56046 -- Update the line information that should be overwritten
56047 --
56048 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
56049 p_header_num => 1);
56050 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
56051
56052 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
56053
56054 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
56055 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
56056 END IF;
56057
56058 --
56059 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
56060 --
56061 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
56062 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
56063 ELSE
56064 ---------------------------------------------------------------------------------------------------
56065 -- 4262811a Switch Sign
56066 ---------------------------------------------------------------------------------------------------
56067 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
56068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56069 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56071 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56072 -- 5132302
56073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
56074 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56075
56076 END IF;
56077
56078 -- 4955764
56079 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56080 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
56081
56082
56083 XLA_AE_LINES_PKG.ValidateCurrentLine;
56084 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56085
56086 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56087 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56088 ,p_balance_type_code => l_balance_type_code);
56089
56090 END IF;
56091
56092 -----------------------------------------------------------------------------------------
56093 -- 4262811 Multiperiod Accounting
56094 -----------------------------------------------------------------------------------------
56095 -- No MPA option is assigned.
56096
56097
56098 END IF;
56099 END IF;
56100 --
56101
56102 --
56103 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56104 trace
56105 (p_msg => 'END of AcctLineType_123'
56106 ,p_level => C_LEVEL_PROCEDURE
56107 ,p_module => l_log_module);
56108 END IF;
56109 --
56110 EXCEPTION
56111 WHEN xla_exceptions_pkg.application_exception THEN
56112 RAISE;
56113 WHEN OTHERS THEN
56114 xla_exceptions_pkg.raise_message
56115 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_123');
56116 END AcctLineType_123;
56117 --
56118
56119 ---------------------------------------
56120 --
56121 -- PRIVATE FUNCTION
56122 -- AcctLineType_124
56123 --
56124 ---------------------------------------
56125 PROCEDURE AcctLineType_124 (
56126 p_application_id IN NUMBER
56127 ,p_event_id IN NUMBER
56128 ,p_calculate_acctd_flag IN VARCHAR2
56129 ,p_calculate_g_l_flag IN VARCHAR2
56130 ,p_actual_flag IN OUT VARCHAR2
56131 ,p_balance_type_code OUT VARCHAR2
56132 ,p_gain_or_loss_ref OUT VARCHAR2
56133
56134 --TRANSACTION_ID
56135 , p_source_1 IN NUMBER
56136 --Item Concatenated Segments
56137 , p_source_2 IN VARCHAR2
56138 --Transaction Quantity
56139 , p_source_3 IN NUMBER
56140 --Transaction Unit of Measure Code
56141 , p_source_4 IN VARCHAR2
56142 --Inventory Transaction Type Description
56143 , p_source_5 IN VARCHAR2
56144 --Cost Management Default Account
56145 , p_source_11 IN NUMBER
56146 --DISTRIBUTION_IDENTIFIER
56147 , p_source_84 IN NUMBER
56148 --Distribution Type
56149 , p_source_85 IN VARCHAR2
56150 , p_source_85_meaning IN VARCHAR2
56151 --Entered Currency Code
56152 , p_source_88 IN VARCHAR2
56153 --Entered Amount
56154 , p_source_91 IN NUMBER
56155 --Currency Conversion Date
56156 , p_source_92 IN DATE
56157 --Currency Conversion Rate
56158 , p_source_93 IN NUMBER
56159 --Currency Conversion Type
56160 , p_source_94 IN VARCHAR2
56161 --Accounted Amount
56162 , p_source_95 IN NUMBER
56163 --Accounting Line Type
56164 , p_source_97 IN NUMBER
56165 )
56166 IS
56167
56168 l_component_type VARCHAR2(80);
56169 l_component_code VARCHAR2(30);
56170 l_component_type_code VARCHAR2(1);
56171 l_component_appl_id INTEGER;
56172 l_amb_context_code VARCHAR2(30);
56173 l_entity_code VARCHAR2(30);
56174 l_event_class_code VARCHAR2(30);
56175 l_ae_header_id NUMBER;
56176 l_event_type_code VARCHAR2(30);
56177 l_line_definition_code VARCHAR2(30);
56178 l_line_definition_owner_code VARCHAR2(1);
56179 --
56180 -- adr variables
56181 l_segment VARCHAR2(30);
56182 l_ccid NUMBER;
56183 l_adr_transaction_coa_id NUMBER;
56184 l_adr_accounting_coa_id NUMBER;
56185 l_adr_flexfield_segment_code VARCHAR2(30);
56186 l_adr_flex_value_set_id NUMBER;
56187 l_adr_value_type_code VARCHAR2(30);
56188 l_adr_value_combination_id NUMBER;
56189 l_adr_value_segment_code VARCHAR2(30);
56190
56191 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
56192 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
56193 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
56194 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
56195
56196 -- 4262811 Variables ------------------------------------------------------------------------------------------
56197 l_entered_amt_idx NUMBER;
56198 l_accted_amt_idx NUMBER;
56199 l_acc_rev_flag VARCHAR2(1);
56200 l_accrual_line_num NUMBER;
56201 l_tmp_amt NUMBER;
56202 l_acc_rev_natural_side_code VARCHAR2(1);
56203
56204 l_num_entries NUMBER;
56205 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
56206 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
56207 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
56208 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
56209 l_recog_line_1 NUMBER;
56210 l_recog_line_2 NUMBER;
56211
56212 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
56213 l_bflow_applied_to_amt NUMBER; -- 5132302
56214 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
56215
56216 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
56217
56218 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
56219 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
56220
56221 ---------------------------------------------------------------------------------------------------------------
56222
56223
56224 --
56225 -- bulk performance
56226 --
56227 l_balance_type_code VARCHAR2(1);
56228 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56229 l_log_module VARCHAR2(240);
56230
56231 --
56232 -- Upgrade strategy
56233 --
56234 l_actual_upg_option VARCHAR2(1);
56235 l_enc_upg_option VARCHAR2(1);
56236
56237 --
56238 BEGIN
56239 --
56240 IF g_log_enabled THEN
56241 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_124';
56242 END IF;
56243 --
56244 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56245
56246 trace
56247 (p_msg => 'BEGIN of AcctLineType_124'
56248 ,p_level => C_LEVEL_PROCEDURE
56249 ,p_module => l_log_module);
56250
56251 END IF;
56252 --
56253 l_component_type := 'AMB_JLT';
56254 l_component_code := 'EXPENSE';
56255 l_component_type_code := 'S';
56256 l_component_appl_id := 707;
56257 l_amb_context_code := 'DEFAULT';
56258 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
56259 l_event_class_code := 'USER_DEFINE';
56260 l_event_type_code := 'UAVG_COST_UPD';
56261 l_line_definition_owner_code := 'S';
56262 l_line_definition_code := 'PI_COST_UPD';
56263 --
56264 l_balance_type_code := 'A';
56265 l_segment := NULL;
56266 l_ccid := NULL;
56267 l_adr_transaction_coa_id := NULL;
56268 l_adr_accounting_coa_id := NULL;
56269 l_adr_flexfield_segment_code := NULL;
56270 l_adr_flex_value_set_id := NULL;
56271 l_adr_value_type_code := NULL;
56272 l_adr_value_combination_id := NULL;
56273 l_adr_value_segment_code := NULL;
56274
56275 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
56276 l_bflow_class_code := ''; -- 4219869 Business Flow
56277 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
56278 l_budgetary_control_flag := 'N';
56279
56280 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56281 l_bflow_applied_to_amt := NULL; -- 5132302
56282 l_entered_amt_idx := NULL; -- 4262811
56283 l_accted_amt_idx := NULL; -- 4262811
56284 l_acc_rev_flag := NULL; -- 4262811
56285 l_accrual_line_num := NULL; -- 4262811
56286 l_tmp_amt := NULL; -- 4262811
56287 --
56288
56289 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
56290 l_balance_type_code <> 'B' THEN
56291 IF NVL(p_source_97,9E125) = 20
56292 THEN
56293
56294 --
56295 XLA_AE_LINES_PKG.SetNewLine;
56296
56297 p_balance_type_code := l_balance_type_code;
56298 -- set the flag so later we will know whether the gain loss line needs to be created
56299
56300 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
56301 p_actual_flag :='A';
56302 END IF;
56303
56304 --
56305 -- bulk performance
56306 --
56307 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
56308 p_header_num => 0); -- 4262811
56309 --
56310 -- set accounting line options
56311 --
56312 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
56313 p_natural_side_code => 'D'
56314 , p_gain_or_loss_flag => 'N'
56315 , p_gl_transfer_mode_code => 'S'
56316 , p_acct_entry_type_code => 'A'
56317 , p_switch_side_flag => 'Y'
56318 , p_merge_duplicate_code => 'N'
56319 );
56320 --
56321 l_acc_rev_natural_side_code := 'C'; -- 4262811
56322 --
56323 --
56324 -- set accounting line type info
56325 --
56326 xla_ae_lines_pkg.SetAcctLineType
56327 (p_component_type => l_component_type
56328 ,p_event_type_code => l_event_type_code
56329 ,p_line_definition_owner_code => l_line_definition_owner_code
56330 ,p_line_definition_code => l_line_definition_code
56331 ,p_accounting_line_code => l_component_code
56332 ,p_accounting_line_type_code => l_component_type_code
56333 ,p_accounting_line_appl_id => l_component_appl_id
56334 ,p_amb_context_code => l_amb_context_code
56335 ,p_entity_code => l_entity_code
56336 ,p_event_class_code => l_event_class_code);
56337 --
56338 -- set accounting class
56339 --
56340 xla_ae_lines_pkg.SetAcctClass(
56341 p_accounting_class_code => 'EXPENSE'
56342 , p_ae_header_id => l_ae_header_id
56343 );
56344
56345 --
56346 -- set rounding class
56347 --
56348 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
56349 'EXPENSE';
56350
56351 --
56352 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56353 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56354 --
56355 -- bulk performance
56356 --
56357 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56358
56359 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56360 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56361
56362 -- 4955764
56363 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56364 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56365
56366 -- 4458381 Public Sector Enh
56367
56368 --
56369 -- set accounting attributes for the line type
56370 --
56371 l_entered_amt_idx := 3;
56372 l_accted_amt_idx := 8;
56373 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56374 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
56375 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
56376 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
56377 l_rec_acct_attrs.array_char_value(2) := p_source_85;
56378 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
56379 l_rec_acct_attrs.array_num_value(3) := p_source_91;
56380 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
56381 l_rec_acct_attrs.array_char_value(4) := p_source_88;
56382 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
56383 l_rec_acct_attrs.array_date_value(5) := p_source_92;
56384 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
56385 l_rec_acct_attrs.array_num_value(6) := p_source_93;
56386 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
56387 l_rec_acct_attrs.array_char_value(7) := p_source_94;
56388 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
56389 l_rec_acct_attrs.array_num_value(8) := p_source_95;
56390
56391 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56392 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56393
56394 ---------------------------------------------------------------------------------------------------------------
56395 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56396 ---------------------------------------------------------------------------------------------------------------
56397 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56398
56399 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56400 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56401
56402 IF xla_accounting_cache_pkg.GetValueChar
56403 (p_source_code => 'LEDGER_CATEGORY_CODE'
56404 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56405 AND l_bflow_method_code = 'PRIOR_ENTRY'
56406 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56407 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56408 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56409 )
56410 THEN
56411 xla_ae_lines_pkg.BflowUpgEntry
56412 (p_business_method_code => l_bflow_method_code
56413 ,p_business_class_code => l_bflow_class_code
56414 ,p_balance_type => l_balance_type_code);
56415 ELSE
56416 NULL;
56417 -- No business flow processing for business flow method of NONE.
56418 END IF;
56419
56420 --
56421 -- call analytical criteria
56422 --
56423
56424 --
56425 -- call description
56426 --
56427
56428 xla_ae_lines_pkg.SetLineDescription(
56429 p_ae_header_id => l_ae_header_id
56430 ,p_description => Description_1 (
56431 p_application_id => p_application_id
56432 , p_ae_header_id => l_ae_header_id
56433 , p_source_1 => p_source_1
56434 , p_source_2 => p_source_2
56435 , p_source_3 => p_source_3
56436 , p_source_4 => p_source_4
56437 , p_source_5 => p_source_5
56438 )
56439 );
56440
56441
56442 --
56443 -- call ADRs
56444 -- Bug 4922099
56445 --
56446 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56447 (NVL(l_actual_upg_option, 'N') = 'O') OR
56448 (NVL(l_enc_upg_option, 'N') = 'O')
56449 )
56450 THEN
56451 NULL;
56452 --
56453 --
56454
56455 l_ccid := AcctDerRule_6(
56456 p_application_id => p_application_id
56457 , p_ae_header_id => l_ae_header_id
56458 , p_source_11 => p_source_11
56459 , x_transaction_coa_id => l_adr_transaction_coa_id
56460 , x_accounting_coa_id => l_adr_accounting_coa_id
56461 , x_value_type_code => l_adr_value_type_code
56462 , p_side => 'NA'
56463 );
56464
56465 xla_ae_lines_pkg.set_ccid(
56466 p_code_combination_id => l_ccid
56467 , p_value_type_code => l_adr_value_type_code
56468 , p_transaction_coa_id => l_adr_transaction_coa_id
56469 , p_accounting_coa_id => l_adr_accounting_coa_id
56470 , p_adr_code => 'CST_DEFAULT'
56471 , p_adr_type_code => 'S'
56472 , p_component_type => l_component_type
56473 , p_component_code => l_component_code
56474 , p_component_type_code => l_component_type_code
56475 , p_component_appl_id => l_component_appl_id
56476 , p_amb_context_code => l_amb_context_code
56477 , p_side => 'NA'
56478 );
56479
56480
56481 --
56482 --
56483 END IF;
56484 --
56485 -- Bug 4922099
56486 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
56487 (NVL(l_enc_upg_option, 'N') = 'O')
56488 ) AND
56489 (l_bflow_method_code = 'PRIOR_ENTRY')
56490 )
56491 THEN
56492 IF
56493 --
56494 1 = 2
56495 --
56496 THEN
56497 xla_accounting_err_pkg.build_message
56498 (p_appli_s_name => 'XLA'
56499 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56500 ,p_token_1 => 'LINE_NUMBER'
56501 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
56502 ,p_token_2 => 'LINE_TYPE_NAME'
56503 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
56504 l_component_type
56505 ,l_component_code
56506 ,l_component_type_code
56507 ,l_component_appl_id
56508 ,l_amb_context_code
56509 ,l_entity_code
56510 ,l_event_class_code
56511 )
56512 ,p_token_3 => 'OWNER'
56513 ,p_value_3 => xla_lookups_pkg.get_meaning(
56514 p_lookup_type => 'XLA_OWNER_TYPE'
56515 ,p_lookup_code => l_component_type_code
56516 )
56517 ,p_token_4 => 'PRODUCT_NAME'
56518 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
56519 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
56520 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
56521 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
56522 ,p_ae_header_id => NULL
56523 );
56524
56525 IF (C_LEVEL_ERROR>= g_log_level) THEN
56526 trace
56527 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56528 ,p_level => C_LEVEL_ERROR
56529 ,p_module => l_log_module);
56530 END IF;
56531 END IF;
56532 END IF;
56533 --
56534 --
56535 ------------------------------------------------------------------------------------------------
56536 -- 4219869 Business Flow
56537 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
56538 -- Prior Entry. Currently, the following code is always generated.
56539 ------------------------------------------------------------------------------------------------
56540 XLA_AE_LINES_PKG.ValidateCurrentLine;
56541
56542 ------------------------------------------------------------------------------------
56543 -- 4219869 Business Flow
56544 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
56545 ------------------------------------------------------------------------------------
56546 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56547
56548 ----------------------------------------------------------------------------------
56549 -- 4219869 Business Flow
56550 -- Update journal entry status -- Need to generate this within IF <condition>
56551 ----------------------------------------------------------------------------------
56552 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56553 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
56554 ,p_balance_type_code => l_balance_type_code
56555 );
56556
56557 -------------------------------------------------------------------------------------------
56558 -- 4262811 - Generate the Accrual Reversal lines
56559 -------------------------------------------------------------------------------------------
56560 BEGIN
56561 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
56562 (g_array_event(p_event_id).array_value_num('header_index'));
56563 IF l_acc_rev_flag IS NULL THEN
56564 l_acc_rev_flag := 'N';
56565 END IF;
56566 EXCEPTION
56567 WHEN OTHERS THEN
56568 l_acc_rev_flag := 'N';
56569 END;
56570 --
56571 IF (l_acc_rev_flag = 'Y') THEN
56572
56573 -- 4645092 ------------------------------------------------------------------------------
56574 -- To allow MPA report to determine if it should generate report process
56575 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
56576 ------------------------------------------------------------------------------------------
56577
56578 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
56579 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
56580 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
56581 -- call ADRs
56582 -- Bug 4922099
56583 --
56584 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56585 (NVL(l_actual_upg_option, 'N') = 'O') OR
56586 (NVL(l_enc_upg_option, 'N') = 'O')
56587 )
56588 THEN
56589 NULL;
56590 --
56591 --
56592
56593 l_ccid := AcctDerRule_6(
56594 p_application_id => p_application_id
56595 , p_ae_header_id => l_ae_header_id
56596 , p_source_11 => p_source_11
56597 , x_transaction_coa_id => l_adr_transaction_coa_id
56598 , x_accounting_coa_id => l_adr_accounting_coa_id
56599 , x_value_type_code => l_adr_value_type_code
56600 , p_side => 'NA'
56601 );
56602
56603 xla_ae_lines_pkg.set_ccid(
56604 p_code_combination_id => l_ccid
56605 , p_value_type_code => l_adr_value_type_code
56606 , p_transaction_coa_id => l_adr_transaction_coa_id
56607 , p_accounting_coa_id => l_adr_accounting_coa_id
56608 , p_adr_code => 'CST_DEFAULT'
56609 , p_adr_type_code => 'S'
56610 , p_component_type => l_component_type
56611 , p_component_code => l_component_code
56612 , p_component_type_code => l_component_type_code
56613 , p_component_appl_id => l_component_appl_id
56614 , p_amb_context_code => l_amb_context_code
56615 , p_side => 'NA'
56616 );
56617
56618
56619 --
56620 --
56621 END IF;
56622
56623 --
56624 -- Update the line information that should be overwritten
56625 --
56626 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
56627 p_header_num => 1);
56628 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
56629
56630 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
56631
56632 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
56633 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
56634 END IF;
56635
56636 --
56637 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
56638 --
56639 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
56640 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
56641 ELSE
56642 ---------------------------------------------------------------------------------------------------
56643 -- 4262811a Switch Sign
56644 ---------------------------------------------------------------------------------------------------
56645 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
56646 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56647 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56648 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56649 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56650 -- 5132302
56651 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
56652 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56653
56654 END IF;
56655
56656 -- 4955764
56657 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56658 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
56659
56660
56661 XLA_AE_LINES_PKG.ValidateCurrentLine;
56662 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56663
56664 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56665 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56666 ,p_balance_type_code => l_balance_type_code);
56667
56668 END IF;
56669
56670 -----------------------------------------------------------------------------------------
56671 -- 4262811 Multiperiod Accounting
56672 -----------------------------------------------------------------------------------------
56673 -- No MPA option is assigned.
56674
56675
56676 END IF;
56677 END IF;
56678 --
56679
56680 --
56681 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56682 trace
56683 (p_msg => 'END of AcctLineType_124'
56684 ,p_level => C_LEVEL_PROCEDURE
56685 ,p_module => l_log_module);
56686 END IF;
56687 --
56688 EXCEPTION
56689 WHEN xla_exceptions_pkg.application_exception THEN
56690 RAISE;
56691 WHEN OTHERS THEN
56692 xla_exceptions_pkg.raise_message
56693 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_124');
56694 END AcctLineType_124;
56695 --
56696
56697 ---------------------------------------
56698 --
56699 -- PRIVATE FUNCTION
56700 -- AcctLineType_125
56701 --
56702 ---------------------------------------
56703 PROCEDURE AcctLineType_125 (
56704 p_application_id IN NUMBER
56705 ,p_event_id IN NUMBER
56706 ,p_calculate_acctd_flag IN VARCHAR2
56707 ,p_calculate_g_l_flag IN VARCHAR2
56708 ,p_actual_flag IN OUT VARCHAR2
56709 ,p_balance_type_code OUT VARCHAR2
56710 ,p_gain_or_loss_ref OUT VARCHAR2
56711
56712 --Cost Management Default Account
56713 , p_source_11 IN NUMBER
56714 --Receiving Accounting Line Type
56715 , p_source_78 IN VARCHAR2
56716 --DISTRIBUTION_IDENTIFIER
56717 , p_source_84 IN NUMBER
56718 --Distribution Type
56719 , p_source_85 IN VARCHAR2
56720 , p_source_85_meaning IN VARCHAR2
56721 --Entered Amount
56722 , p_source_91 IN NUMBER
56723 --Accounted Amount
56724 , p_source_95 IN NUMBER
56725 --Entered Currency Code
56726 , p_source_105 IN VARCHAR2
56727 --Currency Conversion Date
56728 , p_source_106 IN DATE
56729 --Currency Conversion Rate
56730 , p_source_107 IN NUMBER
56731 )
56732 IS
56733
56734 l_component_type VARCHAR2(80);
56735 l_component_code VARCHAR2(30);
56736 l_component_type_code VARCHAR2(1);
56737 l_component_appl_id INTEGER;
56738 l_amb_context_code VARCHAR2(30);
56739 l_entity_code VARCHAR2(30);
56740 l_event_class_code VARCHAR2(30);
56741 l_ae_header_id NUMBER;
56742 l_event_type_code VARCHAR2(30);
56743 l_line_definition_code VARCHAR2(30);
56744 l_line_definition_owner_code VARCHAR2(1);
56745 --
56746 -- adr variables
56747 l_segment VARCHAR2(30);
56748 l_ccid NUMBER;
56749 l_adr_transaction_coa_id NUMBER;
56750 l_adr_accounting_coa_id NUMBER;
56751 l_adr_flexfield_segment_code VARCHAR2(30);
56752 l_adr_flex_value_set_id NUMBER;
56753 l_adr_value_type_code VARCHAR2(30);
56754 l_adr_value_combination_id NUMBER;
56755 l_adr_value_segment_code VARCHAR2(30);
56756
56757 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
56758 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
56759 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
56760 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
56761
56762 -- 4262811 Variables ------------------------------------------------------------------------------------------
56763 l_entered_amt_idx NUMBER;
56764 l_accted_amt_idx NUMBER;
56765 l_acc_rev_flag VARCHAR2(1);
56766 l_accrual_line_num NUMBER;
56767 l_tmp_amt NUMBER;
56768 l_acc_rev_natural_side_code VARCHAR2(1);
56769
56770 l_num_entries NUMBER;
56771 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
56772 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
56773 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
56774 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
56775 l_recog_line_1 NUMBER;
56776 l_recog_line_2 NUMBER;
56777
56778 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
56779 l_bflow_applied_to_amt NUMBER; -- 5132302
56780 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
56781
56782 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
56783
56784 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
56785 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
56786
56787 ---------------------------------------------------------------------------------------------------------------
56788
56789
56790 --
56791 -- bulk performance
56792 --
56793 l_balance_type_code VARCHAR2(1);
56794 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56795 l_log_module VARCHAR2(240);
56796
56797 --
56798 -- Upgrade strategy
56799 --
56800 l_actual_upg_option VARCHAR2(1);
56801 l_enc_upg_option VARCHAR2(1);
56802
56803 --
56804 BEGIN
56805 --
56806 IF g_log_enabled THEN
56807 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_125';
56808 END IF;
56809 --
56810 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56811
56812 trace
56813 (p_msg => 'BEGIN of AcctLineType_125'
56814 ,p_level => C_LEVEL_PROCEDURE
56815 ,p_module => l_log_module);
56816
56817 END IF;
56818 --
56819 l_component_type := 'AMB_JLT';
56820 l_component_code := 'EXPENSE';
56821 l_component_type_code := 'S';
56822 l_component_appl_id := 707;
56823 l_amb_context_code := 'DEFAULT';
56824 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
56825 l_event_class_code := 'LDD_COST_ADJ_DEL';
56826 l_event_type_code := 'LDD_COST_ADJ_DEL_ALL';
56827 l_line_definition_owner_code := 'S';
56828 l_line_definition_code := 'LDD_COST_ADJ_DEL';
56829 --
56830 l_balance_type_code := 'A';
56831 l_segment := NULL;
56832 l_ccid := NULL;
56833 l_adr_transaction_coa_id := NULL;
56834 l_adr_accounting_coa_id := NULL;
56835 l_adr_flexfield_segment_code := NULL;
56836 l_adr_flex_value_set_id := NULL;
56837 l_adr_value_type_code := NULL;
56838 l_adr_value_combination_id := NULL;
56839 l_adr_value_segment_code := NULL;
56840
56841 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
56842 l_bflow_class_code := ''; -- 4219869 Business Flow
56843 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
56844 l_budgetary_control_flag := 'N';
56845
56846 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56847 l_bflow_applied_to_amt := NULL; -- 5132302
56848 l_entered_amt_idx := NULL; -- 4262811
56849 l_accted_amt_idx := NULL; -- 4262811
56850 l_acc_rev_flag := NULL; -- 4262811
56851 l_accrual_line_num := NULL; -- 4262811
56852 l_tmp_amt := NULL; -- 4262811
56853 --
56854
56855 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
56856 l_balance_type_code <> 'B' THEN
56857 IF NVL(p_source_78,'
56858 ') = 'Expense'
56859 THEN
56860
56861 --
56862 XLA_AE_LINES_PKG.SetNewLine;
56863
56864 p_balance_type_code := l_balance_type_code;
56865 -- set the flag so later we will know whether the gain loss line needs to be created
56866
56867 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
56868 p_actual_flag :='A';
56869 END IF;
56870
56871 --
56872 -- bulk performance
56873 --
56874 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
56875 p_header_num => 0); -- 4262811
56876 --
56877 -- set accounting line options
56878 --
56879 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
56880 p_natural_side_code => 'D'
56881 , p_gain_or_loss_flag => 'N'
56882 , p_gl_transfer_mode_code => 'S'
56883 , p_acct_entry_type_code => 'A'
56884 , p_switch_side_flag => 'Y'
56885 , p_merge_duplicate_code => 'N'
56886 );
56887 --
56888 l_acc_rev_natural_side_code := 'C'; -- 4262811
56889 --
56890 --
56891 -- set accounting line type info
56892 --
56893 xla_ae_lines_pkg.SetAcctLineType
56894 (p_component_type => l_component_type
56895 ,p_event_type_code => l_event_type_code
56896 ,p_line_definition_owner_code => l_line_definition_owner_code
56897 ,p_line_definition_code => l_line_definition_code
56898 ,p_accounting_line_code => l_component_code
56899 ,p_accounting_line_type_code => l_component_type_code
56900 ,p_accounting_line_appl_id => l_component_appl_id
56901 ,p_amb_context_code => l_amb_context_code
56902 ,p_entity_code => l_entity_code
56903 ,p_event_class_code => l_event_class_code);
56904 --
56905 -- set accounting class
56906 --
56907 xla_ae_lines_pkg.SetAcctClass(
56908 p_accounting_class_code => 'EXPENSE'
56909 , p_ae_header_id => l_ae_header_id
56910 );
56911
56912 --
56913 -- set rounding class
56914 --
56915 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
56916 'EXPENSE';
56917
56918 --
56919 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56920 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56921 --
56922 -- bulk performance
56923 --
56924 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56925
56926 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56927 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56928
56929 -- 4955764
56930 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56931 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56932
56933 -- 4458381 Public Sector Enh
56934
56935 --
56936 -- set accounting attributes for the line type
56937 --
56938 l_entered_amt_idx := 3;
56939 l_accted_amt_idx := 7;
56940 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56941 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
56942 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
56943 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
56944 l_rec_acct_attrs.array_char_value(2) := p_source_85;
56945 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
56946 l_rec_acct_attrs.array_num_value(3) := p_source_91;
56947 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
56948 l_rec_acct_attrs.array_char_value(4) := p_source_105;
56949 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
56950 l_rec_acct_attrs.array_date_value(5) := p_source_106;
56951 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
56952 l_rec_acct_attrs.array_num_value(6) := p_source_107;
56953 l_rec_acct_attrs.array_acct_attr_code(7) := 'LEDGER_AMOUNT';
56954 l_rec_acct_attrs.array_num_value(7) := p_source_95;
56955
56956 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56957 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56958
56959 ---------------------------------------------------------------------------------------------------------------
56960 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56961 ---------------------------------------------------------------------------------------------------------------
56962 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56963
56964 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56965 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56966
56967 IF xla_accounting_cache_pkg.GetValueChar
56968 (p_source_code => 'LEDGER_CATEGORY_CODE'
56969 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56970 AND l_bflow_method_code = 'PRIOR_ENTRY'
56971 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56972 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56973 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56974 )
56975 THEN
56976 xla_ae_lines_pkg.BflowUpgEntry
56977 (p_business_method_code => l_bflow_method_code
56978 ,p_business_class_code => l_bflow_class_code
56979 ,p_balance_type => l_balance_type_code);
56980 ELSE
56981 NULL;
56982 -- No business flow processing for business flow method of NONE.
56983 END IF;
56984
56985 --
56986 -- call analytical criteria
56987 --
56988
56989 --
56990 -- call description
56991 --
56992 -- No description or it is inherited.
56993 --
56994 -- call ADRs
56995 -- Bug 4922099
56996 --
56997 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56998 (NVL(l_actual_upg_option, 'N') = 'O') OR
56999 (NVL(l_enc_upg_option, 'N') = 'O')
57000 )
57001 THEN
57002 NULL;
57003 --
57004 --
57005
57006 l_ccid := AcctDerRule_6(
57007 p_application_id => p_application_id
57008 , p_ae_header_id => l_ae_header_id
57009 , p_source_11 => p_source_11
57010 , x_transaction_coa_id => l_adr_transaction_coa_id
57011 , x_accounting_coa_id => l_adr_accounting_coa_id
57012 , x_value_type_code => l_adr_value_type_code
57013 , p_side => 'NA'
57014 );
57015
57016 xla_ae_lines_pkg.set_ccid(
57017 p_code_combination_id => l_ccid
57018 , p_value_type_code => l_adr_value_type_code
57019 , p_transaction_coa_id => l_adr_transaction_coa_id
57020 , p_accounting_coa_id => l_adr_accounting_coa_id
57021 , p_adr_code => 'CST_DEFAULT'
57022 , p_adr_type_code => 'S'
57023 , p_component_type => l_component_type
57024 , p_component_code => l_component_code
57025 , p_component_type_code => l_component_type_code
57026 , p_component_appl_id => l_component_appl_id
57027 , p_amb_context_code => l_amb_context_code
57028 , p_side => 'NA'
57029 );
57030
57031
57032 --
57033 --
57034 END IF;
57035 --
57036 -- Bug 4922099
57037 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57038 (NVL(l_enc_upg_option, 'N') = 'O')
57039 ) AND
57040 (l_bflow_method_code = 'PRIOR_ENTRY')
57041 )
57042 THEN
57043 IF
57044 --
57045 1 = 2
57046 --
57047 THEN
57048 xla_accounting_err_pkg.build_message
57049 (p_appli_s_name => 'XLA'
57050 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57051 ,p_token_1 => 'LINE_NUMBER'
57052 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57053 ,p_token_2 => 'LINE_TYPE_NAME'
57054 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57055 l_component_type
57056 ,l_component_code
57057 ,l_component_type_code
57058 ,l_component_appl_id
57059 ,l_amb_context_code
57060 ,l_entity_code
57061 ,l_event_class_code
57062 )
57063 ,p_token_3 => 'OWNER'
57064 ,p_value_3 => xla_lookups_pkg.get_meaning(
57065 p_lookup_type => 'XLA_OWNER_TYPE'
57066 ,p_lookup_code => l_component_type_code
57067 )
57068 ,p_token_4 => 'PRODUCT_NAME'
57069 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57070 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57071 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57072 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57073 ,p_ae_header_id => NULL
57074 );
57075
57076 IF (C_LEVEL_ERROR>= g_log_level) THEN
57077 trace
57078 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57079 ,p_level => C_LEVEL_ERROR
57080 ,p_module => l_log_module);
57081 END IF;
57082 END IF;
57083 END IF;
57084 --
57085 --
57086 ------------------------------------------------------------------------------------------------
57087 -- 4219869 Business Flow
57088 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57089 -- Prior Entry. Currently, the following code is always generated.
57090 ------------------------------------------------------------------------------------------------
57091 XLA_AE_LINES_PKG.ValidateCurrentLine;
57092
57093 ------------------------------------------------------------------------------------
57094 -- 4219869 Business Flow
57095 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57096 ------------------------------------------------------------------------------------
57097 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57098
57099 ----------------------------------------------------------------------------------
57100 -- 4219869 Business Flow
57101 -- Update journal entry status -- Need to generate this within IF <condition>
57102 ----------------------------------------------------------------------------------
57103 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57104 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57105 ,p_balance_type_code => l_balance_type_code
57106 );
57107
57108 -------------------------------------------------------------------------------------------
57109 -- 4262811 - Generate the Accrual Reversal lines
57110 -------------------------------------------------------------------------------------------
57111 BEGIN
57112 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
57113 (g_array_event(p_event_id).array_value_num('header_index'));
57114 IF l_acc_rev_flag IS NULL THEN
57115 l_acc_rev_flag := 'N';
57116 END IF;
57117 EXCEPTION
57118 WHEN OTHERS THEN
57119 l_acc_rev_flag := 'N';
57120 END;
57121 --
57122 IF (l_acc_rev_flag = 'Y') THEN
57123
57124 -- 4645092 ------------------------------------------------------------------------------
57125 -- To allow MPA report to determine if it should generate report process
57126 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
57127 ------------------------------------------------------------------------------------------
57128
57129 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
57130 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
57131 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
57132 -- call ADRs
57133 -- Bug 4922099
57134 --
57135 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57136 (NVL(l_actual_upg_option, 'N') = 'O') OR
57137 (NVL(l_enc_upg_option, 'N') = 'O')
57138 )
57139 THEN
57140 NULL;
57141 --
57142 --
57143
57144 l_ccid := AcctDerRule_6(
57145 p_application_id => p_application_id
57146 , p_ae_header_id => l_ae_header_id
57147 , p_source_11 => p_source_11
57148 , x_transaction_coa_id => l_adr_transaction_coa_id
57149 , x_accounting_coa_id => l_adr_accounting_coa_id
57150 , x_value_type_code => l_adr_value_type_code
57151 , p_side => 'NA'
57152 );
57153
57154 xla_ae_lines_pkg.set_ccid(
57155 p_code_combination_id => l_ccid
57156 , p_value_type_code => l_adr_value_type_code
57157 , p_transaction_coa_id => l_adr_transaction_coa_id
57158 , p_accounting_coa_id => l_adr_accounting_coa_id
57159 , p_adr_code => 'CST_DEFAULT'
57160 , p_adr_type_code => 'S'
57161 , p_component_type => l_component_type
57162 , p_component_code => l_component_code
57163 , p_component_type_code => l_component_type_code
57164 , p_component_appl_id => l_component_appl_id
57165 , p_amb_context_code => l_amb_context_code
57166 , p_side => 'NA'
57167 );
57168
57169
57170 --
57171 --
57172 END IF;
57173
57174 --
57175 -- Update the line information that should be overwritten
57176 --
57177 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
57178 p_header_num => 1);
57179 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
57180
57181 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
57182
57183 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
57184 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
57185 END IF;
57186
57187 --
57188 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
57189 --
57190 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
57191 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
57192 ELSE
57193 ---------------------------------------------------------------------------------------------------
57194 -- 4262811a Switch Sign
57195 ---------------------------------------------------------------------------------------------------
57196 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
57197 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57198 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57199 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57200 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57201 -- 5132302
57202 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
57203 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57204
57205 END IF;
57206
57207 -- 4955764
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('acc_rev_header_index'));
57210
57211
57212 XLA_AE_LINES_PKG.ValidateCurrentLine;
57213 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57214
57215 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57216 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
57217 ,p_balance_type_code => l_balance_type_code);
57218
57219 END IF;
57220
57221 -----------------------------------------------------------------------------------------
57222 -- 4262811 Multiperiod Accounting
57223 -----------------------------------------------------------------------------------------
57224 -- No MPA option is assigned.
57225
57226
57227 END IF;
57228 END IF;
57229 --
57230
57231 --
57232 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57233 trace
57234 (p_msg => 'END of AcctLineType_125'
57235 ,p_level => C_LEVEL_PROCEDURE
57236 ,p_module => l_log_module);
57237 END IF;
57238 --
57239 EXCEPTION
57240 WHEN xla_exceptions_pkg.application_exception THEN
57241 RAISE;
57242 WHEN OTHERS THEN
57243 xla_exceptions_pkg.raise_message
57244 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_125');
57245 END AcctLineType_125;
57246 --
57247
57248 ---------------------------------------
57249 --
57250 -- PRIVATE FUNCTION
57251 -- AcctLineType_126
57252 --
57253 ---------------------------------------
57254 PROCEDURE AcctLineType_126 (
57255 p_application_id IN NUMBER
57256 ,p_event_id IN NUMBER
57257 ,p_calculate_acctd_flag IN VARCHAR2
57258 ,p_calculate_g_l_flag IN VARCHAR2
57259 ,p_actual_flag IN OUT VARCHAR2
57260 ,p_balance_type_code OUT VARCHAR2
57261 ,p_gain_or_loss_ref OUT VARCHAR2
57262
57263 --TRANSACTION_ID
57264 , p_source_1 IN NUMBER
57265 --Item Concatenated Segments
57266 , p_source_2 IN VARCHAR2
57267 --Transaction Quantity
57268 , p_source_3 IN NUMBER
57269 --Transaction Unit of Measure Code
57270 , p_source_4 IN VARCHAR2
57271 --Inventory Transaction Type Description
57272 , p_source_5 IN VARCHAR2
57273 --Cost Management Default Account
57274 , p_source_11 IN NUMBER
57275 --DISTRIBUTION_IDENTIFIER
57276 , p_source_84 IN NUMBER
57277 --Distribution Type
57278 , p_source_85 IN VARCHAR2
57279 , p_source_85_meaning IN VARCHAR2
57280 --Entered Currency Code
57281 , p_source_88 IN VARCHAR2
57282 --Entered Amount
57283 , p_source_91 IN NUMBER
57284 --Currency Conversion Date
57285 , p_source_92 IN DATE
57286 --Currency Conversion Rate
57287 , p_source_93 IN NUMBER
57288 --Currency Conversion Type
57289 , p_source_94 IN VARCHAR2
57290 --Accounted Amount
57291 , p_source_95 IN NUMBER
57292 --Accounting Line Type
57293 , p_source_97 IN NUMBER
57294 )
57295 IS
57296
57297 l_component_type VARCHAR2(80);
57298 l_component_code VARCHAR2(30);
57299 l_component_type_code VARCHAR2(1);
57300 l_component_appl_id INTEGER;
57301 l_amb_context_code VARCHAR2(30);
57302 l_entity_code VARCHAR2(30);
57303 l_event_class_code VARCHAR2(30);
57304 l_ae_header_id NUMBER;
57305 l_event_type_code VARCHAR2(30);
57306 l_line_definition_code VARCHAR2(30);
57307 l_line_definition_owner_code VARCHAR2(1);
57308 --
57309 -- adr variables
57310 l_segment VARCHAR2(30);
57311 l_ccid NUMBER;
57312 l_adr_transaction_coa_id NUMBER;
57313 l_adr_accounting_coa_id NUMBER;
57314 l_adr_flexfield_segment_code VARCHAR2(30);
57315 l_adr_flex_value_set_id NUMBER;
57316 l_adr_value_type_code VARCHAR2(30);
57317 l_adr_value_combination_id NUMBER;
57318 l_adr_value_segment_code VARCHAR2(30);
57319
57320 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57321 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57322 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57323 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57324
57325 -- 4262811 Variables ------------------------------------------------------------------------------------------
57326 l_entered_amt_idx NUMBER;
57327 l_accted_amt_idx NUMBER;
57328 l_acc_rev_flag VARCHAR2(1);
57329 l_accrual_line_num NUMBER;
57330 l_tmp_amt NUMBER;
57331 l_acc_rev_natural_side_code VARCHAR2(1);
57332
57333 l_num_entries NUMBER;
57334 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57335 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57336 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57337 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57338 l_recog_line_1 NUMBER;
57339 l_recog_line_2 NUMBER;
57340
57341 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57342 l_bflow_applied_to_amt NUMBER; -- 5132302
57343 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57344
57345 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57346
57347 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
57348 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
57349
57350 ---------------------------------------------------------------------------------------------------------------
57351
57352
57353 --
57354 -- bulk performance
57355 --
57356 l_balance_type_code VARCHAR2(1);
57357 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57358 l_log_module VARCHAR2(240);
57359
57360 --
57361 -- Upgrade strategy
57362 --
57363 l_actual_upg_option VARCHAR2(1);
57364 l_enc_upg_option VARCHAR2(1);
57365
57366 --
57367 BEGIN
57368 --
57369 IF g_log_enabled THEN
57370 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_126';
57371 END IF;
57372 --
57373 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57374
57375 trace
57376 (p_msg => 'BEGIN of AcctLineType_126'
57377 ,p_level => C_LEVEL_PROCEDURE
57378 ,p_module => l_log_module);
57379
57380 END IF;
57381 --
57382 l_component_type := 'AMB_JLT';
57383 l_component_code := 'EXPENSE';
57384 l_component_type_code := 'S';
57385 l_component_appl_id := 707;
57386 l_amb_context_code := 'DEFAULT';
57387 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
57388 l_event_class_code := 'MTL_COST_UPD';
57389 l_event_type_code := 'AVG_COST_UPD';
57390 l_line_definition_owner_code := 'S';
57391 l_line_definition_code := 'PI_AVG_COST_UPD';
57392 --
57393 l_balance_type_code := 'A';
57394 l_segment := NULL;
57395 l_ccid := NULL;
57396 l_adr_transaction_coa_id := NULL;
57397 l_adr_accounting_coa_id := NULL;
57398 l_adr_flexfield_segment_code := NULL;
57399 l_adr_flex_value_set_id := NULL;
57400 l_adr_value_type_code := NULL;
57401 l_adr_value_combination_id := NULL;
57402 l_adr_value_segment_code := NULL;
57403
57404 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
57405 l_bflow_class_code := ''; -- 4219869 Business Flow
57406 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
57407 l_budgetary_control_flag := 'N';
57408
57409 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57410 l_bflow_applied_to_amt := NULL; -- 5132302
57411 l_entered_amt_idx := NULL; -- 4262811
57412 l_accted_amt_idx := NULL; -- 4262811
57413 l_acc_rev_flag := NULL; -- 4262811
57414 l_accrual_line_num := NULL; -- 4262811
57415 l_tmp_amt := NULL; -- 4262811
57416 --
57417
57418 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
57419 l_balance_type_code <> 'B' THEN
57420 IF NVL(p_source_97,9E125) = 20
57421 THEN
57422
57423 --
57424 XLA_AE_LINES_PKG.SetNewLine;
57425
57426 p_balance_type_code := l_balance_type_code;
57427 -- set the flag so later we will know whether the gain loss line needs to be created
57428
57429 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
57430 p_actual_flag :='A';
57431 END IF;
57432
57433 --
57434 -- bulk performance
57435 --
57436 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
57437 p_header_num => 0); -- 4262811
57438 --
57439 -- set accounting line options
57440 --
57441 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
57442 p_natural_side_code => 'D'
57443 , p_gain_or_loss_flag => 'N'
57444 , p_gl_transfer_mode_code => 'S'
57445 , p_acct_entry_type_code => 'A'
57446 , p_switch_side_flag => 'Y'
57447 , p_merge_duplicate_code => 'N'
57448 );
57449 --
57450 l_acc_rev_natural_side_code := 'C'; -- 4262811
57451 --
57452 --
57453 -- set accounting line type info
57454 --
57455 xla_ae_lines_pkg.SetAcctLineType
57456 (p_component_type => l_component_type
57457 ,p_event_type_code => l_event_type_code
57458 ,p_line_definition_owner_code => l_line_definition_owner_code
57459 ,p_line_definition_code => l_line_definition_code
57460 ,p_accounting_line_code => l_component_code
57461 ,p_accounting_line_type_code => l_component_type_code
57462 ,p_accounting_line_appl_id => l_component_appl_id
57463 ,p_amb_context_code => l_amb_context_code
57464 ,p_entity_code => l_entity_code
57465 ,p_event_class_code => l_event_class_code);
57466 --
57467 -- set accounting class
57468 --
57469 xla_ae_lines_pkg.SetAcctClass(
57470 p_accounting_class_code => 'EXPENSE'
57471 , p_ae_header_id => l_ae_header_id
57472 );
57473
57474 --
57475 -- set rounding class
57476 --
57477 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
57478 'EXPENSE';
57479
57480 --
57481 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
57482 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
57483 --
57484 -- bulk performance
57485 --
57486 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
57487
57488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
57489 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
57490
57491 -- 4955764
57492 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57493 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
57494
57495 -- 4458381 Public Sector Enh
57496
57497 --
57498 -- set accounting attributes for the line type
57499 --
57500 l_entered_amt_idx := 3;
57501 l_accted_amt_idx := 8;
57502 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57503 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
57504 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
57505 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
57506 l_rec_acct_attrs.array_char_value(2) := p_source_85;
57507 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
57508 l_rec_acct_attrs.array_num_value(3) := p_source_91;
57509 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
57510 l_rec_acct_attrs.array_char_value(4) := p_source_88;
57511 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
57512 l_rec_acct_attrs.array_date_value(5) := p_source_92;
57513 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
57514 l_rec_acct_attrs.array_num_value(6) := p_source_93;
57515 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
57516 l_rec_acct_attrs.array_char_value(7) := p_source_94;
57517 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
57518 l_rec_acct_attrs.array_num_value(8) := p_source_95;
57519
57520 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
57521 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
57522
57523 ---------------------------------------------------------------------------------------------------------------
57524 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
57525 ---------------------------------------------------------------------------------------------------------------
57526 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
57527
57528 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57529 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57530
57531 IF xla_accounting_cache_pkg.GetValueChar
57532 (p_source_code => 'LEDGER_CATEGORY_CODE'
57533 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
57534 AND l_bflow_method_code = 'PRIOR_ENTRY'
57535 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
57536 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
57537 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
57538 )
57539 THEN
57540 xla_ae_lines_pkg.BflowUpgEntry
57541 (p_business_method_code => l_bflow_method_code
57542 ,p_business_class_code => l_bflow_class_code
57543 ,p_balance_type => l_balance_type_code);
57544 ELSE
57545 NULL;
57546 -- No business flow processing for business flow method of NONE.
57547 END IF;
57548
57549 --
57550 -- call analytical criteria
57551 --
57552
57553 --
57554 -- call description
57555 --
57556
57557 xla_ae_lines_pkg.SetLineDescription(
57558 p_ae_header_id => l_ae_header_id
57559 ,p_description => Description_1 (
57560 p_application_id => p_application_id
57561 , p_ae_header_id => l_ae_header_id
57562 , p_source_1 => p_source_1
57563 , p_source_2 => p_source_2
57564 , p_source_3 => p_source_3
57565 , p_source_4 => p_source_4
57566 , p_source_5 => p_source_5
57567 )
57568 );
57569
57570
57571 --
57572 -- call ADRs
57573 -- Bug 4922099
57574 --
57575 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57576 (NVL(l_actual_upg_option, 'N') = 'O') OR
57577 (NVL(l_enc_upg_option, 'N') = 'O')
57578 )
57579 THEN
57580 NULL;
57581 --
57582 --
57583
57584 l_ccid := AcctDerRule_6(
57585 p_application_id => p_application_id
57586 , p_ae_header_id => l_ae_header_id
57587 , p_source_11 => p_source_11
57588 , x_transaction_coa_id => l_adr_transaction_coa_id
57589 , x_accounting_coa_id => l_adr_accounting_coa_id
57590 , x_value_type_code => l_adr_value_type_code
57591 , p_side => 'NA'
57592 );
57593
57594 xla_ae_lines_pkg.set_ccid(
57595 p_code_combination_id => l_ccid
57596 , p_value_type_code => l_adr_value_type_code
57597 , p_transaction_coa_id => l_adr_transaction_coa_id
57598 , p_accounting_coa_id => l_adr_accounting_coa_id
57599 , p_adr_code => 'CST_DEFAULT'
57600 , p_adr_type_code => 'S'
57601 , p_component_type => l_component_type
57602 , p_component_code => l_component_code
57603 , p_component_type_code => l_component_type_code
57604 , p_component_appl_id => l_component_appl_id
57605 , p_amb_context_code => l_amb_context_code
57606 , p_side => 'NA'
57607 );
57608
57609
57610 --
57611 --
57612 END IF;
57613 --
57614 -- Bug 4922099
57615 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57616 (NVL(l_enc_upg_option, 'N') = 'O')
57617 ) AND
57618 (l_bflow_method_code = 'PRIOR_ENTRY')
57619 )
57620 THEN
57621 IF
57622 --
57623 1 = 2
57624 --
57625 THEN
57626 xla_accounting_err_pkg.build_message
57627 (p_appli_s_name => 'XLA'
57628 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57629 ,p_token_1 => 'LINE_NUMBER'
57630 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57631 ,p_token_2 => 'LINE_TYPE_NAME'
57632 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57633 l_component_type
57634 ,l_component_code
57635 ,l_component_type_code
57636 ,l_component_appl_id
57637 ,l_amb_context_code
57638 ,l_entity_code
57639 ,l_event_class_code
57640 )
57641 ,p_token_3 => 'OWNER'
57642 ,p_value_3 => xla_lookups_pkg.get_meaning(
57643 p_lookup_type => 'XLA_OWNER_TYPE'
57644 ,p_lookup_code => l_component_type_code
57645 )
57646 ,p_token_4 => 'PRODUCT_NAME'
57647 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57648 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57649 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57650 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57651 ,p_ae_header_id => NULL
57652 );
57653
57654 IF (C_LEVEL_ERROR>= g_log_level) THEN
57655 trace
57656 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57657 ,p_level => C_LEVEL_ERROR
57658 ,p_module => l_log_module);
57659 END IF;
57660 END IF;
57661 END IF;
57662 --
57663 --
57664 ------------------------------------------------------------------------------------------------
57665 -- 4219869 Business Flow
57666 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57667 -- Prior Entry. Currently, the following code is always generated.
57668 ------------------------------------------------------------------------------------------------
57669 XLA_AE_LINES_PKG.ValidateCurrentLine;
57670
57671 ------------------------------------------------------------------------------------
57672 -- 4219869 Business Flow
57673 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57674 ------------------------------------------------------------------------------------
57675 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57676
57677 ----------------------------------------------------------------------------------
57678 -- 4219869 Business Flow
57679 -- Update journal entry status -- Need to generate this within IF <condition>
57680 ----------------------------------------------------------------------------------
57681 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57682 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57683 ,p_balance_type_code => l_balance_type_code
57684 );
57685
57686 -------------------------------------------------------------------------------------------
57687 -- 4262811 - Generate the Accrual Reversal lines
57688 -------------------------------------------------------------------------------------------
57689 BEGIN
57690 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
57691 (g_array_event(p_event_id).array_value_num('header_index'));
57692 IF l_acc_rev_flag IS NULL THEN
57693 l_acc_rev_flag := 'N';
57694 END IF;
57695 EXCEPTION
57696 WHEN OTHERS THEN
57697 l_acc_rev_flag := 'N';
57698 END;
57699 --
57700 IF (l_acc_rev_flag = 'Y') THEN
57701
57702 -- 4645092 ------------------------------------------------------------------------------
57703 -- To allow MPA report to determine if it should generate report process
57704 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
57705 ------------------------------------------------------------------------------------------
57706
57707 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
57708 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
57709 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
57710 -- call ADRs
57711 -- Bug 4922099
57712 --
57713 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57714 (NVL(l_actual_upg_option, 'N') = 'O') OR
57715 (NVL(l_enc_upg_option, 'N') = 'O')
57716 )
57717 THEN
57718 NULL;
57719 --
57720 --
57721
57722 l_ccid := AcctDerRule_6(
57723 p_application_id => p_application_id
57724 , p_ae_header_id => l_ae_header_id
57725 , p_source_11 => p_source_11
57726 , x_transaction_coa_id => l_adr_transaction_coa_id
57727 , x_accounting_coa_id => l_adr_accounting_coa_id
57728 , x_value_type_code => l_adr_value_type_code
57729 , p_side => 'NA'
57730 );
57731
57732 xla_ae_lines_pkg.set_ccid(
57733 p_code_combination_id => l_ccid
57734 , p_value_type_code => l_adr_value_type_code
57735 , p_transaction_coa_id => l_adr_transaction_coa_id
57736 , p_accounting_coa_id => l_adr_accounting_coa_id
57737 , p_adr_code => 'CST_DEFAULT'
57738 , p_adr_type_code => 'S'
57739 , p_component_type => l_component_type
57740 , p_component_code => l_component_code
57741 , p_component_type_code => l_component_type_code
57742 , p_component_appl_id => l_component_appl_id
57743 , p_amb_context_code => l_amb_context_code
57744 , p_side => 'NA'
57745 );
57746
57747
57748 --
57749 --
57750 END IF;
57751
57752 --
57753 -- Update the line information that should be overwritten
57754 --
57755 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
57756 p_header_num => 1);
57757 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
57758
57759 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
57760
57761 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
57762 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
57763 END IF;
57764
57765 --
57766 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
57767 --
57768 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
57769 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
57770 ELSE
57771 ---------------------------------------------------------------------------------------------------
57772 -- 4262811a Switch Sign
57773 ---------------------------------------------------------------------------------------------------
57774 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
57775 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57776 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57777 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57778 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57779 -- 5132302
57780 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
57781 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57782
57783 END IF;
57784
57785 -- 4955764
57786 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57787 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
57788
57789
57790 XLA_AE_LINES_PKG.ValidateCurrentLine;
57791 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57792
57793 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57794 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
57795 ,p_balance_type_code => l_balance_type_code);
57796
57797 END IF;
57798
57799 -----------------------------------------------------------------------------------------
57800 -- 4262811 Multiperiod Accounting
57801 -----------------------------------------------------------------------------------------
57802 -- No MPA option is assigned.
57803
57804
57805 END IF;
57806 END IF;
57807 --
57808
57809 --
57810 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57811 trace
57812 (p_msg => 'END of AcctLineType_126'
57813 ,p_level => C_LEVEL_PROCEDURE
57814 ,p_module => l_log_module);
57815 END IF;
57816 --
57817 EXCEPTION
57818 WHEN xla_exceptions_pkg.application_exception THEN
57819 RAISE;
57820 WHEN OTHERS THEN
57821 xla_exceptions_pkg.raise_message
57822 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_126');
57823 END AcctLineType_126;
57824 --
57825
57826 ---------------------------------------
57827 --
57828 -- PRIVATE FUNCTION
57829 -- AcctLineType_127
57830 --
57831 ---------------------------------------
57832 PROCEDURE AcctLineType_127 (
57833 p_application_id IN NUMBER
57834 ,p_event_id IN NUMBER
57835 ,p_calculate_acctd_flag IN VARCHAR2
57836 ,p_calculate_g_l_flag IN VARCHAR2
57837 ,p_actual_flag IN OUT VARCHAR2
57838 ,p_balance_type_code OUT VARCHAR2
57839 ,p_gain_or_loss_ref OUT VARCHAR2
57840
57841 --TRANSACTION_ID
57842 , p_source_1 IN NUMBER
57843 --Item Concatenated Segments
57844 , p_source_2 IN VARCHAR2
57845 --Transaction Quantity
57846 , p_source_3 IN NUMBER
57847 --Transaction Unit of Measure Code
57848 , p_source_4 IN VARCHAR2
57849 --Inventory Transaction Type Description
57850 , p_source_5 IN VARCHAR2
57851 --Cost Management Default Account
57852 , p_source_11 IN NUMBER
57853 --DISTRIBUTION_IDENTIFIER
57854 , p_source_84 IN NUMBER
57855 --Distribution Type
57856 , p_source_85 IN VARCHAR2
57857 , p_source_85_meaning IN VARCHAR2
57858 --Entered Currency Code
57859 , p_source_88 IN VARCHAR2
57860 --Entered Amount
57861 , p_source_91 IN NUMBER
57862 --Currency Conversion Date
57863 , p_source_92 IN DATE
57864 --Currency Conversion Rate
57865 , p_source_93 IN NUMBER
57866 --Currency Conversion Type
57867 , p_source_94 IN VARCHAR2
57868 --Accounted Amount
57869 , p_source_95 IN NUMBER
57870 --Accounting Line Type
57871 , p_source_97 IN NUMBER
57872 )
57873 IS
57874
57875 l_component_type VARCHAR2(80);
57876 l_component_code VARCHAR2(30);
57877 l_component_type_code VARCHAR2(1);
57878 l_component_appl_id INTEGER;
57879 l_amb_context_code VARCHAR2(30);
57880 l_entity_code VARCHAR2(30);
57881 l_event_class_code VARCHAR2(30);
57882 l_ae_header_id NUMBER;
57883 l_event_type_code VARCHAR2(30);
57884 l_line_definition_code VARCHAR2(30);
57885 l_line_definition_owner_code VARCHAR2(1);
57886 --
57887 -- adr variables
57888 l_segment VARCHAR2(30);
57889 l_ccid NUMBER;
57890 l_adr_transaction_coa_id NUMBER;
57891 l_adr_accounting_coa_id NUMBER;
57892 l_adr_flexfield_segment_code VARCHAR2(30);
57893 l_adr_flex_value_set_id NUMBER;
57894 l_adr_value_type_code VARCHAR2(30);
57895 l_adr_value_combination_id NUMBER;
57896 l_adr_value_segment_code VARCHAR2(30);
57897
57898 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57899 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57900 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57901 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57902
57903 -- 4262811 Variables ------------------------------------------------------------------------------------------
57904 l_entered_amt_idx NUMBER;
57905 l_accted_amt_idx NUMBER;
57906 l_acc_rev_flag VARCHAR2(1);
57907 l_accrual_line_num NUMBER;
57908 l_tmp_amt NUMBER;
57909 l_acc_rev_natural_side_code VARCHAR2(1);
57910
57911 l_num_entries NUMBER;
57912 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57913 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57914 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57915 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57916 l_recog_line_1 NUMBER;
57917 l_recog_line_2 NUMBER;
57918
57919 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57920 l_bflow_applied_to_amt NUMBER; -- 5132302
57921 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57922
57923 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57924
57925 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
57926 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
57927
57928 ---------------------------------------------------------------------------------------------------------------
57929
57930
57931 --
57932 -- bulk performance
57933 --
57934 l_balance_type_code VARCHAR2(1);
57935 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57936 l_log_module VARCHAR2(240);
57937
57938 --
57939 -- Upgrade strategy
57940 --
57941 l_actual_upg_option VARCHAR2(1);
57942 l_enc_upg_option VARCHAR2(1);
57943
57944 --
57945 BEGIN
57946 --
57947 IF g_log_enabled THEN
57948 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_127';
57949 END IF;
57950 --
57951 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57952
57953 trace
57954 (p_msg => 'BEGIN of AcctLineType_127'
57955 ,p_level => C_LEVEL_PROCEDURE
57956 ,p_module => l_log_module);
57957
57958 END IF;
57959 --
57960 l_component_type := 'AMB_JLT';
57961 l_component_code := 'EXPENSE';
57962 l_component_type_code := 'S';
57963 l_component_appl_id := 707;
57964 l_amb_context_code := 'DEFAULT';
57965 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
57966 l_event_class_code := 'MTL_COST_UPD';
57967 l_event_type_code := 'LAYER_COST_UPD';
57968 l_line_definition_owner_code := 'S';
57969 l_line_definition_code := 'PI_LAYER_COST_UPDATE';
57970 --
57971 l_balance_type_code := 'A';
57972 l_segment := NULL;
57973 l_ccid := NULL;
57974 l_adr_transaction_coa_id := NULL;
57975 l_adr_accounting_coa_id := NULL;
57976 l_adr_flexfield_segment_code := NULL;
57977 l_adr_flex_value_set_id := NULL;
57978 l_adr_value_type_code := NULL;
57979 l_adr_value_combination_id := NULL;
57980 l_adr_value_segment_code := NULL;
57981
57982 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
57983 l_bflow_class_code := ''; -- 4219869 Business Flow
57984 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
57985 l_budgetary_control_flag := 'N';
57986
57987 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57988 l_bflow_applied_to_amt := NULL; -- 5132302
57989 l_entered_amt_idx := NULL; -- 4262811
57990 l_accted_amt_idx := NULL; -- 4262811
57991 l_acc_rev_flag := NULL; -- 4262811
57992 l_accrual_line_num := NULL; -- 4262811
57993 l_tmp_amt := NULL; -- 4262811
57994 --
57995
57996 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
57997 l_balance_type_code <> 'B' THEN
57998 IF NVL(p_source_97,9E125) = 20
57999 THEN
58000
58001 --
58002 XLA_AE_LINES_PKG.SetNewLine;
58003
58004 p_balance_type_code := l_balance_type_code;
58005 -- set the flag so later we will know whether the gain loss line needs to be created
58006
58007 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
58008 p_actual_flag :='A';
58009 END IF;
58010
58011 --
58012 -- bulk performance
58013 --
58014 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58015 p_header_num => 0); -- 4262811
58016 --
58017 -- set accounting line options
58018 --
58019 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58020 p_natural_side_code => 'D'
58021 , p_gain_or_loss_flag => 'N'
58022 , p_gl_transfer_mode_code => 'S'
58023 , p_acct_entry_type_code => 'A'
58024 , p_switch_side_flag => 'Y'
58025 , p_merge_duplicate_code => 'N'
58026 );
58027 --
58028 l_acc_rev_natural_side_code := 'C'; -- 4262811
58029 --
58030 --
58031 -- set accounting line type info
58032 --
58033 xla_ae_lines_pkg.SetAcctLineType
58034 (p_component_type => l_component_type
58035 ,p_event_type_code => l_event_type_code
58036 ,p_line_definition_owner_code => l_line_definition_owner_code
58037 ,p_line_definition_code => l_line_definition_code
58038 ,p_accounting_line_code => l_component_code
58039 ,p_accounting_line_type_code => l_component_type_code
58040 ,p_accounting_line_appl_id => l_component_appl_id
58041 ,p_amb_context_code => l_amb_context_code
58042 ,p_entity_code => l_entity_code
58043 ,p_event_class_code => l_event_class_code);
58044 --
58045 -- set accounting class
58046 --
58047 xla_ae_lines_pkg.SetAcctClass(
58048 p_accounting_class_code => 'EXPENSE'
58049 , p_ae_header_id => l_ae_header_id
58050 );
58051
58052 --
58053 -- set rounding class
58054 --
58055 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58056 'EXPENSE';
58057
58058 --
58059 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58060 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58061 --
58062 -- bulk performance
58063 --
58064 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58065
58066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58067 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58068
58069 -- 4955764
58070 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58071 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58072
58073 -- 4458381 Public Sector Enh
58074
58075 --
58076 -- set accounting attributes for the line type
58077 --
58078 l_entered_amt_idx := 3;
58079 l_accted_amt_idx := 8;
58080 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58081 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
58082 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
58083 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
58084 l_rec_acct_attrs.array_char_value(2) := p_source_85;
58085 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
58086 l_rec_acct_attrs.array_num_value(3) := p_source_91;
58087 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
58088 l_rec_acct_attrs.array_char_value(4) := p_source_88;
58089 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
58090 l_rec_acct_attrs.array_date_value(5) := p_source_92;
58091 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
58092 l_rec_acct_attrs.array_num_value(6) := p_source_93;
58093 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
58094 l_rec_acct_attrs.array_char_value(7) := p_source_94;
58095 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
58096 l_rec_acct_attrs.array_num_value(8) := p_source_95;
58097
58098 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
58099 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
58100
58101 ---------------------------------------------------------------------------------------------------------------
58102 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
58103 ---------------------------------------------------------------------------------------------------------------
58104 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
58105
58106 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58107 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58108
58109 IF xla_accounting_cache_pkg.GetValueChar
58110 (p_source_code => 'LEDGER_CATEGORY_CODE'
58111 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
58112 AND l_bflow_method_code = 'PRIOR_ENTRY'
58113 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
58114 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
58115 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
58116 )
58117 THEN
58118 xla_ae_lines_pkg.BflowUpgEntry
58119 (p_business_method_code => l_bflow_method_code
58120 ,p_business_class_code => l_bflow_class_code
58121 ,p_balance_type => l_balance_type_code);
58122 ELSE
58123 NULL;
58124 -- No business flow processing for business flow method of NONE.
58125 END IF;
58126
58127 --
58128 -- call analytical criteria
58129 --
58130
58131 --
58132 -- call description
58133 --
58134
58135 xla_ae_lines_pkg.SetLineDescription(
58136 p_ae_header_id => l_ae_header_id
58137 ,p_description => Description_1 (
58138 p_application_id => p_application_id
58139 , p_ae_header_id => l_ae_header_id
58140 , p_source_1 => p_source_1
58141 , p_source_2 => p_source_2
58142 , p_source_3 => p_source_3
58143 , p_source_4 => p_source_4
58144 , p_source_5 => p_source_5
58145 )
58146 );
58147
58148
58149 --
58150 -- call ADRs
58151 -- Bug 4922099
58152 --
58153 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58154 (NVL(l_actual_upg_option, 'N') = 'O') OR
58155 (NVL(l_enc_upg_option, 'N') = 'O')
58156 )
58157 THEN
58158 NULL;
58159 --
58160 --
58161
58162 l_ccid := AcctDerRule_6(
58163 p_application_id => p_application_id
58164 , p_ae_header_id => l_ae_header_id
58165 , p_source_11 => p_source_11
58166 , x_transaction_coa_id => l_adr_transaction_coa_id
58167 , x_accounting_coa_id => l_adr_accounting_coa_id
58168 , x_value_type_code => l_adr_value_type_code
58169 , p_side => 'NA'
58170 );
58171
58172 xla_ae_lines_pkg.set_ccid(
58173 p_code_combination_id => l_ccid
58174 , p_value_type_code => l_adr_value_type_code
58175 , p_transaction_coa_id => l_adr_transaction_coa_id
58176 , p_accounting_coa_id => l_adr_accounting_coa_id
58177 , p_adr_code => 'CST_DEFAULT'
58178 , p_adr_type_code => 'S'
58179 , p_component_type => l_component_type
58180 , p_component_code => l_component_code
58181 , p_component_type_code => l_component_type_code
58182 , p_component_appl_id => l_component_appl_id
58183 , p_amb_context_code => l_amb_context_code
58184 , p_side => 'NA'
58185 );
58186
58187
58188 --
58189 --
58190 END IF;
58191 --
58192 -- Bug 4922099
58193 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
58194 (NVL(l_enc_upg_option, 'N') = 'O')
58195 ) AND
58196 (l_bflow_method_code = 'PRIOR_ENTRY')
58197 )
58198 THEN
58199 IF
58200 --
58201 1 = 2
58202 --
58203 THEN
58204 xla_accounting_err_pkg.build_message
58205 (p_appli_s_name => 'XLA'
58206 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58207 ,p_token_1 => 'LINE_NUMBER'
58208 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
58209 ,p_token_2 => 'LINE_TYPE_NAME'
58210 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
58211 l_component_type
58212 ,l_component_code
58213 ,l_component_type_code
58214 ,l_component_appl_id
58215 ,l_amb_context_code
58216 ,l_entity_code
58217 ,l_event_class_code
58218 )
58219 ,p_token_3 => 'OWNER'
58220 ,p_value_3 => xla_lookups_pkg.get_meaning(
58221 p_lookup_type => 'XLA_OWNER_TYPE'
58222 ,p_lookup_code => l_component_type_code
58223 )
58224 ,p_token_4 => 'PRODUCT_NAME'
58225 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
58226 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
58227 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
58228 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
58229 ,p_ae_header_id => NULL
58230 );
58231
58232 IF (C_LEVEL_ERROR>= g_log_level) THEN
58233 trace
58234 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58235 ,p_level => C_LEVEL_ERROR
58236 ,p_module => l_log_module);
58237 END IF;
58238 END IF;
58239 END IF;
58240 --
58241 --
58242 ------------------------------------------------------------------------------------------------
58243 -- 4219869 Business Flow
58244 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
58245 -- Prior Entry. Currently, the following code is always generated.
58246 ------------------------------------------------------------------------------------------------
58247 XLA_AE_LINES_PKG.ValidateCurrentLine;
58248
58249 ------------------------------------------------------------------------------------
58250 -- 4219869 Business Flow
58251 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
58252 ------------------------------------------------------------------------------------
58253 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58254
58255 ----------------------------------------------------------------------------------
58256 -- 4219869 Business Flow
58257 -- Update journal entry status -- Need to generate this within IF <condition>
58258 ----------------------------------------------------------------------------------
58259 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58260 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
58261 ,p_balance_type_code => l_balance_type_code
58262 );
58263
58264 -------------------------------------------------------------------------------------------
58265 -- 4262811 - Generate the Accrual Reversal lines
58266 -------------------------------------------------------------------------------------------
58267 BEGIN
58268 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58269 (g_array_event(p_event_id).array_value_num('header_index'));
58270 IF l_acc_rev_flag IS NULL THEN
58271 l_acc_rev_flag := 'N';
58272 END IF;
58273 EXCEPTION
58274 WHEN OTHERS THEN
58275 l_acc_rev_flag := 'N';
58276 END;
58277 --
58278 IF (l_acc_rev_flag = 'Y') THEN
58279
58280 -- 4645092 ------------------------------------------------------------------------------
58281 -- To allow MPA report to determine if it should generate report process
58282 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58283 ------------------------------------------------------------------------------------------
58284
58285 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58286 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58287 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58288 -- call ADRs
58289 -- Bug 4922099
58290 --
58291 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58292 (NVL(l_actual_upg_option, 'N') = 'O') OR
58293 (NVL(l_enc_upg_option, 'N') = 'O')
58294 )
58295 THEN
58296 NULL;
58297 --
58298 --
58299
58300 l_ccid := AcctDerRule_6(
58301 p_application_id => p_application_id
58302 , p_ae_header_id => l_ae_header_id
58303 , p_source_11 => p_source_11
58304 , x_transaction_coa_id => l_adr_transaction_coa_id
58305 , x_accounting_coa_id => l_adr_accounting_coa_id
58306 , x_value_type_code => l_adr_value_type_code
58307 , p_side => 'NA'
58308 );
58309
58310 xla_ae_lines_pkg.set_ccid(
58311 p_code_combination_id => l_ccid
58312 , p_value_type_code => l_adr_value_type_code
58313 , p_transaction_coa_id => l_adr_transaction_coa_id
58314 , p_accounting_coa_id => l_adr_accounting_coa_id
58315 , p_adr_code => 'CST_DEFAULT'
58316 , p_adr_type_code => 'S'
58317 , p_component_type => l_component_type
58318 , p_component_code => l_component_code
58319 , p_component_type_code => l_component_type_code
58320 , p_component_appl_id => l_component_appl_id
58321 , p_amb_context_code => l_amb_context_code
58322 , p_side => 'NA'
58323 );
58324
58325
58326 --
58327 --
58328 END IF;
58329
58330 --
58331 -- Update the line information that should be overwritten
58332 --
58333 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
58334 p_header_num => 1);
58335 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
58336
58337 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
58338
58339 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
58340 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
58341 END IF;
58342
58343 --
58344 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
58345 --
58346 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
58347 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
58348 ELSE
58349 ---------------------------------------------------------------------------------------------------
58350 -- 4262811a Switch Sign
58351 ---------------------------------------------------------------------------------------------------
58352 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
58353 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58354 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58355 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58356 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58357 -- 5132302
58358 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
58359 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58360
58361 END IF;
58362
58363 -- 4955764
58364 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58365 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
58366
58367
58368 XLA_AE_LINES_PKG.ValidateCurrentLine;
58369 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58370
58371 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58372 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
58373 ,p_balance_type_code => l_balance_type_code);
58374
58375 END IF;
58376
58377 -----------------------------------------------------------------------------------------
58378 -- 4262811 Multiperiod Accounting
58379 -----------------------------------------------------------------------------------------
58380 -- No MPA option is assigned.
58381
58382
58383 END IF;
58384 END IF;
58385 --
58386
58387 --
58388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58389 trace
58390 (p_msg => 'END of AcctLineType_127'
58391 ,p_level => C_LEVEL_PROCEDURE
58392 ,p_module => l_log_module);
58393 END IF;
58394 --
58395 EXCEPTION
58396 WHEN xla_exceptions_pkg.application_exception THEN
58397 RAISE;
58398 WHEN OTHERS THEN
58399 xla_exceptions_pkg.raise_message
58400 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_127');
58401 END AcctLineType_127;
58402 --
58403
58404 ---------------------------------------
58405 --
58406 -- PRIVATE FUNCTION
58407 -- AcctLineType_128
58408 --
58409 ---------------------------------------
58410 PROCEDURE AcctLineType_128 (
58411 p_application_id IN NUMBER
58412 ,p_event_id IN NUMBER
58413 ,p_calculate_acctd_flag IN VARCHAR2
58414 ,p_calculate_g_l_flag IN VARCHAR2
58415 ,p_actual_flag IN OUT VARCHAR2
58416 ,p_balance_type_code OUT VARCHAR2
58417 ,p_gain_or_loss_ref OUT VARCHAR2
58418
58419 --TRANSACTION_ID
58420 , p_source_1 IN NUMBER
58421 --Item Concatenated Segments
58422 , p_source_2 IN VARCHAR2
58423 --Transaction Quantity
58424 , p_source_3 IN NUMBER
58425 --Transaction Unit of Measure Code
58426 , p_source_4 IN VARCHAR2
58427 --Inventory Transaction Type Description
58428 , p_source_5 IN VARCHAR2
58429 --Cost Management Default Account
58430 , p_source_11 IN NUMBER
58431 --DISTRIBUTION_IDENTIFIER
58432 , p_source_84 IN NUMBER
58433 --Distribution Type
58434 , p_source_85 IN VARCHAR2
58435 , p_source_85_meaning IN VARCHAR2
58436 --Entered Currency Code
58437 , p_source_88 IN VARCHAR2
58438 --Entered Amount
58439 , p_source_91 IN NUMBER
58440 --Currency Conversion Date
58441 , p_source_92 IN DATE
58442 --Currency Conversion Rate
58443 , p_source_93 IN NUMBER
58444 --Currency Conversion Type
58445 , p_source_94 IN VARCHAR2
58446 --Accounted Amount
58447 , p_source_95 IN NUMBER
58448 --Accounting Line Type
58449 , p_source_97 IN NUMBER
58450 )
58451 IS
58452
58453 l_component_type VARCHAR2(80);
58454 l_component_code VARCHAR2(30);
58455 l_component_type_code VARCHAR2(1);
58456 l_component_appl_id INTEGER;
58457 l_amb_context_code VARCHAR2(30);
58458 l_entity_code VARCHAR2(30);
58459 l_event_class_code VARCHAR2(30);
58460 l_ae_header_id NUMBER;
58461 l_event_type_code VARCHAR2(30);
58462 l_line_definition_code VARCHAR2(30);
58463 l_line_definition_owner_code VARCHAR2(1);
58464 --
58465 -- adr variables
58466 l_segment VARCHAR2(30);
58467 l_ccid NUMBER;
58468 l_adr_transaction_coa_id NUMBER;
58469 l_adr_accounting_coa_id NUMBER;
58470 l_adr_flexfield_segment_code VARCHAR2(30);
58471 l_adr_flex_value_set_id NUMBER;
58472 l_adr_value_type_code VARCHAR2(30);
58473 l_adr_value_combination_id NUMBER;
58474 l_adr_value_segment_code VARCHAR2(30);
58475
58476 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
58477 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
58478 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
58479 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
58480
58481 -- 4262811 Variables ------------------------------------------------------------------------------------------
58482 l_entered_amt_idx NUMBER;
58483 l_accted_amt_idx NUMBER;
58484 l_acc_rev_flag VARCHAR2(1);
58485 l_accrual_line_num NUMBER;
58486 l_tmp_amt NUMBER;
58487 l_acc_rev_natural_side_code VARCHAR2(1);
58488
58489 l_num_entries NUMBER;
58490 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
58491 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
58492 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
58493 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
58494 l_recog_line_1 NUMBER;
58495 l_recog_line_2 NUMBER;
58496
58497 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
58498 l_bflow_applied_to_amt NUMBER; -- 5132302
58499 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
58500
58501 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
58502
58503 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
58504 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
58505
58506 ---------------------------------------------------------------------------------------------------------------
58507
58508
58509 --
58510 -- bulk performance
58511 --
58512 l_balance_type_code VARCHAR2(1);
58513 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
58514 l_log_module VARCHAR2(240);
58515
58516 --
58517 -- Upgrade strategy
58518 --
58519 l_actual_upg_option VARCHAR2(1);
58520 l_enc_upg_option VARCHAR2(1);
58521
58522 --
58523 BEGIN
58524 --
58525 IF g_log_enabled THEN
58526 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_128';
58527 END IF;
58528 --
58529 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58530
58531 trace
58532 (p_msg => 'BEGIN of AcctLineType_128'
58533 ,p_level => C_LEVEL_PROCEDURE
58534 ,p_module => l_log_module);
58535
58536 END IF;
58537 --
58538 l_component_type := 'AMB_JLT';
58539 l_component_code := 'INTERCOMPANY_ACCRUAL';
58540 l_component_type_code := 'S';
58541 l_component_appl_id := 707;
58542 l_amb_context_code := 'DEFAULT';
58543 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
58544 l_event_class_code := 'LOG_INTERCOMPANY';
58545 l_event_type_code := 'LOG_IC_RCPT_RETURN';
58546 l_line_definition_owner_code := 'S';
58547 l_line_definition_code := 'PI_LOG_IC_RCPT_RETURN';
58548 --
58549 l_balance_type_code := 'A';
58550 l_segment := NULL;
58551 l_ccid := NULL;
58552 l_adr_transaction_coa_id := NULL;
58553 l_adr_accounting_coa_id := NULL;
58554 l_adr_flexfield_segment_code := NULL;
58555 l_adr_flex_value_set_id := NULL;
58556 l_adr_value_type_code := NULL;
58557 l_adr_value_combination_id := NULL;
58558 l_adr_value_segment_code := NULL;
58559
58560 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
58561 l_bflow_class_code := ''; -- 4219869 Business Flow
58562 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
58563 l_budgetary_control_flag := 'N';
58564
58565 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58566 l_bflow_applied_to_amt := NULL; -- 5132302
58567 l_entered_amt_idx := NULL; -- 4262811
58568 l_accted_amt_idx := NULL; -- 4262811
58569 l_acc_rev_flag := NULL; -- 4262811
58570 l_accrual_line_num := NULL; -- 4262811
58571 l_tmp_amt := NULL; -- 4262811
58572 --
58573
58574 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
58575 l_balance_type_code <> 'B' THEN
58576 IF NVL(p_source_97,9E125) = 16
58577 THEN
58578
58579 --
58580 XLA_AE_LINES_PKG.SetNewLine;
58581
58582 p_balance_type_code := l_balance_type_code;
58583 -- set the flag so later we will know whether the gain loss line needs to be created
58584
58585 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
58586 p_actual_flag :='A';
58587 END IF;
58588
58589 --
58590 -- bulk performance
58591 --
58592 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58593 p_header_num => 0); -- 4262811
58594 --
58595 -- set accounting line options
58596 --
58597 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58598 p_natural_side_code => 'D'
58599 , p_gain_or_loss_flag => 'N'
58600 , p_gl_transfer_mode_code => 'S'
58601 , p_acct_entry_type_code => 'A'
58602 , p_switch_side_flag => 'Y'
58603 , p_merge_duplicate_code => 'N'
58604 );
58605 --
58606 l_acc_rev_natural_side_code := 'C'; -- 4262811
58607 --
58608 --
58609 -- set accounting line type info
58610 --
58611 xla_ae_lines_pkg.SetAcctLineType
58612 (p_component_type => l_component_type
58613 ,p_event_type_code => l_event_type_code
58614 ,p_line_definition_owner_code => l_line_definition_owner_code
58615 ,p_line_definition_code => l_line_definition_code
58616 ,p_accounting_line_code => l_component_code
58617 ,p_accounting_line_type_code => l_component_type_code
58618 ,p_accounting_line_appl_id => l_component_appl_id
58619 ,p_amb_context_code => l_amb_context_code
58620 ,p_entity_code => l_entity_code
58621 ,p_event_class_code => l_event_class_code);
58622 --
58623 -- set accounting class
58624 --
58625 xla_ae_lines_pkg.SetAcctClass(
58626 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
58627 , p_ae_header_id => l_ae_header_id
58628 );
58629
58630 --
58631 -- set rounding class
58632 --
58633 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58634 'INTERCOMPANY_ACCRUAL';
58635
58636 --
58637 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58638 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58639 --
58640 -- bulk performance
58641 --
58642 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58643
58644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58645 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58646
58647 -- 4955764
58648 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58649 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58650
58651 -- 4458381 Public Sector Enh
58652
58653 --
58654 -- set accounting attributes for the line type
58655 --
58656 l_entered_amt_idx := 3;
58657 l_accted_amt_idx := 8;
58658 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58659 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
58660 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
58661 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
58662 l_rec_acct_attrs.array_char_value(2) := p_source_85;
58663 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
58664 l_rec_acct_attrs.array_num_value(3) := p_source_91;
58665 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
58666 l_rec_acct_attrs.array_char_value(4) := p_source_88;
58667 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
58668 l_rec_acct_attrs.array_date_value(5) := p_source_92;
58669 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
58670 l_rec_acct_attrs.array_num_value(6) := p_source_93;
58671 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
58672 l_rec_acct_attrs.array_char_value(7) := p_source_94;
58673 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
58674 l_rec_acct_attrs.array_num_value(8) := p_source_95;
58675
58676 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
58677 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
58678
58679 ---------------------------------------------------------------------------------------------------------------
58680 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
58681 ---------------------------------------------------------------------------------------------------------------
58682 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
58683
58684 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58685 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58686
58687 IF xla_accounting_cache_pkg.GetValueChar
58688 (p_source_code => 'LEDGER_CATEGORY_CODE'
58689 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
58690 AND l_bflow_method_code = 'PRIOR_ENTRY'
58691 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
58692 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
58693 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
58694 )
58695 THEN
58696 xla_ae_lines_pkg.BflowUpgEntry
58697 (p_business_method_code => l_bflow_method_code
58698 ,p_business_class_code => l_bflow_class_code
58699 ,p_balance_type => l_balance_type_code);
58700 ELSE
58701 NULL;
58702 -- No business flow processing for business flow method of NONE.
58703 END IF;
58704
58705 --
58706 -- call analytical criteria
58707 --
58708
58709 --
58710 -- call description
58711 --
58712
58713 xla_ae_lines_pkg.SetLineDescription(
58714 p_ae_header_id => l_ae_header_id
58715 ,p_description => Description_1 (
58716 p_application_id => p_application_id
58717 , p_ae_header_id => l_ae_header_id
58718 , p_source_1 => p_source_1
58719 , p_source_2 => p_source_2
58720 , p_source_3 => p_source_3
58721 , p_source_4 => p_source_4
58722 , p_source_5 => p_source_5
58723 )
58724 );
58725
58726
58727 --
58728 -- call ADRs
58729 -- Bug 4922099
58730 --
58731 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58732 (NVL(l_actual_upg_option, 'N') = 'O') OR
58733 (NVL(l_enc_upg_option, 'N') = 'O')
58734 )
58735 THEN
58736 NULL;
58737 --
58738 --
58739
58740 l_ccid := AcctDerRule_6(
58741 p_application_id => p_application_id
58742 , p_ae_header_id => l_ae_header_id
58743 , p_source_11 => p_source_11
58744 , x_transaction_coa_id => l_adr_transaction_coa_id
58745 , x_accounting_coa_id => l_adr_accounting_coa_id
58746 , x_value_type_code => l_adr_value_type_code
58747 , p_side => 'NA'
58748 );
58749
58750 xla_ae_lines_pkg.set_ccid(
58751 p_code_combination_id => l_ccid
58752 , p_value_type_code => l_adr_value_type_code
58753 , p_transaction_coa_id => l_adr_transaction_coa_id
58754 , p_accounting_coa_id => l_adr_accounting_coa_id
58755 , p_adr_code => 'CST_DEFAULT'
58756 , p_adr_type_code => 'S'
58757 , p_component_type => l_component_type
58758 , p_component_code => l_component_code
58759 , p_component_type_code => l_component_type_code
58760 , p_component_appl_id => l_component_appl_id
58761 , p_amb_context_code => l_amb_context_code
58762 , p_side => 'NA'
58763 );
58764
58765
58766 --
58767 --
58768 END IF;
58769 --
58770 -- Bug 4922099
58771 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
58772 (NVL(l_enc_upg_option, 'N') = 'O')
58773 ) AND
58774 (l_bflow_method_code = 'PRIOR_ENTRY')
58775 )
58776 THEN
58777 IF
58778 --
58779 1 = 2
58780 --
58781 THEN
58782 xla_accounting_err_pkg.build_message
58783 (p_appli_s_name => 'XLA'
58784 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58785 ,p_token_1 => 'LINE_NUMBER'
58786 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
58787 ,p_token_2 => 'LINE_TYPE_NAME'
58788 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
58789 l_component_type
58790 ,l_component_code
58791 ,l_component_type_code
58792 ,l_component_appl_id
58793 ,l_amb_context_code
58794 ,l_entity_code
58795 ,l_event_class_code
58796 )
58797 ,p_token_3 => 'OWNER'
58798 ,p_value_3 => xla_lookups_pkg.get_meaning(
58799 p_lookup_type => 'XLA_OWNER_TYPE'
58800 ,p_lookup_code => l_component_type_code
58801 )
58802 ,p_token_4 => 'PRODUCT_NAME'
58803 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
58804 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
58805 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
58806 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
58807 ,p_ae_header_id => NULL
58808 );
58809
58810 IF (C_LEVEL_ERROR>= g_log_level) THEN
58811 trace
58812 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58813 ,p_level => C_LEVEL_ERROR
58814 ,p_module => l_log_module);
58815 END IF;
58816 END IF;
58817 END IF;
58818 --
58819 --
58820 ------------------------------------------------------------------------------------------------
58821 -- 4219869 Business Flow
58822 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
58823 -- Prior Entry. Currently, the following code is always generated.
58824 ------------------------------------------------------------------------------------------------
58825 XLA_AE_LINES_PKG.ValidateCurrentLine;
58826
58827 ------------------------------------------------------------------------------------
58828 -- 4219869 Business Flow
58829 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
58830 ------------------------------------------------------------------------------------
58831 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58832
58833 ----------------------------------------------------------------------------------
58834 -- 4219869 Business Flow
58835 -- Update journal entry status -- Need to generate this within IF <condition>
58836 ----------------------------------------------------------------------------------
58837 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58838 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
58839 ,p_balance_type_code => l_balance_type_code
58840 );
58841
58842 -------------------------------------------------------------------------------------------
58843 -- 4262811 - Generate the Accrual Reversal lines
58844 -------------------------------------------------------------------------------------------
58845 BEGIN
58846 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58847 (g_array_event(p_event_id).array_value_num('header_index'));
58848 IF l_acc_rev_flag IS NULL THEN
58849 l_acc_rev_flag := 'N';
58850 END IF;
58851 EXCEPTION
58852 WHEN OTHERS THEN
58853 l_acc_rev_flag := 'N';
58854 END;
58855 --
58856 IF (l_acc_rev_flag = 'Y') THEN
58857
58858 -- 4645092 ------------------------------------------------------------------------------
58859 -- To allow MPA report to determine if it should generate report process
58860 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58861 ------------------------------------------------------------------------------------------
58862
58863 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58864 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58865 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58866 -- call ADRs
58867 -- Bug 4922099
58868 --
58869 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58870 (NVL(l_actual_upg_option, 'N') = 'O') OR
58871 (NVL(l_enc_upg_option, 'N') = 'O')
58872 )
58873 THEN
58874 NULL;
58875 --
58876 --
58877
58878 l_ccid := AcctDerRule_6(
58879 p_application_id => p_application_id
58880 , p_ae_header_id => l_ae_header_id
58881 , p_source_11 => p_source_11
58882 , x_transaction_coa_id => l_adr_transaction_coa_id
58883 , x_accounting_coa_id => l_adr_accounting_coa_id
58884 , x_value_type_code => l_adr_value_type_code
58885 , p_side => 'NA'
58886 );
58887
58888 xla_ae_lines_pkg.set_ccid(
58889 p_code_combination_id => l_ccid
58890 , p_value_type_code => l_adr_value_type_code
58891 , p_transaction_coa_id => l_adr_transaction_coa_id
58892 , p_accounting_coa_id => l_adr_accounting_coa_id
58893 , p_adr_code => 'CST_DEFAULT'
58894 , p_adr_type_code => 'S'
58895 , p_component_type => l_component_type
58896 , p_component_code => l_component_code
58897 , p_component_type_code => l_component_type_code
58898 , p_component_appl_id => l_component_appl_id
58899 , p_amb_context_code => l_amb_context_code
58900 , p_side => 'NA'
58901 );
58902
58903
58904 --
58905 --
58906 END IF;
58907
58908 --
58909 -- Update the line information that should be overwritten
58910 --
58911 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
58912 p_header_num => 1);
58913 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
58914
58915 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
58916
58917 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
58918 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
58919 END IF;
58920
58921 --
58922 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
58923 --
58924 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
58925 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
58926 ELSE
58927 ---------------------------------------------------------------------------------------------------
58928 -- 4262811a Switch Sign
58929 ---------------------------------------------------------------------------------------------------
58930 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
58931 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58932 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58933 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58934 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58935 -- 5132302
58936 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
58937 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58938
58939 END IF;
58940
58941 -- 4955764
58942 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58943 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
58944
58945
58946 XLA_AE_LINES_PKG.ValidateCurrentLine;
58947 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58948
58949 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58950 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
58951 ,p_balance_type_code => l_balance_type_code);
58952
58953 END IF;
58954
58955 -----------------------------------------------------------------------------------------
58956 -- 4262811 Multiperiod Accounting
58957 -----------------------------------------------------------------------------------------
58958 -- No MPA option is assigned.
58959
58960
58961 END IF;
58962 END IF;
58963 --
58964
58965 --
58966 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58967 trace
58968 (p_msg => 'END of AcctLineType_128'
58969 ,p_level => C_LEVEL_PROCEDURE
58970 ,p_module => l_log_module);
58971 END IF;
58972 --
58973 EXCEPTION
58974 WHEN xla_exceptions_pkg.application_exception THEN
58975 RAISE;
58976 WHEN OTHERS THEN
58977 xla_exceptions_pkg.raise_message
58978 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_128');
58979 END AcctLineType_128;
58980 --
58981
58982 ---------------------------------------
58983 --
58984 -- PRIVATE FUNCTION
58985 -- AcctLineType_129
58986 --
58987 ---------------------------------------
58988 PROCEDURE AcctLineType_129 (
58989 p_application_id IN NUMBER
58990 ,p_event_id IN NUMBER
58991 ,p_calculate_acctd_flag IN VARCHAR2
58992 ,p_calculate_g_l_flag IN VARCHAR2
58993 ,p_actual_flag IN OUT VARCHAR2
58994 ,p_balance_type_code OUT VARCHAR2
58995 ,p_gain_or_loss_ref OUT VARCHAR2
58996
58997 --TRANSACTION_ID
58998 , p_source_1 IN NUMBER
58999 --Item Concatenated Segments
59000 , p_source_2 IN VARCHAR2
59001 --Transaction Quantity
59002 , p_source_3 IN NUMBER
59003 --Transaction Unit of Measure Code
59004 , p_source_4 IN VARCHAR2
59005 --Inventory Transaction Type Description
59006 , p_source_5 IN VARCHAR2
59007 --Transaction Expense Account
59008 , p_source_60 IN NUMBER
59009 --Applied to Application ID
59010 , p_source_79 IN NUMBER
59011 --Applied to Distribution Link Type
59012 , p_source_80 IN VARCHAR2
59013 --Applied to Entity Code
59014 , p_source_81 IN VARCHAR2
59015 --DISTRIBUTION_IDENTIFIER
59016 , p_source_84 IN NUMBER
59017 --Distribution Type
59018 , p_source_85 IN VARCHAR2
59019 , p_source_85_meaning IN VARCHAR2
59020 --Encumbrance Reversal Amount Entered
59021 , p_source_87 IN NUMBER
59022 --Entered Currency Code
59023 , p_source_88 IN VARCHAR2
59024 --Transaction Encumbrance Reversal Amount
59025 , p_source_89 IN NUMBER
59026 --Entered Amount
59027 , p_source_91 IN NUMBER
59028 --Currency Conversion Date
59029 , p_source_92 IN DATE
59030 --Currency Conversion Rate
59031 , p_source_93 IN NUMBER
59032 --Currency Conversion Type
59033 , p_source_94 IN VARCHAR2
59034 --Accounted Amount
59035 , p_source_95 IN NUMBER
59036 --Accounting Line Type
59037 , p_source_97 IN NUMBER
59038 --Costing Encumbrance Upgrade Option
59039 , p_source_100 IN VARCHAR2
59040 --TXN_PO_DISTRIBUTION_ID
59041 , p_source_101 IN NUMBER
59042 --TXN_PO_HEADER_ID
59043 , p_source_102 IN NUMBER
59044 --Requisition Budget Account
59045 , p_source_103 IN NUMBER
59046 --Requisition Encumbrance Type Identifier
59047 , p_source_104 IN NUMBER
59048 )
59049 IS
59050
59051 l_component_type VARCHAR2(80);
59052 l_component_code VARCHAR2(30);
59053 l_component_type_code VARCHAR2(1);
59054 l_component_appl_id INTEGER;
59055 l_amb_context_code VARCHAR2(30);
59056 l_entity_code VARCHAR2(30);
59057 l_event_class_code VARCHAR2(30);
59058 l_ae_header_id NUMBER;
59059 l_event_type_code VARCHAR2(30);
59060 l_line_definition_code VARCHAR2(30);
59061 l_line_definition_owner_code VARCHAR2(1);
59062 --
59063 -- adr variables
59064 l_segment VARCHAR2(30);
59065 l_ccid NUMBER;
59066 l_adr_transaction_coa_id NUMBER;
59067 l_adr_accounting_coa_id NUMBER;
59068 l_adr_flexfield_segment_code VARCHAR2(30);
59069 l_adr_flex_value_set_id NUMBER;
59070 l_adr_value_type_code VARCHAR2(30);
59071 l_adr_value_combination_id NUMBER;
59072 l_adr_value_segment_code VARCHAR2(30);
59073
59074 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
59075 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
59076 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
59077 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
59078
59079 -- 4262811 Variables ------------------------------------------------------------------------------------------
59080 l_entered_amt_idx NUMBER;
59081 l_accted_amt_idx NUMBER;
59082 l_acc_rev_flag VARCHAR2(1);
59083 l_accrual_line_num NUMBER;
59084 l_tmp_amt NUMBER;
59085 l_acc_rev_natural_side_code VARCHAR2(1);
59086
59087 l_num_entries NUMBER;
59088 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
59089 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
59090 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
59091 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
59092 l_recog_line_1 NUMBER;
59093 l_recog_line_2 NUMBER;
59094
59095 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
59096 l_bflow_applied_to_amt NUMBER; -- 5132302
59097 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
59098
59099 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
59100
59101 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
59102 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
59103
59104 ---------------------------------------------------------------------------------------------------------------
59105
59106
59107 --
59108 -- bulk performance
59109 --
59110 l_balance_type_code VARCHAR2(1);
59111 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59112 l_log_module VARCHAR2(240);
59113
59114 --
59115 -- Upgrade strategy
59116 --
59117 l_actual_upg_option VARCHAR2(1);
59118 l_enc_upg_option VARCHAR2(1);
59119
59120 --
59121 BEGIN
59122 --
59123 IF g_log_enabled THEN
59124 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_129';
59125 END IF;
59126 --
59127 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59128
59129 trace
59130 (p_msg => 'BEGIN of AcctLineType_129'
59131 ,p_level => C_LEVEL_PROCEDURE
59132 ,p_module => l_log_module);
59133
59134 END IF;
59135 --
59136 l_component_type := 'AMB_JLT';
59137 l_component_code := 'INTERCOMPANY_ACCRUAL';
59138 l_component_type_code := 'S';
59139 l_component_appl_id := 707;
59140 l_amb_context_code := 'DEFAULT';
59141 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
59142 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
59143 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
59144 l_line_definition_owner_code := 'S';
59145 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
59146 --
59147 l_balance_type_code := 'A';
59148 l_segment := NULL;
59149 l_ccid := NULL;
59150 l_adr_transaction_coa_id := NULL;
59151 l_adr_accounting_coa_id := NULL;
59152 l_adr_flexfield_segment_code := NULL;
59153 l_adr_flex_value_set_id := NULL;
59154 l_adr_value_type_code := NULL;
59155 l_adr_value_combination_id := NULL;
59156 l_adr_value_segment_code := NULL;
59157
59158 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
59159 l_bflow_class_code := ''; -- 4219869 Business Flow
59160 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
59161 l_budgetary_control_flag := 'N';
59162
59163 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59164 l_bflow_applied_to_amt := NULL; -- 5132302
59165 l_entered_amt_idx := NULL; -- 4262811
59166 l_accted_amt_idx := NULL; -- 4262811
59167 l_acc_rev_flag := NULL; -- 4262811
59168 l_accrual_line_num := NULL; -- 4262811
59169 l_tmp_amt := NULL; -- 4262811
59170 --
59171
59172 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
59173 l_balance_type_code <> 'B' THEN
59174 IF NVL(p_source_97,9E125) = 2 AND
59175 p_source_95 < 0
59176 THEN
59177
59178 --
59179 XLA_AE_LINES_PKG.SetNewLine;
59180
59181 p_balance_type_code := l_balance_type_code;
59182 -- set the flag so later we will know whether the gain loss line needs to be created
59183
59184 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
59185 p_actual_flag :='A';
59186 END IF;
59187
59188 --
59189 -- bulk performance
59190 --
59191 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
59192 p_header_num => 0); -- 4262811
59193 --
59194 -- set accounting line options
59195 --
59196 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
59197 p_natural_side_code => 'D'
59198 , p_gain_or_loss_flag => 'N'
59199 , p_gl_transfer_mode_code => 'S'
59200 , p_acct_entry_type_code => 'A'
59201 , p_switch_side_flag => 'Y'
59202 , p_merge_duplicate_code => 'N'
59203 );
59204 --
59205 l_acc_rev_natural_side_code := 'C'; -- 4262811
59206 --
59207 --
59208 -- set accounting line type info
59209 --
59210 xla_ae_lines_pkg.SetAcctLineType
59211 (p_component_type => l_component_type
59212 ,p_event_type_code => l_event_type_code
59213 ,p_line_definition_owner_code => l_line_definition_owner_code
59214 ,p_line_definition_code => l_line_definition_code
59215 ,p_accounting_line_code => l_component_code
59216 ,p_accounting_line_type_code => l_component_type_code
59217 ,p_accounting_line_appl_id => l_component_appl_id
59218 ,p_amb_context_code => l_amb_context_code
59219 ,p_entity_code => l_entity_code
59220 ,p_event_class_code => l_event_class_code);
59221 --
59222 -- set accounting class
59223 --
59224 xla_ae_lines_pkg.SetAcctClass(
59225 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
59226 , p_ae_header_id => l_ae_header_id
59227 );
59228
59229 --
59230 -- set rounding class
59231 --
59232 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
59233 'INTERCOMPANY_ACCRUAL';
59234
59235 --
59236 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
59237 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
59238 --
59239 -- bulk performance
59240 --
59241 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
59242
59243 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
59244 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
59245
59246 -- 4955764
59247 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59248 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
59249
59250 -- 4458381 Public Sector Enh
59251
59252 --
59253 -- set accounting attributes for the line type
59254 --
59255 l_entered_amt_idx := 17;
59256 l_accted_amt_idx := 22;
59257 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59258 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
59259 l_rec_acct_attrs.array_num_value(1) := p_source_79;
59260 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
59261 l_rec_acct_attrs.array_char_value(2) := p_source_80;
59262 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
59263 l_rec_acct_attrs.array_char_value(3) := p_source_81;
59264 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
59265 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
59266 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
59267 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
59268 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
59269 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
59270 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
59271 l_rec_acct_attrs.array_char_value(7) := p_source_85;
59272 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
59273 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
59274 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
59275 l_rec_acct_attrs.array_num_value(9) := p_source_87;
59276 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
59277 l_rec_acct_attrs.array_char_value(10) := p_source_88;
59278 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
59279 l_rec_acct_attrs.array_num_value(11) := p_source_89;
59280 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
59281 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
59282 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
59283 l_rec_acct_attrs.array_num_value(13) := p_source_87;
59284 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
59285 l_rec_acct_attrs.array_char_value(14) := p_source_88;
59286 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
59287 l_rec_acct_attrs.array_num_value(15) := p_source_89;
59288 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
59289 l_rec_acct_attrs.array_char_value(16) := p_source_100;
59290 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
59291 l_rec_acct_attrs.array_num_value(17) := p_source_91;
59292 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
59293 l_rec_acct_attrs.array_char_value(18) := p_source_88;
59294 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
59295 l_rec_acct_attrs.array_date_value(19) := p_source_92;
59296 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
59297 l_rec_acct_attrs.array_num_value(20) := p_source_93;
59298 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
59299 l_rec_acct_attrs.array_char_value(21) := p_source_94;
59300 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
59301 l_rec_acct_attrs.array_num_value(22) := p_source_95;
59302 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
59303 l_rec_acct_attrs.array_num_value(23) := p_source_104;
59304 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
59305 l_rec_acct_attrs.array_num_value(24) := p_source_104;
59306
59307 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59308 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59309
59310 ---------------------------------------------------------------------------------------------------------------
59311 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59312 ---------------------------------------------------------------------------------------------------------------
59313 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59314
59315 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59316 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59317
59318 IF xla_accounting_cache_pkg.GetValueChar
59319 (p_source_code => 'LEDGER_CATEGORY_CODE'
59320 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59321 AND l_bflow_method_code = 'PRIOR_ENTRY'
59322 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59323 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59324 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59325 )
59326 THEN
59327 xla_ae_lines_pkg.BflowUpgEntry
59328 (p_business_method_code => l_bflow_method_code
59329 ,p_business_class_code => l_bflow_class_code
59330 ,p_balance_type => l_balance_type_code);
59331 ELSE
59332 NULL;
59333 -- No business flow processing for business flow method of NONE.
59334 END IF;
59335
59336 --
59337 -- call analytical criteria
59338 --
59339
59340 --
59341 -- call description
59342 --
59343
59344 xla_ae_lines_pkg.SetLineDescription(
59345 p_ae_header_id => l_ae_header_id
59346 ,p_description => Description_1 (
59347 p_application_id => p_application_id
59348 , p_ae_header_id => l_ae_header_id
59349 , p_source_1 => p_source_1
59350 , p_source_2 => p_source_2
59351 , p_source_3 => p_source_3
59352 , p_source_4 => p_source_4
59353 , p_source_5 => p_source_5
59354 )
59355 );
59356
59357
59358 --
59359 -- call ADRs
59360 -- Bug 4922099
59361 --
59362 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59363 (NVL(l_actual_upg_option, 'N') = 'O') OR
59364 (NVL(l_enc_upg_option, 'N') = 'O')
59365 )
59366 THEN
59367 NULL;
59368 --
59369 --
59370
59371 l_ccid := AcctDerRule_34(
59372 p_application_id => p_application_id
59373 , p_ae_header_id => l_ae_header_id
59374 , p_source_60 => p_source_60
59375 , x_transaction_coa_id => l_adr_transaction_coa_id
59376 , x_accounting_coa_id => l_adr_accounting_coa_id
59377 , x_value_type_code => l_adr_value_type_code
59378 , p_side => 'NA'
59379 );
59380
59381 xla_ae_lines_pkg.set_ccid(
59382 p_code_combination_id => l_ccid
59383 , p_value_type_code => l_adr_value_type_code
59384 , p_transaction_coa_id => l_adr_transaction_coa_id
59385 , p_accounting_coa_id => l_adr_accounting_coa_id
59386 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
59387 , p_adr_type_code => 'S'
59388 , p_component_type => l_component_type
59389 , p_component_code => l_component_code
59390 , p_component_type_code => l_component_type_code
59391 , p_component_appl_id => l_component_appl_id
59392 , p_amb_context_code => l_amb_context_code
59393 , p_side => 'NA'
59394 );
59395
59396
59397 --
59398 --
59399 END IF;
59400 --
59401 -- Bug 4922099
59402 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
59403 (NVL(l_enc_upg_option, 'N') = 'O')
59404 ) AND
59405 (l_bflow_method_code = 'PRIOR_ENTRY')
59406 )
59407 THEN
59408 IF
59409 --
59410 1 = 2
59411 --
59412 THEN
59413 xla_accounting_err_pkg.build_message
59414 (p_appli_s_name => 'XLA'
59415 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59416 ,p_token_1 => 'LINE_NUMBER'
59417 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
59418 ,p_token_2 => 'LINE_TYPE_NAME'
59419 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
59420 l_component_type
59421 ,l_component_code
59422 ,l_component_type_code
59423 ,l_component_appl_id
59424 ,l_amb_context_code
59425 ,l_entity_code
59426 ,l_event_class_code
59427 )
59428 ,p_token_3 => 'OWNER'
59429 ,p_value_3 => xla_lookups_pkg.get_meaning(
59430 p_lookup_type => 'XLA_OWNER_TYPE'
59431 ,p_lookup_code => l_component_type_code
59432 )
59433 ,p_token_4 => 'PRODUCT_NAME'
59434 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
59435 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
59436 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
59437 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
59438 ,p_ae_header_id => NULL
59439 );
59440
59441 IF (C_LEVEL_ERROR>= g_log_level) THEN
59442 trace
59443 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59444 ,p_level => C_LEVEL_ERROR
59445 ,p_module => l_log_module);
59446 END IF;
59447 END IF;
59448 END IF;
59449 --
59450 --
59451 ------------------------------------------------------------------------------------------------
59452 -- 4219869 Business Flow
59453 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
59454 -- Prior Entry. Currently, the following code is always generated.
59455 ------------------------------------------------------------------------------------------------
59456 XLA_AE_LINES_PKG.ValidateCurrentLine;
59457
59458 ------------------------------------------------------------------------------------
59459 -- 4219869 Business Flow
59460 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
59461 ------------------------------------------------------------------------------------
59462 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59463
59464 ----------------------------------------------------------------------------------
59465 -- 4219869 Business Flow
59466 -- Update journal entry status -- Need to generate this within IF <condition>
59467 ----------------------------------------------------------------------------------
59468 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59469 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
59470 ,p_balance_type_code => l_balance_type_code
59471 );
59472
59473 -------------------------------------------------------------------------------------------
59474 -- 4262811 - Generate the Accrual Reversal lines
59475 -------------------------------------------------------------------------------------------
59476 BEGIN
59477 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
59478 (g_array_event(p_event_id).array_value_num('header_index'));
59479 IF l_acc_rev_flag IS NULL THEN
59480 l_acc_rev_flag := 'N';
59481 END IF;
59482 EXCEPTION
59483 WHEN OTHERS THEN
59484 l_acc_rev_flag := 'N';
59485 END;
59486 --
59487 IF (l_acc_rev_flag = 'Y') THEN
59488
59489 -- 4645092 ------------------------------------------------------------------------------
59490 -- To allow MPA report to determine if it should generate report process
59491 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
59492 ------------------------------------------------------------------------------------------
59493
59494 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
59495 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
59496 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
59497 -- call ADRs
59498 -- Bug 4922099
59499 --
59500 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59501 (NVL(l_actual_upg_option, 'N') = 'O') OR
59502 (NVL(l_enc_upg_option, 'N') = 'O')
59503 )
59504 THEN
59505 NULL;
59506 --
59507 --
59508
59509 l_ccid := AcctDerRule_34(
59510 p_application_id => p_application_id
59511 , p_ae_header_id => l_ae_header_id
59512 , p_source_60 => p_source_60
59513 , x_transaction_coa_id => l_adr_transaction_coa_id
59514 , x_accounting_coa_id => l_adr_accounting_coa_id
59515 , x_value_type_code => l_adr_value_type_code
59516 , p_side => 'NA'
59517 );
59518
59519 xla_ae_lines_pkg.set_ccid(
59520 p_code_combination_id => l_ccid
59521 , p_value_type_code => l_adr_value_type_code
59522 , p_transaction_coa_id => l_adr_transaction_coa_id
59523 , p_accounting_coa_id => l_adr_accounting_coa_id
59524 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
59525 , p_adr_type_code => 'S'
59526 , p_component_type => l_component_type
59527 , p_component_code => l_component_code
59528 , p_component_type_code => l_component_type_code
59529 , p_component_appl_id => l_component_appl_id
59530 , p_amb_context_code => l_amb_context_code
59531 , p_side => 'NA'
59532 );
59533
59534
59535 --
59536 --
59537 END IF;
59538
59539 --
59540 -- Update the line information that should be overwritten
59541 --
59542 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
59543 p_header_num => 1);
59544 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
59545
59546 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
59547
59548 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
59549 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
59550 END IF;
59551
59552 --
59553 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
59554 --
59555 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
59556 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
59557 ELSE
59558 ---------------------------------------------------------------------------------------------------
59559 -- 4262811a Switch Sign
59560 ---------------------------------------------------------------------------------------------------
59561 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
59562 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59563 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59564 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59565 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59566 -- 5132302
59567 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
59568 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59569
59570 END IF;
59571
59572 -- 4955764
59573 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59574 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
59575
59576
59577 XLA_AE_LINES_PKG.ValidateCurrentLine;
59578 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59579
59580 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59581 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
59582 ,p_balance_type_code => l_balance_type_code);
59583
59584 END IF;
59585
59586 -----------------------------------------------------------------------------------------
59587 -- 4262811 Multiperiod Accounting
59588 -----------------------------------------------------------------------------------------
59589 -- No MPA option is assigned.
59590
59591
59592 END IF;
59593 END IF;
59594 --
59595
59596 --
59597 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59598 trace
59599 (p_msg => 'END of AcctLineType_129'
59600 ,p_level => C_LEVEL_PROCEDURE
59601 ,p_module => l_log_module);
59602 END IF;
59603 --
59604 EXCEPTION
59605 WHEN xla_exceptions_pkg.application_exception THEN
59606 RAISE;
59607 WHEN OTHERS THEN
59608 xla_exceptions_pkg.raise_message
59609 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_129');
59610 END AcctLineType_129;
59611 --
59612
59613 ---------------------------------------
59614 --
59615 -- PRIVATE FUNCTION
59616 -- AcctLineType_130
59617 --
59618 ---------------------------------------
59619 PROCEDURE AcctLineType_130 (
59620 p_application_id IN NUMBER
59621 ,p_event_id IN NUMBER
59622 ,p_calculate_acctd_flag IN VARCHAR2
59623 ,p_calculate_g_l_flag IN VARCHAR2
59624 ,p_actual_flag IN OUT VARCHAR2
59625 ,p_balance_type_code OUT VARCHAR2
59626 ,p_gain_or_loss_ref OUT VARCHAR2
59627
59628 --TRANSACTION_ID
59629 , p_source_1 IN NUMBER
59630 --Item Concatenated Segments
59631 , p_source_2 IN VARCHAR2
59632 --Transaction Quantity
59633 , p_source_3 IN NUMBER
59634 --Transaction Unit of Measure Code
59635 , p_source_4 IN VARCHAR2
59636 --Inventory Transaction Type Description
59637 , p_source_5 IN VARCHAR2
59638 --Cost Management Default Account
59639 , p_source_11 IN NUMBER
59640 --DISTRIBUTION_IDENTIFIER
59641 , p_source_84 IN NUMBER
59642 --Distribution Type
59643 , p_source_85 IN VARCHAR2
59644 , p_source_85_meaning IN VARCHAR2
59645 --Entered Currency Code
59646 , p_source_88 IN VARCHAR2
59647 --Entered Amount
59648 , p_source_91 IN NUMBER
59649 --Currency Conversion Date
59650 , p_source_92 IN DATE
59651 --Currency Conversion Rate
59652 , p_source_93 IN NUMBER
59653 --Currency Conversion Type
59654 , p_source_94 IN VARCHAR2
59655 --Accounted Amount
59656 , p_source_95 IN NUMBER
59657 --Accounting Line Type
59658 , p_source_97 IN NUMBER
59659 )
59660 IS
59661
59662 l_component_type VARCHAR2(80);
59663 l_component_code VARCHAR2(30);
59664 l_component_type_code VARCHAR2(1);
59665 l_component_appl_id INTEGER;
59666 l_amb_context_code VARCHAR2(30);
59667 l_entity_code VARCHAR2(30);
59668 l_event_class_code VARCHAR2(30);
59669 l_ae_header_id NUMBER;
59670 l_event_type_code VARCHAR2(30);
59671 l_line_definition_code VARCHAR2(30);
59672 l_line_definition_owner_code VARCHAR2(1);
59673 --
59674 -- adr variables
59675 l_segment VARCHAR2(30);
59676 l_ccid NUMBER;
59677 l_adr_transaction_coa_id NUMBER;
59678 l_adr_accounting_coa_id NUMBER;
59679 l_adr_flexfield_segment_code VARCHAR2(30);
59680 l_adr_flex_value_set_id NUMBER;
59681 l_adr_value_type_code VARCHAR2(30);
59682 l_adr_value_combination_id NUMBER;
59683 l_adr_value_segment_code VARCHAR2(30);
59684
59685 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
59686 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
59687 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
59688 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
59689
59690 -- 4262811 Variables ------------------------------------------------------------------------------------------
59691 l_entered_amt_idx NUMBER;
59692 l_accted_amt_idx NUMBER;
59693 l_acc_rev_flag VARCHAR2(1);
59694 l_accrual_line_num NUMBER;
59695 l_tmp_amt NUMBER;
59696 l_acc_rev_natural_side_code VARCHAR2(1);
59697
59698 l_num_entries NUMBER;
59699 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
59700 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
59701 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
59702 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
59703 l_recog_line_1 NUMBER;
59704 l_recog_line_2 NUMBER;
59705
59706 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
59707 l_bflow_applied_to_amt NUMBER; -- 5132302
59708 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
59709
59710 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
59711
59712 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
59713 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
59714
59715 ---------------------------------------------------------------------------------------------------------------
59716
59717
59718 --
59719 -- bulk performance
59720 --
59721 l_balance_type_code VARCHAR2(1);
59722 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59723 l_log_module VARCHAR2(240);
59724
59725 --
59726 -- Upgrade strategy
59727 --
59728 l_actual_upg_option VARCHAR2(1);
59729 l_enc_upg_option VARCHAR2(1);
59730
59731 --
59732 BEGIN
59733 --
59734 IF g_log_enabled THEN
59735 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_130';
59736 END IF;
59737 --
59738 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59739
59740 trace
59741 (p_msg => 'BEGIN of AcctLineType_130'
59742 ,p_level => C_LEVEL_PROCEDURE
59743 ,p_module => l_log_module);
59744
59745 END IF;
59746 --
59747 l_component_type := 'AMB_JLT';
59748 l_component_code := 'INTERCOMPANY_ACCRUAL';
59749 l_component_type_code := 'S';
59750 l_component_appl_id := 707;
59751 l_amb_context_code := 'DEFAULT';
59752 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
59753 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
59754 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
59755 l_line_definition_owner_code := 'S';
59756 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
59757 --
59758 l_balance_type_code := 'A';
59759 l_segment := NULL;
59760 l_ccid := NULL;
59761 l_adr_transaction_coa_id := NULL;
59762 l_adr_accounting_coa_id := NULL;
59763 l_adr_flexfield_segment_code := NULL;
59764 l_adr_flex_value_set_id := NULL;
59765 l_adr_value_type_code := NULL;
59766 l_adr_value_combination_id := NULL;
59767 l_adr_value_segment_code := NULL;
59768
59769 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
59770 l_bflow_class_code := ''; -- 4219869 Business Flow
59771 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
59772 l_budgetary_control_flag := 'N';
59773
59774 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59775 l_bflow_applied_to_amt := NULL; -- 5132302
59776 l_entered_amt_idx := NULL; -- 4262811
59777 l_accted_amt_idx := NULL; -- 4262811
59778 l_acc_rev_flag := NULL; -- 4262811
59779 l_accrual_line_num := NULL; -- 4262811
59780 l_tmp_amt := NULL; -- 4262811
59781 --
59782
59783 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
59784 l_balance_type_code <> 'B' THEN
59785 IF NVL(p_source_97,9E125) = 2 AND
59786 p_source_95 < 0
59787 THEN
59788
59789 --
59790 XLA_AE_LINES_PKG.SetNewLine;
59791
59792 p_balance_type_code := l_balance_type_code;
59793 -- set the flag so later we will know whether the gain loss line needs to be created
59794
59795 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
59796 p_actual_flag :='A';
59797 END IF;
59798
59799 --
59800 -- bulk performance
59801 --
59802 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
59803 p_header_num => 0); -- 4262811
59804 --
59805 -- set accounting line options
59806 --
59807 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
59808 p_natural_side_code => 'D'
59809 , p_gain_or_loss_flag => 'N'
59810 , p_gl_transfer_mode_code => 'S'
59811 , p_acct_entry_type_code => 'A'
59812 , p_switch_side_flag => 'Y'
59813 , p_merge_duplicate_code => 'N'
59814 );
59815 --
59816 l_acc_rev_natural_side_code := 'C'; -- 4262811
59817 --
59818 --
59819 -- set accounting line type info
59820 --
59821 xla_ae_lines_pkg.SetAcctLineType
59822 (p_component_type => l_component_type
59823 ,p_event_type_code => l_event_type_code
59824 ,p_line_definition_owner_code => l_line_definition_owner_code
59825 ,p_line_definition_code => l_line_definition_code
59826 ,p_accounting_line_code => l_component_code
59827 ,p_accounting_line_type_code => l_component_type_code
59828 ,p_accounting_line_appl_id => l_component_appl_id
59829 ,p_amb_context_code => l_amb_context_code
59830 ,p_entity_code => l_entity_code
59831 ,p_event_class_code => l_event_class_code);
59832 --
59833 -- set accounting class
59834 --
59835 xla_ae_lines_pkg.SetAcctClass(
59836 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
59837 , p_ae_header_id => l_ae_header_id
59838 );
59839
59840 --
59841 -- set rounding class
59842 --
59843 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
59844 'INTERCOMPANY_ACCRUAL';
59845
59846 --
59847 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
59848 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
59849 --
59850 -- bulk performance
59851 --
59852 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
59853
59854 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
59855 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
59856
59857 -- 4955764
59858 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59859 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
59860
59861 -- 4458381 Public Sector Enh
59862
59863 --
59864 -- set accounting attributes for the line type
59865 --
59866 l_entered_amt_idx := 3;
59867 l_accted_amt_idx := 8;
59868 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59869 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
59870 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
59871 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
59872 l_rec_acct_attrs.array_char_value(2) := p_source_85;
59873 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
59874 l_rec_acct_attrs.array_num_value(3) := p_source_91;
59875 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
59876 l_rec_acct_attrs.array_char_value(4) := p_source_88;
59877 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
59878 l_rec_acct_attrs.array_date_value(5) := p_source_92;
59879 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
59880 l_rec_acct_attrs.array_num_value(6) := p_source_93;
59881 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
59882 l_rec_acct_attrs.array_char_value(7) := p_source_94;
59883 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
59884 l_rec_acct_attrs.array_num_value(8) := p_source_95;
59885
59886 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59887 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59888
59889 ---------------------------------------------------------------------------------------------------------------
59890 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59891 ---------------------------------------------------------------------------------------------------------------
59892 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59893
59894 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59895 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59896
59897 IF xla_accounting_cache_pkg.GetValueChar
59898 (p_source_code => 'LEDGER_CATEGORY_CODE'
59899 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59900 AND l_bflow_method_code = 'PRIOR_ENTRY'
59901 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59902 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59903 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59904 )
59905 THEN
59906 xla_ae_lines_pkg.BflowUpgEntry
59907 (p_business_method_code => l_bflow_method_code
59908 ,p_business_class_code => l_bflow_class_code
59909 ,p_balance_type => l_balance_type_code);
59910 ELSE
59911 NULL;
59912 -- No business flow processing for business flow method of NONE.
59913 END IF;
59914
59915 --
59916 -- call analytical criteria
59917 --
59918
59919 --
59920 -- call description
59921 --
59922
59923 xla_ae_lines_pkg.SetLineDescription(
59924 p_ae_header_id => l_ae_header_id
59925 ,p_description => Description_1 (
59926 p_application_id => p_application_id
59927 , p_ae_header_id => l_ae_header_id
59928 , p_source_1 => p_source_1
59929 , p_source_2 => p_source_2
59930 , p_source_3 => p_source_3
59931 , p_source_4 => p_source_4
59932 , p_source_5 => p_source_5
59933 )
59934 );
59935
59936
59937 --
59938 -- call ADRs
59939 -- Bug 4922099
59940 --
59941 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59942 (NVL(l_actual_upg_option, 'N') = 'O') OR
59943 (NVL(l_enc_upg_option, 'N') = 'O')
59944 )
59945 THEN
59946 NULL;
59947 --
59948 --
59949
59950 l_ccid := AcctDerRule_6(
59951 p_application_id => p_application_id
59952 , p_ae_header_id => l_ae_header_id
59953 , p_source_11 => p_source_11
59954 , x_transaction_coa_id => l_adr_transaction_coa_id
59955 , x_accounting_coa_id => l_adr_accounting_coa_id
59956 , x_value_type_code => l_adr_value_type_code
59957 , p_side => 'NA'
59958 );
59959
59960 xla_ae_lines_pkg.set_ccid(
59961 p_code_combination_id => l_ccid
59962 , p_value_type_code => l_adr_value_type_code
59963 , p_transaction_coa_id => l_adr_transaction_coa_id
59964 , p_accounting_coa_id => l_adr_accounting_coa_id
59965 , p_adr_code => 'CST_DEFAULT'
59966 , p_adr_type_code => 'S'
59967 , p_component_type => l_component_type
59968 , p_component_code => l_component_code
59969 , p_component_type_code => l_component_type_code
59970 , p_component_appl_id => l_component_appl_id
59971 , p_amb_context_code => l_amb_context_code
59972 , p_side => 'NA'
59973 );
59974
59975
59976 --
59977 --
59978 END IF;
59979 --
59980 -- Bug 4922099
59981 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
59982 (NVL(l_enc_upg_option, 'N') = 'O')
59983 ) AND
59984 (l_bflow_method_code = 'PRIOR_ENTRY')
59985 )
59986 THEN
59987 IF
59988 --
59989 1 = 2
59990 --
59991 THEN
59992 xla_accounting_err_pkg.build_message
59993 (p_appli_s_name => 'XLA'
59994 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59995 ,p_token_1 => 'LINE_NUMBER'
59996 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
59997 ,p_token_2 => 'LINE_TYPE_NAME'
59998 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
59999 l_component_type
60000 ,l_component_code
60001 ,l_component_type_code
60002 ,l_component_appl_id
60003 ,l_amb_context_code
60004 ,l_entity_code
60005 ,l_event_class_code
60006 )
60007 ,p_token_3 => 'OWNER'
60008 ,p_value_3 => xla_lookups_pkg.get_meaning(
60009 p_lookup_type => 'XLA_OWNER_TYPE'
60010 ,p_lookup_code => l_component_type_code
60011 )
60012 ,p_token_4 => 'PRODUCT_NAME'
60013 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60014 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60015 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60016 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60017 ,p_ae_header_id => NULL
60018 );
60019
60020 IF (C_LEVEL_ERROR>= g_log_level) THEN
60021 trace
60022 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60023 ,p_level => C_LEVEL_ERROR
60024 ,p_module => l_log_module);
60025 END IF;
60026 END IF;
60027 END IF;
60028 --
60029 --
60030 ------------------------------------------------------------------------------------------------
60031 -- 4219869 Business Flow
60032 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60033 -- Prior Entry. Currently, the following code is always generated.
60034 ------------------------------------------------------------------------------------------------
60035 XLA_AE_LINES_PKG.ValidateCurrentLine;
60036
60037 ------------------------------------------------------------------------------------
60038 -- 4219869 Business Flow
60039 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60040 ------------------------------------------------------------------------------------
60041 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60042
60043 ----------------------------------------------------------------------------------
60044 -- 4219869 Business Flow
60045 -- Update journal entry status -- Need to generate this within IF <condition>
60046 ----------------------------------------------------------------------------------
60047 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60048 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60049 ,p_balance_type_code => l_balance_type_code
60050 );
60051
60052 -------------------------------------------------------------------------------------------
60053 -- 4262811 - Generate the Accrual Reversal lines
60054 -------------------------------------------------------------------------------------------
60055 BEGIN
60056 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60057 (g_array_event(p_event_id).array_value_num('header_index'));
60058 IF l_acc_rev_flag IS NULL THEN
60059 l_acc_rev_flag := 'N';
60060 END IF;
60061 EXCEPTION
60062 WHEN OTHERS THEN
60063 l_acc_rev_flag := 'N';
60064 END;
60065 --
60066 IF (l_acc_rev_flag = 'Y') THEN
60067
60068 -- 4645092 ------------------------------------------------------------------------------
60069 -- To allow MPA report to determine if it should generate report process
60070 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60071 ------------------------------------------------------------------------------------------
60072
60073 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60074 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60075 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
60076 -- call ADRs
60077 -- Bug 4922099
60078 --
60079 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60080 (NVL(l_actual_upg_option, 'N') = 'O') OR
60081 (NVL(l_enc_upg_option, 'N') = 'O')
60082 )
60083 THEN
60084 NULL;
60085 --
60086 --
60087
60088 l_ccid := AcctDerRule_6(
60089 p_application_id => p_application_id
60090 , p_ae_header_id => l_ae_header_id
60091 , p_source_11 => p_source_11
60092 , x_transaction_coa_id => l_adr_transaction_coa_id
60093 , x_accounting_coa_id => l_adr_accounting_coa_id
60094 , x_value_type_code => l_adr_value_type_code
60095 , p_side => 'NA'
60096 );
60097
60098 xla_ae_lines_pkg.set_ccid(
60099 p_code_combination_id => l_ccid
60100 , p_value_type_code => l_adr_value_type_code
60101 , p_transaction_coa_id => l_adr_transaction_coa_id
60102 , p_accounting_coa_id => l_adr_accounting_coa_id
60103 , p_adr_code => 'CST_DEFAULT'
60104 , p_adr_type_code => 'S'
60105 , p_component_type => l_component_type
60106 , p_component_code => l_component_code
60107 , p_component_type_code => l_component_type_code
60108 , p_component_appl_id => l_component_appl_id
60109 , p_amb_context_code => l_amb_context_code
60110 , p_side => 'NA'
60111 );
60112
60113
60114 --
60115 --
60116 END IF;
60117
60118 --
60119 -- Update the line information that should be overwritten
60120 --
60121 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
60122 p_header_num => 1);
60123 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
60124
60125 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
60126
60127 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
60128 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
60129 END IF;
60130
60131 --
60132 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
60133 --
60134 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
60135 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
60136 ELSE
60137 ---------------------------------------------------------------------------------------------------
60138 -- 4262811a Switch Sign
60139 ---------------------------------------------------------------------------------------------------
60140 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
60141 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60142 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60143 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60144 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60145 -- 5132302
60146 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
60147 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60148
60149 END IF;
60150
60151 -- 4955764
60152 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60153 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
60154
60155
60156 XLA_AE_LINES_PKG.ValidateCurrentLine;
60157 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60158
60159 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60160 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
60161 ,p_balance_type_code => l_balance_type_code);
60162
60163 END IF;
60164
60165 -----------------------------------------------------------------------------------------
60166 -- 4262811 Multiperiod Accounting
60167 -----------------------------------------------------------------------------------------
60168 -- No MPA option is assigned.
60169
60170
60171 END IF;
60172 END IF;
60173 --
60174
60175 --
60176 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60177 trace
60178 (p_msg => 'END of AcctLineType_130'
60179 ,p_level => C_LEVEL_PROCEDURE
60180 ,p_module => l_log_module);
60181 END IF;
60182 --
60183 EXCEPTION
60184 WHEN xla_exceptions_pkg.application_exception THEN
60185 RAISE;
60186 WHEN OTHERS THEN
60187 xla_exceptions_pkg.raise_message
60188 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_130');
60189 END AcctLineType_130;
60190 --
60191
60192 ---------------------------------------
60193 --
60194 -- PRIVATE FUNCTION
60195 -- AcctLineType_131
60196 --
60197 ---------------------------------------
60198 PROCEDURE AcctLineType_131 (
60199 p_application_id IN NUMBER
60200 ,p_event_id IN NUMBER
60201 ,p_calculate_acctd_flag IN VARCHAR2
60202 ,p_calculate_g_l_flag IN VARCHAR2
60203 ,p_actual_flag IN OUT VARCHAR2
60204 ,p_balance_type_code OUT VARCHAR2
60205 ,p_gain_or_loss_ref OUT VARCHAR2
60206
60207 --TRANSACTION_ID
60208 , p_source_1 IN NUMBER
60209 --Item Concatenated Segments
60210 , p_source_2 IN VARCHAR2
60211 --Transaction Quantity
60212 , p_source_3 IN NUMBER
60213 --Transaction Unit of Measure Code
60214 , p_source_4 IN VARCHAR2
60215 --Inventory Transaction Type Description
60216 , p_source_5 IN VARCHAR2
60217 --Transaction Expense Account
60218 , p_source_60 IN NUMBER
60219 --DISTRIBUTION_IDENTIFIER
60220 , p_source_84 IN NUMBER
60221 --Distribution Type
60222 , p_source_85 IN VARCHAR2
60223 , p_source_85_meaning IN VARCHAR2
60224 --Entered Currency Code
60225 , p_source_88 IN VARCHAR2
60226 --Entered Amount
60227 , p_source_91 IN NUMBER
60228 --Currency Conversion Date
60229 , p_source_92 IN DATE
60230 --Currency Conversion Rate
60231 , p_source_93 IN NUMBER
60232 --Currency Conversion Type
60233 , p_source_94 IN VARCHAR2
60234 --Accounted Amount
60235 , p_source_95 IN NUMBER
60236 --Accounting Line Type
60237 , p_source_97 IN NUMBER
60238 )
60239 IS
60240
60241 l_component_type VARCHAR2(80);
60242 l_component_code VARCHAR2(30);
60243 l_component_type_code VARCHAR2(1);
60244 l_component_appl_id INTEGER;
60245 l_amb_context_code VARCHAR2(30);
60246 l_entity_code VARCHAR2(30);
60247 l_event_class_code VARCHAR2(30);
60248 l_ae_header_id NUMBER;
60249 l_event_type_code VARCHAR2(30);
60250 l_line_definition_code VARCHAR2(30);
60251 l_line_definition_owner_code VARCHAR2(1);
60252 --
60253 -- adr variables
60254 l_segment VARCHAR2(30);
60255 l_ccid NUMBER;
60256 l_adr_transaction_coa_id NUMBER;
60257 l_adr_accounting_coa_id NUMBER;
60258 l_adr_flexfield_segment_code VARCHAR2(30);
60259 l_adr_flex_value_set_id NUMBER;
60260 l_adr_value_type_code VARCHAR2(30);
60261 l_adr_value_combination_id NUMBER;
60262 l_adr_value_segment_code VARCHAR2(30);
60263
60264 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60265 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60266 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60267 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60268
60269 -- 4262811 Variables ------------------------------------------------------------------------------------------
60270 l_entered_amt_idx NUMBER;
60271 l_accted_amt_idx NUMBER;
60272 l_acc_rev_flag VARCHAR2(1);
60273 l_accrual_line_num NUMBER;
60274 l_tmp_amt NUMBER;
60275 l_acc_rev_natural_side_code VARCHAR2(1);
60276
60277 l_num_entries NUMBER;
60278 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60279 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60280 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60281 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60282 l_recog_line_1 NUMBER;
60283 l_recog_line_2 NUMBER;
60284
60285 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60286 l_bflow_applied_to_amt NUMBER; -- 5132302
60287 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60288
60289 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60290
60291 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60292 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60293
60294 ---------------------------------------------------------------------------------------------------------------
60295
60296
60297 --
60298 -- bulk performance
60299 --
60300 l_balance_type_code VARCHAR2(1);
60301 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60302 l_log_module VARCHAR2(240);
60303
60304 --
60305 -- Upgrade strategy
60306 --
60307 l_actual_upg_option VARCHAR2(1);
60308 l_enc_upg_option VARCHAR2(1);
60309
60310 --
60311 BEGIN
60312 --
60313 IF g_log_enabled THEN
60314 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_131';
60315 END IF;
60316 --
60317 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60318
60319 trace
60320 (p_msg => 'BEGIN of AcctLineType_131'
60321 ,p_level => C_LEVEL_PROCEDURE
60322 ,p_module => l_log_module);
60323
60324 END IF;
60325 --
60326 l_component_type := 'AMB_JLT';
60327 l_component_code := 'INTERCOMPANY_ACCRUAL';
60328 l_component_type_code := 'S';
60329 l_component_appl_id := 707;
60330 l_amb_context_code := 'DEFAULT';
60331 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
60332 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
60333 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
60334 l_line_definition_owner_code := 'S';
60335 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
60336 --
60337 l_balance_type_code := 'A';
60338 l_segment := NULL;
60339 l_ccid := NULL;
60340 l_adr_transaction_coa_id := NULL;
60341 l_adr_accounting_coa_id := NULL;
60342 l_adr_flexfield_segment_code := NULL;
60343 l_adr_flex_value_set_id := NULL;
60344 l_adr_value_type_code := NULL;
60345 l_adr_value_combination_id := NULL;
60346 l_adr_value_segment_code := NULL;
60347
60348 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
60349 l_bflow_class_code := ''; -- 4219869 Business Flow
60350 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
60351 l_budgetary_control_flag := 'N';
60352
60353 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60354 l_bflow_applied_to_amt := NULL; -- 5132302
60355 l_entered_amt_idx := NULL; -- 4262811
60356 l_accted_amt_idx := NULL; -- 4262811
60357 l_acc_rev_flag := NULL; -- 4262811
60358 l_accrual_line_num := NULL; -- 4262811
60359 l_tmp_amt := NULL; -- 4262811
60360 --
60361
60362 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
60363 l_balance_type_code <> 'B' THEN
60364 IF NVL(p_source_97,9E125) = 2 AND
60365 p_source_95 < 0
60366 THEN
60367
60368 --
60369 XLA_AE_LINES_PKG.SetNewLine;
60370
60371 p_balance_type_code := l_balance_type_code;
60372 -- set the flag so later we will know whether the gain loss line needs to be created
60373
60374 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
60375 p_actual_flag :='A';
60376 END IF;
60377
60378 --
60379 -- bulk performance
60380 --
60381 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
60382 p_header_num => 0); -- 4262811
60383 --
60384 -- set accounting line options
60385 --
60386 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
60387 p_natural_side_code => 'D'
60388 , p_gain_or_loss_flag => 'N'
60389 , p_gl_transfer_mode_code => 'S'
60390 , p_acct_entry_type_code => 'A'
60391 , p_switch_side_flag => 'Y'
60392 , p_merge_duplicate_code => 'N'
60393 );
60394 --
60395 l_acc_rev_natural_side_code := 'C'; -- 4262811
60396 --
60397 --
60398 -- set accounting line type info
60399 --
60400 xla_ae_lines_pkg.SetAcctLineType
60401 (p_component_type => l_component_type
60402 ,p_event_type_code => l_event_type_code
60403 ,p_line_definition_owner_code => l_line_definition_owner_code
60404 ,p_line_definition_code => l_line_definition_code
60405 ,p_accounting_line_code => l_component_code
60406 ,p_accounting_line_type_code => l_component_type_code
60407 ,p_accounting_line_appl_id => l_component_appl_id
60408 ,p_amb_context_code => l_amb_context_code
60409 ,p_entity_code => l_entity_code
60410 ,p_event_class_code => l_event_class_code);
60411 --
60412 -- set accounting class
60413 --
60414 xla_ae_lines_pkg.SetAcctClass(
60415 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
60416 , p_ae_header_id => l_ae_header_id
60417 );
60418
60419 --
60420 -- set rounding class
60421 --
60422 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
60423 'INTERCOMPANY_ACCRUAL';
60424
60425 --
60426 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
60427 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
60428 --
60429 -- bulk performance
60430 --
60431 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
60432
60433 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
60434 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
60435
60436 -- 4955764
60437 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60438 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
60439
60440 -- 4458381 Public Sector Enh
60441
60442 --
60443 -- set accounting attributes for the line type
60444 --
60445 l_entered_amt_idx := 3;
60446 l_accted_amt_idx := 8;
60447 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60448 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
60449 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
60450 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
60451 l_rec_acct_attrs.array_char_value(2) := p_source_85;
60452 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
60453 l_rec_acct_attrs.array_num_value(3) := p_source_91;
60454 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
60455 l_rec_acct_attrs.array_char_value(4) := p_source_88;
60456 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
60457 l_rec_acct_attrs.array_date_value(5) := p_source_92;
60458 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
60459 l_rec_acct_attrs.array_num_value(6) := p_source_93;
60460 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
60461 l_rec_acct_attrs.array_char_value(7) := p_source_94;
60462 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
60463 l_rec_acct_attrs.array_num_value(8) := p_source_95;
60464
60465 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
60466 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
60467
60468 ---------------------------------------------------------------------------------------------------------------
60469 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
60470 ---------------------------------------------------------------------------------------------------------------
60471 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
60472
60473 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60474 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60475
60476 IF xla_accounting_cache_pkg.GetValueChar
60477 (p_source_code => 'LEDGER_CATEGORY_CODE'
60478 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
60479 AND l_bflow_method_code = 'PRIOR_ENTRY'
60480 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
60481 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
60482 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
60483 )
60484 THEN
60485 xla_ae_lines_pkg.BflowUpgEntry
60486 (p_business_method_code => l_bflow_method_code
60487 ,p_business_class_code => l_bflow_class_code
60488 ,p_balance_type => l_balance_type_code);
60489 ELSE
60490 NULL;
60491 -- No business flow processing for business flow method of NONE.
60492 END IF;
60493
60494 --
60495 -- call analytical criteria
60496 --
60497
60498 --
60499 -- call description
60500 --
60501
60502 xla_ae_lines_pkg.SetLineDescription(
60503 p_ae_header_id => l_ae_header_id
60504 ,p_description => Description_1 (
60505 p_application_id => p_application_id
60506 , p_ae_header_id => l_ae_header_id
60507 , p_source_1 => p_source_1
60508 , p_source_2 => p_source_2
60509 , p_source_3 => p_source_3
60510 , p_source_4 => p_source_4
60511 , p_source_5 => p_source_5
60512 )
60513 );
60514
60515
60516 --
60517 -- call ADRs
60518 -- Bug 4922099
60519 --
60520 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60521 (NVL(l_actual_upg_option, 'N') = 'O') OR
60522 (NVL(l_enc_upg_option, 'N') = 'O')
60523 )
60524 THEN
60525 NULL;
60526 --
60527 --
60528
60529 l_ccid := AcctDerRule_34(
60530 p_application_id => p_application_id
60531 , p_ae_header_id => l_ae_header_id
60532 , p_source_60 => p_source_60
60533 , x_transaction_coa_id => l_adr_transaction_coa_id
60534 , x_accounting_coa_id => l_adr_accounting_coa_id
60535 , x_value_type_code => l_adr_value_type_code
60536 , p_side => 'NA'
60537 );
60538
60539 xla_ae_lines_pkg.set_ccid(
60540 p_code_combination_id => l_ccid
60541 , p_value_type_code => l_adr_value_type_code
60542 , p_transaction_coa_id => l_adr_transaction_coa_id
60543 , p_accounting_coa_id => l_adr_accounting_coa_id
60544 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
60545 , p_adr_type_code => 'S'
60546 , p_component_type => l_component_type
60547 , p_component_code => l_component_code
60548 , p_component_type_code => l_component_type_code
60549 , p_component_appl_id => l_component_appl_id
60550 , p_amb_context_code => l_amb_context_code
60551 , p_side => 'NA'
60552 );
60553
60554
60555 --
60556 --
60557 END IF;
60558 --
60559 -- Bug 4922099
60560 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
60561 (NVL(l_enc_upg_option, 'N') = 'O')
60562 ) AND
60563 (l_bflow_method_code = 'PRIOR_ENTRY')
60564 )
60565 THEN
60566 IF
60567 --
60568 1 = 2
60569 --
60570 THEN
60571 xla_accounting_err_pkg.build_message
60572 (p_appli_s_name => 'XLA'
60573 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60574 ,p_token_1 => 'LINE_NUMBER'
60575 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
60576 ,p_token_2 => 'LINE_TYPE_NAME'
60577 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
60578 l_component_type
60579 ,l_component_code
60580 ,l_component_type_code
60581 ,l_component_appl_id
60582 ,l_amb_context_code
60583 ,l_entity_code
60584 ,l_event_class_code
60585 )
60586 ,p_token_3 => 'OWNER'
60587 ,p_value_3 => xla_lookups_pkg.get_meaning(
60588 p_lookup_type => 'XLA_OWNER_TYPE'
60589 ,p_lookup_code => l_component_type_code
60590 )
60591 ,p_token_4 => 'PRODUCT_NAME'
60592 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60593 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60594 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60595 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60596 ,p_ae_header_id => NULL
60597 );
60598
60599 IF (C_LEVEL_ERROR>= g_log_level) THEN
60600 trace
60601 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60602 ,p_level => C_LEVEL_ERROR
60603 ,p_module => l_log_module);
60604 END IF;
60605 END IF;
60606 END IF;
60607 --
60608 --
60609 ------------------------------------------------------------------------------------------------
60610 -- 4219869 Business Flow
60611 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60612 -- Prior Entry. Currently, the following code is always generated.
60613 ------------------------------------------------------------------------------------------------
60614 XLA_AE_LINES_PKG.ValidateCurrentLine;
60615
60616 ------------------------------------------------------------------------------------
60617 -- 4219869 Business Flow
60618 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60619 ------------------------------------------------------------------------------------
60620 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60621
60622 ----------------------------------------------------------------------------------
60623 -- 4219869 Business Flow
60624 -- Update journal entry status -- Need to generate this within IF <condition>
60625 ----------------------------------------------------------------------------------
60626 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60627 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60628 ,p_balance_type_code => l_balance_type_code
60629 );
60630
60631 -------------------------------------------------------------------------------------------
60632 -- 4262811 - Generate the Accrual Reversal lines
60633 -------------------------------------------------------------------------------------------
60634 BEGIN
60635 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60636 (g_array_event(p_event_id).array_value_num('header_index'));
60637 IF l_acc_rev_flag IS NULL THEN
60638 l_acc_rev_flag := 'N';
60639 END IF;
60640 EXCEPTION
60641 WHEN OTHERS THEN
60642 l_acc_rev_flag := 'N';
60643 END;
60644 --
60645 IF (l_acc_rev_flag = 'Y') THEN
60646
60647 -- 4645092 ------------------------------------------------------------------------------
60648 -- To allow MPA report to determine if it should generate report process
60649 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60650 ------------------------------------------------------------------------------------------
60651
60652 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60653 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60654 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
60655 -- call ADRs
60656 -- Bug 4922099
60657 --
60658 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60659 (NVL(l_actual_upg_option, 'N') = 'O') OR
60660 (NVL(l_enc_upg_option, 'N') = 'O')
60661 )
60662 THEN
60663 NULL;
60664 --
60665 --
60666
60667 l_ccid := AcctDerRule_34(
60668 p_application_id => p_application_id
60669 , p_ae_header_id => l_ae_header_id
60670 , p_source_60 => p_source_60
60671 , x_transaction_coa_id => l_adr_transaction_coa_id
60672 , x_accounting_coa_id => l_adr_accounting_coa_id
60673 , x_value_type_code => l_adr_value_type_code
60674 , p_side => 'NA'
60675 );
60676
60677 xla_ae_lines_pkg.set_ccid(
60678 p_code_combination_id => l_ccid
60679 , p_value_type_code => l_adr_value_type_code
60680 , p_transaction_coa_id => l_adr_transaction_coa_id
60681 , p_accounting_coa_id => l_adr_accounting_coa_id
60682 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
60683 , p_adr_type_code => 'S'
60684 , p_component_type => l_component_type
60685 , p_component_code => l_component_code
60686 , p_component_type_code => l_component_type_code
60687 , p_component_appl_id => l_component_appl_id
60688 , p_amb_context_code => l_amb_context_code
60689 , p_side => 'NA'
60690 );
60691
60692
60693 --
60694 --
60695 END IF;
60696
60697 --
60698 -- Update the line information that should be overwritten
60699 --
60700 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
60701 p_header_num => 1);
60702 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
60703
60704 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
60705
60706 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
60707 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
60708 END IF;
60709
60710 --
60711 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
60712 --
60713 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
60714 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
60715 ELSE
60716 ---------------------------------------------------------------------------------------------------
60717 -- 4262811a Switch Sign
60718 ---------------------------------------------------------------------------------------------------
60719 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
60720 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60721 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60722 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60723 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60724 -- 5132302
60725 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
60726 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60727
60728 END IF;
60729
60730 -- 4955764
60731 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60732 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
60733
60734
60735 XLA_AE_LINES_PKG.ValidateCurrentLine;
60736 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60737
60738 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60739 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
60740 ,p_balance_type_code => l_balance_type_code);
60741
60742 END IF;
60743
60744 -----------------------------------------------------------------------------------------
60745 -- 4262811 Multiperiod Accounting
60746 -----------------------------------------------------------------------------------------
60747 -- No MPA option is assigned.
60748
60749
60750 END IF;
60751 END IF;
60752 --
60753
60754 --
60755 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60756 trace
60757 (p_msg => 'END of AcctLineType_131'
60758 ,p_level => C_LEVEL_PROCEDURE
60759 ,p_module => l_log_module);
60760 END IF;
60761 --
60762 EXCEPTION
60763 WHEN xla_exceptions_pkg.application_exception THEN
60764 RAISE;
60765 WHEN OTHERS THEN
60766 xla_exceptions_pkg.raise_message
60767 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_131');
60768 END AcctLineType_131;
60769 --
60770
60771 ---------------------------------------
60772 --
60773 -- PRIVATE FUNCTION
60774 -- AcctLineType_132
60775 --
60776 ---------------------------------------
60777 PROCEDURE AcctLineType_132 (
60778 p_application_id IN NUMBER
60779 ,p_event_id IN NUMBER
60780 ,p_calculate_acctd_flag IN VARCHAR2
60781 ,p_calculate_g_l_flag IN VARCHAR2
60782 ,p_actual_flag IN OUT VARCHAR2
60783 ,p_balance_type_code OUT VARCHAR2
60784 ,p_gain_or_loss_ref OUT VARCHAR2
60785
60786 --TRANSACTION_ID
60787 , p_source_1 IN NUMBER
60788 --Item Concatenated Segments
60789 , p_source_2 IN VARCHAR2
60790 --Transaction Quantity
60791 , p_source_3 IN NUMBER
60792 --Transaction Unit of Measure Code
60793 , p_source_4 IN VARCHAR2
60794 --Inventory Transaction Type Description
60795 , p_source_5 IN VARCHAR2
60796 --Transaction Expense Account
60797 , p_source_60 IN NUMBER
60798 --DISTRIBUTION_IDENTIFIER
60799 , p_source_84 IN NUMBER
60800 --Distribution Type
60801 , p_source_85 IN VARCHAR2
60802 , p_source_85_meaning IN VARCHAR2
60803 --Entered Currency Code
60804 , p_source_88 IN VARCHAR2
60805 --Entered Amount
60806 , p_source_91 IN NUMBER
60807 --Currency Conversion Date
60808 , p_source_92 IN DATE
60809 --Currency Conversion Rate
60810 , p_source_93 IN NUMBER
60811 --Currency Conversion Type
60812 , p_source_94 IN VARCHAR2
60813 --Accounted Amount
60814 , p_source_95 IN NUMBER
60815 --Accounting Line Type
60816 , p_source_97 IN NUMBER
60817 )
60818 IS
60819
60820 l_component_type VARCHAR2(80);
60821 l_component_code VARCHAR2(30);
60822 l_component_type_code VARCHAR2(1);
60823 l_component_appl_id INTEGER;
60824 l_amb_context_code VARCHAR2(30);
60825 l_entity_code VARCHAR2(30);
60826 l_event_class_code VARCHAR2(30);
60827 l_ae_header_id NUMBER;
60828 l_event_type_code VARCHAR2(30);
60829 l_line_definition_code VARCHAR2(30);
60830 l_line_definition_owner_code VARCHAR2(1);
60831 --
60832 -- adr variables
60833 l_segment VARCHAR2(30);
60834 l_ccid NUMBER;
60835 l_adr_transaction_coa_id NUMBER;
60836 l_adr_accounting_coa_id NUMBER;
60837 l_adr_flexfield_segment_code VARCHAR2(30);
60838 l_adr_flex_value_set_id NUMBER;
60839 l_adr_value_type_code VARCHAR2(30);
60840 l_adr_value_combination_id NUMBER;
60841 l_adr_value_segment_code VARCHAR2(30);
60842
60843 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60844 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60845 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60846 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60847
60848 -- 4262811 Variables ------------------------------------------------------------------------------------------
60849 l_entered_amt_idx NUMBER;
60850 l_accted_amt_idx NUMBER;
60851 l_acc_rev_flag VARCHAR2(1);
60852 l_accrual_line_num NUMBER;
60853 l_tmp_amt NUMBER;
60854 l_acc_rev_natural_side_code VARCHAR2(1);
60855
60856 l_num_entries NUMBER;
60857 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60858 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60859 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60860 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60861 l_recog_line_1 NUMBER;
60862 l_recog_line_2 NUMBER;
60863
60864 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60865 l_bflow_applied_to_amt NUMBER; -- 5132302
60866 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60867
60868 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60869
60870 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60871 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60872
60873 ---------------------------------------------------------------------------------------------------------------
60874
60875
60876 --
60877 -- bulk performance
60878 --
60879 l_balance_type_code VARCHAR2(1);
60880 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60881 l_log_module VARCHAR2(240);
60882
60883 --
60884 -- Upgrade strategy
60885 --
60886 l_actual_upg_option VARCHAR2(1);
60887 l_enc_upg_option VARCHAR2(1);
60888
60889 --
60890 BEGIN
60891 --
60892 IF g_log_enabled THEN
60893 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_132';
60894 END IF;
60895 --
60896 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60897
60898 trace
60899 (p_msg => 'BEGIN of AcctLineType_132'
60900 ,p_level => C_LEVEL_PROCEDURE
60901 ,p_module => l_log_module);
60902
60903 END IF;
60904 --
60905 l_component_type := 'AMB_JLT';
60906 l_component_code := 'INTERCOMPANY_ACCRUAL';
60907 l_component_type_code := 'S';
60908 l_component_appl_id := 707;
60909 l_amb_context_code := 'DEFAULT';
60910 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
60911 l_event_class_code := 'USER_DEFINE';
60912 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
60913 l_line_definition_owner_code := 'S';
60914 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
60915 --
60916 l_balance_type_code := 'A';
60917 l_segment := NULL;
60918 l_ccid := NULL;
60919 l_adr_transaction_coa_id := NULL;
60920 l_adr_accounting_coa_id := NULL;
60921 l_adr_flexfield_segment_code := NULL;
60922 l_adr_flex_value_set_id := NULL;
60923 l_adr_value_type_code := NULL;
60924 l_adr_value_combination_id := NULL;
60925 l_adr_value_segment_code := NULL;
60926
60927 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
60928 l_bflow_class_code := ''; -- 4219869 Business Flow
60929 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
60930 l_budgetary_control_flag := 'N';
60931
60932 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60933 l_bflow_applied_to_amt := NULL; -- 5132302
60934 l_entered_amt_idx := NULL; -- 4262811
60935 l_accted_amt_idx := NULL; -- 4262811
60936 l_acc_rev_flag := NULL; -- 4262811
60937 l_accrual_line_num := NULL; -- 4262811
60938 l_tmp_amt := NULL; -- 4262811
60939 --
60940
60941 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
60942 l_balance_type_code <> 'B' THEN
60943 IF NVL(p_source_97,9E125) = 2 AND
60944 p_source_95 < 0
60945 THEN
60946
60947 --
60948 XLA_AE_LINES_PKG.SetNewLine;
60949
60950 p_balance_type_code := l_balance_type_code;
60951 -- set the flag so later we will know whether the gain loss line needs to be created
60952
60953 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
60954 p_actual_flag :='A';
60955 END IF;
60956
60957 --
60958 -- bulk performance
60959 --
60960 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
60961 p_header_num => 0); -- 4262811
60962 --
60963 -- set accounting line options
60964 --
60965 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
60966 p_natural_side_code => 'D'
60967 , p_gain_or_loss_flag => 'N'
60968 , p_gl_transfer_mode_code => 'S'
60969 , p_acct_entry_type_code => 'A'
60970 , p_switch_side_flag => 'Y'
60971 , p_merge_duplicate_code => 'N'
60972 );
60973 --
60974 l_acc_rev_natural_side_code := 'C'; -- 4262811
60975 --
60976 --
60977 -- set accounting line type info
60978 --
60979 xla_ae_lines_pkg.SetAcctLineType
60980 (p_component_type => l_component_type
60981 ,p_event_type_code => l_event_type_code
60982 ,p_line_definition_owner_code => l_line_definition_owner_code
60983 ,p_line_definition_code => l_line_definition_code
60984 ,p_accounting_line_code => l_component_code
60985 ,p_accounting_line_type_code => l_component_type_code
60986 ,p_accounting_line_appl_id => l_component_appl_id
60987 ,p_amb_context_code => l_amb_context_code
60988 ,p_entity_code => l_entity_code
60989 ,p_event_class_code => l_event_class_code);
60990 --
60991 -- set accounting class
60992 --
60993 xla_ae_lines_pkg.SetAcctClass(
60994 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
60995 , p_ae_header_id => l_ae_header_id
60996 );
60997
60998 --
60999 -- set rounding class
61000 --
61001 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
61002 'INTERCOMPANY_ACCRUAL';
61003
61004 --
61005 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
61006 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
61007 --
61008 -- bulk performance
61009 --
61010 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
61011
61012 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
61013 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
61014
61015 -- 4955764
61016 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61017 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
61018
61019 -- 4458381 Public Sector Enh
61020
61021 --
61022 -- set accounting attributes for the line type
61023 --
61024 l_entered_amt_idx := 3;
61025 l_accted_amt_idx := 8;
61026 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61027 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
61028 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
61029 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
61030 l_rec_acct_attrs.array_char_value(2) := p_source_85;
61031 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
61032 l_rec_acct_attrs.array_num_value(3) := p_source_91;
61033 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
61034 l_rec_acct_attrs.array_char_value(4) := p_source_88;
61035 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
61036 l_rec_acct_attrs.array_date_value(5) := p_source_92;
61037 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
61038 l_rec_acct_attrs.array_num_value(6) := p_source_93;
61039 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
61040 l_rec_acct_attrs.array_char_value(7) := p_source_94;
61041 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
61042 l_rec_acct_attrs.array_num_value(8) := p_source_95;
61043
61044 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
61045 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
61046
61047 ---------------------------------------------------------------------------------------------------------------
61048 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
61049 ---------------------------------------------------------------------------------------------------------------
61050 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
61051
61052 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61053 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61054
61055 IF xla_accounting_cache_pkg.GetValueChar
61056 (p_source_code => 'LEDGER_CATEGORY_CODE'
61057 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
61058 AND l_bflow_method_code = 'PRIOR_ENTRY'
61059 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
61060 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
61061 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
61062 )
61063 THEN
61064 xla_ae_lines_pkg.BflowUpgEntry
61065 (p_business_method_code => l_bflow_method_code
61066 ,p_business_class_code => l_bflow_class_code
61067 ,p_balance_type => l_balance_type_code);
61068 ELSE
61069 NULL;
61070 -- No business flow processing for business flow method of NONE.
61071 END IF;
61072
61073 --
61074 -- call analytical criteria
61075 --
61076
61077 --
61078 -- call description
61079 --
61080
61081 xla_ae_lines_pkg.SetLineDescription(
61082 p_ae_header_id => l_ae_header_id
61083 ,p_description => Description_1 (
61084 p_application_id => p_application_id
61085 , p_ae_header_id => l_ae_header_id
61086 , p_source_1 => p_source_1
61087 , p_source_2 => p_source_2
61088 , p_source_3 => p_source_3
61089 , p_source_4 => p_source_4
61090 , p_source_5 => p_source_5
61091 )
61092 );
61093
61094
61095 --
61096 -- call ADRs
61097 -- Bug 4922099
61098 --
61099 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61100 (NVL(l_actual_upg_option, 'N') = 'O') OR
61101 (NVL(l_enc_upg_option, 'N') = 'O')
61102 )
61103 THEN
61104 NULL;
61105 --
61106 --
61107
61108 l_ccid := AcctDerRule_34(
61109 p_application_id => p_application_id
61110 , p_ae_header_id => l_ae_header_id
61111 , p_source_60 => p_source_60
61112 , x_transaction_coa_id => l_adr_transaction_coa_id
61113 , x_accounting_coa_id => l_adr_accounting_coa_id
61114 , x_value_type_code => l_adr_value_type_code
61115 , p_side => 'NA'
61116 );
61117
61118 xla_ae_lines_pkg.set_ccid(
61119 p_code_combination_id => l_ccid
61120 , p_value_type_code => l_adr_value_type_code
61121 , p_transaction_coa_id => l_adr_transaction_coa_id
61122 , p_accounting_coa_id => l_adr_accounting_coa_id
61123 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
61124 , p_adr_type_code => 'S'
61125 , p_component_type => l_component_type
61126 , p_component_code => l_component_code
61127 , p_component_type_code => l_component_type_code
61128 , p_component_appl_id => l_component_appl_id
61129 , p_amb_context_code => l_amb_context_code
61130 , p_side => 'NA'
61131 );
61132
61133
61134 --
61135 --
61136 END IF;
61137 --
61138 -- Bug 4922099
61139 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
61140 (NVL(l_enc_upg_option, 'N') = 'O')
61141 ) AND
61142 (l_bflow_method_code = 'PRIOR_ENTRY')
61143 )
61144 THEN
61145 IF
61146 --
61147 1 = 2
61148 --
61149 THEN
61150 xla_accounting_err_pkg.build_message
61151 (p_appli_s_name => 'XLA'
61152 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61153 ,p_token_1 => 'LINE_NUMBER'
61154 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
61155 ,p_token_2 => 'LINE_TYPE_NAME'
61156 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
61157 l_component_type
61158 ,l_component_code
61159 ,l_component_type_code
61160 ,l_component_appl_id
61161 ,l_amb_context_code
61162 ,l_entity_code
61163 ,l_event_class_code
61164 )
61165 ,p_token_3 => 'OWNER'
61166 ,p_value_3 => xla_lookups_pkg.get_meaning(
61167 p_lookup_type => 'XLA_OWNER_TYPE'
61168 ,p_lookup_code => l_component_type_code
61169 )
61170 ,p_token_4 => 'PRODUCT_NAME'
61171 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
61172 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
61173 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
61174 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
61175 ,p_ae_header_id => NULL
61176 );
61177
61178 IF (C_LEVEL_ERROR>= g_log_level) THEN
61179 trace
61180 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61181 ,p_level => C_LEVEL_ERROR
61182 ,p_module => l_log_module);
61183 END IF;
61184 END IF;
61185 END IF;
61186 --
61187 --
61188 ------------------------------------------------------------------------------------------------
61189 -- 4219869 Business Flow
61190 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
61191 -- Prior Entry. Currently, the following code is always generated.
61192 ------------------------------------------------------------------------------------------------
61193 XLA_AE_LINES_PKG.ValidateCurrentLine;
61194
61195 ------------------------------------------------------------------------------------
61196 -- 4219869 Business Flow
61197 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
61198 ------------------------------------------------------------------------------------
61199 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61200
61201 ----------------------------------------------------------------------------------
61202 -- 4219869 Business Flow
61203 -- Update journal entry status -- Need to generate this within IF <condition>
61204 ----------------------------------------------------------------------------------
61205 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61206 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
61207 ,p_balance_type_code => l_balance_type_code
61208 );
61209
61210 -------------------------------------------------------------------------------------------
61211 -- 4262811 - Generate the Accrual Reversal lines
61212 -------------------------------------------------------------------------------------------
61213 BEGIN
61214 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
61215 (g_array_event(p_event_id).array_value_num('header_index'));
61216 IF l_acc_rev_flag IS NULL THEN
61217 l_acc_rev_flag := 'N';
61218 END IF;
61219 EXCEPTION
61220 WHEN OTHERS THEN
61221 l_acc_rev_flag := 'N';
61222 END;
61223 --
61224 IF (l_acc_rev_flag = 'Y') THEN
61225
61226 -- 4645092 ------------------------------------------------------------------------------
61227 -- To allow MPA report to determine if it should generate report process
61228 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
61229 ------------------------------------------------------------------------------------------
61230
61231 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
61232 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
61233 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61234 -- call ADRs
61235 -- Bug 4922099
61236 --
61237 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61238 (NVL(l_actual_upg_option, 'N') = 'O') OR
61239 (NVL(l_enc_upg_option, 'N') = 'O')
61240 )
61241 THEN
61242 NULL;
61243 --
61244 --
61245
61246 l_ccid := AcctDerRule_34(
61247 p_application_id => p_application_id
61248 , p_ae_header_id => l_ae_header_id
61249 , p_source_60 => p_source_60
61250 , x_transaction_coa_id => l_adr_transaction_coa_id
61251 , x_accounting_coa_id => l_adr_accounting_coa_id
61252 , x_value_type_code => l_adr_value_type_code
61253 , p_side => 'NA'
61254 );
61255
61256 xla_ae_lines_pkg.set_ccid(
61257 p_code_combination_id => l_ccid
61258 , p_value_type_code => l_adr_value_type_code
61259 , p_transaction_coa_id => l_adr_transaction_coa_id
61260 , p_accounting_coa_id => l_adr_accounting_coa_id
61261 , p_adr_code => 'PI_TRANSACTION_EXPENSE'
61262 , p_adr_type_code => 'S'
61263 , p_component_type => l_component_type
61264 , p_component_code => l_component_code
61265 , p_component_type_code => l_component_type_code
61266 , p_component_appl_id => l_component_appl_id
61267 , p_amb_context_code => l_amb_context_code
61268 , p_side => 'NA'
61269 );
61270
61271
61272 --
61273 --
61274 END IF;
61275
61276 --
61277 -- Update the line information that should be overwritten
61278 --
61279 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61280 p_header_num => 1);
61281 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61282
61283 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61284
61285 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61286 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61287 END IF;
61288
61289 --
61290 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61291 --
61292 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61293 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61294 ELSE
61295 ---------------------------------------------------------------------------------------------------
61296 -- 4262811a Switch Sign
61297 ---------------------------------------------------------------------------------------------------
61298 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
61299 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61300 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61301 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61302 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61303 -- 5132302
61304 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
61305 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61306
61307 END IF;
61308
61309 -- 4955764
61310 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61311 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
61312
61313
61314 XLA_AE_LINES_PKG.ValidateCurrentLine;
61315 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61316
61317 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61318 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
61319 ,p_balance_type_code => l_balance_type_code);
61320
61321 END IF;
61322
61323 -----------------------------------------------------------------------------------------
61324 -- 4262811 Multiperiod Accounting
61325 -----------------------------------------------------------------------------------------
61326 -- No MPA option is assigned.
61327
61328
61329 END IF;
61330 END IF;
61331 --
61332
61333 --
61334 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61335 trace
61336 (p_msg => 'END of AcctLineType_132'
61337 ,p_level => C_LEVEL_PROCEDURE
61338 ,p_module => l_log_module);
61339 END IF;
61340 --
61341 EXCEPTION
61342 WHEN xla_exceptions_pkg.application_exception THEN
61343 RAISE;
61344 WHEN OTHERS THEN
61345 xla_exceptions_pkg.raise_message
61346 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_132');
61347 END AcctLineType_132;
61348 --
61349
61350 ---------------------------------------
61351 --
61352 -- PRIVATE FUNCTION
61353 -- AcctLineType_133
61354 --
61355 ---------------------------------------
61356 PROCEDURE AcctLineType_133 (
61357 p_application_id IN NUMBER
61358 ,p_event_id IN NUMBER
61359 ,p_calculate_acctd_flag IN VARCHAR2
61360 ,p_calculate_g_l_flag IN VARCHAR2
61361 ,p_actual_flag IN OUT VARCHAR2
61362 ,p_balance_type_code OUT VARCHAR2
61363 ,p_gain_or_loss_ref OUT VARCHAR2
61364
61365 --TRANSACTION_ID
61366 , p_source_1 IN NUMBER
61367 --Item Concatenated Segments
61368 , p_source_2 IN VARCHAR2
61369 --Transaction Quantity
61370 , p_source_3 IN NUMBER
61371 --Transaction Unit of Measure Code
61372 , p_source_4 IN VARCHAR2
61373 --Inventory Transaction Type Description
61374 , p_source_5 IN VARCHAR2
61375 --Cost Management Default Account
61376 , p_source_11 IN NUMBER
61377 --DISTRIBUTION_IDENTIFIER
61378 , p_source_84 IN NUMBER
61379 --Distribution Type
61380 , p_source_85 IN VARCHAR2
61381 , p_source_85_meaning IN VARCHAR2
61382 --Entered Currency Code
61383 , p_source_88 IN VARCHAR2
61384 --Entered Amount
61385 , p_source_91 IN NUMBER
61386 --Currency Conversion Date
61387 , p_source_92 IN DATE
61388 --Currency Conversion Rate
61389 , p_source_93 IN NUMBER
61390 --Currency Conversion Type
61391 , p_source_94 IN VARCHAR2
61392 --Accounted Amount
61393 , p_source_95 IN NUMBER
61394 --Accounting Line Type
61395 , p_source_97 IN NUMBER
61396 )
61397 IS
61398
61399 l_component_type VARCHAR2(80);
61400 l_component_code VARCHAR2(30);
61401 l_component_type_code VARCHAR2(1);
61402 l_component_appl_id INTEGER;
61403 l_amb_context_code VARCHAR2(30);
61404 l_entity_code VARCHAR2(30);
61405 l_event_class_code VARCHAR2(30);
61406 l_ae_header_id NUMBER;
61407 l_event_type_code VARCHAR2(30);
61408 l_line_definition_code VARCHAR2(30);
61409 l_line_definition_owner_code VARCHAR2(1);
61410 --
61411 -- adr variables
61412 l_segment VARCHAR2(30);
61413 l_ccid NUMBER;
61414 l_adr_transaction_coa_id NUMBER;
61415 l_adr_accounting_coa_id NUMBER;
61416 l_adr_flexfield_segment_code VARCHAR2(30);
61417 l_adr_flex_value_set_id NUMBER;
61418 l_adr_value_type_code VARCHAR2(30);
61419 l_adr_value_combination_id NUMBER;
61420 l_adr_value_segment_code VARCHAR2(30);
61421
61422 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
61423 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
61424 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
61425 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
61426
61427 -- 4262811 Variables ------------------------------------------------------------------------------------------
61428 l_entered_amt_idx NUMBER;
61429 l_accted_amt_idx NUMBER;
61430 l_acc_rev_flag VARCHAR2(1);
61431 l_accrual_line_num NUMBER;
61432 l_tmp_amt NUMBER;
61433 l_acc_rev_natural_side_code VARCHAR2(1);
61434
61435 l_num_entries NUMBER;
61436 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
61437 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
61438 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
61439 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
61440 l_recog_line_1 NUMBER;
61441 l_recog_line_2 NUMBER;
61442
61443 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
61444 l_bflow_applied_to_amt NUMBER; -- 5132302
61445 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
61446
61447 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
61448
61449 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
61450 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
61451
61452 ---------------------------------------------------------------------------------------------------------------
61453
61454
61455 --
61456 -- bulk performance
61457 --
61458 l_balance_type_code VARCHAR2(1);
61459 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
61460 l_log_module VARCHAR2(240);
61461
61462 --
61463 -- Upgrade strategy
61464 --
61465 l_actual_upg_option VARCHAR2(1);
61466 l_enc_upg_option VARCHAR2(1);
61467
61468 --
61469 BEGIN
61470 --
61471 IF g_log_enabled THEN
61472 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_133';
61473 END IF;
61474 --
61475 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61476
61477 trace
61478 (p_msg => 'BEGIN of AcctLineType_133'
61479 ,p_level => C_LEVEL_PROCEDURE
61480 ,p_module => l_log_module);
61481
61482 END IF;
61483 --
61484 l_component_type := 'AMB_JLT';
61485 l_component_code := 'INTERCOMPANY_ACCRUAL';
61486 l_component_type_code := 'S';
61487 l_component_appl_id := 707;
61488 l_amb_context_code := 'DEFAULT';
61489 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
61490 l_event_class_code := 'LOG_INTERCOMPANY';
61491 l_event_type_code := 'LOG_IC_SHIPMENT_RCPT';
61492 l_line_definition_owner_code := 'S';
61493 l_line_definition_code := 'PI_LOG_IC_SHIPMENT_RCPT';
61494 --
61495 l_balance_type_code := 'A';
61496 l_segment := NULL;
61497 l_ccid := NULL;
61498 l_adr_transaction_coa_id := NULL;
61499 l_adr_accounting_coa_id := NULL;
61500 l_adr_flexfield_segment_code := NULL;
61501 l_adr_flex_value_set_id := NULL;
61502 l_adr_value_type_code := NULL;
61503 l_adr_value_combination_id := NULL;
61504 l_adr_value_segment_code := NULL;
61505
61506 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
61507 l_bflow_class_code := ''; -- 4219869 Business Flow
61508 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
61509 l_budgetary_control_flag := 'N';
61510
61511 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61512 l_bflow_applied_to_amt := NULL; -- 5132302
61513 l_entered_amt_idx := NULL; -- 4262811
61514 l_accted_amt_idx := NULL; -- 4262811
61515 l_acc_rev_flag := NULL; -- 4262811
61516 l_accrual_line_num := NULL; -- 4262811
61517 l_tmp_amt := NULL; -- 4262811
61518 --
61519
61520 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
61521 l_balance_type_code <> 'B' THEN
61522 IF NVL(p_source_97,9E125) = 16
61523 THEN
61524
61525 --
61526 XLA_AE_LINES_PKG.SetNewLine;
61527
61528 p_balance_type_code := l_balance_type_code;
61529 -- set the flag so later we will know whether the gain loss line needs to be created
61530
61531 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
61532 p_actual_flag :='A';
61533 END IF;
61534
61535 --
61536 -- bulk performance
61537 --
61538 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
61539 p_header_num => 0); -- 4262811
61540 --
61541 -- set accounting line options
61542 --
61543 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
61544 p_natural_side_code => 'D'
61545 , p_gain_or_loss_flag => 'N'
61546 , p_gl_transfer_mode_code => 'S'
61547 , p_acct_entry_type_code => 'A'
61548 , p_switch_side_flag => 'Y'
61549 , p_merge_duplicate_code => 'N'
61550 );
61551 --
61552 l_acc_rev_natural_side_code := 'C'; -- 4262811
61553 --
61554 --
61555 -- set accounting line type info
61556 --
61557 xla_ae_lines_pkg.SetAcctLineType
61558 (p_component_type => l_component_type
61559 ,p_event_type_code => l_event_type_code
61560 ,p_line_definition_owner_code => l_line_definition_owner_code
61561 ,p_line_definition_code => l_line_definition_code
61562 ,p_accounting_line_code => l_component_code
61563 ,p_accounting_line_type_code => l_component_type_code
61564 ,p_accounting_line_appl_id => l_component_appl_id
61565 ,p_amb_context_code => l_amb_context_code
61566 ,p_entity_code => l_entity_code
61567 ,p_event_class_code => l_event_class_code);
61568 --
61569 -- set accounting class
61570 --
61571 xla_ae_lines_pkg.SetAcctClass(
61572 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
61573 , p_ae_header_id => l_ae_header_id
61574 );
61575
61576 --
61577 -- set rounding class
61578 --
61579 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
61580 'INTERCOMPANY_ACCRUAL';
61581
61582 --
61583 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
61584 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
61585 --
61586 -- bulk performance
61587 --
61588 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
61589
61590 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
61591 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
61592
61593 -- 4955764
61594 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61595 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
61596
61597 -- 4458381 Public Sector Enh
61598
61599 --
61600 -- set accounting attributes for the line type
61601 --
61602 l_entered_amt_idx := 3;
61603 l_accted_amt_idx := 8;
61604 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61605 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
61606 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
61607 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
61608 l_rec_acct_attrs.array_char_value(2) := p_source_85;
61609 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
61610 l_rec_acct_attrs.array_num_value(3) := p_source_91;
61611 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
61612 l_rec_acct_attrs.array_char_value(4) := p_source_88;
61613 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
61614 l_rec_acct_attrs.array_date_value(5) := p_source_92;
61615 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
61616 l_rec_acct_attrs.array_num_value(6) := p_source_93;
61617 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
61618 l_rec_acct_attrs.array_char_value(7) := p_source_94;
61619 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
61620 l_rec_acct_attrs.array_num_value(8) := p_source_95;
61621
61622 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
61623 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
61624
61625 ---------------------------------------------------------------------------------------------------------------
61626 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
61627 ---------------------------------------------------------------------------------------------------------------
61628 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
61629
61630 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61631 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61632
61633 IF xla_accounting_cache_pkg.GetValueChar
61634 (p_source_code => 'LEDGER_CATEGORY_CODE'
61635 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
61636 AND l_bflow_method_code = 'PRIOR_ENTRY'
61637 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
61638 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
61639 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
61640 )
61641 THEN
61642 xla_ae_lines_pkg.BflowUpgEntry
61643 (p_business_method_code => l_bflow_method_code
61644 ,p_business_class_code => l_bflow_class_code
61645 ,p_balance_type => l_balance_type_code);
61646 ELSE
61647 NULL;
61648 -- No business flow processing for business flow method of NONE.
61649 END IF;
61650
61651 --
61652 -- call analytical criteria
61653 --
61654
61655 --
61656 -- call description
61657 --
61658
61659 xla_ae_lines_pkg.SetLineDescription(
61660 p_ae_header_id => l_ae_header_id
61661 ,p_description => Description_1 (
61662 p_application_id => p_application_id
61663 , p_ae_header_id => l_ae_header_id
61664 , p_source_1 => p_source_1
61665 , p_source_2 => p_source_2
61666 , p_source_3 => p_source_3
61667 , p_source_4 => p_source_4
61668 , p_source_5 => p_source_5
61669 )
61670 );
61671
61672
61673 --
61674 -- call ADRs
61675 -- Bug 4922099
61676 --
61677 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61678 (NVL(l_actual_upg_option, 'N') = 'O') OR
61679 (NVL(l_enc_upg_option, 'N') = 'O')
61680 )
61681 THEN
61682 NULL;
61683 --
61684 --
61685
61686 l_ccid := AcctDerRule_6(
61687 p_application_id => p_application_id
61688 , p_ae_header_id => l_ae_header_id
61689 , p_source_11 => p_source_11
61690 , x_transaction_coa_id => l_adr_transaction_coa_id
61691 , x_accounting_coa_id => l_adr_accounting_coa_id
61692 , x_value_type_code => l_adr_value_type_code
61693 , p_side => 'NA'
61694 );
61695
61696 xla_ae_lines_pkg.set_ccid(
61697 p_code_combination_id => l_ccid
61698 , p_value_type_code => l_adr_value_type_code
61699 , p_transaction_coa_id => l_adr_transaction_coa_id
61700 , p_accounting_coa_id => l_adr_accounting_coa_id
61701 , p_adr_code => 'CST_DEFAULT'
61702 , p_adr_type_code => 'S'
61703 , p_component_type => l_component_type
61704 , p_component_code => l_component_code
61705 , p_component_type_code => l_component_type_code
61706 , p_component_appl_id => l_component_appl_id
61707 , p_amb_context_code => l_amb_context_code
61708 , p_side => 'NA'
61709 );
61710
61711
61712 --
61713 --
61714 END IF;
61715 --
61716 -- Bug 4922099
61717 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
61718 (NVL(l_enc_upg_option, 'N') = 'O')
61719 ) AND
61720 (l_bflow_method_code = 'PRIOR_ENTRY')
61721 )
61722 THEN
61723 IF
61724 --
61725 1 = 2
61726 --
61727 THEN
61728 xla_accounting_err_pkg.build_message
61729 (p_appli_s_name => 'XLA'
61730 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61731 ,p_token_1 => 'LINE_NUMBER'
61732 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
61733 ,p_token_2 => 'LINE_TYPE_NAME'
61734 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
61735 l_component_type
61736 ,l_component_code
61737 ,l_component_type_code
61738 ,l_component_appl_id
61739 ,l_amb_context_code
61740 ,l_entity_code
61741 ,l_event_class_code
61742 )
61743 ,p_token_3 => 'OWNER'
61744 ,p_value_3 => xla_lookups_pkg.get_meaning(
61745 p_lookup_type => 'XLA_OWNER_TYPE'
61746 ,p_lookup_code => l_component_type_code
61747 )
61748 ,p_token_4 => 'PRODUCT_NAME'
61749 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
61750 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
61751 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
61752 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
61753 ,p_ae_header_id => NULL
61754 );
61755
61756 IF (C_LEVEL_ERROR>= g_log_level) THEN
61757 trace
61758 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61759 ,p_level => C_LEVEL_ERROR
61760 ,p_module => l_log_module);
61761 END IF;
61762 END IF;
61763 END IF;
61764 --
61765 --
61766 ------------------------------------------------------------------------------------------------
61767 -- 4219869 Business Flow
61768 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
61769 -- Prior Entry. Currently, the following code is always generated.
61770 ------------------------------------------------------------------------------------------------
61771 XLA_AE_LINES_PKG.ValidateCurrentLine;
61772
61773 ------------------------------------------------------------------------------------
61774 -- 4219869 Business Flow
61775 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
61776 ------------------------------------------------------------------------------------
61777 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61778
61779 ----------------------------------------------------------------------------------
61780 -- 4219869 Business Flow
61781 -- Update journal entry status -- Need to generate this within IF <condition>
61782 ----------------------------------------------------------------------------------
61783 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61784 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
61785 ,p_balance_type_code => l_balance_type_code
61786 );
61787
61788 -------------------------------------------------------------------------------------------
61789 -- 4262811 - Generate the Accrual Reversal lines
61790 -------------------------------------------------------------------------------------------
61791 BEGIN
61792 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
61793 (g_array_event(p_event_id).array_value_num('header_index'));
61794 IF l_acc_rev_flag IS NULL THEN
61795 l_acc_rev_flag := 'N';
61796 END IF;
61797 EXCEPTION
61798 WHEN OTHERS THEN
61799 l_acc_rev_flag := 'N';
61800 END;
61801 --
61802 IF (l_acc_rev_flag = 'Y') THEN
61803
61804 -- 4645092 ------------------------------------------------------------------------------
61805 -- To allow MPA report to determine if it should generate report process
61806 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
61807 ------------------------------------------------------------------------------------------
61808
61809 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
61810 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
61811 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61812 -- call ADRs
61813 -- Bug 4922099
61814 --
61815 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61816 (NVL(l_actual_upg_option, 'N') = 'O') OR
61817 (NVL(l_enc_upg_option, 'N') = 'O')
61818 )
61819 THEN
61820 NULL;
61821 --
61822 --
61823
61824 l_ccid := AcctDerRule_6(
61825 p_application_id => p_application_id
61826 , p_ae_header_id => l_ae_header_id
61827 , p_source_11 => p_source_11
61828 , x_transaction_coa_id => l_adr_transaction_coa_id
61829 , x_accounting_coa_id => l_adr_accounting_coa_id
61830 , x_value_type_code => l_adr_value_type_code
61831 , p_side => 'NA'
61832 );
61833
61834 xla_ae_lines_pkg.set_ccid(
61835 p_code_combination_id => l_ccid
61836 , p_value_type_code => l_adr_value_type_code
61837 , p_transaction_coa_id => l_adr_transaction_coa_id
61838 , p_accounting_coa_id => l_adr_accounting_coa_id
61839 , p_adr_code => 'CST_DEFAULT'
61840 , p_adr_type_code => 'S'
61841 , p_component_type => l_component_type
61842 , p_component_code => l_component_code
61843 , p_component_type_code => l_component_type_code
61844 , p_component_appl_id => l_component_appl_id
61845 , p_amb_context_code => l_amb_context_code
61846 , p_side => 'NA'
61847 );
61848
61849
61850 --
61851 --
61852 END IF;
61853
61854 --
61855 -- Update the line information that should be overwritten
61856 --
61857 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61858 p_header_num => 1);
61859 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61860
61861 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61862
61863 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61864 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61865 END IF;
61866
61867 --
61868 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61869 --
61870 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61871 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61872 ELSE
61873 ---------------------------------------------------------------------------------------------------
61874 -- 4262811a Switch Sign
61875 ---------------------------------------------------------------------------------------------------
61876 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
61877 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61878 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61879 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61880 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61881 -- 5132302
61882 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
61883 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61884
61885 END IF;
61886
61887 -- 4955764
61888 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61889 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
61890
61891
61892 XLA_AE_LINES_PKG.ValidateCurrentLine;
61893 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61894
61895 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61896 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
61897 ,p_balance_type_code => l_balance_type_code);
61898
61899 END IF;
61900
61901 -----------------------------------------------------------------------------------------
61902 -- 4262811 Multiperiod Accounting
61903 -----------------------------------------------------------------------------------------
61904 -- No MPA option is assigned.
61905
61906
61907 END IF;
61908 END IF;
61909 --
61910
61911 --
61912 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61913 trace
61914 (p_msg => 'END of AcctLineType_133'
61915 ,p_level => C_LEVEL_PROCEDURE
61916 ,p_module => l_log_module);
61917 END IF;
61918 --
61919 EXCEPTION
61920 WHEN xla_exceptions_pkg.application_exception THEN
61921 RAISE;
61922 WHEN OTHERS THEN
61923 xla_exceptions_pkg.raise_message
61924 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_133');
61925 END AcctLineType_133;
61926 --
61927
61928 ---------------------------------------
61929 --
61930 -- PRIVATE FUNCTION
61931 -- AcctLineType_134
61932 --
61933 ---------------------------------------
61934 PROCEDURE AcctLineType_134 (
61935 p_application_id IN NUMBER
61936 ,p_event_id IN NUMBER
61937 ,p_calculate_acctd_flag IN VARCHAR2
61938 ,p_calculate_g_l_flag IN VARCHAR2
61939 ,p_actual_flag IN OUT VARCHAR2
61940 ,p_balance_type_code OUT VARCHAR2
61941 ,p_gain_or_loss_ref OUT VARCHAR2
61942
61943 --TRANSACTION_ID
61944 , p_source_1 IN NUMBER
61945 --Item Concatenated Segments
61946 , p_source_2 IN VARCHAR2
61947 --Transaction Quantity
61948 , p_source_3 IN NUMBER
61949 --Transaction Unit of Measure Code
61950 , p_source_4 IN VARCHAR2
61951 --Inventory Transaction Type Description
61952 , p_source_5 IN VARCHAR2
61953 --Cost Management Default Account
61954 , p_source_11 IN NUMBER
61955 --Applied to Application ID
61956 , p_source_79 IN NUMBER
61957 --Applied to Distribution Link Type
61958 , p_source_80 IN VARCHAR2
61959 --Applied to Entity Code
61960 , p_source_81 IN VARCHAR2
61961 --DISTRIBUTION_IDENTIFIER
61962 , p_source_84 IN NUMBER
61963 --Distribution Type
61964 , p_source_85 IN VARCHAR2
61965 , p_source_85_meaning IN VARCHAR2
61966 --Encumbrance Reversal Amount Entered
61967 , p_source_87 IN NUMBER
61968 --Entered Currency Code
61969 , p_source_88 IN VARCHAR2
61970 --Transaction Encumbrance Reversal Amount
61971 , p_source_89 IN NUMBER
61972 --Entered Amount
61973 , p_source_91 IN NUMBER
61974 --Currency Conversion Date
61975 , p_source_92 IN DATE
61976 --Currency Conversion Rate
61977 , p_source_93 IN NUMBER
61978 --Currency Conversion Type
61979 , p_source_94 IN VARCHAR2
61980 --Accounted Amount
61981 , p_source_95 IN NUMBER
61982 --Accounting Line Type
61983 , p_source_97 IN NUMBER
61984 --Costing Encumbrance Upgrade Option
61985 , p_source_100 IN VARCHAR2
61986 --TXN_PO_DISTRIBUTION_ID
61987 , p_source_101 IN NUMBER
61988 --TXN_PO_HEADER_ID
61989 , p_source_102 IN NUMBER
61990 --Requisition Budget Account
61991 , p_source_103 IN NUMBER
61992 --Requisition Encumbrance Type Identifier
61993 , p_source_104 IN NUMBER
61994 )
61995 IS
61996
61997 l_component_type VARCHAR2(80);
61998 l_component_code VARCHAR2(30);
61999 l_component_type_code VARCHAR2(1);
62000 l_component_appl_id INTEGER;
62001 l_amb_context_code VARCHAR2(30);
62002 l_entity_code VARCHAR2(30);
62003 l_event_class_code VARCHAR2(30);
62004 l_ae_header_id NUMBER;
62005 l_event_type_code VARCHAR2(30);
62006 l_line_definition_code VARCHAR2(30);
62007 l_line_definition_owner_code VARCHAR2(1);
62008 --
62009 -- adr variables
62010 l_segment VARCHAR2(30);
62011 l_ccid NUMBER;
62012 l_adr_transaction_coa_id NUMBER;
62013 l_adr_accounting_coa_id NUMBER;
62014 l_adr_flexfield_segment_code VARCHAR2(30);
62015 l_adr_flex_value_set_id NUMBER;
62016 l_adr_value_type_code VARCHAR2(30);
62017 l_adr_value_combination_id NUMBER;
62018 l_adr_value_segment_code VARCHAR2(30);
62019
62020 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
62021 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
62022 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
62023 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
62024
62025 -- 4262811 Variables ------------------------------------------------------------------------------------------
62026 l_entered_amt_idx NUMBER;
62027 l_accted_amt_idx NUMBER;
62028 l_acc_rev_flag VARCHAR2(1);
62029 l_accrual_line_num NUMBER;
62030 l_tmp_amt NUMBER;
62031 l_acc_rev_natural_side_code VARCHAR2(1);
62032
62033 l_num_entries NUMBER;
62034 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
62035 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
62036 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
62037 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
62038 l_recog_line_1 NUMBER;
62039 l_recog_line_2 NUMBER;
62040
62041 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
62042 l_bflow_applied_to_amt NUMBER; -- 5132302
62043 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
62044
62045 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
62046
62047 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
62048 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
62049
62050 ---------------------------------------------------------------------------------------------------------------
62051
62052
62053 --
62054 -- bulk performance
62055 --
62056 l_balance_type_code VARCHAR2(1);
62057 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
62058 l_log_module VARCHAR2(240);
62059
62060 --
62061 -- Upgrade strategy
62062 --
62063 l_actual_upg_option VARCHAR2(1);
62064 l_enc_upg_option VARCHAR2(1);
62065
62066 --
62067 BEGIN
62068 --
62069 IF g_log_enabled THEN
62070 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_134';
62071 END IF;
62072 --
62073 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62074
62075 trace
62076 (p_msg => 'BEGIN of AcctLineType_134'
62077 ,p_level => C_LEVEL_PROCEDURE
62078 ,p_module => l_log_module);
62079
62080 END IF;
62081 --
62082 l_component_type := 'AMB_JLT';
62083 l_component_code := 'INTERCOMPANY_ACCRUAL';
62084 l_component_type_code := 'S';
62085 l_component_appl_id := 707;
62086 l_amb_context_code := 'DEFAULT';
62087 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
62088 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
62089 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
62090 l_line_definition_owner_code := 'S';
62091 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
62092 --
62093 l_balance_type_code := 'A';
62094 l_segment := NULL;
62095 l_ccid := NULL;
62096 l_adr_transaction_coa_id := NULL;
62097 l_adr_accounting_coa_id := NULL;
62098 l_adr_flexfield_segment_code := NULL;
62099 l_adr_flex_value_set_id := NULL;
62100 l_adr_value_type_code := NULL;
62101 l_adr_value_combination_id := NULL;
62102 l_adr_value_segment_code := NULL;
62103
62104 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
62105 l_bflow_class_code := ''; -- 4219869 Business Flow
62106 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
62107 l_budgetary_control_flag := 'N';
62108
62109 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62110 l_bflow_applied_to_amt := NULL; -- 5132302
62111 l_entered_amt_idx := NULL; -- 4262811
62112 l_accted_amt_idx := NULL; -- 4262811
62113 l_acc_rev_flag := NULL; -- 4262811
62114 l_accrual_line_num := NULL; -- 4262811
62115 l_tmp_amt := NULL; -- 4262811
62116 --
62117
62118 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
62119 l_balance_type_code <> 'B' THEN
62120 IF NVL(p_source_97,9E125) = 2 AND
62121 p_source_95 < 0
62122 THEN
62123
62124 --
62125 XLA_AE_LINES_PKG.SetNewLine;
62126
62127 p_balance_type_code := l_balance_type_code;
62128 -- set the flag so later we will know whether the gain loss line needs to be created
62129
62130 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
62131 p_actual_flag :='A';
62132 END IF;
62133
62134 --
62135 -- bulk performance
62136 --
62137 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
62138 p_header_num => 0); -- 4262811
62139 --
62140 -- set accounting line options
62141 --
62142 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
62143 p_natural_side_code => 'D'
62144 , p_gain_or_loss_flag => 'N'
62145 , p_gl_transfer_mode_code => 'S'
62146 , p_acct_entry_type_code => 'A'
62147 , p_switch_side_flag => 'Y'
62148 , p_merge_duplicate_code => 'N'
62149 );
62150 --
62151 l_acc_rev_natural_side_code := 'C'; -- 4262811
62152 --
62153 --
62154 -- set accounting line type info
62155 --
62156 xla_ae_lines_pkg.SetAcctLineType
62157 (p_component_type => l_component_type
62158 ,p_event_type_code => l_event_type_code
62159 ,p_line_definition_owner_code => l_line_definition_owner_code
62160 ,p_line_definition_code => l_line_definition_code
62161 ,p_accounting_line_code => l_component_code
62162 ,p_accounting_line_type_code => l_component_type_code
62163 ,p_accounting_line_appl_id => l_component_appl_id
62164 ,p_amb_context_code => l_amb_context_code
62165 ,p_entity_code => l_entity_code
62166 ,p_event_class_code => l_event_class_code);
62167 --
62168 -- set accounting class
62169 --
62170 xla_ae_lines_pkg.SetAcctClass(
62171 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
62172 , p_ae_header_id => l_ae_header_id
62173 );
62174
62175 --
62176 -- set rounding class
62177 --
62178 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62179 'INTERCOMPANY_ACCRUAL';
62180
62181 --
62182 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62183 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62184 --
62185 -- bulk performance
62186 --
62187 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62188
62189 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62190 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62191
62192 -- 4955764
62193 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62194 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62195
62196 -- 4458381 Public Sector Enh
62197
62198 --
62199 -- set accounting attributes for the line type
62200 --
62201 l_entered_amt_idx := 17;
62202 l_accted_amt_idx := 22;
62203 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62204 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
62205 l_rec_acct_attrs.array_num_value(1) := p_source_79;
62206 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
62207 l_rec_acct_attrs.array_char_value(2) := p_source_80;
62208 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
62209 l_rec_acct_attrs.array_char_value(3) := p_source_81;
62210 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
62211 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
62212 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
62213 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
62214 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
62215 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
62216 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
62217 l_rec_acct_attrs.array_char_value(7) := p_source_85;
62218 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
62219 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
62220 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
62221 l_rec_acct_attrs.array_num_value(9) := p_source_87;
62222 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
62223 l_rec_acct_attrs.array_char_value(10) := p_source_88;
62224 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
62225 l_rec_acct_attrs.array_num_value(11) := p_source_89;
62226 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
62227 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
62228 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
62229 l_rec_acct_attrs.array_num_value(13) := p_source_87;
62230 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
62231 l_rec_acct_attrs.array_char_value(14) := p_source_88;
62232 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
62233 l_rec_acct_attrs.array_num_value(15) := p_source_89;
62234 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
62235 l_rec_acct_attrs.array_char_value(16) := p_source_100;
62236 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
62237 l_rec_acct_attrs.array_num_value(17) := p_source_91;
62238 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
62239 l_rec_acct_attrs.array_char_value(18) := p_source_88;
62240 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
62241 l_rec_acct_attrs.array_date_value(19) := p_source_92;
62242 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
62243 l_rec_acct_attrs.array_num_value(20) := p_source_93;
62244 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
62245 l_rec_acct_attrs.array_char_value(21) := p_source_94;
62246 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
62247 l_rec_acct_attrs.array_num_value(22) := p_source_95;
62248 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
62249 l_rec_acct_attrs.array_num_value(23) := p_source_104;
62250 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
62251 l_rec_acct_attrs.array_num_value(24) := p_source_104;
62252
62253 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62254 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62255
62256 ---------------------------------------------------------------------------------------------------------------
62257 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62258 ---------------------------------------------------------------------------------------------------------------
62259 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62260
62261 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62262 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62263
62264 IF xla_accounting_cache_pkg.GetValueChar
62265 (p_source_code => 'LEDGER_CATEGORY_CODE'
62266 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62267 AND l_bflow_method_code = 'PRIOR_ENTRY'
62268 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62269 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62270 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62271 )
62272 THEN
62273 xla_ae_lines_pkg.BflowUpgEntry
62274 (p_business_method_code => l_bflow_method_code
62275 ,p_business_class_code => l_bflow_class_code
62276 ,p_balance_type => l_balance_type_code);
62277 ELSE
62278 NULL;
62279 -- No business flow processing for business flow method of NONE.
62280 END IF;
62281
62282 --
62283 -- call analytical criteria
62284 --
62285
62286 --
62287 -- call description
62288 --
62289
62290 xla_ae_lines_pkg.SetLineDescription(
62291 p_ae_header_id => l_ae_header_id
62292 ,p_description => Description_1 (
62293 p_application_id => p_application_id
62294 , p_ae_header_id => l_ae_header_id
62295 , p_source_1 => p_source_1
62296 , p_source_2 => p_source_2
62297 , p_source_3 => p_source_3
62298 , p_source_4 => p_source_4
62299 , p_source_5 => p_source_5
62300 )
62301 );
62302
62303
62304 --
62305 -- call ADRs
62306 -- Bug 4922099
62307 --
62308 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62309 (NVL(l_actual_upg_option, 'N') = 'O') OR
62310 (NVL(l_enc_upg_option, 'N') = 'O')
62311 )
62312 THEN
62313 NULL;
62314 --
62315 --
62316
62317 l_ccid := AcctDerRule_6(
62318 p_application_id => p_application_id
62319 , p_ae_header_id => l_ae_header_id
62320 , p_source_11 => p_source_11
62321 , x_transaction_coa_id => l_adr_transaction_coa_id
62322 , x_accounting_coa_id => l_adr_accounting_coa_id
62323 , x_value_type_code => l_adr_value_type_code
62324 , p_side => 'NA'
62325 );
62326
62327 xla_ae_lines_pkg.set_ccid(
62328 p_code_combination_id => l_ccid
62329 , p_value_type_code => l_adr_value_type_code
62330 , p_transaction_coa_id => l_adr_transaction_coa_id
62331 , p_accounting_coa_id => l_adr_accounting_coa_id
62332 , p_adr_code => 'CST_DEFAULT'
62333 , p_adr_type_code => 'S'
62334 , p_component_type => l_component_type
62335 , p_component_code => l_component_code
62336 , p_component_type_code => l_component_type_code
62337 , p_component_appl_id => l_component_appl_id
62338 , p_amb_context_code => l_amb_context_code
62339 , p_side => 'NA'
62340 );
62341
62342
62343 --
62344 --
62345 END IF;
62346 --
62347 -- Bug 4922099
62348 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
62349 (NVL(l_enc_upg_option, 'N') = 'O')
62350 ) AND
62351 (l_bflow_method_code = 'PRIOR_ENTRY')
62352 )
62353 THEN
62354 IF
62355 --
62356 1 = 2
62357 --
62358 THEN
62359 xla_accounting_err_pkg.build_message
62360 (p_appli_s_name => 'XLA'
62361 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62362 ,p_token_1 => 'LINE_NUMBER'
62363 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
62364 ,p_token_2 => 'LINE_TYPE_NAME'
62365 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
62366 l_component_type
62367 ,l_component_code
62368 ,l_component_type_code
62369 ,l_component_appl_id
62370 ,l_amb_context_code
62371 ,l_entity_code
62372 ,l_event_class_code
62373 )
62374 ,p_token_3 => 'OWNER'
62375 ,p_value_3 => xla_lookups_pkg.get_meaning(
62376 p_lookup_type => 'XLA_OWNER_TYPE'
62377 ,p_lookup_code => l_component_type_code
62378 )
62379 ,p_token_4 => 'PRODUCT_NAME'
62380 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
62381 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
62382 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
62383 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
62384 ,p_ae_header_id => NULL
62385 );
62386
62387 IF (C_LEVEL_ERROR>= g_log_level) THEN
62388 trace
62389 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62390 ,p_level => C_LEVEL_ERROR
62391 ,p_module => l_log_module);
62392 END IF;
62393 END IF;
62394 END IF;
62395 --
62396 --
62397 ------------------------------------------------------------------------------------------------
62398 -- 4219869 Business Flow
62399 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
62400 -- Prior Entry. Currently, the following code is always generated.
62401 ------------------------------------------------------------------------------------------------
62402 XLA_AE_LINES_PKG.ValidateCurrentLine;
62403
62404 ------------------------------------------------------------------------------------
62405 -- 4219869 Business Flow
62406 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
62407 ------------------------------------------------------------------------------------
62408 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62409
62410 ----------------------------------------------------------------------------------
62411 -- 4219869 Business Flow
62412 -- Update journal entry status -- Need to generate this within IF <condition>
62413 ----------------------------------------------------------------------------------
62414 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62415 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
62416 ,p_balance_type_code => l_balance_type_code
62417 );
62418
62419 -------------------------------------------------------------------------------------------
62420 -- 4262811 - Generate the Accrual Reversal lines
62421 -------------------------------------------------------------------------------------------
62422 BEGIN
62423 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
62424 (g_array_event(p_event_id).array_value_num('header_index'));
62425 IF l_acc_rev_flag IS NULL THEN
62426 l_acc_rev_flag := 'N';
62427 END IF;
62428 EXCEPTION
62429 WHEN OTHERS THEN
62430 l_acc_rev_flag := 'N';
62431 END;
62432 --
62433 IF (l_acc_rev_flag = 'Y') THEN
62434
62435 -- 4645092 ------------------------------------------------------------------------------
62436 -- To allow MPA report to determine if it should generate report process
62437 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
62438 ------------------------------------------------------------------------------------------
62439
62440 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
62441 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
62442 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
62443 -- call ADRs
62444 -- Bug 4922099
62445 --
62446 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62447 (NVL(l_actual_upg_option, 'N') = 'O') OR
62448 (NVL(l_enc_upg_option, 'N') = 'O')
62449 )
62450 THEN
62451 NULL;
62452 --
62453 --
62454
62455 l_ccid := AcctDerRule_6(
62456 p_application_id => p_application_id
62457 , p_ae_header_id => l_ae_header_id
62458 , p_source_11 => p_source_11
62459 , x_transaction_coa_id => l_adr_transaction_coa_id
62460 , x_accounting_coa_id => l_adr_accounting_coa_id
62461 , x_value_type_code => l_adr_value_type_code
62462 , p_side => 'NA'
62463 );
62464
62465 xla_ae_lines_pkg.set_ccid(
62466 p_code_combination_id => l_ccid
62467 , p_value_type_code => l_adr_value_type_code
62468 , p_transaction_coa_id => l_adr_transaction_coa_id
62469 , p_accounting_coa_id => l_adr_accounting_coa_id
62470 , p_adr_code => 'CST_DEFAULT'
62471 , p_adr_type_code => 'S'
62472 , p_component_type => l_component_type
62473 , p_component_code => l_component_code
62474 , p_component_type_code => l_component_type_code
62475 , p_component_appl_id => l_component_appl_id
62476 , p_amb_context_code => l_amb_context_code
62477 , p_side => 'NA'
62478 );
62479
62480
62481 --
62482 --
62483 END IF;
62484
62485 --
62486 -- Update the line information that should be overwritten
62487 --
62488 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
62489 p_header_num => 1);
62490 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
62491
62492 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
62493
62494 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
62495 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
62496 END IF;
62497
62498 --
62499 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
62500 --
62501 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
62502 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
62503 ELSE
62504 ---------------------------------------------------------------------------------------------------
62505 -- 4262811a Switch Sign
62506 ---------------------------------------------------------------------------------------------------
62507 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
62508 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62509 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62510 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62511 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62512 -- 5132302
62513 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
62514 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62515
62516 END IF;
62517
62518 -- 4955764
62519 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62520 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
62521
62522
62523 XLA_AE_LINES_PKG.ValidateCurrentLine;
62524 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62525
62526 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62527 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
62528 ,p_balance_type_code => l_balance_type_code);
62529
62530 END IF;
62531
62532 -----------------------------------------------------------------------------------------
62533 -- 4262811 Multiperiod Accounting
62534 -----------------------------------------------------------------------------------------
62535 -- No MPA option is assigned.
62536
62537
62538 END IF;
62539 END IF;
62540 --
62541
62542 --
62543 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62544 trace
62545 (p_msg => 'END of AcctLineType_134'
62546 ,p_level => C_LEVEL_PROCEDURE
62547 ,p_module => l_log_module);
62548 END IF;
62549 --
62550 EXCEPTION
62551 WHEN xla_exceptions_pkg.application_exception THEN
62552 RAISE;
62553 WHEN OTHERS THEN
62554 xla_exceptions_pkg.raise_message
62555 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_134');
62556 END AcctLineType_134;
62557 --
62558
62559 ---------------------------------------
62560 --
62561 -- PRIVATE FUNCTION
62562 -- AcctLineType_135
62563 --
62564 ---------------------------------------
62565 PROCEDURE AcctLineType_135 (
62566 p_application_id IN NUMBER
62567 ,p_event_id IN NUMBER
62568 ,p_calculate_acctd_flag IN VARCHAR2
62569 ,p_calculate_g_l_flag IN VARCHAR2
62570 ,p_actual_flag IN OUT VARCHAR2
62571 ,p_balance_type_code OUT VARCHAR2
62572 ,p_gain_or_loss_ref OUT VARCHAR2
62573
62574 --Cost Management Default Account
62575 , p_source_11 IN NUMBER
62576 --Receiving Accounting Line Type
62577 , p_source_78 IN VARCHAR2
62578 --DISTRIBUTION_IDENTIFIER
62579 , p_source_84 IN NUMBER
62580 --Distribution Type
62581 , p_source_85 IN VARCHAR2
62582 , p_source_85_meaning IN VARCHAR2
62583 --Entered Currency Code
62584 , p_source_88 IN VARCHAR2
62585 --Entered Amount
62586 , p_source_91 IN NUMBER
62587 --Currency Conversion Date
62588 , p_source_92 IN DATE
62589 --Currency Conversion Rate
62590 , p_source_93 IN NUMBER
62591 --Currency Conversion Type
62592 , p_source_94 IN VARCHAR2
62593 --Accounted Amount
62594 , p_source_95 IN NUMBER
62595 )
62596 IS
62597
62598 l_component_type VARCHAR2(80);
62599 l_component_code VARCHAR2(30);
62600 l_component_type_code VARCHAR2(1);
62601 l_component_appl_id INTEGER;
62602 l_amb_context_code VARCHAR2(30);
62603 l_entity_code VARCHAR2(30);
62604 l_event_class_code VARCHAR2(30);
62605 l_ae_header_id NUMBER;
62606 l_event_type_code VARCHAR2(30);
62607 l_line_definition_code VARCHAR2(30);
62608 l_line_definition_owner_code VARCHAR2(1);
62609 --
62610 -- adr variables
62611 l_segment VARCHAR2(30);
62612 l_ccid NUMBER;
62613 l_adr_transaction_coa_id NUMBER;
62614 l_adr_accounting_coa_id NUMBER;
62615 l_adr_flexfield_segment_code VARCHAR2(30);
62616 l_adr_flex_value_set_id NUMBER;
62617 l_adr_value_type_code VARCHAR2(30);
62618 l_adr_value_combination_id NUMBER;
62619 l_adr_value_segment_code VARCHAR2(30);
62620
62621 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
62622 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
62623 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
62624 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
62625
62626 -- 4262811 Variables ------------------------------------------------------------------------------------------
62627 l_entered_amt_idx NUMBER;
62628 l_accted_amt_idx NUMBER;
62629 l_acc_rev_flag VARCHAR2(1);
62630 l_accrual_line_num NUMBER;
62631 l_tmp_amt NUMBER;
62632 l_acc_rev_natural_side_code VARCHAR2(1);
62633
62634 l_num_entries NUMBER;
62635 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
62636 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
62637 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
62638 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
62639 l_recog_line_1 NUMBER;
62640 l_recog_line_2 NUMBER;
62641
62642 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
62643 l_bflow_applied_to_amt NUMBER; -- 5132302
62644 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
62645
62646 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
62647
62648 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
62649 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
62650
62651 ---------------------------------------------------------------------------------------------------------------
62652
62653
62654 --
62655 -- bulk performance
62656 --
62657 l_balance_type_code VARCHAR2(1);
62658 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
62659 l_log_module VARCHAR2(240);
62660
62661 --
62662 -- Upgrade strategy
62663 --
62664 l_actual_upg_option VARCHAR2(1);
62665 l_enc_upg_option VARCHAR2(1);
62666
62667 --
62668 BEGIN
62669 --
62670 IF g_log_enabled THEN
62671 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_135';
62672 END IF;
62673 --
62674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62675
62676 trace
62677 (p_msg => 'BEGIN of AcctLineType_135'
62678 ,p_level => C_LEVEL_PROCEDURE
62679 ,p_module => l_log_module);
62680
62681 END IF;
62682 --
62683 l_component_type := 'AMB_JLT';
62684 l_component_code := 'INTERCOMPANY_ACCRUAL';
62685 l_component_type_code := 'S';
62686 l_component_appl_id := 707;
62687 l_amb_context_code := 'DEFAULT';
62688 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
62689 l_event_class_code := 'RCPT_REC_INSP';
62690 l_event_type_code := 'RCPT_REC_INSP_ALL';
62691 l_line_definition_owner_code := 'S';
62692 l_line_definition_code := 'RCPT_REC_INSP';
62693 --
62694 l_balance_type_code := 'A';
62695 l_segment := NULL;
62696 l_ccid := NULL;
62697 l_adr_transaction_coa_id := NULL;
62698 l_adr_accounting_coa_id := NULL;
62699 l_adr_flexfield_segment_code := NULL;
62700 l_adr_flex_value_set_id := NULL;
62701 l_adr_value_type_code := NULL;
62702 l_adr_value_combination_id := NULL;
62703 l_adr_value_segment_code := NULL;
62704
62705 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
62706 l_bflow_class_code := ''; -- 4219869 Business Flow
62707 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
62708 l_budgetary_control_flag := 'N';
62709
62710 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62711 l_bflow_applied_to_amt := NULL; -- 5132302
62712 l_entered_amt_idx := NULL; -- 4262811
62713 l_accted_amt_idx := NULL; -- 4262811
62714 l_acc_rev_flag := NULL; -- 4262811
62715 l_accrual_line_num := NULL; -- 4262811
62716 l_tmp_amt := NULL; -- 4262811
62717 --
62718
62719 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
62720 l_balance_type_code <> 'B' THEN
62721 IF NVL(p_source_78,'
62722 ') = 'IC Accrual'
62723 THEN
62724
62725 --
62726 XLA_AE_LINES_PKG.SetNewLine;
62727
62728 p_balance_type_code := l_balance_type_code;
62729 -- set the flag so later we will know whether the gain loss line needs to be created
62730
62731 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
62732 p_actual_flag :='A';
62733 END IF;
62734
62735 --
62736 -- bulk performance
62737 --
62738 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
62739 p_header_num => 0); -- 4262811
62740 --
62741 -- set accounting line options
62742 --
62743 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
62744 p_natural_side_code => 'D'
62745 , p_gain_or_loss_flag => 'N'
62746 , p_gl_transfer_mode_code => 'S'
62747 , p_acct_entry_type_code => 'A'
62748 , p_switch_side_flag => 'Y'
62749 , p_merge_duplicate_code => 'N'
62750 );
62751 --
62752 l_acc_rev_natural_side_code := 'C'; -- 4262811
62753 --
62754 --
62755 -- set accounting line type info
62756 --
62757 xla_ae_lines_pkg.SetAcctLineType
62758 (p_component_type => l_component_type
62759 ,p_event_type_code => l_event_type_code
62760 ,p_line_definition_owner_code => l_line_definition_owner_code
62761 ,p_line_definition_code => l_line_definition_code
62762 ,p_accounting_line_code => l_component_code
62763 ,p_accounting_line_type_code => l_component_type_code
62764 ,p_accounting_line_appl_id => l_component_appl_id
62765 ,p_amb_context_code => l_amb_context_code
62766 ,p_entity_code => l_entity_code
62767 ,p_event_class_code => l_event_class_code);
62768 --
62769 -- set accounting class
62770 --
62771 xla_ae_lines_pkg.SetAcctClass(
62772 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
62773 , p_ae_header_id => l_ae_header_id
62774 );
62775
62776 --
62777 -- set rounding class
62778 --
62779 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62780 'INTERCOMPANY_ACCRUAL';
62781
62782 --
62783 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62784 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62785 --
62786 -- bulk performance
62787 --
62788 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62789
62790 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62791 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62792
62793 -- 4955764
62794 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62795 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62796
62797 -- 4458381 Public Sector Enh
62798
62799 --
62800 -- set accounting attributes for the line type
62801 --
62802 l_entered_amt_idx := 3;
62803 l_accted_amt_idx := 8;
62804 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62805 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
62806 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
62807 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
62808 l_rec_acct_attrs.array_char_value(2) := p_source_85;
62809 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
62810 l_rec_acct_attrs.array_num_value(3) := p_source_91;
62811 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
62812 l_rec_acct_attrs.array_char_value(4) := p_source_88;
62813 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
62814 l_rec_acct_attrs.array_date_value(5) := p_source_92;
62815 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
62816 l_rec_acct_attrs.array_num_value(6) := p_source_93;
62817 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
62818 l_rec_acct_attrs.array_char_value(7) := p_source_94;
62819 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
62820 l_rec_acct_attrs.array_num_value(8) := p_source_95;
62821
62822 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62823 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62824
62825 ---------------------------------------------------------------------------------------------------------------
62826 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62827 ---------------------------------------------------------------------------------------------------------------
62828 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62829
62830 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62831 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62832
62833 IF xla_accounting_cache_pkg.GetValueChar
62834 (p_source_code => 'LEDGER_CATEGORY_CODE'
62835 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62836 AND l_bflow_method_code = 'PRIOR_ENTRY'
62837 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62838 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62839 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62840 )
62841 THEN
62842 xla_ae_lines_pkg.BflowUpgEntry
62843 (p_business_method_code => l_bflow_method_code
62844 ,p_business_class_code => l_bflow_class_code
62845 ,p_balance_type => l_balance_type_code);
62846 ELSE
62847 NULL;
62848 -- No business flow processing for business flow method of NONE.
62849 END IF;
62850
62851 --
62852 -- call analytical criteria
62853 --
62854
62855 --
62856 -- call description
62857 --
62858 -- No description or it is inherited.
62859 --
62860 -- call ADRs
62861 -- Bug 4922099
62862 --
62863 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62864 (NVL(l_actual_upg_option, 'N') = 'O') OR
62865 (NVL(l_enc_upg_option, 'N') = 'O')
62866 )
62867 THEN
62868 NULL;
62869 --
62870 --
62871
62872 l_ccid := AcctDerRule_6(
62873 p_application_id => p_application_id
62874 , p_ae_header_id => l_ae_header_id
62875 , p_source_11 => p_source_11
62876 , x_transaction_coa_id => l_adr_transaction_coa_id
62877 , x_accounting_coa_id => l_adr_accounting_coa_id
62878 , x_value_type_code => l_adr_value_type_code
62879 , p_side => 'NA'
62880 );
62881
62882 xla_ae_lines_pkg.set_ccid(
62883 p_code_combination_id => l_ccid
62884 , p_value_type_code => l_adr_value_type_code
62885 , p_transaction_coa_id => l_adr_transaction_coa_id
62886 , p_accounting_coa_id => l_adr_accounting_coa_id
62887 , p_adr_code => 'CST_DEFAULT'
62888 , p_adr_type_code => 'S'
62889 , p_component_type => l_component_type
62890 , p_component_code => l_component_code
62891 , p_component_type_code => l_component_type_code
62892 , p_component_appl_id => l_component_appl_id
62893 , p_amb_context_code => l_amb_context_code
62894 , p_side => 'NA'
62895 );
62896
62897
62898 --
62899 --
62900 END IF;
62901 --
62902 -- Bug 4922099
62903 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
62904 (NVL(l_enc_upg_option, 'N') = 'O')
62905 ) AND
62906 (l_bflow_method_code = 'PRIOR_ENTRY')
62907 )
62908 THEN
62909 IF
62910 --
62911 1 = 2
62912 --
62913 THEN
62914 xla_accounting_err_pkg.build_message
62915 (p_appli_s_name => 'XLA'
62916 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62917 ,p_token_1 => 'LINE_NUMBER'
62918 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
62919 ,p_token_2 => 'LINE_TYPE_NAME'
62920 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
62921 l_component_type
62922 ,l_component_code
62923 ,l_component_type_code
62924 ,l_component_appl_id
62925 ,l_amb_context_code
62926 ,l_entity_code
62927 ,l_event_class_code
62928 )
62929 ,p_token_3 => 'OWNER'
62930 ,p_value_3 => xla_lookups_pkg.get_meaning(
62931 p_lookup_type => 'XLA_OWNER_TYPE'
62932 ,p_lookup_code => l_component_type_code
62933 )
62934 ,p_token_4 => 'PRODUCT_NAME'
62935 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
62936 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
62937 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
62938 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
62939 ,p_ae_header_id => NULL
62940 );
62941
62942 IF (C_LEVEL_ERROR>= g_log_level) THEN
62943 trace
62944 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62945 ,p_level => C_LEVEL_ERROR
62946 ,p_module => l_log_module);
62947 END IF;
62948 END IF;
62949 END IF;
62950 --
62951 --
62952 ------------------------------------------------------------------------------------------------
62953 -- 4219869 Business Flow
62954 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
62955 -- Prior Entry. Currently, the following code is always generated.
62956 ------------------------------------------------------------------------------------------------
62957 XLA_AE_LINES_PKG.ValidateCurrentLine;
62958
62959 ------------------------------------------------------------------------------------
62960 -- 4219869 Business Flow
62961 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
62962 ------------------------------------------------------------------------------------
62963 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62964
62965 ----------------------------------------------------------------------------------
62966 -- 4219869 Business Flow
62967 -- Update journal entry status -- Need to generate this within IF <condition>
62968 ----------------------------------------------------------------------------------
62969 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62970 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
62971 ,p_balance_type_code => l_balance_type_code
62972 );
62973
62974 -------------------------------------------------------------------------------------------
62975 -- 4262811 - Generate the Accrual Reversal lines
62976 -------------------------------------------------------------------------------------------
62977 BEGIN
62978 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
62979 (g_array_event(p_event_id).array_value_num('header_index'));
62980 IF l_acc_rev_flag IS NULL THEN
62981 l_acc_rev_flag := 'N';
62982 END IF;
62983 EXCEPTION
62984 WHEN OTHERS THEN
62985 l_acc_rev_flag := 'N';
62986 END;
62987 --
62988 IF (l_acc_rev_flag = 'Y') THEN
62989
62990 -- 4645092 ------------------------------------------------------------------------------
62991 -- To allow MPA report to determine if it should generate report process
62992 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
62993 ------------------------------------------------------------------------------------------
62994
62995 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
62996 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
62997 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
62998 -- call ADRs
62999 -- Bug 4922099
63000 --
63001 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63002 (NVL(l_actual_upg_option, 'N') = 'O') OR
63003 (NVL(l_enc_upg_option, 'N') = 'O')
63004 )
63005 THEN
63006 NULL;
63007 --
63008 --
63009
63010 l_ccid := AcctDerRule_6(
63011 p_application_id => p_application_id
63012 , p_ae_header_id => l_ae_header_id
63013 , p_source_11 => p_source_11
63014 , x_transaction_coa_id => l_adr_transaction_coa_id
63015 , x_accounting_coa_id => l_adr_accounting_coa_id
63016 , x_value_type_code => l_adr_value_type_code
63017 , p_side => 'NA'
63018 );
63019
63020 xla_ae_lines_pkg.set_ccid(
63021 p_code_combination_id => l_ccid
63022 , p_value_type_code => l_adr_value_type_code
63023 , p_transaction_coa_id => l_adr_transaction_coa_id
63024 , p_accounting_coa_id => l_adr_accounting_coa_id
63025 , p_adr_code => 'CST_DEFAULT'
63026 , p_adr_type_code => 'S'
63027 , p_component_type => l_component_type
63028 , p_component_code => l_component_code
63029 , p_component_type_code => l_component_type_code
63030 , p_component_appl_id => l_component_appl_id
63031 , p_amb_context_code => l_amb_context_code
63032 , p_side => 'NA'
63033 );
63034
63035
63036 --
63037 --
63038 END IF;
63039
63040 --
63041 -- Update the line information that should be overwritten
63042 --
63043 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
63044 p_header_num => 1);
63045 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
63046
63047 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
63048
63049 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
63050 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
63051 END IF;
63052
63053 --
63054 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
63055 --
63056 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
63057 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
63058 ELSE
63059 ---------------------------------------------------------------------------------------------------
63060 -- 4262811a Switch Sign
63061 ---------------------------------------------------------------------------------------------------
63062 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
63063 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63064 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63065 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63066 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63067 -- 5132302
63068 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
63069 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63070
63071 END IF;
63072
63073 -- 4955764
63074 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63075 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
63076
63077
63078 XLA_AE_LINES_PKG.ValidateCurrentLine;
63079 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63080
63081 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63082 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
63083 ,p_balance_type_code => l_balance_type_code);
63084
63085 END IF;
63086
63087 -----------------------------------------------------------------------------------------
63088 -- 4262811 Multiperiod Accounting
63089 -----------------------------------------------------------------------------------------
63090 -- No MPA option is assigned.
63091
63092
63093 END IF;
63094 END IF;
63095 --
63096
63097 --
63098 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63099 trace
63100 (p_msg => 'END of AcctLineType_135'
63101 ,p_level => C_LEVEL_PROCEDURE
63102 ,p_module => l_log_module);
63103 END IF;
63104 --
63105 EXCEPTION
63106 WHEN xla_exceptions_pkg.application_exception THEN
63107 RAISE;
63108 WHEN OTHERS THEN
63109 xla_exceptions_pkg.raise_message
63110 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_135');
63111 END AcctLineType_135;
63112 --
63113
63114 ---------------------------------------
63115 --
63116 -- PRIVATE FUNCTION
63117 -- AcctLineType_136
63118 --
63119 ---------------------------------------
63120 PROCEDURE AcctLineType_136 (
63121 p_application_id IN NUMBER
63122 ,p_event_id IN NUMBER
63123 ,p_calculate_acctd_flag IN VARCHAR2
63124 ,p_calculate_g_l_flag IN VARCHAR2
63125 ,p_actual_flag IN OUT VARCHAR2
63126 ,p_balance_type_code OUT VARCHAR2
63127 ,p_gain_or_loss_ref OUT VARCHAR2
63128
63129 --TRANSACTION_ID
63130 , p_source_1 IN NUMBER
63131 --Item Concatenated Segments
63132 , p_source_2 IN VARCHAR2
63133 --Transaction Quantity
63134 , p_source_3 IN NUMBER
63135 --Transaction Unit of Measure Code
63136 , p_source_4 IN VARCHAR2
63137 --Inventory Transaction Type Description
63138 , p_source_5 IN VARCHAR2
63139 --Cost Management Default Account
63140 , p_source_11 IN NUMBER
63141 --DISTRIBUTION_IDENTIFIER
63142 , p_source_84 IN NUMBER
63143 --Distribution Type
63144 , p_source_85 IN VARCHAR2
63145 , p_source_85_meaning IN VARCHAR2
63146 --Entered Currency Code
63147 , p_source_88 IN VARCHAR2
63148 --Entered Amount
63149 , p_source_91 IN NUMBER
63150 --Currency Conversion Date
63151 , p_source_92 IN DATE
63152 --Currency Conversion Rate
63153 , p_source_93 IN NUMBER
63154 --Currency Conversion Type
63155 , p_source_94 IN VARCHAR2
63156 --Accounted Amount
63157 , p_source_95 IN NUMBER
63158 --Accounting Line Type
63159 , p_source_97 IN NUMBER
63160 )
63161 IS
63162
63163 l_component_type VARCHAR2(80);
63164 l_component_code VARCHAR2(30);
63165 l_component_type_code VARCHAR2(1);
63166 l_component_appl_id INTEGER;
63167 l_amb_context_code VARCHAR2(30);
63168 l_entity_code VARCHAR2(30);
63169 l_event_class_code VARCHAR2(30);
63170 l_ae_header_id NUMBER;
63171 l_event_type_code VARCHAR2(30);
63172 l_line_definition_code VARCHAR2(30);
63173 l_line_definition_owner_code VARCHAR2(1);
63174 --
63175 -- adr variables
63176 l_segment VARCHAR2(30);
63177 l_ccid NUMBER;
63178 l_adr_transaction_coa_id NUMBER;
63179 l_adr_accounting_coa_id NUMBER;
63180 l_adr_flexfield_segment_code VARCHAR2(30);
63181 l_adr_flex_value_set_id NUMBER;
63182 l_adr_value_type_code VARCHAR2(30);
63183 l_adr_value_combination_id NUMBER;
63184 l_adr_value_segment_code VARCHAR2(30);
63185
63186 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63187 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63188 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63189 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63190
63191 -- 4262811 Variables ------------------------------------------------------------------------------------------
63192 l_entered_amt_idx NUMBER;
63193 l_accted_amt_idx NUMBER;
63194 l_acc_rev_flag VARCHAR2(1);
63195 l_accrual_line_num NUMBER;
63196 l_tmp_amt NUMBER;
63197 l_acc_rev_natural_side_code VARCHAR2(1);
63198
63199 l_num_entries NUMBER;
63200 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63201 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63202 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63203 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63204 l_recog_line_1 NUMBER;
63205 l_recog_line_2 NUMBER;
63206
63207 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63208 l_bflow_applied_to_amt NUMBER; -- 5132302
63209 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63210
63211 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63212
63213 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63214 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63215
63216 ---------------------------------------------------------------------------------------------------------------
63217
63218
63219 --
63220 -- bulk performance
63221 --
63222 l_balance_type_code VARCHAR2(1);
63223 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63224 l_log_module VARCHAR2(240);
63225
63226 --
63227 -- Upgrade strategy
63228 --
63229 l_actual_upg_option VARCHAR2(1);
63230 l_enc_upg_option VARCHAR2(1);
63231
63232 --
63233 BEGIN
63234 --
63235 IF g_log_enabled THEN
63236 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_136';
63237 END IF;
63238 --
63239 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63240
63241 trace
63242 (p_msg => 'BEGIN of AcctLineType_136'
63243 ,p_level => C_LEVEL_PROCEDURE
63244 ,p_module => l_log_module);
63245
63246 END IF;
63247 --
63248 l_component_type := 'AMB_JLT';
63249 l_component_code := 'INTERCOMPANY_ACCRUAL';
63250 l_component_type_code := 'S';
63251 l_component_appl_id := 707;
63252 l_amb_context_code := 'DEFAULT';
63253 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
63254 l_event_class_code := 'USER_DEFINE';
63255 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
63256 l_line_definition_owner_code := 'S';
63257 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
63258 --
63259 l_balance_type_code := 'A';
63260 l_segment := NULL;
63261 l_ccid := NULL;
63262 l_adr_transaction_coa_id := NULL;
63263 l_adr_accounting_coa_id := NULL;
63264 l_adr_flexfield_segment_code := NULL;
63265 l_adr_flex_value_set_id := NULL;
63266 l_adr_value_type_code := NULL;
63267 l_adr_value_combination_id := NULL;
63268 l_adr_value_segment_code := NULL;
63269
63270 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
63271 l_bflow_class_code := ''; -- 4219869 Business Flow
63272 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
63273 l_budgetary_control_flag := 'N';
63274
63275 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63276 l_bflow_applied_to_amt := NULL; -- 5132302
63277 l_entered_amt_idx := NULL; -- 4262811
63278 l_accted_amt_idx := NULL; -- 4262811
63279 l_acc_rev_flag := NULL; -- 4262811
63280 l_accrual_line_num := NULL; -- 4262811
63281 l_tmp_amt := NULL; -- 4262811
63282 --
63283
63284 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
63285 l_balance_type_code <> 'B' THEN
63286 IF NVL(p_source_97,9E125) = 2 AND
63287 p_source_95 < 0
63288 THEN
63289
63290 --
63291 XLA_AE_LINES_PKG.SetNewLine;
63292
63293 p_balance_type_code := l_balance_type_code;
63294 -- set the flag so later we will know whether the gain loss line needs to be created
63295
63296 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
63297 p_actual_flag :='A';
63298 END IF;
63299
63300 --
63301 -- bulk performance
63302 --
63303 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
63304 p_header_num => 0); -- 4262811
63305 --
63306 -- set accounting line options
63307 --
63308 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
63309 p_natural_side_code => 'D'
63310 , p_gain_or_loss_flag => 'N'
63311 , p_gl_transfer_mode_code => 'S'
63312 , p_acct_entry_type_code => 'A'
63313 , p_switch_side_flag => 'Y'
63314 , p_merge_duplicate_code => 'N'
63315 );
63316 --
63317 l_acc_rev_natural_side_code := 'C'; -- 4262811
63318 --
63319 --
63320 -- set accounting line type info
63321 --
63322 xla_ae_lines_pkg.SetAcctLineType
63323 (p_component_type => l_component_type
63324 ,p_event_type_code => l_event_type_code
63325 ,p_line_definition_owner_code => l_line_definition_owner_code
63326 ,p_line_definition_code => l_line_definition_code
63327 ,p_accounting_line_code => l_component_code
63328 ,p_accounting_line_type_code => l_component_type_code
63329 ,p_accounting_line_appl_id => l_component_appl_id
63330 ,p_amb_context_code => l_amb_context_code
63331 ,p_entity_code => l_entity_code
63332 ,p_event_class_code => l_event_class_code);
63333 --
63334 -- set accounting class
63335 --
63336 xla_ae_lines_pkg.SetAcctClass(
63337 p_accounting_class_code => 'INTERCOMPANY_ACCRUAL'
63338 , p_ae_header_id => l_ae_header_id
63339 );
63340
63341 --
63342 -- set rounding class
63343 --
63344 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
63345 'INTERCOMPANY_ACCRUAL';
63346
63347 --
63348 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
63349 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
63350 --
63351 -- bulk performance
63352 --
63353 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
63354
63355 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
63356 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
63357
63358 -- 4955764
63359 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63360 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
63361
63362 -- 4458381 Public Sector Enh
63363
63364 --
63365 -- set accounting attributes for the line type
63366 --
63367 l_entered_amt_idx := 3;
63368 l_accted_amt_idx := 8;
63369 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63370 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
63371 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
63372 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
63373 l_rec_acct_attrs.array_char_value(2) := p_source_85;
63374 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
63375 l_rec_acct_attrs.array_num_value(3) := p_source_91;
63376 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
63377 l_rec_acct_attrs.array_char_value(4) := p_source_88;
63378 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
63379 l_rec_acct_attrs.array_date_value(5) := p_source_92;
63380 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
63381 l_rec_acct_attrs.array_num_value(6) := p_source_93;
63382 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
63383 l_rec_acct_attrs.array_char_value(7) := p_source_94;
63384 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
63385 l_rec_acct_attrs.array_num_value(8) := p_source_95;
63386
63387 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
63388 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
63389
63390 ---------------------------------------------------------------------------------------------------------------
63391 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
63392 ---------------------------------------------------------------------------------------------------------------
63393 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
63394
63395 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63396 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63397
63398 IF xla_accounting_cache_pkg.GetValueChar
63399 (p_source_code => 'LEDGER_CATEGORY_CODE'
63400 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
63401 AND l_bflow_method_code = 'PRIOR_ENTRY'
63402 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
63403 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
63404 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
63405 )
63406 THEN
63407 xla_ae_lines_pkg.BflowUpgEntry
63408 (p_business_method_code => l_bflow_method_code
63409 ,p_business_class_code => l_bflow_class_code
63410 ,p_balance_type => l_balance_type_code);
63411 ELSE
63412 NULL;
63413 -- No business flow processing for business flow method of NONE.
63414 END IF;
63415
63416 --
63417 -- call analytical criteria
63418 --
63419
63420 --
63421 -- call description
63422 --
63423
63424 xla_ae_lines_pkg.SetLineDescription(
63425 p_ae_header_id => l_ae_header_id
63426 ,p_description => Description_1 (
63427 p_application_id => p_application_id
63428 , p_ae_header_id => l_ae_header_id
63429 , p_source_1 => p_source_1
63430 , p_source_2 => p_source_2
63431 , p_source_3 => p_source_3
63432 , p_source_4 => p_source_4
63433 , p_source_5 => p_source_5
63434 )
63435 );
63436
63437
63438 --
63439 -- call ADRs
63440 -- Bug 4922099
63441 --
63442 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63443 (NVL(l_actual_upg_option, 'N') = 'O') OR
63444 (NVL(l_enc_upg_option, 'N') = 'O')
63445 )
63446 THEN
63447 NULL;
63448 --
63449 --
63450
63451 l_ccid := AcctDerRule_6(
63452 p_application_id => p_application_id
63453 , p_ae_header_id => l_ae_header_id
63454 , p_source_11 => p_source_11
63455 , x_transaction_coa_id => l_adr_transaction_coa_id
63456 , x_accounting_coa_id => l_adr_accounting_coa_id
63457 , x_value_type_code => l_adr_value_type_code
63458 , p_side => 'NA'
63459 );
63460
63461 xla_ae_lines_pkg.set_ccid(
63462 p_code_combination_id => l_ccid
63463 , p_value_type_code => l_adr_value_type_code
63464 , p_transaction_coa_id => l_adr_transaction_coa_id
63465 , p_accounting_coa_id => l_adr_accounting_coa_id
63466 , p_adr_code => 'CST_DEFAULT'
63467 , p_adr_type_code => 'S'
63468 , p_component_type => l_component_type
63469 , p_component_code => l_component_code
63470 , p_component_type_code => l_component_type_code
63471 , p_component_appl_id => l_component_appl_id
63472 , p_amb_context_code => l_amb_context_code
63473 , p_side => 'NA'
63474 );
63475
63476
63477 --
63478 --
63479 END IF;
63480 --
63481 -- Bug 4922099
63482 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
63483 (NVL(l_enc_upg_option, 'N') = 'O')
63484 ) AND
63485 (l_bflow_method_code = 'PRIOR_ENTRY')
63486 )
63487 THEN
63488 IF
63489 --
63490 1 = 2
63491 --
63492 THEN
63493 xla_accounting_err_pkg.build_message
63494 (p_appli_s_name => 'XLA'
63495 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63496 ,p_token_1 => 'LINE_NUMBER'
63497 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
63498 ,p_token_2 => 'LINE_TYPE_NAME'
63499 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
63500 l_component_type
63501 ,l_component_code
63502 ,l_component_type_code
63503 ,l_component_appl_id
63504 ,l_amb_context_code
63505 ,l_entity_code
63506 ,l_event_class_code
63507 )
63508 ,p_token_3 => 'OWNER'
63509 ,p_value_3 => xla_lookups_pkg.get_meaning(
63510 p_lookup_type => 'XLA_OWNER_TYPE'
63511 ,p_lookup_code => l_component_type_code
63512 )
63513 ,p_token_4 => 'PRODUCT_NAME'
63514 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
63515 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
63516 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
63517 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
63518 ,p_ae_header_id => NULL
63519 );
63520
63521 IF (C_LEVEL_ERROR>= g_log_level) THEN
63522 trace
63523 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63524 ,p_level => C_LEVEL_ERROR
63525 ,p_module => l_log_module);
63526 END IF;
63527 END IF;
63528 END IF;
63529 --
63530 --
63531 ------------------------------------------------------------------------------------------------
63532 -- 4219869 Business Flow
63533 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
63534 -- Prior Entry. Currently, the following code is always generated.
63535 ------------------------------------------------------------------------------------------------
63536 XLA_AE_LINES_PKG.ValidateCurrentLine;
63537
63538 ------------------------------------------------------------------------------------
63539 -- 4219869 Business Flow
63540 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
63541 ------------------------------------------------------------------------------------
63542 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63543
63544 ----------------------------------------------------------------------------------
63545 -- 4219869 Business Flow
63546 -- Update journal entry status -- Need to generate this within IF <condition>
63547 ----------------------------------------------------------------------------------
63548 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63549 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
63550 ,p_balance_type_code => l_balance_type_code
63551 );
63552
63553 -------------------------------------------------------------------------------------------
63554 -- 4262811 - Generate the Accrual Reversal lines
63555 -------------------------------------------------------------------------------------------
63556 BEGIN
63557 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
63558 (g_array_event(p_event_id).array_value_num('header_index'));
63559 IF l_acc_rev_flag IS NULL THEN
63560 l_acc_rev_flag := 'N';
63561 END IF;
63562 EXCEPTION
63563 WHEN OTHERS THEN
63564 l_acc_rev_flag := 'N';
63565 END;
63566 --
63567 IF (l_acc_rev_flag = 'Y') THEN
63568
63569 -- 4645092 ------------------------------------------------------------------------------
63570 -- To allow MPA report to determine if it should generate report process
63571 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
63572 ------------------------------------------------------------------------------------------
63573
63574 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
63575 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
63576 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
63577 -- call ADRs
63578 -- Bug 4922099
63579 --
63580 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63581 (NVL(l_actual_upg_option, 'N') = 'O') OR
63582 (NVL(l_enc_upg_option, 'N') = 'O')
63583 )
63584 THEN
63585 NULL;
63586 --
63587 --
63588
63589 l_ccid := AcctDerRule_6(
63590 p_application_id => p_application_id
63591 , p_ae_header_id => l_ae_header_id
63592 , p_source_11 => p_source_11
63593 , x_transaction_coa_id => l_adr_transaction_coa_id
63594 , x_accounting_coa_id => l_adr_accounting_coa_id
63595 , x_value_type_code => l_adr_value_type_code
63596 , p_side => 'NA'
63597 );
63598
63599 xla_ae_lines_pkg.set_ccid(
63600 p_code_combination_id => l_ccid
63601 , p_value_type_code => l_adr_value_type_code
63602 , p_transaction_coa_id => l_adr_transaction_coa_id
63603 , p_accounting_coa_id => l_adr_accounting_coa_id
63604 , p_adr_code => 'CST_DEFAULT'
63605 , p_adr_type_code => 'S'
63606 , p_component_type => l_component_type
63607 , p_component_code => l_component_code
63608 , p_component_type_code => l_component_type_code
63609 , p_component_appl_id => l_component_appl_id
63610 , p_amb_context_code => l_amb_context_code
63611 , p_side => 'NA'
63612 );
63613
63614
63615 --
63616 --
63617 END IF;
63618
63619 --
63620 -- Update the line information that should be overwritten
63621 --
63622 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
63623 p_header_num => 1);
63624 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
63625
63626 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
63627
63628 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
63629 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
63630 END IF;
63631
63632 --
63633 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
63634 --
63635 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
63636 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
63637 ELSE
63638 ---------------------------------------------------------------------------------------------------
63639 -- 4262811a Switch Sign
63640 ---------------------------------------------------------------------------------------------------
63641 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
63642 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63643 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63644 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63645 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63646 -- 5132302
63647 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
63648 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63649
63650 END IF;
63651
63652 -- 4955764
63653 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63654 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
63655
63656
63657 XLA_AE_LINES_PKG.ValidateCurrentLine;
63658 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63659
63660 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63661 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
63662 ,p_balance_type_code => l_balance_type_code);
63663
63664 END IF;
63665
63666 -----------------------------------------------------------------------------------------
63667 -- 4262811 Multiperiod Accounting
63668 -----------------------------------------------------------------------------------------
63669 -- No MPA option is assigned.
63670
63671
63672 END IF;
63673 END IF;
63674 --
63675
63676 --
63677 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63678 trace
63679 (p_msg => 'END of AcctLineType_136'
63680 ,p_level => C_LEVEL_PROCEDURE
63681 ,p_module => l_log_module);
63682 END IF;
63683 --
63684 EXCEPTION
63685 WHEN xla_exceptions_pkg.application_exception THEN
63686 RAISE;
63687 WHEN OTHERS THEN
63688 xla_exceptions_pkg.raise_message
63689 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_136');
63690 END AcctLineType_136;
63691 --
63692
63693 ---------------------------------------
63694 --
63695 -- PRIVATE FUNCTION
63696 -- AcctLineType_137
63697 --
63698 ---------------------------------------
63699 PROCEDURE AcctLineType_137 (
63700 p_application_id IN NUMBER
63701 ,p_event_id IN NUMBER
63702 ,p_calculate_acctd_flag IN VARCHAR2
63703 ,p_calculate_g_l_flag IN VARCHAR2
63704 ,p_actual_flag IN OUT VARCHAR2
63705 ,p_balance_type_code OUT VARCHAR2
63706 ,p_gain_or_loss_ref OUT VARCHAR2
63707
63708 --TRANSACTION_ID
63709 , p_source_1 IN NUMBER
63710 --Item Concatenated Segments
63711 , p_source_2 IN VARCHAR2
63712 --Transaction Quantity
63713 , p_source_3 IN NUMBER
63714 --Transaction Unit of Measure Code
63715 , p_source_4 IN VARCHAR2
63716 --Inventory Transaction Type Description
63717 , p_source_5 IN VARCHAR2
63718 --Cost Management Default Account
63719 , p_source_11 IN NUMBER
63720 --Transaction Action Name
63721 , p_source_62 IN NUMBER
63722 , p_source_62_meaning IN VARCHAR2
63723 --DISTRIBUTION_IDENTIFIER
63724 , p_source_84 IN NUMBER
63725 --Distribution Type
63726 , p_source_85 IN VARCHAR2
63727 , p_source_85_meaning IN VARCHAR2
63728 --Entered Currency Code
63729 , p_source_88 IN VARCHAR2
63730 --Entered Amount
63731 , p_source_91 IN NUMBER
63732 --Currency Conversion Date
63733 , p_source_92 IN DATE
63734 --Currency Conversion Rate
63735 , p_source_93 IN NUMBER
63736 --Currency Conversion Type
63737 , p_source_94 IN VARCHAR2
63738 --Accounted Amount
63739 , p_source_95 IN NUMBER
63740 --Accounting Line Type
63741 , p_source_97 IN NUMBER
63742 )
63743 IS
63744
63745 l_component_type VARCHAR2(80);
63746 l_component_code VARCHAR2(30);
63747 l_component_type_code VARCHAR2(1);
63748 l_component_appl_id INTEGER;
63749 l_amb_context_code VARCHAR2(30);
63750 l_entity_code VARCHAR2(30);
63751 l_event_class_code VARCHAR2(30);
63752 l_ae_header_id NUMBER;
63753 l_event_type_code VARCHAR2(30);
63754 l_line_definition_code VARCHAR2(30);
63755 l_line_definition_owner_code VARCHAR2(1);
63756 --
63757 -- adr variables
63758 l_segment VARCHAR2(30);
63759 l_ccid NUMBER;
63760 l_adr_transaction_coa_id NUMBER;
63761 l_adr_accounting_coa_id NUMBER;
63762 l_adr_flexfield_segment_code VARCHAR2(30);
63763 l_adr_flex_value_set_id NUMBER;
63764 l_adr_value_type_code VARCHAR2(30);
63765 l_adr_value_combination_id NUMBER;
63766 l_adr_value_segment_code VARCHAR2(30);
63767
63768 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63769 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63770 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63771 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63772
63773 -- 4262811 Variables ------------------------------------------------------------------------------------------
63774 l_entered_amt_idx NUMBER;
63775 l_accted_amt_idx NUMBER;
63776 l_acc_rev_flag VARCHAR2(1);
63777 l_accrual_line_num NUMBER;
63778 l_tmp_amt NUMBER;
63779 l_acc_rev_natural_side_code VARCHAR2(1);
63780
63781 l_num_entries NUMBER;
63782 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63783 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63784 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63785 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63786 l_recog_line_1 NUMBER;
63787 l_recog_line_2 NUMBER;
63788
63789 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63790 l_bflow_applied_to_amt NUMBER; -- 5132302
63791 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63792
63793 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63794
63795 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63796 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63797
63798 ---------------------------------------------------------------------------------------------------------------
63799
63800
63801 --
63802 -- bulk performance
63803 --
63804 l_balance_type_code VARCHAR2(1);
63805 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63806 l_log_module VARCHAR2(240);
63807
63808 --
63809 -- Upgrade strategy
63810 --
63811 l_actual_upg_option VARCHAR2(1);
63812 l_enc_upg_option VARCHAR2(1);
63813
63814 --
63815 BEGIN
63816 --
63817 IF g_log_enabled THEN
63818 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_137';
63819 END IF;
63820 --
63821 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63822
63823 trace
63824 (p_msg => 'BEGIN of AcctLineType_137'
63825 ,p_level => C_LEVEL_PROCEDURE
63826 ,p_module => l_log_module);
63827
63828 END IF;
63829 --
63830 l_component_type := 'AMB_JLT';
63831 l_component_code := 'INTERCOMPANY_COGS';
63832 l_component_type_code := 'S';
63833 l_component_appl_id := 707;
63834 l_amb_context_code := 'DEFAULT';
63835 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
63836 l_event_class_code := 'LOG_INTERCOMPANY';
63837 l_event_type_code := 'LOG_IC_SHIPMENT_RCPT';
63838 l_line_definition_owner_code := 'S';
63839 l_line_definition_code := 'PI_LOG_IC_SHIPMENT_RCPT';
63840 --
63841 l_balance_type_code := 'A';
63842 l_segment := NULL;
63843 l_ccid := NULL;
63844 l_adr_transaction_coa_id := NULL;
63845 l_adr_accounting_coa_id := NULL;
63846 l_adr_flexfield_segment_code := NULL;
63847 l_adr_flex_value_set_id := NULL;
63848 l_adr_value_type_code := NULL;
63849 l_adr_value_combination_id := NULL;
63850 l_adr_value_segment_code := NULL;
63851
63852 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
63853 l_bflow_class_code := ''; -- 4219869 Business Flow
63854 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
63855 l_budgetary_control_flag := 'N';
63856
63857 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63858 l_bflow_applied_to_amt := NULL; -- 5132302
63859 l_entered_amt_idx := NULL; -- 4262811
63860 l_accted_amt_idx := NULL; -- 4262811
63861 l_acc_rev_flag := NULL; -- 4262811
63862 l_accrual_line_num := NULL; -- 4262811
63863 l_tmp_amt := NULL; -- 4262811
63864 --
63865
63866 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
63867 l_balance_type_code <> 'B' THEN
63868 IF NVL(p_source_97,9E125) = 2 AND
63869 ((p_source_95 >= 0 AND
63870 NVL(p_source_62,9E125) = 9) OR
63871 (p_source_95 <= 0 AND
63872 NVL(p_source_62,9E125) = 14)
63873 ) THEN
63874
63875 --
63876 XLA_AE_LINES_PKG.SetNewLine;
63877
63878 p_balance_type_code := l_balance_type_code;
63879 -- set the flag so later we will know whether the gain loss line needs to be created
63880
63881 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
63882 p_actual_flag :='A';
63883 END IF;
63884
63885 --
63886 -- bulk performance
63887 --
63888 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
63889 p_header_num => 0); -- 4262811
63890 --
63891 -- set accounting line options
63892 --
63893 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
63894 p_natural_side_code => 'D'
63895 , p_gain_or_loss_flag => 'N'
63896 , p_gl_transfer_mode_code => 'S'
63897 , p_acct_entry_type_code => 'A'
63898 , p_switch_side_flag => 'Y'
63899 , p_merge_duplicate_code => 'N'
63900 );
63901 --
63902 l_acc_rev_natural_side_code := 'C'; -- 4262811
63903 --
63904 --
63905 -- set accounting line type info
63906 --
63907 xla_ae_lines_pkg.SetAcctLineType
63908 (p_component_type => l_component_type
63909 ,p_event_type_code => l_event_type_code
63910 ,p_line_definition_owner_code => l_line_definition_owner_code
63911 ,p_line_definition_code => l_line_definition_code
63912 ,p_accounting_line_code => l_component_code
63913 ,p_accounting_line_type_code => l_component_type_code
63914 ,p_accounting_line_appl_id => l_component_appl_id
63915 ,p_amb_context_code => l_amb_context_code
63916 ,p_entity_code => l_entity_code
63917 ,p_event_class_code => l_event_class_code);
63918 --
63919 -- set accounting class
63920 --
63921 xla_ae_lines_pkg.SetAcctClass(
63922 p_accounting_class_code => 'INTERCOMPANY_COGS'
63923 , p_ae_header_id => l_ae_header_id
63924 );
63925
63926 --
63927 -- set rounding class
63928 --
63929 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
63930 'INTERCOMPANY_COGS';
63931
63932 --
63933 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
63934 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
63935 --
63936 -- bulk performance
63937 --
63938 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
63939
63940 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
63941 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
63942
63943 -- 4955764
63944 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63945 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
63946
63947 -- 4458381 Public Sector Enh
63948
63949 --
63950 -- set accounting attributes for the line type
63951 --
63952 l_entered_amt_idx := 3;
63953 l_accted_amt_idx := 8;
63954 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63955 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
63956 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
63957 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
63958 l_rec_acct_attrs.array_char_value(2) := p_source_85;
63959 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
63960 l_rec_acct_attrs.array_num_value(3) := p_source_91;
63961 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
63962 l_rec_acct_attrs.array_char_value(4) := p_source_88;
63963 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
63964 l_rec_acct_attrs.array_date_value(5) := p_source_92;
63965 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
63966 l_rec_acct_attrs.array_num_value(6) := p_source_93;
63967 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
63968 l_rec_acct_attrs.array_char_value(7) := p_source_94;
63969 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
63970 l_rec_acct_attrs.array_num_value(8) := p_source_95;
63971
63972 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
63973 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
63974
63975 ---------------------------------------------------------------------------------------------------------------
63976 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
63977 ---------------------------------------------------------------------------------------------------------------
63978 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
63979
63980 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63981 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63982
63983 IF xla_accounting_cache_pkg.GetValueChar
63984 (p_source_code => 'LEDGER_CATEGORY_CODE'
63985 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
63986 AND l_bflow_method_code = 'PRIOR_ENTRY'
63987 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
63988 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
63989 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
63990 )
63991 THEN
63992 xla_ae_lines_pkg.BflowUpgEntry
63993 (p_business_method_code => l_bflow_method_code
63994 ,p_business_class_code => l_bflow_class_code
63995 ,p_balance_type => l_balance_type_code);
63996 ELSE
63997 NULL;
63998 -- No business flow processing for business flow method of NONE.
63999 END IF;
64000
64001 --
64002 -- call analytical criteria
64003 --
64004
64005 --
64006 -- call description
64007 --
64008
64009 xla_ae_lines_pkg.SetLineDescription(
64010 p_ae_header_id => l_ae_header_id
64011 ,p_description => Description_1 (
64012 p_application_id => p_application_id
64013 , p_ae_header_id => l_ae_header_id
64014 , p_source_1 => p_source_1
64015 , p_source_2 => p_source_2
64016 , p_source_3 => p_source_3
64017 , p_source_4 => p_source_4
64018 , p_source_5 => p_source_5
64019 )
64020 );
64021
64022
64023 --
64024 -- call ADRs
64025 -- Bug 4922099
64026 --
64027 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64028 (NVL(l_actual_upg_option, 'N') = 'O') OR
64029 (NVL(l_enc_upg_option, 'N') = 'O')
64030 )
64031 THEN
64032 NULL;
64033 --
64034 --
64035
64036 l_ccid := AcctDerRule_6(
64037 p_application_id => p_application_id
64038 , p_ae_header_id => l_ae_header_id
64039 , p_source_11 => p_source_11
64040 , x_transaction_coa_id => l_adr_transaction_coa_id
64041 , x_accounting_coa_id => l_adr_accounting_coa_id
64042 , x_value_type_code => l_adr_value_type_code
64043 , p_side => 'NA'
64044 );
64045
64046 xla_ae_lines_pkg.set_ccid(
64047 p_code_combination_id => l_ccid
64048 , p_value_type_code => l_adr_value_type_code
64049 , p_transaction_coa_id => l_adr_transaction_coa_id
64050 , p_accounting_coa_id => l_adr_accounting_coa_id
64051 , p_adr_code => 'CST_DEFAULT'
64052 , p_adr_type_code => 'S'
64053 , p_component_type => l_component_type
64054 , p_component_code => l_component_code
64055 , p_component_type_code => l_component_type_code
64056 , p_component_appl_id => l_component_appl_id
64057 , p_amb_context_code => l_amb_context_code
64058 , p_side => 'NA'
64059 );
64060
64061
64062 --
64063 --
64064 END IF;
64065 --
64066 -- Bug 4922099
64067 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64068 (NVL(l_enc_upg_option, 'N') = 'O')
64069 ) AND
64070 (l_bflow_method_code = 'PRIOR_ENTRY')
64071 )
64072 THEN
64073 IF
64074 --
64075 1 = 2
64076 --
64077 THEN
64078 xla_accounting_err_pkg.build_message
64079 (p_appli_s_name => 'XLA'
64080 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64081 ,p_token_1 => 'LINE_NUMBER'
64082 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64083 ,p_token_2 => 'LINE_TYPE_NAME'
64084 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64085 l_component_type
64086 ,l_component_code
64087 ,l_component_type_code
64088 ,l_component_appl_id
64089 ,l_amb_context_code
64090 ,l_entity_code
64091 ,l_event_class_code
64092 )
64093 ,p_token_3 => 'OWNER'
64094 ,p_value_3 => xla_lookups_pkg.get_meaning(
64095 p_lookup_type => 'XLA_OWNER_TYPE'
64096 ,p_lookup_code => l_component_type_code
64097 )
64098 ,p_token_4 => 'PRODUCT_NAME'
64099 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64100 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64101 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64102 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64103 ,p_ae_header_id => NULL
64104 );
64105
64106 IF (C_LEVEL_ERROR>= g_log_level) THEN
64107 trace
64108 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64109 ,p_level => C_LEVEL_ERROR
64110 ,p_module => l_log_module);
64111 END IF;
64112 END IF;
64113 END IF;
64114 --
64115 --
64116 ------------------------------------------------------------------------------------------------
64117 -- 4219869 Business Flow
64118 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64119 -- Prior Entry. Currently, the following code is always generated.
64120 ------------------------------------------------------------------------------------------------
64121 XLA_AE_LINES_PKG.ValidateCurrentLine;
64122
64123 ------------------------------------------------------------------------------------
64124 -- 4219869 Business Flow
64125 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64126 ------------------------------------------------------------------------------------
64127 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64128
64129 ----------------------------------------------------------------------------------
64130 -- 4219869 Business Flow
64131 -- Update journal entry status -- Need to generate this within IF <condition>
64132 ----------------------------------------------------------------------------------
64133 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64134 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64135 ,p_balance_type_code => l_balance_type_code
64136 );
64137
64138 -------------------------------------------------------------------------------------------
64139 -- 4262811 - Generate the Accrual Reversal lines
64140 -------------------------------------------------------------------------------------------
64141 BEGIN
64142 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
64143 (g_array_event(p_event_id).array_value_num('header_index'));
64144 IF l_acc_rev_flag IS NULL THEN
64145 l_acc_rev_flag := 'N';
64146 END IF;
64147 EXCEPTION
64148 WHEN OTHERS THEN
64149 l_acc_rev_flag := 'N';
64150 END;
64151 --
64152 IF (l_acc_rev_flag = 'Y') THEN
64153
64154 -- 4645092 ------------------------------------------------------------------------------
64155 -- To allow MPA report to determine if it should generate report process
64156 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
64157 ------------------------------------------------------------------------------------------
64158
64159 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
64160 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
64161 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
64162 -- call ADRs
64163 -- Bug 4922099
64164 --
64165 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64166 (NVL(l_actual_upg_option, 'N') = 'O') OR
64167 (NVL(l_enc_upg_option, 'N') = 'O')
64168 )
64169 THEN
64170 NULL;
64171 --
64172 --
64173
64174 l_ccid := AcctDerRule_6(
64175 p_application_id => p_application_id
64176 , p_ae_header_id => l_ae_header_id
64177 , p_source_11 => p_source_11
64178 , x_transaction_coa_id => l_adr_transaction_coa_id
64179 , x_accounting_coa_id => l_adr_accounting_coa_id
64180 , x_value_type_code => l_adr_value_type_code
64181 , p_side => 'NA'
64182 );
64183
64184 xla_ae_lines_pkg.set_ccid(
64185 p_code_combination_id => l_ccid
64186 , p_value_type_code => l_adr_value_type_code
64187 , p_transaction_coa_id => l_adr_transaction_coa_id
64188 , p_accounting_coa_id => l_adr_accounting_coa_id
64189 , p_adr_code => 'CST_DEFAULT'
64190 , p_adr_type_code => 'S'
64191 , p_component_type => l_component_type
64192 , p_component_code => l_component_code
64193 , p_component_type_code => l_component_type_code
64194 , p_component_appl_id => l_component_appl_id
64195 , p_amb_context_code => l_amb_context_code
64196 , p_side => 'NA'
64197 );
64198
64199
64200 --
64201 --
64202 END IF;
64203
64204 --
64205 -- Update the line information that should be overwritten
64206 --
64207 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
64208 p_header_num => 1);
64209 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
64210
64211 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
64212
64213 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
64214 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
64215 END IF;
64216
64217 --
64218 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
64219 --
64220 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
64221 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
64222 ELSE
64223 ---------------------------------------------------------------------------------------------------
64224 -- 4262811a Switch Sign
64225 ---------------------------------------------------------------------------------------------------
64226 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
64227 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64229 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64230 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64231 -- 5132302
64232 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
64233 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64234
64235 END IF;
64236
64237 -- 4955764
64238 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64239 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
64240
64241
64242 XLA_AE_LINES_PKG.ValidateCurrentLine;
64243 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64244
64245 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64246 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
64247 ,p_balance_type_code => l_balance_type_code);
64248
64249 END IF;
64250
64251 -----------------------------------------------------------------------------------------
64252 -- 4262811 Multiperiod Accounting
64253 -----------------------------------------------------------------------------------------
64254 -- No MPA option is assigned.
64255
64256
64257 END IF;
64258 END IF;
64259 --
64260
64261 --
64262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64263 trace
64264 (p_msg => 'END of AcctLineType_137'
64265 ,p_level => C_LEVEL_PROCEDURE
64266 ,p_module => l_log_module);
64267 END IF;
64268 --
64269 EXCEPTION
64270 WHEN xla_exceptions_pkg.application_exception THEN
64271 RAISE;
64272 WHEN OTHERS THEN
64273 xla_exceptions_pkg.raise_message
64274 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_137');
64275 END AcctLineType_137;
64276 --
64277
64278 ---------------------------------------
64279 --
64280 -- PRIVATE FUNCTION
64281 -- AcctLineType_138
64282 --
64283 ---------------------------------------
64284 PROCEDURE AcctLineType_138 (
64285 p_application_id IN NUMBER
64286 ,p_event_id IN NUMBER
64287 ,p_calculate_acctd_flag IN VARCHAR2
64288 ,p_calculate_g_l_flag IN VARCHAR2
64289 ,p_actual_flag IN OUT VARCHAR2
64290 ,p_balance_type_code OUT VARCHAR2
64291 ,p_gain_or_loss_ref OUT VARCHAR2
64292
64293 --TRANSACTION_ID
64294 , p_source_1 IN NUMBER
64295 --Item Concatenated Segments
64296 , p_source_2 IN VARCHAR2
64297 --Transaction Quantity
64298 , p_source_3 IN NUMBER
64299 --Transaction Unit of Measure Code
64300 , p_source_4 IN VARCHAR2
64301 --Inventory Transaction Type Description
64302 , p_source_5 IN VARCHAR2
64303 --Cost Management Default Account
64304 , p_source_11 IN NUMBER
64305 --Transaction Action Name
64306 , p_source_62 IN NUMBER
64307 , p_source_62_meaning IN VARCHAR2
64308 --DISTRIBUTION_IDENTIFIER
64309 , p_source_84 IN NUMBER
64310 --Distribution Type
64311 , p_source_85 IN VARCHAR2
64312 , p_source_85_meaning IN VARCHAR2
64313 --Entered Currency Code
64314 , p_source_88 IN VARCHAR2
64315 --Entered Amount
64316 , p_source_91 IN NUMBER
64317 --Currency Conversion Date
64318 , p_source_92 IN DATE
64319 --Currency Conversion Rate
64320 , p_source_93 IN NUMBER
64321 --Currency Conversion Type
64322 , p_source_94 IN VARCHAR2
64323 --Accounted Amount
64324 , p_source_95 IN NUMBER
64325 --Accounting Line Type
64326 , p_source_97 IN NUMBER
64327 )
64328 IS
64329
64330 l_component_type VARCHAR2(80);
64331 l_component_code VARCHAR2(30);
64332 l_component_type_code VARCHAR2(1);
64333 l_component_appl_id INTEGER;
64334 l_amb_context_code VARCHAR2(30);
64335 l_entity_code VARCHAR2(30);
64336 l_event_class_code VARCHAR2(30);
64337 l_ae_header_id NUMBER;
64338 l_event_type_code VARCHAR2(30);
64339 l_line_definition_code VARCHAR2(30);
64340 l_line_definition_owner_code VARCHAR2(1);
64341 --
64342 -- adr variables
64343 l_segment VARCHAR2(30);
64344 l_ccid NUMBER;
64345 l_adr_transaction_coa_id NUMBER;
64346 l_adr_accounting_coa_id NUMBER;
64347 l_adr_flexfield_segment_code VARCHAR2(30);
64348 l_adr_flex_value_set_id NUMBER;
64349 l_adr_value_type_code VARCHAR2(30);
64350 l_adr_value_combination_id NUMBER;
64351 l_adr_value_segment_code VARCHAR2(30);
64352
64353 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
64354 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
64355 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
64356 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
64357
64358 -- 4262811 Variables ------------------------------------------------------------------------------------------
64359 l_entered_amt_idx NUMBER;
64360 l_accted_amt_idx NUMBER;
64361 l_acc_rev_flag VARCHAR2(1);
64362 l_accrual_line_num NUMBER;
64363 l_tmp_amt NUMBER;
64364 l_acc_rev_natural_side_code VARCHAR2(1);
64365
64366 l_num_entries NUMBER;
64367 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
64368 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
64369 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
64370 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
64371 l_recog_line_1 NUMBER;
64372 l_recog_line_2 NUMBER;
64373
64374 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
64375 l_bflow_applied_to_amt NUMBER; -- 5132302
64376 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
64377
64378 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
64379
64380 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
64381 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
64382
64383 ---------------------------------------------------------------------------------------------------------------
64384
64385
64386 --
64387 -- bulk performance
64388 --
64389 l_balance_type_code VARCHAR2(1);
64390 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64391 l_log_module VARCHAR2(240);
64392
64393 --
64394 -- Upgrade strategy
64395 --
64396 l_actual_upg_option VARCHAR2(1);
64397 l_enc_upg_option VARCHAR2(1);
64398
64399 --
64400 BEGIN
64401 --
64402 IF g_log_enabled THEN
64403 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_138';
64404 END IF;
64405 --
64406 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64407
64408 trace
64409 (p_msg => 'BEGIN of AcctLineType_138'
64410 ,p_level => C_LEVEL_PROCEDURE
64411 ,p_module => l_log_module);
64412
64413 END IF;
64414 --
64415 l_component_type := 'AMB_JLT';
64416 l_component_code := 'INTERCOMPANY_COGS';
64417 l_component_type_code := 'S';
64418 l_component_appl_id := 707;
64419 l_amb_context_code := 'DEFAULT';
64420 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
64421 l_event_class_code := 'LOG_INTERCOMPANY';
64422 l_event_type_code := 'LOG_IC_RCPT_RETURN';
64423 l_line_definition_owner_code := 'S';
64424 l_line_definition_code := 'PI_LOG_IC_RCPT_RETURN';
64425 --
64426 l_balance_type_code := 'A';
64427 l_segment := NULL;
64428 l_ccid := NULL;
64429 l_adr_transaction_coa_id := NULL;
64430 l_adr_accounting_coa_id := NULL;
64431 l_adr_flexfield_segment_code := NULL;
64432 l_adr_flex_value_set_id := NULL;
64433 l_adr_value_type_code := NULL;
64434 l_adr_value_combination_id := NULL;
64435 l_adr_value_segment_code := NULL;
64436
64437 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
64438 l_bflow_class_code := ''; -- 4219869 Business Flow
64439 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
64440 l_budgetary_control_flag := 'N';
64441
64442 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64443 l_bflow_applied_to_amt := NULL; -- 5132302
64444 l_entered_amt_idx := NULL; -- 4262811
64445 l_accted_amt_idx := NULL; -- 4262811
64446 l_acc_rev_flag := NULL; -- 4262811
64447 l_accrual_line_num := NULL; -- 4262811
64448 l_tmp_amt := NULL; -- 4262811
64449 --
64450
64451 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
64452 l_balance_type_code <> 'B' THEN
64453 IF NVL(p_source_97,9E125) = 2 AND
64454 ((p_source_95 >= 0 AND
64455 NVL(p_source_62,9E125) = 9) OR
64456 (p_source_95 <= 0 AND
64457 NVL(p_source_62,9E125) = 14)
64458 ) THEN
64459
64460 --
64461 XLA_AE_LINES_PKG.SetNewLine;
64462
64463 p_balance_type_code := l_balance_type_code;
64464 -- set the flag so later we will know whether the gain loss line needs to be created
64465
64466 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
64467 p_actual_flag :='A';
64468 END IF;
64469
64470 --
64471 -- bulk performance
64472 --
64473 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
64474 p_header_num => 0); -- 4262811
64475 --
64476 -- set accounting line options
64477 --
64478 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
64479 p_natural_side_code => 'D'
64480 , p_gain_or_loss_flag => 'N'
64481 , p_gl_transfer_mode_code => 'S'
64482 , p_acct_entry_type_code => 'A'
64483 , p_switch_side_flag => 'Y'
64484 , p_merge_duplicate_code => 'N'
64485 );
64486 --
64487 l_acc_rev_natural_side_code := 'C'; -- 4262811
64488 --
64489 --
64490 -- set accounting line type info
64491 --
64492 xla_ae_lines_pkg.SetAcctLineType
64493 (p_component_type => l_component_type
64494 ,p_event_type_code => l_event_type_code
64495 ,p_line_definition_owner_code => l_line_definition_owner_code
64496 ,p_line_definition_code => l_line_definition_code
64497 ,p_accounting_line_code => l_component_code
64498 ,p_accounting_line_type_code => l_component_type_code
64499 ,p_accounting_line_appl_id => l_component_appl_id
64500 ,p_amb_context_code => l_amb_context_code
64501 ,p_entity_code => l_entity_code
64502 ,p_event_class_code => l_event_class_code);
64503 --
64504 -- set accounting class
64505 --
64506 xla_ae_lines_pkg.SetAcctClass(
64507 p_accounting_class_code => 'INTERCOMPANY_COGS'
64508 , p_ae_header_id => l_ae_header_id
64509 );
64510
64511 --
64512 -- set rounding class
64513 --
64514 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
64515 'INTERCOMPANY_COGS';
64516
64517 --
64518 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
64519 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
64520 --
64521 -- bulk performance
64522 --
64523 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
64524
64525 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
64526 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
64527
64528 -- 4955764
64529 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64530 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
64531
64532 -- 4458381 Public Sector Enh
64533
64534 --
64535 -- set accounting attributes for the line type
64536 --
64537 l_entered_amt_idx := 3;
64538 l_accted_amt_idx := 8;
64539 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64540 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
64541 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
64542 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
64543 l_rec_acct_attrs.array_char_value(2) := p_source_85;
64544 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
64545 l_rec_acct_attrs.array_num_value(3) := p_source_91;
64546 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
64547 l_rec_acct_attrs.array_char_value(4) := p_source_88;
64548 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
64549 l_rec_acct_attrs.array_date_value(5) := p_source_92;
64550 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
64551 l_rec_acct_attrs.array_num_value(6) := p_source_93;
64552 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
64553 l_rec_acct_attrs.array_char_value(7) := p_source_94;
64554 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
64555 l_rec_acct_attrs.array_num_value(8) := p_source_95;
64556
64557 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
64558 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
64559
64560 ---------------------------------------------------------------------------------------------------------------
64561 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
64562 ---------------------------------------------------------------------------------------------------------------
64563 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
64564
64565 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64566 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64567
64568 IF xla_accounting_cache_pkg.GetValueChar
64569 (p_source_code => 'LEDGER_CATEGORY_CODE'
64570 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
64571 AND l_bflow_method_code = 'PRIOR_ENTRY'
64572 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
64573 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
64574 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
64575 )
64576 THEN
64577 xla_ae_lines_pkg.BflowUpgEntry
64578 (p_business_method_code => l_bflow_method_code
64579 ,p_business_class_code => l_bflow_class_code
64580 ,p_balance_type => l_balance_type_code);
64581 ELSE
64582 NULL;
64583 -- No business flow processing for business flow method of NONE.
64584 END IF;
64585
64586 --
64587 -- call analytical criteria
64588 --
64589
64590 --
64591 -- call description
64592 --
64593
64594 xla_ae_lines_pkg.SetLineDescription(
64595 p_ae_header_id => l_ae_header_id
64596 ,p_description => Description_1 (
64597 p_application_id => p_application_id
64598 , p_ae_header_id => l_ae_header_id
64599 , p_source_1 => p_source_1
64600 , p_source_2 => p_source_2
64601 , p_source_3 => p_source_3
64602 , p_source_4 => p_source_4
64603 , p_source_5 => p_source_5
64604 )
64605 );
64606
64607
64608 --
64609 -- call ADRs
64610 -- Bug 4922099
64611 --
64612 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64613 (NVL(l_actual_upg_option, 'N') = 'O') OR
64614 (NVL(l_enc_upg_option, 'N') = 'O')
64615 )
64616 THEN
64617 NULL;
64618 --
64619 --
64620
64621 l_ccid := AcctDerRule_6(
64622 p_application_id => p_application_id
64623 , p_ae_header_id => l_ae_header_id
64624 , p_source_11 => p_source_11
64625 , x_transaction_coa_id => l_adr_transaction_coa_id
64626 , x_accounting_coa_id => l_adr_accounting_coa_id
64627 , x_value_type_code => l_adr_value_type_code
64628 , p_side => 'NA'
64629 );
64630
64631 xla_ae_lines_pkg.set_ccid(
64632 p_code_combination_id => l_ccid
64633 , p_value_type_code => l_adr_value_type_code
64634 , p_transaction_coa_id => l_adr_transaction_coa_id
64635 , p_accounting_coa_id => l_adr_accounting_coa_id
64636 , p_adr_code => 'CST_DEFAULT'
64637 , p_adr_type_code => 'S'
64638 , p_component_type => l_component_type
64639 , p_component_code => l_component_code
64640 , p_component_type_code => l_component_type_code
64641 , p_component_appl_id => l_component_appl_id
64642 , p_amb_context_code => l_amb_context_code
64643 , p_side => 'NA'
64644 );
64645
64646
64647 --
64648 --
64649 END IF;
64650 --
64651 -- Bug 4922099
64652 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64653 (NVL(l_enc_upg_option, 'N') = 'O')
64654 ) AND
64655 (l_bflow_method_code = 'PRIOR_ENTRY')
64656 )
64657 THEN
64658 IF
64659 --
64660 1 = 2
64661 --
64662 THEN
64663 xla_accounting_err_pkg.build_message
64664 (p_appli_s_name => 'XLA'
64665 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64666 ,p_token_1 => 'LINE_NUMBER'
64667 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64668 ,p_token_2 => 'LINE_TYPE_NAME'
64669 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64670 l_component_type
64671 ,l_component_code
64672 ,l_component_type_code
64673 ,l_component_appl_id
64674 ,l_amb_context_code
64675 ,l_entity_code
64676 ,l_event_class_code
64677 )
64678 ,p_token_3 => 'OWNER'
64679 ,p_value_3 => xla_lookups_pkg.get_meaning(
64680 p_lookup_type => 'XLA_OWNER_TYPE'
64681 ,p_lookup_code => l_component_type_code
64682 )
64683 ,p_token_4 => 'PRODUCT_NAME'
64684 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64685 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64686 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64687 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64688 ,p_ae_header_id => NULL
64689 );
64690
64691 IF (C_LEVEL_ERROR>= g_log_level) THEN
64692 trace
64693 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64694 ,p_level => C_LEVEL_ERROR
64695 ,p_module => l_log_module);
64696 END IF;
64697 END IF;
64698 END IF;
64699 --
64700 --
64701 ------------------------------------------------------------------------------------------------
64702 -- 4219869 Business Flow
64703 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64704 -- Prior Entry. Currently, the following code is always generated.
64705 ------------------------------------------------------------------------------------------------
64706 XLA_AE_LINES_PKG.ValidateCurrentLine;
64707
64708 ------------------------------------------------------------------------------------
64709 -- 4219869 Business Flow
64710 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64711 ------------------------------------------------------------------------------------
64712 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64713
64714 ----------------------------------------------------------------------------------
64715 -- 4219869 Business Flow
64716 -- Update journal entry status -- Need to generate this within IF <condition>
64717 ----------------------------------------------------------------------------------
64718 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64719 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64720 ,p_balance_type_code => l_balance_type_code
64721 );
64722
64723 -------------------------------------------------------------------------------------------
64724 -- 4262811 - Generate the Accrual Reversal lines
64725 -------------------------------------------------------------------------------------------
64726 BEGIN
64727 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
64728 (g_array_event(p_event_id).array_value_num('header_index'));
64729 IF l_acc_rev_flag IS NULL THEN
64730 l_acc_rev_flag := 'N';
64731 END IF;
64732 EXCEPTION
64733 WHEN OTHERS THEN
64734 l_acc_rev_flag := 'N';
64735 END;
64736 --
64737 IF (l_acc_rev_flag = 'Y') THEN
64738
64739 -- 4645092 ------------------------------------------------------------------------------
64740 -- To allow MPA report to determine if it should generate report process
64741 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
64742 ------------------------------------------------------------------------------------------
64743
64744 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
64745 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
64746 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
64747 -- call ADRs
64748 -- Bug 4922099
64749 --
64750 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64751 (NVL(l_actual_upg_option, 'N') = 'O') OR
64752 (NVL(l_enc_upg_option, 'N') = 'O')
64753 )
64754 THEN
64755 NULL;
64756 --
64757 --
64758
64759 l_ccid := AcctDerRule_6(
64760 p_application_id => p_application_id
64761 , p_ae_header_id => l_ae_header_id
64762 , p_source_11 => p_source_11
64763 , x_transaction_coa_id => l_adr_transaction_coa_id
64764 , x_accounting_coa_id => l_adr_accounting_coa_id
64765 , x_value_type_code => l_adr_value_type_code
64766 , p_side => 'NA'
64767 );
64768
64769 xla_ae_lines_pkg.set_ccid(
64770 p_code_combination_id => l_ccid
64771 , p_value_type_code => l_adr_value_type_code
64772 , p_transaction_coa_id => l_adr_transaction_coa_id
64773 , p_accounting_coa_id => l_adr_accounting_coa_id
64774 , p_adr_code => 'CST_DEFAULT'
64775 , p_adr_type_code => 'S'
64776 , p_component_type => l_component_type
64777 , p_component_code => l_component_code
64778 , p_component_type_code => l_component_type_code
64779 , p_component_appl_id => l_component_appl_id
64780 , p_amb_context_code => l_amb_context_code
64781 , p_side => 'NA'
64782 );
64783
64784
64785 --
64786 --
64787 END IF;
64788
64789 --
64790 -- Update the line information that should be overwritten
64791 --
64792 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
64793 p_header_num => 1);
64794 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
64795
64796 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
64797
64798 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
64799 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
64800 END IF;
64801
64802 --
64803 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
64804 --
64805 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
64806 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
64807 ELSE
64808 ---------------------------------------------------------------------------------------------------
64809 -- 4262811a Switch Sign
64810 ---------------------------------------------------------------------------------------------------
64811 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
64812 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64813 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64814 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64815 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64816 -- 5132302
64817 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
64818 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64819
64820 END IF;
64821
64822 -- 4955764
64823 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64824 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
64825
64826
64827 XLA_AE_LINES_PKG.ValidateCurrentLine;
64828 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64829
64830 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64831 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
64832 ,p_balance_type_code => l_balance_type_code);
64833
64834 END IF;
64835
64836 -----------------------------------------------------------------------------------------
64837 -- 4262811 Multiperiod Accounting
64838 -----------------------------------------------------------------------------------------
64839 -- No MPA option is assigned.
64840
64841
64842 END IF;
64843 END IF;
64844 --
64845
64846 --
64847 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64848 trace
64849 (p_msg => 'END of AcctLineType_138'
64850 ,p_level => C_LEVEL_PROCEDURE
64851 ,p_module => l_log_module);
64852 END IF;
64853 --
64854 EXCEPTION
64855 WHEN xla_exceptions_pkg.application_exception THEN
64856 RAISE;
64857 WHEN OTHERS THEN
64858 xla_exceptions_pkg.raise_message
64859 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_138');
64860 END AcctLineType_138;
64861 --
64862
64863 ---------------------------------------
64864 --
64865 -- PRIVATE FUNCTION
64866 -- AcctLineType_139
64867 --
64868 ---------------------------------------
64869 PROCEDURE AcctLineType_139 (
64870 p_application_id IN NUMBER
64871 ,p_event_id IN NUMBER
64872 ,p_calculate_acctd_flag IN VARCHAR2
64873 ,p_calculate_g_l_flag IN VARCHAR2
64874 ,p_actual_flag IN OUT VARCHAR2
64875 ,p_balance_type_code OUT VARCHAR2
64876 ,p_gain_or_loss_ref OUT VARCHAR2
64877
64878 --Cost Management Default Account
64879 , p_source_11 IN NUMBER
64880 --Receiving Accounting Line Type
64881 , p_source_78 IN VARCHAR2
64882 --DISTRIBUTION_IDENTIFIER
64883 , p_source_84 IN NUMBER
64884 --Distribution Type
64885 , p_source_85 IN VARCHAR2
64886 , p_source_85_meaning IN VARCHAR2
64887 --Entered Currency Code
64888 , p_source_88 IN VARCHAR2
64889 --Entered Amount
64890 , p_source_91 IN NUMBER
64891 --Currency Conversion Date
64892 , p_source_92 IN DATE
64893 --Currency Conversion Rate
64894 , p_source_93 IN NUMBER
64895 --Currency Conversion Type
64896 , p_source_94 IN VARCHAR2
64897 --Accounted Amount
64898 , p_source_95 IN NUMBER
64899 )
64900 IS
64901
64902 l_component_type VARCHAR2(80);
64903 l_component_code VARCHAR2(30);
64904 l_component_type_code VARCHAR2(1);
64905 l_component_appl_id INTEGER;
64906 l_amb_context_code VARCHAR2(30);
64907 l_entity_code VARCHAR2(30);
64908 l_event_class_code VARCHAR2(30);
64909 l_ae_header_id NUMBER;
64910 l_event_type_code VARCHAR2(30);
64911 l_line_definition_code VARCHAR2(30);
64912 l_line_definition_owner_code VARCHAR2(1);
64913 --
64914 -- adr variables
64915 l_segment VARCHAR2(30);
64916 l_ccid NUMBER;
64917 l_adr_transaction_coa_id NUMBER;
64918 l_adr_accounting_coa_id NUMBER;
64919 l_adr_flexfield_segment_code VARCHAR2(30);
64920 l_adr_flex_value_set_id NUMBER;
64921 l_adr_value_type_code VARCHAR2(30);
64922 l_adr_value_combination_id NUMBER;
64923 l_adr_value_segment_code VARCHAR2(30);
64924
64925 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
64926 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
64927 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
64928 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
64929
64930 -- 4262811 Variables ------------------------------------------------------------------------------------------
64931 l_entered_amt_idx NUMBER;
64932 l_accted_amt_idx NUMBER;
64933 l_acc_rev_flag VARCHAR2(1);
64934 l_accrual_line_num NUMBER;
64935 l_tmp_amt NUMBER;
64936 l_acc_rev_natural_side_code VARCHAR2(1);
64937
64938 l_num_entries NUMBER;
64939 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
64940 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
64941 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
64942 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
64943 l_recog_line_1 NUMBER;
64944 l_recog_line_2 NUMBER;
64945
64946 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
64947 l_bflow_applied_to_amt NUMBER; -- 5132302
64948 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
64949
64950 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
64951
64952 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
64953 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
64954
64955 ---------------------------------------------------------------------------------------------------------------
64956
64957
64958 --
64959 -- bulk performance
64960 --
64961 l_balance_type_code VARCHAR2(1);
64962 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64963 l_log_module VARCHAR2(240);
64964
64965 --
64966 -- Upgrade strategy
64967 --
64968 l_actual_upg_option VARCHAR2(1);
64969 l_enc_upg_option VARCHAR2(1);
64970
64971 --
64972 BEGIN
64973 --
64974 IF g_log_enabled THEN
64975 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_139';
64976 END IF;
64977 --
64978 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64979
64980 trace
64981 (p_msg => 'BEGIN of AcctLineType_139'
64982 ,p_level => C_LEVEL_PROCEDURE
64983 ,p_module => l_log_module);
64984
64985 END IF;
64986 --
64987 l_component_type := 'AMB_JLT';
64988 l_component_code := 'INTERCOMPANY_COGS';
64989 l_component_type_code := 'S';
64990 l_component_appl_id := 707;
64991 l_amb_context_code := 'DEFAULT';
64992 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
64993 l_event_class_code := 'RCPT_REC_INSP';
64994 l_event_type_code := 'RCPT_REC_INSP_ALL';
64995 l_line_definition_owner_code := 'S';
64996 l_line_definition_code := 'RCPT_REC_INSP';
64997 --
64998 l_balance_type_code := 'A';
64999 l_segment := NULL;
65000 l_ccid := NULL;
65001 l_adr_transaction_coa_id := NULL;
65002 l_adr_accounting_coa_id := NULL;
65003 l_adr_flexfield_segment_code := NULL;
65004 l_adr_flex_value_set_id := NULL;
65005 l_adr_value_type_code := NULL;
65006 l_adr_value_combination_id := NULL;
65007 l_adr_value_segment_code := NULL;
65008
65009 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
65010 l_bflow_class_code := ''; -- 4219869 Business Flow
65011 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
65012 l_budgetary_control_flag := 'N';
65013
65014 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65015 l_bflow_applied_to_amt := NULL; -- 5132302
65016 l_entered_amt_idx := NULL; -- 4262811
65017 l_accted_amt_idx := NULL; -- 4262811
65018 l_acc_rev_flag := NULL; -- 4262811
65019 l_accrual_line_num := NULL; -- 4262811
65020 l_tmp_amt := NULL; -- 4262811
65021 --
65022
65023 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
65024 l_balance_type_code <> 'B' THEN
65025 IF NVL(p_source_78,'
65026 ') = 'IC Cost of Sales'
65027 THEN
65028
65029 --
65030 XLA_AE_LINES_PKG.SetNewLine;
65031
65032 p_balance_type_code := l_balance_type_code;
65033 -- set the flag so later we will know whether the gain loss line needs to be created
65034
65035 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65036 p_actual_flag :='A';
65037 END IF;
65038
65039 --
65040 -- bulk performance
65041 --
65042 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65043 p_header_num => 0); -- 4262811
65044 --
65045 -- set accounting line options
65046 --
65047 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65048 p_natural_side_code => 'D'
65049 , p_gain_or_loss_flag => 'N'
65050 , p_gl_transfer_mode_code => 'S'
65051 , p_acct_entry_type_code => 'A'
65052 , p_switch_side_flag => 'Y'
65053 , p_merge_duplicate_code => 'N'
65054 );
65055 --
65056 l_acc_rev_natural_side_code := 'C'; -- 4262811
65057 --
65058 --
65059 -- set accounting line type info
65060 --
65061 xla_ae_lines_pkg.SetAcctLineType
65062 (p_component_type => l_component_type
65063 ,p_event_type_code => l_event_type_code
65064 ,p_line_definition_owner_code => l_line_definition_owner_code
65065 ,p_line_definition_code => l_line_definition_code
65066 ,p_accounting_line_code => l_component_code
65067 ,p_accounting_line_type_code => l_component_type_code
65068 ,p_accounting_line_appl_id => l_component_appl_id
65069 ,p_amb_context_code => l_amb_context_code
65070 ,p_entity_code => l_entity_code
65071 ,p_event_class_code => l_event_class_code);
65072 --
65073 -- set accounting class
65074 --
65075 xla_ae_lines_pkg.SetAcctClass(
65076 p_accounting_class_code => 'INTERCOMPANY_COGS'
65077 , p_ae_header_id => l_ae_header_id
65078 );
65079
65080 --
65081 -- set rounding class
65082 --
65083 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65084 'INTERCOMPANY_COGS';
65085
65086 --
65087 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65088 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65089 --
65090 -- bulk performance
65091 --
65092 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65093
65094 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65095 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65096
65097 -- 4955764
65098 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65099 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65100
65101 -- 4458381 Public Sector Enh
65102
65103 --
65104 -- set accounting attributes for the line type
65105 --
65106 l_entered_amt_idx := 3;
65107 l_accted_amt_idx := 8;
65108 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65109 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
65110 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
65111 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
65112 l_rec_acct_attrs.array_char_value(2) := p_source_85;
65113 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
65114 l_rec_acct_attrs.array_num_value(3) := p_source_91;
65115 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
65116 l_rec_acct_attrs.array_char_value(4) := p_source_88;
65117 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
65118 l_rec_acct_attrs.array_date_value(5) := p_source_92;
65119 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
65120 l_rec_acct_attrs.array_num_value(6) := p_source_93;
65121 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
65122 l_rec_acct_attrs.array_char_value(7) := p_source_94;
65123 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
65124 l_rec_acct_attrs.array_num_value(8) := p_source_95;
65125
65126 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
65127 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
65128
65129 ---------------------------------------------------------------------------------------------------------------
65130 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
65131 ---------------------------------------------------------------------------------------------------------------
65132 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
65133
65134 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65135 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65136
65137 IF xla_accounting_cache_pkg.GetValueChar
65138 (p_source_code => 'LEDGER_CATEGORY_CODE'
65139 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
65140 AND l_bflow_method_code = 'PRIOR_ENTRY'
65141 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
65142 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
65143 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
65144 )
65145 THEN
65146 xla_ae_lines_pkg.BflowUpgEntry
65147 (p_business_method_code => l_bflow_method_code
65148 ,p_business_class_code => l_bflow_class_code
65149 ,p_balance_type => l_balance_type_code);
65150 ELSE
65151 NULL;
65152 -- No business flow processing for business flow method of NONE.
65153 END IF;
65154
65155 --
65156 -- call analytical criteria
65157 --
65158
65159 --
65160 -- call description
65161 --
65162 -- No description or it is inherited.
65163 --
65164 -- call ADRs
65165 -- Bug 4922099
65166 --
65167 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65168 (NVL(l_actual_upg_option, 'N') = 'O') OR
65169 (NVL(l_enc_upg_option, 'N') = 'O')
65170 )
65171 THEN
65172 NULL;
65173 --
65174 --
65175
65176 l_ccid := AcctDerRule_6(
65177 p_application_id => p_application_id
65178 , p_ae_header_id => l_ae_header_id
65179 , p_source_11 => p_source_11
65180 , x_transaction_coa_id => l_adr_transaction_coa_id
65181 , x_accounting_coa_id => l_adr_accounting_coa_id
65182 , x_value_type_code => l_adr_value_type_code
65183 , p_side => 'NA'
65184 );
65185
65186 xla_ae_lines_pkg.set_ccid(
65187 p_code_combination_id => l_ccid
65188 , p_value_type_code => l_adr_value_type_code
65189 , p_transaction_coa_id => l_adr_transaction_coa_id
65190 , p_accounting_coa_id => l_adr_accounting_coa_id
65191 , p_adr_code => 'CST_DEFAULT'
65192 , p_adr_type_code => 'S'
65193 , p_component_type => l_component_type
65194 , p_component_code => l_component_code
65195 , p_component_type_code => l_component_type_code
65196 , p_component_appl_id => l_component_appl_id
65197 , p_amb_context_code => l_amb_context_code
65198 , p_side => 'NA'
65199 );
65200
65201
65202 --
65203 --
65204 END IF;
65205 --
65206 -- Bug 4922099
65207 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
65208 (NVL(l_enc_upg_option, 'N') = 'O')
65209 ) AND
65210 (l_bflow_method_code = 'PRIOR_ENTRY')
65211 )
65212 THEN
65213 IF
65214 --
65215 1 = 2
65216 --
65217 THEN
65218 xla_accounting_err_pkg.build_message
65219 (p_appli_s_name => 'XLA'
65220 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65221 ,p_token_1 => 'LINE_NUMBER'
65222 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
65223 ,p_token_2 => 'LINE_TYPE_NAME'
65224 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
65225 l_component_type
65226 ,l_component_code
65227 ,l_component_type_code
65228 ,l_component_appl_id
65229 ,l_amb_context_code
65230 ,l_entity_code
65231 ,l_event_class_code
65232 )
65233 ,p_token_3 => 'OWNER'
65234 ,p_value_3 => xla_lookups_pkg.get_meaning(
65235 p_lookup_type => 'XLA_OWNER_TYPE'
65236 ,p_lookup_code => l_component_type_code
65237 )
65238 ,p_token_4 => 'PRODUCT_NAME'
65239 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
65240 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
65241 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
65242 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
65243 ,p_ae_header_id => NULL
65244 );
65245
65246 IF (C_LEVEL_ERROR>= g_log_level) THEN
65247 trace
65248 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65249 ,p_level => C_LEVEL_ERROR
65250 ,p_module => l_log_module);
65251 END IF;
65252 END IF;
65253 END IF;
65254 --
65255 --
65256 ------------------------------------------------------------------------------------------------
65257 -- 4219869 Business Flow
65258 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
65259 -- Prior Entry. Currently, the following code is always generated.
65260 ------------------------------------------------------------------------------------------------
65261 XLA_AE_LINES_PKG.ValidateCurrentLine;
65262
65263 ------------------------------------------------------------------------------------
65264 -- 4219869 Business Flow
65265 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
65266 ------------------------------------------------------------------------------------
65267 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65268
65269 ----------------------------------------------------------------------------------
65270 -- 4219869 Business Flow
65271 -- Update journal entry status -- Need to generate this within IF <condition>
65272 ----------------------------------------------------------------------------------
65273 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65274 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
65275 ,p_balance_type_code => l_balance_type_code
65276 );
65277
65278 -------------------------------------------------------------------------------------------
65279 -- 4262811 - Generate the Accrual Reversal lines
65280 -------------------------------------------------------------------------------------------
65281 BEGIN
65282 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65283 (g_array_event(p_event_id).array_value_num('header_index'));
65284 IF l_acc_rev_flag IS NULL THEN
65285 l_acc_rev_flag := 'N';
65286 END IF;
65287 EXCEPTION
65288 WHEN OTHERS THEN
65289 l_acc_rev_flag := 'N';
65290 END;
65291 --
65292 IF (l_acc_rev_flag = 'Y') THEN
65293
65294 -- 4645092 ------------------------------------------------------------------------------
65295 -- To allow MPA report to determine if it should generate report process
65296 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65297 ------------------------------------------------------------------------------------------
65298
65299 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65300 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65301 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65302 -- call ADRs
65303 -- Bug 4922099
65304 --
65305 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65306 (NVL(l_actual_upg_option, 'N') = 'O') OR
65307 (NVL(l_enc_upg_option, 'N') = 'O')
65308 )
65309 THEN
65310 NULL;
65311 --
65312 --
65313
65314 l_ccid := AcctDerRule_6(
65315 p_application_id => p_application_id
65316 , p_ae_header_id => l_ae_header_id
65317 , p_source_11 => p_source_11
65318 , x_transaction_coa_id => l_adr_transaction_coa_id
65319 , x_accounting_coa_id => l_adr_accounting_coa_id
65320 , x_value_type_code => l_adr_value_type_code
65321 , p_side => 'NA'
65322 );
65323
65324 xla_ae_lines_pkg.set_ccid(
65325 p_code_combination_id => l_ccid
65326 , p_value_type_code => l_adr_value_type_code
65327 , p_transaction_coa_id => l_adr_transaction_coa_id
65328 , p_accounting_coa_id => l_adr_accounting_coa_id
65329 , p_adr_code => 'CST_DEFAULT'
65330 , p_adr_type_code => 'S'
65331 , p_component_type => l_component_type
65332 , p_component_code => l_component_code
65333 , p_component_type_code => l_component_type_code
65334 , p_component_appl_id => l_component_appl_id
65335 , p_amb_context_code => l_amb_context_code
65336 , p_side => 'NA'
65337 );
65338
65339
65340 --
65341 --
65342 END IF;
65343
65344 --
65345 -- Update the line information that should be overwritten
65346 --
65347 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65348 p_header_num => 1);
65349 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65350
65351 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65352
65353 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65354 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65355 END IF;
65356
65357 --
65358 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65359 --
65360 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65361 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65362 ELSE
65363 ---------------------------------------------------------------------------------------------------
65364 -- 4262811a Switch Sign
65365 ---------------------------------------------------------------------------------------------------
65366 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65367 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65368 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65369 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65370 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65371 -- 5132302
65372 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65373 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65374
65375 END IF;
65376
65377 -- 4955764
65378 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65379 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
65380
65381
65382 XLA_AE_LINES_PKG.ValidateCurrentLine;
65383 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65384
65385 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65386 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
65387 ,p_balance_type_code => l_balance_type_code);
65388
65389 END IF;
65390
65391 -----------------------------------------------------------------------------------------
65392 -- 4262811 Multiperiod Accounting
65393 -----------------------------------------------------------------------------------------
65394 -- No MPA option is assigned.
65395
65396
65397 END IF;
65398 END IF;
65399 --
65400
65401 --
65402 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65403 trace
65404 (p_msg => 'END of AcctLineType_139'
65405 ,p_level => C_LEVEL_PROCEDURE
65406 ,p_module => l_log_module);
65407 END IF;
65408 --
65409 EXCEPTION
65410 WHEN xla_exceptions_pkg.application_exception THEN
65411 RAISE;
65412 WHEN OTHERS THEN
65413 xla_exceptions_pkg.raise_message
65414 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_139');
65415 END AcctLineType_139;
65416 --
65417
65418 ---------------------------------------
65419 --
65420 -- PRIVATE FUNCTION
65421 -- AcctLineType_140
65422 --
65423 ---------------------------------------
65424 PROCEDURE AcctLineType_140 (
65425 p_application_id IN NUMBER
65426 ,p_event_id IN NUMBER
65427 ,p_calculate_acctd_flag IN VARCHAR2
65428 ,p_calculate_g_l_flag IN VARCHAR2
65429 ,p_actual_flag IN OUT VARCHAR2
65430 ,p_balance_type_code OUT VARCHAR2
65431 ,p_gain_or_loss_ref OUT VARCHAR2
65432
65433 --Cost Management Default Account
65434 , p_source_11 IN NUMBER
65435 --Receiving Accounting Line Type
65436 , p_source_78 IN VARCHAR2
65437 --DISTRIBUTION_IDENTIFIER
65438 , p_source_84 IN NUMBER
65439 --Distribution Type
65440 , p_source_85 IN VARCHAR2
65441 , p_source_85_meaning IN VARCHAR2
65442 --Entered Currency Code
65443 , p_source_88 IN VARCHAR2
65444 --Entered Amount
65445 , p_source_91 IN NUMBER
65446 --Currency Conversion Date
65447 , p_source_92 IN DATE
65448 --Currency Conversion Rate
65449 , p_source_93 IN NUMBER
65450 --Currency Conversion Type
65451 , p_source_94 IN VARCHAR2
65452 --Accounted Amount
65453 , p_source_95 IN NUMBER
65454 )
65455 IS
65456
65457 l_component_type VARCHAR2(80);
65458 l_component_code VARCHAR2(30);
65459 l_component_type_code VARCHAR2(1);
65460 l_component_appl_id INTEGER;
65461 l_amb_context_code VARCHAR2(30);
65462 l_entity_code VARCHAR2(30);
65463 l_event_class_code VARCHAR2(30);
65464 l_ae_header_id NUMBER;
65465 l_event_type_code VARCHAR2(30);
65466 l_line_definition_code VARCHAR2(30);
65467 l_line_definition_owner_code VARCHAR2(1);
65468 --
65469 -- adr variables
65470 l_segment VARCHAR2(30);
65471 l_ccid NUMBER;
65472 l_adr_transaction_coa_id NUMBER;
65473 l_adr_accounting_coa_id NUMBER;
65474 l_adr_flexfield_segment_code VARCHAR2(30);
65475 l_adr_flex_value_set_id NUMBER;
65476 l_adr_value_type_code VARCHAR2(30);
65477 l_adr_value_combination_id NUMBER;
65478 l_adr_value_segment_code VARCHAR2(30);
65479
65480 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
65481 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
65482 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
65483 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
65484
65485 -- 4262811 Variables ------------------------------------------------------------------------------------------
65486 l_entered_amt_idx NUMBER;
65487 l_accted_amt_idx NUMBER;
65488 l_acc_rev_flag VARCHAR2(1);
65489 l_accrual_line_num NUMBER;
65490 l_tmp_amt NUMBER;
65491 l_acc_rev_natural_side_code VARCHAR2(1);
65492
65493 l_num_entries NUMBER;
65494 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
65495 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
65496 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
65497 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
65498 l_recog_line_1 NUMBER;
65499 l_recog_line_2 NUMBER;
65500
65501 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
65502 l_bflow_applied_to_amt NUMBER; -- 5132302
65503 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
65504
65505 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
65506
65507 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
65508 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
65509
65510 ---------------------------------------------------------------------------------------------------------------
65511
65512
65513 --
65514 -- bulk performance
65515 --
65516 l_balance_type_code VARCHAR2(1);
65517 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
65518 l_log_module VARCHAR2(240);
65519
65520 --
65521 -- Upgrade strategy
65522 --
65523 l_actual_upg_option VARCHAR2(1);
65524 l_enc_upg_option VARCHAR2(1);
65525
65526 --
65527 BEGIN
65528 --
65529 IF g_log_enabled THEN
65530 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_140';
65531 END IF;
65532 --
65533 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65534
65535 trace
65536 (p_msg => 'BEGIN of AcctLineType_140'
65537 ,p_level => C_LEVEL_PROCEDURE
65538 ,p_module => l_log_module);
65539
65540 END IF;
65541 --
65542 l_component_type := 'AMB_JLT';
65543 l_component_code := 'INTERCOMPANY_COGS';
65544 l_component_type_code := 'S';
65545 l_component_appl_id := 707;
65546 l_amb_context_code := 'DEFAULT';
65547 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
65548 l_event_class_code := 'RETR_PRICE_ADJ_RCV';
65549 l_event_type_code := 'RETR_PRICE_ADJ_RCV_ALL';
65550 l_line_definition_owner_code := 'S';
65551 l_line_definition_code := 'RETR_PRICE_ADJ_RCV';
65552 --
65553 l_balance_type_code := 'A';
65554 l_segment := NULL;
65555 l_ccid := NULL;
65556 l_adr_transaction_coa_id := NULL;
65557 l_adr_accounting_coa_id := NULL;
65558 l_adr_flexfield_segment_code := NULL;
65559 l_adr_flex_value_set_id := NULL;
65560 l_adr_value_type_code := NULL;
65561 l_adr_value_combination_id := NULL;
65562 l_adr_value_segment_code := NULL;
65563
65564 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
65565 l_bflow_class_code := ''; -- 4219869 Business Flow
65566 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
65567 l_budgetary_control_flag := 'N';
65568
65569 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65570 l_bflow_applied_to_amt := NULL; -- 5132302
65571 l_entered_amt_idx := NULL; -- 4262811
65572 l_accted_amt_idx := NULL; -- 4262811
65573 l_acc_rev_flag := NULL; -- 4262811
65574 l_accrual_line_num := NULL; -- 4262811
65575 l_tmp_amt := NULL; -- 4262811
65576 --
65577
65578 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
65579 l_balance_type_code <> 'B' THEN
65580 IF NVL(p_source_78,'
65581 ') = 'IC Cost of Sales'
65582 THEN
65583
65584 --
65585 XLA_AE_LINES_PKG.SetNewLine;
65586
65587 p_balance_type_code := l_balance_type_code;
65588 -- set the flag so later we will know whether the gain loss line needs to be created
65589
65590 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65591 p_actual_flag :='A';
65592 END IF;
65593
65594 --
65595 -- bulk performance
65596 --
65597 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65598 p_header_num => 0); -- 4262811
65599 --
65600 -- set accounting line options
65601 --
65602 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65603 p_natural_side_code => 'D'
65604 , p_gain_or_loss_flag => 'N'
65605 , p_gl_transfer_mode_code => 'S'
65606 , p_acct_entry_type_code => 'A'
65607 , p_switch_side_flag => 'Y'
65608 , p_merge_duplicate_code => 'N'
65609 );
65610 --
65611 l_acc_rev_natural_side_code := 'C'; -- 4262811
65612 --
65613 --
65614 -- set accounting line type info
65615 --
65616 xla_ae_lines_pkg.SetAcctLineType
65617 (p_component_type => l_component_type
65618 ,p_event_type_code => l_event_type_code
65619 ,p_line_definition_owner_code => l_line_definition_owner_code
65620 ,p_line_definition_code => l_line_definition_code
65621 ,p_accounting_line_code => l_component_code
65622 ,p_accounting_line_type_code => l_component_type_code
65623 ,p_accounting_line_appl_id => l_component_appl_id
65624 ,p_amb_context_code => l_amb_context_code
65625 ,p_entity_code => l_entity_code
65626 ,p_event_class_code => l_event_class_code);
65627 --
65628 -- set accounting class
65629 --
65630 xla_ae_lines_pkg.SetAcctClass(
65631 p_accounting_class_code => 'INTERCOMPANY_COGS'
65632 , p_ae_header_id => l_ae_header_id
65633 );
65634
65635 --
65636 -- set rounding class
65637 --
65638 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65639 'INTERCOMPANY_COGS';
65640
65641 --
65642 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65643 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65644 --
65645 -- bulk performance
65646 --
65647 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65648
65649 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65650 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65651
65652 -- 4955764
65653 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65654 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65655
65656 -- 4458381 Public Sector Enh
65657
65658 --
65659 -- set accounting attributes for the line type
65660 --
65661 l_entered_amt_idx := 3;
65662 l_accted_amt_idx := 8;
65663 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65664 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
65665 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
65666 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
65667 l_rec_acct_attrs.array_char_value(2) := p_source_85;
65668 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
65669 l_rec_acct_attrs.array_num_value(3) := p_source_91;
65670 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
65671 l_rec_acct_attrs.array_char_value(4) := p_source_88;
65672 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
65673 l_rec_acct_attrs.array_date_value(5) := p_source_92;
65674 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
65675 l_rec_acct_attrs.array_num_value(6) := p_source_93;
65676 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
65677 l_rec_acct_attrs.array_char_value(7) := p_source_94;
65678 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
65679 l_rec_acct_attrs.array_num_value(8) := p_source_95;
65680
65681 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
65682 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
65683
65684 ---------------------------------------------------------------------------------------------------------------
65685 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
65686 ---------------------------------------------------------------------------------------------------------------
65687 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
65688
65689 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65690 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65691
65692 IF xla_accounting_cache_pkg.GetValueChar
65693 (p_source_code => 'LEDGER_CATEGORY_CODE'
65694 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
65695 AND l_bflow_method_code = 'PRIOR_ENTRY'
65696 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
65697 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
65698 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
65699 )
65700 THEN
65701 xla_ae_lines_pkg.BflowUpgEntry
65702 (p_business_method_code => l_bflow_method_code
65703 ,p_business_class_code => l_bflow_class_code
65704 ,p_balance_type => l_balance_type_code);
65705 ELSE
65706 NULL;
65707 -- No business flow processing for business flow method of NONE.
65708 END IF;
65709
65710 --
65711 -- call analytical criteria
65712 --
65713
65714 --
65715 -- call description
65716 --
65717 -- No description or it is inherited.
65718 --
65719 -- call ADRs
65720 -- Bug 4922099
65721 --
65722 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65723 (NVL(l_actual_upg_option, 'N') = 'O') OR
65724 (NVL(l_enc_upg_option, 'N') = 'O')
65725 )
65726 THEN
65727 NULL;
65728 --
65729 --
65730
65731 l_ccid := AcctDerRule_6(
65732 p_application_id => p_application_id
65733 , p_ae_header_id => l_ae_header_id
65734 , p_source_11 => p_source_11
65735 , x_transaction_coa_id => l_adr_transaction_coa_id
65736 , x_accounting_coa_id => l_adr_accounting_coa_id
65737 , x_value_type_code => l_adr_value_type_code
65738 , p_side => 'NA'
65739 );
65740
65741 xla_ae_lines_pkg.set_ccid(
65742 p_code_combination_id => l_ccid
65743 , p_value_type_code => l_adr_value_type_code
65744 , p_transaction_coa_id => l_adr_transaction_coa_id
65745 , p_accounting_coa_id => l_adr_accounting_coa_id
65746 , p_adr_code => 'CST_DEFAULT'
65747 , p_adr_type_code => 'S'
65748 , p_component_type => l_component_type
65749 , p_component_code => l_component_code
65750 , p_component_type_code => l_component_type_code
65751 , p_component_appl_id => l_component_appl_id
65752 , p_amb_context_code => l_amb_context_code
65753 , p_side => 'NA'
65754 );
65755
65756
65757 --
65758 --
65759 END IF;
65760 --
65761 -- Bug 4922099
65762 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
65763 (NVL(l_enc_upg_option, 'N') = 'O')
65764 ) AND
65765 (l_bflow_method_code = 'PRIOR_ENTRY')
65766 )
65767 THEN
65768 IF
65769 --
65770 1 = 2
65771 --
65772 THEN
65773 xla_accounting_err_pkg.build_message
65774 (p_appli_s_name => 'XLA'
65775 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65776 ,p_token_1 => 'LINE_NUMBER'
65777 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
65778 ,p_token_2 => 'LINE_TYPE_NAME'
65779 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
65780 l_component_type
65781 ,l_component_code
65782 ,l_component_type_code
65783 ,l_component_appl_id
65784 ,l_amb_context_code
65785 ,l_entity_code
65786 ,l_event_class_code
65787 )
65788 ,p_token_3 => 'OWNER'
65789 ,p_value_3 => xla_lookups_pkg.get_meaning(
65790 p_lookup_type => 'XLA_OWNER_TYPE'
65791 ,p_lookup_code => l_component_type_code
65792 )
65793 ,p_token_4 => 'PRODUCT_NAME'
65794 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
65795 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
65796 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
65797 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
65798 ,p_ae_header_id => NULL
65799 );
65800
65801 IF (C_LEVEL_ERROR>= g_log_level) THEN
65802 trace
65803 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65804 ,p_level => C_LEVEL_ERROR
65805 ,p_module => l_log_module);
65806 END IF;
65807 END IF;
65808 END IF;
65809 --
65810 --
65811 ------------------------------------------------------------------------------------------------
65812 -- 4219869 Business Flow
65813 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
65814 -- Prior Entry. Currently, the following code is always generated.
65815 ------------------------------------------------------------------------------------------------
65816 XLA_AE_LINES_PKG.ValidateCurrentLine;
65817
65818 ------------------------------------------------------------------------------------
65819 -- 4219869 Business Flow
65820 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
65821 ------------------------------------------------------------------------------------
65822 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65823
65824 ----------------------------------------------------------------------------------
65825 -- 4219869 Business Flow
65826 -- Update journal entry status -- Need to generate this within IF <condition>
65827 ----------------------------------------------------------------------------------
65828 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65829 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
65830 ,p_balance_type_code => l_balance_type_code
65831 );
65832
65833 -------------------------------------------------------------------------------------------
65834 -- 4262811 - Generate the Accrual Reversal lines
65835 -------------------------------------------------------------------------------------------
65836 BEGIN
65837 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65838 (g_array_event(p_event_id).array_value_num('header_index'));
65839 IF l_acc_rev_flag IS NULL THEN
65840 l_acc_rev_flag := 'N';
65841 END IF;
65842 EXCEPTION
65843 WHEN OTHERS THEN
65844 l_acc_rev_flag := 'N';
65845 END;
65846 --
65847 IF (l_acc_rev_flag = 'Y') THEN
65848
65849 -- 4645092 ------------------------------------------------------------------------------
65850 -- To allow MPA report to determine if it should generate report process
65851 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65852 ------------------------------------------------------------------------------------------
65853
65854 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65855 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65856 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65857 -- call ADRs
65858 -- Bug 4922099
65859 --
65860 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65861 (NVL(l_actual_upg_option, 'N') = 'O') OR
65862 (NVL(l_enc_upg_option, 'N') = 'O')
65863 )
65864 THEN
65865 NULL;
65866 --
65867 --
65868
65869 l_ccid := AcctDerRule_6(
65870 p_application_id => p_application_id
65871 , p_ae_header_id => l_ae_header_id
65872 , p_source_11 => p_source_11
65873 , x_transaction_coa_id => l_adr_transaction_coa_id
65874 , x_accounting_coa_id => l_adr_accounting_coa_id
65875 , x_value_type_code => l_adr_value_type_code
65876 , p_side => 'NA'
65877 );
65878
65879 xla_ae_lines_pkg.set_ccid(
65880 p_code_combination_id => l_ccid
65881 , p_value_type_code => l_adr_value_type_code
65882 , p_transaction_coa_id => l_adr_transaction_coa_id
65883 , p_accounting_coa_id => l_adr_accounting_coa_id
65884 , p_adr_code => 'CST_DEFAULT'
65885 , p_adr_type_code => 'S'
65886 , p_component_type => l_component_type
65887 , p_component_code => l_component_code
65888 , p_component_type_code => l_component_type_code
65889 , p_component_appl_id => l_component_appl_id
65890 , p_amb_context_code => l_amb_context_code
65891 , p_side => 'NA'
65892 );
65893
65894
65895 --
65896 --
65897 END IF;
65898
65899 --
65900 -- Update the line information that should be overwritten
65901 --
65902 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65903 p_header_num => 1);
65904 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65905
65906 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65907
65908 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65909 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65910 END IF;
65911
65912 --
65913 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65914 --
65915 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65916 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65917 ELSE
65918 ---------------------------------------------------------------------------------------------------
65919 -- 4262811a Switch Sign
65920 ---------------------------------------------------------------------------------------------------
65921 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65922 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65923 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65924 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65925 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65926 -- 5132302
65927 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65928 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65929
65930 END IF;
65931
65932 -- 4955764
65933 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65934 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
65935
65936
65937 XLA_AE_LINES_PKG.ValidateCurrentLine;
65938 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65939
65940 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65941 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
65942 ,p_balance_type_code => l_balance_type_code);
65943
65944 END IF;
65945
65946 -----------------------------------------------------------------------------------------
65947 -- 4262811 Multiperiod Accounting
65948 -----------------------------------------------------------------------------------------
65949 -- No MPA option is assigned.
65950
65951
65952 END IF;
65953 END IF;
65954 --
65955
65956 --
65957 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65958 trace
65959 (p_msg => 'END of AcctLineType_140'
65960 ,p_level => C_LEVEL_PROCEDURE
65961 ,p_module => l_log_module);
65962 END IF;
65963 --
65964 EXCEPTION
65965 WHEN xla_exceptions_pkg.application_exception THEN
65966 RAISE;
65967 WHEN OTHERS THEN
65968 xla_exceptions_pkg.raise_message
65969 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_140');
65970 END AcctLineType_140;
65971 --
65972
65973 ---------------------------------------
65974 --
65975 -- PRIVATE FUNCTION
65976 -- AcctLineType_141
65977 --
65978 ---------------------------------------
65979 PROCEDURE AcctLineType_141 (
65980 p_application_id IN NUMBER
65981 ,p_event_id IN NUMBER
65982 ,p_calculate_acctd_flag IN VARCHAR2
65983 ,p_calculate_g_l_flag IN VARCHAR2
65984 ,p_actual_flag IN OUT VARCHAR2
65985 ,p_balance_type_code OUT VARCHAR2
65986 ,p_gain_or_loss_ref OUT VARCHAR2
65987
65988 --TRANSACTION_ID
65989 , p_source_1 IN NUMBER
65990 --Item Concatenated Segments
65991 , p_source_2 IN VARCHAR2
65992 --Transaction Quantity
65993 , p_source_3 IN NUMBER
65994 --Transaction Unit of Measure Code
65995 , p_source_4 IN VARCHAR2
65996 --Inventory Transaction Type Description
65997 , p_source_5 IN VARCHAR2
65998 --Cost Management Default Account
65999 , p_source_11 IN NUMBER
66000 --Transaction Action Name
66001 , p_source_62 IN NUMBER
66002 , p_source_62_meaning IN VARCHAR2
66003 --DISTRIBUTION_IDENTIFIER
66004 , p_source_84 IN NUMBER
66005 --Distribution Type
66006 , p_source_85 IN VARCHAR2
66007 , p_source_85_meaning IN VARCHAR2
66008 --Entered Currency Code
66009 , p_source_88 IN VARCHAR2
66010 --Entered Amount
66011 , p_source_91 IN NUMBER
66012 --Currency Conversion Date
66013 , p_source_92 IN DATE
66014 --Currency Conversion Rate
66015 , p_source_93 IN NUMBER
66016 --Currency Conversion Type
66017 , p_source_94 IN VARCHAR2
66018 --Accounted Amount
66019 , p_source_95 IN NUMBER
66020 --Accounting Line Type
66021 , p_source_97 IN NUMBER
66022 )
66023 IS
66024
66025 l_component_type VARCHAR2(80);
66026 l_component_code VARCHAR2(30);
66027 l_component_type_code VARCHAR2(1);
66028 l_component_appl_id INTEGER;
66029 l_amb_context_code VARCHAR2(30);
66030 l_entity_code VARCHAR2(30);
66031 l_event_class_code VARCHAR2(30);
66032 l_ae_header_id NUMBER;
66033 l_event_type_code VARCHAR2(30);
66034 l_line_definition_code VARCHAR2(30);
66035 l_line_definition_owner_code VARCHAR2(1);
66036 --
66037 -- adr variables
66038 l_segment VARCHAR2(30);
66039 l_ccid NUMBER;
66040 l_adr_transaction_coa_id NUMBER;
66041 l_adr_accounting_coa_id NUMBER;
66042 l_adr_flexfield_segment_code VARCHAR2(30);
66043 l_adr_flex_value_set_id NUMBER;
66044 l_adr_value_type_code VARCHAR2(30);
66045 l_adr_value_combination_id NUMBER;
66046 l_adr_value_segment_code VARCHAR2(30);
66047
66048 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
66049 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
66050 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
66051 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
66052
66053 -- 4262811 Variables ------------------------------------------------------------------------------------------
66054 l_entered_amt_idx NUMBER;
66055 l_accted_amt_idx NUMBER;
66056 l_acc_rev_flag VARCHAR2(1);
66057 l_accrual_line_num NUMBER;
66058 l_tmp_amt NUMBER;
66059 l_acc_rev_natural_side_code VARCHAR2(1);
66060
66061 l_num_entries NUMBER;
66062 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
66063 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
66064 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
66065 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
66066 l_recog_line_1 NUMBER;
66067 l_recog_line_2 NUMBER;
66068
66069 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
66070 l_bflow_applied_to_amt NUMBER; -- 5132302
66071 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
66072
66073 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
66074
66075 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
66076 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
66077
66078 ---------------------------------------------------------------------------------------------------------------
66079
66080
66081 --
66082 -- bulk performance
66083 --
66084 l_balance_type_code VARCHAR2(1);
66085 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
66086 l_log_module VARCHAR2(240);
66087
66088 --
66089 -- Upgrade strategy
66090 --
66091 l_actual_upg_option VARCHAR2(1);
66092 l_enc_upg_option VARCHAR2(1);
66093
66094 --
66095 BEGIN
66096 --
66097 IF g_log_enabled THEN
66098 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_141';
66099 END IF;
66100 --
66101 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66102
66103 trace
66104 (p_msg => 'BEGIN of AcctLineType_141'
66105 ,p_level => C_LEVEL_PROCEDURE
66106 ,p_module => l_log_module);
66107
66108 END IF;
66109 --
66110 l_component_type := 'AMB_JLT';
66111 l_component_code := 'INTERCOMPANY_COGS';
66112 l_component_type_code := 'S';
66113 l_component_appl_id := 707;
66114 l_amb_context_code := 'DEFAULT';
66115 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
66116 l_event_class_code := 'LOG_INTERCOMPANY';
66117 l_event_type_code := 'LOG_IC_SALES_ISSUE';
66118 l_line_definition_owner_code := 'S';
66119 l_line_definition_code := 'PI_LOG_IC_SALES_ISSUE';
66120 --
66121 l_balance_type_code := 'A';
66122 l_segment := NULL;
66123 l_ccid := NULL;
66124 l_adr_transaction_coa_id := NULL;
66125 l_adr_accounting_coa_id := NULL;
66126 l_adr_flexfield_segment_code := NULL;
66127 l_adr_flex_value_set_id := NULL;
66128 l_adr_value_type_code := NULL;
66129 l_adr_value_combination_id := NULL;
66130 l_adr_value_segment_code := NULL;
66131
66132 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
66133 l_bflow_class_code := ''; -- 4219869 Business Flow
66134 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
66135 l_budgetary_control_flag := 'N';
66136
66137 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66138 l_bflow_applied_to_amt := NULL; -- 5132302
66139 l_entered_amt_idx := NULL; -- 4262811
66140 l_accted_amt_idx := NULL; -- 4262811
66141 l_acc_rev_flag := NULL; -- 4262811
66142 l_accrual_line_num := NULL; -- 4262811
66143 l_tmp_amt := NULL; -- 4262811
66144 --
66145
66146 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
66147 l_balance_type_code <> 'B' THEN
66148 IF NVL(p_source_97,9E125) = 2 AND
66149 ((p_source_95 >= 0 AND
66150 NVL(p_source_62,9E125) = 9) OR
66151 (p_source_95 <= 0 AND
66152 NVL(p_source_62,9E125) = 14)
66153 ) THEN
66154
66155 --
66156 XLA_AE_LINES_PKG.SetNewLine;
66157
66158 p_balance_type_code := l_balance_type_code;
66159 -- set the flag so later we will know whether the gain loss line needs to be created
66160
66161 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
66162 p_actual_flag :='A';
66163 END IF;
66164
66165 --
66166 -- bulk performance
66167 --
66168 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
66169 p_header_num => 0); -- 4262811
66170 --
66171 -- set accounting line options
66172 --
66173 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
66174 p_natural_side_code => 'D'
66175 , p_gain_or_loss_flag => 'N'
66176 , p_gl_transfer_mode_code => 'S'
66177 , p_acct_entry_type_code => 'A'
66178 , p_switch_side_flag => 'Y'
66179 , p_merge_duplicate_code => 'N'
66180 );
66181 --
66182 l_acc_rev_natural_side_code := 'C'; -- 4262811
66183 --
66184 --
66185 -- set accounting line type info
66186 --
66187 xla_ae_lines_pkg.SetAcctLineType
66188 (p_component_type => l_component_type
66189 ,p_event_type_code => l_event_type_code
66190 ,p_line_definition_owner_code => l_line_definition_owner_code
66191 ,p_line_definition_code => l_line_definition_code
66192 ,p_accounting_line_code => l_component_code
66193 ,p_accounting_line_type_code => l_component_type_code
66194 ,p_accounting_line_appl_id => l_component_appl_id
66195 ,p_amb_context_code => l_amb_context_code
66196 ,p_entity_code => l_entity_code
66197 ,p_event_class_code => l_event_class_code);
66198 --
66199 -- set accounting class
66200 --
66201 xla_ae_lines_pkg.SetAcctClass(
66202 p_accounting_class_code => 'INTERCOMPANY_COGS'
66203 , p_ae_header_id => l_ae_header_id
66204 );
66205
66206 --
66207 -- set rounding class
66208 --
66209 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
66210 'INTERCOMPANY_COGS';
66211
66212 --
66213 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
66214 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
66215 --
66216 -- bulk performance
66217 --
66218 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
66219
66220 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
66221 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
66222
66223 -- 4955764
66224 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66225 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
66226
66227 -- 4458381 Public Sector Enh
66228
66229 --
66230 -- set accounting attributes for the line type
66231 --
66232 l_entered_amt_idx := 3;
66233 l_accted_amt_idx := 8;
66234 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66235 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
66236 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
66237 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
66238 l_rec_acct_attrs.array_char_value(2) := p_source_85;
66239 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
66240 l_rec_acct_attrs.array_num_value(3) := p_source_91;
66241 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
66242 l_rec_acct_attrs.array_char_value(4) := p_source_88;
66243 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
66244 l_rec_acct_attrs.array_date_value(5) := p_source_92;
66245 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
66246 l_rec_acct_attrs.array_num_value(6) := p_source_93;
66247 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
66248 l_rec_acct_attrs.array_char_value(7) := p_source_94;
66249 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
66250 l_rec_acct_attrs.array_num_value(8) := p_source_95;
66251
66252 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
66253 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
66254
66255 ---------------------------------------------------------------------------------------------------------------
66256 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
66257 ---------------------------------------------------------------------------------------------------------------
66258 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
66259
66260 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66261 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66262
66263 IF xla_accounting_cache_pkg.GetValueChar
66264 (p_source_code => 'LEDGER_CATEGORY_CODE'
66265 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
66266 AND l_bflow_method_code = 'PRIOR_ENTRY'
66267 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
66268 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
66269 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
66270 )
66271 THEN
66272 xla_ae_lines_pkg.BflowUpgEntry
66273 (p_business_method_code => l_bflow_method_code
66274 ,p_business_class_code => l_bflow_class_code
66275 ,p_balance_type => l_balance_type_code);
66276 ELSE
66277 NULL;
66278 -- No business flow processing for business flow method of NONE.
66279 END IF;
66280
66281 --
66282 -- call analytical criteria
66283 --
66284
66285 --
66286 -- call description
66287 --
66288
66289 xla_ae_lines_pkg.SetLineDescription(
66290 p_ae_header_id => l_ae_header_id
66291 ,p_description => Description_1 (
66292 p_application_id => p_application_id
66293 , p_ae_header_id => l_ae_header_id
66294 , p_source_1 => p_source_1
66295 , p_source_2 => p_source_2
66296 , p_source_3 => p_source_3
66297 , p_source_4 => p_source_4
66298 , p_source_5 => p_source_5
66299 )
66300 );
66301
66302
66303 --
66304 -- call ADRs
66305 -- Bug 4922099
66306 --
66307 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66308 (NVL(l_actual_upg_option, 'N') = 'O') OR
66309 (NVL(l_enc_upg_option, 'N') = 'O')
66310 )
66311 THEN
66312 NULL;
66313 --
66314 --
66315
66316 l_ccid := AcctDerRule_6(
66317 p_application_id => p_application_id
66318 , p_ae_header_id => l_ae_header_id
66319 , p_source_11 => p_source_11
66320 , x_transaction_coa_id => l_adr_transaction_coa_id
66321 , x_accounting_coa_id => l_adr_accounting_coa_id
66322 , x_value_type_code => l_adr_value_type_code
66323 , p_side => 'NA'
66324 );
66325
66326 xla_ae_lines_pkg.set_ccid(
66327 p_code_combination_id => l_ccid
66328 , p_value_type_code => l_adr_value_type_code
66329 , p_transaction_coa_id => l_adr_transaction_coa_id
66330 , p_accounting_coa_id => l_adr_accounting_coa_id
66331 , p_adr_code => 'CST_DEFAULT'
66332 , p_adr_type_code => 'S'
66333 , p_component_type => l_component_type
66334 , p_component_code => l_component_code
66335 , p_component_type_code => l_component_type_code
66336 , p_component_appl_id => l_component_appl_id
66337 , p_amb_context_code => l_amb_context_code
66338 , p_side => 'NA'
66339 );
66340
66341
66342 --
66343 --
66344 END IF;
66345 --
66346 -- Bug 4922099
66347 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
66348 (NVL(l_enc_upg_option, 'N') = 'O')
66349 ) AND
66350 (l_bflow_method_code = 'PRIOR_ENTRY')
66351 )
66352 THEN
66353 IF
66354 --
66355 1 = 2
66356 --
66357 THEN
66358 xla_accounting_err_pkg.build_message
66359 (p_appli_s_name => 'XLA'
66360 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66361 ,p_token_1 => 'LINE_NUMBER'
66362 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
66363 ,p_token_2 => 'LINE_TYPE_NAME'
66364 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
66365 l_component_type
66366 ,l_component_code
66367 ,l_component_type_code
66368 ,l_component_appl_id
66369 ,l_amb_context_code
66370 ,l_entity_code
66371 ,l_event_class_code
66372 )
66373 ,p_token_3 => 'OWNER'
66374 ,p_value_3 => xla_lookups_pkg.get_meaning(
66375 p_lookup_type => 'XLA_OWNER_TYPE'
66376 ,p_lookup_code => l_component_type_code
66377 )
66378 ,p_token_4 => 'PRODUCT_NAME'
66379 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
66380 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
66381 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
66382 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
66383 ,p_ae_header_id => NULL
66384 );
66385
66386 IF (C_LEVEL_ERROR>= g_log_level) THEN
66387 trace
66388 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66389 ,p_level => C_LEVEL_ERROR
66390 ,p_module => l_log_module);
66391 END IF;
66392 END IF;
66393 END IF;
66394 --
66395 --
66396 ------------------------------------------------------------------------------------------------
66397 -- 4219869 Business Flow
66398 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
66399 -- Prior Entry. Currently, the following code is always generated.
66400 ------------------------------------------------------------------------------------------------
66401 XLA_AE_LINES_PKG.ValidateCurrentLine;
66402
66403 ------------------------------------------------------------------------------------
66404 -- 4219869 Business Flow
66405 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
66406 ------------------------------------------------------------------------------------
66407 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66408
66409 ----------------------------------------------------------------------------------
66410 -- 4219869 Business Flow
66411 -- Update journal entry status -- Need to generate this within IF <condition>
66412 ----------------------------------------------------------------------------------
66413 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66414 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
66415 ,p_balance_type_code => l_balance_type_code
66416 );
66417
66418 -------------------------------------------------------------------------------------------
66419 -- 4262811 - Generate the Accrual Reversal lines
66420 -------------------------------------------------------------------------------------------
66421 BEGIN
66422 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
66423 (g_array_event(p_event_id).array_value_num('header_index'));
66424 IF l_acc_rev_flag IS NULL THEN
66425 l_acc_rev_flag := 'N';
66426 END IF;
66427 EXCEPTION
66428 WHEN OTHERS THEN
66429 l_acc_rev_flag := 'N';
66430 END;
66431 --
66432 IF (l_acc_rev_flag = 'Y') THEN
66433
66434 -- 4645092 ------------------------------------------------------------------------------
66435 -- To allow MPA report to determine if it should generate report process
66436 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
66437 ------------------------------------------------------------------------------------------
66438
66439 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
66440 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
66441 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
66442 -- call ADRs
66443 -- Bug 4922099
66444 --
66445 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66446 (NVL(l_actual_upg_option, 'N') = 'O') OR
66447 (NVL(l_enc_upg_option, 'N') = 'O')
66448 )
66449 THEN
66450 NULL;
66451 --
66452 --
66453
66454 l_ccid := AcctDerRule_6(
66455 p_application_id => p_application_id
66456 , p_ae_header_id => l_ae_header_id
66457 , p_source_11 => p_source_11
66458 , x_transaction_coa_id => l_adr_transaction_coa_id
66459 , x_accounting_coa_id => l_adr_accounting_coa_id
66460 , x_value_type_code => l_adr_value_type_code
66461 , p_side => 'NA'
66462 );
66463
66464 xla_ae_lines_pkg.set_ccid(
66465 p_code_combination_id => l_ccid
66466 , p_value_type_code => l_adr_value_type_code
66467 , p_transaction_coa_id => l_adr_transaction_coa_id
66468 , p_accounting_coa_id => l_adr_accounting_coa_id
66469 , p_adr_code => 'CST_DEFAULT'
66470 , p_adr_type_code => 'S'
66471 , p_component_type => l_component_type
66472 , p_component_code => l_component_code
66473 , p_component_type_code => l_component_type_code
66474 , p_component_appl_id => l_component_appl_id
66475 , p_amb_context_code => l_amb_context_code
66476 , p_side => 'NA'
66477 );
66478
66479
66480 --
66481 --
66482 END IF;
66483
66484 --
66485 -- Update the line information that should be overwritten
66486 --
66487 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
66488 p_header_num => 1);
66489 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
66490
66491 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
66492
66493 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
66494 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
66495 END IF;
66496
66497 --
66498 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
66499 --
66500 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
66501 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
66502 ELSE
66503 ---------------------------------------------------------------------------------------------------
66504 -- 4262811a Switch Sign
66505 ---------------------------------------------------------------------------------------------------
66506 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
66507 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66508 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66509 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66510 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66511 -- 5132302
66512 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
66513 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66514
66515 END IF;
66516
66517 -- 4955764
66518 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66519 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
66520
66521
66522 XLA_AE_LINES_PKG.ValidateCurrentLine;
66523 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66524
66525 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66526 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
66527 ,p_balance_type_code => l_balance_type_code);
66528
66529 END IF;
66530
66531 -----------------------------------------------------------------------------------------
66532 -- 4262811 Multiperiod Accounting
66533 -----------------------------------------------------------------------------------------
66534 -- No MPA option is assigned.
66535
66536
66537 END IF;
66538 END IF;
66539 --
66540
66541 --
66542 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66543 trace
66544 (p_msg => 'END of AcctLineType_141'
66545 ,p_level => C_LEVEL_PROCEDURE
66546 ,p_module => l_log_module);
66547 END IF;
66548 --
66549 EXCEPTION
66550 WHEN xla_exceptions_pkg.application_exception THEN
66551 RAISE;
66552 WHEN OTHERS THEN
66553 xla_exceptions_pkg.raise_message
66554 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_141');
66555 END AcctLineType_141;
66556 --
66557
66558 ---------------------------------------
66559 --
66560 -- PRIVATE FUNCTION
66561 -- AcctLineType_142
66562 --
66563 ---------------------------------------
66564 PROCEDURE AcctLineType_142 (
66565 p_application_id IN NUMBER
66566 ,p_event_id IN NUMBER
66567 ,p_calculate_acctd_flag IN VARCHAR2
66568 ,p_calculate_g_l_flag IN VARCHAR2
66569 ,p_actual_flag IN OUT VARCHAR2
66570 ,p_balance_type_code OUT VARCHAR2
66571 ,p_gain_or_loss_ref OUT VARCHAR2
66572
66573 --TRANSACTION_ID
66574 , p_source_1 IN NUMBER
66575 --Item Concatenated Segments
66576 , p_source_2 IN VARCHAR2
66577 --Transaction Quantity
66578 , p_source_3 IN NUMBER
66579 --Transaction Unit of Measure Code
66580 , p_source_4 IN VARCHAR2
66581 --Inventory Transaction Type Description
66582 , p_source_5 IN VARCHAR2
66583 --Cost Management Default Account
66584 , p_source_11 IN NUMBER
66585 --Transaction Action Name
66586 , p_source_62 IN NUMBER
66587 , p_source_62_meaning IN VARCHAR2
66588 --DISTRIBUTION_IDENTIFIER
66589 , p_source_84 IN NUMBER
66590 --Distribution Type
66591 , p_source_85 IN VARCHAR2
66592 , p_source_85_meaning IN VARCHAR2
66593 --Entered Currency Code
66594 , p_source_88 IN VARCHAR2
66595 --Entered Amount
66596 , p_source_91 IN NUMBER
66597 --Currency Conversion Date
66598 , p_source_92 IN DATE
66599 --Currency Conversion Rate
66600 , p_source_93 IN NUMBER
66601 --Currency Conversion Type
66602 , p_source_94 IN VARCHAR2
66603 --Accounted Amount
66604 , p_source_95 IN NUMBER
66605 --Accounting Line Type
66606 , p_source_97 IN NUMBER
66607 )
66608 IS
66609
66610 l_component_type VARCHAR2(80);
66611 l_component_code VARCHAR2(30);
66612 l_component_type_code VARCHAR2(1);
66613 l_component_appl_id INTEGER;
66614 l_amb_context_code VARCHAR2(30);
66615 l_entity_code VARCHAR2(30);
66616 l_event_class_code VARCHAR2(30);
66617 l_ae_header_id NUMBER;
66618 l_event_type_code VARCHAR2(30);
66619 l_line_definition_code VARCHAR2(30);
66620 l_line_definition_owner_code VARCHAR2(1);
66621 --
66622 -- adr variables
66623 l_segment VARCHAR2(30);
66624 l_ccid NUMBER;
66625 l_adr_transaction_coa_id NUMBER;
66626 l_adr_accounting_coa_id NUMBER;
66627 l_adr_flexfield_segment_code VARCHAR2(30);
66628 l_adr_flex_value_set_id NUMBER;
66629 l_adr_value_type_code VARCHAR2(30);
66630 l_adr_value_combination_id NUMBER;
66631 l_adr_value_segment_code VARCHAR2(30);
66632
66633 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
66634 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
66635 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
66636 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
66637
66638 -- 4262811 Variables ------------------------------------------------------------------------------------------
66639 l_entered_amt_idx NUMBER;
66640 l_accted_amt_idx NUMBER;
66641 l_acc_rev_flag VARCHAR2(1);
66642 l_accrual_line_num NUMBER;
66643 l_tmp_amt NUMBER;
66644 l_acc_rev_natural_side_code VARCHAR2(1);
66645
66646 l_num_entries NUMBER;
66647 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
66648 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
66649 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
66650 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
66651 l_recog_line_1 NUMBER;
66652 l_recog_line_2 NUMBER;
66653
66654 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
66655 l_bflow_applied_to_amt NUMBER; -- 5132302
66656 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
66657
66658 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
66659
66660 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
66661 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
66662
66663 ---------------------------------------------------------------------------------------------------------------
66664
66665
66666 --
66667 -- bulk performance
66668 --
66669 l_balance_type_code VARCHAR2(1);
66670 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
66671 l_log_module VARCHAR2(240);
66672
66673 --
66674 -- Upgrade strategy
66675 --
66676 l_actual_upg_option VARCHAR2(1);
66677 l_enc_upg_option VARCHAR2(1);
66678
66679 --
66680 BEGIN
66681 --
66682 IF g_log_enabled THEN
66683 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_142';
66684 END IF;
66685 --
66686 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66687
66688 trace
66689 (p_msg => 'BEGIN of AcctLineType_142'
66690 ,p_level => C_LEVEL_PROCEDURE
66691 ,p_module => l_log_module);
66692
66693 END IF;
66694 --
66695 l_component_type := 'AMB_JLT';
66696 l_component_code := 'INTERCOMPANY_COGS';
66697 l_component_type_code := 'S';
66698 l_component_appl_id := 707;
66699 l_amb_context_code := 'DEFAULT';
66700 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
66701 l_event_class_code := 'LOG_INTERCOMPANY';
66702 l_event_type_code := 'LOG_IC_SALES_RETURN';
66703 l_line_definition_owner_code := 'S';
66704 l_line_definition_code := 'PI_LOG_IC_SALES_RETURN';
66705 --
66706 l_balance_type_code := 'A';
66707 l_segment := NULL;
66708 l_ccid := NULL;
66709 l_adr_transaction_coa_id := NULL;
66710 l_adr_accounting_coa_id := NULL;
66711 l_adr_flexfield_segment_code := NULL;
66712 l_adr_flex_value_set_id := NULL;
66713 l_adr_value_type_code := NULL;
66714 l_adr_value_combination_id := NULL;
66715 l_adr_value_segment_code := NULL;
66716
66717 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
66718 l_bflow_class_code := ''; -- 4219869 Business Flow
66719 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
66720 l_budgetary_control_flag := 'N';
66721
66722 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66723 l_bflow_applied_to_amt := NULL; -- 5132302
66724 l_entered_amt_idx := NULL; -- 4262811
66725 l_accted_amt_idx := NULL; -- 4262811
66726 l_acc_rev_flag := NULL; -- 4262811
66727 l_accrual_line_num := NULL; -- 4262811
66728 l_tmp_amt := NULL; -- 4262811
66729 --
66730
66731 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
66732 l_balance_type_code <> 'B' THEN
66733 IF NVL(p_source_97,9E125) = 2 AND
66734 ((p_source_95 >= 0 AND
66735 NVL(p_source_62,9E125) = 9) OR
66736 (p_source_95 <= 0 AND
66737 NVL(p_source_62,9E125) = 14)
66738 ) THEN
66739
66740 --
66741 XLA_AE_LINES_PKG.SetNewLine;
66742
66743 p_balance_type_code := l_balance_type_code;
66744 -- set the flag so later we will know whether the gain loss line needs to be created
66745
66746 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
66747 p_actual_flag :='A';
66748 END IF;
66749
66750 --
66751 -- bulk performance
66752 --
66753 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
66754 p_header_num => 0); -- 4262811
66755 --
66756 -- set accounting line options
66757 --
66758 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
66759 p_natural_side_code => 'D'
66760 , p_gain_or_loss_flag => 'N'
66761 , p_gl_transfer_mode_code => 'S'
66762 , p_acct_entry_type_code => 'A'
66763 , p_switch_side_flag => 'Y'
66764 , p_merge_duplicate_code => 'N'
66765 );
66766 --
66767 l_acc_rev_natural_side_code := 'C'; -- 4262811
66768 --
66769 --
66770 -- set accounting line type info
66771 --
66772 xla_ae_lines_pkg.SetAcctLineType
66773 (p_component_type => l_component_type
66774 ,p_event_type_code => l_event_type_code
66775 ,p_line_definition_owner_code => l_line_definition_owner_code
66776 ,p_line_definition_code => l_line_definition_code
66777 ,p_accounting_line_code => l_component_code
66778 ,p_accounting_line_type_code => l_component_type_code
66779 ,p_accounting_line_appl_id => l_component_appl_id
66780 ,p_amb_context_code => l_amb_context_code
66781 ,p_entity_code => l_entity_code
66782 ,p_event_class_code => l_event_class_code);
66783 --
66784 -- set accounting class
66785 --
66786 xla_ae_lines_pkg.SetAcctClass(
66787 p_accounting_class_code => 'INTERCOMPANY_COGS'
66788 , p_ae_header_id => l_ae_header_id
66789 );
66790
66791 --
66792 -- set rounding class
66793 --
66794 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
66795 'INTERCOMPANY_COGS';
66796
66797 --
66798 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
66799 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
66800 --
66801 -- bulk performance
66802 --
66803 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
66804
66805 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
66806 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
66807
66808 -- 4955764
66809 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66810 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
66811
66812 -- 4458381 Public Sector Enh
66813
66814 --
66815 -- set accounting attributes for the line type
66816 --
66817 l_entered_amt_idx := 3;
66818 l_accted_amt_idx := 8;
66819 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66820 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
66821 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
66822 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
66823 l_rec_acct_attrs.array_char_value(2) := p_source_85;
66824 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
66825 l_rec_acct_attrs.array_num_value(3) := p_source_91;
66826 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
66827 l_rec_acct_attrs.array_char_value(4) := p_source_88;
66828 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
66829 l_rec_acct_attrs.array_date_value(5) := p_source_92;
66830 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
66831 l_rec_acct_attrs.array_num_value(6) := p_source_93;
66832 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
66833 l_rec_acct_attrs.array_char_value(7) := p_source_94;
66834 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
66835 l_rec_acct_attrs.array_num_value(8) := p_source_95;
66836
66837 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
66838 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
66839
66840 ---------------------------------------------------------------------------------------------------------------
66841 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
66842 ---------------------------------------------------------------------------------------------------------------
66843 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
66844
66845 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66846 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66847
66848 IF xla_accounting_cache_pkg.GetValueChar
66849 (p_source_code => 'LEDGER_CATEGORY_CODE'
66850 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
66851 AND l_bflow_method_code = 'PRIOR_ENTRY'
66852 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
66853 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
66854 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
66855 )
66856 THEN
66857 xla_ae_lines_pkg.BflowUpgEntry
66858 (p_business_method_code => l_bflow_method_code
66859 ,p_business_class_code => l_bflow_class_code
66860 ,p_balance_type => l_balance_type_code);
66861 ELSE
66862 NULL;
66863 -- No business flow processing for business flow method of NONE.
66864 END IF;
66865
66866 --
66867 -- call analytical criteria
66868 --
66869
66870 --
66871 -- call description
66872 --
66873
66874 xla_ae_lines_pkg.SetLineDescription(
66875 p_ae_header_id => l_ae_header_id
66876 ,p_description => Description_1 (
66877 p_application_id => p_application_id
66878 , p_ae_header_id => l_ae_header_id
66879 , p_source_1 => p_source_1
66880 , p_source_2 => p_source_2
66881 , p_source_3 => p_source_3
66882 , p_source_4 => p_source_4
66883 , p_source_5 => p_source_5
66884 )
66885 );
66886
66887
66888 --
66889 -- call ADRs
66890 -- Bug 4922099
66891 --
66892 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66893 (NVL(l_actual_upg_option, 'N') = 'O') OR
66894 (NVL(l_enc_upg_option, 'N') = 'O')
66895 )
66896 THEN
66897 NULL;
66898 --
66899 --
66900
66901 l_ccid := AcctDerRule_6(
66902 p_application_id => p_application_id
66903 , p_ae_header_id => l_ae_header_id
66904 , p_source_11 => p_source_11
66905 , x_transaction_coa_id => l_adr_transaction_coa_id
66906 , x_accounting_coa_id => l_adr_accounting_coa_id
66907 , x_value_type_code => l_adr_value_type_code
66908 , p_side => 'NA'
66909 );
66910
66911 xla_ae_lines_pkg.set_ccid(
66912 p_code_combination_id => l_ccid
66913 , p_value_type_code => l_adr_value_type_code
66914 , p_transaction_coa_id => l_adr_transaction_coa_id
66915 , p_accounting_coa_id => l_adr_accounting_coa_id
66916 , p_adr_code => 'CST_DEFAULT'
66917 , p_adr_type_code => 'S'
66918 , p_component_type => l_component_type
66919 , p_component_code => l_component_code
66920 , p_component_type_code => l_component_type_code
66921 , p_component_appl_id => l_component_appl_id
66922 , p_amb_context_code => l_amb_context_code
66923 , p_side => 'NA'
66924 );
66925
66926
66927 --
66928 --
66929 END IF;
66930 --
66931 -- Bug 4922099
66932 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
66933 (NVL(l_enc_upg_option, 'N') = 'O')
66934 ) AND
66935 (l_bflow_method_code = 'PRIOR_ENTRY')
66936 )
66937 THEN
66938 IF
66939 --
66940 1 = 2
66941 --
66942 THEN
66943 xla_accounting_err_pkg.build_message
66944 (p_appli_s_name => 'XLA'
66945 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66946 ,p_token_1 => 'LINE_NUMBER'
66947 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
66948 ,p_token_2 => 'LINE_TYPE_NAME'
66949 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
66950 l_component_type
66951 ,l_component_code
66952 ,l_component_type_code
66953 ,l_component_appl_id
66954 ,l_amb_context_code
66955 ,l_entity_code
66956 ,l_event_class_code
66957 )
66958 ,p_token_3 => 'OWNER'
66959 ,p_value_3 => xla_lookups_pkg.get_meaning(
66960 p_lookup_type => 'XLA_OWNER_TYPE'
66961 ,p_lookup_code => l_component_type_code
66962 )
66963 ,p_token_4 => 'PRODUCT_NAME'
66964 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
66965 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
66966 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
66967 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
66968 ,p_ae_header_id => NULL
66969 );
66970
66971 IF (C_LEVEL_ERROR>= g_log_level) THEN
66972 trace
66973 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66974 ,p_level => C_LEVEL_ERROR
66975 ,p_module => l_log_module);
66976 END IF;
66977 END IF;
66978 END IF;
66979 --
66980 --
66981 ------------------------------------------------------------------------------------------------
66982 -- 4219869 Business Flow
66983 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
66984 -- Prior Entry. Currently, the following code is always generated.
66985 ------------------------------------------------------------------------------------------------
66986 XLA_AE_LINES_PKG.ValidateCurrentLine;
66987
66988 ------------------------------------------------------------------------------------
66989 -- 4219869 Business Flow
66990 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
66991 ------------------------------------------------------------------------------------
66992 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66993
66994 ----------------------------------------------------------------------------------
66995 -- 4219869 Business Flow
66996 -- Update journal entry status -- Need to generate this within IF <condition>
66997 ----------------------------------------------------------------------------------
66998 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66999 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
67000 ,p_balance_type_code => l_balance_type_code
67001 );
67002
67003 -------------------------------------------------------------------------------------------
67004 -- 4262811 - Generate the Accrual Reversal lines
67005 -------------------------------------------------------------------------------------------
67006 BEGIN
67007 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
67008 (g_array_event(p_event_id).array_value_num('header_index'));
67009 IF l_acc_rev_flag IS NULL THEN
67010 l_acc_rev_flag := 'N';
67011 END IF;
67012 EXCEPTION
67013 WHEN OTHERS THEN
67014 l_acc_rev_flag := 'N';
67015 END;
67016 --
67017 IF (l_acc_rev_flag = 'Y') THEN
67018
67019 -- 4645092 ------------------------------------------------------------------------------
67020 -- To allow MPA report to determine if it should generate report process
67021 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
67022 ------------------------------------------------------------------------------------------
67023
67024 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
67025 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
67026 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
67027 -- call ADRs
67028 -- Bug 4922099
67029 --
67030 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
67031 (NVL(l_actual_upg_option, 'N') = 'O') OR
67032 (NVL(l_enc_upg_option, 'N') = 'O')
67033 )
67034 THEN
67035 NULL;
67036 --
67037 --
67038
67039 l_ccid := AcctDerRule_6(
67040 p_application_id => p_application_id
67041 , p_ae_header_id => l_ae_header_id
67042 , p_source_11 => p_source_11
67043 , x_transaction_coa_id => l_adr_transaction_coa_id
67044 , x_accounting_coa_id => l_adr_accounting_coa_id
67045 , x_value_type_code => l_adr_value_type_code
67046 , p_side => 'NA'
67047 );
67048
67049 xla_ae_lines_pkg.set_ccid(
67050 p_code_combination_id => l_ccid
67051 , p_value_type_code => l_adr_value_type_code
67052 , p_transaction_coa_id => l_adr_transaction_coa_id
67053 , p_accounting_coa_id => l_adr_accounting_coa_id
67054 , p_adr_code => 'CST_DEFAULT'
67055 , p_adr_type_code => 'S'
67056 , p_component_type => l_component_type
67057 , p_component_code => l_component_code
67058 , p_component_type_code => l_component_type_code
67059 , p_component_appl_id => l_component_appl_id
67060 , p_amb_context_code => l_amb_context_code
67061 , p_side => 'NA'
67062 );
67063
67064
67065 --
67066 --
67067 END IF;
67068
67069 --
67070 -- Update the line information that should be overwritten
67071 --
67072 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
67073 p_header_num => 1);
67074 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
67075
67076 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
67077
67078 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
67079 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
67080 END IF;
67081
67082 --
67083 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
67084 --
67085 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
67086 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
67087 ELSE
67088 ---------------------------------------------------------------------------------------------------
67089 -- 4262811a Switch Sign
67090 ---------------------------------------------------------------------------------------------------
67091 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
67092 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67093 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67094 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67095 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67096 -- 5132302
67097 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
67098 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67099
67100 END IF;
67101
67102 -- 4955764
67103 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67104 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
67105
67106
67107 XLA_AE_LINES_PKG.ValidateCurrentLine;
67108 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
67109
67110 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
67111 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
67112 ,p_balance_type_code => l_balance_type_code);
67113
67114 END IF;
67115
67116 -----------------------------------------------------------------------------------------
67117 -- 4262811 Multiperiod Accounting
67118 -----------------------------------------------------------------------------------------
67119 -- No MPA option is assigned.
67120
67121
67122 END IF;
67123 END IF;
67124 --
67125
67126 --
67127 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67128 trace
67129 (p_msg => 'END of AcctLineType_142'
67130 ,p_level => C_LEVEL_PROCEDURE
67131 ,p_module => l_log_module);
67132 END IF;
67133 --
67134 EXCEPTION
67135 WHEN xla_exceptions_pkg.application_exception THEN
67136 RAISE;
67137 WHEN OTHERS THEN
67138 xla_exceptions_pkg.raise_message
67139 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_142');
67140 END AcctLineType_142;
67141 --
67142
67143 ---------------------------------------
67144 --
67145 -- PRIVATE FUNCTION
67146 -- AcctLineType_143
67147 --
67148 ---------------------------------------
67149 PROCEDURE AcctLineType_143 (
67150 p_application_id IN NUMBER
67151 ,p_event_id IN NUMBER
67152 ,p_calculate_acctd_flag IN VARCHAR2
67153 ,p_calculate_g_l_flag IN VARCHAR2
67154 ,p_actual_flag IN OUT VARCHAR2
67155 ,p_balance_type_code OUT VARCHAR2
67156 ,p_gain_or_loss_ref OUT VARCHAR2
67157
67158 --TRANSACTION_ID
67159 , p_source_1 IN NUMBER
67160 --Item Concatenated Segments
67161 , p_source_2 IN VARCHAR2
67162 --Transaction Quantity
67163 , p_source_3 IN NUMBER
67164 --Transaction Unit of Measure Code
67165 , p_source_4 IN VARCHAR2
67166 --Inventory Transaction Type Description
67167 , p_source_5 IN VARCHAR2
67168 --Transaction Transportation Distribution Account
67169 , p_source_32 IN NUMBER
67170 --DISTRIBUTION_IDENTIFIER
67171 , p_source_84 IN NUMBER
67172 --Distribution Type
67173 , p_source_85 IN VARCHAR2
67174 , p_source_85_meaning IN VARCHAR2
67175 --Entered Currency Code
67176 , p_source_88 IN VARCHAR2
67177 --Entered Amount
67178 , p_source_91 IN NUMBER
67179 --Currency Conversion Date
67180 , p_source_92 IN DATE
67181 --Currency Conversion Rate
67182 , p_source_93 IN NUMBER
67183 --Currency Conversion Type
67184 , p_source_94 IN VARCHAR2
67185 --Accounted Amount
67186 , p_source_95 IN NUMBER
67187 --Accounting Line Type
67188 , p_source_97 IN NUMBER
67189 )
67190 IS
67191
67192 l_component_type VARCHAR2(80);
67193 l_component_code VARCHAR2(30);
67194 l_component_type_code VARCHAR2(1);
67195 l_component_appl_id INTEGER;
67196 l_amb_context_code VARCHAR2(30);
67197 l_entity_code VARCHAR2(30);
67198 l_event_class_code VARCHAR2(30);
67199 l_ae_header_id NUMBER;
67200 l_event_type_code VARCHAR2(30);
67201 l_line_definition_code VARCHAR2(30);
67202 l_line_definition_owner_code VARCHAR2(1);
67203 --
67204 -- adr variables
67205 l_segment VARCHAR2(30);
67206 l_ccid NUMBER;
67207 l_adr_transaction_coa_id NUMBER;
67208 l_adr_accounting_coa_id NUMBER;
67209 l_adr_flexfield_segment_code VARCHAR2(30);
67210 l_adr_flex_value_set_id NUMBER;
67211 l_adr_value_type_code VARCHAR2(30);
67212 l_adr_value_combination_id NUMBER;
67213 l_adr_value_segment_code VARCHAR2(30);
67214
67215 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
67216 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
67217 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
67218 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
67219
67220 -- 4262811 Variables ------------------------------------------------------------------------------------------
67221 l_entered_amt_idx NUMBER;
67222 l_accted_amt_idx NUMBER;
67223 l_acc_rev_flag VARCHAR2(1);
67224 l_accrual_line_num NUMBER;
67225 l_tmp_amt NUMBER;
67226 l_acc_rev_natural_side_code VARCHAR2(1);
67227
67228 l_num_entries NUMBER;
67229 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
67230 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
67231 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
67232 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
67233 l_recog_line_1 NUMBER;
67234 l_recog_line_2 NUMBER;
67235
67236 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
67237 l_bflow_applied_to_amt NUMBER; -- 5132302
67238 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
67239
67240 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
67241
67242 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
67243 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
67244
67245 ---------------------------------------------------------------------------------------------------------------
67246
67247
67248 --
67249 -- bulk performance
67250 --
67251 l_balance_type_code VARCHAR2(1);
67252 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
67253 l_log_module VARCHAR2(240);
67254
67255 --
67256 -- Upgrade strategy
67257 --
67258 l_actual_upg_option VARCHAR2(1);
67259 l_enc_upg_option VARCHAR2(1);
67260
67261 --
67262 BEGIN
67263 --
67264 IF g_log_enabled THEN
67265 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_143';
67266 END IF;
67267 --
67268 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67269
67270 trace
67271 (p_msg => 'BEGIN of AcctLineType_143'
67272 ,p_level => C_LEVEL_PROCEDURE
67273 ,p_module => l_log_module);
67274
67275 END IF;
67276 --
67277 l_component_type := 'AMB_JLT';
67278 l_component_code := 'INTERORG_FREIGHT_CHARGE';
67279 l_component_type_code := 'S';
67280 l_component_appl_id := 707;
67281 l_amb_context_code := 'DEFAULT';
67282 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
67283 l_event_class_code := 'DIR_INTERORG_SHIP';
67284 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
67285 l_line_definition_owner_code := 'S';
67286 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
67287 --
67288 l_balance_type_code := 'A';
67289 l_segment := NULL;
67290 l_ccid := NULL;
67291 l_adr_transaction_coa_id := NULL;
67292 l_adr_accounting_coa_id := NULL;
67293 l_adr_flexfield_segment_code := NULL;
67294 l_adr_flex_value_set_id := NULL;
67295 l_adr_value_type_code := NULL;
67296 l_adr_value_combination_id := NULL;
67297 l_adr_value_segment_code := NULL;
67298
67299 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
67300 l_bflow_class_code := ''; -- 4219869 Business Flow
67301 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
67302 l_budgetary_control_flag := 'N';
67303
67304 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67305 l_bflow_applied_to_amt := NULL; -- 5132302
67306 l_entered_amt_idx := NULL; -- 4262811
67307 l_accted_amt_idx := NULL; -- 4262811
67308 l_acc_rev_flag := NULL; -- 4262811
67309 l_accrual_line_num := NULL; -- 4262811
67310 l_tmp_amt := NULL; -- 4262811
67311 --
67312
67313 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
67314 l_balance_type_code <> 'B' THEN
67315 IF NVL(p_source_97,9E125) = 12
67316 THEN
67317
67318 --
67319 XLA_AE_LINES_PKG.SetNewLine;
67320
67321 p_balance_type_code := l_balance_type_code;
67322 -- set the flag so later we will know whether the gain loss line needs to be created
67323
67324 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
67325 p_actual_flag :='A';
67326 END IF;
67327
67328 --
67329 -- bulk performance
67330 --
67331 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
67332 p_header_num => 0); -- 4262811
67333 --
67334 -- set accounting line options
67335 --
67336 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
67337 p_natural_side_code => 'D'
67338 , p_gain_or_loss_flag => 'N'
67339 , p_gl_transfer_mode_code => 'S'
67340 , p_acct_entry_type_code => 'A'
67341 , p_switch_side_flag => 'Y'
67342 , p_merge_duplicate_code => 'N'
67343 );
67344 --
67345 l_acc_rev_natural_side_code := 'C'; -- 4262811
67346 --
67347 --
67348 -- set accounting line type info
67349 --
67350 xla_ae_lines_pkg.SetAcctLineType
67351 (p_component_type => l_component_type
67352 ,p_event_type_code => l_event_type_code
67353 ,p_line_definition_owner_code => l_line_definition_owner_code
67354 ,p_line_definition_code => l_line_definition_code
67355 ,p_accounting_line_code => l_component_code
67356 ,p_accounting_line_type_code => l_component_type_code
67357 ,p_accounting_line_appl_id => l_component_appl_id
67358 ,p_amb_context_code => l_amb_context_code
67359 ,p_entity_code => l_entity_code
67360 ,p_event_class_code => l_event_class_code);
67361 --
67362 -- set accounting class
67363 --
67364 xla_ae_lines_pkg.SetAcctClass(
67365 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
67366 , p_ae_header_id => l_ae_header_id
67367 );
67368
67369 --
67370 -- set rounding class
67371 --
67372 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
67373 'INTERORG_FREIGHT_CHARGE';
67374
67375 --
67376 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
67377 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
67378 --
67379 -- bulk performance
67380 --
67381 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
67382
67383 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
67384 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
67385
67386 -- 4955764
67387 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67388 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
67389
67390 -- 4458381 Public Sector Enh
67391
67392 --
67393 -- set accounting attributes for the line type
67394 --
67395 l_entered_amt_idx := 3;
67396 l_accted_amt_idx := 8;
67397 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67398 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
67399 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
67400 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
67401 l_rec_acct_attrs.array_char_value(2) := p_source_85;
67402 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
67403 l_rec_acct_attrs.array_num_value(3) := p_source_91;
67404 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
67405 l_rec_acct_attrs.array_char_value(4) := p_source_88;
67406 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
67407 l_rec_acct_attrs.array_date_value(5) := p_source_92;
67408 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
67409 l_rec_acct_attrs.array_num_value(6) := p_source_93;
67410 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
67411 l_rec_acct_attrs.array_char_value(7) := p_source_94;
67412 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
67413 l_rec_acct_attrs.array_num_value(8) := p_source_95;
67414
67415 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
67416 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
67417
67418 ---------------------------------------------------------------------------------------------------------------
67419 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
67420 ---------------------------------------------------------------------------------------------------------------
67421 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
67422
67423 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
67424 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
67425
67426 IF xla_accounting_cache_pkg.GetValueChar
67427 (p_source_code => 'LEDGER_CATEGORY_CODE'
67428 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
67429 AND l_bflow_method_code = 'PRIOR_ENTRY'
67430 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
67431 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
67432 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
67433 )
67434 THEN
67435 xla_ae_lines_pkg.BflowUpgEntry
67436 (p_business_method_code => l_bflow_method_code
67437 ,p_business_class_code => l_bflow_class_code
67438 ,p_balance_type => l_balance_type_code);
67439 ELSE
67440 NULL;
67441 -- No business flow processing for business flow method of NONE.
67442 END IF;
67443
67444 --
67445 -- call analytical criteria
67446 --
67447
67448 --
67449 -- call description
67450 --
67451
67452 xla_ae_lines_pkg.SetLineDescription(
67453 p_ae_header_id => l_ae_header_id
67454 ,p_description => Description_1 (
67455 p_application_id => p_application_id
67456 , p_ae_header_id => l_ae_header_id
67457 , p_source_1 => p_source_1
67458 , p_source_2 => p_source_2
67459 , p_source_3 => p_source_3
67460 , p_source_4 => p_source_4
67461 , p_source_5 => p_source_5
67462 )
67463 );
67464
67465
67466 --
67467 -- call ADRs
67468 -- Bug 4922099
67469 --
67470 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
67471 (NVL(l_actual_upg_option, 'N') = 'O') OR
67472 (NVL(l_enc_upg_option, 'N') = 'O')
67473 )
67474 THEN
67475 NULL;
67476 --
67477 --
67478
67479 l_ccid := AcctDerRule_17(
67480 p_application_id => p_application_id
67481 , p_ae_header_id => l_ae_header_id
67482 , p_source_32 => p_source_32
67483 , x_transaction_coa_id => l_adr_transaction_coa_id
67484 , x_accounting_coa_id => l_adr_accounting_coa_id
67485 , x_value_type_code => l_adr_value_type_code
67486 , p_side => 'NA'
67487 );
67488
67489 xla_ae_lines_pkg.set_ccid(
67490 p_code_combination_id => l_ccid
67491 , p_value_type_code => l_adr_value_type_code
67492 , p_transaction_coa_id => l_adr_transaction_coa_id
67493 , p_accounting_coa_id => l_adr_accounting_coa_id
67494 , p_adr_code => 'PI_FREIGHT'
67495 , p_adr_type_code => 'S'
67496 , p_component_type => l_component_type
67497 , p_component_code => l_component_code
67498 , p_component_type_code => l_component_type_code
67499 , p_component_appl_id => l_component_appl_id
67500 , p_amb_context_code => l_amb_context_code
67501 , p_side => 'NA'
67502 );
67503
67504
67505 --
67506 --
67507 END IF;
67508 --
67509 -- Bug 4922099
67510 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
67511 (NVL(l_enc_upg_option, 'N') = 'O')
67512 ) AND
67513 (l_bflow_method_code = 'PRIOR_ENTRY')
67514 )
67515 THEN
67516 IF
67517 --
67518 1 = 2
67519 --
67520 THEN
67521 xla_accounting_err_pkg.build_message
67522 (p_appli_s_name => 'XLA'
67523 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
67524 ,p_token_1 => 'LINE_NUMBER'
67525 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
67526 ,p_token_2 => 'LINE_TYPE_NAME'
67527 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
67528 l_component_type
67529 ,l_component_code
67530 ,l_component_type_code
67531 ,l_component_appl_id
67532 ,l_amb_context_code
67533 ,l_entity_code
67534 ,l_event_class_code
67535 )
67536 ,p_token_3 => 'OWNER'
67537 ,p_value_3 => xla_lookups_pkg.get_meaning(
67538 p_lookup_type => 'XLA_OWNER_TYPE'
67539 ,p_lookup_code => l_component_type_code
67540 )
67541 ,p_token_4 => 'PRODUCT_NAME'
67542 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
67543 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
67544 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
67545 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
67546 ,p_ae_header_id => NULL
67547 );
67548
67549 IF (C_LEVEL_ERROR>= g_log_level) THEN
67550 trace
67551 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
67552 ,p_level => C_LEVEL_ERROR
67553 ,p_module => l_log_module);
67554 END IF;
67555 END IF;
67556 END IF;
67557 --
67558 --
67559 ------------------------------------------------------------------------------------------------
67560 -- 4219869 Business Flow
67561 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
67562 -- Prior Entry. Currently, the following code is always generated.
67563 ------------------------------------------------------------------------------------------------
67564 XLA_AE_LINES_PKG.ValidateCurrentLine;
67565
67566 ------------------------------------------------------------------------------------
67567 -- 4219869 Business Flow
67568 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
67569 ------------------------------------------------------------------------------------
67570 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
67571
67572 ----------------------------------------------------------------------------------
67573 -- 4219869 Business Flow
67574 -- Update journal entry status -- Need to generate this within IF <condition>
67575 ----------------------------------------------------------------------------------
67576 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
67577 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
67578 ,p_balance_type_code => l_balance_type_code
67579 );
67580
67581 -------------------------------------------------------------------------------------------
67582 -- 4262811 - Generate the Accrual Reversal lines
67583 -------------------------------------------------------------------------------------------
67584 BEGIN
67585 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
67586 (g_array_event(p_event_id).array_value_num('header_index'));
67587 IF l_acc_rev_flag IS NULL THEN
67588 l_acc_rev_flag := 'N';
67589 END IF;
67590 EXCEPTION
67591 WHEN OTHERS THEN
67592 l_acc_rev_flag := 'N';
67593 END;
67594 --
67595 IF (l_acc_rev_flag = 'Y') THEN
67596
67597 -- 4645092 ------------------------------------------------------------------------------
67598 -- To allow MPA report to determine if it should generate report process
67599 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
67600 ------------------------------------------------------------------------------------------
67601
67602 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
67603 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
67604 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
67605 -- call ADRs
67606 -- Bug 4922099
67607 --
67608 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
67609 (NVL(l_actual_upg_option, 'N') = 'O') OR
67610 (NVL(l_enc_upg_option, 'N') = 'O')
67611 )
67612 THEN
67613 NULL;
67614 --
67615 --
67616
67617 l_ccid := AcctDerRule_17(
67618 p_application_id => p_application_id
67619 , p_ae_header_id => l_ae_header_id
67620 , p_source_32 => p_source_32
67621 , x_transaction_coa_id => l_adr_transaction_coa_id
67622 , x_accounting_coa_id => l_adr_accounting_coa_id
67623 , x_value_type_code => l_adr_value_type_code
67624 , p_side => 'NA'
67625 );
67626
67627 xla_ae_lines_pkg.set_ccid(
67628 p_code_combination_id => l_ccid
67629 , p_value_type_code => l_adr_value_type_code
67630 , p_transaction_coa_id => l_adr_transaction_coa_id
67631 , p_accounting_coa_id => l_adr_accounting_coa_id
67632 , p_adr_code => 'PI_FREIGHT'
67633 , p_adr_type_code => 'S'
67634 , p_component_type => l_component_type
67635 , p_component_code => l_component_code
67636 , p_component_type_code => l_component_type_code
67637 , p_component_appl_id => l_component_appl_id
67638 , p_amb_context_code => l_amb_context_code
67639 , p_side => 'NA'
67640 );
67641
67642
67643 --
67644 --
67645 END IF;
67646
67647 --
67648 -- Update the line information that should be overwritten
67649 --
67650 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
67651 p_header_num => 1);
67652 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
67653
67654 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
67655
67656 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
67657 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
67658 END IF;
67659
67660 --
67661 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
67662 --
67663 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
67664 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
67665 ELSE
67666 ---------------------------------------------------------------------------------------------------
67667 -- 4262811a Switch Sign
67668 ---------------------------------------------------------------------------------------------------
67669 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
67670 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67671 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67672 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
67673 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67674 -- 5132302
67675 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
67676 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
67677
67678 END IF;
67679
67680 -- 4955764
67681 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67682 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
67683
67684
67685 XLA_AE_LINES_PKG.ValidateCurrentLine;
67686 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
67687
67688 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
67689 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
67690 ,p_balance_type_code => l_balance_type_code);
67691
67692 END IF;
67693
67694 -----------------------------------------------------------------------------------------
67695 -- 4262811 Multiperiod Accounting
67696 -----------------------------------------------------------------------------------------
67697 -- No MPA option is assigned.
67698
67699
67700 END IF;
67701 END IF;
67702 --
67703
67704 --
67705 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67706 trace
67707 (p_msg => 'END of AcctLineType_143'
67708 ,p_level => C_LEVEL_PROCEDURE
67709 ,p_module => l_log_module);
67710 END IF;
67711 --
67712 EXCEPTION
67713 WHEN xla_exceptions_pkg.application_exception THEN
67714 RAISE;
67715 WHEN OTHERS THEN
67716 xla_exceptions_pkg.raise_message
67717 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_143');
67718 END AcctLineType_143;
67719 --
67720
67721 ---------------------------------------
67722 --
67723 -- PRIVATE FUNCTION
67724 -- AcctLineType_144
67725 --
67726 ---------------------------------------
67727 PROCEDURE AcctLineType_144 (
67728 p_application_id IN NUMBER
67729 ,p_event_id IN NUMBER
67730 ,p_calculate_acctd_flag IN VARCHAR2
67731 ,p_calculate_g_l_flag IN VARCHAR2
67732 ,p_actual_flag IN OUT VARCHAR2
67733 ,p_balance_type_code OUT VARCHAR2
67734 ,p_gain_or_loss_ref OUT VARCHAR2
67735
67736 --TRANSACTION_ID
67737 , p_source_1 IN NUMBER
67738 --Item Concatenated Segments
67739 , p_source_2 IN VARCHAR2
67740 --Transaction Quantity
67741 , p_source_3 IN NUMBER
67742 --Transaction Unit of Measure Code
67743 , p_source_4 IN VARCHAR2
67744 --Inventory Transaction Type Description
67745 , p_source_5 IN VARCHAR2
67746 --Transaction Transportation Distribution Account
67747 , p_source_32 IN NUMBER
67748 --DISTRIBUTION_IDENTIFIER
67749 , p_source_84 IN NUMBER
67750 --Distribution Type
67751 , p_source_85 IN VARCHAR2
67752 , p_source_85_meaning IN VARCHAR2
67753 --Entered Currency Code
67754 , p_source_88 IN VARCHAR2
67755 --Entered Amount
67756 , p_source_91 IN NUMBER
67757 --Currency Conversion Date
67758 , p_source_92 IN DATE
67759 --Currency Conversion Rate
67760 , p_source_93 IN NUMBER
67761 --Currency Conversion Type
67762 , p_source_94 IN VARCHAR2
67763 --Accounted Amount
67764 , p_source_95 IN NUMBER
67765 --Accounting Line Type
67766 , p_source_97 IN NUMBER
67767 )
67768 IS
67769
67770 l_component_type VARCHAR2(80);
67771 l_component_code VARCHAR2(30);
67772 l_component_type_code VARCHAR2(1);
67773 l_component_appl_id INTEGER;
67774 l_amb_context_code VARCHAR2(30);
67775 l_entity_code VARCHAR2(30);
67776 l_event_class_code VARCHAR2(30);
67777 l_ae_header_id NUMBER;
67778 l_event_type_code VARCHAR2(30);
67779 l_line_definition_code VARCHAR2(30);
67780 l_line_definition_owner_code VARCHAR2(1);
67781 --
67782 -- adr variables
67783 l_segment VARCHAR2(30);
67784 l_ccid NUMBER;
67785 l_adr_transaction_coa_id NUMBER;
67786 l_adr_accounting_coa_id NUMBER;
67787 l_adr_flexfield_segment_code VARCHAR2(30);
67788 l_adr_flex_value_set_id NUMBER;
67789 l_adr_value_type_code VARCHAR2(30);
67790 l_adr_value_combination_id NUMBER;
67791 l_adr_value_segment_code VARCHAR2(30);
67792
67793 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
67794 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
67795 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
67796 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
67797
67798 -- 4262811 Variables ------------------------------------------------------------------------------------------
67799 l_entered_amt_idx NUMBER;
67800 l_accted_amt_idx NUMBER;
67801 l_acc_rev_flag VARCHAR2(1);
67802 l_accrual_line_num NUMBER;
67803 l_tmp_amt NUMBER;
67804 l_acc_rev_natural_side_code VARCHAR2(1);
67805
67806 l_num_entries NUMBER;
67807 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
67808 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
67809 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
67810 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
67811 l_recog_line_1 NUMBER;
67812 l_recog_line_2 NUMBER;
67813
67814 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
67815 l_bflow_applied_to_amt NUMBER; -- 5132302
67816 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
67817
67818 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
67819
67820 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
67821 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
67822
67823 ---------------------------------------------------------------------------------------------------------------
67824
67825
67826 --
67827 -- bulk performance
67828 --
67829 l_balance_type_code VARCHAR2(1);
67830 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
67831 l_log_module VARCHAR2(240);
67832
67833 --
67834 -- Upgrade strategy
67835 --
67836 l_actual_upg_option VARCHAR2(1);
67837 l_enc_upg_option VARCHAR2(1);
67838
67839 --
67840 BEGIN
67841 --
67842 IF g_log_enabled THEN
67843 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_144';
67844 END IF;
67845 --
67846 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67847
67848 trace
67849 (p_msg => 'BEGIN of AcctLineType_144'
67850 ,p_level => C_LEVEL_PROCEDURE
67851 ,p_module => l_log_module);
67852
67853 END IF;
67854 --
67855 l_component_type := 'AMB_JLT';
67856 l_component_code := 'INTERORG_FREIGHT_CHARGE';
67857 l_component_type_code := 'S';
67858 l_component_appl_id := 707;
67859 l_amb_context_code := 'DEFAULT';
67860 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
67861 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
67862 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
67863 l_line_definition_owner_code := 'S';
67864 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
67865 --
67866 l_balance_type_code := 'A';
67867 l_segment := NULL;
67868 l_ccid := NULL;
67869 l_adr_transaction_coa_id := NULL;
67870 l_adr_accounting_coa_id := NULL;
67871 l_adr_flexfield_segment_code := NULL;
67872 l_adr_flex_value_set_id := NULL;
67873 l_adr_value_type_code := NULL;
67874 l_adr_value_combination_id := NULL;
67875 l_adr_value_segment_code := NULL;
67876
67877 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
67878 l_bflow_class_code := ''; -- 4219869 Business Flow
67879 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
67880 l_budgetary_control_flag := 'N';
67881
67882 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67883 l_bflow_applied_to_amt := NULL; -- 5132302
67884 l_entered_amt_idx := NULL; -- 4262811
67885 l_accted_amt_idx := NULL; -- 4262811
67886 l_acc_rev_flag := NULL; -- 4262811
67887 l_accrual_line_num := NULL; -- 4262811
67888 l_tmp_amt := NULL; -- 4262811
67889 --
67890
67891 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
67892 l_balance_type_code <> 'B' THEN
67893 IF NVL(p_source_97,9E125) = 12
67894 THEN
67895
67896 --
67897 XLA_AE_LINES_PKG.SetNewLine;
67898
67899 p_balance_type_code := l_balance_type_code;
67900 -- set the flag so later we will know whether the gain loss line needs to be created
67901
67902 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
67903 p_actual_flag :='A';
67904 END IF;
67905
67906 --
67907 -- bulk performance
67908 --
67909 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
67910 p_header_num => 0); -- 4262811
67911 --
67912 -- set accounting line options
67913 --
67914 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
67915 p_natural_side_code => 'D'
67916 , p_gain_or_loss_flag => 'N'
67917 , p_gl_transfer_mode_code => 'S'
67918 , p_acct_entry_type_code => 'A'
67919 , p_switch_side_flag => 'Y'
67920 , p_merge_duplicate_code => 'N'
67921 );
67922 --
67923 l_acc_rev_natural_side_code := 'C'; -- 4262811
67924 --
67925 --
67926 -- set accounting line type info
67927 --
67928 xla_ae_lines_pkg.SetAcctLineType
67929 (p_component_type => l_component_type
67930 ,p_event_type_code => l_event_type_code
67931 ,p_line_definition_owner_code => l_line_definition_owner_code
67932 ,p_line_definition_code => l_line_definition_code
67933 ,p_accounting_line_code => l_component_code
67934 ,p_accounting_line_type_code => l_component_type_code
67935 ,p_accounting_line_appl_id => l_component_appl_id
67936 ,p_amb_context_code => l_amb_context_code
67937 ,p_entity_code => l_entity_code
67938 ,p_event_class_code => l_event_class_code);
67939 --
67940 -- set accounting class
67941 --
67942 xla_ae_lines_pkg.SetAcctClass(
67943 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
67944 , p_ae_header_id => l_ae_header_id
67945 );
67946
67947 --
67948 -- set rounding class
67949 --
67950 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
67951 'INTERORG_FREIGHT_CHARGE';
67952
67953 --
67954 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
67955 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
67956 --
67957 -- bulk performance
67958 --
67959 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
67960
67961 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
67962 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
67963
67964 -- 4955764
67965 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
67966 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
67967
67968 -- 4458381 Public Sector Enh
67969
67970 --
67971 -- set accounting attributes for the line type
67972 --
67973 l_entered_amt_idx := 3;
67974 l_accted_amt_idx := 8;
67975 l_bflow_applied_to_amt_idx := NULL; -- 5132302
67976 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
67977 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
67978 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
67979 l_rec_acct_attrs.array_char_value(2) := p_source_85;
67980 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
67981 l_rec_acct_attrs.array_num_value(3) := p_source_91;
67982 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
67983 l_rec_acct_attrs.array_char_value(4) := p_source_88;
67984 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
67985 l_rec_acct_attrs.array_date_value(5) := p_source_92;
67986 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
67987 l_rec_acct_attrs.array_num_value(6) := p_source_93;
67988 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
67989 l_rec_acct_attrs.array_char_value(7) := p_source_94;
67990 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
67991 l_rec_acct_attrs.array_num_value(8) := p_source_95;
67992
67993 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
67994 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
67995
67996 ---------------------------------------------------------------------------------------------------------------
67997 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
67998 ---------------------------------------------------------------------------------------------------------------
67999 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
68000
68001 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
68002 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
68003
68004 IF xla_accounting_cache_pkg.GetValueChar
68005 (p_source_code => 'LEDGER_CATEGORY_CODE'
68006 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
68007 AND l_bflow_method_code = 'PRIOR_ENTRY'
68008 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
68009 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
68010 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
68011 )
68012 THEN
68013 xla_ae_lines_pkg.BflowUpgEntry
68014 (p_business_method_code => l_bflow_method_code
68015 ,p_business_class_code => l_bflow_class_code
68016 ,p_balance_type => l_balance_type_code);
68017 ELSE
68018 NULL;
68019 -- No business flow processing for business flow method of NONE.
68020 END IF;
68021
68022 --
68023 -- call analytical criteria
68024 --
68025
68026 --
68027 -- call description
68028 --
68029
68030 xla_ae_lines_pkg.SetLineDescription(
68031 p_ae_header_id => l_ae_header_id
68032 ,p_description => Description_1 (
68033 p_application_id => p_application_id
68034 , p_ae_header_id => l_ae_header_id
68035 , p_source_1 => p_source_1
68036 , p_source_2 => p_source_2
68037 , p_source_3 => p_source_3
68038 , p_source_4 => p_source_4
68039 , p_source_5 => p_source_5
68040 )
68041 );
68042
68043
68044 --
68045 -- call ADRs
68046 -- Bug 4922099
68047 --
68048 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
68049 (NVL(l_actual_upg_option, 'N') = 'O') OR
68050 (NVL(l_enc_upg_option, 'N') = 'O')
68051 )
68052 THEN
68053 NULL;
68054 --
68055 --
68056
68057 l_ccid := AcctDerRule_17(
68058 p_application_id => p_application_id
68059 , p_ae_header_id => l_ae_header_id
68060 , p_source_32 => p_source_32
68061 , x_transaction_coa_id => l_adr_transaction_coa_id
68062 , x_accounting_coa_id => l_adr_accounting_coa_id
68063 , x_value_type_code => l_adr_value_type_code
68064 , p_side => 'NA'
68065 );
68066
68067 xla_ae_lines_pkg.set_ccid(
68068 p_code_combination_id => l_ccid
68069 , p_value_type_code => l_adr_value_type_code
68070 , p_transaction_coa_id => l_adr_transaction_coa_id
68071 , p_accounting_coa_id => l_adr_accounting_coa_id
68072 , p_adr_code => 'PI_FREIGHT'
68073 , p_adr_type_code => 'S'
68074 , p_component_type => l_component_type
68075 , p_component_code => l_component_code
68076 , p_component_type_code => l_component_type_code
68077 , p_component_appl_id => l_component_appl_id
68078 , p_amb_context_code => l_amb_context_code
68079 , p_side => 'NA'
68080 );
68081
68082
68083 --
68084 --
68085 END IF;
68086 --
68087 -- Bug 4922099
68088 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
68089 (NVL(l_enc_upg_option, 'N') = 'O')
68090 ) AND
68091 (l_bflow_method_code = 'PRIOR_ENTRY')
68092 )
68093 THEN
68094 IF
68095 --
68096 1 = 2
68097 --
68098 THEN
68099 xla_accounting_err_pkg.build_message
68100 (p_appli_s_name => 'XLA'
68101 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
68102 ,p_token_1 => 'LINE_NUMBER'
68103 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
68104 ,p_token_2 => 'LINE_TYPE_NAME'
68105 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
68106 l_component_type
68107 ,l_component_code
68108 ,l_component_type_code
68109 ,l_component_appl_id
68110 ,l_amb_context_code
68111 ,l_entity_code
68112 ,l_event_class_code
68113 )
68114 ,p_token_3 => 'OWNER'
68115 ,p_value_3 => xla_lookups_pkg.get_meaning(
68116 p_lookup_type => 'XLA_OWNER_TYPE'
68117 ,p_lookup_code => l_component_type_code
68118 )
68119 ,p_token_4 => 'PRODUCT_NAME'
68120 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
68121 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
68122 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
68123 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
68124 ,p_ae_header_id => NULL
68125 );
68126
68127 IF (C_LEVEL_ERROR>= g_log_level) THEN
68128 trace
68129 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
68130 ,p_level => C_LEVEL_ERROR
68131 ,p_module => l_log_module);
68132 END IF;
68133 END IF;
68134 END IF;
68135 --
68136 --
68137 ------------------------------------------------------------------------------------------------
68138 -- 4219869 Business Flow
68139 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
68140 -- Prior Entry. Currently, the following code is always generated.
68141 ------------------------------------------------------------------------------------------------
68142 XLA_AE_LINES_PKG.ValidateCurrentLine;
68143
68144 ------------------------------------------------------------------------------------
68145 -- 4219869 Business Flow
68146 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
68147 ------------------------------------------------------------------------------------
68148 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
68149
68150 ----------------------------------------------------------------------------------
68151 -- 4219869 Business Flow
68152 -- Update journal entry status -- Need to generate this within IF <condition>
68153 ----------------------------------------------------------------------------------
68154 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
68155 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
68156 ,p_balance_type_code => l_balance_type_code
68157 );
68158
68159 -------------------------------------------------------------------------------------------
68160 -- 4262811 - Generate the Accrual Reversal lines
68161 -------------------------------------------------------------------------------------------
68162 BEGIN
68163 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
68164 (g_array_event(p_event_id).array_value_num('header_index'));
68165 IF l_acc_rev_flag IS NULL THEN
68166 l_acc_rev_flag := 'N';
68167 END IF;
68168 EXCEPTION
68169 WHEN OTHERS THEN
68170 l_acc_rev_flag := 'N';
68171 END;
68172 --
68173 IF (l_acc_rev_flag = 'Y') THEN
68174
68175 -- 4645092 ------------------------------------------------------------------------------
68176 -- To allow MPA report to determine if it should generate report process
68177 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
68178 ------------------------------------------------------------------------------------------
68179
68180 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
68181 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
68182 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
68183 -- call ADRs
68184 -- Bug 4922099
68185 --
68186 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
68187 (NVL(l_actual_upg_option, 'N') = 'O') OR
68188 (NVL(l_enc_upg_option, 'N') = 'O')
68189 )
68190 THEN
68191 NULL;
68192 --
68193 --
68194
68195 l_ccid := AcctDerRule_17(
68196 p_application_id => p_application_id
68197 , p_ae_header_id => l_ae_header_id
68198 , p_source_32 => p_source_32
68199 , x_transaction_coa_id => l_adr_transaction_coa_id
68200 , x_accounting_coa_id => l_adr_accounting_coa_id
68201 , x_value_type_code => l_adr_value_type_code
68202 , p_side => 'NA'
68203 );
68204
68205 xla_ae_lines_pkg.set_ccid(
68206 p_code_combination_id => l_ccid
68207 , p_value_type_code => l_adr_value_type_code
68208 , p_transaction_coa_id => l_adr_transaction_coa_id
68209 , p_accounting_coa_id => l_adr_accounting_coa_id
68210 , p_adr_code => 'PI_FREIGHT'
68211 , p_adr_type_code => 'S'
68212 , p_component_type => l_component_type
68213 , p_component_code => l_component_code
68214 , p_component_type_code => l_component_type_code
68215 , p_component_appl_id => l_component_appl_id
68216 , p_amb_context_code => l_amb_context_code
68217 , p_side => 'NA'
68218 );
68219
68220
68221 --
68222 --
68223 END IF;
68224
68225 --
68226 -- Update the line information that should be overwritten
68227 --
68228 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
68229 p_header_num => 1);
68230 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
68231
68232 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
68233
68234 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
68235 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
68236 END IF;
68237
68238 --
68239 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
68240 --
68241 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
68242 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
68243 ELSE
68244 ---------------------------------------------------------------------------------------------------
68245 -- 4262811a Switch Sign
68246 ---------------------------------------------------------------------------------------------------
68247 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
68248 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
68249 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68250 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
68251 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68252 -- 5132302
68253 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
68254 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68255
68256 END IF;
68257
68258 -- 4955764
68259 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
68260 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
68261
68262
68263 XLA_AE_LINES_PKG.ValidateCurrentLine;
68264 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
68265
68266 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
68267 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
68268 ,p_balance_type_code => l_balance_type_code);
68269
68270 END IF;
68271
68272 -----------------------------------------------------------------------------------------
68273 -- 4262811 Multiperiod Accounting
68274 -----------------------------------------------------------------------------------------
68275 -- No MPA option is assigned.
68276
68277
68278 END IF;
68279 END IF;
68280 --
68281
68282 --
68283 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68284 trace
68285 (p_msg => 'END of AcctLineType_144'
68286 ,p_level => C_LEVEL_PROCEDURE
68287 ,p_module => l_log_module);
68288 END IF;
68289 --
68290 EXCEPTION
68291 WHEN xla_exceptions_pkg.application_exception THEN
68292 RAISE;
68293 WHEN OTHERS THEN
68294 xla_exceptions_pkg.raise_message
68295 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_144');
68296 END AcctLineType_144;
68297 --
68298
68299 ---------------------------------------
68300 --
68301 -- PRIVATE FUNCTION
68302 -- AcctLineType_145
68303 --
68304 ---------------------------------------
68305 PROCEDURE AcctLineType_145 (
68306 p_application_id IN NUMBER
68307 ,p_event_id IN NUMBER
68308 ,p_calculate_acctd_flag IN VARCHAR2
68309 ,p_calculate_g_l_flag IN VARCHAR2
68310 ,p_actual_flag IN OUT VARCHAR2
68311 ,p_balance_type_code OUT VARCHAR2
68312 ,p_gain_or_loss_ref OUT VARCHAR2
68313
68314 --TRANSACTION_ID
68315 , p_source_1 IN NUMBER
68316 --Item Concatenated Segments
68317 , p_source_2 IN VARCHAR2
68318 --Transaction Quantity
68319 , p_source_3 IN NUMBER
68320 --Transaction Unit of Measure Code
68321 , p_source_4 IN VARCHAR2
68322 --Inventory Transaction Type Description
68323 , p_source_5 IN VARCHAR2
68324 --Cost Management Default Account
68325 , p_source_11 IN NUMBER
68326 --DISTRIBUTION_IDENTIFIER
68327 , p_source_84 IN NUMBER
68328 --Distribution Type
68329 , p_source_85 IN VARCHAR2
68330 , p_source_85_meaning IN VARCHAR2
68331 --Entered Currency Code
68332 , p_source_88 IN VARCHAR2
68333 --Entered Amount
68334 , p_source_91 IN NUMBER
68335 --Currency Conversion Date
68336 , p_source_92 IN DATE
68337 --Currency Conversion Rate
68338 , p_source_93 IN NUMBER
68339 --Currency Conversion Type
68340 , p_source_94 IN VARCHAR2
68341 --Accounted Amount
68342 , p_source_95 IN NUMBER
68343 --Accounting Line Type
68344 , p_source_97 IN NUMBER
68345 )
68346 IS
68347
68348 l_component_type VARCHAR2(80);
68349 l_component_code VARCHAR2(30);
68350 l_component_type_code VARCHAR2(1);
68351 l_component_appl_id INTEGER;
68352 l_amb_context_code VARCHAR2(30);
68353 l_entity_code VARCHAR2(30);
68354 l_event_class_code VARCHAR2(30);
68355 l_ae_header_id NUMBER;
68356 l_event_type_code VARCHAR2(30);
68357 l_line_definition_code VARCHAR2(30);
68358 l_line_definition_owner_code VARCHAR2(1);
68359 --
68360 -- adr variables
68361 l_segment VARCHAR2(30);
68362 l_ccid NUMBER;
68363 l_adr_transaction_coa_id NUMBER;
68364 l_adr_accounting_coa_id NUMBER;
68365 l_adr_flexfield_segment_code VARCHAR2(30);
68366 l_adr_flex_value_set_id NUMBER;
68367 l_adr_value_type_code VARCHAR2(30);
68368 l_adr_value_combination_id NUMBER;
68369 l_adr_value_segment_code VARCHAR2(30);
68370
68371 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
68372 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
68373 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
68374 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
68375
68376 -- 4262811 Variables ------------------------------------------------------------------------------------------
68377 l_entered_amt_idx NUMBER;
68378 l_accted_amt_idx NUMBER;
68379 l_acc_rev_flag VARCHAR2(1);
68380 l_accrual_line_num NUMBER;
68381 l_tmp_amt NUMBER;
68382 l_acc_rev_natural_side_code VARCHAR2(1);
68383
68384 l_num_entries NUMBER;
68385 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
68386 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
68387 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
68388 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
68389 l_recog_line_1 NUMBER;
68390 l_recog_line_2 NUMBER;
68391
68392 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
68393 l_bflow_applied_to_amt NUMBER; -- 5132302
68394 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
68395
68396 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
68397
68398 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
68399 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
68400
68401 ---------------------------------------------------------------------------------------------------------------
68402
68403
68404 --
68405 -- bulk performance
68406 --
68407 l_balance_type_code VARCHAR2(1);
68408 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
68409 l_log_module VARCHAR2(240);
68410
68411 --
68412 -- Upgrade strategy
68413 --
68414 l_actual_upg_option VARCHAR2(1);
68415 l_enc_upg_option VARCHAR2(1);
68416
68417 --
68418 BEGIN
68419 --
68420 IF g_log_enabled THEN
68421 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_145';
68422 END IF;
68423 --
68424 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68425
68426 trace
68427 (p_msg => 'BEGIN of AcctLineType_145'
68428 ,p_level => C_LEVEL_PROCEDURE
68429 ,p_module => l_log_module);
68430
68431 END IF;
68432 --
68433 l_component_type := 'AMB_JLT';
68434 l_component_code := 'INTERORG_FREIGHT_CHARGE';
68435 l_component_type_code := 'S';
68436 l_component_appl_id := 707;
68437 l_amb_context_code := 'DEFAULT';
68438 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
68439 l_event_class_code := 'USER_DEFINE';
68440 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
68441 l_line_definition_owner_code := 'S';
68442 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
68443 --
68444 l_balance_type_code := 'A';
68445 l_segment := NULL;
68446 l_ccid := NULL;
68447 l_adr_transaction_coa_id := NULL;
68448 l_adr_accounting_coa_id := NULL;
68449 l_adr_flexfield_segment_code := NULL;
68450 l_adr_flex_value_set_id := NULL;
68451 l_adr_value_type_code := NULL;
68452 l_adr_value_combination_id := NULL;
68453 l_adr_value_segment_code := NULL;
68454
68455 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
68456 l_bflow_class_code := ''; -- 4219869 Business Flow
68457 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
68458 l_budgetary_control_flag := 'N';
68459
68460 l_bflow_applied_to_amt_idx := NULL; -- 5132302
68461 l_bflow_applied_to_amt := NULL; -- 5132302
68462 l_entered_amt_idx := NULL; -- 4262811
68463 l_accted_amt_idx := NULL; -- 4262811
68464 l_acc_rev_flag := NULL; -- 4262811
68465 l_accrual_line_num := NULL; -- 4262811
68466 l_tmp_amt := NULL; -- 4262811
68467 --
68468
68469 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
68470 l_balance_type_code <> 'B' THEN
68471 IF NVL(p_source_97,9E125) = 12
68472 THEN
68473
68474 --
68475 XLA_AE_LINES_PKG.SetNewLine;
68476
68477 p_balance_type_code := l_balance_type_code;
68478 -- set the flag so later we will know whether the gain loss line needs to be created
68479
68480 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
68481 p_actual_flag :='A';
68482 END IF;
68483
68484 --
68485 -- bulk performance
68486 --
68487 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
68488 p_header_num => 0); -- 4262811
68489 --
68490 -- set accounting line options
68491 --
68492 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
68493 p_natural_side_code => 'D'
68494 , p_gain_or_loss_flag => 'N'
68495 , p_gl_transfer_mode_code => 'S'
68496 , p_acct_entry_type_code => 'A'
68497 , p_switch_side_flag => 'Y'
68498 , p_merge_duplicate_code => 'N'
68499 );
68500 --
68501 l_acc_rev_natural_side_code := 'C'; -- 4262811
68502 --
68503 --
68504 -- set accounting line type info
68505 --
68506 xla_ae_lines_pkg.SetAcctLineType
68507 (p_component_type => l_component_type
68508 ,p_event_type_code => l_event_type_code
68509 ,p_line_definition_owner_code => l_line_definition_owner_code
68510 ,p_line_definition_code => l_line_definition_code
68511 ,p_accounting_line_code => l_component_code
68512 ,p_accounting_line_type_code => l_component_type_code
68513 ,p_accounting_line_appl_id => l_component_appl_id
68514 ,p_amb_context_code => l_amb_context_code
68515 ,p_entity_code => l_entity_code
68516 ,p_event_class_code => l_event_class_code);
68517 --
68518 -- set accounting class
68519 --
68520 xla_ae_lines_pkg.SetAcctClass(
68521 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
68522 , p_ae_header_id => l_ae_header_id
68523 );
68524
68525 --
68526 -- set rounding class
68527 --
68528 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
68529 'INTERORG_FREIGHT_CHARGE';
68530
68531 --
68532 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
68533 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
68534 --
68535 -- bulk performance
68536 --
68537 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
68538
68539 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
68540 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
68541
68542 -- 4955764
68543 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
68544 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
68545
68546 -- 4458381 Public Sector Enh
68547
68548 --
68549 -- set accounting attributes for the line type
68550 --
68551 l_entered_amt_idx := 3;
68552 l_accted_amt_idx := 8;
68553 l_bflow_applied_to_amt_idx := NULL; -- 5132302
68554 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
68555 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
68556 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
68557 l_rec_acct_attrs.array_char_value(2) := p_source_85;
68558 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
68559 l_rec_acct_attrs.array_num_value(3) := p_source_91;
68560 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
68561 l_rec_acct_attrs.array_char_value(4) := p_source_88;
68562 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
68563 l_rec_acct_attrs.array_date_value(5) := p_source_92;
68564 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
68565 l_rec_acct_attrs.array_num_value(6) := p_source_93;
68566 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
68567 l_rec_acct_attrs.array_char_value(7) := p_source_94;
68568 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
68569 l_rec_acct_attrs.array_num_value(8) := p_source_95;
68570
68571 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
68572 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
68573
68574 ---------------------------------------------------------------------------------------------------------------
68575 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
68576 ---------------------------------------------------------------------------------------------------------------
68577 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
68578
68579 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
68580 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
68581
68582 IF xla_accounting_cache_pkg.GetValueChar
68583 (p_source_code => 'LEDGER_CATEGORY_CODE'
68584 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
68585 AND l_bflow_method_code = 'PRIOR_ENTRY'
68586 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
68587 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
68588 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
68589 )
68590 THEN
68591 xla_ae_lines_pkg.BflowUpgEntry
68592 (p_business_method_code => l_bflow_method_code
68593 ,p_business_class_code => l_bflow_class_code
68594 ,p_balance_type => l_balance_type_code);
68595 ELSE
68596 NULL;
68597 -- No business flow processing for business flow method of NONE.
68598 END IF;
68599
68600 --
68601 -- call analytical criteria
68602 --
68603
68604 --
68605 -- call description
68606 --
68607
68608 xla_ae_lines_pkg.SetLineDescription(
68609 p_ae_header_id => l_ae_header_id
68610 ,p_description => Description_1 (
68611 p_application_id => p_application_id
68612 , p_ae_header_id => l_ae_header_id
68613 , p_source_1 => p_source_1
68614 , p_source_2 => p_source_2
68615 , p_source_3 => p_source_3
68616 , p_source_4 => p_source_4
68617 , p_source_5 => p_source_5
68618 )
68619 );
68620
68621
68622 --
68623 -- call ADRs
68624 -- Bug 4922099
68625 --
68626 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
68627 (NVL(l_actual_upg_option, 'N') = 'O') OR
68628 (NVL(l_enc_upg_option, 'N') = 'O')
68629 )
68630 THEN
68631 NULL;
68632 --
68633 --
68634
68635 l_ccid := AcctDerRule_6(
68636 p_application_id => p_application_id
68637 , p_ae_header_id => l_ae_header_id
68638 , p_source_11 => p_source_11
68639 , x_transaction_coa_id => l_adr_transaction_coa_id
68640 , x_accounting_coa_id => l_adr_accounting_coa_id
68641 , x_value_type_code => l_adr_value_type_code
68642 , p_side => 'NA'
68643 );
68644
68645 xla_ae_lines_pkg.set_ccid(
68646 p_code_combination_id => l_ccid
68647 , p_value_type_code => l_adr_value_type_code
68648 , p_transaction_coa_id => l_adr_transaction_coa_id
68649 , p_accounting_coa_id => l_adr_accounting_coa_id
68650 , p_adr_code => 'CST_DEFAULT'
68651 , p_adr_type_code => 'S'
68652 , p_component_type => l_component_type
68653 , p_component_code => l_component_code
68654 , p_component_type_code => l_component_type_code
68655 , p_component_appl_id => l_component_appl_id
68656 , p_amb_context_code => l_amb_context_code
68657 , p_side => 'NA'
68658 );
68659
68660
68661 --
68662 --
68663 END IF;
68664 --
68665 -- Bug 4922099
68666 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
68667 (NVL(l_enc_upg_option, 'N') = 'O')
68668 ) AND
68669 (l_bflow_method_code = 'PRIOR_ENTRY')
68670 )
68671 THEN
68672 IF
68673 --
68674 1 = 2
68675 --
68676 THEN
68677 xla_accounting_err_pkg.build_message
68678 (p_appli_s_name => 'XLA'
68679 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
68680 ,p_token_1 => 'LINE_NUMBER'
68681 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
68682 ,p_token_2 => 'LINE_TYPE_NAME'
68683 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
68684 l_component_type
68685 ,l_component_code
68686 ,l_component_type_code
68687 ,l_component_appl_id
68688 ,l_amb_context_code
68689 ,l_entity_code
68690 ,l_event_class_code
68691 )
68692 ,p_token_3 => 'OWNER'
68693 ,p_value_3 => xla_lookups_pkg.get_meaning(
68694 p_lookup_type => 'XLA_OWNER_TYPE'
68695 ,p_lookup_code => l_component_type_code
68696 )
68697 ,p_token_4 => 'PRODUCT_NAME'
68698 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
68699 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
68700 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
68701 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
68702 ,p_ae_header_id => NULL
68703 );
68704
68705 IF (C_LEVEL_ERROR>= g_log_level) THEN
68706 trace
68707 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
68708 ,p_level => C_LEVEL_ERROR
68709 ,p_module => l_log_module);
68710 END IF;
68711 END IF;
68712 END IF;
68713 --
68714 --
68715 ------------------------------------------------------------------------------------------------
68716 -- 4219869 Business Flow
68717 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
68718 -- Prior Entry. Currently, the following code is always generated.
68719 ------------------------------------------------------------------------------------------------
68720 XLA_AE_LINES_PKG.ValidateCurrentLine;
68721
68722 ------------------------------------------------------------------------------------
68723 -- 4219869 Business Flow
68724 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
68725 ------------------------------------------------------------------------------------
68726 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
68727
68728 ----------------------------------------------------------------------------------
68729 -- 4219869 Business Flow
68730 -- Update journal entry status -- Need to generate this within IF <condition>
68731 ----------------------------------------------------------------------------------
68732 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
68733 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
68734 ,p_balance_type_code => l_balance_type_code
68735 );
68736
68737 -------------------------------------------------------------------------------------------
68738 -- 4262811 - Generate the Accrual Reversal lines
68739 -------------------------------------------------------------------------------------------
68740 BEGIN
68741 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
68742 (g_array_event(p_event_id).array_value_num('header_index'));
68743 IF l_acc_rev_flag IS NULL THEN
68744 l_acc_rev_flag := 'N';
68745 END IF;
68746 EXCEPTION
68747 WHEN OTHERS THEN
68748 l_acc_rev_flag := 'N';
68749 END;
68750 --
68751 IF (l_acc_rev_flag = 'Y') THEN
68752
68753 -- 4645092 ------------------------------------------------------------------------------
68754 -- To allow MPA report to determine if it should generate report process
68755 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
68756 ------------------------------------------------------------------------------------------
68757
68758 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
68759 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
68760 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
68761 -- call ADRs
68762 -- Bug 4922099
68763 --
68764 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
68765 (NVL(l_actual_upg_option, 'N') = 'O') OR
68766 (NVL(l_enc_upg_option, 'N') = 'O')
68767 )
68768 THEN
68769 NULL;
68770 --
68771 --
68772
68773 l_ccid := AcctDerRule_6(
68774 p_application_id => p_application_id
68775 , p_ae_header_id => l_ae_header_id
68776 , p_source_11 => p_source_11
68777 , x_transaction_coa_id => l_adr_transaction_coa_id
68778 , x_accounting_coa_id => l_adr_accounting_coa_id
68779 , x_value_type_code => l_adr_value_type_code
68780 , p_side => 'NA'
68781 );
68782
68783 xla_ae_lines_pkg.set_ccid(
68784 p_code_combination_id => l_ccid
68785 , p_value_type_code => l_adr_value_type_code
68786 , p_transaction_coa_id => l_adr_transaction_coa_id
68787 , p_accounting_coa_id => l_adr_accounting_coa_id
68788 , p_adr_code => 'CST_DEFAULT'
68789 , p_adr_type_code => 'S'
68790 , p_component_type => l_component_type
68791 , p_component_code => l_component_code
68792 , p_component_type_code => l_component_type_code
68793 , p_component_appl_id => l_component_appl_id
68794 , p_amb_context_code => l_amb_context_code
68795 , p_side => 'NA'
68796 );
68797
68798
68799 --
68800 --
68801 END IF;
68802
68803 --
68804 -- Update the line information that should be overwritten
68805 --
68806 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
68807 p_header_num => 1);
68808 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
68809
68810 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
68811
68812 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
68813 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
68814 END IF;
68815
68816 --
68817 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
68818 --
68819 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
68820 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
68821 ELSE
68822 ---------------------------------------------------------------------------------------------------
68823 -- 4262811a Switch Sign
68824 ---------------------------------------------------------------------------------------------------
68825 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
68826 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
68827 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68828 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
68829 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68830 -- 5132302
68831 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
68832 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
68833
68834 END IF;
68835
68836 -- 4955764
68837 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
68838 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
68839
68840
68841 XLA_AE_LINES_PKG.ValidateCurrentLine;
68842 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
68843
68844 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
68845 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
68846 ,p_balance_type_code => l_balance_type_code);
68847
68848 END IF;
68849
68850 -----------------------------------------------------------------------------------------
68851 -- 4262811 Multiperiod Accounting
68852 -----------------------------------------------------------------------------------------
68853 -- No MPA option is assigned.
68854
68855
68856 END IF;
68857 END IF;
68858 --
68859
68860 --
68861 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68862 trace
68863 (p_msg => 'END of AcctLineType_145'
68864 ,p_level => C_LEVEL_PROCEDURE
68865 ,p_module => l_log_module);
68866 END IF;
68867 --
68868 EXCEPTION
68869 WHEN xla_exceptions_pkg.application_exception THEN
68870 RAISE;
68871 WHEN OTHERS THEN
68872 xla_exceptions_pkg.raise_message
68873 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_145');
68874 END AcctLineType_145;
68875 --
68876
68877 ---------------------------------------
68878 --
68879 -- PRIVATE FUNCTION
68880 -- AcctLineType_146
68881 --
68882 ---------------------------------------
68883 PROCEDURE AcctLineType_146 (
68884 p_application_id IN NUMBER
68885 ,p_event_id IN NUMBER
68886 ,p_calculate_acctd_flag IN VARCHAR2
68887 ,p_calculate_g_l_flag IN VARCHAR2
68888 ,p_actual_flag IN OUT VARCHAR2
68889 ,p_balance_type_code OUT VARCHAR2
68890 ,p_gain_or_loss_ref OUT VARCHAR2
68891
68892 --TRANSACTION_ID
68893 , p_source_1 IN NUMBER
68894 --Item Concatenated Segments
68895 , p_source_2 IN VARCHAR2
68896 --Transaction Quantity
68897 , p_source_3 IN NUMBER
68898 --Transaction Unit of Measure Code
68899 , p_source_4 IN VARCHAR2
68900 --Inventory Transaction Type Description
68901 , p_source_5 IN VARCHAR2
68902 --Cost Management Default Account
68903 , p_source_11 IN NUMBER
68904 --DISTRIBUTION_IDENTIFIER
68905 , p_source_84 IN NUMBER
68906 --Distribution Type
68907 , p_source_85 IN VARCHAR2
68908 , p_source_85_meaning IN VARCHAR2
68909 --Entered Currency Code
68910 , p_source_88 IN VARCHAR2
68911 --Entered Amount
68912 , p_source_91 IN NUMBER
68913 --Currency Conversion Date
68914 , p_source_92 IN DATE
68915 --Currency Conversion Rate
68916 , p_source_93 IN NUMBER
68917 --Currency Conversion Type
68918 , p_source_94 IN VARCHAR2
68919 --Accounted Amount
68920 , p_source_95 IN NUMBER
68921 --Accounting Line Type
68922 , p_source_97 IN NUMBER
68923 )
68924 IS
68925
68926 l_component_type VARCHAR2(80);
68927 l_component_code VARCHAR2(30);
68928 l_component_type_code VARCHAR2(1);
68929 l_component_appl_id INTEGER;
68930 l_amb_context_code VARCHAR2(30);
68931 l_entity_code VARCHAR2(30);
68932 l_event_class_code VARCHAR2(30);
68933 l_ae_header_id NUMBER;
68934 l_event_type_code VARCHAR2(30);
68935 l_line_definition_code VARCHAR2(30);
68936 l_line_definition_owner_code VARCHAR2(1);
68937 --
68938 -- adr variables
68939 l_segment VARCHAR2(30);
68940 l_ccid NUMBER;
68941 l_adr_transaction_coa_id NUMBER;
68942 l_adr_accounting_coa_id NUMBER;
68943 l_adr_flexfield_segment_code VARCHAR2(30);
68944 l_adr_flex_value_set_id NUMBER;
68945 l_adr_value_type_code VARCHAR2(30);
68946 l_adr_value_combination_id NUMBER;
68947 l_adr_value_segment_code VARCHAR2(30);
68948
68949 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
68950 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
68951 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
68952 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
68953
68954 -- 4262811 Variables ------------------------------------------------------------------------------------------
68955 l_entered_amt_idx NUMBER;
68956 l_accted_amt_idx NUMBER;
68957 l_acc_rev_flag VARCHAR2(1);
68958 l_accrual_line_num NUMBER;
68959 l_tmp_amt NUMBER;
68960 l_acc_rev_natural_side_code VARCHAR2(1);
68961
68962 l_num_entries NUMBER;
68963 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
68964 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
68965 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
68966 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
68967 l_recog_line_1 NUMBER;
68968 l_recog_line_2 NUMBER;
68969
68970 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
68971 l_bflow_applied_to_amt NUMBER; -- 5132302
68972 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
68973
68974 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
68975
68976 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
68977 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
68978
68979 ---------------------------------------------------------------------------------------------------------------
68980
68981
68982 --
68983 -- bulk performance
68984 --
68985 l_balance_type_code VARCHAR2(1);
68986 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
68987 l_log_module VARCHAR2(240);
68988
68989 --
68990 -- Upgrade strategy
68991 --
68992 l_actual_upg_option VARCHAR2(1);
68993 l_enc_upg_option VARCHAR2(1);
68994
68995 --
68996 BEGIN
68997 --
68998 IF g_log_enabled THEN
68999 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_146';
69000 END IF;
69001 --
69002 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69003
69004 trace
69005 (p_msg => 'BEGIN of AcctLineType_146'
69006 ,p_level => C_LEVEL_PROCEDURE
69007 ,p_module => l_log_module);
69008
69009 END IF;
69010 --
69011 l_component_type := 'AMB_JLT';
69012 l_component_code := 'INTERORG_FREIGHT_CHARGE';
69013 l_component_type_code := 'S';
69014 l_component_appl_id := 707;
69015 l_amb_context_code := 'DEFAULT';
69016 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
69017 l_event_class_code := 'USER_DEFINE';
69018 l_event_type_code := 'UDIR_INTERORG_RCPT';
69019 l_line_definition_owner_code := 'S';
69020 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
69021 --
69022 l_balance_type_code := 'A';
69023 l_segment := NULL;
69024 l_ccid := NULL;
69025 l_adr_transaction_coa_id := NULL;
69026 l_adr_accounting_coa_id := NULL;
69027 l_adr_flexfield_segment_code := NULL;
69028 l_adr_flex_value_set_id := NULL;
69029 l_adr_value_type_code := NULL;
69030 l_adr_value_combination_id := NULL;
69031 l_adr_value_segment_code := NULL;
69032
69033 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
69034 l_bflow_class_code := ''; -- 4219869 Business Flow
69035 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
69036 l_budgetary_control_flag := 'N';
69037
69038 l_bflow_applied_to_amt_idx := NULL; -- 5132302
69039 l_bflow_applied_to_amt := NULL; -- 5132302
69040 l_entered_amt_idx := NULL; -- 4262811
69041 l_accted_amt_idx := NULL; -- 4262811
69042 l_acc_rev_flag := NULL; -- 4262811
69043 l_accrual_line_num := NULL; -- 4262811
69044 l_tmp_amt := NULL; -- 4262811
69045 --
69046
69047 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
69048 l_balance_type_code <> 'B' THEN
69049 IF NVL(p_source_97,9E125) = 12
69050 THEN
69051
69052 --
69053 XLA_AE_LINES_PKG.SetNewLine;
69054
69055 p_balance_type_code := l_balance_type_code;
69056 -- set the flag so later we will know whether the gain loss line needs to be created
69057
69058 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
69059 p_actual_flag :='A';
69060 END IF;
69061
69062 --
69063 -- bulk performance
69064 --
69065 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
69066 p_header_num => 0); -- 4262811
69067 --
69068 -- set accounting line options
69069 --
69070 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
69071 p_natural_side_code => 'D'
69072 , p_gain_or_loss_flag => 'N'
69073 , p_gl_transfer_mode_code => 'S'
69074 , p_acct_entry_type_code => 'A'
69075 , p_switch_side_flag => 'Y'
69076 , p_merge_duplicate_code => 'N'
69077 );
69078 --
69079 l_acc_rev_natural_side_code := 'C'; -- 4262811
69080 --
69081 --
69082 -- set accounting line type info
69083 --
69084 xla_ae_lines_pkg.SetAcctLineType
69085 (p_component_type => l_component_type
69086 ,p_event_type_code => l_event_type_code
69087 ,p_line_definition_owner_code => l_line_definition_owner_code
69088 ,p_line_definition_code => l_line_definition_code
69089 ,p_accounting_line_code => l_component_code
69090 ,p_accounting_line_type_code => l_component_type_code
69091 ,p_accounting_line_appl_id => l_component_appl_id
69092 ,p_amb_context_code => l_amb_context_code
69093 ,p_entity_code => l_entity_code
69094 ,p_event_class_code => l_event_class_code);
69095 --
69096 -- set accounting class
69097 --
69098 xla_ae_lines_pkg.SetAcctClass(
69099 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
69100 , p_ae_header_id => l_ae_header_id
69101 );
69102
69103 --
69104 -- set rounding class
69105 --
69106 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
69107 'INTERORG_FREIGHT_CHARGE';
69108
69109 --
69110 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
69111 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
69112 --
69113 -- bulk performance
69114 --
69115 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
69116
69117 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
69118 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
69119
69120 -- 4955764
69121 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
69122 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
69123
69124 -- 4458381 Public Sector Enh
69125
69126 --
69127 -- set accounting attributes for the line type
69128 --
69129 l_entered_amt_idx := 3;
69130 l_accted_amt_idx := 8;
69131 l_bflow_applied_to_amt_idx := NULL; -- 5132302
69132 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
69133 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
69134 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
69135 l_rec_acct_attrs.array_char_value(2) := p_source_85;
69136 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
69137 l_rec_acct_attrs.array_num_value(3) := p_source_91;
69138 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
69139 l_rec_acct_attrs.array_char_value(4) := p_source_88;
69140 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
69141 l_rec_acct_attrs.array_date_value(5) := p_source_92;
69142 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
69143 l_rec_acct_attrs.array_num_value(6) := p_source_93;
69144 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
69145 l_rec_acct_attrs.array_char_value(7) := p_source_94;
69146 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
69147 l_rec_acct_attrs.array_num_value(8) := p_source_95;
69148
69149 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
69150 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
69151
69152 ---------------------------------------------------------------------------------------------------------------
69153 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
69154 ---------------------------------------------------------------------------------------------------------------
69155 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
69156
69157 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
69158 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
69159
69160 IF xla_accounting_cache_pkg.GetValueChar
69161 (p_source_code => 'LEDGER_CATEGORY_CODE'
69162 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
69163 AND l_bflow_method_code = 'PRIOR_ENTRY'
69164 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
69165 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
69166 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
69167 )
69168 THEN
69169 xla_ae_lines_pkg.BflowUpgEntry
69170 (p_business_method_code => l_bflow_method_code
69171 ,p_business_class_code => l_bflow_class_code
69172 ,p_balance_type => l_balance_type_code);
69173 ELSE
69174 NULL;
69175 -- No business flow processing for business flow method of NONE.
69176 END IF;
69177
69178 --
69179 -- call analytical criteria
69180 --
69181
69182 --
69183 -- call description
69184 --
69185
69186 xla_ae_lines_pkg.SetLineDescription(
69187 p_ae_header_id => l_ae_header_id
69188 ,p_description => Description_1 (
69189 p_application_id => p_application_id
69190 , p_ae_header_id => l_ae_header_id
69191 , p_source_1 => p_source_1
69192 , p_source_2 => p_source_2
69193 , p_source_3 => p_source_3
69194 , p_source_4 => p_source_4
69195 , p_source_5 => p_source_5
69196 )
69197 );
69198
69199
69200 --
69201 -- call ADRs
69202 -- Bug 4922099
69203 --
69204 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
69205 (NVL(l_actual_upg_option, 'N') = 'O') OR
69206 (NVL(l_enc_upg_option, 'N') = 'O')
69207 )
69208 THEN
69209 NULL;
69210 --
69211 --
69212
69213 l_ccid := AcctDerRule_6(
69214 p_application_id => p_application_id
69215 , p_ae_header_id => l_ae_header_id
69216 , p_source_11 => p_source_11
69217 , x_transaction_coa_id => l_adr_transaction_coa_id
69218 , x_accounting_coa_id => l_adr_accounting_coa_id
69219 , x_value_type_code => l_adr_value_type_code
69220 , p_side => 'NA'
69221 );
69222
69223 xla_ae_lines_pkg.set_ccid(
69224 p_code_combination_id => l_ccid
69225 , p_value_type_code => l_adr_value_type_code
69226 , p_transaction_coa_id => l_adr_transaction_coa_id
69227 , p_accounting_coa_id => l_adr_accounting_coa_id
69228 , p_adr_code => 'CST_DEFAULT'
69229 , p_adr_type_code => 'S'
69230 , p_component_type => l_component_type
69231 , p_component_code => l_component_code
69232 , p_component_type_code => l_component_type_code
69233 , p_component_appl_id => l_component_appl_id
69234 , p_amb_context_code => l_amb_context_code
69235 , p_side => 'NA'
69236 );
69237
69238
69239 --
69240 --
69241 END IF;
69242 --
69243 -- Bug 4922099
69244 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
69245 (NVL(l_enc_upg_option, 'N') = 'O')
69246 ) AND
69247 (l_bflow_method_code = 'PRIOR_ENTRY')
69248 )
69249 THEN
69250 IF
69251 --
69252 1 = 2
69253 --
69254 THEN
69255 xla_accounting_err_pkg.build_message
69256 (p_appli_s_name => 'XLA'
69257 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
69258 ,p_token_1 => 'LINE_NUMBER'
69259 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
69260 ,p_token_2 => 'LINE_TYPE_NAME'
69261 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
69262 l_component_type
69263 ,l_component_code
69264 ,l_component_type_code
69265 ,l_component_appl_id
69266 ,l_amb_context_code
69267 ,l_entity_code
69268 ,l_event_class_code
69269 )
69270 ,p_token_3 => 'OWNER'
69271 ,p_value_3 => xla_lookups_pkg.get_meaning(
69272 p_lookup_type => 'XLA_OWNER_TYPE'
69273 ,p_lookup_code => l_component_type_code
69274 )
69275 ,p_token_4 => 'PRODUCT_NAME'
69276 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
69277 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
69278 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
69279 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
69280 ,p_ae_header_id => NULL
69281 );
69282
69283 IF (C_LEVEL_ERROR>= g_log_level) THEN
69284 trace
69285 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
69286 ,p_level => C_LEVEL_ERROR
69287 ,p_module => l_log_module);
69288 END IF;
69289 END IF;
69290 END IF;
69291 --
69292 --
69293 ------------------------------------------------------------------------------------------------
69294 -- 4219869 Business Flow
69295 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
69296 -- Prior Entry. Currently, the following code is always generated.
69297 ------------------------------------------------------------------------------------------------
69298 XLA_AE_LINES_PKG.ValidateCurrentLine;
69299
69300 ------------------------------------------------------------------------------------
69301 -- 4219869 Business Flow
69302 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
69303 ------------------------------------------------------------------------------------
69304 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
69305
69306 ----------------------------------------------------------------------------------
69307 -- 4219869 Business Flow
69308 -- Update journal entry status -- Need to generate this within IF <condition>
69309 ----------------------------------------------------------------------------------
69310 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
69311 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
69312 ,p_balance_type_code => l_balance_type_code
69313 );
69314
69315 -------------------------------------------------------------------------------------------
69316 -- 4262811 - Generate the Accrual Reversal lines
69317 -------------------------------------------------------------------------------------------
69318 BEGIN
69319 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
69320 (g_array_event(p_event_id).array_value_num('header_index'));
69321 IF l_acc_rev_flag IS NULL THEN
69322 l_acc_rev_flag := 'N';
69323 END IF;
69324 EXCEPTION
69325 WHEN OTHERS THEN
69326 l_acc_rev_flag := 'N';
69327 END;
69328 --
69329 IF (l_acc_rev_flag = 'Y') THEN
69330
69331 -- 4645092 ------------------------------------------------------------------------------
69332 -- To allow MPA report to determine if it should generate report process
69333 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
69334 ------------------------------------------------------------------------------------------
69335
69336 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
69337 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
69338 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
69339 -- call ADRs
69340 -- Bug 4922099
69341 --
69342 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
69343 (NVL(l_actual_upg_option, 'N') = 'O') OR
69344 (NVL(l_enc_upg_option, 'N') = 'O')
69345 )
69346 THEN
69347 NULL;
69348 --
69349 --
69350
69351 l_ccid := AcctDerRule_6(
69352 p_application_id => p_application_id
69353 , p_ae_header_id => l_ae_header_id
69354 , p_source_11 => p_source_11
69355 , x_transaction_coa_id => l_adr_transaction_coa_id
69356 , x_accounting_coa_id => l_adr_accounting_coa_id
69357 , x_value_type_code => l_adr_value_type_code
69358 , p_side => 'NA'
69359 );
69360
69361 xla_ae_lines_pkg.set_ccid(
69362 p_code_combination_id => l_ccid
69363 , p_value_type_code => l_adr_value_type_code
69364 , p_transaction_coa_id => l_adr_transaction_coa_id
69365 , p_accounting_coa_id => l_adr_accounting_coa_id
69366 , p_adr_code => 'CST_DEFAULT'
69367 , p_adr_type_code => 'S'
69368 , p_component_type => l_component_type
69369 , p_component_code => l_component_code
69370 , p_component_type_code => l_component_type_code
69371 , p_component_appl_id => l_component_appl_id
69372 , p_amb_context_code => l_amb_context_code
69373 , p_side => 'NA'
69374 );
69375
69376
69377 --
69378 --
69379 END IF;
69380
69381 --
69382 -- Update the line information that should be overwritten
69383 --
69384 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
69385 p_header_num => 1);
69386 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
69387
69388 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
69389
69390 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
69391 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
69392 END IF;
69393
69394 --
69395 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
69396 --
69397 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
69398 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
69399 ELSE
69400 ---------------------------------------------------------------------------------------------------
69401 -- 4262811a Switch Sign
69402 ---------------------------------------------------------------------------------------------------
69403 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
69404 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
69405 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69406 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
69407 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69408 -- 5132302
69409 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
69410 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69411
69412 END IF;
69413
69414 -- 4955764
69415 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
69416 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
69417
69418
69419 XLA_AE_LINES_PKG.ValidateCurrentLine;
69420 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
69421
69422 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
69423 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
69424 ,p_balance_type_code => l_balance_type_code);
69425
69426 END IF;
69427
69428 -----------------------------------------------------------------------------------------
69429 -- 4262811 Multiperiod Accounting
69430 -----------------------------------------------------------------------------------------
69431 -- No MPA option is assigned.
69432
69433
69434 END IF;
69435 END IF;
69436 --
69437
69438 --
69439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69440 trace
69441 (p_msg => 'END of AcctLineType_146'
69442 ,p_level => C_LEVEL_PROCEDURE
69443 ,p_module => l_log_module);
69444 END IF;
69445 --
69446 EXCEPTION
69447 WHEN xla_exceptions_pkg.application_exception THEN
69448 RAISE;
69449 WHEN OTHERS THEN
69450 xla_exceptions_pkg.raise_message
69451 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_146');
69452 END AcctLineType_146;
69453 --
69454
69455 ---------------------------------------
69456 --
69457 -- PRIVATE FUNCTION
69458 -- AcctLineType_147
69459 --
69460 ---------------------------------------
69461 PROCEDURE AcctLineType_147 (
69462 p_application_id IN NUMBER
69463 ,p_event_id IN NUMBER
69464 ,p_calculate_acctd_flag IN VARCHAR2
69465 ,p_calculate_g_l_flag IN VARCHAR2
69466 ,p_actual_flag IN OUT VARCHAR2
69467 ,p_balance_type_code OUT VARCHAR2
69468 ,p_gain_or_loss_ref OUT VARCHAR2
69469
69470 --TRANSACTION_ID
69471 , p_source_1 IN NUMBER
69472 --Item Concatenated Segments
69473 , p_source_2 IN VARCHAR2
69474 --Transaction Quantity
69475 , p_source_3 IN NUMBER
69476 --Transaction Unit of Measure Code
69477 , p_source_4 IN VARCHAR2
69478 --Inventory Transaction Type Description
69479 , p_source_5 IN VARCHAR2
69480 --Transaction Transportation Distribution Account
69481 , p_source_32 IN NUMBER
69482 --DISTRIBUTION_IDENTIFIER
69483 , p_source_84 IN NUMBER
69484 --Distribution Type
69485 , p_source_85 IN VARCHAR2
69486 , p_source_85_meaning IN VARCHAR2
69487 --Entered Currency Code
69488 , p_source_88 IN VARCHAR2
69489 --Entered Amount
69490 , p_source_91 IN NUMBER
69491 --Currency Conversion Date
69492 , p_source_92 IN DATE
69493 --Currency Conversion Rate
69494 , p_source_93 IN NUMBER
69495 --Currency Conversion Type
69496 , p_source_94 IN VARCHAR2
69497 --Accounted Amount
69498 , p_source_95 IN NUMBER
69499 --Accounting Line Type
69500 , p_source_97 IN NUMBER
69501 )
69502 IS
69503
69504 l_component_type VARCHAR2(80);
69505 l_component_code VARCHAR2(30);
69506 l_component_type_code VARCHAR2(1);
69507 l_component_appl_id INTEGER;
69508 l_amb_context_code VARCHAR2(30);
69509 l_entity_code VARCHAR2(30);
69510 l_event_class_code VARCHAR2(30);
69511 l_ae_header_id NUMBER;
69512 l_event_type_code VARCHAR2(30);
69513 l_line_definition_code VARCHAR2(30);
69514 l_line_definition_owner_code VARCHAR2(1);
69515 --
69516 -- adr variables
69517 l_segment VARCHAR2(30);
69518 l_ccid NUMBER;
69519 l_adr_transaction_coa_id NUMBER;
69520 l_adr_accounting_coa_id NUMBER;
69521 l_adr_flexfield_segment_code VARCHAR2(30);
69522 l_adr_flex_value_set_id NUMBER;
69523 l_adr_value_type_code VARCHAR2(30);
69524 l_adr_value_combination_id NUMBER;
69525 l_adr_value_segment_code VARCHAR2(30);
69526
69527 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
69528 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
69529 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
69530 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
69531
69532 -- 4262811 Variables ------------------------------------------------------------------------------------------
69533 l_entered_amt_idx NUMBER;
69534 l_accted_amt_idx NUMBER;
69535 l_acc_rev_flag VARCHAR2(1);
69536 l_accrual_line_num NUMBER;
69537 l_tmp_amt NUMBER;
69538 l_acc_rev_natural_side_code VARCHAR2(1);
69539
69540 l_num_entries NUMBER;
69541 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
69542 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
69543 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
69544 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
69545 l_recog_line_1 NUMBER;
69546 l_recog_line_2 NUMBER;
69547
69548 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
69549 l_bflow_applied_to_amt NUMBER; -- 5132302
69550 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
69551
69552 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
69553
69554 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
69555 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
69556
69557 ---------------------------------------------------------------------------------------------------------------
69558
69559
69560 --
69561 -- bulk performance
69562 --
69563 l_balance_type_code VARCHAR2(1);
69564 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
69565 l_log_module VARCHAR2(240);
69566
69567 --
69568 -- Upgrade strategy
69569 --
69570 l_actual_upg_option VARCHAR2(1);
69571 l_enc_upg_option VARCHAR2(1);
69572
69573 --
69574 BEGIN
69575 --
69576 IF g_log_enabled THEN
69577 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_147';
69578 END IF;
69579 --
69580 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69581
69582 trace
69583 (p_msg => 'BEGIN of AcctLineType_147'
69584 ,p_level => C_LEVEL_PROCEDURE
69585 ,p_module => l_log_module);
69586
69587 END IF;
69588 --
69589 l_component_type := 'AMB_JLT';
69590 l_component_code := 'INTERORG_FREIGHT_CHARGE';
69591 l_component_type_code := 'S';
69592 l_component_appl_id := 707;
69593 l_amb_context_code := 'DEFAULT';
69594 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
69595 l_event_class_code := 'USER_DEFINE';
69596 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
69597 l_line_definition_owner_code := 'S';
69598 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
69599 --
69600 l_balance_type_code := 'A';
69601 l_segment := NULL;
69602 l_ccid := NULL;
69603 l_adr_transaction_coa_id := NULL;
69604 l_adr_accounting_coa_id := NULL;
69605 l_adr_flexfield_segment_code := NULL;
69606 l_adr_flex_value_set_id := NULL;
69607 l_adr_value_type_code := NULL;
69608 l_adr_value_combination_id := NULL;
69609 l_adr_value_segment_code := NULL;
69610
69611 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
69612 l_bflow_class_code := ''; -- 4219869 Business Flow
69613 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
69614 l_budgetary_control_flag := 'N';
69615
69616 l_bflow_applied_to_amt_idx := NULL; -- 5132302
69617 l_bflow_applied_to_amt := NULL; -- 5132302
69618 l_entered_amt_idx := NULL; -- 4262811
69619 l_accted_amt_idx := NULL; -- 4262811
69620 l_acc_rev_flag := NULL; -- 4262811
69621 l_accrual_line_num := NULL; -- 4262811
69622 l_tmp_amt := NULL; -- 4262811
69623 --
69624
69625 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
69626 l_balance_type_code <> 'B' THEN
69627 IF NVL(p_source_97,9E125) = 12
69628 THEN
69629
69630 --
69631 XLA_AE_LINES_PKG.SetNewLine;
69632
69633 p_balance_type_code := l_balance_type_code;
69634 -- set the flag so later we will know whether the gain loss line needs to be created
69635
69636 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
69637 p_actual_flag :='A';
69638 END IF;
69639
69640 --
69641 -- bulk performance
69642 --
69643 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
69644 p_header_num => 0); -- 4262811
69645 --
69646 -- set accounting line options
69647 --
69648 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
69649 p_natural_side_code => 'D'
69650 , p_gain_or_loss_flag => 'N'
69651 , p_gl_transfer_mode_code => 'S'
69652 , p_acct_entry_type_code => 'A'
69653 , p_switch_side_flag => 'Y'
69654 , p_merge_duplicate_code => 'N'
69655 );
69656 --
69657 l_acc_rev_natural_side_code := 'C'; -- 4262811
69658 --
69659 --
69660 -- set accounting line type info
69661 --
69662 xla_ae_lines_pkg.SetAcctLineType
69663 (p_component_type => l_component_type
69664 ,p_event_type_code => l_event_type_code
69665 ,p_line_definition_owner_code => l_line_definition_owner_code
69666 ,p_line_definition_code => l_line_definition_code
69667 ,p_accounting_line_code => l_component_code
69668 ,p_accounting_line_type_code => l_component_type_code
69669 ,p_accounting_line_appl_id => l_component_appl_id
69670 ,p_amb_context_code => l_amb_context_code
69671 ,p_entity_code => l_entity_code
69672 ,p_event_class_code => l_event_class_code);
69673 --
69674 -- set accounting class
69675 --
69676 xla_ae_lines_pkg.SetAcctClass(
69677 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
69678 , p_ae_header_id => l_ae_header_id
69679 );
69680
69681 --
69682 -- set rounding class
69683 --
69684 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
69685 'INTERORG_FREIGHT_CHARGE';
69686
69687 --
69688 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
69689 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
69690 --
69691 -- bulk performance
69692 --
69693 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
69694
69695 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
69696 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
69697
69698 -- 4955764
69699 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
69700 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
69701
69702 -- 4458381 Public Sector Enh
69703
69704 --
69705 -- set accounting attributes for the line type
69706 --
69707 l_entered_amt_idx := 3;
69708 l_accted_amt_idx := 8;
69709 l_bflow_applied_to_amt_idx := NULL; -- 5132302
69710 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
69711 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
69712 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
69713 l_rec_acct_attrs.array_char_value(2) := p_source_85;
69714 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
69715 l_rec_acct_attrs.array_num_value(3) := p_source_91;
69716 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
69717 l_rec_acct_attrs.array_char_value(4) := p_source_88;
69718 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
69719 l_rec_acct_attrs.array_date_value(5) := p_source_92;
69720 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
69721 l_rec_acct_attrs.array_num_value(6) := p_source_93;
69722 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
69723 l_rec_acct_attrs.array_char_value(7) := p_source_94;
69724 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
69725 l_rec_acct_attrs.array_num_value(8) := p_source_95;
69726
69727 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
69728 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
69729
69730 ---------------------------------------------------------------------------------------------------------------
69731 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
69732 ---------------------------------------------------------------------------------------------------------------
69733 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
69734
69735 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
69736 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
69737
69738 IF xla_accounting_cache_pkg.GetValueChar
69739 (p_source_code => 'LEDGER_CATEGORY_CODE'
69740 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
69741 AND l_bflow_method_code = 'PRIOR_ENTRY'
69742 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
69743 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
69744 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
69745 )
69746 THEN
69747 xla_ae_lines_pkg.BflowUpgEntry
69748 (p_business_method_code => l_bflow_method_code
69749 ,p_business_class_code => l_bflow_class_code
69750 ,p_balance_type => l_balance_type_code);
69751 ELSE
69752 NULL;
69753 -- No business flow processing for business flow method of NONE.
69754 END IF;
69755
69756 --
69757 -- call analytical criteria
69758 --
69759
69760 --
69761 -- call description
69762 --
69763
69764 xla_ae_lines_pkg.SetLineDescription(
69765 p_ae_header_id => l_ae_header_id
69766 ,p_description => Description_1 (
69767 p_application_id => p_application_id
69768 , p_ae_header_id => l_ae_header_id
69769 , p_source_1 => p_source_1
69770 , p_source_2 => p_source_2
69771 , p_source_3 => p_source_3
69772 , p_source_4 => p_source_4
69773 , p_source_5 => p_source_5
69774 )
69775 );
69776
69777
69778 --
69779 -- call ADRs
69780 -- Bug 4922099
69781 --
69782 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
69783 (NVL(l_actual_upg_option, 'N') = 'O') OR
69784 (NVL(l_enc_upg_option, 'N') = 'O')
69785 )
69786 THEN
69787 NULL;
69788 --
69789 --
69790
69791 l_ccid := AcctDerRule_17(
69792 p_application_id => p_application_id
69793 , p_ae_header_id => l_ae_header_id
69794 , p_source_32 => p_source_32
69795 , x_transaction_coa_id => l_adr_transaction_coa_id
69796 , x_accounting_coa_id => l_adr_accounting_coa_id
69797 , x_value_type_code => l_adr_value_type_code
69798 , p_side => 'NA'
69799 );
69800
69801 xla_ae_lines_pkg.set_ccid(
69802 p_code_combination_id => l_ccid
69803 , p_value_type_code => l_adr_value_type_code
69804 , p_transaction_coa_id => l_adr_transaction_coa_id
69805 , p_accounting_coa_id => l_adr_accounting_coa_id
69806 , p_adr_code => 'PI_FREIGHT'
69807 , p_adr_type_code => 'S'
69808 , p_component_type => l_component_type
69809 , p_component_code => l_component_code
69810 , p_component_type_code => l_component_type_code
69811 , p_component_appl_id => l_component_appl_id
69812 , p_amb_context_code => l_amb_context_code
69813 , p_side => 'NA'
69814 );
69815
69816
69817 --
69818 --
69819 END IF;
69820 --
69821 -- Bug 4922099
69822 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
69823 (NVL(l_enc_upg_option, 'N') = 'O')
69824 ) AND
69825 (l_bflow_method_code = 'PRIOR_ENTRY')
69826 )
69827 THEN
69828 IF
69829 --
69830 1 = 2
69831 --
69832 THEN
69833 xla_accounting_err_pkg.build_message
69834 (p_appli_s_name => 'XLA'
69835 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
69836 ,p_token_1 => 'LINE_NUMBER'
69837 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
69838 ,p_token_2 => 'LINE_TYPE_NAME'
69839 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
69840 l_component_type
69841 ,l_component_code
69842 ,l_component_type_code
69843 ,l_component_appl_id
69844 ,l_amb_context_code
69845 ,l_entity_code
69846 ,l_event_class_code
69847 )
69848 ,p_token_3 => 'OWNER'
69849 ,p_value_3 => xla_lookups_pkg.get_meaning(
69850 p_lookup_type => 'XLA_OWNER_TYPE'
69851 ,p_lookup_code => l_component_type_code
69852 )
69853 ,p_token_4 => 'PRODUCT_NAME'
69854 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
69855 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
69856 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
69857 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
69858 ,p_ae_header_id => NULL
69859 );
69860
69861 IF (C_LEVEL_ERROR>= g_log_level) THEN
69862 trace
69863 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
69864 ,p_level => C_LEVEL_ERROR
69865 ,p_module => l_log_module);
69866 END IF;
69867 END IF;
69868 END IF;
69869 --
69870 --
69871 ------------------------------------------------------------------------------------------------
69872 -- 4219869 Business Flow
69873 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
69874 -- Prior Entry. Currently, the following code is always generated.
69875 ------------------------------------------------------------------------------------------------
69876 XLA_AE_LINES_PKG.ValidateCurrentLine;
69877
69878 ------------------------------------------------------------------------------------
69879 -- 4219869 Business Flow
69880 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
69881 ------------------------------------------------------------------------------------
69882 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
69883
69884 ----------------------------------------------------------------------------------
69885 -- 4219869 Business Flow
69886 -- Update journal entry status -- Need to generate this within IF <condition>
69887 ----------------------------------------------------------------------------------
69888 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
69889 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
69890 ,p_balance_type_code => l_balance_type_code
69891 );
69892
69893 -------------------------------------------------------------------------------------------
69894 -- 4262811 - Generate the Accrual Reversal lines
69895 -------------------------------------------------------------------------------------------
69896 BEGIN
69897 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
69898 (g_array_event(p_event_id).array_value_num('header_index'));
69899 IF l_acc_rev_flag IS NULL THEN
69900 l_acc_rev_flag := 'N';
69901 END IF;
69902 EXCEPTION
69903 WHEN OTHERS THEN
69904 l_acc_rev_flag := 'N';
69905 END;
69906 --
69907 IF (l_acc_rev_flag = 'Y') THEN
69908
69909 -- 4645092 ------------------------------------------------------------------------------
69910 -- To allow MPA report to determine if it should generate report process
69911 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
69912 ------------------------------------------------------------------------------------------
69913
69914 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
69915 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
69916 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
69917 -- call ADRs
69918 -- Bug 4922099
69919 --
69920 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
69921 (NVL(l_actual_upg_option, 'N') = 'O') OR
69922 (NVL(l_enc_upg_option, 'N') = 'O')
69923 )
69924 THEN
69925 NULL;
69926 --
69927 --
69928
69929 l_ccid := AcctDerRule_17(
69930 p_application_id => p_application_id
69931 , p_ae_header_id => l_ae_header_id
69932 , p_source_32 => p_source_32
69933 , x_transaction_coa_id => l_adr_transaction_coa_id
69934 , x_accounting_coa_id => l_adr_accounting_coa_id
69935 , x_value_type_code => l_adr_value_type_code
69936 , p_side => 'NA'
69937 );
69938
69939 xla_ae_lines_pkg.set_ccid(
69940 p_code_combination_id => l_ccid
69941 , p_value_type_code => l_adr_value_type_code
69942 , p_transaction_coa_id => l_adr_transaction_coa_id
69943 , p_accounting_coa_id => l_adr_accounting_coa_id
69944 , p_adr_code => 'PI_FREIGHT'
69945 , p_adr_type_code => 'S'
69946 , p_component_type => l_component_type
69947 , p_component_code => l_component_code
69948 , p_component_type_code => l_component_type_code
69949 , p_component_appl_id => l_component_appl_id
69950 , p_amb_context_code => l_amb_context_code
69951 , p_side => 'NA'
69952 );
69953
69954
69955 --
69956 --
69957 END IF;
69958
69959 --
69960 -- Update the line information that should be overwritten
69961 --
69962 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
69963 p_header_num => 1);
69964 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
69965
69966 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
69967
69968 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
69969 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
69970 END IF;
69971
69972 --
69973 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
69974 --
69975 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
69976 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
69977 ELSE
69978 ---------------------------------------------------------------------------------------------------
69979 -- 4262811a Switch Sign
69980 ---------------------------------------------------------------------------------------------------
69981 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
69982 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
69983 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69984 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
69985 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69986 -- 5132302
69987 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
69988 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
69989
69990 END IF;
69991
69992 -- 4955764
69993 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
69994 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
69995
69996
69997 XLA_AE_LINES_PKG.ValidateCurrentLine;
69998 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
69999
70000 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
70001 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
70002 ,p_balance_type_code => l_balance_type_code);
70003
70004 END IF;
70005
70006 -----------------------------------------------------------------------------------------
70007 -- 4262811 Multiperiod Accounting
70008 -----------------------------------------------------------------------------------------
70009 -- No MPA option is assigned.
70010
70011
70012 END IF;
70013 END IF;
70014 --
70015
70016 --
70017 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70018 trace
70019 (p_msg => 'END of AcctLineType_147'
70020 ,p_level => C_LEVEL_PROCEDURE
70021 ,p_module => l_log_module);
70022 END IF;
70023 --
70024 EXCEPTION
70025 WHEN xla_exceptions_pkg.application_exception THEN
70026 RAISE;
70027 WHEN OTHERS THEN
70028 xla_exceptions_pkg.raise_message
70029 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_147');
70030 END AcctLineType_147;
70031 --
70032
70033 ---------------------------------------
70034 --
70035 -- PRIVATE FUNCTION
70036 -- AcctLineType_148
70037 --
70038 ---------------------------------------
70039 PROCEDURE AcctLineType_148 (
70040 p_application_id IN NUMBER
70041 ,p_event_id IN NUMBER
70042 ,p_calculate_acctd_flag IN VARCHAR2
70043 ,p_calculate_g_l_flag IN VARCHAR2
70044 ,p_actual_flag IN OUT VARCHAR2
70045 ,p_balance_type_code OUT VARCHAR2
70046 ,p_gain_or_loss_ref OUT VARCHAR2
70047
70048 --TRANSACTION_ID
70049 , p_source_1 IN NUMBER
70050 --Item Concatenated Segments
70051 , p_source_2 IN VARCHAR2
70052 --Transaction Quantity
70053 , p_source_3 IN NUMBER
70054 --Transaction Unit of Measure Code
70055 , p_source_4 IN VARCHAR2
70056 --Inventory Transaction Type Description
70057 , p_source_5 IN VARCHAR2
70058 --Transaction Transportation Distribution Account
70059 , p_source_32 IN NUMBER
70060 --DISTRIBUTION_IDENTIFIER
70061 , p_source_84 IN NUMBER
70062 --Distribution Type
70063 , p_source_85 IN VARCHAR2
70064 , p_source_85_meaning IN VARCHAR2
70065 --Entered Currency Code
70066 , p_source_88 IN VARCHAR2
70067 --Entered Amount
70068 , p_source_91 IN NUMBER
70069 --Currency Conversion Date
70070 , p_source_92 IN DATE
70071 --Currency Conversion Rate
70072 , p_source_93 IN NUMBER
70073 --Currency Conversion Type
70074 , p_source_94 IN VARCHAR2
70075 --Accounted Amount
70076 , p_source_95 IN NUMBER
70077 --Accounting Line Type
70078 , p_source_97 IN NUMBER
70079 )
70080 IS
70081
70082 l_component_type VARCHAR2(80);
70083 l_component_code VARCHAR2(30);
70084 l_component_type_code VARCHAR2(1);
70085 l_component_appl_id INTEGER;
70086 l_amb_context_code VARCHAR2(30);
70087 l_entity_code VARCHAR2(30);
70088 l_event_class_code VARCHAR2(30);
70089 l_ae_header_id NUMBER;
70090 l_event_type_code VARCHAR2(30);
70091 l_line_definition_code VARCHAR2(30);
70092 l_line_definition_owner_code VARCHAR2(1);
70093 --
70094 -- adr variables
70095 l_segment VARCHAR2(30);
70096 l_ccid NUMBER;
70097 l_adr_transaction_coa_id NUMBER;
70098 l_adr_accounting_coa_id NUMBER;
70099 l_adr_flexfield_segment_code VARCHAR2(30);
70100 l_adr_flex_value_set_id NUMBER;
70101 l_adr_value_type_code VARCHAR2(30);
70102 l_adr_value_combination_id NUMBER;
70103 l_adr_value_segment_code VARCHAR2(30);
70104
70105 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
70106 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
70107 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
70108 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
70109
70110 -- 4262811 Variables ------------------------------------------------------------------------------------------
70111 l_entered_amt_idx NUMBER;
70112 l_accted_amt_idx NUMBER;
70113 l_acc_rev_flag VARCHAR2(1);
70114 l_accrual_line_num NUMBER;
70115 l_tmp_amt NUMBER;
70116 l_acc_rev_natural_side_code VARCHAR2(1);
70117
70118 l_num_entries NUMBER;
70119 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
70120 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
70121 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
70122 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
70123 l_recog_line_1 NUMBER;
70124 l_recog_line_2 NUMBER;
70125
70126 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
70127 l_bflow_applied_to_amt NUMBER; -- 5132302
70128 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
70129
70130 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
70131
70132 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
70133 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
70134
70135 ---------------------------------------------------------------------------------------------------------------
70136
70137
70138 --
70139 -- bulk performance
70140 --
70141 l_balance_type_code VARCHAR2(1);
70142 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
70143 l_log_module VARCHAR2(240);
70144
70145 --
70146 -- Upgrade strategy
70147 --
70148 l_actual_upg_option VARCHAR2(1);
70149 l_enc_upg_option VARCHAR2(1);
70150
70151 --
70152 BEGIN
70153 --
70154 IF g_log_enabled THEN
70155 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_148';
70156 END IF;
70157 --
70158 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70159
70160 trace
70161 (p_msg => 'BEGIN of AcctLineType_148'
70162 ,p_level => C_LEVEL_PROCEDURE
70163 ,p_module => l_log_module);
70164
70165 END IF;
70166 --
70167 l_component_type := 'AMB_JLT';
70168 l_component_code := 'INTERORG_FREIGHT_CHARGE';
70169 l_component_type_code := 'S';
70170 l_component_appl_id := 707;
70171 l_amb_context_code := 'DEFAULT';
70172 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
70173 l_event_class_code := 'USER_DEFINE';
70174 l_event_type_code := 'UDIR_INTERORG_SHIP';
70175 l_line_definition_owner_code := 'S';
70176 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
70177 --
70178 l_balance_type_code := 'A';
70179 l_segment := NULL;
70180 l_ccid := NULL;
70181 l_adr_transaction_coa_id := NULL;
70182 l_adr_accounting_coa_id := NULL;
70183 l_adr_flexfield_segment_code := NULL;
70184 l_adr_flex_value_set_id := NULL;
70185 l_adr_value_type_code := NULL;
70186 l_adr_value_combination_id := NULL;
70187 l_adr_value_segment_code := NULL;
70188
70189 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
70190 l_bflow_class_code := ''; -- 4219869 Business Flow
70191 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
70192 l_budgetary_control_flag := 'N';
70193
70194 l_bflow_applied_to_amt_idx := NULL; -- 5132302
70195 l_bflow_applied_to_amt := NULL; -- 5132302
70196 l_entered_amt_idx := NULL; -- 4262811
70197 l_accted_amt_idx := NULL; -- 4262811
70198 l_acc_rev_flag := NULL; -- 4262811
70199 l_accrual_line_num := NULL; -- 4262811
70200 l_tmp_amt := NULL; -- 4262811
70201 --
70202
70203 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
70204 l_balance_type_code <> 'B' THEN
70205 IF NVL(p_source_97,9E125) = 12
70206 THEN
70207
70208 --
70209 XLA_AE_LINES_PKG.SetNewLine;
70210
70211 p_balance_type_code := l_balance_type_code;
70212 -- set the flag so later we will know whether the gain loss line needs to be created
70213
70214 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
70215 p_actual_flag :='A';
70216 END IF;
70217
70218 --
70219 -- bulk performance
70220 --
70221 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
70222 p_header_num => 0); -- 4262811
70223 --
70224 -- set accounting line options
70225 --
70226 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
70227 p_natural_side_code => 'D'
70228 , p_gain_or_loss_flag => 'N'
70229 , p_gl_transfer_mode_code => 'S'
70230 , p_acct_entry_type_code => 'A'
70231 , p_switch_side_flag => 'Y'
70232 , p_merge_duplicate_code => 'N'
70233 );
70234 --
70235 l_acc_rev_natural_side_code := 'C'; -- 4262811
70236 --
70237 --
70238 -- set accounting line type info
70239 --
70240 xla_ae_lines_pkg.SetAcctLineType
70241 (p_component_type => l_component_type
70242 ,p_event_type_code => l_event_type_code
70243 ,p_line_definition_owner_code => l_line_definition_owner_code
70244 ,p_line_definition_code => l_line_definition_code
70245 ,p_accounting_line_code => l_component_code
70246 ,p_accounting_line_type_code => l_component_type_code
70247 ,p_accounting_line_appl_id => l_component_appl_id
70248 ,p_amb_context_code => l_amb_context_code
70249 ,p_entity_code => l_entity_code
70250 ,p_event_class_code => l_event_class_code);
70251 --
70252 -- set accounting class
70253 --
70254 xla_ae_lines_pkg.SetAcctClass(
70255 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
70256 , p_ae_header_id => l_ae_header_id
70257 );
70258
70259 --
70260 -- set rounding class
70261 --
70262 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
70263 'INTERORG_FREIGHT_CHARGE';
70264
70265 --
70266 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
70267 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
70268 --
70269 -- bulk performance
70270 --
70271 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
70272
70273 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
70274 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
70275
70276 -- 4955764
70277 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
70278 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
70279
70280 -- 4458381 Public Sector Enh
70281
70282 --
70283 -- set accounting attributes for the line type
70284 --
70285 l_entered_amt_idx := 3;
70286 l_accted_amt_idx := 8;
70287 l_bflow_applied_to_amt_idx := NULL; -- 5132302
70288 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
70289 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
70290 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
70291 l_rec_acct_attrs.array_char_value(2) := p_source_85;
70292 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
70293 l_rec_acct_attrs.array_num_value(3) := p_source_91;
70294 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
70295 l_rec_acct_attrs.array_char_value(4) := p_source_88;
70296 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
70297 l_rec_acct_attrs.array_date_value(5) := p_source_92;
70298 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
70299 l_rec_acct_attrs.array_num_value(6) := p_source_93;
70300 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
70301 l_rec_acct_attrs.array_char_value(7) := p_source_94;
70302 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
70303 l_rec_acct_attrs.array_num_value(8) := p_source_95;
70304
70305 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
70306 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
70307
70308 ---------------------------------------------------------------------------------------------------------------
70309 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
70310 ---------------------------------------------------------------------------------------------------------------
70311 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
70312
70313 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
70314 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
70315
70316 IF xla_accounting_cache_pkg.GetValueChar
70317 (p_source_code => 'LEDGER_CATEGORY_CODE'
70318 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
70319 AND l_bflow_method_code = 'PRIOR_ENTRY'
70320 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
70321 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
70322 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
70323 )
70324 THEN
70325 xla_ae_lines_pkg.BflowUpgEntry
70326 (p_business_method_code => l_bflow_method_code
70327 ,p_business_class_code => l_bflow_class_code
70328 ,p_balance_type => l_balance_type_code);
70329 ELSE
70330 NULL;
70331 -- No business flow processing for business flow method of NONE.
70332 END IF;
70333
70334 --
70335 -- call analytical criteria
70336 --
70337
70338 --
70339 -- call description
70340 --
70341
70342 xla_ae_lines_pkg.SetLineDescription(
70343 p_ae_header_id => l_ae_header_id
70344 ,p_description => Description_1 (
70345 p_application_id => p_application_id
70346 , p_ae_header_id => l_ae_header_id
70347 , p_source_1 => p_source_1
70348 , p_source_2 => p_source_2
70349 , p_source_3 => p_source_3
70350 , p_source_4 => p_source_4
70351 , p_source_5 => p_source_5
70352 )
70353 );
70354
70355
70356 --
70357 -- call ADRs
70358 -- Bug 4922099
70359 --
70360 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
70361 (NVL(l_actual_upg_option, 'N') = 'O') OR
70362 (NVL(l_enc_upg_option, 'N') = 'O')
70363 )
70364 THEN
70365 NULL;
70366 --
70367 --
70368
70369 l_ccid := AcctDerRule_17(
70370 p_application_id => p_application_id
70371 , p_ae_header_id => l_ae_header_id
70372 , p_source_32 => p_source_32
70373 , x_transaction_coa_id => l_adr_transaction_coa_id
70374 , x_accounting_coa_id => l_adr_accounting_coa_id
70375 , x_value_type_code => l_adr_value_type_code
70376 , p_side => 'NA'
70377 );
70378
70379 xla_ae_lines_pkg.set_ccid(
70380 p_code_combination_id => l_ccid
70381 , p_value_type_code => l_adr_value_type_code
70382 , p_transaction_coa_id => l_adr_transaction_coa_id
70383 , p_accounting_coa_id => l_adr_accounting_coa_id
70384 , p_adr_code => 'PI_FREIGHT'
70385 , p_adr_type_code => 'S'
70386 , p_component_type => l_component_type
70387 , p_component_code => l_component_code
70388 , p_component_type_code => l_component_type_code
70389 , p_component_appl_id => l_component_appl_id
70390 , p_amb_context_code => l_amb_context_code
70391 , p_side => 'NA'
70392 );
70393
70394
70395 --
70396 --
70397 END IF;
70398 --
70399 -- Bug 4922099
70400 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
70401 (NVL(l_enc_upg_option, 'N') = 'O')
70402 ) AND
70403 (l_bflow_method_code = 'PRIOR_ENTRY')
70404 )
70405 THEN
70406 IF
70407 --
70408 1 = 2
70409 --
70410 THEN
70411 xla_accounting_err_pkg.build_message
70412 (p_appli_s_name => 'XLA'
70413 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
70414 ,p_token_1 => 'LINE_NUMBER'
70415 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
70416 ,p_token_2 => 'LINE_TYPE_NAME'
70417 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
70418 l_component_type
70419 ,l_component_code
70420 ,l_component_type_code
70421 ,l_component_appl_id
70422 ,l_amb_context_code
70423 ,l_entity_code
70424 ,l_event_class_code
70425 )
70426 ,p_token_3 => 'OWNER'
70427 ,p_value_3 => xla_lookups_pkg.get_meaning(
70428 p_lookup_type => 'XLA_OWNER_TYPE'
70429 ,p_lookup_code => l_component_type_code
70430 )
70431 ,p_token_4 => 'PRODUCT_NAME'
70432 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
70433 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
70434 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
70435 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
70436 ,p_ae_header_id => NULL
70437 );
70438
70439 IF (C_LEVEL_ERROR>= g_log_level) THEN
70440 trace
70441 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
70442 ,p_level => C_LEVEL_ERROR
70443 ,p_module => l_log_module);
70444 END IF;
70445 END IF;
70446 END IF;
70447 --
70448 --
70449 ------------------------------------------------------------------------------------------------
70450 -- 4219869 Business Flow
70451 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
70452 -- Prior Entry. Currently, the following code is always generated.
70453 ------------------------------------------------------------------------------------------------
70454 XLA_AE_LINES_PKG.ValidateCurrentLine;
70455
70456 ------------------------------------------------------------------------------------
70457 -- 4219869 Business Flow
70458 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
70459 ------------------------------------------------------------------------------------
70460 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
70461
70462 ----------------------------------------------------------------------------------
70463 -- 4219869 Business Flow
70464 -- Update journal entry status -- Need to generate this within IF <condition>
70465 ----------------------------------------------------------------------------------
70466 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
70467 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
70468 ,p_balance_type_code => l_balance_type_code
70469 );
70470
70471 -------------------------------------------------------------------------------------------
70472 -- 4262811 - Generate the Accrual Reversal lines
70473 -------------------------------------------------------------------------------------------
70474 BEGIN
70475 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
70476 (g_array_event(p_event_id).array_value_num('header_index'));
70477 IF l_acc_rev_flag IS NULL THEN
70478 l_acc_rev_flag := 'N';
70479 END IF;
70480 EXCEPTION
70481 WHEN OTHERS THEN
70482 l_acc_rev_flag := 'N';
70483 END;
70484 --
70485 IF (l_acc_rev_flag = 'Y') THEN
70486
70487 -- 4645092 ------------------------------------------------------------------------------
70488 -- To allow MPA report to determine if it should generate report process
70489 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
70490 ------------------------------------------------------------------------------------------
70491
70492 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
70493 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
70494 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
70495 -- call ADRs
70496 -- Bug 4922099
70497 --
70498 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
70499 (NVL(l_actual_upg_option, 'N') = 'O') OR
70500 (NVL(l_enc_upg_option, 'N') = 'O')
70501 )
70502 THEN
70503 NULL;
70504 --
70505 --
70506
70507 l_ccid := AcctDerRule_17(
70508 p_application_id => p_application_id
70509 , p_ae_header_id => l_ae_header_id
70510 , p_source_32 => p_source_32
70511 , x_transaction_coa_id => l_adr_transaction_coa_id
70512 , x_accounting_coa_id => l_adr_accounting_coa_id
70513 , x_value_type_code => l_adr_value_type_code
70514 , p_side => 'NA'
70515 );
70516
70517 xla_ae_lines_pkg.set_ccid(
70518 p_code_combination_id => l_ccid
70519 , p_value_type_code => l_adr_value_type_code
70520 , p_transaction_coa_id => l_adr_transaction_coa_id
70521 , p_accounting_coa_id => l_adr_accounting_coa_id
70522 , p_adr_code => 'PI_FREIGHT'
70523 , p_adr_type_code => 'S'
70524 , p_component_type => l_component_type
70525 , p_component_code => l_component_code
70526 , p_component_type_code => l_component_type_code
70527 , p_component_appl_id => l_component_appl_id
70528 , p_amb_context_code => l_amb_context_code
70529 , p_side => 'NA'
70530 );
70531
70532
70533 --
70534 --
70535 END IF;
70536
70537 --
70538 -- Update the line information that should be overwritten
70539 --
70540 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
70541 p_header_num => 1);
70542 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
70543
70544 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
70545
70546 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
70547 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
70548 END IF;
70549
70550 --
70551 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
70552 --
70553 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
70554 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
70555 ELSE
70556 ---------------------------------------------------------------------------------------------------
70557 -- 4262811a Switch Sign
70558 ---------------------------------------------------------------------------------------------------
70559 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
70560 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
70561 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
70562 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
70563 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
70564 -- 5132302
70565 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
70566 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
70567
70568 END IF;
70569
70570 -- 4955764
70571 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
70572 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
70573
70574
70575 XLA_AE_LINES_PKG.ValidateCurrentLine;
70576 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
70577
70578 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
70579 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
70580 ,p_balance_type_code => l_balance_type_code);
70581
70582 END IF;
70583
70584 -----------------------------------------------------------------------------------------
70585 -- 4262811 Multiperiod Accounting
70586 -----------------------------------------------------------------------------------------
70587 -- No MPA option is assigned.
70588
70589
70590 END IF;
70591 END IF;
70592 --
70593
70594 --
70595 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70596 trace
70597 (p_msg => 'END of AcctLineType_148'
70598 ,p_level => C_LEVEL_PROCEDURE
70599 ,p_module => l_log_module);
70600 END IF;
70601 --
70602 EXCEPTION
70603 WHEN xla_exceptions_pkg.application_exception THEN
70604 RAISE;
70605 WHEN OTHERS THEN
70606 xla_exceptions_pkg.raise_message
70607 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_148');
70608 END AcctLineType_148;
70609 --
70610
70611 ---------------------------------------
70612 --
70613 -- PRIVATE FUNCTION
70614 -- AcctLineType_149
70615 --
70616 ---------------------------------------
70617 PROCEDURE AcctLineType_149 (
70618 p_application_id IN NUMBER
70619 ,p_event_id IN NUMBER
70620 ,p_calculate_acctd_flag IN VARCHAR2
70621 ,p_calculate_g_l_flag IN VARCHAR2
70622 ,p_actual_flag IN OUT VARCHAR2
70623 ,p_balance_type_code OUT VARCHAR2
70624 ,p_gain_or_loss_ref OUT VARCHAR2
70625
70626 --Cost Management Default Account
70627 , p_source_11 IN NUMBER
70628 --DISTRIBUTION_IDENTIFIER
70629 , p_source_84 IN NUMBER
70630 --Distribution Type
70631 , p_source_85 IN VARCHAR2
70632 , p_source_85_meaning IN VARCHAR2
70633 --Entered Currency Code
70634 , p_source_88 IN VARCHAR2
70635 --Entered Amount
70636 , p_source_91 IN NUMBER
70637 --Currency Conversion Date
70638 , p_source_92 IN DATE
70639 --Currency Conversion Rate
70640 , p_source_93 IN NUMBER
70641 --Currency Conversion Type
70642 , p_source_94 IN VARCHAR2
70643 --Accounted Amount
70644 , p_source_95 IN NUMBER
70645 --Accounting Line Type
70646 , p_source_97 IN NUMBER
70647 )
70648 IS
70649
70650 l_component_type VARCHAR2(80);
70651 l_component_code VARCHAR2(30);
70652 l_component_type_code VARCHAR2(1);
70653 l_component_appl_id INTEGER;
70654 l_amb_context_code VARCHAR2(30);
70655 l_entity_code VARCHAR2(30);
70656 l_event_class_code VARCHAR2(30);
70657 l_ae_header_id NUMBER;
70658 l_event_type_code VARCHAR2(30);
70659 l_line_definition_code VARCHAR2(30);
70660 l_line_definition_owner_code VARCHAR2(1);
70661 --
70662 -- adr variables
70663 l_segment VARCHAR2(30);
70664 l_ccid NUMBER;
70665 l_adr_transaction_coa_id NUMBER;
70666 l_adr_accounting_coa_id NUMBER;
70667 l_adr_flexfield_segment_code VARCHAR2(30);
70668 l_adr_flex_value_set_id NUMBER;
70669 l_adr_value_type_code VARCHAR2(30);
70670 l_adr_value_combination_id NUMBER;
70671 l_adr_value_segment_code VARCHAR2(30);
70672
70673 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
70674 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
70675 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
70676 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
70677
70678 -- 4262811 Variables ------------------------------------------------------------------------------------------
70679 l_entered_amt_idx NUMBER;
70680 l_accted_amt_idx NUMBER;
70681 l_acc_rev_flag VARCHAR2(1);
70682 l_accrual_line_num NUMBER;
70683 l_tmp_amt NUMBER;
70684 l_acc_rev_natural_side_code VARCHAR2(1);
70685
70686 l_num_entries NUMBER;
70687 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
70688 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
70689 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
70690 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
70691 l_recog_line_1 NUMBER;
70692 l_recog_line_2 NUMBER;
70693
70694 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
70695 l_bflow_applied_to_amt NUMBER; -- 5132302
70696 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
70697
70698 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
70699
70700 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
70701 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
70702
70703 ---------------------------------------------------------------------------------------------------------------
70704
70705
70706 --
70707 -- bulk performance
70708 --
70709 l_balance_type_code VARCHAR2(1);
70710 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
70711 l_log_module VARCHAR2(240);
70712
70713 --
70714 -- Upgrade strategy
70715 --
70716 l_actual_upg_option VARCHAR2(1);
70717 l_enc_upg_option VARCHAR2(1);
70718
70719 --
70720 BEGIN
70721 --
70722 IF g_log_enabled THEN
70723 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_149';
70724 END IF;
70725 --
70726 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70727
70728 trace
70729 (p_msg => 'BEGIN of AcctLineType_149'
70730 ,p_level => C_LEVEL_PROCEDURE
70731 ,p_module => l_log_module);
70732
70733 END IF;
70734 --
70735 l_component_type := 'AMB_JLT';
70736 l_component_code := 'INTERORG_FREIGHT_CHARGE';
70737 l_component_type_code := 'S';
70738 l_component_appl_id := 707;
70739 l_amb_context_code := 'DEFAULT';
70740 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
70741 l_event_class_code := 'USER_DEFINE';
70742 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
70743 l_line_definition_owner_code := 'S';
70744 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
70745 --
70746 l_balance_type_code := 'A';
70747 l_segment := NULL;
70748 l_ccid := NULL;
70749 l_adr_transaction_coa_id := NULL;
70750 l_adr_accounting_coa_id := NULL;
70751 l_adr_flexfield_segment_code := NULL;
70752 l_adr_flex_value_set_id := NULL;
70753 l_adr_value_type_code := NULL;
70754 l_adr_value_combination_id := NULL;
70755 l_adr_value_segment_code := NULL;
70756
70757 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
70758 l_bflow_class_code := ''; -- 4219869 Business Flow
70759 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
70760 l_budgetary_control_flag := 'N';
70761
70762 l_bflow_applied_to_amt_idx := NULL; -- 5132302
70763 l_bflow_applied_to_amt := NULL; -- 5132302
70764 l_entered_amt_idx := NULL; -- 4262811
70765 l_accted_amt_idx := NULL; -- 4262811
70766 l_acc_rev_flag := NULL; -- 4262811
70767 l_accrual_line_num := NULL; -- 4262811
70768 l_tmp_amt := NULL; -- 4262811
70769 --
70770
70771 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
70772 l_balance_type_code <> 'B' THEN
70773 IF NVL(p_source_97,9E125) = 12
70774 THEN
70775
70776 --
70777 XLA_AE_LINES_PKG.SetNewLine;
70778
70779 p_balance_type_code := l_balance_type_code;
70780 -- set the flag so later we will know whether the gain loss line needs to be created
70781
70782 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
70783 p_actual_flag :='A';
70784 END IF;
70785
70786 --
70787 -- bulk performance
70788 --
70789 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
70790 p_header_num => 0); -- 4262811
70791 --
70792 -- set accounting line options
70793 --
70794 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
70795 p_natural_side_code => 'D'
70796 , p_gain_or_loss_flag => 'N'
70797 , p_gl_transfer_mode_code => 'S'
70798 , p_acct_entry_type_code => 'A'
70799 , p_switch_side_flag => 'Y'
70800 , p_merge_duplicate_code => 'N'
70801 );
70802 --
70803 l_acc_rev_natural_side_code := 'C'; -- 4262811
70804 --
70805 --
70806 -- set accounting line type info
70807 --
70808 xla_ae_lines_pkg.SetAcctLineType
70809 (p_component_type => l_component_type
70810 ,p_event_type_code => l_event_type_code
70811 ,p_line_definition_owner_code => l_line_definition_owner_code
70812 ,p_line_definition_code => l_line_definition_code
70813 ,p_accounting_line_code => l_component_code
70814 ,p_accounting_line_type_code => l_component_type_code
70815 ,p_accounting_line_appl_id => l_component_appl_id
70816 ,p_amb_context_code => l_amb_context_code
70817 ,p_entity_code => l_entity_code
70818 ,p_event_class_code => l_event_class_code);
70819 --
70820 -- set accounting class
70821 --
70822 xla_ae_lines_pkg.SetAcctClass(
70823 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
70824 , p_ae_header_id => l_ae_header_id
70825 );
70826
70827 --
70828 -- set rounding class
70829 --
70830 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
70831 'INTERORG_FREIGHT_CHARGE';
70832
70833 --
70834 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
70835 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
70836 --
70837 -- bulk performance
70838 --
70839 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
70840
70841 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
70842 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
70843
70844 -- 4955764
70845 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
70846 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
70847
70848 -- 4458381 Public Sector Enh
70849
70850 --
70851 -- set accounting attributes for the line type
70852 --
70853 l_entered_amt_idx := 3;
70854 l_accted_amt_idx := 8;
70855 l_bflow_applied_to_amt_idx := NULL; -- 5132302
70856 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
70857 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
70858 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
70859 l_rec_acct_attrs.array_char_value(2) := p_source_85;
70860 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
70861 l_rec_acct_attrs.array_num_value(3) := p_source_91;
70862 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
70863 l_rec_acct_attrs.array_char_value(4) := p_source_88;
70864 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
70865 l_rec_acct_attrs.array_date_value(5) := p_source_92;
70866 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
70867 l_rec_acct_attrs.array_num_value(6) := p_source_93;
70868 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
70869 l_rec_acct_attrs.array_char_value(7) := p_source_94;
70870 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
70871 l_rec_acct_attrs.array_num_value(8) := p_source_95;
70872
70873 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
70874 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
70875
70876 ---------------------------------------------------------------------------------------------------------------
70877 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
70878 ---------------------------------------------------------------------------------------------------------------
70879 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
70880
70881 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
70882 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
70883
70884 IF xla_accounting_cache_pkg.GetValueChar
70885 (p_source_code => 'LEDGER_CATEGORY_CODE'
70886 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
70887 AND l_bflow_method_code = 'PRIOR_ENTRY'
70888 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
70889 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
70890 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
70891 )
70892 THEN
70893 xla_ae_lines_pkg.BflowUpgEntry
70894 (p_business_method_code => l_bflow_method_code
70895 ,p_business_class_code => l_bflow_class_code
70896 ,p_balance_type => l_balance_type_code);
70897 ELSE
70898 NULL;
70899 -- No business flow processing for business flow method of NONE.
70900 END IF;
70901
70902 --
70903 -- call analytical criteria
70904 --
70905
70906 --
70907 -- call description
70908 --
70909 -- No description or it is inherited.
70910 --
70911 -- call ADRs
70912 -- Bug 4922099
70913 --
70914 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
70915 (NVL(l_actual_upg_option, 'N') = 'O') OR
70916 (NVL(l_enc_upg_option, 'N') = 'O')
70917 )
70918 THEN
70919 NULL;
70920 --
70921 --
70922
70923 l_ccid := AcctDerRule_6(
70924 p_application_id => p_application_id
70925 , p_ae_header_id => l_ae_header_id
70926 , p_source_11 => p_source_11
70927 , x_transaction_coa_id => l_adr_transaction_coa_id
70928 , x_accounting_coa_id => l_adr_accounting_coa_id
70929 , x_value_type_code => l_adr_value_type_code
70930 , p_side => 'NA'
70931 );
70932
70933 xla_ae_lines_pkg.set_ccid(
70934 p_code_combination_id => l_ccid
70935 , p_value_type_code => l_adr_value_type_code
70936 , p_transaction_coa_id => l_adr_transaction_coa_id
70937 , p_accounting_coa_id => l_adr_accounting_coa_id
70938 , p_adr_code => 'CST_DEFAULT'
70939 , p_adr_type_code => 'S'
70940 , p_component_type => l_component_type
70941 , p_component_code => l_component_code
70942 , p_component_type_code => l_component_type_code
70943 , p_component_appl_id => l_component_appl_id
70944 , p_amb_context_code => l_amb_context_code
70945 , p_side => 'NA'
70946 );
70947
70948
70949 --
70950 --
70951 END IF;
70952 --
70953 -- Bug 4922099
70954 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
70955 (NVL(l_enc_upg_option, 'N') = 'O')
70956 ) AND
70957 (l_bflow_method_code = 'PRIOR_ENTRY')
70958 )
70959 THEN
70960 IF
70961 --
70962 1 = 2
70963 --
70964 THEN
70965 xla_accounting_err_pkg.build_message
70966 (p_appli_s_name => 'XLA'
70967 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
70968 ,p_token_1 => 'LINE_NUMBER'
70969 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
70970 ,p_token_2 => 'LINE_TYPE_NAME'
70971 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
70972 l_component_type
70973 ,l_component_code
70974 ,l_component_type_code
70975 ,l_component_appl_id
70976 ,l_amb_context_code
70977 ,l_entity_code
70978 ,l_event_class_code
70979 )
70980 ,p_token_3 => 'OWNER'
70981 ,p_value_3 => xla_lookups_pkg.get_meaning(
70982 p_lookup_type => 'XLA_OWNER_TYPE'
70983 ,p_lookup_code => l_component_type_code
70984 )
70985 ,p_token_4 => 'PRODUCT_NAME'
70986 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
70987 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
70988 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
70989 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
70990 ,p_ae_header_id => NULL
70991 );
70992
70993 IF (C_LEVEL_ERROR>= g_log_level) THEN
70994 trace
70995 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
70996 ,p_level => C_LEVEL_ERROR
70997 ,p_module => l_log_module);
70998 END IF;
70999 END IF;
71000 END IF;
71001 --
71002 --
71003 ------------------------------------------------------------------------------------------------
71004 -- 4219869 Business Flow
71005 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
71006 -- Prior Entry. Currently, the following code is always generated.
71007 ------------------------------------------------------------------------------------------------
71008 XLA_AE_LINES_PKG.ValidateCurrentLine;
71009
71010 ------------------------------------------------------------------------------------
71011 -- 4219869 Business Flow
71012 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
71013 ------------------------------------------------------------------------------------
71014 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
71015
71016 ----------------------------------------------------------------------------------
71017 -- 4219869 Business Flow
71018 -- Update journal entry status -- Need to generate this within IF <condition>
71019 ----------------------------------------------------------------------------------
71020 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
71021 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
71022 ,p_balance_type_code => l_balance_type_code
71023 );
71024
71025 -------------------------------------------------------------------------------------------
71026 -- 4262811 - Generate the Accrual Reversal lines
71027 -------------------------------------------------------------------------------------------
71028 BEGIN
71029 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
71030 (g_array_event(p_event_id).array_value_num('header_index'));
71031 IF l_acc_rev_flag IS NULL THEN
71032 l_acc_rev_flag := 'N';
71033 END IF;
71034 EXCEPTION
71035 WHEN OTHERS THEN
71036 l_acc_rev_flag := 'N';
71037 END;
71038 --
71039 IF (l_acc_rev_flag = 'Y') THEN
71040
71041 -- 4645092 ------------------------------------------------------------------------------
71042 -- To allow MPA report to determine if it should generate report process
71043 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
71044 ------------------------------------------------------------------------------------------
71045
71046 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
71047 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
71048 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
71049 -- call ADRs
71050 -- Bug 4922099
71051 --
71052 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
71053 (NVL(l_actual_upg_option, 'N') = 'O') OR
71054 (NVL(l_enc_upg_option, 'N') = 'O')
71055 )
71056 THEN
71057 NULL;
71058 --
71059 --
71060
71061 l_ccid := AcctDerRule_6(
71062 p_application_id => p_application_id
71063 , p_ae_header_id => l_ae_header_id
71064 , p_source_11 => p_source_11
71065 , x_transaction_coa_id => l_adr_transaction_coa_id
71066 , x_accounting_coa_id => l_adr_accounting_coa_id
71067 , x_value_type_code => l_adr_value_type_code
71068 , p_side => 'NA'
71069 );
71070
71071 xla_ae_lines_pkg.set_ccid(
71072 p_code_combination_id => l_ccid
71073 , p_value_type_code => l_adr_value_type_code
71074 , p_transaction_coa_id => l_adr_transaction_coa_id
71075 , p_accounting_coa_id => l_adr_accounting_coa_id
71076 , p_adr_code => 'CST_DEFAULT'
71077 , p_adr_type_code => 'S'
71078 , p_component_type => l_component_type
71079 , p_component_code => l_component_code
71080 , p_component_type_code => l_component_type_code
71081 , p_component_appl_id => l_component_appl_id
71082 , p_amb_context_code => l_amb_context_code
71083 , p_side => 'NA'
71084 );
71085
71086
71087 --
71088 --
71089 END IF;
71090
71091 --
71092 -- Update the line information that should be overwritten
71093 --
71094 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
71095 p_header_num => 1);
71096 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
71097
71098 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
71099
71100 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
71101 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
71102 END IF;
71103
71104 --
71105 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
71106 --
71107 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
71108 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
71109 ELSE
71110 ---------------------------------------------------------------------------------------------------
71111 -- 4262811a Switch Sign
71112 ---------------------------------------------------------------------------------------------------
71113 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
71114 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
71115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71116 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
71117 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71118 -- 5132302
71119 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
71120 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71121
71122 END IF;
71123
71124 -- 4955764
71125 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
71126 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
71127
71128
71129 XLA_AE_LINES_PKG.ValidateCurrentLine;
71130 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
71131
71132 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
71133 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
71134 ,p_balance_type_code => l_balance_type_code);
71135
71136 END IF;
71137
71138 -----------------------------------------------------------------------------------------
71139 -- 4262811 Multiperiod Accounting
71140 -----------------------------------------------------------------------------------------
71141 -- No MPA option is assigned.
71142
71143
71144 END IF;
71145 END IF;
71146 --
71147
71148 --
71149 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71150 trace
71151 (p_msg => 'END of AcctLineType_149'
71152 ,p_level => C_LEVEL_PROCEDURE
71153 ,p_module => l_log_module);
71154 END IF;
71155 --
71156 EXCEPTION
71157 WHEN xla_exceptions_pkg.application_exception THEN
71158 RAISE;
71159 WHEN OTHERS THEN
71160 xla_exceptions_pkg.raise_message
71161 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_149');
71162 END AcctLineType_149;
71163 --
71164
71165 ---------------------------------------
71166 --
71167 -- PRIVATE FUNCTION
71168 -- AcctLineType_150
71169 --
71170 ---------------------------------------
71171 PROCEDURE AcctLineType_150 (
71172 p_application_id IN NUMBER
71173 ,p_event_id IN NUMBER
71174 ,p_calculate_acctd_flag IN VARCHAR2
71175 ,p_calculate_g_l_flag IN VARCHAR2
71176 ,p_actual_flag IN OUT VARCHAR2
71177 ,p_balance_type_code OUT VARCHAR2
71178 ,p_gain_or_loss_ref OUT VARCHAR2
71179
71180 --TRANSACTION_ID
71181 , p_source_1 IN NUMBER
71182 --Item Concatenated Segments
71183 , p_source_2 IN VARCHAR2
71184 --Transaction Quantity
71185 , p_source_3 IN NUMBER
71186 --Transaction Unit of Measure Code
71187 , p_source_4 IN VARCHAR2
71188 --Inventory Transaction Type Description
71189 , p_source_5 IN VARCHAR2
71190 --Transaction Transportation Distribution Account
71191 , p_source_32 IN NUMBER
71192 --DISTRIBUTION_IDENTIFIER
71193 , p_source_84 IN NUMBER
71194 --Distribution Type
71195 , p_source_85 IN VARCHAR2
71196 , p_source_85_meaning IN VARCHAR2
71197 --Entered Currency Code
71198 , p_source_88 IN VARCHAR2
71199 --Entered Amount
71200 , p_source_91 IN NUMBER
71201 --Currency Conversion Date
71202 , p_source_92 IN DATE
71203 --Currency Conversion Rate
71204 , p_source_93 IN NUMBER
71205 --Currency Conversion Type
71206 , p_source_94 IN VARCHAR2
71207 --Accounted Amount
71208 , p_source_95 IN NUMBER
71209 --Accounting Line Type
71210 , p_source_97 IN NUMBER
71211 )
71212 IS
71213
71214 l_component_type VARCHAR2(80);
71215 l_component_code VARCHAR2(30);
71216 l_component_type_code VARCHAR2(1);
71217 l_component_appl_id INTEGER;
71218 l_amb_context_code VARCHAR2(30);
71219 l_entity_code VARCHAR2(30);
71220 l_event_class_code VARCHAR2(30);
71221 l_ae_header_id NUMBER;
71222 l_event_type_code VARCHAR2(30);
71223 l_line_definition_code VARCHAR2(30);
71224 l_line_definition_owner_code VARCHAR2(1);
71225 --
71226 -- adr variables
71227 l_segment VARCHAR2(30);
71228 l_ccid NUMBER;
71229 l_adr_transaction_coa_id NUMBER;
71230 l_adr_accounting_coa_id NUMBER;
71231 l_adr_flexfield_segment_code VARCHAR2(30);
71232 l_adr_flex_value_set_id NUMBER;
71233 l_adr_value_type_code VARCHAR2(30);
71234 l_adr_value_combination_id NUMBER;
71235 l_adr_value_segment_code VARCHAR2(30);
71236
71237 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
71238 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
71239 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
71240 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
71241
71242 -- 4262811 Variables ------------------------------------------------------------------------------------------
71243 l_entered_amt_idx NUMBER;
71244 l_accted_amt_idx NUMBER;
71245 l_acc_rev_flag VARCHAR2(1);
71246 l_accrual_line_num NUMBER;
71247 l_tmp_amt NUMBER;
71248 l_acc_rev_natural_side_code VARCHAR2(1);
71249
71250 l_num_entries NUMBER;
71251 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
71252 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
71253 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
71254 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
71255 l_recog_line_1 NUMBER;
71256 l_recog_line_2 NUMBER;
71257
71258 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
71259 l_bflow_applied_to_amt NUMBER; -- 5132302
71260 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
71261
71262 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
71263
71264 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
71265 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
71266
71267 ---------------------------------------------------------------------------------------------------------------
71268
71269
71270 --
71271 -- bulk performance
71272 --
71273 l_balance_type_code VARCHAR2(1);
71274 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
71275 l_log_module VARCHAR2(240);
71276
71277 --
71278 -- Upgrade strategy
71279 --
71280 l_actual_upg_option VARCHAR2(1);
71281 l_enc_upg_option VARCHAR2(1);
71282
71283 --
71284 BEGIN
71285 --
71286 IF g_log_enabled THEN
71287 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_150';
71288 END IF;
71289 --
71290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71291
71292 trace
71293 (p_msg => 'BEGIN of AcctLineType_150'
71294 ,p_level => C_LEVEL_PROCEDURE
71295 ,p_module => l_log_module);
71296
71297 END IF;
71298 --
71299 l_component_type := 'AMB_JLT';
71300 l_component_code := 'INTERORG_FREIGHT_CHARGE';
71301 l_component_type_code := 'S';
71302 l_component_appl_id := 707;
71303 l_amb_context_code := 'DEFAULT';
71304 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
71305 l_event_class_code := 'USER_DEFINE';
71306 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
71307 l_line_definition_owner_code := 'S';
71308 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
71309 --
71310 l_balance_type_code := 'A';
71311 l_segment := NULL;
71312 l_ccid := NULL;
71313 l_adr_transaction_coa_id := NULL;
71314 l_adr_accounting_coa_id := NULL;
71315 l_adr_flexfield_segment_code := NULL;
71316 l_adr_flex_value_set_id := NULL;
71317 l_adr_value_type_code := NULL;
71318 l_adr_value_combination_id := NULL;
71319 l_adr_value_segment_code := NULL;
71320
71321 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
71322 l_bflow_class_code := ''; -- 4219869 Business Flow
71323 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
71324 l_budgetary_control_flag := 'N';
71325
71326 l_bflow_applied_to_amt_idx := NULL; -- 5132302
71327 l_bflow_applied_to_amt := NULL; -- 5132302
71328 l_entered_amt_idx := NULL; -- 4262811
71329 l_accted_amt_idx := NULL; -- 4262811
71330 l_acc_rev_flag := NULL; -- 4262811
71331 l_accrual_line_num := NULL; -- 4262811
71332 l_tmp_amt := NULL; -- 4262811
71333 --
71334
71335 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
71336 l_balance_type_code <> 'B' THEN
71337 IF NVL(p_source_97,9E125) = 12
71338 THEN
71339
71340 --
71341 XLA_AE_LINES_PKG.SetNewLine;
71342
71343 p_balance_type_code := l_balance_type_code;
71344 -- set the flag so later we will know whether the gain loss line needs to be created
71345
71346 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
71347 p_actual_flag :='A';
71348 END IF;
71349
71350 --
71351 -- bulk performance
71352 --
71353 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
71354 p_header_num => 0); -- 4262811
71355 --
71356 -- set accounting line options
71357 --
71358 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
71359 p_natural_side_code => 'D'
71360 , p_gain_or_loss_flag => 'N'
71361 , p_gl_transfer_mode_code => 'S'
71362 , p_acct_entry_type_code => 'A'
71363 , p_switch_side_flag => 'Y'
71364 , p_merge_duplicate_code => 'N'
71365 );
71366 --
71367 l_acc_rev_natural_side_code := 'C'; -- 4262811
71368 --
71369 --
71370 -- set accounting line type info
71371 --
71372 xla_ae_lines_pkg.SetAcctLineType
71373 (p_component_type => l_component_type
71374 ,p_event_type_code => l_event_type_code
71375 ,p_line_definition_owner_code => l_line_definition_owner_code
71376 ,p_line_definition_code => l_line_definition_code
71377 ,p_accounting_line_code => l_component_code
71378 ,p_accounting_line_type_code => l_component_type_code
71379 ,p_accounting_line_appl_id => l_component_appl_id
71380 ,p_amb_context_code => l_amb_context_code
71381 ,p_entity_code => l_entity_code
71382 ,p_event_class_code => l_event_class_code);
71383 --
71384 -- set accounting class
71385 --
71386 xla_ae_lines_pkg.SetAcctClass(
71387 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
71388 , p_ae_header_id => l_ae_header_id
71389 );
71390
71391 --
71392 -- set rounding class
71393 --
71394 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
71395 'INTERORG_FREIGHT_CHARGE';
71396
71397 --
71398 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
71399 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
71400 --
71401 -- bulk performance
71402 --
71403 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
71404
71405 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
71406 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
71407
71408 -- 4955764
71409 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
71410 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
71411
71412 -- 4458381 Public Sector Enh
71413
71414 --
71415 -- set accounting attributes for the line type
71416 --
71417 l_entered_amt_idx := 3;
71418 l_accted_amt_idx := 8;
71419 l_bflow_applied_to_amt_idx := NULL; -- 5132302
71420 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
71421 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
71422 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
71423 l_rec_acct_attrs.array_char_value(2) := p_source_85;
71424 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
71425 l_rec_acct_attrs.array_num_value(3) := p_source_91;
71426 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
71427 l_rec_acct_attrs.array_char_value(4) := p_source_88;
71428 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
71429 l_rec_acct_attrs.array_date_value(5) := p_source_92;
71430 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
71431 l_rec_acct_attrs.array_num_value(6) := p_source_93;
71432 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
71433 l_rec_acct_attrs.array_char_value(7) := p_source_94;
71434 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
71435 l_rec_acct_attrs.array_num_value(8) := p_source_95;
71436
71437 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
71438 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
71439
71440 ---------------------------------------------------------------------------------------------------------------
71441 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
71442 ---------------------------------------------------------------------------------------------------------------
71443 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
71444
71445 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
71446 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
71447
71448 IF xla_accounting_cache_pkg.GetValueChar
71449 (p_source_code => 'LEDGER_CATEGORY_CODE'
71450 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
71451 AND l_bflow_method_code = 'PRIOR_ENTRY'
71452 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
71453 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
71454 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
71455 )
71456 THEN
71457 xla_ae_lines_pkg.BflowUpgEntry
71458 (p_business_method_code => l_bflow_method_code
71459 ,p_business_class_code => l_bflow_class_code
71460 ,p_balance_type => l_balance_type_code);
71461 ELSE
71462 NULL;
71463 -- No business flow processing for business flow method of NONE.
71464 END IF;
71465
71466 --
71467 -- call analytical criteria
71468 --
71469
71470 --
71471 -- call description
71472 --
71473
71474 xla_ae_lines_pkg.SetLineDescription(
71475 p_ae_header_id => l_ae_header_id
71476 ,p_description => Description_1 (
71477 p_application_id => p_application_id
71478 , p_ae_header_id => l_ae_header_id
71479 , p_source_1 => p_source_1
71480 , p_source_2 => p_source_2
71481 , p_source_3 => p_source_3
71482 , p_source_4 => p_source_4
71483 , p_source_5 => p_source_5
71484 )
71485 );
71486
71487
71488 --
71489 -- call ADRs
71490 -- Bug 4922099
71491 --
71492 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
71493 (NVL(l_actual_upg_option, 'N') = 'O') OR
71494 (NVL(l_enc_upg_option, 'N') = 'O')
71495 )
71496 THEN
71497 NULL;
71498 --
71499 --
71500
71501 l_ccid := AcctDerRule_17(
71502 p_application_id => p_application_id
71503 , p_ae_header_id => l_ae_header_id
71504 , p_source_32 => p_source_32
71505 , x_transaction_coa_id => l_adr_transaction_coa_id
71506 , x_accounting_coa_id => l_adr_accounting_coa_id
71507 , x_value_type_code => l_adr_value_type_code
71508 , p_side => 'NA'
71509 );
71510
71511 xla_ae_lines_pkg.set_ccid(
71512 p_code_combination_id => l_ccid
71513 , p_value_type_code => l_adr_value_type_code
71514 , p_transaction_coa_id => l_adr_transaction_coa_id
71515 , p_accounting_coa_id => l_adr_accounting_coa_id
71516 , p_adr_code => 'PI_FREIGHT'
71517 , p_adr_type_code => 'S'
71518 , p_component_type => l_component_type
71519 , p_component_code => l_component_code
71520 , p_component_type_code => l_component_type_code
71521 , p_component_appl_id => l_component_appl_id
71522 , p_amb_context_code => l_amb_context_code
71523 , p_side => 'NA'
71524 );
71525
71526
71527 --
71528 --
71529 END IF;
71530 --
71531 -- Bug 4922099
71532 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
71533 (NVL(l_enc_upg_option, 'N') = 'O')
71534 ) AND
71535 (l_bflow_method_code = 'PRIOR_ENTRY')
71536 )
71537 THEN
71538 IF
71539 --
71540 1 = 2
71541 --
71542 THEN
71543 xla_accounting_err_pkg.build_message
71544 (p_appli_s_name => 'XLA'
71545 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
71546 ,p_token_1 => 'LINE_NUMBER'
71547 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
71548 ,p_token_2 => 'LINE_TYPE_NAME'
71549 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
71550 l_component_type
71551 ,l_component_code
71552 ,l_component_type_code
71553 ,l_component_appl_id
71554 ,l_amb_context_code
71555 ,l_entity_code
71556 ,l_event_class_code
71557 )
71558 ,p_token_3 => 'OWNER'
71559 ,p_value_3 => xla_lookups_pkg.get_meaning(
71560 p_lookup_type => 'XLA_OWNER_TYPE'
71561 ,p_lookup_code => l_component_type_code
71562 )
71563 ,p_token_4 => 'PRODUCT_NAME'
71564 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
71565 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
71566 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
71567 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
71568 ,p_ae_header_id => NULL
71569 );
71570
71571 IF (C_LEVEL_ERROR>= g_log_level) THEN
71572 trace
71573 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
71574 ,p_level => C_LEVEL_ERROR
71575 ,p_module => l_log_module);
71576 END IF;
71577 END IF;
71578 END IF;
71579 --
71580 --
71581 ------------------------------------------------------------------------------------------------
71582 -- 4219869 Business Flow
71583 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
71584 -- Prior Entry. Currently, the following code is always generated.
71585 ------------------------------------------------------------------------------------------------
71586 XLA_AE_LINES_PKG.ValidateCurrentLine;
71587
71588 ------------------------------------------------------------------------------------
71589 -- 4219869 Business Flow
71590 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
71591 ------------------------------------------------------------------------------------
71592 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
71593
71594 ----------------------------------------------------------------------------------
71595 -- 4219869 Business Flow
71596 -- Update journal entry status -- Need to generate this within IF <condition>
71597 ----------------------------------------------------------------------------------
71598 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
71599 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
71600 ,p_balance_type_code => l_balance_type_code
71601 );
71602
71603 -------------------------------------------------------------------------------------------
71604 -- 4262811 - Generate the Accrual Reversal lines
71605 -------------------------------------------------------------------------------------------
71606 BEGIN
71607 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
71608 (g_array_event(p_event_id).array_value_num('header_index'));
71609 IF l_acc_rev_flag IS NULL THEN
71610 l_acc_rev_flag := 'N';
71611 END IF;
71612 EXCEPTION
71613 WHEN OTHERS THEN
71614 l_acc_rev_flag := 'N';
71615 END;
71616 --
71617 IF (l_acc_rev_flag = 'Y') THEN
71618
71619 -- 4645092 ------------------------------------------------------------------------------
71620 -- To allow MPA report to determine if it should generate report process
71621 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
71622 ------------------------------------------------------------------------------------------
71623
71624 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
71625 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
71626 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
71627 -- call ADRs
71628 -- Bug 4922099
71629 --
71630 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
71631 (NVL(l_actual_upg_option, 'N') = 'O') OR
71632 (NVL(l_enc_upg_option, 'N') = 'O')
71633 )
71634 THEN
71635 NULL;
71636 --
71637 --
71638
71639 l_ccid := AcctDerRule_17(
71640 p_application_id => p_application_id
71641 , p_ae_header_id => l_ae_header_id
71642 , p_source_32 => p_source_32
71643 , x_transaction_coa_id => l_adr_transaction_coa_id
71644 , x_accounting_coa_id => l_adr_accounting_coa_id
71645 , x_value_type_code => l_adr_value_type_code
71646 , p_side => 'NA'
71647 );
71648
71649 xla_ae_lines_pkg.set_ccid(
71650 p_code_combination_id => l_ccid
71651 , p_value_type_code => l_adr_value_type_code
71652 , p_transaction_coa_id => l_adr_transaction_coa_id
71653 , p_accounting_coa_id => l_adr_accounting_coa_id
71654 , p_adr_code => 'PI_FREIGHT'
71655 , p_adr_type_code => 'S'
71656 , p_component_type => l_component_type
71657 , p_component_code => l_component_code
71658 , p_component_type_code => l_component_type_code
71659 , p_component_appl_id => l_component_appl_id
71660 , p_amb_context_code => l_amb_context_code
71661 , p_side => 'NA'
71662 );
71663
71664
71665 --
71666 --
71667 END IF;
71668
71669 --
71670 -- Update the line information that should be overwritten
71671 --
71672 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
71673 p_header_num => 1);
71674 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
71675
71676 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
71677
71678 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
71679 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
71680 END IF;
71681
71682 --
71683 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
71684 --
71685 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
71686 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
71687 ELSE
71688 ---------------------------------------------------------------------------------------------------
71689 -- 4262811a Switch Sign
71690 ---------------------------------------------------------------------------------------------------
71691 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
71692 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
71693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71694 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
71695 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71696 -- 5132302
71697 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
71698 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
71699
71700 END IF;
71701
71702 -- 4955764
71703 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
71704 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
71705
71706
71707 XLA_AE_LINES_PKG.ValidateCurrentLine;
71708 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
71709
71710 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
71711 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
71712 ,p_balance_type_code => l_balance_type_code);
71713
71714 END IF;
71715
71716 -----------------------------------------------------------------------------------------
71717 -- 4262811 Multiperiod Accounting
71718 -----------------------------------------------------------------------------------------
71719 -- No MPA option is assigned.
71720
71721
71722 END IF;
71723 END IF;
71724 --
71725
71726 --
71727 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71728 trace
71729 (p_msg => 'END of AcctLineType_150'
71730 ,p_level => C_LEVEL_PROCEDURE
71731 ,p_module => l_log_module);
71732 END IF;
71733 --
71734 EXCEPTION
71735 WHEN xla_exceptions_pkg.application_exception THEN
71736 RAISE;
71737 WHEN OTHERS THEN
71738 xla_exceptions_pkg.raise_message
71739 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_150');
71740 END AcctLineType_150;
71741 --
71742
71743 ---------------------------------------
71744 --
71745 -- PRIVATE FUNCTION
71746 -- AcctLineType_151
71747 --
71748 ---------------------------------------
71749 PROCEDURE AcctLineType_151 (
71750 p_application_id IN NUMBER
71751 ,p_event_id IN NUMBER
71752 ,p_calculate_acctd_flag IN VARCHAR2
71753 ,p_calculate_g_l_flag IN VARCHAR2
71754 ,p_actual_flag IN OUT VARCHAR2
71755 ,p_balance_type_code OUT VARCHAR2
71756 ,p_gain_or_loss_ref OUT VARCHAR2
71757
71758 --TRANSACTION_ID
71759 , p_source_1 IN NUMBER
71760 --Item Concatenated Segments
71761 , p_source_2 IN VARCHAR2
71762 --Transaction Quantity
71763 , p_source_3 IN NUMBER
71764 --Transaction Unit of Measure Code
71765 , p_source_4 IN VARCHAR2
71766 --Inventory Transaction Type Description
71767 , p_source_5 IN VARCHAR2
71768 --Transaction Transportation Distribution Account
71769 , p_source_32 IN NUMBER
71770 --DISTRIBUTION_IDENTIFIER
71771 , p_source_84 IN NUMBER
71772 --Distribution Type
71773 , p_source_85 IN VARCHAR2
71774 , p_source_85_meaning IN VARCHAR2
71775 --Entered Currency Code
71776 , p_source_88 IN VARCHAR2
71777 --Entered Amount
71778 , p_source_91 IN NUMBER
71779 --Currency Conversion Date
71780 , p_source_92 IN DATE
71781 --Currency Conversion Rate
71782 , p_source_93 IN NUMBER
71783 --Currency Conversion Type
71784 , p_source_94 IN VARCHAR2
71785 --Accounted Amount
71786 , p_source_95 IN NUMBER
71787 --Accounting Line Type
71788 , p_source_97 IN NUMBER
71789 )
71790 IS
71791
71792 l_component_type VARCHAR2(80);
71793 l_component_code VARCHAR2(30);
71794 l_component_type_code VARCHAR2(1);
71795 l_component_appl_id INTEGER;
71796 l_amb_context_code VARCHAR2(30);
71797 l_entity_code VARCHAR2(30);
71798 l_event_class_code VARCHAR2(30);
71799 l_ae_header_id NUMBER;
71800 l_event_type_code VARCHAR2(30);
71801 l_line_definition_code VARCHAR2(30);
71802 l_line_definition_owner_code VARCHAR2(1);
71803 --
71804 -- adr variables
71805 l_segment VARCHAR2(30);
71806 l_ccid NUMBER;
71807 l_adr_transaction_coa_id NUMBER;
71808 l_adr_accounting_coa_id NUMBER;
71809 l_adr_flexfield_segment_code VARCHAR2(30);
71810 l_adr_flex_value_set_id NUMBER;
71811 l_adr_value_type_code VARCHAR2(30);
71812 l_adr_value_combination_id NUMBER;
71813 l_adr_value_segment_code VARCHAR2(30);
71814
71815 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
71816 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
71817 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
71818 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
71819
71820 -- 4262811 Variables ------------------------------------------------------------------------------------------
71821 l_entered_amt_idx NUMBER;
71822 l_accted_amt_idx NUMBER;
71823 l_acc_rev_flag VARCHAR2(1);
71824 l_accrual_line_num NUMBER;
71825 l_tmp_amt NUMBER;
71826 l_acc_rev_natural_side_code VARCHAR2(1);
71827
71828 l_num_entries NUMBER;
71829 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
71830 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
71831 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
71832 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
71833 l_recog_line_1 NUMBER;
71834 l_recog_line_2 NUMBER;
71835
71836 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
71837 l_bflow_applied_to_amt NUMBER; -- 5132302
71838 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
71839
71840 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
71841
71842 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
71843 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
71844
71845 ---------------------------------------------------------------------------------------------------------------
71846
71847
71848 --
71849 -- bulk performance
71850 --
71851 l_balance_type_code VARCHAR2(1);
71852 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
71853 l_log_module VARCHAR2(240);
71854
71855 --
71856 -- Upgrade strategy
71857 --
71858 l_actual_upg_option VARCHAR2(1);
71859 l_enc_upg_option VARCHAR2(1);
71860
71861 --
71862 BEGIN
71863 --
71864 IF g_log_enabled THEN
71865 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_151';
71866 END IF;
71867 --
71868 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71869
71870 trace
71871 (p_msg => 'BEGIN of AcctLineType_151'
71872 ,p_level => C_LEVEL_PROCEDURE
71873 ,p_module => l_log_module);
71874
71875 END IF;
71876 --
71877 l_component_type := 'AMB_JLT';
71878 l_component_code := 'INTERORG_FREIGHT_CHARGE';
71879 l_component_type_code := 'S';
71880 l_component_appl_id := 707;
71881 l_amb_context_code := 'DEFAULT';
71882 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
71883 l_event_class_code := 'USER_DEFINE';
71884 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
71885 l_line_definition_owner_code := 'S';
71886 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
71887 --
71888 l_balance_type_code := 'A';
71889 l_segment := NULL;
71890 l_ccid := NULL;
71891 l_adr_transaction_coa_id := NULL;
71892 l_adr_accounting_coa_id := NULL;
71893 l_adr_flexfield_segment_code := NULL;
71894 l_adr_flex_value_set_id := NULL;
71895 l_adr_value_type_code := NULL;
71896 l_adr_value_combination_id := NULL;
71897 l_adr_value_segment_code := NULL;
71898
71899 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
71900 l_bflow_class_code := ''; -- 4219869 Business Flow
71901 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
71902 l_budgetary_control_flag := 'N';
71903
71904 l_bflow_applied_to_amt_idx := NULL; -- 5132302
71905 l_bflow_applied_to_amt := NULL; -- 5132302
71906 l_entered_amt_idx := NULL; -- 4262811
71907 l_accted_amt_idx := NULL; -- 4262811
71908 l_acc_rev_flag := NULL; -- 4262811
71909 l_accrual_line_num := NULL; -- 4262811
71910 l_tmp_amt := NULL; -- 4262811
71911 --
71912
71913 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
71914 l_balance_type_code <> 'B' THEN
71915 IF NVL(p_source_97,9E125) = 12
71916 THEN
71917
71918 --
71919 XLA_AE_LINES_PKG.SetNewLine;
71920
71921 p_balance_type_code := l_balance_type_code;
71922 -- set the flag so later we will know whether the gain loss line needs to be created
71923
71924 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
71925 p_actual_flag :='A';
71926 END IF;
71927
71928 --
71929 -- bulk performance
71930 --
71931 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
71932 p_header_num => 0); -- 4262811
71933 --
71934 -- set accounting line options
71935 --
71936 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
71937 p_natural_side_code => 'D'
71938 , p_gain_or_loss_flag => 'N'
71939 , p_gl_transfer_mode_code => 'S'
71940 , p_acct_entry_type_code => 'A'
71941 , p_switch_side_flag => 'Y'
71942 , p_merge_duplicate_code => 'N'
71943 );
71944 --
71945 l_acc_rev_natural_side_code := 'C'; -- 4262811
71946 --
71947 --
71948 -- set accounting line type info
71949 --
71950 xla_ae_lines_pkg.SetAcctLineType
71951 (p_component_type => l_component_type
71952 ,p_event_type_code => l_event_type_code
71953 ,p_line_definition_owner_code => l_line_definition_owner_code
71954 ,p_line_definition_code => l_line_definition_code
71955 ,p_accounting_line_code => l_component_code
71956 ,p_accounting_line_type_code => l_component_type_code
71957 ,p_accounting_line_appl_id => l_component_appl_id
71958 ,p_amb_context_code => l_amb_context_code
71959 ,p_entity_code => l_entity_code
71960 ,p_event_class_code => l_event_class_code);
71961 --
71962 -- set accounting class
71963 --
71964 xla_ae_lines_pkg.SetAcctClass(
71965 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
71966 , p_ae_header_id => l_ae_header_id
71967 );
71968
71969 --
71970 -- set rounding class
71971 --
71972 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
71973 'INTERORG_FREIGHT_CHARGE';
71974
71975 --
71976 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
71977 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
71978 --
71979 -- bulk performance
71980 --
71981 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
71982
71983 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
71984 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
71985
71986 -- 4955764
71987 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
71988 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
71989
71990 -- 4458381 Public Sector Enh
71991
71992 --
71993 -- set accounting attributes for the line type
71994 --
71995 l_entered_amt_idx := 3;
71996 l_accted_amt_idx := 8;
71997 l_bflow_applied_to_amt_idx := NULL; -- 5132302
71998 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
71999 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
72000 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
72001 l_rec_acct_attrs.array_char_value(2) := p_source_85;
72002 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
72003 l_rec_acct_attrs.array_num_value(3) := p_source_91;
72004 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
72005 l_rec_acct_attrs.array_char_value(4) := p_source_88;
72006 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
72007 l_rec_acct_attrs.array_date_value(5) := p_source_92;
72008 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
72009 l_rec_acct_attrs.array_num_value(6) := p_source_93;
72010 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
72011 l_rec_acct_attrs.array_char_value(7) := p_source_94;
72012 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
72013 l_rec_acct_attrs.array_num_value(8) := p_source_95;
72014
72015 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
72016 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
72017
72018 ---------------------------------------------------------------------------------------------------------------
72019 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
72020 ---------------------------------------------------------------------------------------------------------------
72021 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
72022
72023 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
72024 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
72025
72026 IF xla_accounting_cache_pkg.GetValueChar
72027 (p_source_code => 'LEDGER_CATEGORY_CODE'
72028 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
72029 AND l_bflow_method_code = 'PRIOR_ENTRY'
72030 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
72031 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
72032 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
72033 )
72034 THEN
72035 xla_ae_lines_pkg.BflowUpgEntry
72036 (p_business_method_code => l_bflow_method_code
72037 ,p_business_class_code => l_bflow_class_code
72038 ,p_balance_type => l_balance_type_code);
72039 ELSE
72040 NULL;
72041 -- No business flow processing for business flow method of NONE.
72042 END IF;
72043
72044 --
72045 -- call analytical criteria
72046 --
72047
72048 --
72049 -- call description
72050 --
72051
72052 xla_ae_lines_pkg.SetLineDescription(
72053 p_ae_header_id => l_ae_header_id
72054 ,p_description => Description_1 (
72055 p_application_id => p_application_id
72056 , p_ae_header_id => l_ae_header_id
72057 , p_source_1 => p_source_1
72058 , p_source_2 => p_source_2
72059 , p_source_3 => p_source_3
72060 , p_source_4 => p_source_4
72061 , p_source_5 => p_source_5
72062 )
72063 );
72064
72065
72066 --
72067 -- call ADRs
72068 -- Bug 4922099
72069 --
72070 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
72071 (NVL(l_actual_upg_option, 'N') = 'O') OR
72072 (NVL(l_enc_upg_option, 'N') = 'O')
72073 )
72074 THEN
72075 NULL;
72076 --
72077 --
72078
72079 l_ccid := AcctDerRule_17(
72080 p_application_id => p_application_id
72081 , p_ae_header_id => l_ae_header_id
72082 , p_source_32 => p_source_32
72083 , x_transaction_coa_id => l_adr_transaction_coa_id
72084 , x_accounting_coa_id => l_adr_accounting_coa_id
72085 , x_value_type_code => l_adr_value_type_code
72086 , p_side => 'NA'
72087 );
72088
72089 xla_ae_lines_pkg.set_ccid(
72090 p_code_combination_id => l_ccid
72091 , p_value_type_code => l_adr_value_type_code
72092 , p_transaction_coa_id => l_adr_transaction_coa_id
72093 , p_accounting_coa_id => l_adr_accounting_coa_id
72094 , p_adr_code => 'PI_FREIGHT'
72095 , p_adr_type_code => 'S'
72096 , p_component_type => l_component_type
72097 , p_component_code => l_component_code
72098 , p_component_type_code => l_component_type_code
72099 , p_component_appl_id => l_component_appl_id
72100 , p_amb_context_code => l_amb_context_code
72101 , p_side => 'NA'
72102 );
72103
72104
72105 --
72106 --
72107 END IF;
72108 --
72109 -- Bug 4922099
72110 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
72111 (NVL(l_enc_upg_option, 'N') = 'O')
72112 ) AND
72113 (l_bflow_method_code = 'PRIOR_ENTRY')
72114 )
72115 THEN
72116 IF
72117 --
72118 1 = 2
72119 --
72120 THEN
72121 xla_accounting_err_pkg.build_message
72122 (p_appli_s_name => 'XLA'
72123 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
72124 ,p_token_1 => 'LINE_NUMBER'
72125 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
72126 ,p_token_2 => 'LINE_TYPE_NAME'
72127 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
72128 l_component_type
72129 ,l_component_code
72130 ,l_component_type_code
72131 ,l_component_appl_id
72132 ,l_amb_context_code
72133 ,l_entity_code
72134 ,l_event_class_code
72135 )
72136 ,p_token_3 => 'OWNER'
72137 ,p_value_3 => xla_lookups_pkg.get_meaning(
72138 p_lookup_type => 'XLA_OWNER_TYPE'
72139 ,p_lookup_code => l_component_type_code
72140 )
72141 ,p_token_4 => 'PRODUCT_NAME'
72142 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
72143 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
72144 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
72145 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
72146 ,p_ae_header_id => NULL
72147 );
72148
72149 IF (C_LEVEL_ERROR>= g_log_level) THEN
72150 trace
72151 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
72152 ,p_level => C_LEVEL_ERROR
72153 ,p_module => l_log_module);
72154 END IF;
72155 END IF;
72156 END IF;
72157 --
72158 --
72159 ------------------------------------------------------------------------------------------------
72160 -- 4219869 Business Flow
72161 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
72162 -- Prior Entry. Currently, the following code is always generated.
72163 ------------------------------------------------------------------------------------------------
72164 XLA_AE_LINES_PKG.ValidateCurrentLine;
72165
72166 ------------------------------------------------------------------------------------
72167 -- 4219869 Business Flow
72168 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
72169 ------------------------------------------------------------------------------------
72170 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
72171
72172 ----------------------------------------------------------------------------------
72173 -- 4219869 Business Flow
72174 -- Update journal entry status -- Need to generate this within IF <condition>
72175 ----------------------------------------------------------------------------------
72176 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
72177 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
72178 ,p_balance_type_code => l_balance_type_code
72179 );
72180
72181 -------------------------------------------------------------------------------------------
72182 -- 4262811 - Generate the Accrual Reversal lines
72183 -------------------------------------------------------------------------------------------
72184 BEGIN
72185 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
72186 (g_array_event(p_event_id).array_value_num('header_index'));
72187 IF l_acc_rev_flag IS NULL THEN
72188 l_acc_rev_flag := 'N';
72189 END IF;
72190 EXCEPTION
72191 WHEN OTHERS THEN
72192 l_acc_rev_flag := 'N';
72193 END;
72194 --
72195 IF (l_acc_rev_flag = 'Y') THEN
72196
72197 -- 4645092 ------------------------------------------------------------------------------
72198 -- To allow MPA report to determine if it should generate report process
72199 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
72200 ------------------------------------------------------------------------------------------
72201
72202 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
72203 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
72204 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
72205 -- call ADRs
72206 -- Bug 4922099
72207 --
72208 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
72209 (NVL(l_actual_upg_option, 'N') = 'O') OR
72210 (NVL(l_enc_upg_option, 'N') = 'O')
72211 )
72212 THEN
72213 NULL;
72214 --
72215 --
72216
72217 l_ccid := AcctDerRule_17(
72218 p_application_id => p_application_id
72219 , p_ae_header_id => l_ae_header_id
72220 , p_source_32 => p_source_32
72221 , x_transaction_coa_id => l_adr_transaction_coa_id
72222 , x_accounting_coa_id => l_adr_accounting_coa_id
72223 , x_value_type_code => l_adr_value_type_code
72224 , p_side => 'NA'
72225 );
72226
72227 xla_ae_lines_pkg.set_ccid(
72228 p_code_combination_id => l_ccid
72229 , p_value_type_code => l_adr_value_type_code
72230 , p_transaction_coa_id => l_adr_transaction_coa_id
72231 , p_accounting_coa_id => l_adr_accounting_coa_id
72232 , p_adr_code => 'PI_FREIGHT'
72233 , p_adr_type_code => 'S'
72234 , p_component_type => l_component_type
72235 , p_component_code => l_component_code
72236 , p_component_type_code => l_component_type_code
72237 , p_component_appl_id => l_component_appl_id
72238 , p_amb_context_code => l_amb_context_code
72239 , p_side => 'NA'
72240 );
72241
72242
72243 --
72244 --
72245 END IF;
72246
72247 --
72248 -- Update the line information that should be overwritten
72249 --
72250 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
72251 p_header_num => 1);
72252 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
72253
72254 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
72255
72256 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
72257 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
72258 END IF;
72259
72260 --
72261 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
72262 --
72263 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
72264 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
72265 ELSE
72266 ---------------------------------------------------------------------------------------------------
72267 -- 4262811a Switch Sign
72268 ---------------------------------------------------------------------------------------------------
72269 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
72270 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
72271 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72272 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
72273 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72274 -- 5132302
72275 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
72276 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72277
72278 END IF;
72279
72280 -- 4955764
72281 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
72282 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
72283
72284
72285 XLA_AE_LINES_PKG.ValidateCurrentLine;
72286 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
72287
72288 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
72289 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
72290 ,p_balance_type_code => l_balance_type_code);
72291
72292 END IF;
72293
72294 -----------------------------------------------------------------------------------------
72295 -- 4262811 Multiperiod Accounting
72296 -----------------------------------------------------------------------------------------
72297 -- No MPA option is assigned.
72298
72299
72300 END IF;
72301 END IF;
72302 --
72303
72304 --
72305 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72306 trace
72307 (p_msg => 'END of AcctLineType_151'
72308 ,p_level => C_LEVEL_PROCEDURE
72309 ,p_module => l_log_module);
72310 END IF;
72311 --
72312 EXCEPTION
72313 WHEN xla_exceptions_pkg.application_exception THEN
72314 RAISE;
72315 WHEN OTHERS THEN
72316 xla_exceptions_pkg.raise_message
72317 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_151');
72318 END AcctLineType_151;
72319 --
72320
72321 ---------------------------------------
72322 --
72323 -- PRIVATE FUNCTION
72324 -- AcctLineType_152
72325 --
72326 ---------------------------------------
72327 PROCEDURE AcctLineType_152 (
72328 p_application_id IN NUMBER
72329 ,p_event_id IN NUMBER
72330 ,p_calculate_acctd_flag IN VARCHAR2
72331 ,p_calculate_g_l_flag IN VARCHAR2
72332 ,p_actual_flag IN OUT VARCHAR2
72333 ,p_balance_type_code OUT VARCHAR2
72334 ,p_gain_or_loss_ref OUT VARCHAR2
72335
72336 --TRANSACTION_ID
72337 , p_source_1 IN NUMBER
72338 --Item Concatenated Segments
72339 , p_source_2 IN VARCHAR2
72340 --Transaction Quantity
72341 , p_source_3 IN NUMBER
72342 --Transaction Unit of Measure Code
72343 , p_source_4 IN VARCHAR2
72344 --Inventory Transaction Type Description
72345 , p_source_5 IN VARCHAR2
72346 --Cost Management Default Account
72347 , p_source_11 IN NUMBER
72348 --DISTRIBUTION_IDENTIFIER
72349 , p_source_84 IN NUMBER
72350 --Distribution Type
72351 , p_source_85 IN VARCHAR2
72352 , p_source_85_meaning IN VARCHAR2
72353 --Entered Currency Code
72354 , p_source_88 IN VARCHAR2
72355 --Entered Amount
72356 , p_source_91 IN NUMBER
72357 --Currency Conversion Date
72358 , p_source_92 IN DATE
72359 --Currency Conversion Rate
72360 , p_source_93 IN NUMBER
72361 --Currency Conversion Type
72362 , p_source_94 IN VARCHAR2
72363 --Accounted Amount
72364 , p_source_95 IN NUMBER
72365 --Accounting Line Type
72366 , p_source_97 IN NUMBER
72367 )
72368 IS
72369
72370 l_component_type VARCHAR2(80);
72371 l_component_code VARCHAR2(30);
72372 l_component_type_code VARCHAR2(1);
72373 l_component_appl_id INTEGER;
72374 l_amb_context_code VARCHAR2(30);
72375 l_entity_code VARCHAR2(30);
72376 l_event_class_code VARCHAR2(30);
72377 l_ae_header_id NUMBER;
72378 l_event_type_code VARCHAR2(30);
72379 l_line_definition_code VARCHAR2(30);
72380 l_line_definition_owner_code VARCHAR2(1);
72381 --
72382 -- adr variables
72383 l_segment VARCHAR2(30);
72384 l_ccid NUMBER;
72385 l_adr_transaction_coa_id NUMBER;
72386 l_adr_accounting_coa_id NUMBER;
72387 l_adr_flexfield_segment_code VARCHAR2(30);
72388 l_adr_flex_value_set_id NUMBER;
72389 l_adr_value_type_code VARCHAR2(30);
72390 l_adr_value_combination_id NUMBER;
72391 l_adr_value_segment_code VARCHAR2(30);
72392
72393 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
72394 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
72395 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
72396 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
72397
72398 -- 4262811 Variables ------------------------------------------------------------------------------------------
72399 l_entered_amt_idx NUMBER;
72400 l_accted_amt_idx NUMBER;
72401 l_acc_rev_flag VARCHAR2(1);
72402 l_accrual_line_num NUMBER;
72403 l_tmp_amt NUMBER;
72404 l_acc_rev_natural_side_code VARCHAR2(1);
72405
72406 l_num_entries NUMBER;
72407 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
72408 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
72409 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
72410 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
72411 l_recog_line_1 NUMBER;
72412 l_recog_line_2 NUMBER;
72413
72414 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
72415 l_bflow_applied_to_amt NUMBER; -- 5132302
72416 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
72417
72418 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
72419
72420 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
72421 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
72422
72423 ---------------------------------------------------------------------------------------------------------------
72424
72425
72426 --
72427 -- bulk performance
72428 --
72429 l_balance_type_code VARCHAR2(1);
72430 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
72431 l_log_module VARCHAR2(240);
72432
72433 --
72434 -- Upgrade strategy
72435 --
72436 l_actual_upg_option VARCHAR2(1);
72437 l_enc_upg_option VARCHAR2(1);
72438
72439 --
72440 BEGIN
72441 --
72442 IF g_log_enabled THEN
72443 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_152';
72444 END IF;
72445 --
72446 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72447
72448 trace
72449 (p_msg => 'BEGIN of AcctLineType_152'
72450 ,p_level => C_LEVEL_PROCEDURE
72451 ,p_module => l_log_module);
72452
72453 END IF;
72454 --
72455 l_component_type := 'AMB_JLT';
72456 l_component_code := 'INTERORG_FREIGHT_CHARGE';
72457 l_component_type_code := 'S';
72458 l_component_appl_id := 707;
72459 l_amb_context_code := 'DEFAULT';
72460 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
72461 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
72462 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
72463 l_line_definition_owner_code := 'S';
72464 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
72465 --
72466 l_balance_type_code := 'A';
72467 l_segment := NULL;
72468 l_ccid := NULL;
72469 l_adr_transaction_coa_id := NULL;
72470 l_adr_accounting_coa_id := NULL;
72471 l_adr_flexfield_segment_code := NULL;
72472 l_adr_flex_value_set_id := NULL;
72473 l_adr_value_type_code := NULL;
72474 l_adr_value_combination_id := NULL;
72475 l_adr_value_segment_code := NULL;
72476
72477 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
72478 l_bflow_class_code := ''; -- 4219869 Business Flow
72479 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
72480 l_budgetary_control_flag := 'N';
72481
72482 l_bflow_applied_to_amt_idx := NULL; -- 5132302
72483 l_bflow_applied_to_amt := NULL; -- 5132302
72484 l_entered_amt_idx := NULL; -- 4262811
72485 l_accted_amt_idx := NULL; -- 4262811
72486 l_acc_rev_flag := NULL; -- 4262811
72487 l_accrual_line_num := NULL; -- 4262811
72488 l_tmp_amt := NULL; -- 4262811
72489 --
72490
72491 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
72492 l_balance_type_code <> 'B' THEN
72493 IF NVL(p_source_97,9E125) = 12
72494 THEN
72495
72496 --
72497 XLA_AE_LINES_PKG.SetNewLine;
72498
72499 p_balance_type_code := l_balance_type_code;
72500 -- set the flag so later we will know whether the gain loss line needs to be created
72501
72502 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
72503 p_actual_flag :='A';
72504 END IF;
72505
72506 --
72507 -- bulk performance
72508 --
72509 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
72510 p_header_num => 0); -- 4262811
72511 --
72512 -- set accounting line options
72513 --
72514 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
72515 p_natural_side_code => 'D'
72516 , p_gain_or_loss_flag => 'N'
72517 , p_gl_transfer_mode_code => 'S'
72518 , p_acct_entry_type_code => 'A'
72519 , p_switch_side_flag => 'Y'
72520 , p_merge_duplicate_code => 'N'
72521 );
72522 --
72523 l_acc_rev_natural_side_code := 'C'; -- 4262811
72524 --
72525 --
72526 -- set accounting line type info
72527 --
72528 xla_ae_lines_pkg.SetAcctLineType
72529 (p_component_type => l_component_type
72530 ,p_event_type_code => l_event_type_code
72531 ,p_line_definition_owner_code => l_line_definition_owner_code
72532 ,p_line_definition_code => l_line_definition_code
72533 ,p_accounting_line_code => l_component_code
72534 ,p_accounting_line_type_code => l_component_type_code
72535 ,p_accounting_line_appl_id => l_component_appl_id
72536 ,p_amb_context_code => l_amb_context_code
72537 ,p_entity_code => l_entity_code
72538 ,p_event_class_code => l_event_class_code);
72539 --
72540 -- set accounting class
72541 --
72542 xla_ae_lines_pkg.SetAcctClass(
72543 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
72544 , p_ae_header_id => l_ae_header_id
72545 );
72546
72547 --
72548 -- set rounding class
72549 --
72550 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
72551 'INTERORG_FREIGHT_CHARGE';
72552
72553 --
72554 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
72555 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
72556 --
72557 -- bulk performance
72558 --
72559 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
72560
72561 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
72562 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
72563
72564 -- 4955764
72565 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
72566 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
72567
72568 -- 4458381 Public Sector Enh
72569
72570 --
72571 -- set accounting attributes for the line type
72572 --
72573 l_entered_amt_idx := 3;
72574 l_accted_amt_idx := 8;
72575 l_bflow_applied_to_amt_idx := NULL; -- 5132302
72576 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
72577 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
72578 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
72579 l_rec_acct_attrs.array_char_value(2) := p_source_85;
72580 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
72581 l_rec_acct_attrs.array_num_value(3) := p_source_91;
72582 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
72583 l_rec_acct_attrs.array_char_value(4) := p_source_88;
72584 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
72585 l_rec_acct_attrs.array_date_value(5) := p_source_92;
72586 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
72587 l_rec_acct_attrs.array_num_value(6) := p_source_93;
72588 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
72589 l_rec_acct_attrs.array_char_value(7) := p_source_94;
72590 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
72591 l_rec_acct_attrs.array_num_value(8) := p_source_95;
72592
72593 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
72594 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
72595
72596 ---------------------------------------------------------------------------------------------------------------
72597 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
72598 ---------------------------------------------------------------------------------------------------------------
72599 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
72600
72601 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
72602 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
72603
72604 IF xla_accounting_cache_pkg.GetValueChar
72605 (p_source_code => 'LEDGER_CATEGORY_CODE'
72606 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
72607 AND l_bflow_method_code = 'PRIOR_ENTRY'
72608 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
72609 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
72610 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
72611 )
72612 THEN
72613 xla_ae_lines_pkg.BflowUpgEntry
72614 (p_business_method_code => l_bflow_method_code
72615 ,p_business_class_code => l_bflow_class_code
72616 ,p_balance_type => l_balance_type_code);
72617 ELSE
72618 NULL;
72619 -- No business flow processing for business flow method of NONE.
72620 END IF;
72621
72622 --
72623 -- call analytical criteria
72624 --
72625
72626 --
72627 -- call description
72628 --
72629
72630 xla_ae_lines_pkg.SetLineDescription(
72631 p_ae_header_id => l_ae_header_id
72632 ,p_description => Description_1 (
72633 p_application_id => p_application_id
72634 , p_ae_header_id => l_ae_header_id
72635 , p_source_1 => p_source_1
72636 , p_source_2 => p_source_2
72637 , p_source_3 => p_source_3
72638 , p_source_4 => p_source_4
72639 , p_source_5 => p_source_5
72640 )
72641 );
72642
72643
72644 --
72645 -- call ADRs
72646 -- Bug 4922099
72647 --
72648 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
72649 (NVL(l_actual_upg_option, 'N') = 'O') OR
72650 (NVL(l_enc_upg_option, 'N') = 'O')
72651 )
72652 THEN
72653 NULL;
72654 --
72655 --
72656
72657 l_ccid := AcctDerRule_6(
72658 p_application_id => p_application_id
72659 , p_ae_header_id => l_ae_header_id
72660 , p_source_11 => p_source_11
72661 , x_transaction_coa_id => l_adr_transaction_coa_id
72662 , x_accounting_coa_id => l_adr_accounting_coa_id
72663 , x_value_type_code => l_adr_value_type_code
72664 , p_side => 'NA'
72665 );
72666
72667 xla_ae_lines_pkg.set_ccid(
72668 p_code_combination_id => l_ccid
72669 , p_value_type_code => l_adr_value_type_code
72670 , p_transaction_coa_id => l_adr_transaction_coa_id
72671 , p_accounting_coa_id => l_adr_accounting_coa_id
72672 , p_adr_code => 'CST_DEFAULT'
72673 , p_adr_type_code => 'S'
72674 , p_component_type => l_component_type
72675 , p_component_code => l_component_code
72676 , p_component_type_code => l_component_type_code
72677 , p_component_appl_id => l_component_appl_id
72678 , p_amb_context_code => l_amb_context_code
72679 , p_side => 'NA'
72680 );
72681
72682
72683 --
72684 --
72685 END IF;
72686 --
72687 -- Bug 4922099
72688 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
72689 (NVL(l_enc_upg_option, 'N') = 'O')
72690 ) AND
72691 (l_bflow_method_code = 'PRIOR_ENTRY')
72692 )
72693 THEN
72694 IF
72695 --
72696 1 = 2
72697 --
72698 THEN
72699 xla_accounting_err_pkg.build_message
72700 (p_appli_s_name => 'XLA'
72701 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
72702 ,p_token_1 => 'LINE_NUMBER'
72703 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
72704 ,p_token_2 => 'LINE_TYPE_NAME'
72705 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
72706 l_component_type
72707 ,l_component_code
72708 ,l_component_type_code
72709 ,l_component_appl_id
72710 ,l_amb_context_code
72711 ,l_entity_code
72712 ,l_event_class_code
72713 )
72714 ,p_token_3 => 'OWNER'
72715 ,p_value_3 => xla_lookups_pkg.get_meaning(
72716 p_lookup_type => 'XLA_OWNER_TYPE'
72717 ,p_lookup_code => l_component_type_code
72718 )
72719 ,p_token_4 => 'PRODUCT_NAME'
72720 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
72721 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
72722 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
72723 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
72724 ,p_ae_header_id => NULL
72725 );
72726
72727 IF (C_LEVEL_ERROR>= g_log_level) THEN
72728 trace
72729 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
72730 ,p_level => C_LEVEL_ERROR
72731 ,p_module => l_log_module);
72732 END IF;
72733 END IF;
72734 END IF;
72735 --
72736 --
72737 ------------------------------------------------------------------------------------------------
72738 -- 4219869 Business Flow
72739 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
72740 -- Prior Entry. Currently, the following code is always generated.
72741 ------------------------------------------------------------------------------------------------
72742 XLA_AE_LINES_PKG.ValidateCurrentLine;
72743
72744 ------------------------------------------------------------------------------------
72745 -- 4219869 Business Flow
72746 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
72747 ------------------------------------------------------------------------------------
72748 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
72749
72750 ----------------------------------------------------------------------------------
72751 -- 4219869 Business Flow
72752 -- Update journal entry status -- Need to generate this within IF <condition>
72753 ----------------------------------------------------------------------------------
72754 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
72755 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
72756 ,p_balance_type_code => l_balance_type_code
72757 );
72758
72759 -------------------------------------------------------------------------------------------
72760 -- 4262811 - Generate the Accrual Reversal lines
72761 -------------------------------------------------------------------------------------------
72762 BEGIN
72763 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
72764 (g_array_event(p_event_id).array_value_num('header_index'));
72765 IF l_acc_rev_flag IS NULL THEN
72766 l_acc_rev_flag := 'N';
72767 END IF;
72768 EXCEPTION
72769 WHEN OTHERS THEN
72770 l_acc_rev_flag := 'N';
72771 END;
72772 --
72773 IF (l_acc_rev_flag = 'Y') THEN
72774
72775 -- 4645092 ------------------------------------------------------------------------------
72776 -- To allow MPA report to determine if it should generate report process
72777 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
72778 ------------------------------------------------------------------------------------------
72779
72780 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
72781 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
72782 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
72783 -- call ADRs
72784 -- Bug 4922099
72785 --
72786 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
72787 (NVL(l_actual_upg_option, 'N') = 'O') OR
72788 (NVL(l_enc_upg_option, 'N') = 'O')
72789 )
72790 THEN
72791 NULL;
72792 --
72793 --
72794
72795 l_ccid := AcctDerRule_6(
72796 p_application_id => p_application_id
72797 , p_ae_header_id => l_ae_header_id
72798 , p_source_11 => p_source_11
72799 , x_transaction_coa_id => l_adr_transaction_coa_id
72800 , x_accounting_coa_id => l_adr_accounting_coa_id
72801 , x_value_type_code => l_adr_value_type_code
72802 , p_side => 'NA'
72803 );
72804
72805 xla_ae_lines_pkg.set_ccid(
72806 p_code_combination_id => l_ccid
72807 , p_value_type_code => l_adr_value_type_code
72808 , p_transaction_coa_id => l_adr_transaction_coa_id
72809 , p_accounting_coa_id => l_adr_accounting_coa_id
72810 , p_adr_code => 'CST_DEFAULT'
72811 , p_adr_type_code => 'S'
72812 , p_component_type => l_component_type
72813 , p_component_code => l_component_code
72814 , p_component_type_code => l_component_type_code
72815 , p_component_appl_id => l_component_appl_id
72816 , p_amb_context_code => l_amb_context_code
72817 , p_side => 'NA'
72818 );
72819
72820
72821 --
72822 --
72823 END IF;
72824
72825 --
72826 -- Update the line information that should be overwritten
72827 --
72828 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
72829 p_header_num => 1);
72830 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
72831
72832 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
72833
72834 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
72835 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
72836 END IF;
72837
72838 --
72839 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
72840 --
72841 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
72842 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
72843 ELSE
72844 ---------------------------------------------------------------------------------------------------
72845 -- 4262811a Switch Sign
72846 ---------------------------------------------------------------------------------------------------
72847 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
72848 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
72849 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72850 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
72851 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72852 -- 5132302
72853 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
72854 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
72855
72856 END IF;
72857
72858 -- 4955764
72859 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
72860 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
72861
72862
72863 XLA_AE_LINES_PKG.ValidateCurrentLine;
72864 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
72865
72866 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
72867 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
72868 ,p_balance_type_code => l_balance_type_code);
72869
72870 END IF;
72871
72872 -----------------------------------------------------------------------------------------
72873 -- 4262811 Multiperiod Accounting
72874 -----------------------------------------------------------------------------------------
72875 -- No MPA option is assigned.
72876
72877
72878 END IF;
72879 END IF;
72880 --
72881
72882 --
72883 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72884 trace
72885 (p_msg => 'END of AcctLineType_152'
72886 ,p_level => C_LEVEL_PROCEDURE
72887 ,p_module => l_log_module);
72888 END IF;
72889 --
72890 EXCEPTION
72891 WHEN xla_exceptions_pkg.application_exception THEN
72892 RAISE;
72893 WHEN OTHERS THEN
72894 xla_exceptions_pkg.raise_message
72895 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_152');
72896 END AcctLineType_152;
72897 --
72898
72899 ---------------------------------------
72900 --
72901 -- PRIVATE FUNCTION
72902 -- AcctLineType_153
72903 --
72904 ---------------------------------------
72905 PROCEDURE AcctLineType_153 (
72906 p_application_id IN NUMBER
72907 ,p_event_id IN NUMBER
72908 ,p_calculate_acctd_flag IN VARCHAR2
72909 ,p_calculate_g_l_flag IN VARCHAR2
72910 ,p_actual_flag IN OUT VARCHAR2
72911 ,p_balance_type_code OUT VARCHAR2
72912 ,p_gain_or_loss_ref OUT VARCHAR2
72913
72914 --TRANSACTION_ID
72915 , p_source_1 IN NUMBER
72916 --Item Concatenated Segments
72917 , p_source_2 IN VARCHAR2
72918 --Transaction Quantity
72919 , p_source_3 IN NUMBER
72920 --Transaction Unit of Measure Code
72921 , p_source_4 IN VARCHAR2
72922 --Inventory Transaction Type Description
72923 , p_source_5 IN VARCHAR2
72924 --Cost Management Default Account
72925 , p_source_11 IN NUMBER
72926 --DISTRIBUTION_IDENTIFIER
72927 , p_source_84 IN NUMBER
72928 --Distribution Type
72929 , p_source_85 IN VARCHAR2
72930 , p_source_85_meaning IN VARCHAR2
72931 --Entered Currency Code
72932 , p_source_88 IN VARCHAR2
72933 --Entered Amount
72934 , p_source_91 IN NUMBER
72935 --Currency Conversion Date
72936 , p_source_92 IN DATE
72937 --Currency Conversion Rate
72938 , p_source_93 IN NUMBER
72939 --Currency Conversion Type
72940 , p_source_94 IN VARCHAR2
72941 --Accounted Amount
72942 , p_source_95 IN NUMBER
72943 --Accounting Line Type
72944 , p_source_97 IN NUMBER
72945 )
72946 IS
72947
72948 l_component_type VARCHAR2(80);
72949 l_component_code VARCHAR2(30);
72950 l_component_type_code VARCHAR2(1);
72951 l_component_appl_id INTEGER;
72952 l_amb_context_code VARCHAR2(30);
72953 l_entity_code VARCHAR2(30);
72954 l_event_class_code VARCHAR2(30);
72955 l_ae_header_id NUMBER;
72956 l_event_type_code VARCHAR2(30);
72957 l_line_definition_code VARCHAR2(30);
72958 l_line_definition_owner_code VARCHAR2(1);
72959 --
72960 -- adr variables
72961 l_segment VARCHAR2(30);
72962 l_ccid NUMBER;
72963 l_adr_transaction_coa_id NUMBER;
72964 l_adr_accounting_coa_id NUMBER;
72965 l_adr_flexfield_segment_code VARCHAR2(30);
72966 l_adr_flex_value_set_id NUMBER;
72967 l_adr_value_type_code VARCHAR2(30);
72968 l_adr_value_combination_id NUMBER;
72969 l_adr_value_segment_code VARCHAR2(30);
72970
72971 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
72972 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
72973 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
72974 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
72975
72976 -- 4262811 Variables ------------------------------------------------------------------------------------------
72977 l_entered_amt_idx NUMBER;
72978 l_accted_amt_idx NUMBER;
72979 l_acc_rev_flag VARCHAR2(1);
72980 l_accrual_line_num NUMBER;
72981 l_tmp_amt NUMBER;
72982 l_acc_rev_natural_side_code VARCHAR2(1);
72983
72984 l_num_entries NUMBER;
72985 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
72986 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
72987 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
72988 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
72989 l_recog_line_1 NUMBER;
72990 l_recog_line_2 NUMBER;
72991
72992 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
72993 l_bflow_applied_to_amt NUMBER; -- 5132302
72994 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
72995
72996 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
72997
72998 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
72999 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
73000
73001 ---------------------------------------------------------------------------------------------------------------
73002
73003
73004 --
73005 -- bulk performance
73006 --
73007 l_balance_type_code VARCHAR2(1);
73008 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
73009 l_log_module VARCHAR2(240);
73010
73011 --
73012 -- Upgrade strategy
73013 --
73014 l_actual_upg_option VARCHAR2(1);
73015 l_enc_upg_option VARCHAR2(1);
73016
73017 --
73018 BEGIN
73019 --
73020 IF g_log_enabled THEN
73021 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_153';
73022 END IF;
73023 --
73024 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73025
73026 trace
73027 (p_msg => 'BEGIN of AcctLineType_153'
73028 ,p_level => C_LEVEL_PROCEDURE
73029 ,p_module => l_log_module);
73030
73031 END IF;
73032 --
73033 l_component_type := 'AMB_JLT';
73034 l_component_code := 'INTERORG_FREIGHT_CHARGE';
73035 l_component_type_code := 'S';
73036 l_component_appl_id := 707;
73037 l_amb_context_code := 'DEFAULT';
73038 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
73039 l_event_class_code := 'USER_DEFINE';
73040 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
73041 l_line_definition_owner_code := 'S';
73042 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
73043 --
73044 l_balance_type_code := 'A';
73045 l_segment := NULL;
73046 l_ccid := NULL;
73047 l_adr_transaction_coa_id := NULL;
73048 l_adr_accounting_coa_id := NULL;
73049 l_adr_flexfield_segment_code := NULL;
73050 l_adr_flex_value_set_id := NULL;
73051 l_adr_value_type_code := NULL;
73052 l_adr_value_combination_id := NULL;
73053 l_adr_value_segment_code := NULL;
73054
73055 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
73056 l_bflow_class_code := ''; -- 4219869 Business Flow
73057 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
73058 l_budgetary_control_flag := 'N';
73059
73060 l_bflow_applied_to_amt_idx := NULL; -- 5132302
73061 l_bflow_applied_to_amt := NULL; -- 5132302
73062 l_entered_amt_idx := NULL; -- 4262811
73063 l_accted_amt_idx := NULL; -- 4262811
73064 l_acc_rev_flag := NULL; -- 4262811
73065 l_accrual_line_num := NULL; -- 4262811
73066 l_tmp_amt := NULL; -- 4262811
73067 --
73068
73069 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
73070 l_balance_type_code <> 'B' THEN
73071 IF NVL(p_source_97,9E125) = 12
73072 THEN
73073
73074 --
73075 XLA_AE_LINES_PKG.SetNewLine;
73076
73077 p_balance_type_code := l_balance_type_code;
73078 -- set the flag so later we will know whether the gain loss line needs to be created
73079
73080 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
73081 p_actual_flag :='A';
73082 END IF;
73083
73084 --
73085 -- bulk performance
73086 --
73087 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
73088 p_header_num => 0); -- 4262811
73089 --
73090 -- set accounting line options
73091 --
73092 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
73093 p_natural_side_code => 'D'
73094 , p_gain_or_loss_flag => 'N'
73095 , p_gl_transfer_mode_code => 'S'
73096 , p_acct_entry_type_code => 'A'
73097 , p_switch_side_flag => 'Y'
73098 , p_merge_duplicate_code => 'N'
73099 );
73100 --
73101 l_acc_rev_natural_side_code := 'C'; -- 4262811
73102 --
73103 --
73104 -- set accounting line type info
73105 --
73106 xla_ae_lines_pkg.SetAcctLineType
73107 (p_component_type => l_component_type
73108 ,p_event_type_code => l_event_type_code
73109 ,p_line_definition_owner_code => l_line_definition_owner_code
73110 ,p_line_definition_code => l_line_definition_code
73111 ,p_accounting_line_code => l_component_code
73112 ,p_accounting_line_type_code => l_component_type_code
73113 ,p_accounting_line_appl_id => l_component_appl_id
73114 ,p_amb_context_code => l_amb_context_code
73115 ,p_entity_code => l_entity_code
73116 ,p_event_class_code => l_event_class_code);
73117 --
73118 -- set accounting class
73119 --
73120 xla_ae_lines_pkg.SetAcctClass(
73121 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
73122 , p_ae_header_id => l_ae_header_id
73123 );
73124
73125 --
73126 -- set rounding class
73127 --
73128 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
73129 'INTERORG_FREIGHT_CHARGE';
73130
73131 --
73132 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
73133 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
73134 --
73135 -- bulk performance
73136 --
73137 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
73138
73139 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
73140 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
73141
73142 -- 4955764
73143 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
73144 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
73145
73146 -- 4458381 Public Sector Enh
73147
73148 --
73149 -- set accounting attributes for the line type
73150 --
73151 l_entered_amt_idx := 3;
73152 l_accted_amt_idx := 8;
73153 l_bflow_applied_to_amt_idx := NULL; -- 5132302
73154 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
73155 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
73156 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
73157 l_rec_acct_attrs.array_char_value(2) := p_source_85;
73158 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
73159 l_rec_acct_attrs.array_num_value(3) := p_source_91;
73160 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
73161 l_rec_acct_attrs.array_char_value(4) := p_source_88;
73162 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
73163 l_rec_acct_attrs.array_date_value(5) := p_source_92;
73164 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
73165 l_rec_acct_attrs.array_num_value(6) := p_source_93;
73166 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
73167 l_rec_acct_attrs.array_char_value(7) := p_source_94;
73168 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
73169 l_rec_acct_attrs.array_num_value(8) := p_source_95;
73170
73171 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
73172 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
73173
73174 ---------------------------------------------------------------------------------------------------------------
73175 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
73176 ---------------------------------------------------------------------------------------------------------------
73177 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
73178
73179 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
73180 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
73181
73182 IF xla_accounting_cache_pkg.GetValueChar
73183 (p_source_code => 'LEDGER_CATEGORY_CODE'
73184 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
73185 AND l_bflow_method_code = 'PRIOR_ENTRY'
73186 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
73187 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
73188 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
73189 )
73190 THEN
73191 xla_ae_lines_pkg.BflowUpgEntry
73192 (p_business_method_code => l_bflow_method_code
73193 ,p_business_class_code => l_bflow_class_code
73194 ,p_balance_type => l_balance_type_code);
73195 ELSE
73196 NULL;
73197 -- No business flow processing for business flow method of NONE.
73198 END IF;
73199
73200 --
73201 -- call analytical criteria
73202 --
73203
73204 --
73205 -- call description
73206 --
73207
73208 xla_ae_lines_pkg.SetLineDescription(
73209 p_ae_header_id => l_ae_header_id
73210 ,p_description => Description_1 (
73211 p_application_id => p_application_id
73212 , p_ae_header_id => l_ae_header_id
73213 , p_source_1 => p_source_1
73214 , p_source_2 => p_source_2
73215 , p_source_3 => p_source_3
73216 , p_source_4 => p_source_4
73217 , p_source_5 => p_source_5
73218 )
73219 );
73220
73221
73222 --
73223 -- call ADRs
73224 -- Bug 4922099
73225 --
73226 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
73227 (NVL(l_actual_upg_option, 'N') = 'O') OR
73228 (NVL(l_enc_upg_option, 'N') = 'O')
73229 )
73230 THEN
73231 NULL;
73232 --
73233 --
73234
73235 l_ccid := AcctDerRule_6(
73236 p_application_id => p_application_id
73237 , p_ae_header_id => l_ae_header_id
73238 , p_source_11 => p_source_11
73239 , x_transaction_coa_id => l_adr_transaction_coa_id
73240 , x_accounting_coa_id => l_adr_accounting_coa_id
73241 , x_value_type_code => l_adr_value_type_code
73242 , p_side => 'NA'
73243 );
73244
73245 xla_ae_lines_pkg.set_ccid(
73246 p_code_combination_id => l_ccid
73247 , p_value_type_code => l_adr_value_type_code
73248 , p_transaction_coa_id => l_adr_transaction_coa_id
73249 , p_accounting_coa_id => l_adr_accounting_coa_id
73250 , p_adr_code => 'CST_DEFAULT'
73251 , p_adr_type_code => 'S'
73252 , p_component_type => l_component_type
73253 , p_component_code => l_component_code
73254 , p_component_type_code => l_component_type_code
73255 , p_component_appl_id => l_component_appl_id
73256 , p_amb_context_code => l_amb_context_code
73257 , p_side => 'NA'
73258 );
73259
73260
73261 --
73262 --
73263 END IF;
73264 --
73265 -- Bug 4922099
73266 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
73267 (NVL(l_enc_upg_option, 'N') = 'O')
73268 ) AND
73269 (l_bflow_method_code = 'PRIOR_ENTRY')
73270 )
73271 THEN
73272 IF
73273 --
73274 1 = 2
73275 --
73276 THEN
73277 xla_accounting_err_pkg.build_message
73278 (p_appli_s_name => 'XLA'
73279 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
73280 ,p_token_1 => 'LINE_NUMBER'
73281 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
73282 ,p_token_2 => 'LINE_TYPE_NAME'
73283 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
73284 l_component_type
73285 ,l_component_code
73286 ,l_component_type_code
73287 ,l_component_appl_id
73288 ,l_amb_context_code
73289 ,l_entity_code
73290 ,l_event_class_code
73291 )
73292 ,p_token_3 => 'OWNER'
73293 ,p_value_3 => xla_lookups_pkg.get_meaning(
73294 p_lookup_type => 'XLA_OWNER_TYPE'
73295 ,p_lookup_code => l_component_type_code
73296 )
73297 ,p_token_4 => 'PRODUCT_NAME'
73298 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
73299 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
73300 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
73301 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
73302 ,p_ae_header_id => NULL
73303 );
73304
73305 IF (C_LEVEL_ERROR>= g_log_level) THEN
73306 trace
73307 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
73308 ,p_level => C_LEVEL_ERROR
73309 ,p_module => l_log_module);
73310 END IF;
73311 END IF;
73312 END IF;
73313 --
73314 --
73315 ------------------------------------------------------------------------------------------------
73316 -- 4219869 Business Flow
73317 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
73318 -- Prior Entry. Currently, the following code is always generated.
73319 ------------------------------------------------------------------------------------------------
73320 XLA_AE_LINES_PKG.ValidateCurrentLine;
73321
73322 ------------------------------------------------------------------------------------
73323 -- 4219869 Business Flow
73324 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
73325 ------------------------------------------------------------------------------------
73326 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
73327
73328 ----------------------------------------------------------------------------------
73329 -- 4219869 Business Flow
73330 -- Update journal entry status -- Need to generate this within IF <condition>
73331 ----------------------------------------------------------------------------------
73332 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
73333 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
73334 ,p_balance_type_code => l_balance_type_code
73335 );
73336
73337 -------------------------------------------------------------------------------------------
73338 -- 4262811 - Generate the Accrual Reversal lines
73339 -------------------------------------------------------------------------------------------
73340 BEGIN
73341 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
73342 (g_array_event(p_event_id).array_value_num('header_index'));
73343 IF l_acc_rev_flag IS NULL THEN
73344 l_acc_rev_flag := 'N';
73345 END IF;
73346 EXCEPTION
73347 WHEN OTHERS THEN
73348 l_acc_rev_flag := 'N';
73349 END;
73350 --
73351 IF (l_acc_rev_flag = 'Y') THEN
73352
73353 -- 4645092 ------------------------------------------------------------------------------
73354 -- To allow MPA report to determine if it should generate report process
73355 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
73356 ------------------------------------------------------------------------------------------
73357
73358 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
73359 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
73360 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
73361 -- call ADRs
73362 -- Bug 4922099
73363 --
73364 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
73365 (NVL(l_actual_upg_option, 'N') = 'O') OR
73366 (NVL(l_enc_upg_option, 'N') = 'O')
73367 )
73368 THEN
73369 NULL;
73370 --
73371 --
73372
73373 l_ccid := AcctDerRule_6(
73374 p_application_id => p_application_id
73375 , p_ae_header_id => l_ae_header_id
73376 , p_source_11 => p_source_11
73377 , x_transaction_coa_id => l_adr_transaction_coa_id
73378 , x_accounting_coa_id => l_adr_accounting_coa_id
73379 , x_value_type_code => l_adr_value_type_code
73380 , p_side => 'NA'
73381 );
73382
73383 xla_ae_lines_pkg.set_ccid(
73384 p_code_combination_id => l_ccid
73385 , p_value_type_code => l_adr_value_type_code
73386 , p_transaction_coa_id => l_adr_transaction_coa_id
73387 , p_accounting_coa_id => l_adr_accounting_coa_id
73388 , p_adr_code => 'CST_DEFAULT'
73389 , p_adr_type_code => 'S'
73390 , p_component_type => l_component_type
73391 , p_component_code => l_component_code
73392 , p_component_type_code => l_component_type_code
73393 , p_component_appl_id => l_component_appl_id
73394 , p_amb_context_code => l_amb_context_code
73395 , p_side => 'NA'
73396 );
73397
73398
73399 --
73400 --
73401 END IF;
73402
73403 --
73404 -- Update the line information that should be overwritten
73405 --
73406 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
73407 p_header_num => 1);
73408 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
73409
73410 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
73411
73412 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
73413 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
73414 END IF;
73415
73416 --
73417 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
73418 --
73419 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
73420 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
73421 ELSE
73422 ---------------------------------------------------------------------------------------------------
73423 -- 4262811a Switch Sign
73424 ---------------------------------------------------------------------------------------------------
73425 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
73426 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
73427 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
73428 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
73429 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
73430 -- 5132302
73431 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
73432 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
73433
73434 END IF;
73435
73436 -- 4955764
73437 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
73438 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
73439
73440
73441 XLA_AE_LINES_PKG.ValidateCurrentLine;
73442 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
73443
73444 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
73445 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
73446 ,p_balance_type_code => l_balance_type_code);
73447
73448 END IF;
73449
73450 -----------------------------------------------------------------------------------------
73451 -- 4262811 Multiperiod Accounting
73452 -----------------------------------------------------------------------------------------
73453 -- No MPA option is assigned.
73454
73455
73456 END IF;
73457 END IF;
73458 --
73459
73460 --
73461 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73462 trace
73463 (p_msg => 'END of AcctLineType_153'
73464 ,p_level => C_LEVEL_PROCEDURE
73465 ,p_module => l_log_module);
73466 END IF;
73467 --
73468 EXCEPTION
73469 WHEN xla_exceptions_pkg.application_exception THEN
73470 RAISE;
73471 WHEN OTHERS THEN
73472 xla_exceptions_pkg.raise_message
73473 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_153');
73474 END AcctLineType_153;
73475 --
73476
73477 ---------------------------------------
73478 --
73479 -- PRIVATE FUNCTION
73480 -- AcctLineType_154
73481 --
73482 ---------------------------------------
73483 PROCEDURE AcctLineType_154 (
73484 p_application_id IN NUMBER
73485 ,p_event_id IN NUMBER
73486 ,p_calculate_acctd_flag IN VARCHAR2
73487 ,p_calculate_g_l_flag IN VARCHAR2
73488 ,p_actual_flag IN OUT VARCHAR2
73489 ,p_balance_type_code OUT VARCHAR2
73490 ,p_gain_or_loss_ref OUT VARCHAR2
73491
73492 --TRANSACTION_ID
73493 , p_source_1 IN NUMBER
73494 --Item Concatenated Segments
73495 , p_source_2 IN VARCHAR2
73496 --Transaction Quantity
73497 , p_source_3 IN NUMBER
73498 --Transaction Unit of Measure Code
73499 , p_source_4 IN VARCHAR2
73500 --Inventory Transaction Type Description
73501 , p_source_5 IN VARCHAR2
73502 --Cost Management Default Account
73503 , p_source_11 IN NUMBER
73504 --DISTRIBUTION_IDENTIFIER
73505 , p_source_84 IN NUMBER
73506 --Distribution Type
73507 , p_source_85 IN VARCHAR2
73508 , p_source_85_meaning IN VARCHAR2
73509 --Entered Currency Code
73510 , p_source_88 IN VARCHAR2
73511 --Entered Amount
73512 , p_source_91 IN NUMBER
73513 --Currency Conversion Date
73514 , p_source_92 IN DATE
73515 --Currency Conversion Rate
73516 , p_source_93 IN NUMBER
73517 --Currency Conversion Type
73518 , p_source_94 IN VARCHAR2
73519 --Accounted Amount
73520 , p_source_95 IN NUMBER
73521 --Accounting Line Type
73522 , p_source_97 IN NUMBER
73523 )
73524 IS
73525
73526 l_component_type VARCHAR2(80);
73527 l_component_code VARCHAR2(30);
73528 l_component_type_code VARCHAR2(1);
73529 l_component_appl_id INTEGER;
73530 l_amb_context_code VARCHAR2(30);
73531 l_entity_code VARCHAR2(30);
73532 l_event_class_code VARCHAR2(30);
73533 l_ae_header_id NUMBER;
73534 l_event_type_code VARCHAR2(30);
73535 l_line_definition_code VARCHAR2(30);
73536 l_line_definition_owner_code VARCHAR2(1);
73537 --
73538 -- adr variables
73539 l_segment VARCHAR2(30);
73540 l_ccid NUMBER;
73541 l_adr_transaction_coa_id NUMBER;
73542 l_adr_accounting_coa_id NUMBER;
73543 l_adr_flexfield_segment_code VARCHAR2(30);
73544 l_adr_flex_value_set_id NUMBER;
73545 l_adr_value_type_code VARCHAR2(30);
73546 l_adr_value_combination_id NUMBER;
73547 l_adr_value_segment_code VARCHAR2(30);
73548
73549 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
73550 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
73551 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
73552 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
73553
73554 -- 4262811 Variables ------------------------------------------------------------------------------------------
73555 l_entered_amt_idx NUMBER;
73556 l_accted_amt_idx NUMBER;
73557 l_acc_rev_flag VARCHAR2(1);
73558 l_accrual_line_num NUMBER;
73559 l_tmp_amt NUMBER;
73560 l_acc_rev_natural_side_code VARCHAR2(1);
73561
73562 l_num_entries NUMBER;
73563 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
73564 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
73565 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
73566 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
73567 l_recog_line_1 NUMBER;
73568 l_recog_line_2 NUMBER;
73569
73570 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
73571 l_bflow_applied_to_amt NUMBER; -- 5132302
73572 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
73573
73574 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
73575
73576 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
73577 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
73578
73579 ---------------------------------------------------------------------------------------------------------------
73580
73581
73582 --
73583 -- bulk performance
73584 --
73585 l_balance_type_code VARCHAR2(1);
73586 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
73587 l_log_module VARCHAR2(240);
73588
73589 --
73590 -- Upgrade strategy
73591 --
73592 l_actual_upg_option VARCHAR2(1);
73593 l_enc_upg_option VARCHAR2(1);
73594
73595 --
73596 BEGIN
73597 --
73598 IF g_log_enabled THEN
73599 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_154';
73600 END IF;
73601 --
73602 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73603
73604 trace
73605 (p_msg => 'BEGIN of AcctLineType_154'
73606 ,p_level => C_LEVEL_PROCEDURE
73607 ,p_module => l_log_module);
73608
73609 END IF;
73610 --
73611 l_component_type := 'AMB_JLT';
73612 l_component_code := 'INTERORG_FREIGHT_CHARGE';
73613 l_component_type_code := 'S';
73614 l_component_appl_id := 707;
73615 l_amb_context_code := 'DEFAULT';
73616 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
73617 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
73618 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_TP';
73619 l_line_definition_owner_code := 'S';
73620 l_line_definition_code := 'PI_RCPT_SENDER_RCPT_TP';
73621 --
73622 l_balance_type_code := 'A';
73623 l_segment := NULL;
73624 l_ccid := NULL;
73625 l_adr_transaction_coa_id := NULL;
73626 l_adr_accounting_coa_id := NULL;
73627 l_adr_flexfield_segment_code := NULL;
73628 l_adr_flex_value_set_id := NULL;
73629 l_adr_value_type_code := NULL;
73630 l_adr_value_combination_id := NULL;
73631 l_adr_value_segment_code := NULL;
73632
73633 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
73634 l_bflow_class_code := ''; -- 4219869 Business Flow
73635 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
73636 l_budgetary_control_flag := 'N';
73637
73638 l_bflow_applied_to_amt_idx := NULL; -- 5132302
73639 l_bflow_applied_to_amt := NULL; -- 5132302
73640 l_entered_amt_idx := NULL; -- 4262811
73641 l_accted_amt_idx := NULL; -- 4262811
73642 l_acc_rev_flag := NULL; -- 4262811
73643 l_accrual_line_num := NULL; -- 4262811
73644 l_tmp_amt := NULL; -- 4262811
73645 --
73646
73647 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
73648 l_balance_type_code <> 'B' THEN
73649 IF NVL(p_source_97,9E125) = 12
73650 THEN
73651
73652 --
73653 XLA_AE_LINES_PKG.SetNewLine;
73654
73655 p_balance_type_code := l_balance_type_code;
73656 -- set the flag so later we will know whether the gain loss line needs to be created
73657
73658 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
73659 p_actual_flag :='A';
73660 END IF;
73661
73662 --
73663 -- bulk performance
73664 --
73665 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
73666 p_header_num => 0); -- 4262811
73667 --
73668 -- set accounting line options
73669 --
73670 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
73671 p_natural_side_code => 'D'
73672 , p_gain_or_loss_flag => 'N'
73673 , p_gl_transfer_mode_code => 'S'
73674 , p_acct_entry_type_code => 'A'
73675 , p_switch_side_flag => 'Y'
73676 , p_merge_duplicate_code => 'N'
73677 );
73678 --
73679 l_acc_rev_natural_side_code := 'C'; -- 4262811
73680 --
73681 --
73682 -- set accounting line type info
73683 --
73684 xla_ae_lines_pkg.SetAcctLineType
73685 (p_component_type => l_component_type
73686 ,p_event_type_code => l_event_type_code
73687 ,p_line_definition_owner_code => l_line_definition_owner_code
73688 ,p_line_definition_code => l_line_definition_code
73689 ,p_accounting_line_code => l_component_code
73690 ,p_accounting_line_type_code => l_component_type_code
73691 ,p_accounting_line_appl_id => l_component_appl_id
73692 ,p_amb_context_code => l_amb_context_code
73693 ,p_entity_code => l_entity_code
73694 ,p_event_class_code => l_event_class_code);
73695 --
73696 -- set accounting class
73697 --
73698 xla_ae_lines_pkg.SetAcctClass(
73699 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
73700 , p_ae_header_id => l_ae_header_id
73701 );
73702
73703 --
73704 -- set rounding class
73705 --
73706 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
73707 'INTERORG_FREIGHT_CHARGE';
73708
73709 --
73710 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
73711 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
73712 --
73713 -- bulk performance
73714 --
73715 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
73716
73717 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
73718 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
73719
73720 -- 4955764
73721 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
73722 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
73723
73724 -- 4458381 Public Sector Enh
73725
73726 --
73727 -- set accounting attributes for the line type
73728 --
73729 l_entered_amt_idx := 3;
73730 l_accted_amt_idx := 8;
73731 l_bflow_applied_to_amt_idx := NULL; -- 5132302
73732 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
73733 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
73734 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
73735 l_rec_acct_attrs.array_char_value(2) := p_source_85;
73736 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
73737 l_rec_acct_attrs.array_num_value(3) := p_source_91;
73738 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
73739 l_rec_acct_attrs.array_char_value(4) := p_source_88;
73740 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
73741 l_rec_acct_attrs.array_date_value(5) := p_source_92;
73742 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
73743 l_rec_acct_attrs.array_num_value(6) := p_source_93;
73744 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
73745 l_rec_acct_attrs.array_char_value(7) := p_source_94;
73746 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
73747 l_rec_acct_attrs.array_num_value(8) := p_source_95;
73748
73749 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
73750 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
73751
73752 ---------------------------------------------------------------------------------------------------------------
73753 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
73754 ---------------------------------------------------------------------------------------------------------------
73755 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
73756
73757 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
73758 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
73759
73760 IF xla_accounting_cache_pkg.GetValueChar
73761 (p_source_code => 'LEDGER_CATEGORY_CODE'
73762 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
73763 AND l_bflow_method_code = 'PRIOR_ENTRY'
73764 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
73765 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
73766 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
73767 )
73768 THEN
73769 xla_ae_lines_pkg.BflowUpgEntry
73770 (p_business_method_code => l_bflow_method_code
73771 ,p_business_class_code => l_bflow_class_code
73772 ,p_balance_type => l_balance_type_code);
73773 ELSE
73774 NULL;
73775 -- No business flow processing for business flow method of NONE.
73776 END IF;
73777
73778 --
73779 -- call analytical criteria
73780 --
73781
73782 --
73783 -- call description
73784 --
73785
73786 xla_ae_lines_pkg.SetLineDescription(
73787 p_ae_header_id => l_ae_header_id
73788 ,p_description => Description_1 (
73789 p_application_id => p_application_id
73790 , p_ae_header_id => l_ae_header_id
73791 , p_source_1 => p_source_1
73792 , p_source_2 => p_source_2
73793 , p_source_3 => p_source_3
73794 , p_source_4 => p_source_4
73795 , p_source_5 => p_source_5
73796 )
73797 );
73798
73799
73800 --
73801 -- call ADRs
73802 -- Bug 4922099
73803 --
73804 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
73805 (NVL(l_actual_upg_option, 'N') = 'O') OR
73806 (NVL(l_enc_upg_option, 'N') = 'O')
73807 )
73808 THEN
73809 NULL;
73810 --
73811 --
73812
73813 l_ccid := AcctDerRule_6(
73814 p_application_id => p_application_id
73815 , p_ae_header_id => l_ae_header_id
73816 , p_source_11 => p_source_11
73817 , x_transaction_coa_id => l_adr_transaction_coa_id
73818 , x_accounting_coa_id => l_adr_accounting_coa_id
73819 , x_value_type_code => l_adr_value_type_code
73820 , p_side => 'NA'
73821 );
73822
73823 xla_ae_lines_pkg.set_ccid(
73824 p_code_combination_id => l_ccid
73825 , p_value_type_code => l_adr_value_type_code
73826 , p_transaction_coa_id => l_adr_transaction_coa_id
73827 , p_accounting_coa_id => l_adr_accounting_coa_id
73828 , p_adr_code => 'CST_DEFAULT'
73829 , p_adr_type_code => 'S'
73830 , p_component_type => l_component_type
73831 , p_component_code => l_component_code
73832 , p_component_type_code => l_component_type_code
73833 , p_component_appl_id => l_component_appl_id
73834 , p_amb_context_code => l_amb_context_code
73835 , p_side => 'NA'
73836 );
73837
73838
73839 --
73840 --
73841 END IF;
73842 --
73843 -- Bug 4922099
73844 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
73845 (NVL(l_enc_upg_option, 'N') = 'O')
73846 ) AND
73847 (l_bflow_method_code = 'PRIOR_ENTRY')
73848 )
73849 THEN
73850 IF
73851 --
73852 1 = 2
73853 --
73854 THEN
73855 xla_accounting_err_pkg.build_message
73856 (p_appli_s_name => 'XLA'
73857 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
73858 ,p_token_1 => 'LINE_NUMBER'
73859 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
73860 ,p_token_2 => 'LINE_TYPE_NAME'
73861 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
73862 l_component_type
73863 ,l_component_code
73864 ,l_component_type_code
73865 ,l_component_appl_id
73866 ,l_amb_context_code
73867 ,l_entity_code
73868 ,l_event_class_code
73869 )
73870 ,p_token_3 => 'OWNER'
73871 ,p_value_3 => xla_lookups_pkg.get_meaning(
73872 p_lookup_type => 'XLA_OWNER_TYPE'
73873 ,p_lookup_code => l_component_type_code
73874 )
73875 ,p_token_4 => 'PRODUCT_NAME'
73876 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
73877 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
73878 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
73879 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
73880 ,p_ae_header_id => NULL
73881 );
73882
73883 IF (C_LEVEL_ERROR>= g_log_level) THEN
73884 trace
73885 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
73886 ,p_level => C_LEVEL_ERROR
73887 ,p_module => l_log_module);
73888 END IF;
73889 END IF;
73890 END IF;
73891 --
73892 --
73893 ------------------------------------------------------------------------------------------------
73894 -- 4219869 Business Flow
73895 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
73896 -- Prior Entry. Currently, the following code is always generated.
73897 ------------------------------------------------------------------------------------------------
73898 XLA_AE_LINES_PKG.ValidateCurrentLine;
73899
73900 ------------------------------------------------------------------------------------
73901 -- 4219869 Business Flow
73902 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
73903 ------------------------------------------------------------------------------------
73904 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
73905
73906 ----------------------------------------------------------------------------------
73907 -- 4219869 Business Flow
73908 -- Update journal entry status -- Need to generate this within IF <condition>
73909 ----------------------------------------------------------------------------------
73910 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
73911 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
73912 ,p_balance_type_code => l_balance_type_code
73913 );
73914
73915 -------------------------------------------------------------------------------------------
73916 -- 4262811 - Generate the Accrual Reversal lines
73917 -------------------------------------------------------------------------------------------
73918 BEGIN
73919 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
73920 (g_array_event(p_event_id).array_value_num('header_index'));
73921 IF l_acc_rev_flag IS NULL THEN
73922 l_acc_rev_flag := 'N';
73923 END IF;
73924 EXCEPTION
73925 WHEN OTHERS THEN
73926 l_acc_rev_flag := 'N';
73927 END;
73928 --
73929 IF (l_acc_rev_flag = 'Y') THEN
73930
73931 -- 4645092 ------------------------------------------------------------------------------
73932 -- To allow MPA report to determine if it should generate report process
73933 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
73934 ------------------------------------------------------------------------------------------
73935
73936 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
73937 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
73938 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
73939 -- call ADRs
73940 -- Bug 4922099
73941 --
73942 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
73943 (NVL(l_actual_upg_option, 'N') = 'O') OR
73944 (NVL(l_enc_upg_option, 'N') = 'O')
73945 )
73946 THEN
73947 NULL;
73948 --
73949 --
73950
73951 l_ccid := AcctDerRule_6(
73952 p_application_id => p_application_id
73953 , p_ae_header_id => l_ae_header_id
73954 , p_source_11 => p_source_11
73955 , x_transaction_coa_id => l_adr_transaction_coa_id
73956 , x_accounting_coa_id => l_adr_accounting_coa_id
73957 , x_value_type_code => l_adr_value_type_code
73958 , p_side => 'NA'
73959 );
73960
73961 xla_ae_lines_pkg.set_ccid(
73962 p_code_combination_id => l_ccid
73963 , p_value_type_code => l_adr_value_type_code
73964 , p_transaction_coa_id => l_adr_transaction_coa_id
73965 , p_accounting_coa_id => l_adr_accounting_coa_id
73966 , p_adr_code => 'CST_DEFAULT'
73967 , p_adr_type_code => 'S'
73968 , p_component_type => l_component_type
73969 , p_component_code => l_component_code
73970 , p_component_type_code => l_component_type_code
73971 , p_component_appl_id => l_component_appl_id
73972 , p_amb_context_code => l_amb_context_code
73973 , p_side => 'NA'
73974 );
73975
73976
73977 --
73978 --
73979 END IF;
73980
73981 --
73982 -- Update the line information that should be overwritten
73983 --
73984 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
73985 p_header_num => 1);
73986 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
73987
73988 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
73989
73990 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
73991 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
73992 END IF;
73993
73994 --
73995 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
73996 --
73997 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
73998 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
73999 ELSE
74000 ---------------------------------------------------------------------------------------------------
74001 -- 4262811a Switch Sign
74002 ---------------------------------------------------------------------------------------------------
74003 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
74004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
74005 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74006 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
74007 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74008 -- 5132302
74009 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
74010 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74011
74012 END IF;
74013
74014 -- 4955764
74015 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
74016 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
74017
74018
74019 XLA_AE_LINES_PKG.ValidateCurrentLine;
74020 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
74021
74022 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
74023 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
74024 ,p_balance_type_code => l_balance_type_code);
74025
74026 END IF;
74027
74028 -----------------------------------------------------------------------------------------
74029 -- 4262811 Multiperiod Accounting
74030 -----------------------------------------------------------------------------------------
74031 -- No MPA option is assigned.
74032
74033
74034 END IF;
74035 END IF;
74036 --
74037
74038 --
74039 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74040 trace
74041 (p_msg => 'END of AcctLineType_154'
74042 ,p_level => C_LEVEL_PROCEDURE
74043 ,p_module => l_log_module);
74044 END IF;
74045 --
74046 EXCEPTION
74047 WHEN xla_exceptions_pkg.application_exception THEN
74048 RAISE;
74049 WHEN OTHERS THEN
74050 xla_exceptions_pkg.raise_message
74051 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_154');
74052 END AcctLineType_154;
74053 --
74054
74055 ---------------------------------------
74056 --
74057 -- PRIVATE FUNCTION
74058 -- AcctLineType_155
74059 --
74060 ---------------------------------------
74061 PROCEDURE AcctLineType_155 (
74062 p_application_id IN NUMBER
74063 ,p_event_id IN NUMBER
74064 ,p_calculate_acctd_flag IN VARCHAR2
74065 ,p_calculate_g_l_flag IN VARCHAR2
74066 ,p_actual_flag IN OUT VARCHAR2
74067 ,p_balance_type_code OUT VARCHAR2
74068 ,p_gain_or_loss_ref OUT VARCHAR2
74069
74070 --TRANSACTION_ID
74071 , p_source_1 IN NUMBER
74072 --Item Concatenated Segments
74073 , p_source_2 IN VARCHAR2
74074 --Transaction Quantity
74075 , p_source_3 IN NUMBER
74076 --Transaction Unit of Measure Code
74077 , p_source_4 IN VARCHAR2
74078 --Inventory Transaction Type Description
74079 , p_source_5 IN VARCHAR2
74080 --Transaction Transportation Distribution Account
74081 , p_source_32 IN NUMBER
74082 --DISTRIBUTION_IDENTIFIER
74083 , p_source_84 IN NUMBER
74084 --Distribution Type
74085 , p_source_85 IN VARCHAR2
74086 , p_source_85_meaning IN VARCHAR2
74087 --Entered Currency Code
74088 , p_source_88 IN VARCHAR2
74089 --Entered Amount
74090 , p_source_91 IN NUMBER
74091 --Currency Conversion Date
74092 , p_source_92 IN DATE
74093 --Currency Conversion Rate
74094 , p_source_93 IN NUMBER
74095 --Currency Conversion Type
74096 , p_source_94 IN VARCHAR2
74097 --Accounted Amount
74098 , p_source_95 IN NUMBER
74099 --Accounting Line Type
74100 , p_source_97 IN NUMBER
74101 )
74102 IS
74103
74104 l_component_type VARCHAR2(80);
74105 l_component_code VARCHAR2(30);
74106 l_component_type_code VARCHAR2(1);
74107 l_component_appl_id INTEGER;
74108 l_amb_context_code VARCHAR2(30);
74109 l_entity_code VARCHAR2(30);
74110 l_event_class_code VARCHAR2(30);
74111 l_ae_header_id NUMBER;
74112 l_event_type_code VARCHAR2(30);
74113 l_line_definition_code VARCHAR2(30);
74114 l_line_definition_owner_code VARCHAR2(1);
74115 --
74116 -- adr variables
74117 l_segment VARCHAR2(30);
74118 l_ccid NUMBER;
74119 l_adr_transaction_coa_id NUMBER;
74120 l_adr_accounting_coa_id NUMBER;
74121 l_adr_flexfield_segment_code VARCHAR2(30);
74122 l_adr_flex_value_set_id NUMBER;
74123 l_adr_value_type_code VARCHAR2(30);
74124 l_adr_value_combination_id NUMBER;
74125 l_adr_value_segment_code VARCHAR2(30);
74126
74127 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
74128 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
74129 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
74130 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
74131
74132 -- 4262811 Variables ------------------------------------------------------------------------------------------
74133 l_entered_amt_idx NUMBER;
74134 l_accted_amt_idx NUMBER;
74135 l_acc_rev_flag VARCHAR2(1);
74136 l_accrual_line_num NUMBER;
74137 l_tmp_amt NUMBER;
74138 l_acc_rev_natural_side_code VARCHAR2(1);
74139
74140 l_num_entries NUMBER;
74141 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
74142 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
74143 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
74144 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
74145 l_recog_line_1 NUMBER;
74146 l_recog_line_2 NUMBER;
74147
74148 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
74149 l_bflow_applied_to_amt NUMBER; -- 5132302
74150 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
74151
74152 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
74153
74154 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
74155 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
74156
74157 ---------------------------------------------------------------------------------------------------------------
74158
74159
74160 --
74161 -- bulk performance
74162 --
74163 l_balance_type_code VARCHAR2(1);
74164 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
74165 l_log_module VARCHAR2(240);
74166
74167 --
74168 -- Upgrade strategy
74169 --
74170 l_actual_upg_option VARCHAR2(1);
74171 l_enc_upg_option VARCHAR2(1);
74172
74173 --
74174 BEGIN
74175 --
74176 IF g_log_enabled THEN
74177 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_155';
74178 END IF;
74179 --
74180 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74181
74182 trace
74183 (p_msg => 'BEGIN of AcctLineType_155'
74184 ,p_level => C_LEVEL_PROCEDURE
74185 ,p_module => l_log_module);
74186
74187 END IF;
74188 --
74189 l_component_type := 'AMB_JLT';
74190 l_component_code := 'INTERORG_FREIGHT_CHARGE';
74191 l_component_type_code := 'S';
74192 l_component_appl_id := 707;
74193 l_amb_context_code := 'DEFAULT';
74194 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
74195 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
74196 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
74197 l_line_definition_owner_code := 'S';
74198 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
74199 --
74200 l_balance_type_code := 'A';
74201 l_segment := NULL;
74202 l_ccid := NULL;
74203 l_adr_transaction_coa_id := NULL;
74204 l_adr_accounting_coa_id := NULL;
74205 l_adr_flexfield_segment_code := NULL;
74206 l_adr_flex_value_set_id := NULL;
74207 l_adr_value_type_code := NULL;
74208 l_adr_value_combination_id := NULL;
74209 l_adr_value_segment_code := NULL;
74210
74211 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
74212 l_bflow_class_code := ''; -- 4219869 Business Flow
74213 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
74214 l_budgetary_control_flag := 'N';
74215
74216 l_bflow_applied_to_amt_idx := NULL; -- 5132302
74217 l_bflow_applied_to_amt := NULL; -- 5132302
74218 l_entered_amt_idx := NULL; -- 4262811
74219 l_accted_amt_idx := NULL; -- 4262811
74220 l_acc_rev_flag := NULL; -- 4262811
74221 l_accrual_line_num := NULL; -- 4262811
74222 l_tmp_amt := NULL; -- 4262811
74223 --
74224
74225 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
74226 l_balance_type_code <> 'B' THEN
74227 IF NVL(p_source_97,9E125) = 12
74228 THEN
74229
74230 --
74231 XLA_AE_LINES_PKG.SetNewLine;
74232
74233 p_balance_type_code := l_balance_type_code;
74234 -- set the flag so later we will know whether the gain loss line needs to be created
74235
74236 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
74237 p_actual_flag :='A';
74238 END IF;
74239
74240 --
74241 -- bulk performance
74242 --
74243 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
74244 p_header_num => 0); -- 4262811
74245 --
74246 -- set accounting line options
74247 --
74248 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
74249 p_natural_side_code => 'D'
74250 , p_gain_or_loss_flag => 'N'
74251 , p_gl_transfer_mode_code => 'S'
74252 , p_acct_entry_type_code => 'A'
74253 , p_switch_side_flag => 'Y'
74254 , p_merge_duplicate_code => 'N'
74255 );
74256 --
74257 l_acc_rev_natural_side_code := 'C'; -- 4262811
74258 --
74259 --
74260 -- set accounting line type info
74261 --
74262 xla_ae_lines_pkg.SetAcctLineType
74263 (p_component_type => l_component_type
74264 ,p_event_type_code => l_event_type_code
74265 ,p_line_definition_owner_code => l_line_definition_owner_code
74266 ,p_line_definition_code => l_line_definition_code
74267 ,p_accounting_line_code => l_component_code
74268 ,p_accounting_line_type_code => l_component_type_code
74269 ,p_accounting_line_appl_id => l_component_appl_id
74270 ,p_amb_context_code => l_amb_context_code
74271 ,p_entity_code => l_entity_code
74272 ,p_event_class_code => l_event_class_code);
74273 --
74274 -- set accounting class
74275 --
74276 xla_ae_lines_pkg.SetAcctClass(
74277 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
74278 , p_ae_header_id => l_ae_header_id
74279 );
74280
74281 --
74282 -- set rounding class
74283 --
74284 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
74285 'INTERORG_FREIGHT_CHARGE';
74286
74287 --
74288 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
74289 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
74290 --
74291 -- bulk performance
74292 --
74293 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
74294
74295 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
74296 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
74297
74298 -- 4955764
74299 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
74300 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
74301
74302 -- 4458381 Public Sector Enh
74303
74304 --
74305 -- set accounting attributes for the line type
74306 --
74307 l_entered_amt_idx := 3;
74308 l_accted_amt_idx := 8;
74309 l_bflow_applied_to_amt_idx := NULL; -- 5132302
74310 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
74311 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
74312 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
74313 l_rec_acct_attrs.array_char_value(2) := p_source_85;
74314 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
74315 l_rec_acct_attrs.array_num_value(3) := p_source_91;
74316 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
74317 l_rec_acct_attrs.array_char_value(4) := p_source_88;
74318 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
74319 l_rec_acct_attrs.array_date_value(5) := p_source_92;
74320 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
74321 l_rec_acct_attrs.array_num_value(6) := p_source_93;
74322 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
74323 l_rec_acct_attrs.array_char_value(7) := p_source_94;
74324 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
74325 l_rec_acct_attrs.array_num_value(8) := p_source_95;
74326
74327 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
74328 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
74329
74330 ---------------------------------------------------------------------------------------------------------------
74331 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
74332 ---------------------------------------------------------------------------------------------------------------
74333 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
74334
74335 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
74336 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
74337
74338 IF xla_accounting_cache_pkg.GetValueChar
74339 (p_source_code => 'LEDGER_CATEGORY_CODE'
74340 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
74341 AND l_bflow_method_code = 'PRIOR_ENTRY'
74342 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
74343 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
74344 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
74345 )
74346 THEN
74347 xla_ae_lines_pkg.BflowUpgEntry
74348 (p_business_method_code => l_bflow_method_code
74349 ,p_business_class_code => l_bflow_class_code
74350 ,p_balance_type => l_balance_type_code);
74351 ELSE
74352 NULL;
74353 -- No business flow processing for business flow method of NONE.
74354 END IF;
74355
74356 --
74357 -- call analytical criteria
74358 --
74359
74360 --
74361 -- call description
74362 --
74363
74364 xla_ae_lines_pkg.SetLineDescription(
74365 p_ae_header_id => l_ae_header_id
74366 ,p_description => Description_1 (
74367 p_application_id => p_application_id
74368 , p_ae_header_id => l_ae_header_id
74369 , p_source_1 => p_source_1
74370 , p_source_2 => p_source_2
74371 , p_source_3 => p_source_3
74372 , p_source_4 => p_source_4
74373 , p_source_5 => p_source_5
74374 )
74375 );
74376
74377
74378 --
74379 -- call ADRs
74380 -- Bug 4922099
74381 --
74382 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
74383 (NVL(l_actual_upg_option, 'N') = 'O') OR
74384 (NVL(l_enc_upg_option, 'N') = 'O')
74385 )
74386 THEN
74387 NULL;
74388 --
74389 --
74390
74391 l_ccid := AcctDerRule_17(
74392 p_application_id => p_application_id
74393 , p_ae_header_id => l_ae_header_id
74394 , p_source_32 => p_source_32
74395 , x_transaction_coa_id => l_adr_transaction_coa_id
74396 , x_accounting_coa_id => l_adr_accounting_coa_id
74397 , x_value_type_code => l_adr_value_type_code
74398 , p_side => 'NA'
74399 );
74400
74401 xla_ae_lines_pkg.set_ccid(
74402 p_code_combination_id => l_ccid
74403 , p_value_type_code => l_adr_value_type_code
74404 , p_transaction_coa_id => l_adr_transaction_coa_id
74405 , p_accounting_coa_id => l_adr_accounting_coa_id
74406 , p_adr_code => 'PI_FREIGHT'
74407 , p_adr_type_code => 'S'
74408 , p_component_type => l_component_type
74409 , p_component_code => l_component_code
74410 , p_component_type_code => l_component_type_code
74411 , p_component_appl_id => l_component_appl_id
74412 , p_amb_context_code => l_amb_context_code
74413 , p_side => 'NA'
74414 );
74415
74416
74417 --
74418 --
74419 END IF;
74420 --
74421 -- Bug 4922099
74422 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
74423 (NVL(l_enc_upg_option, 'N') = 'O')
74424 ) AND
74425 (l_bflow_method_code = 'PRIOR_ENTRY')
74426 )
74427 THEN
74428 IF
74429 --
74430 1 = 2
74431 --
74432 THEN
74433 xla_accounting_err_pkg.build_message
74434 (p_appli_s_name => 'XLA'
74435 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
74436 ,p_token_1 => 'LINE_NUMBER'
74437 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
74438 ,p_token_2 => 'LINE_TYPE_NAME'
74439 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
74440 l_component_type
74441 ,l_component_code
74442 ,l_component_type_code
74443 ,l_component_appl_id
74444 ,l_amb_context_code
74445 ,l_entity_code
74446 ,l_event_class_code
74447 )
74448 ,p_token_3 => 'OWNER'
74449 ,p_value_3 => xla_lookups_pkg.get_meaning(
74450 p_lookup_type => 'XLA_OWNER_TYPE'
74451 ,p_lookup_code => l_component_type_code
74452 )
74453 ,p_token_4 => 'PRODUCT_NAME'
74454 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
74455 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
74456 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
74457 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
74458 ,p_ae_header_id => NULL
74459 );
74460
74461 IF (C_LEVEL_ERROR>= g_log_level) THEN
74462 trace
74463 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
74464 ,p_level => C_LEVEL_ERROR
74465 ,p_module => l_log_module);
74466 END IF;
74467 END IF;
74468 END IF;
74469 --
74470 --
74471 ------------------------------------------------------------------------------------------------
74472 -- 4219869 Business Flow
74473 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
74474 -- Prior Entry. Currently, the following code is always generated.
74475 ------------------------------------------------------------------------------------------------
74476 XLA_AE_LINES_PKG.ValidateCurrentLine;
74477
74478 ------------------------------------------------------------------------------------
74479 -- 4219869 Business Flow
74480 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
74481 ------------------------------------------------------------------------------------
74482 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
74483
74484 ----------------------------------------------------------------------------------
74485 -- 4219869 Business Flow
74486 -- Update journal entry status -- Need to generate this within IF <condition>
74487 ----------------------------------------------------------------------------------
74488 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
74489 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
74490 ,p_balance_type_code => l_balance_type_code
74491 );
74492
74493 -------------------------------------------------------------------------------------------
74494 -- 4262811 - Generate the Accrual Reversal lines
74495 -------------------------------------------------------------------------------------------
74496 BEGIN
74497 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
74498 (g_array_event(p_event_id).array_value_num('header_index'));
74499 IF l_acc_rev_flag IS NULL THEN
74500 l_acc_rev_flag := 'N';
74501 END IF;
74502 EXCEPTION
74503 WHEN OTHERS THEN
74504 l_acc_rev_flag := 'N';
74505 END;
74506 --
74507 IF (l_acc_rev_flag = 'Y') THEN
74508
74509 -- 4645092 ------------------------------------------------------------------------------
74510 -- To allow MPA report to determine if it should generate report process
74511 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
74512 ------------------------------------------------------------------------------------------
74513
74514 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
74515 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
74516 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
74517 -- call ADRs
74518 -- Bug 4922099
74519 --
74520 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
74521 (NVL(l_actual_upg_option, 'N') = 'O') OR
74522 (NVL(l_enc_upg_option, 'N') = 'O')
74523 )
74524 THEN
74525 NULL;
74526 --
74527 --
74528
74529 l_ccid := AcctDerRule_17(
74530 p_application_id => p_application_id
74531 , p_ae_header_id => l_ae_header_id
74532 , p_source_32 => p_source_32
74533 , x_transaction_coa_id => l_adr_transaction_coa_id
74534 , x_accounting_coa_id => l_adr_accounting_coa_id
74535 , x_value_type_code => l_adr_value_type_code
74536 , p_side => 'NA'
74537 );
74538
74539 xla_ae_lines_pkg.set_ccid(
74540 p_code_combination_id => l_ccid
74541 , p_value_type_code => l_adr_value_type_code
74542 , p_transaction_coa_id => l_adr_transaction_coa_id
74543 , p_accounting_coa_id => l_adr_accounting_coa_id
74544 , p_adr_code => 'PI_FREIGHT'
74545 , p_adr_type_code => 'S'
74546 , p_component_type => l_component_type
74547 , p_component_code => l_component_code
74548 , p_component_type_code => l_component_type_code
74549 , p_component_appl_id => l_component_appl_id
74550 , p_amb_context_code => l_amb_context_code
74551 , p_side => 'NA'
74552 );
74553
74554
74555 --
74556 --
74557 END IF;
74558
74559 --
74560 -- Update the line information that should be overwritten
74561 --
74562 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
74563 p_header_num => 1);
74564 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
74565
74566 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
74567
74568 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
74569 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
74570 END IF;
74571
74572 --
74573 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
74574 --
74575 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
74576 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
74577 ELSE
74578 ---------------------------------------------------------------------------------------------------
74579 -- 4262811a Switch Sign
74580 ---------------------------------------------------------------------------------------------------
74581 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
74582 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
74583 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74584 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
74585 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74586 -- 5132302
74587 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
74588 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
74589
74590 END IF;
74591
74592 -- 4955764
74593 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
74594 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
74595
74596
74597 XLA_AE_LINES_PKG.ValidateCurrentLine;
74598 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
74599
74600 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
74601 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
74602 ,p_balance_type_code => l_balance_type_code);
74603
74604 END IF;
74605
74606 -----------------------------------------------------------------------------------------
74607 -- 4262811 Multiperiod Accounting
74608 -----------------------------------------------------------------------------------------
74609 -- No MPA option is assigned.
74610
74611
74612 END IF;
74613 END IF;
74614 --
74615
74616 --
74617 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74618 trace
74619 (p_msg => 'END of AcctLineType_155'
74620 ,p_level => C_LEVEL_PROCEDURE
74621 ,p_module => l_log_module);
74622 END IF;
74623 --
74624 EXCEPTION
74625 WHEN xla_exceptions_pkg.application_exception THEN
74626 RAISE;
74627 WHEN OTHERS THEN
74628 xla_exceptions_pkg.raise_message
74629 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_155');
74630 END AcctLineType_155;
74631 --
74632
74633 ---------------------------------------
74634 --
74635 -- PRIVATE FUNCTION
74636 -- AcctLineType_156
74637 --
74638 ---------------------------------------
74639 PROCEDURE AcctLineType_156 (
74640 p_application_id IN NUMBER
74641 ,p_event_id IN NUMBER
74642 ,p_calculate_acctd_flag IN VARCHAR2
74643 ,p_calculate_g_l_flag IN VARCHAR2
74644 ,p_actual_flag IN OUT VARCHAR2
74645 ,p_balance_type_code OUT VARCHAR2
74646 ,p_gain_or_loss_ref OUT VARCHAR2
74647
74648 --TRANSACTION_ID
74649 , p_source_1 IN NUMBER
74650 --Item Concatenated Segments
74651 , p_source_2 IN VARCHAR2
74652 --Transaction Quantity
74653 , p_source_3 IN NUMBER
74654 --Transaction Unit of Measure Code
74655 , p_source_4 IN VARCHAR2
74656 --Inventory Transaction Type Description
74657 , p_source_5 IN VARCHAR2
74658 --Cost Management Default Account
74659 , p_source_11 IN NUMBER
74660 --Applied to Application ID
74661 , p_source_79 IN NUMBER
74662 --Applied to Distribution Link Type
74663 , p_source_80 IN VARCHAR2
74664 --Applied to Entity Code
74665 , p_source_81 IN VARCHAR2
74666 --DISTRIBUTION_IDENTIFIER
74667 , p_source_84 IN NUMBER
74668 --Distribution Type
74669 , p_source_85 IN VARCHAR2
74670 , p_source_85_meaning IN VARCHAR2
74671 --Encumbrance Reversal Amount Entered
74672 , p_source_87 IN NUMBER
74673 --Entered Currency Code
74674 , p_source_88 IN VARCHAR2
74675 --Transaction Encumbrance Reversal Amount
74676 , p_source_89 IN NUMBER
74677 --Entered Amount
74678 , p_source_91 IN NUMBER
74679 --Currency Conversion Date
74680 , p_source_92 IN DATE
74681 --Currency Conversion Rate
74682 , p_source_93 IN NUMBER
74683 --Currency Conversion Type
74684 , p_source_94 IN VARCHAR2
74685 --Accounted Amount
74686 , p_source_95 IN NUMBER
74687 --Accounting Line Type
74688 , p_source_97 IN NUMBER
74689 --Costing Encumbrance Upgrade Option
74690 , p_source_100 IN VARCHAR2
74691 --TXN_PO_DISTRIBUTION_ID
74692 , p_source_101 IN NUMBER
74693 --TXN_PO_HEADER_ID
74694 , p_source_102 IN NUMBER
74695 --Requisition Budget Account
74696 , p_source_103 IN NUMBER
74697 --Requisition Encumbrance Type Identifier
74698 , p_source_104 IN NUMBER
74699 )
74700 IS
74701
74702 l_component_type VARCHAR2(80);
74703 l_component_code VARCHAR2(30);
74704 l_component_type_code VARCHAR2(1);
74705 l_component_appl_id INTEGER;
74706 l_amb_context_code VARCHAR2(30);
74707 l_entity_code VARCHAR2(30);
74708 l_event_class_code VARCHAR2(30);
74709 l_ae_header_id NUMBER;
74710 l_event_type_code VARCHAR2(30);
74711 l_line_definition_code VARCHAR2(30);
74712 l_line_definition_owner_code VARCHAR2(1);
74713 --
74714 -- adr variables
74715 l_segment VARCHAR2(30);
74716 l_ccid NUMBER;
74717 l_adr_transaction_coa_id NUMBER;
74718 l_adr_accounting_coa_id NUMBER;
74719 l_adr_flexfield_segment_code VARCHAR2(30);
74720 l_adr_flex_value_set_id NUMBER;
74721 l_adr_value_type_code VARCHAR2(30);
74722 l_adr_value_combination_id NUMBER;
74723 l_adr_value_segment_code VARCHAR2(30);
74724
74725 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
74726 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
74727 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
74728 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
74729
74730 -- 4262811 Variables ------------------------------------------------------------------------------------------
74731 l_entered_amt_idx NUMBER;
74732 l_accted_amt_idx NUMBER;
74733 l_acc_rev_flag VARCHAR2(1);
74734 l_accrual_line_num NUMBER;
74735 l_tmp_amt NUMBER;
74736 l_acc_rev_natural_side_code VARCHAR2(1);
74737
74738 l_num_entries NUMBER;
74739 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
74740 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
74741 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
74742 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
74743 l_recog_line_1 NUMBER;
74744 l_recog_line_2 NUMBER;
74745
74746 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
74747 l_bflow_applied_to_amt NUMBER; -- 5132302
74748 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
74749
74750 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
74751
74752 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
74753 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
74754
74755 ---------------------------------------------------------------------------------------------------------------
74756
74757
74758 --
74759 -- bulk performance
74760 --
74761 l_balance_type_code VARCHAR2(1);
74762 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
74763 l_log_module VARCHAR2(240);
74764
74765 --
74766 -- Upgrade strategy
74767 --
74768 l_actual_upg_option VARCHAR2(1);
74769 l_enc_upg_option VARCHAR2(1);
74770
74771 --
74772 BEGIN
74773 --
74774 IF g_log_enabled THEN
74775 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_156';
74776 END IF;
74777 --
74778 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74779
74780 trace
74781 (p_msg => 'BEGIN of AcctLineType_156'
74782 ,p_level => C_LEVEL_PROCEDURE
74783 ,p_module => l_log_module);
74784
74785 END IF;
74786 --
74787 l_component_type := 'AMB_JLT';
74788 l_component_code := 'INTERORG_FREIGHT_CHARGE';
74789 l_component_type_code := 'S';
74790 l_component_appl_id := 707;
74791 l_amb_context_code := 'DEFAULT';
74792 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
74793 l_event_class_code := 'DIR_INTERORG_RCPT';
74794 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
74795 l_line_definition_owner_code := 'S';
74796 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
74797 --
74798 l_balance_type_code := 'A';
74799 l_segment := NULL;
74800 l_ccid := NULL;
74801 l_adr_transaction_coa_id := NULL;
74802 l_adr_accounting_coa_id := NULL;
74803 l_adr_flexfield_segment_code := NULL;
74804 l_adr_flex_value_set_id := NULL;
74805 l_adr_value_type_code := NULL;
74806 l_adr_value_combination_id := NULL;
74807 l_adr_value_segment_code := NULL;
74808
74809 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
74810 l_bflow_class_code := ''; -- 4219869 Business Flow
74811 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
74812 l_budgetary_control_flag := 'N';
74813
74814 l_bflow_applied_to_amt_idx := NULL; -- 5132302
74815 l_bflow_applied_to_amt := NULL; -- 5132302
74816 l_entered_amt_idx := NULL; -- 4262811
74817 l_accted_amt_idx := NULL; -- 4262811
74818 l_acc_rev_flag := NULL; -- 4262811
74819 l_accrual_line_num := NULL; -- 4262811
74820 l_tmp_amt := NULL; -- 4262811
74821 --
74822
74823 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
74824 l_balance_type_code <> 'B' THEN
74825 IF NVL(p_source_97,9E125) = 12
74826 THEN
74827
74828 --
74829 XLA_AE_LINES_PKG.SetNewLine;
74830
74831 p_balance_type_code := l_balance_type_code;
74832 -- set the flag so later we will know whether the gain loss line needs to be created
74833
74834 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
74835 p_actual_flag :='A';
74836 END IF;
74837
74838 --
74839 -- bulk performance
74840 --
74841 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
74842 p_header_num => 0); -- 4262811
74843 --
74844 -- set accounting line options
74845 --
74846 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
74847 p_natural_side_code => 'D'
74848 , p_gain_or_loss_flag => 'N'
74849 , p_gl_transfer_mode_code => 'S'
74850 , p_acct_entry_type_code => 'A'
74851 , p_switch_side_flag => 'Y'
74852 , p_merge_duplicate_code => 'N'
74853 );
74854 --
74855 l_acc_rev_natural_side_code := 'C'; -- 4262811
74856 --
74857 --
74858 -- set accounting line type info
74859 --
74860 xla_ae_lines_pkg.SetAcctLineType
74861 (p_component_type => l_component_type
74862 ,p_event_type_code => l_event_type_code
74863 ,p_line_definition_owner_code => l_line_definition_owner_code
74864 ,p_line_definition_code => l_line_definition_code
74865 ,p_accounting_line_code => l_component_code
74866 ,p_accounting_line_type_code => l_component_type_code
74867 ,p_accounting_line_appl_id => l_component_appl_id
74868 ,p_amb_context_code => l_amb_context_code
74869 ,p_entity_code => l_entity_code
74870 ,p_event_class_code => l_event_class_code);
74871 --
74872 -- set accounting class
74873 --
74874 xla_ae_lines_pkg.SetAcctClass(
74875 p_accounting_class_code => 'INTERORG_FREIGHT_CHARGE'
74876 , p_ae_header_id => l_ae_header_id
74877 );
74878
74879 --
74880 -- set rounding class
74881 --
74882 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
74883 'INTERORG_FREIGHT_CHARGE';
74884
74885 --
74886 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
74887 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
74888 --
74889 -- bulk performance
74890 --
74891 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
74892
74893 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
74894 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
74895
74896 -- 4955764
74897 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
74898 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
74899
74900 -- 4458381 Public Sector Enh
74901
74902 --
74903 -- set accounting attributes for the line type
74904 --
74905 l_entered_amt_idx := 17;
74906 l_accted_amt_idx := 22;
74907 l_bflow_applied_to_amt_idx := NULL; -- 5132302
74908 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
74909 l_rec_acct_attrs.array_num_value(1) := p_source_79;
74910 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
74911 l_rec_acct_attrs.array_char_value(2) := p_source_80;
74912 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
74913 l_rec_acct_attrs.array_char_value(3) := p_source_81;
74914 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
74915 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
74916 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
74917 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
74918 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
74919 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
74920 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
74921 l_rec_acct_attrs.array_char_value(7) := p_source_85;
74922 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
74923 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
74924 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
74925 l_rec_acct_attrs.array_num_value(9) := p_source_87;
74926 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
74927 l_rec_acct_attrs.array_char_value(10) := p_source_88;
74928 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
74929 l_rec_acct_attrs.array_num_value(11) := p_source_89;
74930 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
74931 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
74932 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
74933 l_rec_acct_attrs.array_num_value(13) := p_source_87;
74934 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
74935 l_rec_acct_attrs.array_char_value(14) := p_source_88;
74936 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
74937 l_rec_acct_attrs.array_num_value(15) := p_source_89;
74938 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
74939 l_rec_acct_attrs.array_char_value(16) := p_source_100;
74940 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
74941 l_rec_acct_attrs.array_num_value(17) := p_source_91;
74942 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
74943 l_rec_acct_attrs.array_char_value(18) := p_source_88;
74944 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
74945 l_rec_acct_attrs.array_date_value(19) := p_source_92;
74946 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
74947 l_rec_acct_attrs.array_num_value(20) := p_source_93;
74948 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
74949 l_rec_acct_attrs.array_char_value(21) := p_source_94;
74950 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
74951 l_rec_acct_attrs.array_num_value(22) := p_source_95;
74952 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
74953 l_rec_acct_attrs.array_num_value(23) := p_source_104;
74954 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
74955 l_rec_acct_attrs.array_num_value(24) := p_source_104;
74956
74957 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
74958 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
74959
74960 ---------------------------------------------------------------------------------------------------------------
74961 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
74962 ---------------------------------------------------------------------------------------------------------------
74963 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
74964
74965 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
74966 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
74967
74968 IF xla_accounting_cache_pkg.GetValueChar
74969 (p_source_code => 'LEDGER_CATEGORY_CODE'
74970 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
74971 AND l_bflow_method_code = 'PRIOR_ENTRY'
74972 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
74973 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
74974 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
74975 )
74976 THEN
74977 xla_ae_lines_pkg.BflowUpgEntry
74978 (p_business_method_code => l_bflow_method_code
74979 ,p_business_class_code => l_bflow_class_code
74980 ,p_balance_type => l_balance_type_code);
74981 ELSE
74982 NULL;
74983 -- No business flow processing for business flow method of NONE.
74984 END IF;
74985
74986 --
74987 -- call analytical criteria
74988 --
74989
74990 --
74991 -- call description
74992 --
74993
74994 xla_ae_lines_pkg.SetLineDescription(
74995 p_ae_header_id => l_ae_header_id
74996 ,p_description => Description_1 (
74997 p_application_id => p_application_id
74998 , p_ae_header_id => l_ae_header_id
74999 , p_source_1 => p_source_1
75000 , p_source_2 => p_source_2
75001 , p_source_3 => p_source_3
75002 , p_source_4 => p_source_4
75003 , p_source_5 => p_source_5
75004 )
75005 );
75006
75007
75008 --
75009 -- call ADRs
75010 -- Bug 4922099
75011 --
75012 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
75013 (NVL(l_actual_upg_option, 'N') = 'O') OR
75014 (NVL(l_enc_upg_option, 'N') = 'O')
75015 )
75016 THEN
75017 NULL;
75018 --
75019 --
75020
75021 l_ccid := AcctDerRule_6(
75022 p_application_id => p_application_id
75023 , p_ae_header_id => l_ae_header_id
75024 , p_source_11 => p_source_11
75025 , x_transaction_coa_id => l_adr_transaction_coa_id
75026 , x_accounting_coa_id => l_adr_accounting_coa_id
75027 , x_value_type_code => l_adr_value_type_code
75028 , p_side => 'NA'
75029 );
75030
75031 xla_ae_lines_pkg.set_ccid(
75032 p_code_combination_id => l_ccid
75033 , p_value_type_code => l_adr_value_type_code
75034 , p_transaction_coa_id => l_adr_transaction_coa_id
75035 , p_accounting_coa_id => l_adr_accounting_coa_id
75036 , p_adr_code => 'CST_DEFAULT'
75037 , p_adr_type_code => 'S'
75038 , p_component_type => l_component_type
75039 , p_component_code => l_component_code
75040 , p_component_type_code => l_component_type_code
75041 , p_component_appl_id => l_component_appl_id
75042 , p_amb_context_code => l_amb_context_code
75043 , p_side => 'NA'
75044 );
75045
75046
75047 --
75048 --
75049 END IF;
75050 --
75051 -- Bug 4922099
75052 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
75053 (NVL(l_enc_upg_option, 'N') = 'O')
75054 ) AND
75055 (l_bflow_method_code = 'PRIOR_ENTRY')
75056 )
75057 THEN
75058 IF
75059 --
75060 1 = 2
75061 --
75062 THEN
75063 xla_accounting_err_pkg.build_message
75064 (p_appli_s_name => 'XLA'
75065 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
75066 ,p_token_1 => 'LINE_NUMBER'
75067 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
75068 ,p_token_2 => 'LINE_TYPE_NAME'
75069 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
75070 l_component_type
75071 ,l_component_code
75072 ,l_component_type_code
75073 ,l_component_appl_id
75074 ,l_amb_context_code
75075 ,l_entity_code
75076 ,l_event_class_code
75077 )
75078 ,p_token_3 => 'OWNER'
75079 ,p_value_3 => xla_lookups_pkg.get_meaning(
75080 p_lookup_type => 'XLA_OWNER_TYPE'
75081 ,p_lookup_code => l_component_type_code
75082 )
75083 ,p_token_4 => 'PRODUCT_NAME'
75084 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
75085 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
75086 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
75087 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
75088 ,p_ae_header_id => NULL
75089 );
75090
75091 IF (C_LEVEL_ERROR>= g_log_level) THEN
75092 trace
75093 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
75094 ,p_level => C_LEVEL_ERROR
75095 ,p_module => l_log_module);
75096 END IF;
75097 END IF;
75098 END IF;
75099 --
75100 --
75101 ------------------------------------------------------------------------------------------------
75102 -- 4219869 Business Flow
75103 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
75104 -- Prior Entry. Currently, the following code is always generated.
75105 ------------------------------------------------------------------------------------------------
75106 XLA_AE_LINES_PKG.ValidateCurrentLine;
75107
75108 ------------------------------------------------------------------------------------
75109 -- 4219869 Business Flow
75110 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
75111 ------------------------------------------------------------------------------------
75112 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
75113
75114 ----------------------------------------------------------------------------------
75115 -- 4219869 Business Flow
75116 -- Update journal entry status -- Need to generate this within IF <condition>
75117 ----------------------------------------------------------------------------------
75118 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
75119 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
75120 ,p_balance_type_code => l_balance_type_code
75121 );
75122
75123 -------------------------------------------------------------------------------------------
75124 -- 4262811 - Generate the Accrual Reversal lines
75125 -------------------------------------------------------------------------------------------
75126 BEGIN
75127 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
75128 (g_array_event(p_event_id).array_value_num('header_index'));
75129 IF l_acc_rev_flag IS NULL THEN
75130 l_acc_rev_flag := 'N';
75131 END IF;
75132 EXCEPTION
75133 WHEN OTHERS THEN
75134 l_acc_rev_flag := 'N';
75135 END;
75136 --
75137 IF (l_acc_rev_flag = 'Y') THEN
75138
75139 -- 4645092 ------------------------------------------------------------------------------
75140 -- To allow MPA report to determine if it should generate report process
75141 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
75142 ------------------------------------------------------------------------------------------
75143
75144 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
75145 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
75146 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
75147 -- call ADRs
75148 -- Bug 4922099
75149 --
75150 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
75151 (NVL(l_actual_upg_option, 'N') = 'O') OR
75152 (NVL(l_enc_upg_option, 'N') = 'O')
75153 )
75154 THEN
75155 NULL;
75156 --
75157 --
75158
75159 l_ccid := AcctDerRule_6(
75160 p_application_id => p_application_id
75161 , p_ae_header_id => l_ae_header_id
75162 , p_source_11 => p_source_11
75163 , x_transaction_coa_id => l_adr_transaction_coa_id
75164 , x_accounting_coa_id => l_adr_accounting_coa_id
75165 , x_value_type_code => l_adr_value_type_code
75166 , p_side => 'NA'
75167 );
75168
75169 xla_ae_lines_pkg.set_ccid(
75170 p_code_combination_id => l_ccid
75171 , p_value_type_code => l_adr_value_type_code
75172 , p_transaction_coa_id => l_adr_transaction_coa_id
75173 , p_accounting_coa_id => l_adr_accounting_coa_id
75174 , p_adr_code => 'CST_DEFAULT'
75175 , p_adr_type_code => 'S'
75176 , p_component_type => l_component_type
75177 , p_component_code => l_component_code
75178 , p_component_type_code => l_component_type_code
75179 , p_component_appl_id => l_component_appl_id
75180 , p_amb_context_code => l_amb_context_code
75181 , p_side => 'NA'
75182 );
75183
75184
75185 --
75186 --
75187 END IF;
75188
75189 --
75190 -- Update the line information that should be overwritten
75191 --
75192 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
75193 p_header_num => 1);
75194 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
75195
75196 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
75197
75198 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
75199 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
75200 END IF;
75201
75202 --
75203 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
75204 --
75205 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
75206 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
75207 ELSE
75208 ---------------------------------------------------------------------------------------------------
75209 -- 4262811a Switch Sign
75210 ---------------------------------------------------------------------------------------------------
75211 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
75212 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
75213 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75214 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
75215 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75216 -- 5132302
75217 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
75218 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75219
75220 END IF;
75221
75222 -- 4955764
75223 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
75224 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
75225
75226
75227 XLA_AE_LINES_PKG.ValidateCurrentLine;
75228 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
75229
75230 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
75231 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
75232 ,p_balance_type_code => l_balance_type_code);
75233
75234 END IF;
75235
75236 -----------------------------------------------------------------------------------------
75237 -- 4262811 Multiperiod Accounting
75238 -----------------------------------------------------------------------------------------
75239 -- No MPA option is assigned.
75240
75241
75242 END IF;
75243 END IF;
75244 --
75245
75246 --
75247 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75248 trace
75249 (p_msg => 'END of AcctLineType_156'
75250 ,p_level => C_LEVEL_PROCEDURE
75251 ,p_module => l_log_module);
75252 END IF;
75253 --
75254 EXCEPTION
75255 WHEN xla_exceptions_pkg.application_exception THEN
75256 RAISE;
75257 WHEN OTHERS THEN
75258 xla_exceptions_pkg.raise_message
75259 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_156');
75260 END AcctLineType_156;
75261 --
75262
75263 ---------------------------------------
75264 --
75265 -- PRIVATE FUNCTION
75266 -- AcctLineType_157
75267 --
75268 ---------------------------------------
75269 PROCEDURE AcctLineType_157 (
75270 p_application_id IN NUMBER
75271 ,p_event_id IN NUMBER
75272 ,p_calculate_acctd_flag IN VARCHAR2
75273 ,p_calculate_g_l_flag IN VARCHAR2
75274 ,p_actual_flag IN OUT VARCHAR2
75275 ,p_balance_type_code OUT VARCHAR2
75276 ,p_gain_or_loss_ref OUT VARCHAR2
75277
75278 --TRANSACTION_ID
75279 , p_source_1 IN NUMBER
75280 --Item Concatenated Segments
75281 , p_source_2 IN VARCHAR2
75282 --Transaction Quantity
75283 , p_source_3 IN NUMBER
75284 --Transaction Unit of Measure Code
75285 , p_source_4 IN VARCHAR2
75286 --Inventory Transaction Type Description
75287 , p_source_5 IN VARCHAR2
75288 --Cost Management Default Account
75289 , p_source_11 IN NUMBER
75290 --DISTRIBUTION_IDENTIFIER
75291 , p_source_84 IN NUMBER
75292 --Distribution Type
75293 , p_source_85 IN VARCHAR2
75294 , p_source_85_meaning IN VARCHAR2
75295 --Entered Currency Code
75296 , p_source_88 IN VARCHAR2
75297 --Entered Amount
75298 , p_source_91 IN NUMBER
75299 --Currency Conversion Date
75300 , p_source_92 IN DATE
75301 --Currency Conversion Rate
75302 , p_source_93 IN NUMBER
75303 --Currency Conversion Type
75304 , p_source_94 IN VARCHAR2
75305 --Accounted Amount
75306 , p_source_95 IN NUMBER
75307 --Accounting Line Type
75308 , p_source_97 IN NUMBER
75309 )
75310 IS
75311
75312 l_component_type VARCHAR2(80);
75313 l_component_code VARCHAR2(30);
75314 l_component_type_code VARCHAR2(1);
75315 l_component_appl_id INTEGER;
75316 l_amb_context_code VARCHAR2(30);
75317 l_entity_code VARCHAR2(30);
75318 l_event_class_code VARCHAR2(30);
75319 l_ae_header_id NUMBER;
75320 l_event_type_code VARCHAR2(30);
75321 l_line_definition_code VARCHAR2(30);
75322 l_line_definition_owner_code VARCHAR2(1);
75323 --
75324 -- adr variables
75325 l_segment VARCHAR2(30);
75326 l_ccid NUMBER;
75327 l_adr_transaction_coa_id NUMBER;
75328 l_adr_accounting_coa_id NUMBER;
75329 l_adr_flexfield_segment_code VARCHAR2(30);
75330 l_adr_flex_value_set_id NUMBER;
75331 l_adr_value_type_code VARCHAR2(30);
75332 l_adr_value_combination_id NUMBER;
75333 l_adr_value_segment_code VARCHAR2(30);
75334
75335 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
75336 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
75337 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
75338 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
75339
75340 -- 4262811 Variables ------------------------------------------------------------------------------------------
75341 l_entered_amt_idx NUMBER;
75342 l_accted_amt_idx NUMBER;
75343 l_acc_rev_flag VARCHAR2(1);
75344 l_accrual_line_num NUMBER;
75345 l_tmp_amt NUMBER;
75346 l_acc_rev_natural_side_code VARCHAR2(1);
75347
75348 l_num_entries NUMBER;
75349 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
75350 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
75351 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
75352 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
75353 l_recog_line_1 NUMBER;
75354 l_recog_line_2 NUMBER;
75355
75356 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
75357 l_bflow_applied_to_amt NUMBER; -- 5132302
75358 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
75359
75360 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
75361
75362 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
75363 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
75364
75365 ---------------------------------------------------------------------------------------------------------------
75366
75367
75368 --
75369 -- bulk performance
75370 --
75371 l_balance_type_code VARCHAR2(1);
75372 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
75373 l_log_module VARCHAR2(240);
75374
75375 --
75376 -- Upgrade strategy
75377 --
75378 l_actual_upg_option VARCHAR2(1);
75379 l_enc_upg_option VARCHAR2(1);
75380
75381 --
75382 BEGIN
75383 --
75384 IF g_log_enabled THEN
75385 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_157';
75386 END IF;
75387 --
75388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75389
75390 trace
75391 (p_msg => 'BEGIN of AcctLineType_157'
75392 ,p_level => C_LEVEL_PROCEDURE
75393 ,p_module => l_log_module);
75394
75395 END IF;
75396 --
75397 l_component_type := 'AMB_JLT';
75398 l_component_code := 'INTERORG_PAYABLES';
75399 l_component_type_code := 'S';
75400 l_component_appl_id := 707;
75401 l_amb_context_code := 'DEFAULT';
75402 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
75403 l_event_class_code := 'INT_ORDER_TO_EXP';
75404 l_event_type_code := 'INT_ORDER_ISSUE_TP';
75405 l_line_definition_owner_code := 'S';
75406 l_line_definition_code := 'PI_INT_ORDER_ISSUE_TP';
75407 --
75408 l_balance_type_code := 'A';
75409 l_segment := NULL;
75410 l_ccid := NULL;
75411 l_adr_transaction_coa_id := NULL;
75412 l_adr_accounting_coa_id := NULL;
75413 l_adr_flexfield_segment_code := NULL;
75414 l_adr_flex_value_set_id := NULL;
75415 l_adr_value_type_code := NULL;
75416 l_adr_value_combination_id := NULL;
75417 l_adr_value_segment_code := NULL;
75418
75419 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
75420 l_bflow_class_code := ''; -- 4219869 Business Flow
75421 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
75422 l_budgetary_control_flag := 'N';
75423
75424 l_bflow_applied_to_amt_idx := NULL; -- 5132302
75425 l_bflow_applied_to_amt := NULL; -- 5132302
75426 l_entered_amt_idx := NULL; -- 4262811
75427 l_accted_amt_idx := NULL; -- 4262811
75428 l_acc_rev_flag := NULL; -- 4262811
75429 l_accrual_line_num := NULL; -- 4262811
75430 l_tmp_amt := NULL; -- 4262811
75431 --
75432
75433 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
75434 l_balance_type_code <> 'B' THEN
75435 IF NVL(p_source_97,9E125) = 9
75436 THEN
75437
75438 --
75439 XLA_AE_LINES_PKG.SetNewLine;
75440
75441 p_balance_type_code := l_balance_type_code;
75442 -- set the flag so later we will know whether the gain loss line needs to be created
75443
75444 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
75445 p_actual_flag :='A';
75446 END IF;
75447
75448 --
75449 -- bulk performance
75450 --
75451 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
75452 p_header_num => 0); -- 4262811
75453 --
75454 -- set accounting line options
75455 --
75456 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
75457 p_natural_side_code => 'D'
75458 , p_gain_or_loss_flag => 'N'
75459 , p_gl_transfer_mode_code => 'S'
75460 , p_acct_entry_type_code => 'A'
75461 , p_switch_side_flag => 'Y'
75462 , p_merge_duplicate_code => 'N'
75463 );
75464 --
75465 l_acc_rev_natural_side_code := 'C'; -- 4262811
75466 --
75467 --
75468 -- set accounting line type info
75469 --
75470 xla_ae_lines_pkg.SetAcctLineType
75471 (p_component_type => l_component_type
75472 ,p_event_type_code => l_event_type_code
75473 ,p_line_definition_owner_code => l_line_definition_owner_code
75474 ,p_line_definition_code => l_line_definition_code
75475 ,p_accounting_line_code => l_component_code
75476 ,p_accounting_line_type_code => l_component_type_code
75477 ,p_accounting_line_appl_id => l_component_appl_id
75478 ,p_amb_context_code => l_amb_context_code
75479 ,p_entity_code => l_entity_code
75480 ,p_event_class_code => l_event_class_code);
75481 --
75482 -- set accounting class
75483 --
75484 xla_ae_lines_pkg.SetAcctClass(
75485 p_accounting_class_code => 'INTERORG_PAYABLES'
75486 , p_ae_header_id => l_ae_header_id
75487 );
75488
75489 --
75490 -- set rounding class
75491 --
75492 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
75493 'INTERORG_PAYABLES';
75494
75495 --
75496 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
75497 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
75498 --
75499 -- bulk performance
75500 --
75501 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
75502
75503 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
75504 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
75505
75506 -- 4955764
75507 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
75508 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
75509
75510 -- 4458381 Public Sector Enh
75511
75512 --
75513 -- set accounting attributes for the line type
75514 --
75515 l_entered_amt_idx := 3;
75516 l_accted_amt_idx := 8;
75517 l_bflow_applied_to_amt_idx := NULL; -- 5132302
75518 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
75519 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
75520 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
75521 l_rec_acct_attrs.array_char_value(2) := p_source_85;
75522 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
75523 l_rec_acct_attrs.array_num_value(3) := p_source_91;
75524 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
75525 l_rec_acct_attrs.array_char_value(4) := p_source_88;
75526 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
75527 l_rec_acct_attrs.array_date_value(5) := p_source_92;
75528 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
75529 l_rec_acct_attrs.array_num_value(6) := p_source_93;
75530 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
75531 l_rec_acct_attrs.array_char_value(7) := p_source_94;
75532 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
75533 l_rec_acct_attrs.array_num_value(8) := p_source_95;
75534
75535 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
75536 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
75537
75538 ---------------------------------------------------------------------------------------------------------------
75539 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
75540 ---------------------------------------------------------------------------------------------------------------
75541 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
75542
75543 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
75544 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
75545
75546 IF xla_accounting_cache_pkg.GetValueChar
75547 (p_source_code => 'LEDGER_CATEGORY_CODE'
75548 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
75549 AND l_bflow_method_code = 'PRIOR_ENTRY'
75550 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
75551 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
75552 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
75553 )
75554 THEN
75555 xla_ae_lines_pkg.BflowUpgEntry
75556 (p_business_method_code => l_bflow_method_code
75557 ,p_business_class_code => l_bflow_class_code
75558 ,p_balance_type => l_balance_type_code);
75559 ELSE
75560 NULL;
75561 -- No business flow processing for business flow method of NONE.
75562 END IF;
75563
75564 --
75565 -- call analytical criteria
75566 --
75567
75568 --
75569 -- call description
75570 --
75571
75572 xla_ae_lines_pkg.SetLineDescription(
75573 p_ae_header_id => l_ae_header_id
75574 ,p_description => Description_1 (
75575 p_application_id => p_application_id
75576 , p_ae_header_id => l_ae_header_id
75577 , p_source_1 => p_source_1
75578 , p_source_2 => p_source_2
75579 , p_source_3 => p_source_3
75580 , p_source_4 => p_source_4
75581 , p_source_5 => p_source_5
75582 )
75583 );
75584
75585
75586 --
75587 -- call ADRs
75588 -- Bug 4922099
75589 --
75590 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
75591 (NVL(l_actual_upg_option, 'N') = 'O') OR
75592 (NVL(l_enc_upg_option, 'N') = 'O')
75593 )
75594 THEN
75595 NULL;
75596 --
75597 --
75598
75599 l_ccid := AcctDerRule_6(
75600 p_application_id => p_application_id
75601 , p_ae_header_id => l_ae_header_id
75602 , p_source_11 => p_source_11
75603 , x_transaction_coa_id => l_adr_transaction_coa_id
75604 , x_accounting_coa_id => l_adr_accounting_coa_id
75605 , x_value_type_code => l_adr_value_type_code
75606 , p_side => 'NA'
75607 );
75608
75609 xla_ae_lines_pkg.set_ccid(
75610 p_code_combination_id => l_ccid
75611 , p_value_type_code => l_adr_value_type_code
75612 , p_transaction_coa_id => l_adr_transaction_coa_id
75613 , p_accounting_coa_id => l_adr_accounting_coa_id
75614 , p_adr_code => 'CST_DEFAULT'
75615 , p_adr_type_code => 'S'
75616 , p_component_type => l_component_type
75617 , p_component_code => l_component_code
75618 , p_component_type_code => l_component_type_code
75619 , p_component_appl_id => l_component_appl_id
75620 , p_amb_context_code => l_amb_context_code
75621 , p_side => 'NA'
75622 );
75623
75624
75625 --
75626 --
75627 END IF;
75628 --
75629 -- Bug 4922099
75630 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
75631 (NVL(l_enc_upg_option, 'N') = 'O')
75632 ) AND
75633 (l_bflow_method_code = 'PRIOR_ENTRY')
75634 )
75635 THEN
75636 IF
75637 --
75638 1 = 2
75639 --
75640 THEN
75641 xla_accounting_err_pkg.build_message
75642 (p_appli_s_name => 'XLA'
75643 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
75644 ,p_token_1 => 'LINE_NUMBER'
75645 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
75646 ,p_token_2 => 'LINE_TYPE_NAME'
75647 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
75648 l_component_type
75649 ,l_component_code
75650 ,l_component_type_code
75651 ,l_component_appl_id
75652 ,l_amb_context_code
75653 ,l_entity_code
75654 ,l_event_class_code
75655 )
75656 ,p_token_3 => 'OWNER'
75657 ,p_value_3 => xla_lookups_pkg.get_meaning(
75658 p_lookup_type => 'XLA_OWNER_TYPE'
75659 ,p_lookup_code => l_component_type_code
75660 )
75661 ,p_token_4 => 'PRODUCT_NAME'
75662 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
75663 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
75664 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
75665 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
75666 ,p_ae_header_id => NULL
75667 );
75668
75669 IF (C_LEVEL_ERROR>= g_log_level) THEN
75670 trace
75671 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
75672 ,p_level => C_LEVEL_ERROR
75673 ,p_module => l_log_module);
75674 END IF;
75675 END IF;
75676 END IF;
75677 --
75678 --
75679 ------------------------------------------------------------------------------------------------
75680 -- 4219869 Business Flow
75681 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
75682 -- Prior Entry. Currently, the following code is always generated.
75683 ------------------------------------------------------------------------------------------------
75684 XLA_AE_LINES_PKG.ValidateCurrentLine;
75685
75686 ------------------------------------------------------------------------------------
75687 -- 4219869 Business Flow
75688 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
75689 ------------------------------------------------------------------------------------
75690 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
75691
75692 ----------------------------------------------------------------------------------
75693 -- 4219869 Business Flow
75694 -- Update journal entry status -- Need to generate this within IF <condition>
75695 ----------------------------------------------------------------------------------
75696 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
75697 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
75698 ,p_balance_type_code => l_balance_type_code
75699 );
75700
75701 -------------------------------------------------------------------------------------------
75702 -- 4262811 - Generate the Accrual Reversal lines
75703 -------------------------------------------------------------------------------------------
75704 BEGIN
75705 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
75706 (g_array_event(p_event_id).array_value_num('header_index'));
75707 IF l_acc_rev_flag IS NULL THEN
75708 l_acc_rev_flag := 'N';
75709 END IF;
75710 EXCEPTION
75711 WHEN OTHERS THEN
75712 l_acc_rev_flag := 'N';
75713 END;
75714 --
75715 IF (l_acc_rev_flag = 'Y') THEN
75716
75717 -- 4645092 ------------------------------------------------------------------------------
75718 -- To allow MPA report to determine if it should generate report process
75719 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
75720 ------------------------------------------------------------------------------------------
75721
75722 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
75723 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
75724 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
75725 -- call ADRs
75726 -- Bug 4922099
75727 --
75728 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
75729 (NVL(l_actual_upg_option, 'N') = 'O') OR
75730 (NVL(l_enc_upg_option, 'N') = 'O')
75731 )
75732 THEN
75733 NULL;
75734 --
75735 --
75736
75737 l_ccid := AcctDerRule_6(
75738 p_application_id => p_application_id
75739 , p_ae_header_id => l_ae_header_id
75740 , p_source_11 => p_source_11
75741 , x_transaction_coa_id => l_adr_transaction_coa_id
75742 , x_accounting_coa_id => l_adr_accounting_coa_id
75743 , x_value_type_code => l_adr_value_type_code
75744 , p_side => 'NA'
75745 );
75746
75747 xla_ae_lines_pkg.set_ccid(
75748 p_code_combination_id => l_ccid
75749 , p_value_type_code => l_adr_value_type_code
75750 , p_transaction_coa_id => l_adr_transaction_coa_id
75751 , p_accounting_coa_id => l_adr_accounting_coa_id
75752 , p_adr_code => 'CST_DEFAULT'
75753 , p_adr_type_code => 'S'
75754 , p_component_type => l_component_type
75755 , p_component_code => l_component_code
75756 , p_component_type_code => l_component_type_code
75757 , p_component_appl_id => l_component_appl_id
75758 , p_amb_context_code => l_amb_context_code
75759 , p_side => 'NA'
75760 );
75761
75762
75763 --
75764 --
75765 END IF;
75766
75767 --
75768 -- Update the line information that should be overwritten
75769 --
75770 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
75771 p_header_num => 1);
75772 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
75773
75774 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
75775
75776 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
75777 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
75778 END IF;
75779
75780 --
75781 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
75782 --
75783 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
75784 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
75785 ELSE
75786 ---------------------------------------------------------------------------------------------------
75787 -- 4262811a Switch Sign
75788 ---------------------------------------------------------------------------------------------------
75789 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
75790 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
75791 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75792 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
75793 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75794 -- 5132302
75795 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
75796 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
75797
75798 END IF;
75799
75800 -- 4955764
75801 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
75802 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
75803
75804
75805 XLA_AE_LINES_PKG.ValidateCurrentLine;
75806 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
75807
75808 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
75809 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
75810 ,p_balance_type_code => l_balance_type_code);
75811
75812 END IF;
75813
75814 -----------------------------------------------------------------------------------------
75815 -- 4262811 Multiperiod Accounting
75816 -----------------------------------------------------------------------------------------
75817 -- No MPA option is assigned.
75818
75819
75820 END IF;
75821 END IF;
75822 --
75823
75824 --
75825 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75826 trace
75827 (p_msg => 'END of AcctLineType_157'
75828 ,p_level => C_LEVEL_PROCEDURE
75829 ,p_module => l_log_module);
75830 END IF;
75831 --
75832 EXCEPTION
75833 WHEN xla_exceptions_pkg.application_exception THEN
75834 RAISE;
75835 WHEN OTHERS THEN
75836 xla_exceptions_pkg.raise_message
75837 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_157');
75838 END AcctLineType_157;
75839 --
75840
75841 ---------------------------------------
75842 --
75843 -- PRIVATE FUNCTION
75844 -- AcctLineType_158
75845 --
75846 ---------------------------------------
75847 PROCEDURE AcctLineType_158 (
75848 p_application_id IN NUMBER
75849 ,p_event_id IN NUMBER
75850 ,p_calculate_acctd_flag IN VARCHAR2
75851 ,p_calculate_g_l_flag IN VARCHAR2
75852 ,p_actual_flag IN OUT VARCHAR2
75853 ,p_balance_type_code OUT VARCHAR2
75854 ,p_gain_or_loss_ref OUT VARCHAR2
75855
75856 --TRANSACTION_ID
75857 , p_source_1 IN NUMBER
75858 --Item Concatenated Segments
75859 , p_source_2 IN VARCHAR2
75860 --Transaction Quantity
75861 , p_source_3 IN NUMBER
75862 --Transaction Unit of Measure Code
75863 , p_source_4 IN VARCHAR2
75864 --Inventory Transaction Type Description
75865 , p_source_5 IN VARCHAR2
75866 --Interorg Payables Account
75867 , p_source_35 IN NUMBER
75868 --Applied to Application ID
75869 , p_source_79 IN NUMBER
75870 --Applied to Distribution Link Type
75871 , p_source_80 IN VARCHAR2
75872 --Applied to Entity Code
75873 , p_source_81 IN VARCHAR2
75874 --DISTRIBUTION_IDENTIFIER
75875 , p_source_84 IN NUMBER
75876 --Distribution Type
75877 , p_source_85 IN VARCHAR2
75878 , p_source_85_meaning IN VARCHAR2
75879 --Encumbrance Reversal Amount Entered
75880 , p_source_87 IN NUMBER
75881 --Entered Currency Code
75882 , p_source_88 IN VARCHAR2
75883 --Transaction Encumbrance Reversal Amount
75884 , p_source_89 IN NUMBER
75885 --Entered Amount
75886 , p_source_91 IN NUMBER
75887 --Currency Conversion Date
75888 , p_source_92 IN DATE
75889 --Currency Conversion Rate
75890 , p_source_93 IN NUMBER
75891 --Currency Conversion Type
75892 , p_source_94 IN VARCHAR2
75893 --Accounted Amount
75894 , p_source_95 IN NUMBER
75895 --Accounting Line Type
75896 , p_source_97 IN NUMBER
75897 --Costing Encumbrance Upgrade Option
75898 , p_source_100 IN VARCHAR2
75899 --TXN_PO_DISTRIBUTION_ID
75900 , p_source_101 IN NUMBER
75901 --TXN_PO_HEADER_ID
75902 , p_source_102 IN NUMBER
75903 --Requisition Budget Account
75904 , p_source_103 IN NUMBER
75905 --Requisition Encumbrance Type Identifier
75906 , p_source_104 IN NUMBER
75907 )
75908 IS
75909
75910 l_component_type VARCHAR2(80);
75911 l_component_code VARCHAR2(30);
75912 l_component_type_code VARCHAR2(1);
75913 l_component_appl_id INTEGER;
75914 l_amb_context_code VARCHAR2(30);
75915 l_entity_code VARCHAR2(30);
75916 l_event_class_code VARCHAR2(30);
75917 l_ae_header_id NUMBER;
75918 l_event_type_code VARCHAR2(30);
75919 l_line_definition_code VARCHAR2(30);
75920 l_line_definition_owner_code VARCHAR2(1);
75921 --
75922 -- adr variables
75923 l_segment VARCHAR2(30);
75924 l_ccid NUMBER;
75925 l_adr_transaction_coa_id NUMBER;
75926 l_adr_accounting_coa_id NUMBER;
75927 l_adr_flexfield_segment_code VARCHAR2(30);
75928 l_adr_flex_value_set_id NUMBER;
75929 l_adr_value_type_code VARCHAR2(30);
75930 l_adr_value_combination_id NUMBER;
75931 l_adr_value_segment_code VARCHAR2(30);
75932
75933 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
75934 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
75935 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
75936 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
75937
75938 -- 4262811 Variables ------------------------------------------------------------------------------------------
75939 l_entered_amt_idx NUMBER;
75940 l_accted_amt_idx NUMBER;
75941 l_acc_rev_flag VARCHAR2(1);
75942 l_accrual_line_num NUMBER;
75943 l_tmp_amt NUMBER;
75944 l_acc_rev_natural_side_code VARCHAR2(1);
75945
75946 l_num_entries NUMBER;
75947 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
75948 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
75949 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
75950 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
75951 l_recog_line_1 NUMBER;
75952 l_recog_line_2 NUMBER;
75953
75954 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
75955 l_bflow_applied_to_amt NUMBER; -- 5132302
75956 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
75957
75958 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
75959
75960 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
75961 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
75962
75963 ---------------------------------------------------------------------------------------------------------------
75964
75965
75966 --
75967 -- bulk performance
75968 --
75969 l_balance_type_code VARCHAR2(1);
75970 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
75971 l_log_module VARCHAR2(240);
75972
75973 --
75974 -- Upgrade strategy
75975 --
75976 l_actual_upg_option VARCHAR2(1);
75977 l_enc_upg_option VARCHAR2(1);
75978
75979 --
75980 BEGIN
75981 --
75982 IF g_log_enabled THEN
75983 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_158';
75984 END IF;
75985 --
75986 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75987
75988 trace
75989 (p_msg => 'BEGIN of AcctLineType_158'
75990 ,p_level => C_LEVEL_PROCEDURE
75991 ,p_module => l_log_module);
75992
75993 END IF;
75994 --
75995 l_component_type := 'AMB_JLT';
75996 l_component_code := 'INTERORG_PAYABLES';
75997 l_component_type_code := 'S';
75998 l_component_appl_id := 707;
75999 l_amb_context_code := 'DEFAULT';
76000 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
76001 l_event_class_code := 'DIR_INTERORG_RCPT';
76002 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
76003 l_line_definition_owner_code := 'S';
76004 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
76005 --
76006 l_balance_type_code := 'A';
76007 l_segment := NULL;
76008 l_ccid := NULL;
76009 l_adr_transaction_coa_id := NULL;
76010 l_adr_accounting_coa_id := NULL;
76011 l_adr_flexfield_segment_code := NULL;
76012 l_adr_flex_value_set_id := NULL;
76013 l_adr_value_type_code := NULL;
76014 l_adr_value_combination_id := NULL;
76015 l_adr_value_segment_code := NULL;
76016
76017 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
76018 l_bflow_class_code := ''; -- 4219869 Business Flow
76019 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
76020 l_budgetary_control_flag := 'N';
76021
76022 l_bflow_applied_to_amt_idx := NULL; -- 5132302
76023 l_bflow_applied_to_amt := NULL; -- 5132302
76024 l_entered_amt_idx := NULL; -- 4262811
76025 l_accted_amt_idx := NULL; -- 4262811
76026 l_acc_rev_flag := NULL; -- 4262811
76027 l_accrual_line_num := NULL; -- 4262811
76028 l_tmp_amt := NULL; -- 4262811
76029 --
76030
76031 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
76032 l_balance_type_code <> 'B' THEN
76033 IF NVL(p_source_97,9E125) = 9
76034 THEN
76035
76036 --
76037 XLA_AE_LINES_PKG.SetNewLine;
76038
76039 p_balance_type_code := l_balance_type_code;
76040 -- set the flag so later we will know whether the gain loss line needs to be created
76041
76042 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
76043 p_actual_flag :='A';
76044 END IF;
76045
76046 --
76047 -- bulk performance
76048 --
76049 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
76050 p_header_num => 0); -- 4262811
76051 --
76052 -- set accounting line options
76053 --
76054 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
76055 p_natural_side_code => 'D'
76056 , p_gain_or_loss_flag => 'N'
76057 , p_gl_transfer_mode_code => 'S'
76058 , p_acct_entry_type_code => 'A'
76059 , p_switch_side_flag => 'Y'
76060 , p_merge_duplicate_code => 'N'
76061 );
76062 --
76063 l_acc_rev_natural_side_code := 'C'; -- 4262811
76064 --
76065 --
76066 -- set accounting line type info
76067 --
76068 xla_ae_lines_pkg.SetAcctLineType
76069 (p_component_type => l_component_type
76070 ,p_event_type_code => l_event_type_code
76071 ,p_line_definition_owner_code => l_line_definition_owner_code
76072 ,p_line_definition_code => l_line_definition_code
76073 ,p_accounting_line_code => l_component_code
76074 ,p_accounting_line_type_code => l_component_type_code
76075 ,p_accounting_line_appl_id => l_component_appl_id
76076 ,p_amb_context_code => l_amb_context_code
76077 ,p_entity_code => l_entity_code
76078 ,p_event_class_code => l_event_class_code);
76079 --
76080 -- set accounting class
76081 --
76082 xla_ae_lines_pkg.SetAcctClass(
76083 p_accounting_class_code => 'INTERORG_PAYABLES'
76084 , p_ae_header_id => l_ae_header_id
76085 );
76086
76087 --
76088 -- set rounding class
76089 --
76090 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
76091 'INTERORG_PAYABLES';
76092
76093 --
76094 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
76095 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
76096 --
76097 -- bulk performance
76098 --
76099 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
76100
76101 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
76102 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
76103
76104 -- 4955764
76105 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
76106 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
76107
76108 -- 4458381 Public Sector Enh
76109
76110 --
76111 -- set accounting attributes for the line type
76112 --
76113 l_entered_amt_idx := 17;
76114 l_accted_amt_idx := 22;
76115 l_bflow_applied_to_amt_idx := NULL; -- 5132302
76116 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
76117 l_rec_acct_attrs.array_num_value(1) := p_source_79;
76118 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
76119 l_rec_acct_attrs.array_char_value(2) := p_source_80;
76120 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
76121 l_rec_acct_attrs.array_char_value(3) := p_source_81;
76122 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
76123 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
76124 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
76125 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
76126 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
76127 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
76128 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
76129 l_rec_acct_attrs.array_char_value(7) := p_source_85;
76130 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
76131 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
76132 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
76133 l_rec_acct_attrs.array_num_value(9) := p_source_87;
76134 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
76135 l_rec_acct_attrs.array_char_value(10) := p_source_88;
76136 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
76137 l_rec_acct_attrs.array_num_value(11) := p_source_89;
76138 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
76139 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
76140 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
76141 l_rec_acct_attrs.array_num_value(13) := p_source_87;
76142 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
76143 l_rec_acct_attrs.array_char_value(14) := p_source_88;
76144 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
76145 l_rec_acct_attrs.array_num_value(15) := p_source_89;
76146 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
76147 l_rec_acct_attrs.array_char_value(16) := p_source_100;
76148 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
76149 l_rec_acct_attrs.array_num_value(17) := p_source_91;
76150 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
76151 l_rec_acct_attrs.array_char_value(18) := p_source_88;
76152 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
76153 l_rec_acct_attrs.array_date_value(19) := p_source_92;
76154 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
76155 l_rec_acct_attrs.array_num_value(20) := p_source_93;
76156 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
76157 l_rec_acct_attrs.array_char_value(21) := p_source_94;
76158 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
76159 l_rec_acct_attrs.array_num_value(22) := p_source_95;
76160 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
76161 l_rec_acct_attrs.array_num_value(23) := p_source_104;
76162 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
76163 l_rec_acct_attrs.array_num_value(24) := p_source_104;
76164
76165 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
76166 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
76167
76168 ---------------------------------------------------------------------------------------------------------------
76169 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
76170 ---------------------------------------------------------------------------------------------------------------
76171 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
76172
76173 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
76174 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
76175
76176 IF xla_accounting_cache_pkg.GetValueChar
76177 (p_source_code => 'LEDGER_CATEGORY_CODE'
76178 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
76179 AND l_bflow_method_code = 'PRIOR_ENTRY'
76180 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
76181 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
76182 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
76183 )
76184 THEN
76185 xla_ae_lines_pkg.BflowUpgEntry
76186 (p_business_method_code => l_bflow_method_code
76187 ,p_business_class_code => l_bflow_class_code
76188 ,p_balance_type => l_balance_type_code);
76189 ELSE
76190 NULL;
76191 -- No business flow processing for business flow method of NONE.
76192 END IF;
76193
76194 --
76195 -- call analytical criteria
76196 --
76197
76198 --
76199 -- call description
76200 --
76201
76202 xla_ae_lines_pkg.SetLineDescription(
76203 p_ae_header_id => l_ae_header_id
76204 ,p_description => Description_1 (
76205 p_application_id => p_application_id
76206 , p_ae_header_id => l_ae_header_id
76207 , p_source_1 => p_source_1
76208 , p_source_2 => p_source_2
76209 , p_source_3 => p_source_3
76210 , p_source_4 => p_source_4
76211 , p_source_5 => p_source_5
76212 )
76213 );
76214
76215
76216 --
76217 -- call ADRs
76218 -- Bug 4922099
76219 --
76220 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
76221 (NVL(l_actual_upg_option, 'N') = 'O') OR
76222 (NVL(l_enc_upg_option, 'N') = 'O')
76223 )
76224 THEN
76225 NULL;
76226 --
76227 --
76228
76229 l_ccid := AcctDerRule_20(
76230 p_application_id => p_application_id
76231 , p_ae_header_id => l_ae_header_id
76232 , p_source_35 => p_source_35
76233 , x_transaction_coa_id => l_adr_transaction_coa_id
76234 , x_accounting_coa_id => l_adr_accounting_coa_id
76235 , x_value_type_code => l_adr_value_type_code
76236 , p_side => 'NA'
76237 );
76238
76239 xla_ae_lines_pkg.set_ccid(
76240 p_code_combination_id => l_ccid
76241 , p_value_type_code => l_adr_value_type_code
76242 , p_transaction_coa_id => l_adr_transaction_coa_id
76243 , p_accounting_coa_id => l_adr_accounting_coa_id
76244 , p_adr_code => 'PI_INTERORG_PAYABLES'
76245 , p_adr_type_code => 'S'
76246 , p_component_type => l_component_type
76247 , p_component_code => l_component_code
76248 , p_component_type_code => l_component_type_code
76249 , p_component_appl_id => l_component_appl_id
76250 , p_amb_context_code => l_amb_context_code
76251 , p_side => 'NA'
76252 );
76253
76254
76255 --
76256 --
76257 END IF;
76258 --
76259 -- Bug 4922099
76260 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
76261 (NVL(l_enc_upg_option, 'N') = 'O')
76262 ) AND
76263 (l_bflow_method_code = 'PRIOR_ENTRY')
76264 )
76265 THEN
76266 IF
76267 --
76268 1 = 2
76269 --
76270 THEN
76271 xla_accounting_err_pkg.build_message
76272 (p_appli_s_name => 'XLA'
76273 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
76274 ,p_token_1 => 'LINE_NUMBER'
76275 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
76276 ,p_token_2 => 'LINE_TYPE_NAME'
76277 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
76278 l_component_type
76279 ,l_component_code
76280 ,l_component_type_code
76281 ,l_component_appl_id
76282 ,l_amb_context_code
76283 ,l_entity_code
76284 ,l_event_class_code
76285 )
76286 ,p_token_3 => 'OWNER'
76287 ,p_value_3 => xla_lookups_pkg.get_meaning(
76288 p_lookup_type => 'XLA_OWNER_TYPE'
76289 ,p_lookup_code => l_component_type_code
76290 )
76291 ,p_token_4 => 'PRODUCT_NAME'
76292 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
76293 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
76294 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
76295 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
76296 ,p_ae_header_id => NULL
76297 );
76298
76299 IF (C_LEVEL_ERROR>= g_log_level) THEN
76300 trace
76301 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
76302 ,p_level => C_LEVEL_ERROR
76303 ,p_module => l_log_module);
76304 END IF;
76305 END IF;
76306 END IF;
76307 --
76308 --
76309 ------------------------------------------------------------------------------------------------
76310 -- 4219869 Business Flow
76311 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
76312 -- Prior Entry. Currently, the following code is always generated.
76313 ------------------------------------------------------------------------------------------------
76314 XLA_AE_LINES_PKG.ValidateCurrentLine;
76315
76316 ------------------------------------------------------------------------------------
76317 -- 4219869 Business Flow
76318 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
76319 ------------------------------------------------------------------------------------
76320 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
76321
76322 ----------------------------------------------------------------------------------
76323 -- 4219869 Business Flow
76324 -- Update journal entry status -- Need to generate this within IF <condition>
76325 ----------------------------------------------------------------------------------
76326 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
76327 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
76328 ,p_balance_type_code => l_balance_type_code
76329 );
76330
76331 -------------------------------------------------------------------------------------------
76332 -- 4262811 - Generate the Accrual Reversal lines
76333 -------------------------------------------------------------------------------------------
76334 BEGIN
76335 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
76336 (g_array_event(p_event_id).array_value_num('header_index'));
76337 IF l_acc_rev_flag IS NULL THEN
76338 l_acc_rev_flag := 'N';
76339 END IF;
76340 EXCEPTION
76341 WHEN OTHERS THEN
76342 l_acc_rev_flag := 'N';
76343 END;
76344 --
76345 IF (l_acc_rev_flag = 'Y') THEN
76346
76347 -- 4645092 ------------------------------------------------------------------------------
76348 -- To allow MPA report to determine if it should generate report process
76349 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
76350 ------------------------------------------------------------------------------------------
76351
76352 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
76353 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
76354 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
76355 -- call ADRs
76356 -- Bug 4922099
76357 --
76358 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
76359 (NVL(l_actual_upg_option, 'N') = 'O') OR
76360 (NVL(l_enc_upg_option, 'N') = 'O')
76361 )
76362 THEN
76363 NULL;
76364 --
76365 --
76366
76367 l_ccid := AcctDerRule_20(
76368 p_application_id => p_application_id
76369 , p_ae_header_id => l_ae_header_id
76370 , p_source_35 => p_source_35
76371 , x_transaction_coa_id => l_adr_transaction_coa_id
76372 , x_accounting_coa_id => l_adr_accounting_coa_id
76373 , x_value_type_code => l_adr_value_type_code
76374 , p_side => 'NA'
76375 );
76376
76377 xla_ae_lines_pkg.set_ccid(
76378 p_code_combination_id => l_ccid
76379 , p_value_type_code => l_adr_value_type_code
76380 , p_transaction_coa_id => l_adr_transaction_coa_id
76381 , p_accounting_coa_id => l_adr_accounting_coa_id
76382 , p_adr_code => 'PI_INTERORG_PAYABLES'
76383 , p_adr_type_code => 'S'
76384 , p_component_type => l_component_type
76385 , p_component_code => l_component_code
76386 , p_component_type_code => l_component_type_code
76387 , p_component_appl_id => l_component_appl_id
76388 , p_amb_context_code => l_amb_context_code
76389 , p_side => 'NA'
76390 );
76391
76392
76393 --
76394 --
76395 END IF;
76396
76397 --
76398 -- Update the line information that should be overwritten
76399 --
76400 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
76401 p_header_num => 1);
76402 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
76403
76404 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
76405
76406 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
76407 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
76408 END IF;
76409
76410 --
76411 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
76412 --
76413 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
76414 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
76415 ELSE
76416 ---------------------------------------------------------------------------------------------------
76417 -- 4262811a Switch Sign
76418 ---------------------------------------------------------------------------------------------------
76419 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
76420 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
76421 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
76422 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
76423 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
76424 -- 5132302
76425 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
76426 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
76427
76428 END IF;
76429
76430 -- 4955764
76431 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
76432 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
76433
76434
76435 XLA_AE_LINES_PKG.ValidateCurrentLine;
76436 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
76437
76438 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
76439 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
76440 ,p_balance_type_code => l_balance_type_code);
76441
76442 END IF;
76443
76444 -----------------------------------------------------------------------------------------
76445 -- 4262811 Multiperiod Accounting
76446 -----------------------------------------------------------------------------------------
76447 -- No MPA option is assigned.
76448
76449
76450 END IF;
76451 END IF;
76452 --
76453
76454 --
76455 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76456 trace
76457 (p_msg => 'END of AcctLineType_158'
76458 ,p_level => C_LEVEL_PROCEDURE
76459 ,p_module => l_log_module);
76460 END IF;
76461 --
76462 EXCEPTION
76463 WHEN xla_exceptions_pkg.application_exception THEN
76464 RAISE;
76465 WHEN OTHERS THEN
76466 xla_exceptions_pkg.raise_message
76467 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_158');
76468 END AcctLineType_158;
76469 --
76470
76471 ---------------------------------------
76472 --
76473 -- PRIVATE FUNCTION
76474 -- AcctLineType_159
76475 --
76476 ---------------------------------------
76477 PROCEDURE AcctLineType_159 (
76478 p_application_id IN NUMBER
76479 ,p_event_id IN NUMBER
76480 ,p_calculate_acctd_flag IN VARCHAR2
76481 ,p_calculate_g_l_flag IN VARCHAR2
76482 ,p_actual_flag IN OUT VARCHAR2
76483 ,p_balance_type_code OUT VARCHAR2
76484 ,p_gain_or_loss_ref OUT VARCHAR2
76485
76486 --TRANSACTION_ID
76487 , p_source_1 IN NUMBER
76488 --Item Concatenated Segments
76489 , p_source_2 IN VARCHAR2
76490 --Transaction Quantity
76491 , p_source_3 IN NUMBER
76492 --Transaction Unit of Measure Code
76493 , p_source_4 IN VARCHAR2
76494 --Inventory Transaction Type Description
76495 , p_source_5 IN VARCHAR2
76496 --Cost Management Default Account
76497 , p_source_11 IN NUMBER
76498 --DISTRIBUTION_IDENTIFIER
76499 , p_source_84 IN NUMBER
76500 --Distribution Type
76501 , p_source_85 IN VARCHAR2
76502 , p_source_85_meaning IN VARCHAR2
76503 --Entered Currency Code
76504 , p_source_88 IN VARCHAR2
76505 --Entered Amount
76506 , p_source_91 IN NUMBER
76507 --Currency Conversion Date
76508 , p_source_92 IN DATE
76509 --Currency Conversion Rate
76510 , p_source_93 IN NUMBER
76511 --Currency Conversion Type
76512 , p_source_94 IN VARCHAR2
76513 --Accounted Amount
76514 , p_source_95 IN NUMBER
76515 --Accounting Line Type
76516 , p_source_97 IN NUMBER
76517 )
76518 IS
76519
76520 l_component_type VARCHAR2(80);
76521 l_component_code VARCHAR2(30);
76522 l_component_type_code VARCHAR2(1);
76523 l_component_appl_id INTEGER;
76524 l_amb_context_code VARCHAR2(30);
76525 l_entity_code VARCHAR2(30);
76526 l_event_class_code VARCHAR2(30);
76527 l_ae_header_id NUMBER;
76528 l_event_type_code VARCHAR2(30);
76529 l_line_definition_code VARCHAR2(30);
76530 l_line_definition_owner_code VARCHAR2(1);
76531 --
76532 -- adr variables
76533 l_segment VARCHAR2(30);
76534 l_ccid NUMBER;
76535 l_adr_transaction_coa_id NUMBER;
76536 l_adr_accounting_coa_id NUMBER;
76537 l_adr_flexfield_segment_code VARCHAR2(30);
76538 l_adr_flex_value_set_id NUMBER;
76539 l_adr_value_type_code VARCHAR2(30);
76540 l_adr_value_combination_id NUMBER;
76541 l_adr_value_segment_code VARCHAR2(30);
76542
76543 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
76544 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
76545 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
76546 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
76547
76548 -- 4262811 Variables ------------------------------------------------------------------------------------------
76549 l_entered_amt_idx NUMBER;
76550 l_accted_amt_idx NUMBER;
76551 l_acc_rev_flag VARCHAR2(1);
76552 l_accrual_line_num NUMBER;
76553 l_tmp_amt NUMBER;
76554 l_acc_rev_natural_side_code VARCHAR2(1);
76555
76556 l_num_entries NUMBER;
76557 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
76558 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
76559 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
76560 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
76561 l_recog_line_1 NUMBER;
76562 l_recog_line_2 NUMBER;
76563
76564 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
76565 l_bflow_applied_to_amt NUMBER; -- 5132302
76566 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
76567
76568 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
76569
76570 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
76571 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
76572
76573 ---------------------------------------------------------------------------------------------------------------
76574
76575
76576 --
76577 -- bulk performance
76578 --
76579 l_balance_type_code VARCHAR2(1);
76580 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
76581 l_log_module VARCHAR2(240);
76582
76583 --
76584 -- Upgrade strategy
76585 --
76586 l_actual_upg_option VARCHAR2(1);
76587 l_enc_upg_option VARCHAR2(1);
76588
76589 --
76590 BEGIN
76591 --
76592 IF g_log_enabled THEN
76593 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_159';
76594 END IF;
76595 --
76596 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76597
76598 trace
76599 (p_msg => 'BEGIN of AcctLineType_159'
76600 ,p_level => C_LEVEL_PROCEDURE
76601 ,p_module => l_log_module);
76602
76603 END IF;
76604 --
76605 l_component_type := 'AMB_JLT';
76606 l_component_code := 'INTERORG_PAYABLES';
76607 l_component_type_code := 'S';
76608 l_component_appl_id := 707;
76609 l_amb_context_code := 'DEFAULT';
76610 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
76611 l_event_class_code := 'DIR_INTERORG_SHIP';
76612 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
76613 l_line_definition_owner_code := 'S';
76614 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
76615 --
76616 l_balance_type_code := 'A';
76617 l_segment := NULL;
76618 l_ccid := NULL;
76619 l_adr_transaction_coa_id := NULL;
76620 l_adr_accounting_coa_id := NULL;
76621 l_adr_flexfield_segment_code := NULL;
76622 l_adr_flex_value_set_id := NULL;
76623 l_adr_value_type_code := NULL;
76624 l_adr_value_combination_id := NULL;
76625 l_adr_value_segment_code := NULL;
76626
76627 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
76628 l_bflow_class_code := ''; -- 4219869 Business Flow
76629 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
76630 l_budgetary_control_flag := 'N';
76631
76632 l_bflow_applied_to_amt_idx := NULL; -- 5132302
76633 l_bflow_applied_to_amt := NULL; -- 5132302
76634 l_entered_amt_idx := NULL; -- 4262811
76635 l_accted_amt_idx := NULL; -- 4262811
76636 l_acc_rev_flag := NULL; -- 4262811
76637 l_accrual_line_num := NULL; -- 4262811
76638 l_tmp_amt := NULL; -- 4262811
76639 --
76640
76641 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
76642 l_balance_type_code <> 'B' THEN
76643 IF NVL(p_source_97,9E125) = 9
76644 THEN
76645
76646 --
76647 XLA_AE_LINES_PKG.SetNewLine;
76648
76649 p_balance_type_code := l_balance_type_code;
76650 -- set the flag so later we will know whether the gain loss line needs to be created
76651
76652 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
76653 p_actual_flag :='A';
76654 END IF;
76655
76656 --
76657 -- bulk performance
76658 --
76659 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
76660 p_header_num => 0); -- 4262811
76661 --
76662 -- set accounting line options
76663 --
76664 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
76665 p_natural_side_code => 'D'
76666 , p_gain_or_loss_flag => 'N'
76667 , p_gl_transfer_mode_code => 'S'
76668 , p_acct_entry_type_code => 'A'
76669 , p_switch_side_flag => 'Y'
76670 , p_merge_duplicate_code => 'N'
76671 );
76672 --
76673 l_acc_rev_natural_side_code := 'C'; -- 4262811
76674 --
76675 --
76676 -- set accounting line type info
76677 --
76678 xla_ae_lines_pkg.SetAcctLineType
76679 (p_component_type => l_component_type
76680 ,p_event_type_code => l_event_type_code
76681 ,p_line_definition_owner_code => l_line_definition_owner_code
76682 ,p_line_definition_code => l_line_definition_code
76683 ,p_accounting_line_code => l_component_code
76684 ,p_accounting_line_type_code => l_component_type_code
76685 ,p_accounting_line_appl_id => l_component_appl_id
76686 ,p_amb_context_code => l_amb_context_code
76687 ,p_entity_code => l_entity_code
76688 ,p_event_class_code => l_event_class_code);
76689 --
76690 -- set accounting class
76691 --
76692 xla_ae_lines_pkg.SetAcctClass(
76693 p_accounting_class_code => 'INTERORG_PAYABLES'
76694 , p_ae_header_id => l_ae_header_id
76695 );
76696
76697 --
76698 -- set rounding class
76699 --
76700 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
76701 'INTERORG_PAYABLES';
76702
76703 --
76704 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
76705 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
76706 --
76707 -- bulk performance
76708 --
76709 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
76710
76711 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
76712 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
76713
76714 -- 4955764
76715 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
76716 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
76717
76718 -- 4458381 Public Sector Enh
76719
76720 --
76721 -- set accounting attributes for the line type
76722 --
76723 l_entered_amt_idx := 3;
76724 l_accted_amt_idx := 8;
76725 l_bflow_applied_to_amt_idx := NULL; -- 5132302
76726 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
76727 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
76728 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
76729 l_rec_acct_attrs.array_char_value(2) := p_source_85;
76730 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
76731 l_rec_acct_attrs.array_num_value(3) := p_source_91;
76732 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
76733 l_rec_acct_attrs.array_char_value(4) := p_source_88;
76734 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
76735 l_rec_acct_attrs.array_date_value(5) := p_source_92;
76736 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
76737 l_rec_acct_attrs.array_num_value(6) := p_source_93;
76738 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
76739 l_rec_acct_attrs.array_char_value(7) := p_source_94;
76740 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
76741 l_rec_acct_attrs.array_num_value(8) := p_source_95;
76742
76743 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
76744 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
76745
76746 ---------------------------------------------------------------------------------------------------------------
76747 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
76748 ---------------------------------------------------------------------------------------------------------------
76749 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
76750
76751 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
76752 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
76753
76754 IF xla_accounting_cache_pkg.GetValueChar
76755 (p_source_code => 'LEDGER_CATEGORY_CODE'
76756 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
76757 AND l_bflow_method_code = 'PRIOR_ENTRY'
76758 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
76759 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
76760 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
76761 )
76762 THEN
76763 xla_ae_lines_pkg.BflowUpgEntry
76764 (p_business_method_code => l_bflow_method_code
76765 ,p_business_class_code => l_bflow_class_code
76766 ,p_balance_type => l_balance_type_code);
76767 ELSE
76768 NULL;
76769 -- No business flow processing for business flow method of NONE.
76770 END IF;
76771
76772 --
76773 -- call analytical criteria
76774 --
76775
76776 --
76777 -- call description
76778 --
76779
76780 xla_ae_lines_pkg.SetLineDescription(
76781 p_ae_header_id => l_ae_header_id
76782 ,p_description => Description_1 (
76783 p_application_id => p_application_id
76784 , p_ae_header_id => l_ae_header_id
76785 , p_source_1 => p_source_1
76786 , p_source_2 => p_source_2
76787 , p_source_3 => p_source_3
76788 , p_source_4 => p_source_4
76789 , p_source_5 => p_source_5
76790 )
76791 );
76792
76793
76794 --
76795 -- call ADRs
76796 -- Bug 4922099
76797 --
76798 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
76799 (NVL(l_actual_upg_option, 'N') = 'O') OR
76800 (NVL(l_enc_upg_option, 'N') = 'O')
76801 )
76802 THEN
76803 NULL;
76804 --
76805 --
76806
76807 l_ccid := AcctDerRule_6(
76808 p_application_id => p_application_id
76809 , p_ae_header_id => l_ae_header_id
76810 , p_source_11 => p_source_11
76811 , x_transaction_coa_id => l_adr_transaction_coa_id
76812 , x_accounting_coa_id => l_adr_accounting_coa_id
76813 , x_value_type_code => l_adr_value_type_code
76814 , p_side => 'NA'
76815 );
76816
76817 xla_ae_lines_pkg.set_ccid(
76818 p_code_combination_id => l_ccid
76819 , p_value_type_code => l_adr_value_type_code
76820 , p_transaction_coa_id => l_adr_transaction_coa_id
76821 , p_accounting_coa_id => l_adr_accounting_coa_id
76822 , p_adr_code => 'CST_DEFAULT'
76823 , p_adr_type_code => 'S'
76824 , p_component_type => l_component_type
76825 , p_component_code => l_component_code
76826 , p_component_type_code => l_component_type_code
76827 , p_component_appl_id => l_component_appl_id
76828 , p_amb_context_code => l_amb_context_code
76829 , p_side => 'NA'
76830 );
76831
76832
76833 --
76834 --
76835 END IF;
76836 --
76837 -- Bug 4922099
76838 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
76839 (NVL(l_enc_upg_option, 'N') = 'O')
76840 ) AND
76841 (l_bflow_method_code = 'PRIOR_ENTRY')
76842 )
76843 THEN
76844 IF
76845 --
76846 1 = 2
76847 --
76848 THEN
76849 xla_accounting_err_pkg.build_message
76850 (p_appli_s_name => 'XLA'
76851 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
76852 ,p_token_1 => 'LINE_NUMBER'
76853 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
76854 ,p_token_2 => 'LINE_TYPE_NAME'
76855 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
76856 l_component_type
76857 ,l_component_code
76858 ,l_component_type_code
76859 ,l_component_appl_id
76860 ,l_amb_context_code
76861 ,l_entity_code
76862 ,l_event_class_code
76863 )
76864 ,p_token_3 => 'OWNER'
76865 ,p_value_3 => xla_lookups_pkg.get_meaning(
76866 p_lookup_type => 'XLA_OWNER_TYPE'
76867 ,p_lookup_code => l_component_type_code
76868 )
76869 ,p_token_4 => 'PRODUCT_NAME'
76870 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
76871 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
76872 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
76873 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
76874 ,p_ae_header_id => NULL
76875 );
76876
76877 IF (C_LEVEL_ERROR>= g_log_level) THEN
76878 trace
76879 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
76880 ,p_level => C_LEVEL_ERROR
76881 ,p_module => l_log_module);
76882 END IF;
76883 END IF;
76884 END IF;
76885 --
76886 --
76887 ------------------------------------------------------------------------------------------------
76888 -- 4219869 Business Flow
76889 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
76890 -- Prior Entry. Currently, the following code is always generated.
76891 ------------------------------------------------------------------------------------------------
76892 XLA_AE_LINES_PKG.ValidateCurrentLine;
76893
76894 ------------------------------------------------------------------------------------
76895 -- 4219869 Business Flow
76896 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
76897 ------------------------------------------------------------------------------------
76898 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
76899
76900 ----------------------------------------------------------------------------------
76901 -- 4219869 Business Flow
76902 -- Update journal entry status -- Need to generate this within IF <condition>
76903 ----------------------------------------------------------------------------------
76904 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
76905 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
76906 ,p_balance_type_code => l_balance_type_code
76907 );
76908
76909 -------------------------------------------------------------------------------------------
76910 -- 4262811 - Generate the Accrual Reversal lines
76911 -------------------------------------------------------------------------------------------
76912 BEGIN
76913 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
76914 (g_array_event(p_event_id).array_value_num('header_index'));
76915 IF l_acc_rev_flag IS NULL THEN
76916 l_acc_rev_flag := 'N';
76917 END IF;
76918 EXCEPTION
76919 WHEN OTHERS THEN
76920 l_acc_rev_flag := 'N';
76921 END;
76922 --
76923 IF (l_acc_rev_flag = 'Y') THEN
76924
76925 -- 4645092 ------------------------------------------------------------------------------
76926 -- To allow MPA report to determine if it should generate report process
76927 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
76928 ------------------------------------------------------------------------------------------
76929
76930 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
76931 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
76932 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
76933 -- call ADRs
76934 -- Bug 4922099
76935 --
76936 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
76937 (NVL(l_actual_upg_option, 'N') = 'O') OR
76938 (NVL(l_enc_upg_option, 'N') = 'O')
76939 )
76940 THEN
76941 NULL;
76942 --
76943 --
76944
76945 l_ccid := AcctDerRule_6(
76946 p_application_id => p_application_id
76947 , p_ae_header_id => l_ae_header_id
76948 , p_source_11 => p_source_11
76949 , x_transaction_coa_id => l_adr_transaction_coa_id
76950 , x_accounting_coa_id => l_adr_accounting_coa_id
76951 , x_value_type_code => l_adr_value_type_code
76952 , p_side => 'NA'
76953 );
76954
76955 xla_ae_lines_pkg.set_ccid(
76956 p_code_combination_id => l_ccid
76957 , p_value_type_code => l_adr_value_type_code
76958 , p_transaction_coa_id => l_adr_transaction_coa_id
76959 , p_accounting_coa_id => l_adr_accounting_coa_id
76960 , p_adr_code => 'CST_DEFAULT'
76961 , p_adr_type_code => 'S'
76962 , p_component_type => l_component_type
76963 , p_component_code => l_component_code
76964 , p_component_type_code => l_component_type_code
76965 , p_component_appl_id => l_component_appl_id
76966 , p_amb_context_code => l_amb_context_code
76967 , p_side => 'NA'
76968 );
76969
76970
76971 --
76972 --
76973 END IF;
76974
76975 --
76976 -- Update the line information that should be overwritten
76977 --
76978 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
76979 p_header_num => 1);
76980 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
76981
76982 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
76983
76984 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
76985 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
76986 END IF;
76987
76988 --
76989 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
76990 --
76991 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
76992 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
76993 ELSE
76994 ---------------------------------------------------------------------------------------------------
76995 -- 4262811a Switch Sign
76996 ---------------------------------------------------------------------------------------------------
76997 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
76998 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
76999 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77000 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
77001 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77002 -- 5132302
77003 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
77004 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77005
77006 END IF;
77007
77008 -- 4955764
77009 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
77010 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
77011
77012
77013 XLA_AE_LINES_PKG.ValidateCurrentLine;
77014 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
77015
77016 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
77017 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
77018 ,p_balance_type_code => l_balance_type_code);
77019
77020 END IF;
77021
77022 -----------------------------------------------------------------------------------------
77023 -- 4262811 Multiperiod Accounting
77024 -----------------------------------------------------------------------------------------
77025 -- No MPA option is assigned.
77026
77027
77028 END IF;
77029 END IF;
77030 --
77031
77032 --
77033 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77034 trace
77035 (p_msg => 'END of AcctLineType_159'
77036 ,p_level => C_LEVEL_PROCEDURE
77037 ,p_module => l_log_module);
77038 END IF;
77039 --
77040 EXCEPTION
77041 WHEN xla_exceptions_pkg.application_exception THEN
77042 RAISE;
77043 WHEN OTHERS THEN
77044 xla_exceptions_pkg.raise_message
77045 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_159');
77046 END AcctLineType_159;
77047 --
77048
77049 ---------------------------------------
77050 --
77051 -- PRIVATE FUNCTION
77052 -- AcctLineType_160
77053 --
77054 ---------------------------------------
77055 PROCEDURE AcctLineType_160 (
77056 p_application_id IN NUMBER
77057 ,p_event_id IN NUMBER
77058 ,p_calculate_acctd_flag IN VARCHAR2
77059 ,p_calculate_g_l_flag IN VARCHAR2
77060 ,p_actual_flag IN OUT VARCHAR2
77061 ,p_balance_type_code OUT VARCHAR2
77062 ,p_gain_or_loss_ref OUT VARCHAR2
77063
77064 --TRANSACTION_ID
77065 , p_source_1 IN NUMBER
77066 --Item Concatenated Segments
77067 , p_source_2 IN VARCHAR2
77068 --Transaction Quantity
77069 , p_source_3 IN NUMBER
77070 --Transaction Unit of Measure Code
77071 , p_source_4 IN VARCHAR2
77072 --Inventory Transaction Type Description
77073 , p_source_5 IN VARCHAR2
77074 --Interorg Payables Account
77075 , p_source_35 IN NUMBER
77076 --Applied to Application ID
77077 , p_source_79 IN NUMBER
77078 --Applied to Distribution Link Type
77079 , p_source_80 IN VARCHAR2
77080 --Applied to Entity Code
77081 , p_source_81 IN VARCHAR2
77082 --DISTRIBUTION_IDENTIFIER
77083 , p_source_84 IN NUMBER
77084 --Distribution Type
77085 , p_source_85 IN VARCHAR2
77086 , p_source_85_meaning IN VARCHAR2
77087 --Encumbrance Reversal Amount Entered
77088 , p_source_87 IN NUMBER
77089 --Entered Currency Code
77090 , p_source_88 IN VARCHAR2
77091 --Transaction Encumbrance Reversal Amount
77092 , p_source_89 IN NUMBER
77093 --Entered Amount
77094 , p_source_91 IN NUMBER
77095 --Currency Conversion Date
77096 , p_source_92 IN DATE
77097 --Currency Conversion Rate
77098 , p_source_93 IN NUMBER
77099 --Currency Conversion Type
77100 , p_source_94 IN VARCHAR2
77101 --Accounted Amount
77102 , p_source_95 IN NUMBER
77103 --Accounting Line Type
77104 , p_source_97 IN NUMBER
77105 --Costing Encumbrance Upgrade Option
77106 , p_source_100 IN VARCHAR2
77107 --TXN_PO_DISTRIBUTION_ID
77108 , p_source_101 IN NUMBER
77109 --TXN_PO_HEADER_ID
77110 , p_source_102 IN NUMBER
77111 --Requisition Budget Account
77112 , p_source_103 IN NUMBER
77113 --Requisition Encumbrance Type Identifier
77114 , p_source_104 IN NUMBER
77115 )
77116 IS
77117
77118 l_component_type VARCHAR2(80);
77119 l_component_code VARCHAR2(30);
77120 l_component_type_code VARCHAR2(1);
77121 l_component_appl_id INTEGER;
77122 l_amb_context_code VARCHAR2(30);
77123 l_entity_code VARCHAR2(30);
77124 l_event_class_code VARCHAR2(30);
77125 l_ae_header_id NUMBER;
77126 l_event_type_code VARCHAR2(30);
77127 l_line_definition_code VARCHAR2(30);
77128 l_line_definition_owner_code VARCHAR2(1);
77129 --
77130 -- adr variables
77131 l_segment VARCHAR2(30);
77132 l_ccid NUMBER;
77133 l_adr_transaction_coa_id NUMBER;
77134 l_adr_accounting_coa_id NUMBER;
77135 l_adr_flexfield_segment_code VARCHAR2(30);
77136 l_adr_flex_value_set_id NUMBER;
77137 l_adr_value_type_code VARCHAR2(30);
77138 l_adr_value_combination_id NUMBER;
77139 l_adr_value_segment_code VARCHAR2(30);
77140
77141 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
77142 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
77143 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
77144 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
77145
77146 -- 4262811 Variables ------------------------------------------------------------------------------------------
77147 l_entered_amt_idx NUMBER;
77148 l_accted_amt_idx NUMBER;
77149 l_acc_rev_flag VARCHAR2(1);
77150 l_accrual_line_num NUMBER;
77151 l_tmp_amt NUMBER;
77152 l_acc_rev_natural_side_code VARCHAR2(1);
77153
77154 l_num_entries NUMBER;
77155 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
77156 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
77157 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
77158 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
77159 l_recog_line_1 NUMBER;
77160 l_recog_line_2 NUMBER;
77161
77162 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
77163 l_bflow_applied_to_amt NUMBER; -- 5132302
77164 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
77165
77166 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
77167
77168 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
77169 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
77170
77171 ---------------------------------------------------------------------------------------------------------------
77172
77173
77174 --
77175 -- bulk performance
77176 --
77177 l_balance_type_code VARCHAR2(1);
77178 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
77179 l_log_module VARCHAR2(240);
77180
77181 --
77182 -- Upgrade strategy
77183 --
77184 l_actual_upg_option VARCHAR2(1);
77185 l_enc_upg_option VARCHAR2(1);
77186
77187 --
77188 BEGIN
77189 --
77190 IF g_log_enabled THEN
77191 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_160';
77192 END IF;
77193 --
77194 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77195
77196 trace
77197 (p_msg => 'BEGIN of AcctLineType_160'
77198 ,p_level => C_LEVEL_PROCEDURE
77199 ,p_module => l_log_module);
77200
77201 END IF;
77202 --
77203 l_component_type := 'AMB_JLT';
77204 l_component_code := 'INTERORG_PAYABLES';
77205 l_component_type_code := 'S';
77206 l_component_appl_id := 707;
77207 l_amb_context_code := 'DEFAULT';
77208 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
77209 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
77210 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
77211 l_line_definition_owner_code := 'S';
77212 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
77213 --
77214 l_balance_type_code := 'A';
77215 l_segment := NULL;
77216 l_ccid := NULL;
77217 l_adr_transaction_coa_id := NULL;
77218 l_adr_accounting_coa_id := NULL;
77219 l_adr_flexfield_segment_code := NULL;
77220 l_adr_flex_value_set_id := NULL;
77221 l_adr_value_type_code := NULL;
77222 l_adr_value_combination_id := NULL;
77223 l_adr_value_segment_code := NULL;
77224
77225 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
77226 l_bflow_class_code := ''; -- 4219869 Business Flow
77227 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
77228 l_budgetary_control_flag := 'N';
77229
77230 l_bflow_applied_to_amt_idx := NULL; -- 5132302
77231 l_bflow_applied_to_amt := NULL; -- 5132302
77232 l_entered_amt_idx := NULL; -- 4262811
77233 l_accted_amt_idx := NULL; -- 4262811
77234 l_acc_rev_flag := NULL; -- 4262811
77235 l_accrual_line_num := NULL; -- 4262811
77236 l_tmp_amt := NULL; -- 4262811
77237 --
77238
77239 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
77240 l_balance_type_code <> 'B' THEN
77241 IF NVL(p_source_97,9E125) = 9
77242 THEN
77243
77244 --
77245 XLA_AE_LINES_PKG.SetNewLine;
77246
77247 p_balance_type_code := l_balance_type_code;
77248 -- set the flag so later we will know whether the gain loss line needs to be created
77249
77250 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
77251 p_actual_flag :='A';
77252 END IF;
77253
77254 --
77255 -- bulk performance
77256 --
77257 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
77258 p_header_num => 0); -- 4262811
77259 --
77260 -- set accounting line options
77261 --
77262 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
77263 p_natural_side_code => 'D'
77264 , p_gain_or_loss_flag => 'N'
77265 , p_gl_transfer_mode_code => 'S'
77266 , p_acct_entry_type_code => 'A'
77267 , p_switch_side_flag => 'Y'
77268 , p_merge_duplicate_code => 'N'
77269 );
77270 --
77271 l_acc_rev_natural_side_code := 'C'; -- 4262811
77272 --
77273 --
77274 -- set accounting line type info
77275 --
77276 xla_ae_lines_pkg.SetAcctLineType
77277 (p_component_type => l_component_type
77278 ,p_event_type_code => l_event_type_code
77279 ,p_line_definition_owner_code => l_line_definition_owner_code
77280 ,p_line_definition_code => l_line_definition_code
77281 ,p_accounting_line_code => l_component_code
77282 ,p_accounting_line_type_code => l_component_type_code
77283 ,p_accounting_line_appl_id => l_component_appl_id
77284 ,p_amb_context_code => l_amb_context_code
77285 ,p_entity_code => l_entity_code
77286 ,p_event_class_code => l_event_class_code);
77287 --
77288 -- set accounting class
77289 --
77290 xla_ae_lines_pkg.SetAcctClass(
77291 p_accounting_class_code => 'INTERORG_PAYABLES'
77292 , p_ae_header_id => l_ae_header_id
77293 );
77294
77295 --
77296 -- set rounding class
77297 --
77298 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
77299 'INTERORG_PAYABLES';
77300
77301 --
77302 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
77303 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
77304 --
77305 -- bulk performance
77306 --
77307 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
77308
77309 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
77310 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
77311
77312 -- 4955764
77313 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
77314 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
77315
77316 -- 4458381 Public Sector Enh
77317
77318 --
77319 -- set accounting attributes for the line type
77320 --
77321 l_entered_amt_idx := 17;
77322 l_accted_amt_idx := 22;
77323 l_bflow_applied_to_amt_idx := NULL; -- 5132302
77324 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
77325 l_rec_acct_attrs.array_num_value(1) := p_source_79;
77326 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
77327 l_rec_acct_attrs.array_char_value(2) := p_source_80;
77328 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
77329 l_rec_acct_attrs.array_char_value(3) := p_source_81;
77330 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
77331 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
77332 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
77333 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
77334 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
77335 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
77336 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
77337 l_rec_acct_attrs.array_char_value(7) := p_source_85;
77338 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
77339 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
77340 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
77341 l_rec_acct_attrs.array_num_value(9) := p_source_87;
77342 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
77343 l_rec_acct_attrs.array_char_value(10) := p_source_88;
77344 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
77345 l_rec_acct_attrs.array_num_value(11) := p_source_89;
77346 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
77347 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
77348 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
77349 l_rec_acct_attrs.array_num_value(13) := p_source_87;
77350 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
77351 l_rec_acct_attrs.array_char_value(14) := p_source_88;
77352 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
77353 l_rec_acct_attrs.array_num_value(15) := p_source_89;
77354 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
77355 l_rec_acct_attrs.array_char_value(16) := p_source_100;
77356 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
77357 l_rec_acct_attrs.array_num_value(17) := p_source_91;
77358 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
77359 l_rec_acct_attrs.array_char_value(18) := p_source_88;
77360 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
77361 l_rec_acct_attrs.array_date_value(19) := p_source_92;
77362 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
77363 l_rec_acct_attrs.array_num_value(20) := p_source_93;
77364 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
77365 l_rec_acct_attrs.array_char_value(21) := p_source_94;
77366 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
77367 l_rec_acct_attrs.array_num_value(22) := p_source_95;
77368 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
77369 l_rec_acct_attrs.array_num_value(23) := p_source_104;
77370 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
77371 l_rec_acct_attrs.array_num_value(24) := p_source_104;
77372
77373 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
77374 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
77375
77376 ---------------------------------------------------------------------------------------------------------------
77377 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
77378 ---------------------------------------------------------------------------------------------------------------
77379 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
77380
77381 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
77382 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
77383
77384 IF xla_accounting_cache_pkg.GetValueChar
77385 (p_source_code => 'LEDGER_CATEGORY_CODE'
77386 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
77387 AND l_bflow_method_code = 'PRIOR_ENTRY'
77388 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
77389 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
77390 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
77391 )
77392 THEN
77393 xla_ae_lines_pkg.BflowUpgEntry
77394 (p_business_method_code => l_bflow_method_code
77395 ,p_business_class_code => l_bflow_class_code
77396 ,p_balance_type => l_balance_type_code);
77397 ELSE
77398 NULL;
77399 -- No business flow processing for business flow method of NONE.
77400 END IF;
77401
77402 --
77403 -- call analytical criteria
77404 --
77405
77406 --
77407 -- call description
77408 --
77409
77410 xla_ae_lines_pkg.SetLineDescription(
77411 p_ae_header_id => l_ae_header_id
77412 ,p_description => Description_1 (
77413 p_application_id => p_application_id
77414 , p_ae_header_id => l_ae_header_id
77415 , p_source_1 => p_source_1
77416 , p_source_2 => p_source_2
77417 , p_source_3 => p_source_3
77418 , p_source_4 => p_source_4
77419 , p_source_5 => p_source_5
77420 )
77421 );
77422
77423
77424 --
77425 -- call ADRs
77426 -- Bug 4922099
77427 --
77428 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
77429 (NVL(l_actual_upg_option, 'N') = 'O') OR
77430 (NVL(l_enc_upg_option, 'N') = 'O')
77431 )
77432 THEN
77433 NULL;
77434 --
77435 --
77436
77437 l_ccid := AcctDerRule_20(
77438 p_application_id => p_application_id
77439 , p_ae_header_id => l_ae_header_id
77440 , p_source_35 => p_source_35
77441 , x_transaction_coa_id => l_adr_transaction_coa_id
77442 , x_accounting_coa_id => l_adr_accounting_coa_id
77443 , x_value_type_code => l_adr_value_type_code
77444 , p_side => 'NA'
77445 );
77446
77447 xla_ae_lines_pkg.set_ccid(
77448 p_code_combination_id => l_ccid
77449 , p_value_type_code => l_adr_value_type_code
77450 , p_transaction_coa_id => l_adr_transaction_coa_id
77451 , p_accounting_coa_id => l_adr_accounting_coa_id
77452 , p_adr_code => 'PI_INTERORG_PAYABLES'
77453 , p_adr_type_code => 'S'
77454 , p_component_type => l_component_type
77455 , p_component_code => l_component_code
77456 , p_component_type_code => l_component_type_code
77457 , p_component_appl_id => l_component_appl_id
77458 , p_amb_context_code => l_amb_context_code
77459 , p_side => 'NA'
77460 );
77461
77462
77463 --
77464 --
77465 END IF;
77466 --
77467 -- Bug 4922099
77468 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
77469 (NVL(l_enc_upg_option, 'N') = 'O')
77470 ) AND
77471 (l_bflow_method_code = 'PRIOR_ENTRY')
77472 )
77473 THEN
77474 IF
77475 --
77476 1 = 2
77477 --
77478 THEN
77479 xla_accounting_err_pkg.build_message
77480 (p_appli_s_name => 'XLA'
77481 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
77482 ,p_token_1 => 'LINE_NUMBER'
77483 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
77484 ,p_token_2 => 'LINE_TYPE_NAME'
77485 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
77486 l_component_type
77487 ,l_component_code
77488 ,l_component_type_code
77489 ,l_component_appl_id
77490 ,l_amb_context_code
77491 ,l_entity_code
77492 ,l_event_class_code
77493 )
77494 ,p_token_3 => 'OWNER'
77495 ,p_value_3 => xla_lookups_pkg.get_meaning(
77496 p_lookup_type => 'XLA_OWNER_TYPE'
77497 ,p_lookup_code => l_component_type_code
77498 )
77499 ,p_token_4 => 'PRODUCT_NAME'
77500 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
77501 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
77502 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
77503 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
77504 ,p_ae_header_id => NULL
77505 );
77506
77507 IF (C_LEVEL_ERROR>= g_log_level) THEN
77508 trace
77509 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
77510 ,p_level => C_LEVEL_ERROR
77511 ,p_module => l_log_module);
77512 END IF;
77513 END IF;
77514 END IF;
77515 --
77516 --
77517 ------------------------------------------------------------------------------------------------
77518 -- 4219869 Business Flow
77519 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
77520 -- Prior Entry. Currently, the following code is always generated.
77521 ------------------------------------------------------------------------------------------------
77522 XLA_AE_LINES_PKG.ValidateCurrentLine;
77523
77524 ------------------------------------------------------------------------------------
77525 -- 4219869 Business Flow
77526 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
77527 ------------------------------------------------------------------------------------
77528 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
77529
77530 ----------------------------------------------------------------------------------
77531 -- 4219869 Business Flow
77532 -- Update journal entry status -- Need to generate this within IF <condition>
77533 ----------------------------------------------------------------------------------
77534 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
77535 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
77536 ,p_balance_type_code => l_balance_type_code
77537 );
77538
77539 -------------------------------------------------------------------------------------------
77540 -- 4262811 - Generate the Accrual Reversal lines
77541 -------------------------------------------------------------------------------------------
77542 BEGIN
77543 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
77544 (g_array_event(p_event_id).array_value_num('header_index'));
77545 IF l_acc_rev_flag IS NULL THEN
77546 l_acc_rev_flag := 'N';
77547 END IF;
77548 EXCEPTION
77549 WHEN OTHERS THEN
77550 l_acc_rev_flag := 'N';
77551 END;
77552 --
77553 IF (l_acc_rev_flag = 'Y') THEN
77554
77555 -- 4645092 ------------------------------------------------------------------------------
77556 -- To allow MPA report to determine if it should generate report process
77557 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
77558 ------------------------------------------------------------------------------------------
77559
77560 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
77561 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
77562 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
77563 -- call ADRs
77564 -- Bug 4922099
77565 --
77566 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
77567 (NVL(l_actual_upg_option, 'N') = 'O') OR
77568 (NVL(l_enc_upg_option, 'N') = 'O')
77569 )
77570 THEN
77571 NULL;
77572 --
77573 --
77574
77575 l_ccid := AcctDerRule_20(
77576 p_application_id => p_application_id
77577 , p_ae_header_id => l_ae_header_id
77578 , p_source_35 => p_source_35
77579 , x_transaction_coa_id => l_adr_transaction_coa_id
77580 , x_accounting_coa_id => l_adr_accounting_coa_id
77581 , x_value_type_code => l_adr_value_type_code
77582 , p_side => 'NA'
77583 );
77584
77585 xla_ae_lines_pkg.set_ccid(
77586 p_code_combination_id => l_ccid
77587 , p_value_type_code => l_adr_value_type_code
77588 , p_transaction_coa_id => l_adr_transaction_coa_id
77589 , p_accounting_coa_id => l_adr_accounting_coa_id
77590 , p_adr_code => 'PI_INTERORG_PAYABLES'
77591 , p_adr_type_code => 'S'
77592 , p_component_type => l_component_type
77593 , p_component_code => l_component_code
77594 , p_component_type_code => l_component_type_code
77595 , p_component_appl_id => l_component_appl_id
77596 , p_amb_context_code => l_amb_context_code
77597 , p_side => 'NA'
77598 );
77599
77600
77601 --
77602 --
77603 END IF;
77604
77605 --
77606 -- Update the line information that should be overwritten
77607 --
77608 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
77609 p_header_num => 1);
77610 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
77611
77612 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
77613
77614 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
77615 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
77616 END IF;
77617
77618 --
77619 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
77620 --
77621 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
77622 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
77623 ELSE
77624 ---------------------------------------------------------------------------------------------------
77625 -- 4262811a Switch Sign
77626 ---------------------------------------------------------------------------------------------------
77627 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
77628 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
77629 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77630 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
77631 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77632 -- 5132302
77633 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
77634 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
77635
77636 END IF;
77637
77638 -- 4955764
77639 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
77640 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
77641
77642
77643 XLA_AE_LINES_PKG.ValidateCurrentLine;
77644 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
77645
77646 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
77647 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
77648 ,p_balance_type_code => l_balance_type_code);
77649
77650 END IF;
77651
77652 -----------------------------------------------------------------------------------------
77653 -- 4262811 Multiperiod Accounting
77654 -----------------------------------------------------------------------------------------
77655 -- No MPA option is assigned.
77656
77657
77658 END IF;
77659 END IF;
77660 --
77661
77662 --
77663 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77664 trace
77665 (p_msg => 'END of AcctLineType_160'
77666 ,p_level => C_LEVEL_PROCEDURE
77667 ,p_module => l_log_module);
77668 END IF;
77669 --
77670 EXCEPTION
77671 WHEN xla_exceptions_pkg.application_exception THEN
77672 RAISE;
77673 WHEN OTHERS THEN
77674 xla_exceptions_pkg.raise_message
77675 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_160');
77676 END AcctLineType_160;
77677 --
77678
77679 ---------------------------------------
77680 --
77681 -- PRIVATE FUNCTION
77682 -- AcctLineType_161
77683 --
77684 ---------------------------------------
77685 PROCEDURE AcctLineType_161 (
77686 p_application_id IN NUMBER
77687 ,p_event_id IN NUMBER
77688 ,p_calculate_acctd_flag IN VARCHAR2
77689 ,p_calculate_g_l_flag IN VARCHAR2
77690 ,p_actual_flag IN OUT VARCHAR2
77691 ,p_balance_type_code OUT VARCHAR2
77692 ,p_gain_or_loss_ref OUT VARCHAR2
77693
77694 --TRANSACTION_ID
77695 , p_source_1 IN NUMBER
77696 --Item Concatenated Segments
77697 , p_source_2 IN VARCHAR2
77698 --Transaction Quantity
77699 , p_source_3 IN NUMBER
77700 --Transaction Unit of Measure Code
77701 , p_source_4 IN VARCHAR2
77702 --Inventory Transaction Type Description
77703 , p_source_5 IN VARCHAR2
77704 --Interorg Payables Account
77705 , p_source_35 IN NUMBER
77706 --DISTRIBUTION_IDENTIFIER
77707 , p_source_84 IN NUMBER
77708 --Distribution Type
77709 , p_source_85 IN VARCHAR2
77710 , p_source_85_meaning IN VARCHAR2
77711 --Entered Currency Code
77712 , p_source_88 IN VARCHAR2
77713 --Entered Amount
77714 , p_source_91 IN NUMBER
77715 --Currency Conversion Date
77716 , p_source_92 IN DATE
77717 --Currency Conversion Rate
77718 , p_source_93 IN NUMBER
77719 --Currency Conversion Type
77720 , p_source_94 IN VARCHAR2
77721 --Accounted Amount
77722 , p_source_95 IN NUMBER
77723 --Accounting Line Type
77724 , p_source_97 IN NUMBER
77725 )
77726 IS
77727
77728 l_component_type VARCHAR2(80);
77729 l_component_code VARCHAR2(30);
77730 l_component_type_code VARCHAR2(1);
77731 l_component_appl_id INTEGER;
77732 l_amb_context_code VARCHAR2(30);
77733 l_entity_code VARCHAR2(30);
77734 l_event_class_code VARCHAR2(30);
77735 l_ae_header_id NUMBER;
77736 l_event_type_code VARCHAR2(30);
77737 l_line_definition_code VARCHAR2(30);
77738 l_line_definition_owner_code VARCHAR2(1);
77739 --
77740 -- adr variables
77741 l_segment VARCHAR2(30);
77742 l_ccid NUMBER;
77743 l_adr_transaction_coa_id NUMBER;
77744 l_adr_accounting_coa_id NUMBER;
77745 l_adr_flexfield_segment_code VARCHAR2(30);
77746 l_adr_flex_value_set_id NUMBER;
77747 l_adr_value_type_code VARCHAR2(30);
77748 l_adr_value_combination_id NUMBER;
77749 l_adr_value_segment_code VARCHAR2(30);
77750
77751 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
77752 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
77753 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
77754 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
77755
77756 -- 4262811 Variables ------------------------------------------------------------------------------------------
77757 l_entered_amt_idx NUMBER;
77758 l_accted_amt_idx NUMBER;
77759 l_acc_rev_flag VARCHAR2(1);
77760 l_accrual_line_num NUMBER;
77761 l_tmp_amt NUMBER;
77762 l_acc_rev_natural_side_code VARCHAR2(1);
77763
77764 l_num_entries NUMBER;
77765 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
77766 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
77767 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
77768 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
77769 l_recog_line_1 NUMBER;
77770 l_recog_line_2 NUMBER;
77771
77772 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
77773 l_bflow_applied_to_amt NUMBER; -- 5132302
77774 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
77775
77776 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
77777
77778 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
77779 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
77780
77781 ---------------------------------------------------------------------------------------------------------------
77782
77783
77784 --
77785 -- bulk performance
77786 --
77787 l_balance_type_code VARCHAR2(1);
77788 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
77789 l_log_module VARCHAR2(240);
77790
77791 --
77792 -- Upgrade strategy
77793 --
77794 l_actual_upg_option VARCHAR2(1);
77795 l_enc_upg_option VARCHAR2(1);
77796
77797 --
77798 BEGIN
77799 --
77800 IF g_log_enabled THEN
77801 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_161';
77802 END IF;
77803 --
77804 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77805
77806 trace
77807 (p_msg => 'BEGIN of AcctLineType_161'
77808 ,p_level => C_LEVEL_PROCEDURE
77809 ,p_module => l_log_module);
77810
77811 END IF;
77812 --
77813 l_component_type := 'AMB_JLT';
77814 l_component_code := 'INTERORG_PAYABLES';
77815 l_component_type_code := 'S';
77816 l_component_appl_id := 707;
77817 l_amb_context_code := 'DEFAULT';
77818 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
77819 l_event_class_code := 'USER_DEFINE';
77820 l_event_type_code := 'UDIR_INTERORG_RCPT';
77821 l_line_definition_owner_code := 'S';
77822 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
77823 --
77824 l_balance_type_code := 'A';
77825 l_segment := NULL;
77826 l_ccid := NULL;
77827 l_adr_transaction_coa_id := NULL;
77828 l_adr_accounting_coa_id := NULL;
77829 l_adr_flexfield_segment_code := NULL;
77830 l_adr_flex_value_set_id := NULL;
77831 l_adr_value_type_code := NULL;
77832 l_adr_value_combination_id := NULL;
77833 l_adr_value_segment_code := NULL;
77834
77835 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
77836 l_bflow_class_code := ''; -- 4219869 Business Flow
77837 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
77838 l_budgetary_control_flag := 'N';
77839
77840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
77841 l_bflow_applied_to_amt := NULL; -- 5132302
77842 l_entered_amt_idx := NULL; -- 4262811
77843 l_accted_amt_idx := NULL; -- 4262811
77844 l_acc_rev_flag := NULL; -- 4262811
77845 l_accrual_line_num := NULL; -- 4262811
77846 l_tmp_amt := NULL; -- 4262811
77847 --
77848
77849 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
77850 l_balance_type_code <> 'B' THEN
77851 IF NVL(p_source_97,9E125) = 9
77852 THEN
77853
77854 --
77855 XLA_AE_LINES_PKG.SetNewLine;
77856
77857 p_balance_type_code := l_balance_type_code;
77858 -- set the flag so later we will know whether the gain loss line needs to be created
77859
77860 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
77861 p_actual_flag :='A';
77862 END IF;
77863
77864 --
77865 -- bulk performance
77866 --
77867 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
77868 p_header_num => 0); -- 4262811
77869 --
77870 -- set accounting line options
77871 --
77872 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
77873 p_natural_side_code => 'D'
77874 , p_gain_or_loss_flag => 'N'
77875 , p_gl_transfer_mode_code => 'S'
77876 , p_acct_entry_type_code => 'A'
77877 , p_switch_side_flag => 'Y'
77878 , p_merge_duplicate_code => 'N'
77879 );
77880 --
77881 l_acc_rev_natural_side_code := 'C'; -- 4262811
77882 --
77883 --
77884 -- set accounting line type info
77885 --
77886 xla_ae_lines_pkg.SetAcctLineType
77887 (p_component_type => l_component_type
77888 ,p_event_type_code => l_event_type_code
77889 ,p_line_definition_owner_code => l_line_definition_owner_code
77890 ,p_line_definition_code => l_line_definition_code
77891 ,p_accounting_line_code => l_component_code
77892 ,p_accounting_line_type_code => l_component_type_code
77893 ,p_accounting_line_appl_id => l_component_appl_id
77894 ,p_amb_context_code => l_amb_context_code
77895 ,p_entity_code => l_entity_code
77896 ,p_event_class_code => l_event_class_code);
77897 --
77898 -- set accounting class
77899 --
77900 xla_ae_lines_pkg.SetAcctClass(
77901 p_accounting_class_code => 'INTERORG_PAYABLES'
77902 , p_ae_header_id => l_ae_header_id
77903 );
77904
77905 --
77906 -- set rounding class
77907 --
77908 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
77909 'INTERORG_PAYABLES';
77910
77911 --
77912 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
77913 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
77914 --
77915 -- bulk performance
77916 --
77917 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
77918
77919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
77920 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
77921
77922 -- 4955764
77923 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
77924 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
77925
77926 -- 4458381 Public Sector Enh
77927
77928 --
77929 -- set accounting attributes for the line type
77930 --
77931 l_entered_amt_idx := 3;
77932 l_accted_amt_idx := 8;
77933 l_bflow_applied_to_amt_idx := NULL; -- 5132302
77934 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
77935 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
77936 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
77937 l_rec_acct_attrs.array_char_value(2) := p_source_85;
77938 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
77939 l_rec_acct_attrs.array_num_value(3) := p_source_91;
77940 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
77941 l_rec_acct_attrs.array_char_value(4) := p_source_88;
77942 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
77943 l_rec_acct_attrs.array_date_value(5) := p_source_92;
77944 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
77945 l_rec_acct_attrs.array_num_value(6) := p_source_93;
77946 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
77947 l_rec_acct_attrs.array_char_value(7) := p_source_94;
77948 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
77949 l_rec_acct_attrs.array_num_value(8) := p_source_95;
77950
77951 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
77952 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
77953
77954 ---------------------------------------------------------------------------------------------------------------
77955 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
77956 ---------------------------------------------------------------------------------------------------------------
77957 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
77958
77959 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
77960 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
77961
77962 IF xla_accounting_cache_pkg.GetValueChar
77963 (p_source_code => 'LEDGER_CATEGORY_CODE'
77964 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
77965 AND l_bflow_method_code = 'PRIOR_ENTRY'
77966 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
77967 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
77968 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
77969 )
77970 THEN
77971 xla_ae_lines_pkg.BflowUpgEntry
77972 (p_business_method_code => l_bflow_method_code
77973 ,p_business_class_code => l_bflow_class_code
77974 ,p_balance_type => l_balance_type_code);
77975 ELSE
77976 NULL;
77977 -- No business flow processing for business flow method of NONE.
77978 END IF;
77979
77980 --
77981 -- call analytical criteria
77982 --
77983
77984 --
77985 -- call description
77986 --
77987
77988 xla_ae_lines_pkg.SetLineDescription(
77989 p_ae_header_id => l_ae_header_id
77990 ,p_description => Description_1 (
77991 p_application_id => p_application_id
77992 , p_ae_header_id => l_ae_header_id
77993 , p_source_1 => p_source_1
77994 , p_source_2 => p_source_2
77995 , p_source_3 => p_source_3
77996 , p_source_4 => p_source_4
77997 , p_source_5 => p_source_5
77998 )
77999 );
78000
78001
78002 --
78003 -- call ADRs
78004 -- Bug 4922099
78005 --
78006 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
78007 (NVL(l_actual_upg_option, 'N') = 'O') OR
78008 (NVL(l_enc_upg_option, 'N') = 'O')
78009 )
78010 THEN
78011 NULL;
78012 --
78013 --
78014
78015 l_ccid := AcctDerRule_20(
78016 p_application_id => p_application_id
78017 , p_ae_header_id => l_ae_header_id
78018 , p_source_35 => p_source_35
78019 , x_transaction_coa_id => l_adr_transaction_coa_id
78020 , x_accounting_coa_id => l_adr_accounting_coa_id
78021 , x_value_type_code => l_adr_value_type_code
78022 , p_side => 'NA'
78023 );
78024
78025 xla_ae_lines_pkg.set_ccid(
78026 p_code_combination_id => l_ccid
78027 , p_value_type_code => l_adr_value_type_code
78028 , p_transaction_coa_id => l_adr_transaction_coa_id
78029 , p_accounting_coa_id => l_adr_accounting_coa_id
78030 , p_adr_code => 'PI_INTERORG_PAYABLES'
78031 , p_adr_type_code => 'S'
78032 , p_component_type => l_component_type
78033 , p_component_code => l_component_code
78034 , p_component_type_code => l_component_type_code
78035 , p_component_appl_id => l_component_appl_id
78036 , p_amb_context_code => l_amb_context_code
78037 , p_side => 'NA'
78038 );
78039
78040
78041 --
78042 --
78043 END IF;
78044 --
78045 -- Bug 4922099
78046 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
78047 (NVL(l_enc_upg_option, 'N') = 'O')
78048 ) AND
78049 (l_bflow_method_code = 'PRIOR_ENTRY')
78050 )
78051 THEN
78052 IF
78053 --
78054 1 = 2
78055 --
78056 THEN
78057 xla_accounting_err_pkg.build_message
78058 (p_appli_s_name => 'XLA'
78059 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
78060 ,p_token_1 => 'LINE_NUMBER'
78061 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
78062 ,p_token_2 => 'LINE_TYPE_NAME'
78063 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
78064 l_component_type
78065 ,l_component_code
78066 ,l_component_type_code
78067 ,l_component_appl_id
78068 ,l_amb_context_code
78069 ,l_entity_code
78070 ,l_event_class_code
78071 )
78072 ,p_token_3 => 'OWNER'
78073 ,p_value_3 => xla_lookups_pkg.get_meaning(
78074 p_lookup_type => 'XLA_OWNER_TYPE'
78075 ,p_lookup_code => l_component_type_code
78076 )
78077 ,p_token_4 => 'PRODUCT_NAME'
78078 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
78079 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
78080 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
78081 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
78082 ,p_ae_header_id => NULL
78083 );
78084
78085 IF (C_LEVEL_ERROR>= g_log_level) THEN
78086 trace
78087 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
78088 ,p_level => C_LEVEL_ERROR
78089 ,p_module => l_log_module);
78090 END IF;
78091 END IF;
78092 END IF;
78093 --
78094 --
78095 ------------------------------------------------------------------------------------------------
78096 -- 4219869 Business Flow
78097 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
78098 -- Prior Entry. Currently, the following code is always generated.
78099 ------------------------------------------------------------------------------------------------
78100 XLA_AE_LINES_PKG.ValidateCurrentLine;
78101
78102 ------------------------------------------------------------------------------------
78103 -- 4219869 Business Flow
78104 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
78105 ------------------------------------------------------------------------------------
78106 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
78107
78108 ----------------------------------------------------------------------------------
78109 -- 4219869 Business Flow
78110 -- Update journal entry status -- Need to generate this within IF <condition>
78111 ----------------------------------------------------------------------------------
78112 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
78113 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
78114 ,p_balance_type_code => l_balance_type_code
78115 );
78116
78117 -------------------------------------------------------------------------------------------
78118 -- 4262811 - Generate the Accrual Reversal lines
78119 -------------------------------------------------------------------------------------------
78120 BEGIN
78121 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
78122 (g_array_event(p_event_id).array_value_num('header_index'));
78123 IF l_acc_rev_flag IS NULL THEN
78124 l_acc_rev_flag := 'N';
78125 END IF;
78126 EXCEPTION
78127 WHEN OTHERS THEN
78128 l_acc_rev_flag := 'N';
78129 END;
78130 --
78131 IF (l_acc_rev_flag = 'Y') THEN
78132
78133 -- 4645092 ------------------------------------------------------------------------------
78134 -- To allow MPA report to determine if it should generate report process
78135 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
78136 ------------------------------------------------------------------------------------------
78137
78138 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
78139 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
78140 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
78141 -- call ADRs
78142 -- Bug 4922099
78143 --
78144 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
78145 (NVL(l_actual_upg_option, 'N') = 'O') OR
78146 (NVL(l_enc_upg_option, 'N') = 'O')
78147 )
78148 THEN
78149 NULL;
78150 --
78151 --
78152
78153 l_ccid := AcctDerRule_20(
78154 p_application_id => p_application_id
78155 , p_ae_header_id => l_ae_header_id
78156 , p_source_35 => p_source_35
78157 , x_transaction_coa_id => l_adr_transaction_coa_id
78158 , x_accounting_coa_id => l_adr_accounting_coa_id
78159 , x_value_type_code => l_adr_value_type_code
78160 , p_side => 'NA'
78161 );
78162
78163 xla_ae_lines_pkg.set_ccid(
78164 p_code_combination_id => l_ccid
78165 , p_value_type_code => l_adr_value_type_code
78166 , p_transaction_coa_id => l_adr_transaction_coa_id
78167 , p_accounting_coa_id => l_adr_accounting_coa_id
78168 , p_adr_code => 'PI_INTERORG_PAYABLES'
78169 , p_adr_type_code => 'S'
78170 , p_component_type => l_component_type
78171 , p_component_code => l_component_code
78172 , p_component_type_code => l_component_type_code
78173 , p_component_appl_id => l_component_appl_id
78174 , p_amb_context_code => l_amb_context_code
78175 , p_side => 'NA'
78176 );
78177
78178
78179 --
78180 --
78181 END IF;
78182
78183 --
78184 -- Update the line information that should be overwritten
78185 --
78186 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
78187 p_header_num => 1);
78188 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
78189
78190 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
78191
78192 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
78193 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
78194 END IF;
78195
78196 --
78197 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
78198 --
78199 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
78200 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
78201 ELSE
78202 ---------------------------------------------------------------------------------------------------
78203 -- 4262811a Switch Sign
78204 ---------------------------------------------------------------------------------------------------
78205 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
78206 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
78207 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78208 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
78209 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78210 -- 5132302
78211 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
78212 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78213
78214 END IF;
78215
78216 -- 4955764
78217 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
78218 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
78219
78220
78221 XLA_AE_LINES_PKG.ValidateCurrentLine;
78222 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
78223
78224 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
78225 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
78226 ,p_balance_type_code => l_balance_type_code);
78227
78228 END IF;
78229
78230 -----------------------------------------------------------------------------------------
78231 -- 4262811 Multiperiod Accounting
78232 -----------------------------------------------------------------------------------------
78233 -- No MPA option is assigned.
78234
78235
78236 END IF;
78237 END IF;
78238 --
78239
78240 --
78241 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78242 trace
78243 (p_msg => 'END of AcctLineType_161'
78244 ,p_level => C_LEVEL_PROCEDURE
78245 ,p_module => l_log_module);
78246 END IF;
78247 --
78248 EXCEPTION
78249 WHEN xla_exceptions_pkg.application_exception THEN
78250 RAISE;
78251 WHEN OTHERS THEN
78252 xla_exceptions_pkg.raise_message
78253 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_161');
78254 END AcctLineType_161;
78255 --
78256
78257 ---------------------------------------
78258 --
78259 -- PRIVATE FUNCTION
78260 -- AcctLineType_162
78261 --
78262 ---------------------------------------
78263 PROCEDURE AcctLineType_162 (
78264 p_application_id IN NUMBER
78265 ,p_event_id IN NUMBER
78266 ,p_calculate_acctd_flag IN VARCHAR2
78267 ,p_calculate_g_l_flag IN VARCHAR2
78268 ,p_actual_flag IN OUT VARCHAR2
78269 ,p_balance_type_code OUT VARCHAR2
78270 ,p_gain_or_loss_ref OUT VARCHAR2
78271
78272 --TRANSACTION_ID
78273 , p_source_1 IN NUMBER
78274 --Item Concatenated Segments
78275 , p_source_2 IN VARCHAR2
78276 --Transaction Quantity
78277 , p_source_3 IN NUMBER
78278 --Transaction Unit of Measure Code
78279 , p_source_4 IN VARCHAR2
78280 --Inventory Transaction Type Description
78281 , p_source_5 IN VARCHAR2
78282 --Interorg Payables Account
78283 , p_source_35 IN NUMBER
78284 --DISTRIBUTION_IDENTIFIER
78285 , p_source_84 IN NUMBER
78286 --Distribution Type
78287 , p_source_85 IN VARCHAR2
78288 , p_source_85_meaning IN VARCHAR2
78289 --Entered Currency Code
78290 , p_source_88 IN VARCHAR2
78291 --Entered Amount
78292 , p_source_91 IN NUMBER
78293 --Currency Conversion Date
78294 , p_source_92 IN DATE
78295 --Currency Conversion Rate
78296 , p_source_93 IN NUMBER
78297 --Currency Conversion Type
78298 , p_source_94 IN VARCHAR2
78299 --Accounted Amount
78300 , p_source_95 IN NUMBER
78301 --Accounting Line Type
78302 , p_source_97 IN NUMBER
78303 )
78304 IS
78305
78306 l_component_type VARCHAR2(80);
78307 l_component_code VARCHAR2(30);
78308 l_component_type_code VARCHAR2(1);
78309 l_component_appl_id INTEGER;
78310 l_amb_context_code VARCHAR2(30);
78311 l_entity_code VARCHAR2(30);
78312 l_event_class_code VARCHAR2(30);
78313 l_ae_header_id NUMBER;
78314 l_event_type_code VARCHAR2(30);
78315 l_line_definition_code VARCHAR2(30);
78316 l_line_definition_owner_code VARCHAR2(1);
78317 --
78318 -- adr variables
78319 l_segment VARCHAR2(30);
78320 l_ccid NUMBER;
78321 l_adr_transaction_coa_id NUMBER;
78322 l_adr_accounting_coa_id NUMBER;
78323 l_adr_flexfield_segment_code VARCHAR2(30);
78324 l_adr_flex_value_set_id NUMBER;
78325 l_adr_value_type_code VARCHAR2(30);
78326 l_adr_value_combination_id NUMBER;
78327 l_adr_value_segment_code VARCHAR2(30);
78328
78329 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
78330 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
78331 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
78332 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
78333
78334 -- 4262811 Variables ------------------------------------------------------------------------------------------
78335 l_entered_amt_idx NUMBER;
78336 l_accted_amt_idx NUMBER;
78337 l_acc_rev_flag VARCHAR2(1);
78338 l_accrual_line_num NUMBER;
78339 l_tmp_amt NUMBER;
78340 l_acc_rev_natural_side_code VARCHAR2(1);
78341
78342 l_num_entries NUMBER;
78343 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
78344 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
78345 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
78346 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
78347 l_recog_line_1 NUMBER;
78348 l_recog_line_2 NUMBER;
78349
78350 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
78351 l_bflow_applied_to_amt NUMBER; -- 5132302
78352 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
78353
78354 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
78355
78356 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
78357 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
78358
78359 ---------------------------------------------------------------------------------------------------------------
78360
78361
78362 --
78363 -- bulk performance
78364 --
78365 l_balance_type_code VARCHAR2(1);
78366 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
78367 l_log_module VARCHAR2(240);
78368
78369 --
78370 -- Upgrade strategy
78371 --
78372 l_actual_upg_option VARCHAR2(1);
78373 l_enc_upg_option VARCHAR2(1);
78374
78375 --
78376 BEGIN
78377 --
78378 IF g_log_enabled THEN
78379 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_162';
78380 END IF;
78381 --
78382 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78383
78384 trace
78385 (p_msg => 'BEGIN of AcctLineType_162'
78386 ,p_level => C_LEVEL_PROCEDURE
78387 ,p_module => l_log_module);
78388
78389 END IF;
78390 --
78391 l_component_type := 'AMB_JLT';
78392 l_component_code := 'INTERORG_PAYABLES';
78393 l_component_type_code := 'S';
78394 l_component_appl_id := 707;
78395 l_amb_context_code := 'DEFAULT';
78396 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
78397 l_event_class_code := 'USER_DEFINE';
78398 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
78399 l_line_definition_owner_code := 'S';
78400 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
78401 --
78402 l_balance_type_code := 'A';
78403 l_segment := NULL;
78404 l_ccid := NULL;
78405 l_adr_transaction_coa_id := NULL;
78406 l_adr_accounting_coa_id := NULL;
78407 l_adr_flexfield_segment_code := NULL;
78408 l_adr_flex_value_set_id := NULL;
78409 l_adr_value_type_code := NULL;
78410 l_adr_value_combination_id := NULL;
78411 l_adr_value_segment_code := NULL;
78412
78413 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
78414 l_bflow_class_code := ''; -- 4219869 Business Flow
78415 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
78416 l_budgetary_control_flag := 'N';
78417
78418 l_bflow_applied_to_amt_idx := NULL; -- 5132302
78419 l_bflow_applied_to_amt := NULL; -- 5132302
78420 l_entered_amt_idx := NULL; -- 4262811
78421 l_accted_amt_idx := NULL; -- 4262811
78422 l_acc_rev_flag := NULL; -- 4262811
78423 l_accrual_line_num := NULL; -- 4262811
78424 l_tmp_amt := NULL; -- 4262811
78425 --
78426
78427 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
78428 l_balance_type_code <> 'B' THEN
78429 IF NVL(p_source_97,9E125) = 9
78430 THEN
78431
78432 --
78433 XLA_AE_LINES_PKG.SetNewLine;
78434
78435 p_balance_type_code := l_balance_type_code;
78436 -- set the flag so later we will know whether the gain loss line needs to be created
78437
78438 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
78439 p_actual_flag :='A';
78440 END IF;
78441
78442 --
78443 -- bulk performance
78444 --
78445 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
78446 p_header_num => 0); -- 4262811
78447 --
78448 -- set accounting line options
78449 --
78450 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
78451 p_natural_side_code => 'D'
78452 , p_gain_or_loss_flag => 'N'
78453 , p_gl_transfer_mode_code => 'S'
78454 , p_acct_entry_type_code => 'A'
78455 , p_switch_side_flag => 'Y'
78456 , p_merge_duplicate_code => 'N'
78457 );
78458 --
78459 l_acc_rev_natural_side_code := 'C'; -- 4262811
78460 --
78461 --
78462 -- set accounting line type info
78463 --
78464 xla_ae_lines_pkg.SetAcctLineType
78465 (p_component_type => l_component_type
78466 ,p_event_type_code => l_event_type_code
78467 ,p_line_definition_owner_code => l_line_definition_owner_code
78468 ,p_line_definition_code => l_line_definition_code
78469 ,p_accounting_line_code => l_component_code
78470 ,p_accounting_line_type_code => l_component_type_code
78471 ,p_accounting_line_appl_id => l_component_appl_id
78472 ,p_amb_context_code => l_amb_context_code
78473 ,p_entity_code => l_entity_code
78474 ,p_event_class_code => l_event_class_code);
78475 --
78476 -- set accounting class
78477 --
78478 xla_ae_lines_pkg.SetAcctClass(
78479 p_accounting_class_code => 'INTERORG_PAYABLES'
78480 , p_ae_header_id => l_ae_header_id
78481 );
78482
78483 --
78484 -- set rounding class
78485 --
78486 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
78487 'INTERORG_PAYABLES';
78488
78489 --
78490 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
78491 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
78492 --
78493 -- bulk performance
78494 --
78495 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
78496
78497 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
78498 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
78499
78500 -- 4955764
78501 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
78502 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
78503
78504 -- 4458381 Public Sector Enh
78505
78506 --
78507 -- set accounting attributes for the line type
78508 --
78509 l_entered_amt_idx := 3;
78510 l_accted_amt_idx := 8;
78511 l_bflow_applied_to_amt_idx := NULL; -- 5132302
78512 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
78513 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
78514 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
78515 l_rec_acct_attrs.array_char_value(2) := p_source_85;
78516 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
78517 l_rec_acct_attrs.array_num_value(3) := p_source_91;
78518 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
78519 l_rec_acct_attrs.array_char_value(4) := p_source_88;
78520 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
78521 l_rec_acct_attrs.array_date_value(5) := p_source_92;
78522 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
78523 l_rec_acct_attrs.array_num_value(6) := p_source_93;
78524 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
78525 l_rec_acct_attrs.array_char_value(7) := p_source_94;
78526 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
78527 l_rec_acct_attrs.array_num_value(8) := p_source_95;
78528
78529 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
78530 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
78531
78532 ---------------------------------------------------------------------------------------------------------------
78533 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
78534 ---------------------------------------------------------------------------------------------------------------
78535 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
78536
78537 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
78538 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
78539
78540 IF xla_accounting_cache_pkg.GetValueChar
78541 (p_source_code => 'LEDGER_CATEGORY_CODE'
78542 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
78543 AND l_bflow_method_code = 'PRIOR_ENTRY'
78544 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
78545 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
78546 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
78547 )
78548 THEN
78549 xla_ae_lines_pkg.BflowUpgEntry
78550 (p_business_method_code => l_bflow_method_code
78551 ,p_business_class_code => l_bflow_class_code
78552 ,p_balance_type => l_balance_type_code);
78553 ELSE
78554 NULL;
78555 -- No business flow processing for business flow method of NONE.
78556 END IF;
78557
78558 --
78559 -- call analytical criteria
78560 --
78561
78562 --
78563 -- call description
78564 --
78565
78566 xla_ae_lines_pkg.SetLineDescription(
78567 p_ae_header_id => l_ae_header_id
78568 ,p_description => Description_1 (
78569 p_application_id => p_application_id
78570 , p_ae_header_id => l_ae_header_id
78571 , p_source_1 => p_source_1
78572 , p_source_2 => p_source_2
78573 , p_source_3 => p_source_3
78574 , p_source_4 => p_source_4
78575 , p_source_5 => p_source_5
78576 )
78577 );
78578
78579
78580 --
78581 -- call ADRs
78582 -- Bug 4922099
78583 --
78584 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
78585 (NVL(l_actual_upg_option, 'N') = 'O') OR
78586 (NVL(l_enc_upg_option, 'N') = 'O')
78587 )
78588 THEN
78589 NULL;
78590 --
78591 --
78592
78593 l_ccid := AcctDerRule_20(
78594 p_application_id => p_application_id
78595 , p_ae_header_id => l_ae_header_id
78596 , p_source_35 => p_source_35
78597 , x_transaction_coa_id => l_adr_transaction_coa_id
78598 , x_accounting_coa_id => l_adr_accounting_coa_id
78599 , x_value_type_code => l_adr_value_type_code
78600 , p_side => 'NA'
78601 );
78602
78603 xla_ae_lines_pkg.set_ccid(
78604 p_code_combination_id => l_ccid
78605 , p_value_type_code => l_adr_value_type_code
78606 , p_transaction_coa_id => l_adr_transaction_coa_id
78607 , p_accounting_coa_id => l_adr_accounting_coa_id
78608 , p_adr_code => 'PI_INTERORG_PAYABLES'
78609 , p_adr_type_code => 'S'
78610 , p_component_type => l_component_type
78611 , p_component_code => l_component_code
78612 , p_component_type_code => l_component_type_code
78613 , p_component_appl_id => l_component_appl_id
78614 , p_amb_context_code => l_amb_context_code
78615 , p_side => 'NA'
78616 );
78617
78618
78619 --
78620 --
78621 END IF;
78622 --
78623 -- Bug 4922099
78624 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
78625 (NVL(l_enc_upg_option, 'N') = 'O')
78626 ) AND
78627 (l_bflow_method_code = 'PRIOR_ENTRY')
78628 )
78629 THEN
78630 IF
78631 --
78632 1 = 2
78633 --
78634 THEN
78635 xla_accounting_err_pkg.build_message
78636 (p_appli_s_name => 'XLA'
78637 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
78638 ,p_token_1 => 'LINE_NUMBER'
78639 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
78640 ,p_token_2 => 'LINE_TYPE_NAME'
78641 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
78642 l_component_type
78643 ,l_component_code
78644 ,l_component_type_code
78645 ,l_component_appl_id
78646 ,l_amb_context_code
78647 ,l_entity_code
78648 ,l_event_class_code
78649 )
78650 ,p_token_3 => 'OWNER'
78651 ,p_value_3 => xla_lookups_pkg.get_meaning(
78652 p_lookup_type => 'XLA_OWNER_TYPE'
78653 ,p_lookup_code => l_component_type_code
78654 )
78655 ,p_token_4 => 'PRODUCT_NAME'
78656 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
78657 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
78658 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
78659 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
78660 ,p_ae_header_id => NULL
78661 );
78662
78663 IF (C_LEVEL_ERROR>= g_log_level) THEN
78664 trace
78665 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
78666 ,p_level => C_LEVEL_ERROR
78667 ,p_module => l_log_module);
78668 END IF;
78669 END IF;
78670 END IF;
78671 --
78672 --
78673 ------------------------------------------------------------------------------------------------
78674 -- 4219869 Business Flow
78675 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
78676 -- Prior Entry. Currently, the following code is always generated.
78677 ------------------------------------------------------------------------------------------------
78678 XLA_AE_LINES_PKG.ValidateCurrentLine;
78679
78680 ------------------------------------------------------------------------------------
78681 -- 4219869 Business Flow
78682 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
78683 ------------------------------------------------------------------------------------
78684 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
78685
78686 ----------------------------------------------------------------------------------
78687 -- 4219869 Business Flow
78688 -- Update journal entry status -- Need to generate this within IF <condition>
78689 ----------------------------------------------------------------------------------
78690 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
78691 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
78692 ,p_balance_type_code => l_balance_type_code
78693 );
78694
78695 -------------------------------------------------------------------------------------------
78696 -- 4262811 - Generate the Accrual Reversal lines
78697 -------------------------------------------------------------------------------------------
78698 BEGIN
78699 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
78700 (g_array_event(p_event_id).array_value_num('header_index'));
78701 IF l_acc_rev_flag IS NULL THEN
78702 l_acc_rev_flag := 'N';
78703 END IF;
78704 EXCEPTION
78705 WHEN OTHERS THEN
78706 l_acc_rev_flag := 'N';
78707 END;
78708 --
78709 IF (l_acc_rev_flag = 'Y') THEN
78710
78711 -- 4645092 ------------------------------------------------------------------------------
78712 -- To allow MPA report to determine if it should generate report process
78713 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
78714 ------------------------------------------------------------------------------------------
78715
78716 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
78717 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
78718 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
78719 -- call ADRs
78720 -- Bug 4922099
78721 --
78722 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
78723 (NVL(l_actual_upg_option, 'N') = 'O') OR
78724 (NVL(l_enc_upg_option, 'N') = 'O')
78725 )
78726 THEN
78727 NULL;
78728 --
78729 --
78730
78731 l_ccid := AcctDerRule_20(
78732 p_application_id => p_application_id
78733 , p_ae_header_id => l_ae_header_id
78734 , p_source_35 => p_source_35
78735 , x_transaction_coa_id => l_adr_transaction_coa_id
78736 , x_accounting_coa_id => l_adr_accounting_coa_id
78737 , x_value_type_code => l_adr_value_type_code
78738 , p_side => 'NA'
78739 );
78740
78741 xla_ae_lines_pkg.set_ccid(
78742 p_code_combination_id => l_ccid
78743 , p_value_type_code => l_adr_value_type_code
78744 , p_transaction_coa_id => l_adr_transaction_coa_id
78745 , p_accounting_coa_id => l_adr_accounting_coa_id
78746 , p_adr_code => 'PI_INTERORG_PAYABLES'
78747 , p_adr_type_code => 'S'
78748 , p_component_type => l_component_type
78749 , p_component_code => l_component_code
78750 , p_component_type_code => l_component_type_code
78751 , p_component_appl_id => l_component_appl_id
78752 , p_amb_context_code => l_amb_context_code
78753 , p_side => 'NA'
78754 );
78755
78756
78757 --
78758 --
78759 END IF;
78760
78761 --
78762 -- Update the line information that should be overwritten
78763 --
78764 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
78765 p_header_num => 1);
78766 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
78767
78768 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
78769
78770 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
78771 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
78772 END IF;
78773
78774 --
78775 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
78776 --
78777 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
78778 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
78779 ELSE
78780 ---------------------------------------------------------------------------------------------------
78781 -- 4262811a Switch Sign
78782 ---------------------------------------------------------------------------------------------------
78783 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
78784 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
78785 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78786 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
78787 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78788 -- 5132302
78789 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
78790 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
78791
78792 END IF;
78793
78794 -- 4955764
78795 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
78796 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
78797
78798
78799 XLA_AE_LINES_PKG.ValidateCurrentLine;
78800 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
78801
78802 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
78803 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
78804 ,p_balance_type_code => l_balance_type_code);
78805
78806 END IF;
78807
78808 -----------------------------------------------------------------------------------------
78809 -- 4262811 Multiperiod Accounting
78810 -----------------------------------------------------------------------------------------
78811 -- No MPA option is assigned.
78812
78813
78814 END IF;
78815 END IF;
78816 --
78817
78818 --
78819 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78820 trace
78821 (p_msg => 'END of AcctLineType_162'
78822 ,p_level => C_LEVEL_PROCEDURE
78823 ,p_module => l_log_module);
78824 END IF;
78825 --
78826 EXCEPTION
78827 WHEN xla_exceptions_pkg.application_exception THEN
78828 RAISE;
78829 WHEN OTHERS THEN
78830 xla_exceptions_pkg.raise_message
78831 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_162');
78832 END AcctLineType_162;
78833 --
78834
78835 ---------------------------------------
78836 --
78837 -- PRIVATE FUNCTION
78838 -- AcctLineType_163
78839 --
78840 ---------------------------------------
78841 PROCEDURE AcctLineType_163 (
78842 p_application_id IN NUMBER
78843 ,p_event_id IN NUMBER
78844 ,p_calculate_acctd_flag IN VARCHAR2
78845 ,p_calculate_g_l_flag IN VARCHAR2
78846 ,p_actual_flag IN OUT VARCHAR2
78847 ,p_balance_type_code OUT VARCHAR2
78848 ,p_gain_or_loss_ref OUT VARCHAR2
78849
78850 --TRANSACTION_ID
78851 , p_source_1 IN NUMBER
78852 --Item Concatenated Segments
78853 , p_source_2 IN VARCHAR2
78854 --Transaction Quantity
78855 , p_source_3 IN NUMBER
78856 --Transaction Unit of Measure Code
78857 , p_source_4 IN VARCHAR2
78858 --Inventory Transaction Type Description
78859 , p_source_5 IN VARCHAR2
78860 --Interorg Payables Account
78861 , p_source_35 IN NUMBER
78862 --DISTRIBUTION_IDENTIFIER
78863 , p_source_84 IN NUMBER
78864 --Distribution Type
78865 , p_source_85 IN VARCHAR2
78866 , p_source_85_meaning IN VARCHAR2
78867 --Entered Currency Code
78868 , p_source_88 IN VARCHAR2
78869 --Entered Amount
78870 , p_source_91 IN NUMBER
78871 --Currency Conversion Date
78872 , p_source_92 IN DATE
78873 --Currency Conversion Rate
78874 , p_source_93 IN NUMBER
78875 --Currency Conversion Type
78876 , p_source_94 IN VARCHAR2
78877 --Accounted Amount
78878 , p_source_95 IN NUMBER
78879 --Accounting Line Type
78880 , p_source_97 IN NUMBER
78881 )
78882 IS
78883
78884 l_component_type VARCHAR2(80);
78885 l_component_code VARCHAR2(30);
78886 l_component_type_code VARCHAR2(1);
78887 l_component_appl_id INTEGER;
78888 l_amb_context_code VARCHAR2(30);
78889 l_entity_code VARCHAR2(30);
78890 l_event_class_code VARCHAR2(30);
78891 l_ae_header_id NUMBER;
78892 l_event_type_code VARCHAR2(30);
78893 l_line_definition_code VARCHAR2(30);
78894 l_line_definition_owner_code VARCHAR2(1);
78895 --
78896 -- adr variables
78897 l_segment VARCHAR2(30);
78898 l_ccid NUMBER;
78899 l_adr_transaction_coa_id NUMBER;
78900 l_adr_accounting_coa_id NUMBER;
78901 l_adr_flexfield_segment_code VARCHAR2(30);
78902 l_adr_flex_value_set_id NUMBER;
78903 l_adr_value_type_code VARCHAR2(30);
78904 l_adr_value_combination_id NUMBER;
78905 l_adr_value_segment_code VARCHAR2(30);
78906
78907 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
78908 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
78909 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
78910 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
78911
78912 -- 4262811 Variables ------------------------------------------------------------------------------------------
78913 l_entered_amt_idx NUMBER;
78914 l_accted_amt_idx NUMBER;
78915 l_acc_rev_flag VARCHAR2(1);
78916 l_accrual_line_num NUMBER;
78917 l_tmp_amt NUMBER;
78918 l_acc_rev_natural_side_code VARCHAR2(1);
78919
78920 l_num_entries NUMBER;
78921 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
78922 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
78923 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
78924 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
78925 l_recog_line_1 NUMBER;
78926 l_recog_line_2 NUMBER;
78927
78928 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
78929 l_bflow_applied_to_amt NUMBER; -- 5132302
78930 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
78931
78932 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
78933
78934 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
78935 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
78936
78937 ---------------------------------------------------------------------------------------------------------------
78938
78939
78940 --
78941 -- bulk performance
78942 --
78943 l_balance_type_code VARCHAR2(1);
78944 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
78945 l_log_module VARCHAR2(240);
78946
78947 --
78948 -- Upgrade strategy
78949 --
78950 l_actual_upg_option VARCHAR2(1);
78951 l_enc_upg_option VARCHAR2(1);
78952
78953 --
78954 BEGIN
78955 --
78956 IF g_log_enabled THEN
78957 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_163';
78958 END IF;
78959 --
78960 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78961
78962 trace
78963 (p_msg => 'BEGIN of AcctLineType_163'
78964 ,p_level => C_LEVEL_PROCEDURE
78965 ,p_module => l_log_module);
78966
78967 END IF;
78968 --
78969 l_component_type := 'AMB_JLT';
78970 l_component_code := 'INTERORG_PAYABLES';
78971 l_component_type_code := 'S';
78972 l_component_appl_id := 707;
78973 l_amb_context_code := 'DEFAULT';
78974 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
78975 l_event_class_code := 'USER_DEFINE';
78976 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
78977 l_line_definition_owner_code := 'S';
78978 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
78979 --
78980 l_balance_type_code := 'A';
78981 l_segment := NULL;
78982 l_ccid := NULL;
78983 l_adr_transaction_coa_id := NULL;
78984 l_adr_accounting_coa_id := NULL;
78985 l_adr_flexfield_segment_code := NULL;
78986 l_adr_flex_value_set_id := NULL;
78987 l_adr_value_type_code := NULL;
78988 l_adr_value_combination_id := NULL;
78989 l_adr_value_segment_code := NULL;
78990
78991 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
78992 l_bflow_class_code := ''; -- 4219869 Business Flow
78993 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
78994 l_budgetary_control_flag := 'N';
78995
78996 l_bflow_applied_to_amt_idx := NULL; -- 5132302
78997 l_bflow_applied_to_amt := NULL; -- 5132302
78998 l_entered_amt_idx := NULL; -- 4262811
78999 l_accted_amt_idx := NULL; -- 4262811
79000 l_acc_rev_flag := NULL; -- 4262811
79001 l_accrual_line_num := NULL; -- 4262811
79002 l_tmp_amt := NULL; -- 4262811
79003 --
79004
79005 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
79006 l_balance_type_code <> 'B' THEN
79007 IF NVL(p_source_97,9E125) = 9
79008 THEN
79009
79010 --
79011 XLA_AE_LINES_PKG.SetNewLine;
79012
79013 p_balance_type_code := l_balance_type_code;
79014 -- set the flag so later we will know whether the gain loss line needs to be created
79015
79016 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
79017 p_actual_flag :='A';
79018 END IF;
79019
79020 --
79021 -- bulk performance
79022 --
79023 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
79024 p_header_num => 0); -- 4262811
79025 --
79026 -- set accounting line options
79027 --
79028 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
79029 p_natural_side_code => 'D'
79030 , p_gain_or_loss_flag => 'N'
79031 , p_gl_transfer_mode_code => 'S'
79032 , p_acct_entry_type_code => 'A'
79033 , p_switch_side_flag => 'Y'
79034 , p_merge_duplicate_code => 'N'
79035 );
79036 --
79037 l_acc_rev_natural_side_code := 'C'; -- 4262811
79038 --
79039 --
79040 -- set accounting line type info
79041 --
79042 xla_ae_lines_pkg.SetAcctLineType
79043 (p_component_type => l_component_type
79044 ,p_event_type_code => l_event_type_code
79045 ,p_line_definition_owner_code => l_line_definition_owner_code
79046 ,p_line_definition_code => l_line_definition_code
79047 ,p_accounting_line_code => l_component_code
79048 ,p_accounting_line_type_code => l_component_type_code
79049 ,p_accounting_line_appl_id => l_component_appl_id
79050 ,p_amb_context_code => l_amb_context_code
79051 ,p_entity_code => l_entity_code
79052 ,p_event_class_code => l_event_class_code);
79053 --
79054 -- set accounting class
79055 --
79056 xla_ae_lines_pkg.SetAcctClass(
79057 p_accounting_class_code => 'INTERORG_PAYABLES'
79058 , p_ae_header_id => l_ae_header_id
79059 );
79060
79061 --
79062 -- set rounding class
79063 --
79064 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
79065 'INTERORG_PAYABLES';
79066
79067 --
79068 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
79069 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
79070 --
79071 -- bulk performance
79072 --
79073 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
79074
79075 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
79076 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
79077
79078 -- 4955764
79079 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
79080 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
79081
79082 -- 4458381 Public Sector Enh
79083
79084 --
79085 -- set accounting attributes for the line type
79086 --
79087 l_entered_amt_idx := 3;
79088 l_accted_amt_idx := 8;
79089 l_bflow_applied_to_amt_idx := NULL; -- 5132302
79090 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
79091 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
79092 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
79093 l_rec_acct_attrs.array_char_value(2) := p_source_85;
79094 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
79095 l_rec_acct_attrs.array_num_value(3) := p_source_91;
79096 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
79097 l_rec_acct_attrs.array_char_value(4) := p_source_88;
79098 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
79099 l_rec_acct_attrs.array_date_value(5) := p_source_92;
79100 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
79101 l_rec_acct_attrs.array_num_value(6) := p_source_93;
79102 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
79103 l_rec_acct_attrs.array_char_value(7) := p_source_94;
79104 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
79105 l_rec_acct_attrs.array_num_value(8) := p_source_95;
79106
79107 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
79108 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
79109
79110 ---------------------------------------------------------------------------------------------------------------
79111 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
79112 ---------------------------------------------------------------------------------------------------------------
79113 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
79114
79115 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
79116 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
79117
79118 IF xla_accounting_cache_pkg.GetValueChar
79119 (p_source_code => 'LEDGER_CATEGORY_CODE'
79120 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
79121 AND l_bflow_method_code = 'PRIOR_ENTRY'
79122 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
79123 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
79124 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
79125 )
79126 THEN
79127 xla_ae_lines_pkg.BflowUpgEntry
79128 (p_business_method_code => l_bflow_method_code
79129 ,p_business_class_code => l_bflow_class_code
79130 ,p_balance_type => l_balance_type_code);
79131 ELSE
79132 NULL;
79133 -- No business flow processing for business flow method of NONE.
79134 END IF;
79135
79136 --
79137 -- call analytical criteria
79138 --
79139
79140 --
79141 -- call description
79142 --
79143
79144 xla_ae_lines_pkg.SetLineDescription(
79145 p_ae_header_id => l_ae_header_id
79146 ,p_description => Description_1 (
79147 p_application_id => p_application_id
79148 , p_ae_header_id => l_ae_header_id
79149 , p_source_1 => p_source_1
79150 , p_source_2 => p_source_2
79151 , p_source_3 => p_source_3
79152 , p_source_4 => p_source_4
79153 , p_source_5 => p_source_5
79154 )
79155 );
79156
79157
79158 --
79159 -- call ADRs
79160 -- Bug 4922099
79161 --
79162 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
79163 (NVL(l_actual_upg_option, 'N') = 'O') OR
79164 (NVL(l_enc_upg_option, 'N') = 'O')
79165 )
79166 THEN
79167 NULL;
79168 --
79169 --
79170
79171 l_ccid := AcctDerRule_20(
79172 p_application_id => p_application_id
79173 , p_ae_header_id => l_ae_header_id
79174 , p_source_35 => p_source_35
79175 , x_transaction_coa_id => l_adr_transaction_coa_id
79176 , x_accounting_coa_id => l_adr_accounting_coa_id
79177 , x_value_type_code => l_adr_value_type_code
79178 , p_side => 'NA'
79179 );
79180
79181 xla_ae_lines_pkg.set_ccid(
79182 p_code_combination_id => l_ccid
79183 , p_value_type_code => l_adr_value_type_code
79184 , p_transaction_coa_id => l_adr_transaction_coa_id
79185 , p_accounting_coa_id => l_adr_accounting_coa_id
79186 , p_adr_code => 'PI_INTERORG_PAYABLES'
79187 , p_adr_type_code => 'S'
79188 , p_component_type => l_component_type
79189 , p_component_code => l_component_code
79190 , p_component_type_code => l_component_type_code
79191 , p_component_appl_id => l_component_appl_id
79192 , p_amb_context_code => l_amb_context_code
79193 , p_side => 'NA'
79194 );
79195
79196
79197 --
79198 --
79199 END IF;
79200 --
79201 -- Bug 4922099
79202 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
79203 (NVL(l_enc_upg_option, 'N') = 'O')
79204 ) AND
79205 (l_bflow_method_code = 'PRIOR_ENTRY')
79206 )
79207 THEN
79208 IF
79209 --
79210 1 = 2
79211 --
79212 THEN
79213 xla_accounting_err_pkg.build_message
79214 (p_appli_s_name => 'XLA'
79215 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
79216 ,p_token_1 => 'LINE_NUMBER'
79217 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
79218 ,p_token_2 => 'LINE_TYPE_NAME'
79219 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
79220 l_component_type
79221 ,l_component_code
79222 ,l_component_type_code
79223 ,l_component_appl_id
79224 ,l_amb_context_code
79225 ,l_entity_code
79226 ,l_event_class_code
79227 )
79228 ,p_token_3 => 'OWNER'
79229 ,p_value_3 => xla_lookups_pkg.get_meaning(
79230 p_lookup_type => 'XLA_OWNER_TYPE'
79231 ,p_lookup_code => l_component_type_code
79232 )
79233 ,p_token_4 => 'PRODUCT_NAME'
79234 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
79235 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
79236 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
79237 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
79238 ,p_ae_header_id => NULL
79239 );
79240
79241 IF (C_LEVEL_ERROR>= g_log_level) THEN
79242 trace
79243 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
79244 ,p_level => C_LEVEL_ERROR
79245 ,p_module => l_log_module);
79246 END IF;
79247 END IF;
79248 END IF;
79249 --
79250 --
79251 ------------------------------------------------------------------------------------------------
79252 -- 4219869 Business Flow
79253 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
79254 -- Prior Entry. Currently, the following code is always generated.
79255 ------------------------------------------------------------------------------------------------
79256 XLA_AE_LINES_PKG.ValidateCurrentLine;
79257
79258 ------------------------------------------------------------------------------------
79259 -- 4219869 Business Flow
79260 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
79261 ------------------------------------------------------------------------------------
79262 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
79263
79264 ----------------------------------------------------------------------------------
79265 -- 4219869 Business Flow
79266 -- Update journal entry status -- Need to generate this within IF <condition>
79267 ----------------------------------------------------------------------------------
79268 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
79269 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
79270 ,p_balance_type_code => l_balance_type_code
79271 );
79272
79273 -------------------------------------------------------------------------------------------
79274 -- 4262811 - Generate the Accrual Reversal lines
79275 -------------------------------------------------------------------------------------------
79276 BEGIN
79277 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
79278 (g_array_event(p_event_id).array_value_num('header_index'));
79279 IF l_acc_rev_flag IS NULL THEN
79280 l_acc_rev_flag := 'N';
79281 END IF;
79282 EXCEPTION
79283 WHEN OTHERS THEN
79284 l_acc_rev_flag := 'N';
79285 END;
79286 --
79287 IF (l_acc_rev_flag = 'Y') THEN
79288
79289 -- 4645092 ------------------------------------------------------------------------------
79290 -- To allow MPA report to determine if it should generate report process
79291 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
79292 ------------------------------------------------------------------------------------------
79293
79294 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
79295 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
79296 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
79297 -- call ADRs
79298 -- Bug 4922099
79299 --
79300 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
79301 (NVL(l_actual_upg_option, 'N') = 'O') OR
79302 (NVL(l_enc_upg_option, 'N') = 'O')
79303 )
79304 THEN
79305 NULL;
79306 --
79307 --
79308
79309 l_ccid := AcctDerRule_20(
79310 p_application_id => p_application_id
79311 , p_ae_header_id => l_ae_header_id
79312 , p_source_35 => p_source_35
79313 , x_transaction_coa_id => l_adr_transaction_coa_id
79314 , x_accounting_coa_id => l_adr_accounting_coa_id
79315 , x_value_type_code => l_adr_value_type_code
79316 , p_side => 'NA'
79317 );
79318
79319 xla_ae_lines_pkg.set_ccid(
79320 p_code_combination_id => l_ccid
79321 , p_value_type_code => l_adr_value_type_code
79322 , p_transaction_coa_id => l_adr_transaction_coa_id
79323 , p_accounting_coa_id => l_adr_accounting_coa_id
79324 , p_adr_code => 'PI_INTERORG_PAYABLES'
79325 , p_adr_type_code => 'S'
79326 , p_component_type => l_component_type
79327 , p_component_code => l_component_code
79328 , p_component_type_code => l_component_type_code
79329 , p_component_appl_id => l_component_appl_id
79330 , p_amb_context_code => l_amb_context_code
79331 , p_side => 'NA'
79332 );
79333
79334
79335 --
79336 --
79337 END IF;
79338
79339 --
79340 -- Update the line information that should be overwritten
79341 --
79342 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
79343 p_header_num => 1);
79344 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
79345
79346 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
79347
79348 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
79349 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
79350 END IF;
79351
79352 --
79353 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
79354 --
79355 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
79356 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
79357 ELSE
79358 ---------------------------------------------------------------------------------------------------
79359 -- 4262811a Switch Sign
79360 ---------------------------------------------------------------------------------------------------
79361 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
79362 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
79363 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79364 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
79365 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79366 -- 5132302
79367 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
79368 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79369
79370 END IF;
79371
79372 -- 4955764
79373 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
79374 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
79375
79376
79377 XLA_AE_LINES_PKG.ValidateCurrentLine;
79378 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
79379
79380 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
79381 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
79382 ,p_balance_type_code => l_balance_type_code);
79383
79384 END IF;
79385
79386 -----------------------------------------------------------------------------------------
79387 -- 4262811 Multiperiod Accounting
79388 -----------------------------------------------------------------------------------------
79389 -- No MPA option is assigned.
79390
79391
79392 END IF;
79393 END IF;
79394 --
79395
79396 --
79397 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79398 trace
79399 (p_msg => 'END of AcctLineType_163'
79400 ,p_level => C_LEVEL_PROCEDURE
79401 ,p_module => l_log_module);
79402 END IF;
79403 --
79404 EXCEPTION
79405 WHEN xla_exceptions_pkg.application_exception THEN
79406 RAISE;
79407 WHEN OTHERS THEN
79408 xla_exceptions_pkg.raise_message
79409 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_163');
79410 END AcctLineType_163;
79411 --
79412
79413 ---------------------------------------
79414 --
79415 -- PRIVATE FUNCTION
79416 -- AcctLineType_164
79417 --
79418 ---------------------------------------
79419 PROCEDURE AcctLineType_164 (
79420 p_application_id IN NUMBER
79421 ,p_event_id IN NUMBER
79422 ,p_calculate_acctd_flag IN VARCHAR2
79423 ,p_calculate_g_l_flag IN VARCHAR2
79424 ,p_actual_flag IN OUT VARCHAR2
79425 ,p_balance_type_code OUT VARCHAR2
79426 ,p_gain_or_loss_ref OUT VARCHAR2
79427
79428 --TRANSACTION_ID
79429 , p_source_1 IN NUMBER
79430 --Item Concatenated Segments
79431 , p_source_2 IN VARCHAR2
79432 --Transaction Quantity
79433 , p_source_3 IN NUMBER
79434 --Transaction Unit of Measure Code
79435 , p_source_4 IN VARCHAR2
79436 --Inventory Transaction Type Description
79437 , p_source_5 IN VARCHAR2
79438 --Interorg Payables Account
79439 , p_source_35 IN NUMBER
79440 --DISTRIBUTION_IDENTIFIER
79441 , p_source_84 IN NUMBER
79442 --Distribution Type
79443 , p_source_85 IN VARCHAR2
79444 , p_source_85_meaning IN VARCHAR2
79445 --Entered Currency Code
79446 , p_source_88 IN VARCHAR2
79447 --Entered Amount
79448 , p_source_91 IN NUMBER
79449 --Currency Conversion Date
79450 , p_source_92 IN DATE
79451 --Currency Conversion Rate
79452 , p_source_93 IN NUMBER
79453 --Currency Conversion Type
79454 , p_source_94 IN VARCHAR2
79455 --Accounted Amount
79456 , p_source_95 IN NUMBER
79457 --Accounting Line Type
79458 , p_source_97 IN NUMBER
79459 )
79460 IS
79461
79462 l_component_type VARCHAR2(80);
79463 l_component_code VARCHAR2(30);
79464 l_component_type_code VARCHAR2(1);
79465 l_component_appl_id INTEGER;
79466 l_amb_context_code VARCHAR2(30);
79467 l_entity_code VARCHAR2(30);
79468 l_event_class_code VARCHAR2(30);
79469 l_ae_header_id NUMBER;
79470 l_event_type_code VARCHAR2(30);
79471 l_line_definition_code VARCHAR2(30);
79472 l_line_definition_owner_code VARCHAR2(1);
79473 --
79474 -- adr variables
79475 l_segment VARCHAR2(30);
79476 l_ccid NUMBER;
79477 l_adr_transaction_coa_id NUMBER;
79478 l_adr_accounting_coa_id NUMBER;
79479 l_adr_flexfield_segment_code VARCHAR2(30);
79480 l_adr_flex_value_set_id NUMBER;
79481 l_adr_value_type_code VARCHAR2(30);
79482 l_adr_value_combination_id NUMBER;
79483 l_adr_value_segment_code VARCHAR2(30);
79484
79485 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
79486 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
79487 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
79488 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
79489
79490 -- 4262811 Variables ------------------------------------------------------------------------------------------
79491 l_entered_amt_idx NUMBER;
79492 l_accted_amt_idx NUMBER;
79493 l_acc_rev_flag VARCHAR2(1);
79494 l_accrual_line_num NUMBER;
79495 l_tmp_amt NUMBER;
79496 l_acc_rev_natural_side_code VARCHAR2(1);
79497
79498 l_num_entries NUMBER;
79499 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
79500 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
79501 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
79502 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
79503 l_recog_line_1 NUMBER;
79504 l_recog_line_2 NUMBER;
79505
79506 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
79507 l_bflow_applied_to_amt NUMBER; -- 5132302
79508 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
79509
79510 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
79511
79512 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
79513 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
79514
79515 ---------------------------------------------------------------------------------------------------------------
79516
79517
79518 --
79519 -- bulk performance
79520 --
79521 l_balance_type_code VARCHAR2(1);
79522 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
79523 l_log_module VARCHAR2(240);
79524
79525 --
79526 -- Upgrade strategy
79527 --
79528 l_actual_upg_option VARCHAR2(1);
79529 l_enc_upg_option VARCHAR2(1);
79530
79531 --
79532 BEGIN
79533 --
79534 IF g_log_enabled THEN
79535 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_164';
79536 END IF;
79537 --
79538 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79539
79540 trace
79541 (p_msg => 'BEGIN of AcctLineType_164'
79542 ,p_level => C_LEVEL_PROCEDURE
79543 ,p_module => l_log_module);
79544
79545 END IF;
79546 --
79547 l_component_type := 'AMB_JLT';
79548 l_component_code := 'INTERORG_PAYABLES';
79549 l_component_type_code := 'S';
79550 l_component_appl_id := 707;
79551 l_amb_context_code := 'DEFAULT';
79552 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
79553 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
79554 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
79555 l_line_definition_owner_code := 'S';
79556 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
79557 --
79558 l_balance_type_code := 'A';
79559 l_segment := NULL;
79560 l_ccid := NULL;
79561 l_adr_transaction_coa_id := NULL;
79562 l_adr_accounting_coa_id := NULL;
79563 l_adr_flexfield_segment_code := NULL;
79564 l_adr_flex_value_set_id := NULL;
79565 l_adr_value_type_code := NULL;
79566 l_adr_value_combination_id := NULL;
79567 l_adr_value_segment_code := NULL;
79568
79569 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
79570 l_bflow_class_code := ''; -- 4219869 Business Flow
79571 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
79572 l_budgetary_control_flag := 'N';
79573
79574 l_bflow_applied_to_amt_idx := NULL; -- 5132302
79575 l_bflow_applied_to_amt := NULL; -- 5132302
79576 l_entered_amt_idx := NULL; -- 4262811
79577 l_accted_amt_idx := NULL; -- 4262811
79578 l_acc_rev_flag := NULL; -- 4262811
79579 l_accrual_line_num := NULL; -- 4262811
79580 l_tmp_amt := NULL; -- 4262811
79581 --
79582
79583 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
79584 l_balance_type_code <> 'B' THEN
79585 IF NVL(p_source_97,9E125) = 9
79586 THEN
79587
79588 --
79589 XLA_AE_LINES_PKG.SetNewLine;
79590
79591 p_balance_type_code := l_balance_type_code;
79592 -- set the flag so later we will know whether the gain loss line needs to be created
79593
79594 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
79595 p_actual_flag :='A';
79596 END IF;
79597
79598 --
79599 -- bulk performance
79600 --
79601 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
79602 p_header_num => 0); -- 4262811
79603 --
79604 -- set accounting line options
79605 --
79606 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
79607 p_natural_side_code => 'D'
79608 , p_gain_or_loss_flag => 'N'
79609 , p_gl_transfer_mode_code => 'S'
79610 , p_acct_entry_type_code => 'A'
79611 , p_switch_side_flag => 'Y'
79612 , p_merge_duplicate_code => 'N'
79613 );
79614 --
79615 l_acc_rev_natural_side_code := 'C'; -- 4262811
79616 --
79617 --
79618 -- set accounting line type info
79619 --
79620 xla_ae_lines_pkg.SetAcctLineType
79621 (p_component_type => l_component_type
79622 ,p_event_type_code => l_event_type_code
79623 ,p_line_definition_owner_code => l_line_definition_owner_code
79624 ,p_line_definition_code => l_line_definition_code
79625 ,p_accounting_line_code => l_component_code
79626 ,p_accounting_line_type_code => l_component_type_code
79627 ,p_accounting_line_appl_id => l_component_appl_id
79628 ,p_amb_context_code => l_amb_context_code
79629 ,p_entity_code => l_entity_code
79630 ,p_event_class_code => l_event_class_code);
79631 --
79632 -- set accounting class
79633 --
79634 xla_ae_lines_pkg.SetAcctClass(
79635 p_accounting_class_code => 'INTERORG_PAYABLES'
79636 , p_ae_header_id => l_ae_header_id
79637 );
79638
79639 --
79640 -- set rounding class
79641 --
79642 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
79643 'INTERORG_PAYABLES';
79644
79645 --
79646 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
79647 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
79648 --
79649 -- bulk performance
79650 --
79651 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
79652
79653 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
79654 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
79655
79656 -- 4955764
79657 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
79658 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
79659
79660 -- 4458381 Public Sector Enh
79661
79662 --
79663 -- set accounting attributes for the line type
79664 --
79665 l_entered_amt_idx := 3;
79666 l_accted_amt_idx := 8;
79667 l_bflow_applied_to_amt_idx := NULL; -- 5132302
79668 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
79669 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
79670 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
79671 l_rec_acct_attrs.array_char_value(2) := p_source_85;
79672 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
79673 l_rec_acct_attrs.array_num_value(3) := p_source_91;
79674 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
79675 l_rec_acct_attrs.array_char_value(4) := p_source_88;
79676 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
79677 l_rec_acct_attrs.array_date_value(5) := p_source_92;
79678 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
79679 l_rec_acct_attrs.array_num_value(6) := p_source_93;
79680 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
79681 l_rec_acct_attrs.array_char_value(7) := p_source_94;
79682 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
79683 l_rec_acct_attrs.array_num_value(8) := p_source_95;
79684
79685 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
79686 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
79687
79688 ---------------------------------------------------------------------------------------------------------------
79689 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
79690 ---------------------------------------------------------------------------------------------------------------
79691 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
79692
79693 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
79694 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
79695
79696 IF xla_accounting_cache_pkg.GetValueChar
79697 (p_source_code => 'LEDGER_CATEGORY_CODE'
79698 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
79699 AND l_bflow_method_code = 'PRIOR_ENTRY'
79700 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
79701 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
79702 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
79703 )
79704 THEN
79705 xla_ae_lines_pkg.BflowUpgEntry
79706 (p_business_method_code => l_bflow_method_code
79707 ,p_business_class_code => l_bflow_class_code
79708 ,p_balance_type => l_balance_type_code);
79709 ELSE
79710 NULL;
79711 -- No business flow processing for business flow method of NONE.
79712 END IF;
79713
79714 --
79715 -- call analytical criteria
79716 --
79717
79718 --
79719 -- call description
79720 --
79721
79722 xla_ae_lines_pkg.SetLineDescription(
79723 p_ae_header_id => l_ae_header_id
79724 ,p_description => Description_1 (
79725 p_application_id => p_application_id
79726 , p_ae_header_id => l_ae_header_id
79727 , p_source_1 => p_source_1
79728 , p_source_2 => p_source_2
79729 , p_source_3 => p_source_3
79730 , p_source_4 => p_source_4
79731 , p_source_5 => p_source_5
79732 )
79733 );
79734
79735
79736 --
79737 -- call ADRs
79738 -- Bug 4922099
79739 --
79740 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
79741 (NVL(l_actual_upg_option, 'N') = 'O') OR
79742 (NVL(l_enc_upg_option, 'N') = 'O')
79743 )
79744 THEN
79745 NULL;
79746 --
79747 --
79748
79749 l_ccid := AcctDerRule_20(
79750 p_application_id => p_application_id
79751 , p_ae_header_id => l_ae_header_id
79752 , p_source_35 => p_source_35
79753 , x_transaction_coa_id => l_adr_transaction_coa_id
79754 , x_accounting_coa_id => l_adr_accounting_coa_id
79755 , x_value_type_code => l_adr_value_type_code
79756 , p_side => 'NA'
79757 );
79758
79759 xla_ae_lines_pkg.set_ccid(
79760 p_code_combination_id => l_ccid
79761 , p_value_type_code => l_adr_value_type_code
79762 , p_transaction_coa_id => l_adr_transaction_coa_id
79763 , p_accounting_coa_id => l_adr_accounting_coa_id
79764 , p_adr_code => 'PI_INTERORG_PAYABLES'
79765 , p_adr_type_code => 'S'
79766 , p_component_type => l_component_type
79767 , p_component_code => l_component_code
79768 , p_component_type_code => l_component_type_code
79769 , p_component_appl_id => l_component_appl_id
79770 , p_amb_context_code => l_amb_context_code
79771 , p_side => 'NA'
79772 );
79773
79774
79775 --
79776 --
79777 END IF;
79778 --
79779 -- Bug 4922099
79780 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
79781 (NVL(l_enc_upg_option, 'N') = 'O')
79782 ) AND
79783 (l_bflow_method_code = 'PRIOR_ENTRY')
79784 )
79785 THEN
79786 IF
79787 --
79788 1 = 2
79789 --
79790 THEN
79791 xla_accounting_err_pkg.build_message
79792 (p_appli_s_name => 'XLA'
79793 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
79794 ,p_token_1 => 'LINE_NUMBER'
79795 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
79796 ,p_token_2 => 'LINE_TYPE_NAME'
79797 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
79798 l_component_type
79799 ,l_component_code
79800 ,l_component_type_code
79801 ,l_component_appl_id
79802 ,l_amb_context_code
79803 ,l_entity_code
79804 ,l_event_class_code
79805 )
79806 ,p_token_3 => 'OWNER'
79807 ,p_value_3 => xla_lookups_pkg.get_meaning(
79808 p_lookup_type => 'XLA_OWNER_TYPE'
79809 ,p_lookup_code => l_component_type_code
79810 )
79811 ,p_token_4 => 'PRODUCT_NAME'
79812 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
79813 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
79814 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
79815 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
79816 ,p_ae_header_id => NULL
79817 );
79818
79819 IF (C_LEVEL_ERROR>= g_log_level) THEN
79820 trace
79821 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
79822 ,p_level => C_LEVEL_ERROR
79823 ,p_module => l_log_module);
79824 END IF;
79825 END IF;
79826 END IF;
79827 --
79828 --
79829 ------------------------------------------------------------------------------------------------
79830 -- 4219869 Business Flow
79831 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
79832 -- Prior Entry. Currently, the following code is always generated.
79833 ------------------------------------------------------------------------------------------------
79834 XLA_AE_LINES_PKG.ValidateCurrentLine;
79835
79836 ------------------------------------------------------------------------------------
79837 -- 4219869 Business Flow
79838 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
79839 ------------------------------------------------------------------------------------
79840 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
79841
79842 ----------------------------------------------------------------------------------
79843 -- 4219869 Business Flow
79844 -- Update journal entry status -- Need to generate this within IF <condition>
79845 ----------------------------------------------------------------------------------
79846 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
79847 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
79848 ,p_balance_type_code => l_balance_type_code
79849 );
79850
79851 -------------------------------------------------------------------------------------------
79852 -- 4262811 - Generate the Accrual Reversal lines
79853 -------------------------------------------------------------------------------------------
79854 BEGIN
79855 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
79856 (g_array_event(p_event_id).array_value_num('header_index'));
79857 IF l_acc_rev_flag IS NULL THEN
79858 l_acc_rev_flag := 'N';
79859 END IF;
79860 EXCEPTION
79861 WHEN OTHERS THEN
79862 l_acc_rev_flag := 'N';
79863 END;
79864 --
79865 IF (l_acc_rev_flag = 'Y') THEN
79866
79867 -- 4645092 ------------------------------------------------------------------------------
79868 -- To allow MPA report to determine if it should generate report process
79869 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
79870 ------------------------------------------------------------------------------------------
79871
79872 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
79873 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
79874 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
79875 -- call ADRs
79876 -- Bug 4922099
79877 --
79878 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
79879 (NVL(l_actual_upg_option, 'N') = 'O') OR
79880 (NVL(l_enc_upg_option, 'N') = 'O')
79881 )
79882 THEN
79883 NULL;
79884 --
79885 --
79886
79887 l_ccid := AcctDerRule_20(
79888 p_application_id => p_application_id
79889 , p_ae_header_id => l_ae_header_id
79890 , p_source_35 => p_source_35
79891 , x_transaction_coa_id => l_adr_transaction_coa_id
79892 , x_accounting_coa_id => l_adr_accounting_coa_id
79893 , x_value_type_code => l_adr_value_type_code
79894 , p_side => 'NA'
79895 );
79896
79897 xla_ae_lines_pkg.set_ccid(
79898 p_code_combination_id => l_ccid
79899 , p_value_type_code => l_adr_value_type_code
79900 , p_transaction_coa_id => l_adr_transaction_coa_id
79901 , p_accounting_coa_id => l_adr_accounting_coa_id
79902 , p_adr_code => 'PI_INTERORG_PAYABLES'
79903 , p_adr_type_code => 'S'
79904 , p_component_type => l_component_type
79905 , p_component_code => l_component_code
79906 , p_component_type_code => l_component_type_code
79907 , p_component_appl_id => l_component_appl_id
79908 , p_amb_context_code => l_amb_context_code
79909 , p_side => 'NA'
79910 );
79911
79912
79913 --
79914 --
79915 END IF;
79916
79917 --
79918 -- Update the line information that should be overwritten
79919 --
79920 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
79921 p_header_num => 1);
79922 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
79923
79924 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
79925
79926 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
79927 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
79928 END IF;
79929
79930 --
79931 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
79932 --
79933 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
79934 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
79935 ELSE
79936 ---------------------------------------------------------------------------------------------------
79937 -- 4262811a Switch Sign
79938 ---------------------------------------------------------------------------------------------------
79939 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
79940 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
79941 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79942 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
79943 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79944 -- 5132302
79945 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
79946 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
79947
79948 END IF;
79949
79950 -- 4955764
79951 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
79952 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
79953
79954
79955 XLA_AE_LINES_PKG.ValidateCurrentLine;
79956 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
79957
79958 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
79959 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
79960 ,p_balance_type_code => l_balance_type_code);
79961
79962 END IF;
79963
79964 -----------------------------------------------------------------------------------------
79965 -- 4262811 Multiperiod Accounting
79966 -----------------------------------------------------------------------------------------
79967 -- No MPA option is assigned.
79968
79969
79970 END IF;
79971 END IF;
79972 --
79973
79974 --
79975 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79976 trace
79977 (p_msg => 'END of AcctLineType_164'
79978 ,p_level => C_LEVEL_PROCEDURE
79979 ,p_module => l_log_module);
79980 END IF;
79981 --
79982 EXCEPTION
79983 WHEN xla_exceptions_pkg.application_exception THEN
79984 RAISE;
79985 WHEN OTHERS THEN
79986 xla_exceptions_pkg.raise_message
79987 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_164');
79988 END AcctLineType_164;
79989 --
79990
79991 ---------------------------------------
79992 --
79993 -- PRIVATE FUNCTION
79994 -- AcctLineType_165
79995 --
79996 ---------------------------------------
79997 PROCEDURE AcctLineType_165 (
79998 p_application_id IN NUMBER
79999 ,p_event_id IN NUMBER
80000 ,p_calculate_acctd_flag IN VARCHAR2
80001 ,p_calculate_g_l_flag IN VARCHAR2
80002 ,p_actual_flag IN OUT VARCHAR2
80003 ,p_balance_type_code OUT VARCHAR2
80004 ,p_gain_or_loss_ref OUT VARCHAR2
80005
80006 --TRANSACTION_ID
80007 , p_source_1 IN NUMBER
80008 --Item Concatenated Segments
80009 , p_source_2 IN VARCHAR2
80010 --Transaction Quantity
80011 , p_source_3 IN NUMBER
80012 --Transaction Unit of Measure Code
80013 , p_source_4 IN VARCHAR2
80014 --Inventory Transaction Type Description
80015 , p_source_5 IN VARCHAR2
80016 --Cost Management Default Account
80017 , p_source_11 IN NUMBER
80018 --DISTRIBUTION_IDENTIFIER
80019 , p_source_84 IN NUMBER
80020 --Distribution Type
80021 , p_source_85 IN VARCHAR2
80022 , p_source_85_meaning IN VARCHAR2
80023 --Entered Currency Code
80024 , p_source_88 IN VARCHAR2
80025 --Entered Amount
80026 , p_source_91 IN NUMBER
80027 --Currency Conversion Date
80028 , p_source_92 IN DATE
80029 --Currency Conversion Rate
80030 , p_source_93 IN NUMBER
80031 --Currency Conversion Type
80032 , p_source_94 IN VARCHAR2
80033 --Accounted Amount
80034 , p_source_95 IN NUMBER
80035 --Accounting Line Type
80036 , p_source_97 IN NUMBER
80037 )
80038 IS
80039
80040 l_component_type VARCHAR2(80);
80041 l_component_code VARCHAR2(30);
80042 l_component_type_code VARCHAR2(1);
80043 l_component_appl_id INTEGER;
80044 l_amb_context_code VARCHAR2(30);
80045 l_entity_code VARCHAR2(30);
80046 l_event_class_code VARCHAR2(30);
80047 l_ae_header_id NUMBER;
80048 l_event_type_code VARCHAR2(30);
80049 l_line_definition_code VARCHAR2(30);
80050 l_line_definition_owner_code VARCHAR2(1);
80051 --
80052 -- adr variables
80053 l_segment VARCHAR2(30);
80054 l_ccid NUMBER;
80055 l_adr_transaction_coa_id NUMBER;
80056 l_adr_accounting_coa_id NUMBER;
80057 l_adr_flexfield_segment_code VARCHAR2(30);
80058 l_adr_flex_value_set_id NUMBER;
80059 l_adr_value_type_code VARCHAR2(30);
80060 l_adr_value_combination_id NUMBER;
80061 l_adr_value_segment_code VARCHAR2(30);
80062
80063 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
80064 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
80065 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
80066 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
80067
80068 -- 4262811 Variables ------------------------------------------------------------------------------------------
80069 l_entered_amt_idx NUMBER;
80070 l_accted_amt_idx NUMBER;
80071 l_acc_rev_flag VARCHAR2(1);
80072 l_accrual_line_num NUMBER;
80073 l_tmp_amt NUMBER;
80074 l_acc_rev_natural_side_code VARCHAR2(1);
80075
80076 l_num_entries NUMBER;
80077 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
80078 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
80079 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
80080 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
80081 l_recog_line_1 NUMBER;
80082 l_recog_line_2 NUMBER;
80083
80084 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
80085 l_bflow_applied_to_amt NUMBER; -- 5132302
80086 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
80087
80088 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
80089
80090 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
80091 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
80092
80093 ---------------------------------------------------------------------------------------------------------------
80094
80095
80096 --
80097 -- bulk performance
80098 --
80099 l_balance_type_code VARCHAR2(1);
80100 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
80101 l_log_module VARCHAR2(240);
80102
80103 --
80104 -- Upgrade strategy
80105 --
80106 l_actual_upg_option VARCHAR2(1);
80107 l_enc_upg_option VARCHAR2(1);
80108
80109 --
80110 BEGIN
80111 --
80112 IF g_log_enabled THEN
80113 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_165';
80114 END IF;
80115 --
80116 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
80117
80118 trace
80119 (p_msg => 'BEGIN of AcctLineType_165'
80120 ,p_level => C_LEVEL_PROCEDURE
80121 ,p_module => l_log_module);
80122
80123 END IF;
80124 --
80125 l_component_type := 'AMB_JLT';
80126 l_component_code := 'INTERORG_PAYABLES';
80127 l_component_type_code := 'S';
80128 l_component_appl_id := 707;
80129 l_amb_context_code := 'DEFAULT';
80130 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
80131 l_event_class_code := 'INT_ORDER_TO_EXP';
80132 l_event_type_code := 'INT_ORDER_ISSUE_NO_TP';
80133 l_line_definition_owner_code := 'S';
80134 l_line_definition_code := 'PI_INT_ORDER_ISSUE_NO_TP';
80135 --
80136 l_balance_type_code := 'A';
80137 l_segment := NULL;
80138 l_ccid := NULL;
80139 l_adr_transaction_coa_id := NULL;
80140 l_adr_accounting_coa_id := NULL;
80141 l_adr_flexfield_segment_code := NULL;
80142 l_adr_flex_value_set_id := NULL;
80143 l_adr_value_type_code := NULL;
80144 l_adr_value_combination_id := NULL;
80145 l_adr_value_segment_code := NULL;
80146
80147 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
80148 l_bflow_class_code := ''; -- 4219869 Business Flow
80149 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
80150 l_budgetary_control_flag := 'N';
80151
80152 l_bflow_applied_to_amt_idx := NULL; -- 5132302
80153 l_bflow_applied_to_amt := NULL; -- 5132302
80154 l_entered_amt_idx := NULL; -- 4262811
80155 l_accted_amt_idx := NULL; -- 4262811
80156 l_acc_rev_flag := NULL; -- 4262811
80157 l_accrual_line_num := NULL; -- 4262811
80158 l_tmp_amt := NULL; -- 4262811
80159 --
80160
80161 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
80162 l_balance_type_code <> 'B' THEN
80163 IF NVL(p_source_97,9E125) = 9
80164 THEN
80165
80166 --
80167 XLA_AE_LINES_PKG.SetNewLine;
80168
80169 p_balance_type_code := l_balance_type_code;
80170 -- set the flag so later we will know whether the gain loss line needs to be created
80171
80172 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
80173 p_actual_flag :='A';
80174 END IF;
80175
80176 --
80177 -- bulk performance
80178 --
80179 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
80180 p_header_num => 0); -- 4262811
80181 --
80182 -- set accounting line options
80183 --
80184 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
80185 p_natural_side_code => 'D'
80186 , p_gain_or_loss_flag => 'N'
80187 , p_gl_transfer_mode_code => 'S'
80188 , p_acct_entry_type_code => 'A'
80189 , p_switch_side_flag => 'Y'
80190 , p_merge_duplicate_code => 'N'
80191 );
80192 --
80193 l_acc_rev_natural_side_code := 'C'; -- 4262811
80194 --
80195 --
80196 -- set accounting line type info
80197 --
80198 xla_ae_lines_pkg.SetAcctLineType
80199 (p_component_type => l_component_type
80200 ,p_event_type_code => l_event_type_code
80201 ,p_line_definition_owner_code => l_line_definition_owner_code
80202 ,p_line_definition_code => l_line_definition_code
80203 ,p_accounting_line_code => l_component_code
80204 ,p_accounting_line_type_code => l_component_type_code
80205 ,p_accounting_line_appl_id => l_component_appl_id
80206 ,p_amb_context_code => l_amb_context_code
80207 ,p_entity_code => l_entity_code
80208 ,p_event_class_code => l_event_class_code);
80209 --
80210 -- set accounting class
80211 --
80212 xla_ae_lines_pkg.SetAcctClass(
80213 p_accounting_class_code => 'INTERORG_PAYABLES'
80214 , p_ae_header_id => l_ae_header_id
80215 );
80216
80217 --
80218 -- set rounding class
80219 --
80220 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
80221 'INTERORG_PAYABLES';
80222
80223 --
80224 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
80225 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
80226 --
80227 -- bulk performance
80228 --
80229 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
80230
80231 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
80232 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
80233
80234 -- 4955764
80235 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
80236 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
80237
80238 -- 4458381 Public Sector Enh
80239
80240 --
80241 -- set accounting attributes for the line type
80242 --
80243 l_entered_amt_idx := 3;
80244 l_accted_amt_idx := 8;
80245 l_bflow_applied_to_amt_idx := NULL; -- 5132302
80246 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
80247 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
80248 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
80249 l_rec_acct_attrs.array_char_value(2) := p_source_85;
80250 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
80251 l_rec_acct_attrs.array_num_value(3) := p_source_91;
80252 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
80253 l_rec_acct_attrs.array_char_value(4) := p_source_88;
80254 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
80255 l_rec_acct_attrs.array_date_value(5) := p_source_92;
80256 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
80257 l_rec_acct_attrs.array_num_value(6) := p_source_93;
80258 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
80259 l_rec_acct_attrs.array_char_value(7) := p_source_94;
80260 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
80261 l_rec_acct_attrs.array_num_value(8) := p_source_95;
80262
80263 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
80264 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
80265
80266 ---------------------------------------------------------------------------------------------------------------
80267 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
80268 ---------------------------------------------------------------------------------------------------------------
80269 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
80270
80271 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
80272 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
80273
80274 IF xla_accounting_cache_pkg.GetValueChar
80275 (p_source_code => 'LEDGER_CATEGORY_CODE'
80276 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
80277 AND l_bflow_method_code = 'PRIOR_ENTRY'
80278 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
80279 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
80280 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
80281 )
80282 THEN
80283 xla_ae_lines_pkg.BflowUpgEntry
80284 (p_business_method_code => l_bflow_method_code
80285 ,p_business_class_code => l_bflow_class_code
80286 ,p_balance_type => l_balance_type_code);
80287 ELSE
80288 NULL;
80289 -- No business flow processing for business flow method of NONE.
80290 END IF;
80291
80292 --
80293 -- call analytical criteria
80294 --
80295
80296 --
80297 -- call description
80298 --
80299
80300 xla_ae_lines_pkg.SetLineDescription(
80301 p_ae_header_id => l_ae_header_id
80302 ,p_description => Description_1 (
80303 p_application_id => p_application_id
80304 , p_ae_header_id => l_ae_header_id
80305 , p_source_1 => p_source_1
80306 , p_source_2 => p_source_2
80307 , p_source_3 => p_source_3
80308 , p_source_4 => p_source_4
80309 , p_source_5 => p_source_5
80310 )
80311 );
80312
80313
80314 --
80315 -- call ADRs
80316 -- Bug 4922099
80317 --
80318 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
80319 (NVL(l_actual_upg_option, 'N') = 'O') OR
80320 (NVL(l_enc_upg_option, 'N') = 'O')
80321 )
80322 THEN
80323 NULL;
80324 --
80325 --
80326
80327 l_ccid := AcctDerRule_6(
80328 p_application_id => p_application_id
80329 , p_ae_header_id => l_ae_header_id
80330 , p_source_11 => p_source_11
80331 , x_transaction_coa_id => l_adr_transaction_coa_id
80332 , x_accounting_coa_id => l_adr_accounting_coa_id
80333 , x_value_type_code => l_adr_value_type_code
80334 , p_side => 'NA'
80335 );
80336
80337 xla_ae_lines_pkg.set_ccid(
80338 p_code_combination_id => l_ccid
80339 , p_value_type_code => l_adr_value_type_code
80340 , p_transaction_coa_id => l_adr_transaction_coa_id
80341 , p_accounting_coa_id => l_adr_accounting_coa_id
80342 , p_adr_code => 'CST_DEFAULT'
80343 , p_adr_type_code => 'S'
80344 , p_component_type => l_component_type
80345 , p_component_code => l_component_code
80346 , p_component_type_code => l_component_type_code
80347 , p_component_appl_id => l_component_appl_id
80348 , p_amb_context_code => l_amb_context_code
80349 , p_side => 'NA'
80350 );
80351
80352
80353 --
80354 --
80355 END IF;
80356 --
80357 -- Bug 4922099
80358 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
80359 (NVL(l_enc_upg_option, 'N') = 'O')
80360 ) AND
80361 (l_bflow_method_code = 'PRIOR_ENTRY')
80362 )
80363 THEN
80364 IF
80365 --
80366 1 = 2
80367 --
80368 THEN
80369 xla_accounting_err_pkg.build_message
80370 (p_appli_s_name => 'XLA'
80371 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
80372 ,p_token_1 => 'LINE_NUMBER'
80373 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
80374 ,p_token_2 => 'LINE_TYPE_NAME'
80375 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
80376 l_component_type
80377 ,l_component_code
80378 ,l_component_type_code
80379 ,l_component_appl_id
80380 ,l_amb_context_code
80381 ,l_entity_code
80382 ,l_event_class_code
80383 )
80384 ,p_token_3 => 'OWNER'
80385 ,p_value_3 => xla_lookups_pkg.get_meaning(
80386 p_lookup_type => 'XLA_OWNER_TYPE'
80387 ,p_lookup_code => l_component_type_code
80388 )
80389 ,p_token_4 => 'PRODUCT_NAME'
80390 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
80391 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
80392 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
80393 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
80394 ,p_ae_header_id => NULL
80395 );
80396
80397 IF (C_LEVEL_ERROR>= g_log_level) THEN
80398 trace
80399 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
80400 ,p_level => C_LEVEL_ERROR
80401 ,p_module => l_log_module);
80402 END IF;
80403 END IF;
80404 END IF;
80405 --
80406 --
80407 ------------------------------------------------------------------------------------------------
80408 -- 4219869 Business Flow
80409 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
80410 -- Prior Entry. Currently, the following code is always generated.
80411 ------------------------------------------------------------------------------------------------
80412 XLA_AE_LINES_PKG.ValidateCurrentLine;
80413
80414 ------------------------------------------------------------------------------------
80415 -- 4219869 Business Flow
80416 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
80417 ------------------------------------------------------------------------------------
80418 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
80419
80420 ----------------------------------------------------------------------------------
80421 -- 4219869 Business Flow
80422 -- Update journal entry status -- Need to generate this within IF <condition>
80423 ----------------------------------------------------------------------------------
80424 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
80425 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
80426 ,p_balance_type_code => l_balance_type_code
80427 );
80428
80429 -------------------------------------------------------------------------------------------
80430 -- 4262811 - Generate the Accrual Reversal lines
80431 -------------------------------------------------------------------------------------------
80432 BEGIN
80433 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
80434 (g_array_event(p_event_id).array_value_num('header_index'));
80435 IF l_acc_rev_flag IS NULL THEN
80436 l_acc_rev_flag := 'N';
80437 END IF;
80438 EXCEPTION
80439 WHEN OTHERS THEN
80440 l_acc_rev_flag := 'N';
80441 END;
80442 --
80443 IF (l_acc_rev_flag = 'Y') THEN
80444
80445 -- 4645092 ------------------------------------------------------------------------------
80446 -- To allow MPA report to determine if it should generate report process
80447 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
80448 ------------------------------------------------------------------------------------------
80449
80450 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
80451 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
80452 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
80453 -- call ADRs
80454 -- Bug 4922099
80455 --
80456 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
80457 (NVL(l_actual_upg_option, 'N') = 'O') OR
80458 (NVL(l_enc_upg_option, 'N') = 'O')
80459 )
80460 THEN
80461 NULL;
80462 --
80463 --
80464
80465 l_ccid := AcctDerRule_6(
80466 p_application_id => p_application_id
80467 , p_ae_header_id => l_ae_header_id
80468 , p_source_11 => p_source_11
80469 , x_transaction_coa_id => l_adr_transaction_coa_id
80470 , x_accounting_coa_id => l_adr_accounting_coa_id
80471 , x_value_type_code => l_adr_value_type_code
80472 , p_side => 'NA'
80473 );
80474
80475 xla_ae_lines_pkg.set_ccid(
80476 p_code_combination_id => l_ccid
80477 , p_value_type_code => l_adr_value_type_code
80478 , p_transaction_coa_id => l_adr_transaction_coa_id
80479 , p_accounting_coa_id => l_adr_accounting_coa_id
80480 , p_adr_code => 'CST_DEFAULT'
80481 , p_adr_type_code => 'S'
80482 , p_component_type => l_component_type
80483 , p_component_code => l_component_code
80484 , p_component_type_code => l_component_type_code
80485 , p_component_appl_id => l_component_appl_id
80486 , p_amb_context_code => l_amb_context_code
80487 , p_side => 'NA'
80488 );
80489
80490
80491 --
80492 --
80493 END IF;
80494
80495 --
80496 -- Update the line information that should be overwritten
80497 --
80498 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
80499 p_header_num => 1);
80500 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
80501
80502 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
80503
80504 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
80505 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
80506 END IF;
80507
80508 --
80509 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
80510 --
80511 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
80512 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
80513 ELSE
80514 ---------------------------------------------------------------------------------------------------
80515 -- 4262811a Switch Sign
80516 ---------------------------------------------------------------------------------------------------
80517 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
80518 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
80519 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
80520 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
80521 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
80522 -- 5132302
80523 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
80524 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
80525
80526 END IF;
80527
80528 -- 4955764
80529 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
80530 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
80531
80532
80533 XLA_AE_LINES_PKG.ValidateCurrentLine;
80534 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
80535
80536 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
80537 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
80538 ,p_balance_type_code => l_balance_type_code);
80539
80540 END IF;
80541
80542 -----------------------------------------------------------------------------------------
80543 -- 4262811 Multiperiod Accounting
80544 -----------------------------------------------------------------------------------------
80545 -- No MPA option is assigned.
80546
80547
80548 END IF;
80549 END IF;
80550 --
80551
80552 --
80553 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
80554 trace
80555 (p_msg => 'END of AcctLineType_165'
80556 ,p_level => C_LEVEL_PROCEDURE
80557 ,p_module => l_log_module);
80558 END IF;
80559 --
80560 EXCEPTION
80561 WHEN xla_exceptions_pkg.application_exception THEN
80562 RAISE;
80563 WHEN OTHERS THEN
80564 xla_exceptions_pkg.raise_message
80565 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_165');
80566 END AcctLineType_165;
80567 --
80568
80569 ---------------------------------------
80570 --
80571 -- PRIVATE FUNCTION
80572 -- AcctLineType_166
80573 --
80574 ---------------------------------------
80575 PROCEDURE AcctLineType_166 (
80576 p_application_id IN NUMBER
80577 ,p_event_id IN NUMBER
80578 ,p_calculate_acctd_flag IN VARCHAR2
80579 ,p_calculate_g_l_flag IN VARCHAR2
80580 ,p_actual_flag IN OUT VARCHAR2
80581 ,p_balance_type_code OUT VARCHAR2
80582 ,p_gain_or_loss_ref OUT VARCHAR2
80583
80584 --TRANSACTION_ID
80585 , p_source_1 IN NUMBER
80586 --Item Concatenated Segments
80587 , p_source_2 IN VARCHAR2
80588 --Transaction Quantity
80589 , p_source_3 IN NUMBER
80590 --Transaction Unit of Measure Code
80591 , p_source_4 IN VARCHAR2
80592 --Inventory Transaction Type Description
80593 , p_source_5 IN VARCHAR2
80594 --Cost Management Default Account
80595 , p_source_11 IN NUMBER
80596 --DISTRIBUTION_IDENTIFIER
80597 , p_source_84 IN NUMBER
80598 --Distribution Type
80599 , p_source_85 IN VARCHAR2
80600 , p_source_85_meaning IN VARCHAR2
80601 --Entered Currency Code
80602 , p_source_88 IN VARCHAR2
80603 --Entered Amount
80604 , p_source_91 IN NUMBER
80605 --Currency Conversion Date
80606 , p_source_92 IN DATE
80607 --Currency Conversion Rate
80608 , p_source_93 IN NUMBER
80609 --Currency Conversion Type
80610 , p_source_94 IN VARCHAR2
80611 --Accounted Amount
80612 , p_source_95 IN NUMBER
80613 --Accounting Line Type
80614 , p_source_97 IN NUMBER
80615 )
80616 IS
80617
80618 l_component_type VARCHAR2(80);
80619 l_component_code VARCHAR2(30);
80620 l_component_type_code VARCHAR2(1);
80621 l_component_appl_id INTEGER;
80622 l_amb_context_code VARCHAR2(30);
80623 l_entity_code VARCHAR2(30);
80624 l_event_class_code VARCHAR2(30);
80625 l_ae_header_id NUMBER;
80626 l_event_type_code VARCHAR2(30);
80627 l_line_definition_code VARCHAR2(30);
80628 l_line_definition_owner_code VARCHAR2(1);
80629 --
80630 -- adr variables
80631 l_segment VARCHAR2(30);
80632 l_ccid NUMBER;
80633 l_adr_transaction_coa_id NUMBER;
80634 l_adr_accounting_coa_id NUMBER;
80635 l_adr_flexfield_segment_code VARCHAR2(30);
80636 l_adr_flex_value_set_id NUMBER;
80637 l_adr_value_type_code VARCHAR2(30);
80638 l_adr_value_combination_id NUMBER;
80639 l_adr_value_segment_code VARCHAR2(30);
80640
80641 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
80642 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
80643 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
80644 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
80645
80646 -- 4262811 Variables ------------------------------------------------------------------------------------------
80647 l_entered_amt_idx NUMBER;
80648 l_accted_amt_idx NUMBER;
80649 l_acc_rev_flag VARCHAR2(1);
80650 l_accrual_line_num NUMBER;
80651 l_tmp_amt NUMBER;
80652 l_acc_rev_natural_side_code VARCHAR2(1);
80653
80654 l_num_entries NUMBER;
80655 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
80656 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
80657 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
80658 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
80659 l_recog_line_1 NUMBER;
80660 l_recog_line_2 NUMBER;
80661
80662 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
80663 l_bflow_applied_to_amt NUMBER; -- 5132302
80664 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
80665
80666 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
80667
80668 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
80669 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
80670
80671 ---------------------------------------------------------------------------------------------------------------
80672
80673
80674 --
80675 -- bulk performance
80676 --
80677 l_balance_type_code VARCHAR2(1);
80678 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
80679 l_log_module VARCHAR2(240);
80680
80681 --
80682 -- Upgrade strategy
80683 --
80684 l_actual_upg_option VARCHAR2(1);
80685 l_enc_upg_option VARCHAR2(1);
80686
80687 --
80688 BEGIN
80689 --
80690 IF g_log_enabled THEN
80691 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_166';
80692 END IF;
80693 --
80694 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
80695
80696 trace
80697 (p_msg => 'BEGIN of AcctLineType_166'
80698 ,p_level => C_LEVEL_PROCEDURE
80699 ,p_module => l_log_module);
80700
80701 END IF;
80702 --
80703 l_component_type := 'AMB_JLT';
80704 l_component_code := 'INTERORG_PAYABLES';
80705 l_component_type_code := 'S';
80706 l_component_appl_id := 707;
80707 l_amb_context_code := 'DEFAULT';
80708 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
80709 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
80710 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
80711 l_line_definition_owner_code := 'S';
80712 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
80713 --
80714 l_balance_type_code := 'A';
80715 l_segment := NULL;
80716 l_ccid := NULL;
80717 l_adr_transaction_coa_id := NULL;
80718 l_adr_accounting_coa_id := NULL;
80719 l_adr_flexfield_segment_code := NULL;
80720 l_adr_flex_value_set_id := NULL;
80721 l_adr_value_type_code := NULL;
80722 l_adr_value_combination_id := NULL;
80723 l_adr_value_segment_code := NULL;
80724
80725 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
80726 l_bflow_class_code := ''; -- 4219869 Business Flow
80727 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
80728 l_budgetary_control_flag := 'N';
80729
80730 l_bflow_applied_to_amt_idx := NULL; -- 5132302
80731 l_bflow_applied_to_amt := NULL; -- 5132302
80732 l_entered_amt_idx := NULL; -- 4262811
80733 l_accted_amt_idx := NULL; -- 4262811
80734 l_acc_rev_flag := NULL; -- 4262811
80735 l_accrual_line_num := NULL; -- 4262811
80736 l_tmp_amt := NULL; -- 4262811
80737 --
80738
80739 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
80740 l_balance_type_code <> 'B' THEN
80741 IF NVL(p_source_97,9E125) = 9
80742 THEN
80743
80744 --
80745 XLA_AE_LINES_PKG.SetNewLine;
80746
80747 p_balance_type_code := l_balance_type_code;
80748 -- set the flag so later we will know whether the gain loss line needs to be created
80749
80750 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
80751 p_actual_flag :='A';
80752 END IF;
80753
80754 --
80755 -- bulk performance
80756 --
80757 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
80758 p_header_num => 0); -- 4262811
80759 --
80760 -- set accounting line options
80761 --
80762 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
80763 p_natural_side_code => 'D'
80764 , p_gain_or_loss_flag => 'N'
80765 , p_gl_transfer_mode_code => 'S'
80766 , p_acct_entry_type_code => 'A'
80767 , p_switch_side_flag => 'Y'
80768 , p_merge_duplicate_code => 'N'
80769 );
80770 --
80771 l_acc_rev_natural_side_code := 'C'; -- 4262811
80772 --
80773 --
80774 -- set accounting line type info
80775 --
80776 xla_ae_lines_pkg.SetAcctLineType
80777 (p_component_type => l_component_type
80778 ,p_event_type_code => l_event_type_code
80779 ,p_line_definition_owner_code => l_line_definition_owner_code
80780 ,p_line_definition_code => l_line_definition_code
80781 ,p_accounting_line_code => l_component_code
80782 ,p_accounting_line_type_code => l_component_type_code
80783 ,p_accounting_line_appl_id => l_component_appl_id
80784 ,p_amb_context_code => l_amb_context_code
80785 ,p_entity_code => l_entity_code
80786 ,p_event_class_code => l_event_class_code);
80787 --
80788 -- set accounting class
80789 --
80790 xla_ae_lines_pkg.SetAcctClass(
80791 p_accounting_class_code => 'INTERORG_PAYABLES'
80792 , p_ae_header_id => l_ae_header_id
80793 );
80794
80795 --
80796 -- set rounding class
80797 --
80798 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
80799 'INTERORG_PAYABLES';
80800
80801 --
80802 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
80803 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
80804 --
80805 -- bulk performance
80806 --
80807 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
80808
80809 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
80810 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
80811
80812 -- 4955764
80813 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
80814 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
80815
80816 -- 4458381 Public Sector Enh
80817
80818 --
80819 -- set accounting attributes for the line type
80820 --
80821 l_entered_amt_idx := 3;
80822 l_accted_amt_idx := 8;
80823 l_bflow_applied_to_amt_idx := NULL; -- 5132302
80824 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
80825 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
80826 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
80827 l_rec_acct_attrs.array_char_value(2) := p_source_85;
80828 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
80829 l_rec_acct_attrs.array_num_value(3) := p_source_91;
80830 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
80831 l_rec_acct_attrs.array_char_value(4) := p_source_88;
80832 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
80833 l_rec_acct_attrs.array_date_value(5) := p_source_92;
80834 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
80835 l_rec_acct_attrs.array_num_value(6) := p_source_93;
80836 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
80837 l_rec_acct_attrs.array_char_value(7) := p_source_94;
80838 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
80839 l_rec_acct_attrs.array_num_value(8) := p_source_95;
80840
80841 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
80842 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
80843
80844 ---------------------------------------------------------------------------------------------------------------
80845 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
80846 ---------------------------------------------------------------------------------------------------------------
80847 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
80848
80849 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
80850 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
80851
80852 IF xla_accounting_cache_pkg.GetValueChar
80853 (p_source_code => 'LEDGER_CATEGORY_CODE'
80854 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
80855 AND l_bflow_method_code = 'PRIOR_ENTRY'
80856 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
80857 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
80858 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
80859 )
80860 THEN
80861 xla_ae_lines_pkg.BflowUpgEntry
80862 (p_business_method_code => l_bflow_method_code
80863 ,p_business_class_code => l_bflow_class_code
80864 ,p_balance_type => l_balance_type_code);
80865 ELSE
80866 NULL;
80867 -- No business flow processing for business flow method of NONE.
80868 END IF;
80869
80870 --
80871 -- call analytical criteria
80872 --
80873
80874 --
80875 -- call description
80876 --
80877
80878 xla_ae_lines_pkg.SetLineDescription(
80879 p_ae_header_id => l_ae_header_id
80880 ,p_description => Description_1 (
80881 p_application_id => p_application_id
80882 , p_ae_header_id => l_ae_header_id
80883 , p_source_1 => p_source_1
80884 , p_source_2 => p_source_2
80885 , p_source_3 => p_source_3
80886 , p_source_4 => p_source_4
80887 , p_source_5 => p_source_5
80888 )
80889 );
80890
80891
80892 --
80893 -- call ADRs
80894 -- Bug 4922099
80895 --
80896 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
80897 (NVL(l_actual_upg_option, 'N') = 'O') OR
80898 (NVL(l_enc_upg_option, 'N') = 'O')
80899 )
80900 THEN
80901 NULL;
80902 --
80903 --
80904
80905 l_ccid := AcctDerRule_6(
80906 p_application_id => p_application_id
80907 , p_ae_header_id => l_ae_header_id
80908 , p_source_11 => p_source_11
80909 , x_transaction_coa_id => l_adr_transaction_coa_id
80910 , x_accounting_coa_id => l_adr_accounting_coa_id
80911 , x_value_type_code => l_adr_value_type_code
80912 , p_side => 'NA'
80913 );
80914
80915 xla_ae_lines_pkg.set_ccid(
80916 p_code_combination_id => l_ccid
80917 , p_value_type_code => l_adr_value_type_code
80918 , p_transaction_coa_id => l_adr_transaction_coa_id
80919 , p_accounting_coa_id => l_adr_accounting_coa_id
80920 , p_adr_code => 'CST_DEFAULT'
80921 , p_adr_type_code => 'S'
80922 , p_component_type => l_component_type
80923 , p_component_code => l_component_code
80924 , p_component_type_code => l_component_type_code
80925 , p_component_appl_id => l_component_appl_id
80926 , p_amb_context_code => l_amb_context_code
80927 , p_side => 'NA'
80928 );
80929
80930
80931 --
80932 --
80933 END IF;
80934 --
80935 -- Bug 4922099
80936 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
80937 (NVL(l_enc_upg_option, 'N') = 'O')
80938 ) AND
80939 (l_bflow_method_code = 'PRIOR_ENTRY')
80940 )
80941 THEN
80942 IF
80943 --
80944 1 = 2
80945 --
80946 THEN
80947 xla_accounting_err_pkg.build_message
80948 (p_appli_s_name => 'XLA'
80949 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
80950 ,p_token_1 => 'LINE_NUMBER'
80951 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
80952 ,p_token_2 => 'LINE_TYPE_NAME'
80953 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
80954 l_component_type
80955 ,l_component_code
80956 ,l_component_type_code
80957 ,l_component_appl_id
80958 ,l_amb_context_code
80959 ,l_entity_code
80960 ,l_event_class_code
80961 )
80962 ,p_token_3 => 'OWNER'
80963 ,p_value_3 => xla_lookups_pkg.get_meaning(
80964 p_lookup_type => 'XLA_OWNER_TYPE'
80965 ,p_lookup_code => l_component_type_code
80966 )
80967 ,p_token_4 => 'PRODUCT_NAME'
80968 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
80969 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
80970 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
80971 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
80972 ,p_ae_header_id => NULL
80973 );
80974
80975 IF (C_LEVEL_ERROR>= g_log_level) THEN
80976 trace
80977 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
80978 ,p_level => C_LEVEL_ERROR
80979 ,p_module => l_log_module);
80980 END IF;
80981 END IF;
80982 END IF;
80983 --
80984 --
80985 ------------------------------------------------------------------------------------------------
80986 -- 4219869 Business Flow
80987 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
80988 -- Prior Entry. Currently, the following code is always generated.
80989 ------------------------------------------------------------------------------------------------
80990 XLA_AE_LINES_PKG.ValidateCurrentLine;
80991
80992 ------------------------------------------------------------------------------------
80993 -- 4219869 Business Flow
80994 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
80995 ------------------------------------------------------------------------------------
80996 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
80997
80998 ----------------------------------------------------------------------------------
80999 -- 4219869 Business Flow
81000 -- Update journal entry status -- Need to generate this within IF <condition>
81001 ----------------------------------------------------------------------------------
81002 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
81003 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
81004 ,p_balance_type_code => l_balance_type_code
81005 );
81006
81007 -------------------------------------------------------------------------------------------
81008 -- 4262811 - Generate the Accrual Reversal lines
81009 -------------------------------------------------------------------------------------------
81010 BEGIN
81011 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
81012 (g_array_event(p_event_id).array_value_num('header_index'));
81013 IF l_acc_rev_flag IS NULL THEN
81014 l_acc_rev_flag := 'N';
81015 END IF;
81016 EXCEPTION
81017 WHEN OTHERS THEN
81018 l_acc_rev_flag := 'N';
81019 END;
81020 --
81021 IF (l_acc_rev_flag = 'Y') THEN
81022
81023 -- 4645092 ------------------------------------------------------------------------------
81024 -- To allow MPA report to determine if it should generate report process
81025 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
81026 ------------------------------------------------------------------------------------------
81027
81028 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
81029 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
81030 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
81031 -- call ADRs
81032 -- Bug 4922099
81033 --
81034 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
81035 (NVL(l_actual_upg_option, 'N') = 'O') OR
81036 (NVL(l_enc_upg_option, 'N') = 'O')
81037 )
81038 THEN
81039 NULL;
81040 --
81041 --
81042
81043 l_ccid := AcctDerRule_6(
81044 p_application_id => p_application_id
81045 , p_ae_header_id => l_ae_header_id
81046 , p_source_11 => p_source_11
81047 , x_transaction_coa_id => l_adr_transaction_coa_id
81048 , x_accounting_coa_id => l_adr_accounting_coa_id
81049 , x_value_type_code => l_adr_value_type_code
81050 , p_side => 'NA'
81051 );
81052
81053 xla_ae_lines_pkg.set_ccid(
81054 p_code_combination_id => l_ccid
81055 , p_value_type_code => l_adr_value_type_code
81056 , p_transaction_coa_id => l_adr_transaction_coa_id
81057 , p_accounting_coa_id => l_adr_accounting_coa_id
81058 , p_adr_code => 'CST_DEFAULT'
81059 , p_adr_type_code => 'S'
81060 , p_component_type => l_component_type
81061 , p_component_code => l_component_code
81062 , p_component_type_code => l_component_type_code
81063 , p_component_appl_id => l_component_appl_id
81064 , p_amb_context_code => l_amb_context_code
81065 , p_side => 'NA'
81066 );
81067
81068
81069 --
81070 --
81071 END IF;
81072
81073 --
81074 -- Update the line information that should be overwritten
81075 --
81076 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
81077 p_header_num => 1);
81078 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
81079
81080 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
81081
81082 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
81083 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
81084 END IF;
81085
81086 --
81087 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
81088 --
81089 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
81090 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
81091 ELSE
81092 ---------------------------------------------------------------------------------------------------
81093 -- 4262811a Switch Sign
81094 ---------------------------------------------------------------------------------------------------
81095 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
81096 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
81097 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81098 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
81099 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81100 -- 5132302
81101 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
81102 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81103
81104 END IF;
81105
81106 -- 4955764
81107 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
81108 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
81109
81110
81111 XLA_AE_LINES_PKG.ValidateCurrentLine;
81112 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
81113
81114 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
81115 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
81116 ,p_balance_type_code => l_balance_type_code);
81117
81118 END IF;
81119
81120 -----------------------------------------------------------------------------------------
81121 -- 4262811 Multiperiod Accounting
81122 -----------------------------------------------------------------------------------------
81123 -- No MPA option is assigned.
81124
81125
81126 END IF;
81127 END IF;
81128 --
81129
81130 --
81131 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81132 trace
81133 (p_msg => 'END of AcctLineType_166'
81134 ,p_level => C_LEVEL_PROCEDURE
81135 ,p_module => l_log_module);
81136 END IF;
81137 --
81138 EXCEPTION
81139 WHEN xla_exceptions_pkg.application_exception THEN
81140 RAISE;
81141 WHEN OTHERS THEN
81142 xla_exceptions_pkg.raise_message
81143 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_166');
81144 END AcctLineType_166;
81145 --
81146
81147 ---------------------------------------
81148 --
81149 -- PRIVATE FUNCTION
81150 -- AcctLineType_167
81151 --
81152 ---------------------------------------
81153 PROCEDURE AcctLineType_167 (
81154 p_application_id IN NUMBER
81155 ,p_event_id IN NUMBER
81156 ,p_calculate_acctd_flag IN VARCHAR2
81157 ,p_calculate_g_l_flag IN VARCHAR2
81158 ,p_actual_flag IN OUT VARCHAR2
81159 ,p_balance_type_code OUT VARCHAR2
81160 ,p_gain_or_loss_ref OUT VARCHAR2
81161
81162 --Interorg Payables Account
81163 , p_source_35 IN NUMBER
81164 --DISTRIBUTION_IDENTIFIER
81165 , p_source_84 IN NUMBER
81166 --Distribution Type
81167 , p_source_85 IN VARCHAR2
81168 , p_source_85_meaning IN VARCHAR2
81169 --Entered Currency Code
81170 , p_source_88 IN VARCHAR2
81171 --Entered Amount
81172 , p_source_91 IN NUMBER
81173 --Currency Conversion Date
81174 , p_source_92 IN DATE
81175 --Currency Conversion Rate
81176 , p_source_93 IN NUMBER
81177 --Currency Conversion Type
81178 , p_source_94 IN VARCHAR2
81179 --Accounted Amount
81180 , p_source_95 IN NUMBER
81181 --Accounting Line Type
81182 , p_source_97 IN NUMBER
81183 )
81184 IS
81185
81186 l_component_type VARCHAR2(80);
81187 l_component_code VARCHAR2(30);
81188 l_component_type_code VARCHAR2(1);
81189 l_component_appl_id INTEGER;
81190 l_amb_context_code VARCHAR2(30);
81191 l_entity_code VARCHAR2(30);
81192 l_event_class_code VARCHAR2(30);
81193 l_ae_header_id NUMBER;
81194 l_event_type_code VARCHAR2(30);
81195 l_line_definition_code VARCHAR2(30);
81196 l_line_definition_owner_code VARCHAR2(1);
81197 --
81198 -- adr variables
81199 l_segment VARCHAR2(30);
81200 l_ccid NUMBER;
81201 l_adr_transaction_coa_id NUMBER;
81202 l_adr_accounting_coa_id NUMBER;
81203 l_adr_flexfield_segment_code VARCHAR2(30);
81204 l_adr_flex_value_set_id NUMBER;
81205 l_adr_value_type_code VARCHAR2(30);
81206 l_adr_value_combination_id NUMBER;
81207 l_adr_value_segment_code VARCHAR2(30);
81208
81209 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
81210 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
81211 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
81212 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
81213
81214 -- 4262811 Variables ------------------------------------------------------------------------------------------
81215 l_entered_amt_idx NUMBER;
81216 l_accted_amt_idx NUMBER;
81217 l_acc_rev_flag VARCHAR2(1);
81218 l_accrual_line_num NUMBER;
81219 l_tmp_amt NUMBER;
81220 l_acc_rev_natural_side_code VARCHAR2(1);
81221
81222 l_num_entries NUMBER;
81223 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
81224 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
81225 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
81226 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
81227 l_recog_line_1 NUMBER;
81228 l_recog_line_2 NUMBER;
81229
81230 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
81231 l_bflow_applied_to_amt NUMBER; -- 5132302
81232 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
81233
81234 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
81235
81236 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
81237 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
81238
81239 ---------------------------------------------------------------------------------------------------------------
81240
81241
81242 --
81243 -- bulk performance
81244 --
81245 l_balance_type_code VARCHAR2(1);
81246 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
81247 l_log_module VARCHAR2(240);
81248
81249 --
81250 -- Upgrade strategy
81251 --
81252 l_actual_upg_option VARCHAR2(1);
81253 l_enc_upg_option VARCHAR2(1);
81254
81255 --
81256 BEGIN
81257 --
81258 IF g_log_enabled THEN
81259 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_167';
81260 END IF;
81261 --
81262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81263
81264 trace
81265 (p_msg => 'BEGIN of AcctLineType_167'
81266 ,p_level => C_LEVEL_PROCEDURE
81267 ,p_module => l_log_module);
81268
81269 END IF;
81270 --
81271 l_component_type := 'AMB_JLT';
81272 l_component_code := 'INTERORG_PAYABLES';
81273 l_component_type_code := 'S';
81274 l_component_appl_id := 707;
81275 l_amb_context_code := 'DEFAULT';
81276 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
81277 l_event_class_code := 'USER_DEFINE';
81278 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
81279 l_line_definition_owner_code := 'S';
81280 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
81281 --
81282 l_balance_type_code := 'A';
81283 l_segment := NULL;
81284 l_ccid := NULL;
81285 l_adr_transaction_coa_id := NULL;
81286 l_adr_accounting_coa_id := NULL;
81287 l_adr_flexfield_segment_code := NULL;
81288 l_adr_flex_value_set_id := NULL;
81289 l_adr_value_type_code := NULL;
81290 l_adr_value_combination_id := NULL;
81291 l_adr_value_segment_code := NULL;
81292
81293 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
81294 l_bflow_class_code := ''; -- 4219869 Business Flow
81295 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
81296 l_budgetary_control_flag := 'N';
81297
81298 l_bflow_applied_to_amt_idx := NULL; -- 5132302
81299 l_bflow_applied_to_amt := NULL; -- 5132302
81300 l_entered_amt_idx := NULL; -- 4262811
81301 l_accted_amt_idx := NULL; -- 4262811
81302 l_acc_rev_flag := NULL; -- 4262811
81303 l_accrual_line_num := NULL; -- 4262811
81304 l_tmp_amt := NULL; -- 4262811
81305 --
81306
81307 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
81308 l_balance_type_code <> 'B' THEN
81309 IF NVL(p_source_97,9E125) = 9
81310 THEN
81311
81312 --
81313 XLA_AE_LINES_PKG.SetNewLine;
81314
81315 p_balance_type_code := l_balance_type_code;
81316 -- set the flag so later we will know whether the gain loss line needs to be created
81317
81318 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
81319 p_actual_flag :='A';
81320 END IF;
81321
81322 --
81323 -- bulk performance
81324 --
81325 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
81326 p_header_num => 0); -- 4262811
81327 --
81328 -- set accounting line options
81329 --
81330 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
81331 p_natural_side_code => 'D'
81332 , p_gain_or_loss_flag => 'N'
81333 , p_gl_transfer_mode_code => 'S'
81334 , p_acct_entry_type_code => 'A'
81335 , p_switch_side_flag => 'Y'
81336 , p_merge_duplicate_code => 'N'
81337 );
81338 --
81339 l_acc_rev_natural_side_code := 'C'; -- 4262811
81340 --
81341 --
81342 -- set accounting line type info
81343 --
81344 xla_ae_lines_pkg.SetAcctLineType
81345 (p_component_type => l_component_type
81346 ,p_event_type_code => l_event_type_code
81347 ,p_line_definition_owner_code => l_line_definition_owner_code
81348 ,p_line_definition_code => l_line_definition_code
81349 ,p_accounting_line_code => l_component_code
81350 ,p_accounting_line_type_code => l_component_type_code
81351 ,p_accounting_line_appl_id => l_component_appl_id
81352 ,p_amb_context_code => l_amb_context_code
81353 ,p_entity_code => l_entity_code
81354 ,p_event_class_code => l_event_class_code);
81355 --
81356 -- set accounting class
81357 --
81358 xla_ae_lines_pkg.SetAcctClass(
81359 p_accounting_class_code => 'INTERORG_PAYABLES'
81360 , p_ae_header_id => l_ae_header_id
81361 );
81362
81363 --
81364 -- set rounding class
81365 --
81366 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
81367 'INTERORG_PAYABLES';
81368
81369 --
81370 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
81371 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
81372 --
81373 -- bulk performance
81374 --
81375 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
81376
81377 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
81378 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
81379
81380 -- 4955764
81381 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
81382 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
81383
81384 -- 4458381 Public Sector Enh
81385
81386 --
81387 -- set accounting attributes for the line type
81388 --
81389 l_entered_amt_idx := 3;
81390 l_accted_amt_idx := 8;
81391 l_bflow_applied_to_amt_idx := NULL; -- 5132302
81392 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
81393 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
81394 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
81395 l_rec_acct_attrs.array_char_value(2) := p_source_85;
81396 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
81397 l_rec_acct_attrs.array_num_value(3) := p_source_91;
81398 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
81399 l_rec_acct_attrs.array_char_value(4) := p_source_88;
81400 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
81401 l_rec_acct_attrs.array_date_value(5) := p_source_92;
81402 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
81403 l_rec_acct_attrs.array_num_value(6) := p_source_93;
81404 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
81405 l_rec_acct_attrs.array_char_value(7) := p_source_94;
81406 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
81407 l_rec_acct_attrs.array_num_value(8) := p_source_95;
81408
81409 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
81410 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
81411
81412 ---------------------------------------------------------------------------------------------------------------
81413 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
81414 ---------------------------------------------------------------------------------------------------------------
81415 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
81416
81417 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
81418 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
81419
81420 IF xla_accounting_cache_pkg.GetValueChar
81421 (p_source_code => 'LEDGER_CATEGORY_CODE'
81422 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
81423 AND l_bflow_method_code = 'PRIOR_ENTRY'
81424 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
81425 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
81426 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
81427 )
81428 THEN
81429 xla_ae_lines_pkg.BflowUpgEntry
81430 (p_business_method_code => l_bflow_method_code
81431 ,p_business_class_code => l_bflow_class_code
81432 ,p_balance_type => l_balance_type_code);
81433 ELSE
81434 NULL;
81435 -- No business flow processing for business flow method of NONE.
81436 END IF;
81437
81438 --
81439 -- call analytical criteria
81440 --
81441
81442 --
81443 -- call description
81444 --
81445 -- No description or it is inherited.
81446 --
81447 -- call ADRs
81448 -- Bug 4922099
81449 --
81450 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
81451 (NVL(l_actual_upg_option, 'N') = 'O') OR
81452 (NVL(l_enc_upg_option, 'N') = 'O')
81453 )
81454 THEN
81455 NULL;
81456 --
81457 --
81458
81459 l_ccid := AcctDerRule_20(
81460 p_application_id => p_application_id
81461 , p_ae_header_id => l_ae_header_id
81462 , p_source_35 => p_source_35
81463 , x_transaction_coa_id => l_adr_transaction_coa_id
81464 , x_accounting_coa_id => l_adr_accounting_coa_id
81465 , x_value_type_code => l_adr_value_type_code
81466 , p_side => 'NA'
81467 );
81468
81469 xla_ae_lines_pkg.set_ccid(
81470 p_code_combination_id => l_ccid
81471 , p_value_type_code => l_adr_value_type_code
81472 , p_transaction_coa_id => l_adr_transaction_coa_id
81473 , p_accounting_coa_id => l_adr_accounting_coa_id
81474 , p_adr_code => 'PI_INTERORG_PAYABLES'
81475 , p_adr_type_code => 'S'
81476 , p_component_type => l_component_type
81477 , p_component_code => l_component_code
81478 , p_component_type_code => l_component_type_code
81479 , p_component_appl_id => l_component_appl_id
81480 , p_amb_context_code => l_amb_context_code
81481 , p_side => 'NA'
81482 );
81483
81484
81485 --
81486 --
81487 END IF;
81488 --
81489 -- Bug 4922099
81490 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
81491 (NVL(l_enc_upg_option, 'N') = 'O')
81492 ) AND
81493 (l_bflow_method_code = 'PRIOR_ENTRY')
81494 )
81495 THEN
81496 IF
81497 --
81498 1 = 2
81499 --
81500 THEN
81501 xla_accounting_err_pkg.build_message
81502 (p_appli_s_name => 'XLA'
81503 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
81504 ,p_token_1 => 'LINE_NUMBER'
81505 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
81506 ,p_token_2 => 'LINE_TYPE_NAME'
81507 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
81508 l_component_type
81509 ,l_component_code
81510 ,l_component_type_code
81511 ,l_component_appl_id
81512 ,l_amb_context_code
81513 ,l_entity_code
81514 ,l_event_class_code
81515 )
81516 ,p_token_3 => 'OWNER'
81517 ,p_value_3 => xla_lookups_pkg.get_meaning(
81518 p_lookup_type => 'XLA_OWNER_TYPE'
81519 ,p_lookup_code => l_component_type_code
81520 )
81521 ,p_token_4 => 'PRODUCT_NAME'
81522 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
81523 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
81524 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
81525 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
81526 ,p_ae_header_id => NULL
81527 );
81528
81529 IF (C_LEVEL_ERROR>= g_log_level) THEN
81530 trace
81531 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
81532 ,p_level => C_LEVEL_ERROR
81533 ,p_module => l_log_module);
81534 END IF;
81535 END IF;
81536 END IF;
81537 --
81538 --
81539 ------------------------------------------------------------------------------------------------
81540 -- 4219869 Business Flow
81541 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
81542 -- Prior Entry. Currently, the following code is always generated.
81543 ------------------------------------------------------------------------------------------------
81544 XLA_AE_LINES_PKG.ValidateCurrentLine;
81545
81546 ------------------------------------------------------------------------------------
81547 -- 4219869 Business Flow
81548 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
81549 ------------------------------------------------------------------------------------
81550 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
81551
81552 ----------------------------------------------------------------------------------
81553 -- 4219869 Business Flow
81554 -- Update journal entry status -- Need to generate this within IF <condition>
81555 ----------------------------------------------------------------------------------
81556 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
81557 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
81558 ,p_balance_type_code => l_balance_type_code
81559 );
81560
81561 -------------------------------------------------------------------------------------------
81562 -- 4262811 - Generate the Accrual Reversal lines
81563 -------------------------------------------------------------------------------------------
81564 BEGIN
81565 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
81566 (g_array_event(p_event_id).array_value_num('header_index'));
81567 IF l_acc_rev_flag IS NULL THEN
81568 l_acc_rev_flag := 'N';
81569 END IF;
81570 EXCEPTION
81571 WHEN OTHERS THEN
81572 l_acc_rev_flag := 'N';
81573 END;
81574 --
81575 IF (l_acc_rev_flag = 'Y') THEN
81576
81577 -- 4645092 ------------------------------------------------------------------------------
81578 -- To allow MPA report to determine if it should generate report process
81579 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
81580 ------------------------------------------------------------------------------------------
81581
81582 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
81583 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
81584 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
81585 -- call ADRs
81586 -- Bug 4922099
81587 --
81588 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
81589 (NVL(l_actual_upg_option, 'N') = 'O') OR
81590 (NVL(l_enc_upg_option, 'N') = 'O')
81591 )
81592 THEN
81593 NULL;
81594 --
81595 --
81596
81597 l_ccid := AcctDerRule_20(
81598 p_application_id => p_application_id
81599 , p_ae_header_id => l_ae_header_id
81600 , p_source_35 => p_source_35
81601 , x_transaction_coa_id => l_adr_transaction_coa_id
81602 , x_accounting_coa_id => l_adr_accounting_coa_id
81603 , x_value_type_code => l_adr_value_type_code
81604 , p_side => 'NA'
81605 );
81606
81607 xla_ae_lines_pkg.set_ccid(
81608 p_code_combination_id => l_ccid
81609 , p_value_type_code => l_adr_value_type_code
81610 , p_transaction_coa_id => l_adr_transaction_coa_id
81611 , p_accounting_coa_id => l_adr_accounting_coa_id
81612 , p_adr_code => 'PI_INTERORG_PAYABLES'
81613 , p_adr_type_code => 'S'
81614 , p_component_type => l_component_type
81615 , p_component_code => l_component_code
81616 , p_component_type_code => l_component_type_code
81617 , p_component_appl_id => l_component_appl_id
81618 , p_amb_context_code => l_amb_context_code
81619 , p_side => 'NA'
81620 );
81621
81622
81623 --
81624 --
81625 END IF;
81626
81627 --
81628 -- Update the line information that should be overwritten
81629 --
81630 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
81631 p_header_num => 1);
81632 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
81633
81634 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
81635
81636 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
81637 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
81638 END IF;
81639
81640 --
81641 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
81642 --
81643 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
81644 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
81645 ELSE
81646 ---------------------------------------------------------------------------------------------------
81647 -- 4262811a Switch Sign
81648 ---------------------------------------------------------------------------------------------------
81649 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
81650 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
81651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81652 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
81653 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81654 -- 5132302
81655 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
81656 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
81657
81658 END IF;
81659
81660 -- 4955764
81661 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
81662 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
81663
81664
81665 XLA_AE_LINES_PKG.ValidateCurrentLine;
81666 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
81667
81668 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
81669 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
81670 ,p_balance_type_code => l_balance_type_code);
81671
81672 END IF;
81673
81674 -----------------------------------------------------------------------------------------
81675 -- 4262811 Multiperiod Accounting
81676 -----------------------------------------------------------------------------------------
81677 -- No MPA option is assigned.
81678
81679
81680 END IF;
81681 END IF;
81682 --
81683
81684 --
81685 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81686 trace
81687 (p_msg => 'END of AcctLineType_167'
81688 ,p_level => C_LEVEL_PROCEDURE
81689 ,p_module => l_log_module);
81690 END IF;
81691 --
81692 EXCEPTION
81693 WHEN xla_exceptions_pkg.application_exception THEN
81694 RAISE;
81695 WHEN OTHERS THEN
81696 xla_exceptions_pkg.raise_message
81697 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_167');
81698 END AcctLineType_167;
81699 --
81700
81701 ---------------------------------------
81702 --
81703 -- PRIVATE FUNCTION
81704 -- AcctLineType_168
81705 --
81706 ---------------------------------------
81707 PROCEDURE AcctLineType_168 (
81708 p_application_id IN NUMBER
81709 ,p_event_id IN NUMBER
81710 ,p_calculate_acctd_flag IN VARCHAR2
81711 ,p_calculate_g_l_flag IN VARCHAR2
81712 ,p_actual_flag IN OUT VARCHAR2
81713 ,p_balance_type_code OUT VARCHAR2
81714 ,p_gain_or_loss_ref OUT VARCHAR2
81715
81716 --TRANSACTION_ID
81717 , p_source_1 IN NUMBER
81718 --Item Concatenated Segments
81719 , p_source_2 IN VARCHAR2
81720 --Transaction Quantity
81721 , p_source_3 IN NUMBER
81722 --Transaction Unit of Measure Code
81723 , p_source_4 IN VARCHAR2
81724 --Inventory Transaction Type Description
81725 , p_source_5 IN VARCHAR2
81726 --Interorg Payables Account
81727 , p_source_35 IN NUMBER
81728 --DISTRIBUTION_IDENTIFIER
81729 , p_source_84 IN NUMBER
81730 --Distribution Type
81731 , p_source_85 IN VARCHAR2
81732 , p_source_85_meaning IN VARCHAR2
81733 --Entered Currency Code
81734 , p_source_88 IN VARCHAR2
81735 --Entered Amount
81736 , p_source_91 IN NUMBER
81737 --Currency Conversion Date
81738 , p_source_92 IN DATE
81739 --Currency Conversion Rate
81740 , p_source_93 IN NUMBER
81741 --Currency Conversion Type
81742 , p_source_94 IN VARCHAR2
81743 --Accounted Amount
81744 , p_source_95 IN NUMBER
81745 --Accounting Line Type
81746 , p_source_97 IN NUMBER
81747 )
81748 IS
81749
81750 l_component_type VARCHAR2(80);
81751 l_component_code VARCHAR2(30);
81752 l_component_type_code VARCHAR2(1);
81753 l_component_appl_id INTEGER;
81754 l_amb_context_code VARCHAR2(30);
81755 l_entity_code VARCHAR2(30);
81756 l_event_class_code VARCHAR2(30);
81757 l_ae_header_id NUMBER;
81758 l_event_type_code VARCHAR2(30);
81759 l_line_definition_code VARCHAR2(30);
81760 l_line_definition_owner_code VARCHAR2(1);
81761 --
81762 -- adr variables
81763 l_segment VARCHAR2(30);
81764 l_ccid NUMBER;
81765 l_adr_transaction_coa_id NUMBER;
81766 l_adr_accounting_coa_id NUMBER;
81767 l_adr_flexfield_segment_code VARCHAR2(30);
81768 l_adr_flex_value_set_id NUMBER;
81769 l_adr_value_type_code VARCHAR2(30);
81770 l_adr_value_combination_id NUMBER;
81771 l_adr_value_segment_code VARCHAR2(30);
81772
81773 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
81774 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
81775 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
81776 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
81777
81778 -- 4262811 Variables ------------------------------------------------------------------------------------------
81779 l_entered_amt_idx NUMBER;
81780 l_accted_amt_idx NUMBER;
81781 l_acc_rev_flag VARCHAR2(1);
81782 l_accrual_line_num NUMBER;
81783 l_tmp_amt NUMBER;
81784 l_acc_rev_natural_side_code VARCHAR2(1);
81785
81786 l_num_entries NUMBER;
81787 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
81788 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
81789 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
81790 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
81791 l_recog_line_1 NUMBER;
81792 l_recog_line_2 NUMBER;
81793
81794 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
81795 l_bflow_applied_to_amt NUMBER; -- 5132302
81796 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
81797
81798 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
81799
81800 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
81801 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
81802
81803 ---------------------------------------------------------------------------------------------------------------
81804
81805
81806 --
81807 -- bulk performance
81808 --
81809 l_balance_type_code VARCHAR2(1);
81810 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
81811 l_log_module VARCHAR2(240);
81812
81813 --
81814 -- Upgrade strategy
81815 --
81816 l_actual_upg_option VARCHAR2(1);
81817 l_enc_upg_option VARCHAR2(1);
81818
81819 --
81820 BEGIN
81821 --
81822 IF g_log_enabled THEN
81823 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_168';
81824 END IF;
81825 --
81826 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81827
81828 trace
81829 (p_msg => 'BEGIN of AcctLineType_168'
81830 ,p_level => C_LEVEL_PROCEDURE
81831 ,p_module => l_log_module);
81832
81833 END IF;
81834 --
81835 l_component_type := 'AMB_JLT';
81836 l_component_code := 'INTERORG_PAYABLES';
81837 l_component_type_code := 'S';
81838 l_component_appl_id := 707;
81839 l_amb_context_code := 'DEFAULT';
81840 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
81841 l_event_class_code := 'INT_ORDER_TO_EXP';
81842 l_event_type_code := 'EXP_REQ_RCPT_NO_TP';
81843 l_line_definition_owner_code := 'S';
81844 l_line_definition_code := 'PI_EXP_REQ_RCPT_NO_TP';
81845 --
81846 l_balance_type_code := 'A';
81847 l_segment := NULL;
81848 l_ccid := NULL;
81849 l_adr_transaction_coa_id := NULL;
81850 l_adr_accounting_coa_id := NULL;
81851 l_adr_flexfield_segment_code := NULL;
81852 l_adr_flex_value_set_id := NULL;
81853 l_adr_value_type_code := NULL;
81854 l_adr_value_combination_id := NULL;
81855 l_adr_value_segment_code := NULL;
81856
81857 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
81858 l_bflow_class_code := ''; -- 4219869 Business Flow
81859 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
81860 l_budgetary_control_flag := 'N';
81861
81862 l_bflow_applied_to_amt_idx := NULL; -- 5132302
81863 l_bflow_applied_to_amt := NULL; -- 5132302
81864 l_entered_amt_idx := NULL; -- 4262811
81865 l_accted_amt_idx := NULL; -- 4262811
81866 l_acc_rev_flag := NULL; -- 4262811
81867 l_accrual_line_num := NULL; -- 4262811
81868 l_tmp_amt := NULL; -- 4262811
81869 --
81870
81871 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
81872 l_balance_type_code <> 'B' THEN
81873 IF NVL(p_source_97,9E125) = 9
81874 THEN
81875
81876 --
81877 XLA_AE_LINES_PKG.SetNewLine;
81878
81879 p_balance_type_code := l_balance_type_code;
81880 -- set the flag so later we will know whether the gain loss line needs to be created
81881
81882 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
81883 p_actual_flag :='A';
81884 END IF;
81885
81886 --
81887 -- bulk performance
81888 --
81889 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
81890 p_header_num => 0); -- 4262811
81891 --
81892 -- set accounting line options
81893 --
81894 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
81895 p_natural_side_code => 'D'
81896 , p_gain_or_loss_flag => 'N'
81897 , p_gl_transfer_mode_code => 'S'
81898 , p_acct_entry_type_code => 'A'
81899 , p_switch_side_flag => 'Y'
81900 , p_merge_duplicate_code => 'N'
81901 );
81902 --
81903 l_acc_rev_natural_side_code := 'C'; -- 4262811
81904 --
81905 --
81906 -- set accounting line type info
81907 --
81908 xla_ae_lines_pkg.SetAcctLineType
81909 (p_component_type => l_component_type
81910 ,p_event_type_code => l_event_type_code
81911 ,p_line_definition_owner_code => l_line_definition_owner_code
81912 ,p_line_definition_code => l_line_definition_code
81913 ,p_accounting_line_code => l_component_code
81914 ,p_accounting_line_type_code => l_component_type_code
81915 ,p_accounting_line_appl_id => l_component_appl_id
81916 ,p_amb_context_code => l_amb_context_code
81917 ,p_entity_code => l_entity_code
81918 ,p_event_class_code => l_event_class_code);
81919 --
81920 -- set accounting class
81921 --
81922 xla_ae_lines_pkg.SetAcctClass(
81923 p_accounting_class_code => 'INTERORG_PAYABLES'
81924 , p_ae_header_id => l_ae_header_id
81925 );
81926
81927 --
81928 -- set rounding class
81929 --
81930 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
81931 'INTERORG_PAYABLES';
81932
81933 --
81934 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
81935 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
81936 --
81937 -- bulk performance
81938 --
81939 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
81940
81941 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
81942 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
81943
81944 -- 4955764
81945 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
81946 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
81947
81948 -- 4458381 Public Sector Enh
81949
81950 --
81951 -- set accounting attributes for the line type
81952 --
81953 l_entered_amt_idx := 3;
81954 l_accted_amt_idx := 8;
81955 l_bflow_applied_to_amt_idx := NULL; -- 5132302
81956 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
81957 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
81958 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
81959 l_rec_acct_attrs.array_char_value(2) := p_source_85;
81960 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
81961 l_rec_acct_attrs.array_num_value(3) := p_source_91;
81962 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
81963 l_rec_acct_attrs.array_char_value(4) := p_source_88;
81964 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
81965 l_rec_acct_attrs.array_date_value(5) := p_source_92;
81966 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
81967 l_rec_acct_attrs.array_num_value(6) := p_source_93;
81968 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
81969 l_rec_acct_attrs.array_char_value(7) := p_source_94;
81970 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
81971 l_rec_acct_attrs.array_num_value(8) := p_source_95;
81972
81973 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
81974 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
81975
81976 ---------------------------------------------------------------------------------------------------------------
81977 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
81978 ---------------------------------------------------------------------------------------------------------------
81979 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
81980
81981 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
81982 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
81983
81984 IF xla_accounting_cache_pkg.GetValueChar
81985 (p_source_code => 'LEDGER_CATEGORY_CODE'
81986 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
81987 AND l_bflow_method_code = 'PRIOR_ENTRY'
81988 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
81989 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
81990 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
81991 )
81992 THEN
81993 xla_ae_lines_pkg.BflowUpgEntry
81994 (p_business_method_code => l_bflow_method_code
81995 ,p_business_class_code => l_bflow_class_code
81996 ,p_balance_type => l_balance_type_code);
81997 ELSE
81998 NULL;
81999 -- No business flow processing for business flow method of NONE.
82000 END IF;
82001
82002 --
82003 -- call analytical criteria
82004 --
82005
82006 --
82007 -- call description
82008 --
82009
82010 xla_ae_lines_pkg.SetLineDescription(
82011 p_ae_header_id => l_ae_header_id
82012 ,p_description => Description_1 (
82013 p_application_id => p_application_id
82014 , p_ae_header_id => l_ae_header_id
82015 , p_source_1 => p_source_1
82016 , p_source_2 => p_source_2
82017 , p_source_3 => p_source_3
82018 , p_source_4 => p_source_4
82019 , p_source_5 => p_source_5
82020 )
82021 );
82022
82023
82024 --
82025 -- call ADRs
82026 -- Bug 4922099
82027 --
82028 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
82029 (NVL(l_actual_upg_option, 'N') = 'O') OR
82030 (NVL(l_enc_upg_option, 'N') = 'O')
82031 )
82032 THEN
82033 NULL;
82034 --
82035 --
82036
82037 l_ccid := AcctDerRule_20(
82038 p_application_id => p_application_id
82039 , p_ae_header_id => l_ae_header_id
82040 , p_source_35 => p_source_35
82041 , x_transaction_coa_id => l_adr_transaction_coa_id
82042 , x_accounting_coa_id => l_adr_accounting_coa_id
82043 , x_value_type_code => l_adr_value_type_code
82044 , p_side => 'NA'
82045 );
82046
82047 xla_ae_lines_pkg.set_ccid(
82048 p_code_combination_id => l_ccid
82049 , p_value_type_code => l_adr_value_type_code
82050 , p_transaction_coa_id => l_adr_transaction_coa_id
82051 , p_accounting_coa_id => l_adr_accounting_coa_id
82052 , p_adr_code => 'PI_INTERORG_PAYABLES'
82053 , p_adr_type_code => 'S'
82054 , p_component_type => l_component_type
82055 , p_component_code => l_component_code
82056 , p_component_type_code => l_component_type_code
82057 , p_component_appl_id => l_component_appl_id
82058 , p_amb_context_code => l_amb_context_code
82059 , p_side => 'NA'
82060 );
82061
82062
82063 --
82064 --
82065 END IF;
82066 --
82067 -- Bug 4922099
82068 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
82069 (NVL(l_enc_upg_option, 'N') = 'O')
82070 ) AND
82071 (l_bflow_method_code = 'PRIOR_ENTRY')
82072 )
82073 THEN
82074 IF
82075 --
82076 1 = 2
82077 --
82078 THEN
82079 xla_accounting_err_pkg.build_message
82080 (p_appli_s_name => 'XLA'
82081 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
82082 ,p_token_1 => 'LINE_NUMBER'
82083 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
82084 ,p_token_2 => 'LINE_TYPE_NAME'
82085 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
82086 l_component_type
82087 ,l_component_code
82088 ,l_component_type_code
82089 ,l_component_appl_id
82090 ,l_amb_context_code
82091 ,l_entity_code
82092 ,l_event_class_code
82093 )
82094 ,p_token_3 => 'OWNER'
82095 ,p_value_3 => xla_lookups_pkg.get_meaning(
82096 p_lookup_type => 'XLA_OWNER_TYPE'
82097 ,p_lookup_code => l_component_type_code
82098 )
82099 ,p_token_4 => 'PRODUCT_NAME'
82100 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
82101 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
82102 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
82103 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
82104 ,p_ae_header_id => NULL
82105 );
82106
82107 IF (C_LEVEL_ERROR>= g_log_level) THEN
82108 trace
82109 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
82110 ,p_level => C_LEVEL_ERROR
82111 ,p_module => l_log_module);
82112 END IF;
82113 END IF;
82114 END IF;
82115 --
82116 --
82117 ------------------------------------------------------------------------------------------------
82118 -- 4219869 Business Flow
82119 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
82120 -- Prior Entry. Currently, the following code is always generated.
82121 ------------------------------------------------------------------------------------------------
82122 XLA_AE_LINES_PKG.ValidateCurrentLine;
82123
82124 ------------------------------------------------------------------------------------
82125 -- 4219869 Business Flow
82126 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
82127 ------------------------------------------------------------------------------------
82128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
82129
82130 ----------------------------------------------------------------------------------
82131 -- 4219869 Business Flow
82132 -- Update journal entry status -- Need to generate this within IF <condition>
82133 ----------------------------------------------------------------------------------
82134 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
82135 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
82136 ,p_balance_type_code => l_balance_type_code
82137 );
82138
82139 -------------------------------------------------------------------------------------------
82140 -- 4262811 - Generate the Accrual Reversal lines
82141 -------------------------------------------------------------------------------------------
82142 BEGIN
82143 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
82144 (g_array_event(p_event_id).array_value_num('header_index'));
82145 IF l_acc_rev_flag IS NULL THEN
82146 l_acc_rev_flag := 'N';
82147 END IF;
82148 EXCEPTION
82149 WHEN OTHERS THEN
82150 l_acc_rev_flag := 'N';
82151 END;
82152 --
82153 IF (l_acc_rev_flag = 'Y') THEN
82154
82155 -- 4645092 ------------------------------------------------------------------------------
82156 -- To allow MPA report to determine if it should generate report process
82157 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
82158 ------------------------------------------------------------------------------------------
82159
82160 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
82161 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
82162 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
82163 -- call ADRs
82164 -- Bug 4922099
82165 --
82166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
82167 (NVL(l_actual_upg_option, 'N') = 'O') OR
82168 (NVL(l_enc_upg_option, 'N') = 'O')
82169 )
82170 THEN
82171 NULL;
82172 --
82173 --
82174
82175 l_ccid := AcctDerRule_20(
82176 p_application_id => p_application_id
82177 , p_ae_header_id => l_ae_header_id
82178 , p_source_35 => p_source_35
82179 , x_transaction_coa_id => l_adr_transaction_coa_id
82180 , x_accounting_coa_id => l_adr_accounting_coa_id
82181 , x_value_type_code => l_adr_value_type_code
82182 , p_side => 'NA'
82183 );
82184
82185 xla_ae_lines_pkg.set_ccid(
82186 p_code_combination_id => l_ccid
82187 , p_value_type_code => l_adr_value_type_code
82188 , p_transaction_coa_id => l_adr_transaction_coa_id
82189 , p_accounting_coa_id => l_adr_accounting_coa_id
82190 , p_adr_code => 'PI_INTERORG_PAYABLES'
82191 , p_adr_type_code => 'S'
82192 , p_component_type => l_component_type
82193 , p_component_code => l_component_code
82194 , p_component_type_code => l_component_type_code
82195 , p_component_appl_id => l_component_appl_id
82196 , p_amb_context_code => l_amb_context_code
82197 , p_side => 'NA'
82198 );
82199
82200
82201 --
82202 --
82203 END IF;
82204
82205 --
82206 -- Update the line information that should be overwritten
82207 --
82208 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
82209 p_header_num => 1);
82210 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
82211
82212 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
82213
82214 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
82215 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
82216 END IF;
82217
82218 --
82219 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
82220 --
82221 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
82222 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
82223 ELSE
82224 ---------------------------------------------------------------------------------------------------
82225 -- 4262811a Switch Sign
82226 ---------------------------------------------------------------------------------------------------
82227 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
82228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
82229 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82230 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
82231 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82232 -- 5132302
82233 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
82234 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82235
82236 END IF;
82237
82238 -- 4955764
82239 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
82240 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
82241
82242
82243 XLA_AE_LINES_PKG.ValidateCurrentLine;
82244 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
82245
82246 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
82247 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
82248 ,p_balance_type_code => l_balance_type_code);
82249
82250 END IF;
82251
82252 -----------------------------------------------------------------------------------------
82253 -- 4262811 Multiperiod Accounting
82254 -----------------------------------------------------------------------------------------
82255 -- No MPA option is assigned.
82256
82257
82258 END IF;
82259 END IF;
82260 --
82261
82262 --
82263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82264 trace
82265 (p_msg => 'END of AcctLineType_168'
82266 ,p_level => C_LEVEL_PROCEDURE
82267 ,p_module => l_log_module);
82268 END IF;
82269 --
82270 EXCEPTION
82271 WHEN xla_exceptions_pkg.application_exception THEN
82272 RAISE;
82273 WHEN OTHERS THEN
82274 xla_exceptions_pkg.raise_message
82275 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_168');
82276 END AcctLineType_168;
82277 --
82278
82279 ---------------------------------------
82280 --
82281 -- PRIVATE FUNCTION
82282 -- AcctLineType_169
82283 --
82284 ---------------------------------------
82285 PROCEDURE AcctLineType_169 (
82286 p_application_id IN NUMBER
82287 ,p_event_id IN NUMBER
82288 ,p_calculate_acctd_flag IN VARCHAR2
82289 ,p_calculate_g_l_flag IN VARCHAR2
82290 ,p_actual_flag IN OUT VARCHAR2
82291 ,p_balance_type_code OUT VARCHAR2
82292 ,p_gain_or_loss_ref OUT VARCHAR2
82293
82294 --TRANSACTION_ID
82295 , p_source_1 IN NUMBER
82296 --Item Concatenated Segments
82297 , p_source_2 IN VARCHAR2
82298 --Transaction Quantity
82299 , p_source_3 IN NUMBER
82300 --Transaction Unit of Measure Code
82301 , p_source_4 IN VARCHAR2
82302 --Inventory Transaction Type Description
82303 , p_source_5 IN VARCHAR2
82304 --Interorg Payables Account
82305 , p_source_35 IN NUMBER
82306 --DISTRIBUTION_IDENTIFIER
82307 , p_source_84 IN NUMBER
82308 --Distribution Type
82309 , p_source_85 IN VARCHAR2
82310 , p_source_85_meaning IN VARCHAR2
82311 --Entered Currency Code
82312 , p_source_88 IN VARCHAR2
82313 --Entered Amount
82314 , p_source_91 IN NUMBER
82315 --Currency Conversion Date
82316 , p_source_92 IN DATE
82317 --Currency Conversion Rate
82318 , p_source_93 IN NUMBER
82319 --Currency Conversion Type
82320 , p_source_94 IN VARCHAR2
82321 --Accounted Amount
82322 , p_source_95 IN NUMBER
82323 --Accounting Line Type
82324 , p_source_97 IN NUMBER
82325 )
82326 IS
82327
82328 l_component_type VARCHAR2(80);
82329 l_component_code VARCHAR2(30);
82330 l_component_type_code VARCHAR2(1);
82331 l_component_appl_id INTEGER;
82332 l_amb_context_code VARCHAR2(30);
82333 l_entity_code VARCHAR2(30);
82334 l_event_class_code VARCHAR2(30);
82335 l_ae_header_id NUMBER;
82336 l_event_type_code VARCHAR2(30);
82337 l_line_definition_code VARCHAR2(30);
82338 l_line_definition_owner_code VARCHAR2(1);
82339 --
82340 -- adr variables
82341 l_segment VARCHAR2(30);
82342 l_ccid NUMBER;
82343 l_adr_transaction_coa_id NUMBER;
82344 l_adr_accounting_coa_id NUMBER;
82345 l_adr_flexfield_segment_code VARCHAR2(30);
82346 l_adr_flex_value_set_id NUMBER;
82347 l_adr_value_type_code VARCHAR2(30);
82348 l_adr_value_combination_id NUMBER;
82349 l_adr_value_segment_code VARCHAR2(30);
82350
82351 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
82352 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
82353 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
82354 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
82355
82356 -- 4262811 Variables ------------------------------------------------------------------------------------------
82357 l_entered_amt_idx NUMBER;
82358 l_accted_amt_idx NUMBER;
82359 l_acc_rev_flag VARCHAR2(1);
82360 l_accrual_line_num NUMBER;
82361 l_tmp_amt NUMBER;
82362 l_acc_rev_natural_side_code VARCHAR2(1);
82363
82364 l_num_entries NUMBER;
82365 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
82366 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
82367 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
82368 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
82369 l_recog_line_1 NUMBER;
82370 l_recog_line_2 NUMBER;
82371
82372 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
82373 l_bflow_applied_to_amt NUMBER; -- 5132302
82374 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
82375
82376 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
82377
82378 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
82379 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
82380
82381 ---------------------------------------------------------------------------------------------------------------
82382
82383
82384 --
82385 -- bulk performance
82386 --
82387 l_balance_type_code VARCHAR2(1);
82388 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
82389 l_log_module VARCHAR2(240);
82390
82391 --
82392 -- Upgrade strategy
82393 --
82394 l_actual_upg_option VARCHAR2(1);
82395 l_enc_upg_option VARCHAR2(1);
82396
82397 --
82398 BEGIN
82399 --
82400 IF g_log_enabled THEN
82401 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_169';
82402 END IF;
82403 --
82404 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82405
82406 trace
82407 (p_msg => 'BEGIN of AcctLineType_169'
82408 ,p_level => C_LEVEL_PROCEDURE
82409 ,p_module => l_log_module);
82410
82411 END IF;
82412 --
82413 l_component_type := 'AMB_JLT';
82414 l_component_code := 'INTERORG_PAYABLES';
82415 l_component_type_code := 'S';
82416 l_component_appl_id := 707;
82417 l_amb_context_code := 'DEFAULT';
82418 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
82419 l_event_class_code := 'INT_ORDER_TO_EXP';
82420 l_event_type_code := 'EXP_REQ_RCPT_TP';
82421 l_line_definition_owner_code := 'S';
82422 l_line_definition_code := 'PI_EXP_REQ_RCPT_TP';
82423 --
82424 l_balance_type_code := 'A';
82425 l_segment := NULL;
82426 l_ccid := NULL;
82427 l_adr_transaction_coa_id := NULL;
82428 l_adr_accounting_coa_id := NULL;
82429 l_adr_flexfield_segment_code := NULL;
82430 l_adr_flex_value_set_id := NULL;
82431 l_adr_value_type_code := NULL;
82432 l_adr_value_combination_id := NULL;
82433 l_adr_value_segment_code := NULL;
82434
82435 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
82436 l_bflow_class_code := ''; -- 4219869 Business Flow
82437 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
82438 l_budgetary_control_flag := 'N';
82439
82440 l_bflow_applied_to_amt_idx := NULL; -- 5132302
82441 l_bflow_applied_to_amt := NULL; -- 5132302
82442 l_entered_amt_idx := NULL; -- 4262811
82443 l_accted_amt_idx := NULL; -- 4262811
82444 l_acc_rev_flag := NULL; -- 4262811
82445 l_accrual_line_num := NULL; -- 4262811
82446 l_tmp_amt := NULL; -- 4262811
82447 --
82448
82449 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
82450 l_balance_type_code <> 'B' THEN
82451 IF NVL(p_source_97,9E125) = 9
82452 THEN
82453
82454 --
82455 XLA_AE_LINES_PKG.SetNewLine;
82456
82457 p_balance_type_code := l_balance_type_code;
82458 -- set the flag so later we will know whether the gain loss line needs to be created
82459
82460 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
82461 p_actual_flag :='A';
82462 END IF;
82463
82464 --
82465 -- bulk performance
82466 --
82467 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
82468 p_header_num => 0); -- 4262811
82469 --
82470 -- set accounting line options
82471 --
82472 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
82473 p_natural_side_code => 'D'
82474 , p_gain_or_loss_flag => 'N'
82475 , p_gl_transfer_mode_code => 'S'
82476 , p_acct_entry_type_code => 'A'
82477 , p_switch_side_flag => 'Y'
82478 , p_merge_duplicate_code => 'N'
82479 );
82480 --
82481 l_acc_rev_natural_side_code := 'C'; -- 4262811
82482 --
82483 --
82484 -- set accounting line type info
82485 --
82486 xla_ae_lines_pkg.SetAcctLineType
82487 (p_component_type => l_component_type
82488 ,p_event_type_code => l_event_type_code
82489 ,p_line_definition_owner_code => l_line_definition_owner_code
82490 ,p_line_definition_code => l_line_definition_code
82491 ,p_accounting_line_code => l_component_code
82492 ,p_accounting_line_type_code => l_component_type_code
82493 ,p_accounting_line_appl_id => l_component_appl_id
82494 ,p_amb_context_code => l_amb_context_code
82495 ,p_entity_code => l_entity_code
82496 ,p_event_class_code => l_event_class_code);
82497 --
82498 -- set accounting class
82499 --
82500 xla_ae_lines_pkg.SetAcctClass(
82501 p_accounting_class_code => 'INTERORG_PAYABLES'
82502 , p_ae_header_id => l_ae_header_id
82503 );
82504
82505 --
82506 -- set rounding class
82507 --
82508 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
82509 'INTERORG_PAYABLES';
82510
82511 --
82512 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
82513 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
82514 --
82515 -- bulk performance
82516 --
82517 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
82518
82519 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
82520 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
82521
82522 -- 4955764
82523 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
82524 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
82525
82526 -- 4458381 Public Sector Enh
82527
82528 --
82529 -- set accounting attributes for the line type
82530 --
82531 l_entered_amt_idx := 3;
82532 l_accted_amt_idx := 8;
82533 l_bflow_applied_to_amt_idx := NULL; -- 5132302
82534 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
82535 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
82536 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
82537 l_rec_acct_attrs.array_char_value(2) := p_source_85;
82538 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
82539 l_rec_acct_attrs.array_num_value(3) := p_source_91;
82540 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
82541 l_rec_acct_attrs.array_char_value(4) := p_source_88;
82542 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
82543 l_rec_acct_attrs.array_date_value(5) := p_source_92;
82544 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
82545 l_rec_acct_attrs.array_num_value(6) := p_source_93;
82546 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
82547 l_rec_acct_attrs.array_char_value(7) := p_source_94;
82548 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
82549 l_rec_acct_attrs.array_num_value(8) := p_source_95;
82550
82551 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
82552 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
82553
82554 ---------------------------------------------------------------------------------------------------------------
82555 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
82556 ---------------------------------------------------------------------------------------------------------------
82557 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
82558
82559 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
82560 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
82561
82562 IF xla_accounting_cache_pkg.GetValueChar
82563 (p_source_code => 'LEDGER_CATEGORY_CODE'
82564 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
82565 AND l_bflow_method_code = 'PRIOR_ENTRY'
82566 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
82567 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
82568 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
82569 )
82570 THEN
82571 xla_ae_lines_pkg.BflowUpgEntry
82572 (p_business_method_code => l_bflow_method_code
82573 ,p_business_class_code => l_bflow_class_code
82574 ,p_balance_type => l_balance_type_code);
82575 ELSE
82576 NULL;
82577 -- No business flow processing for business flow method of NONE.
82578 END IF;
82579
82580 --
82581 -- call analytical criteria
82582 --
82583
82584 --
82585 -- call description
82586 --
82587
82588 xla_ae_lines_pkg.SetLineDescription(
82589 p_ae_header_id => l_ae_header_id
82590 ,p_description => Description_1 (
82591 p_application_id => p_application_id
82592 , p_ae_header_id => l_ae_header_id
82593 , p_source_1 => p_source_1
82594 , p_source_2 => p_source_2
82595 , p_source_3 => p_source_3
82596 , p_source_4 => p_source_4
82597 , p_source_5 => p_source_5
82598 )
82599 );
82600
82601
82602 --
82603 -- call ADRs
82604 -- Bug 4922099
82605 --
82606 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
82607 (NVL(l_actual_upg_option, 'N') = 'O') OR
82608 (NVL(l_enc_upg_option, 'N') = 'O')
82609 )
82610 THEN
82611 NULL;
82612 --
82613 --
82614
82615 l_ccid := AcctDerRule_20(
82616 p_application_id => p_application_id
82617 , p_ae_header_id => l_ae_header_id
82618 , p_source_35 => p_source_35
82619 , x_transaction_coa_id => l_adr_transaction_coa_id
82620 , x_accounting_coa_id => l_adr_accounting_coa_id
82621 , x_value_type_code => l_adr_value_type_code
82622 , p_side => 'NA'
82623 );
82624
82625 xla_ae_lines_pkg.set_ccid(
82626 p_code_combination_id => l_ccid
82627 , p_value_type_code => l_adr_value_type_code
82628 , p_transaction_coa_id => l_adr_transaction_coa_id
82629 , p_accounting_coa_id => l_adr_accounting_coa_id
82630 , p_adr_code => 'PI_INTERORG_PAYABLES'
82631 , p_adr_type_code => 'S'
82632 , p_component_type => l_component_type
82633 , p_component_code => l_component_code
82634 , p_component_type_code => l_component_type_code
82635 , p_component_appl_id => l_component_appl_id
82636 , p_amb_context_code => l_amb_context_code
82637 , p_side => 'NA'
82638 );
82639
82640
82641 --
82642 --
82643 END IF;
82644 --
82645 -- Bug 4922099
82646 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
82647 (NVL(l_enc_upg_option, 'N') = 'O')
82648 ) AND
82649 (l_bflow_method_code = 'PRIOR_ENTRY')
82650 )
82651 THEN
82652 IF
82653 --
82654 1 = 2
82655 --
82656 THEN
82657 xla_accounting_err_pkg.build_message
82658 (p_appli_s_name => 'XLA'
82659 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
82660 ,p_token_1 => 'LINE_NUMBER'
82661 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
82662 ,p_token_2 => 'LINE_TYPE_NAME'
82663 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
82664 l_component_type
82665 ,l_component_code
82666 ,l_component_type_code
82667 ,l_component_appl_id
82668 ,l_amb_context_code
82669 ,l_entity_code
82670 ,l_event_class_code
82671 )
82672 ,p_token_3 => 'OWNER'
82673 ,p_value_3 => xla_lookups_pkg.get_meaning(
82674 p_lookup_type => 'XLA_OWNER_TYPE'
82675 ,p_lookup_code => l_component_type_code
82676 )
82677 ,p_token_4 => 'PRODUCT_NAME'
82678 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
82679 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
82680 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
82681 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
82682 ,p_ae_header_id => NULL
82683 );
82684
82685 IF (C_LEVEL_ERROR>= g_log_level) THEN
82686 trace
82687 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
82688 ,p_level => C_LEVEL_ERROR
82689 ,p_module => l_log_module);
82690 END IF;
82691 END IF;
82692 END IF;
82693 --
82694 --
82695 ------------------------------------------------------------------------------------------------
82696 -- 4219869 Business Flow
82697 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
82698 -- Prior Entry. Currently, the following code is always generated.
82699 ------------------------------------------------------------------------------------------------
82700 XLA_AE_LINES_PKG.ValidateCurrentLine;
82701
82702 ------------------------------------------------------------------------------------
82703 -- 4219869 Business Flow
82704 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
82705 ------------------------------------------------------------------------------------
82706 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
82707
82708 ----------------------------------------------------------------------------------
82709 -- 4219869 Business Flow
82710 -- Update journal entry status -- Need to generate this within IF <condition>
82711 ----------------------------------------------------------------------------------
82712 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
82713 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
82714 ,p_balance_type_code => l_balance_type_code
82715 );
82716
82717 -------------------------------------------------------------------------------------------
82718 -- 4262811 - Generate the Accrual Reversal lines
82719 -------------------------------------------------------------------------------------------
82720 BEGIN
82721 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
82722 (g_array_event(p_event_id).array_value_num('header_index'));
82723 IF l_acc_rev_flag IS NULL THEN
82724 l_acc_rev_flag := 'N';
82725 END IF;
82726 EXCEPTION
82727 WHEN OTHERS THEN
82728 l_acc_rev_flag := 'N';
82729 END;
82730 --
82731 IF (l_acc_rev_flag = 'Y') THEN
82732
82733 -- 4645092 ------------------------------------------------------------------------------
82734 -- To allow MPA report to determine if it should generate report process
82735 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
82736 ------------------------------------------------------------------------------------------
82737
82738 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
82739 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
82740 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
82741 -- call ADRs
82742 -- Bug 4922099
82743 --
82744 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
82745 (NVL(l_actual_upg_option, 'N') = 'O') OR
82746 (NVL(l_enc_upg_option, 'N') = 'O')
82747 )
82748 THEN
82749 NULL;
82750 --
82751 --
82752
82753 l_ccid := AcctDerRule_20(
82754 p_application_id => p_application_id
82755 , p_ae_header_id => l_ae_header_id
82756 , p_source_35 => p_source_35
82757 , x_transaction_coa_id => l_adr_transaction_coa_id
82758 , x_accounting_coa_id => l_adr_accounting_coa_id
82759 , x_value_type_code => l_adr_value_type_code
82760 , p_side => 'NA'
82761 );
82762
82763 xla_ae_lines_pkg.set_ccid(
82764 p_code_combination_id => l_ccid
82765 , p_value_type_code => l_adr_value_type_code
82766 , p_transaction_coa_id => l_adr_transaction_coa_id
82767 , p_accounting_coa_id => l_adr_accounting_coa_id
82768 , p_adr_code => 'PI_INTERORG_PAYABLES'
82769 , p_adr_type_code => 'S'
82770 , p_component_type => l_component_type
82771 , p_component_code => l_component_code
82772 , p_component_type_code => l_component_type_code
82773 , p_component_appl_id => l_component_appl_id
82774 , p_amb_context_code => l_amb_context_code
82775 , p_side => 'NA'
82776 );
82777
82778
82779 --
82780 --
82781 END IF;
82782
82783 --
82784 -- Update the line information that should be overwritten
82785 --
82786 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
82787 p_header_num => 1);
82788 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
82789
82790 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
82791
82792 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
82793 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
82794 END IF;
82795
82796 --
82797 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
82798 --
82799 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
82800 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
82801 ELSE
82802 ---------------------------------------------------------------------------------------------------
82803 -- 4262811a Switch Sign
82804 ---------------------------------------------------------------------------------------------------
82805 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
82806 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
82807 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82808 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
82809 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82810 -- 5132302
82811 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
82812 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
82813
82814 END IF;
82815
82816 -- 4955764
82817 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
82818 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
82819
82820
82821 XLA_AE_LINES_PKG.ValidateCurrentLine;
82822 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
82823
82824 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
82825 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
82826 ,p_balance_type_code => l_balance_type_code);
82827
82828 END IF;
82829
82830 -----------------------------------------------------------------------------------------
82831 -- 4262811 Multiperiod Accounting
82832 -----------------------------------------------------------------------------------------
82833 -- No MPA option is assigned.
82834
82835
82836 END IF;
82837 END IF;
82838 --
82839
82840 --
82841 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82842 trace
82843 (p_msg => 'END of AcctLineType_169'
82844 ,p_level => C_LEVEL_PROCEDURE
82845 ,p_module => l_log_module);
82846 END IF;
82847 --
82848 EXCEPTION
82849 WHEN xla_exceptions_pkg.application_exception THEN
82850 RAISE;
82851 WHEN OTHERS THEN
82852 xla_exceptions_pkg.raise_message
82853 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_169');
82854 END AcctLineType_169;
82855 --
82856
82857 ---------------------------------------
82858 --
82859 -- PRIVATE FUNCTION
82860 -- AcctLineType_170
82861 --
82862 ---------------------------------------
82863 PROCEDURE AcctLineType_170 (
82864 p_application_id IN NUMBER
82865 ,p_event_id IN NUMBER
82866 ,p_calculate_acctd_flag IN VARCHAR2
82867 ,p_calculate_g_l_flag IN VARCHAR2
82868 ,p_actual_flag IN OUT VARCHAR2
82869 ,p_balance_type_code OUT VARCHAR2
82870 ,p_gain_or_loss_ref OUT VARCHAR2
82871
82872 --TRANSACTION_ID
82873 , p_source_1 IN NUMBER
82874 --Item Concatenated Segments
82875 , p_source_2 IN VARCHAR2
82876 --Transaction Quantity
82877 , p_source_3 IN NUMBER
82878 --Transaction Unit of Measure Code
82879 , p_source_4 IN VARCHAR2
82880 --Inventory Transaction Type Description
82881 , p_source_5 IN VARCHAR2
82882 --Interorg Payables Account
82883 , p_source_35 IN NUMBER
82884 --DISTRIBUTION_IDENTIFIER
82885 , p_source_84 IN NUMBER
82886 --Distribution Type
82887 , p_source_85 IN VARCHAR2
82888 , p_source_85_meaning IN VARCHAR2
82889 --Entered Currency Code
82890 , p_source_88 IN VARCHAR2
82891 --Entered Amount
82892 , p_source_91 IN NUMBER
82893 --Currency Conversion Date
82894 , p_source_92 IN DATE
82895 --Currency Conversion Rate
82896 , p_source_93 IN NUMBER
82897 --Currency Conversion Type
82898 , p_source_94 IN VARCHAR2
82899 --Accounted Amount
82900 , p_source_95 IN NUMBER
82901 --Accounting Line Type
82902 , p_source_97 IN NUMBER
82903 )
82904 IS
82905
82906 l_component_type VARCHAR2(80);
82907 l_component_code VARCHAR2(30);
82908 l_component_type_code VARCHAR2(1);
82909 l_component_appl_id INTEGER;
82910 l_amb_context_code VARCHAR2(30);
82911 l_entity_code VARCHAR2(30);
82912 l_event_class_code VARCHAR2(30);
82913 l_ae_header_id NUMBER;
82914 l_event_type_code VARCHAR2(30);
82915 l_line_definition_code VARCHAR2(30);
82916 l_line_definition_owner_code VARCHAR2(1);
82917 --
82918 -- adr variables
82919 l_segment VARCHAR2(30);
82920 l_ccid NUMBER;
82921 l_adr_transaction_coa_id NUMBER;
82922 l_adr_accounting_coa_id NUMBER;
82923 l_adr_flexfield_segment_code VARCHAR2(30);
82924 l_adr_flex_value_set_id NUMBER;
82925 l_adr_value_type_code VARCHAR2(30);
82926 l_adr_value_combination_id NUMBER;
82927 l_adr_value_segment_code VARCHAR2(30);
82928
82929 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
82930 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
82931 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
82932 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
82933
82934 -- 4262811 Variables ------------------------------------------------------------------------------------------
82935 l_entered_amt_idx NUMBER;
82936 l_accted_amt_idx NUMBER;
82937 l_acc_rev_flag VARCHAR2(1);
82938 l_accrual_line_num NUMBER;
82939 l_tmp_amt NUMBER;
82940 l_acc_rev_natural_side_code VARCHAR2(1);
82941
82942 l_num_entries NUMBER;
82943 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
82944 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
82945 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
82946 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
82947 l_recog_line_1 NUMBER;
82948 l_recog_line_2 NUMBER;
82949
82950 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
82951 l_bflow_applied_to_amt NUMBER; -- 5132302
82952 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
82953
82954 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
82955
82956 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
82957 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
82958
82959 ---------------------------------------------------------------------------------------------------------------
82960
82961
82962 --
82963 -- bulk performance
82964 --
82965 l_balance_type_code VARCHAR2(1);
82966 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
82967 l_log_module VARCHAR2(240);
82968
82969 --
82970 -- Upgrade strategy
82971 --
82972 l_actual_upg_option VARCHAR2(1);
82973 l_enc_upg_option VARCHAR2(1);
82974
82975 --
82976 BEGIN
82977 --
82978 IF g_log_enabled THEN
82979 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_170';
82980 END IF;
82981 --
82982 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
82983
82984 trace
82985 (p_msg => 'BEGIN of AcctLineType_170'
82986 ,p_level => C_LEVEL_PROCEDURE
82987 ,p_module => l_log_module);
82988
82989 END IF;
82990 --
82991 l_component_type := 'AMB_JLT';
82992 l_component_code := 'INTERORG_PAYABLES';
82993 l_component_type_code := 'S';
82994 l_component_appl_id := 707;
82995 l_amb_context_code := 'DEFAULT';
82996 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
82997 l_event_class_code := 'USER_DEFINE';
82998 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
82999 l_line_definition_owner_code := 'S';
83000 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
83001 --
83002 l_balance_type_code := 'A';
83003 l_segment := NULL;
83004 l_ccid := NULL;
83005 l_adr_transaction_coa_id := NULL;
83006 l_adr_accounting_coa_id := NULL;
83007 l_adr_flexfield_segment_code := NULL;
83008 l_adr_flex_value_set_id := NULL;
83009 l_adr_value_type_code := NULL;
83010 l_adr_value_combination_id := NULL;
83011 l_adr_value_segment_code := NULL;
83012
83013 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
83014 l_bflow_class_code := ''; -- 4219869 Business Flow
83015 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
83016 l_budgetary_control_flag := 'N';
83017
83018 l_bflow_applied_to_amt_idx := NULL; -- 5132302
83019 l_bflow_applied_to_amt := NULL; -- 5132302
83020 l_entered_amt_idx := NULL; -- 4262811
83021 l_accted_amt_idx := NULL; -- 4262811
83022 l_acc_rev_flag := NULL; -- 4262811
83023 l_accrual_line_num := NULL; -- 4262811
83024 l_tmp_amt := NULL; -- 4262811
83025 --
83026
83027 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
83028 l_balance_type_code <> 'B' THEN
83029 IF NVL(p_source_97,9E125) = 9
83030 THEN
83031
83032 --
83033 XLA_AE_LINES_PKG.SetNewLine;
83034
83035 p_balance_type_code := l_balance_type_code;
83036 -- set the flag so later we will know whether the gain loss line needs to be created
83037
83038 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
83039 p_actual_flag :='A';
83040 END IF;
83041
83042 --
83043 -- bulk performance
83044 --
83045 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
83046 p_header_num => 0); -- 4262811
83047 --
83048 -- set accounting line options
83049 --
83050 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
83051 p_natural_side_code => 'D'
83052 , p_gain_or_loss_flag => 'N'
83053 , p_gl_transfer_mode_code => 'S'
83054 , p_acct_entry_type_code => 'A'
83055 , p_switch_side_flag => 'Y'
83056 , p_merge_duplicate_code => 'N'
83057 );
83058 --
83059 l_acc_rev_natural_side_code := 'C'; -- 4262811
83060 --
83061 --
83062 -- set accounting line type info
83063 --
83064 xla_ae_lines_pkg.SetAcctLineType
83065 (p_component_type => l_component_type
83066 ,p_event_type_code => l_event_type_code
83067 ,p_line_definition_owner_code => l_line_definition_owner_code
83068 ,p_line_definition_code => l_line_definition_code
83069 ,p_accounting_line_code => l_component_code
83070 ,p_accounting_line_type_code => l_component_type_code
83071 ,p_accounting_line_appl_id => l_component_appl_id
83072 ,p_amb_context_code => l_amb_context_code
83073 ,p_entity_code => l_entity_code
83074 ,p_event_class_code => l_event_class_code);
83075 --
83076 -- set accounting class
83077 --
83078 xla_ae_lines_pkg.SetAcctClass(
83079 p_accounting_class_code => 'INTERORG_PAYABLES'
83080 , p_ae_header_id => l_ae_header_id
83081 );
83082
83083 --
83084 -- set rounding class
83085 --
83086 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
83087 'INTERORG_PAYABLES';
83088
83089 --
83090 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
83091 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
83092 --
83093 -- bulk performance
83094 --
83095 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
83096
83097 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
83098 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
83099
83100 -- 4955764
83101 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
83102 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
83103
83104 -- 4458381 Public Sector Enh
83105
83106 --
83107 -- set accounting attributes for the line type
83108 --
83109 l_entered_amt_idx := 3;
83110 l_accted_amt_idx := 8;
83111 l_bflow_applied_to_amt_idx := NULL; -- 5132302
83112 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
83113 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
83114 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
83115 l_rec_acct_attrs.array_char_value(2) := p_source_85;
83116 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
83117 l_rec_acct_attrs.array_num_value(3) := p_source_91;
83118 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
83119 l_rec_acct_attrs.array_char_value(4) := p_source_88;
83120 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
83121 l_rec_acct_attrs.array_date_value(5) := p_source_92;
83122 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
83123 l_rec_acct_attrs.array_num_value(6) := p_source_93;
83124 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
83125 l_rec_acct_attrs.array_char_value(7) := p_source_94;
83126 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
83127 l_rec_acct_attrs.array_num_value(8) := p_source_95;
83128
83129 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
83130 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
83131
83132 ---------------------------------------------------------------------------------------------------------------
83133 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
83134 ---------------------------------------------------------------------------------------------------------------
83135 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
83136
83137 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
83138 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
83139
83140 IF xla_accounting_cache_pkg.GetValueChar
83141 (p_source_code => 'LEDGER_CATEGORY_CODE'
83142 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
83143 AND l_bflow_method_code = 'PRIOR_ENTRY'
83144 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
83145 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
83146 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
83147 )
83148 THEN
83149 xla_ae_lines_pkg.BflowUpgEntry
83150 (p_business_method_code => l_bflow_method_code
83151 ,p_business_class_code => l_bflow_class_code
83152 ,p_balance_type => l_balance_type_code);
83153 ELSE
83154 NULL;
83155 -- No business flow processing for business flow method of NONE.
83156 END IF;
83157
83158 --
83159 -- call analytical criteria
83160 --
83161
83162 --
83163 -- call description
83164 --
83165
83166 xla_ae_lines_pkg.SetLineDescription(
83167 p_ae_header_id => l_ae_header_id
83168 ,p_description => Description_1 (
83169 p_application_id => p_application_id
83170 , p_ae_header_id => l_ae_header_id
83171 , p_source_1 => p_source_1
83172 , p_source_2 => p_source_2
83173 , p_source_3 => p_source_3
83174 , p_source_4 => p_source_4
83175 , p_source_5 => p_source_5
83176 )
83177 );
83178
83179
83180 --
83181 -- call ADRs
83182 -- Bug 4922099
83183 --
83184 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
83185 (NVL(l_actual_upg_option, 'N') = 'O') OR
83186 (NVL(l_enc_upg_option, 'N') = 'O')
83187 )
83188 THEN
83189 NULL;
83190 --
83191 --
83192
83193 l_ccid := AcctDerRule_20(
83194 p_application_id => p_application_id
83195 , p_ae_header_id => l_ae_header_id
83196 , p_source_35 => p_source_35
83197 , x_transaction_coa_id => l_adr_transaction_coa_id
83198 , x_accounting_coa_id => l_adr_accounting_coa_id
83199 , x_value_type_code => l_adr_value_type_code
83200 , p_side => 'NA'
83201 );
83202
83203 xla_ae_lines_pkg.set_ccid(
83204 p_code_combination_id => l_ccid
83205 , p_value_type_code => l_adr_value_type_code
83206 , p_transaction_coa_id => l_adr_transaction_coa_id
83207 , p_accounting_coa_id => l_adr_accounting_coa_id
83208 , p_adr_code => 'PI_INTERORG_PAYABLES'
83209 , p_adr_type_code => 'S'
83210 , p_component_type => l_component_type
83211 , p_component_code => l_component_code
83212 , p_component_type_code => l_component_type_code
83213 , p_component_appl_id => l_component_appl_id
83214 , p_amb_context_code => l_amb_context_code
83215 , p_side => 'NA'
83216 );
83217
83218
83219 --
83220 --
83221 END IF;
83222 --
83223 -- Bug 4922099
83224 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
83225 (NVL(l_enc_upg_option, 'N') = 'O')
83226 ) AND
83227 (l_bflow_method_code = 'PRIOR_ENTRY')
83228 )
83229 THEN
83230 IF
83231 --
83232 1 = 2
83233 --
83234 THEN
83235 xla_accounting_err_pkg.build_message
83236 (p_appli_s_name => 'XLA'
83237 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
83238 ,p_token_1 => 'LINE_NUMBER'
83239 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
83240 ,p_token_2 => 'LINE_TYPE_NAME'
83241 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
83242 l_component_type
83243 ,l_component_code
83244 ,l_component_type_code
83245 ,l_component_appl_id
83246 ,l_amb_context_code
83247 ,l_entity_code
83248 ,l_event_class_code
83249 )
83250 ,p_token_3 => 'OWNER'
83251 ,p_value_3 => xla_lookups_pkg.get_meaning(
83252 p_lookup_type => 'XLA_OWNER_TYPE'
83253 ,p_lookup_code => l_component_type_code
83254 )
83255 ,p_token_4 => 'PRODUCT_NAME'
83256 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
83257 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
83258 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
83259 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
83260 ,p_ae_header_id => NULL
83261 );
83262
83263 IF (C_LEVEL_ERROR>= g_log_level) THEN
83264 trace
83265 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
83266 ,p_level => C_LEVEL_ERROR
83267 ,p_module => l_log_module);
83268 END IF;
83269 END IF;
83270 END IF;
83271 --
83272 --
83273 ------------------------------------------------------------------------------------------------
83274 -- 4219869 Business Flow
83275 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
83276 -- Prior Entry. Currently, the following code is always generated.
83277 ------------------------------------------------------------------------------------------------
83278 XLA_AE_LINES_PKG.ValidateCurrentLine;
83279
83280 ------------------------------------------------------------------------------------
83281 -- 4219869 Business Flow
83282 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
83283 ------------------------------------------------------------------------------------
83284 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
83285
83286 ----------------------------------------------------------------------------------
83287 -- 4219869 Business Flow
83288 -- Update journal entry status -- Need to generate this within IF <condition>
83289 ----------------------------------------------------------------------------------
83290 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
83291 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
83292 ,p_balance_type_code => l_balance_type_code
83293 );
83294
83295 -------------------------------------------------------------------------------------------
83296 -- 4262811 - Generate the Accrual Reversal lines
83297 -------------------------------------------------------------------------------------------
83298 BEGIN
83299 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
83300 (g_array_event(p_event_id).array_value_num('header_index'));
83301 IF l_acc_rev_flag IS NULL THEN
83302 l_acc_rev_flag := 'N';
83303 END IF;
83304 EXCEPTION
83305 WHEN OTHERS THEN
83306 l_acc_rev_flag := 'N';
83307 END;
83308 --
83309 IF (l_acc_rev_flag = 'Y') THEN
83310
83311 -- 4645092 ------------------------------------------------------------------------------
83312 -- To allow MPA report to determine if it should generate report process
83313 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
83314 ------------------------------------------------------------------------------------------
83315
83316 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
83317 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
83318 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
83319 -- call ADRs
83320 -- Bug 4922099
83321 --
83322 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
83323 (NVL(l_actual_upg_option, 'N') = 'O') OR
83324 (NVL(l_enc_upg_option, 'N') = 'O')
83325 )
83326 THEN
83327 NULL;
83328 --
83329 --
83330
83331 l_ccid := AcctDerRule_20(
83332 p_application_id => p_application_id
83333 , p_ae_header_id => l_ae_header_id
83334 , p_source_35 => p_source_35
83335 , x_transaction_coa_id => l_adr_transaction_coa_id
83336 , x_accounting_coa_id => l_adr_accounting_coa_id
83337 , x_value_type_code => l_adr_value_type_code
83338 , p_side => 'NA'
83339 );
83340
83341 xla_ae_lines_pkg.set_ccid(
83342 p_code_combination_id => l_ccid
83343 , p_value_type_code => l_adr_value_type_code
83344 , p_transaction_coa_id => l_adr_transaction_coa_id
83345 , p_accounting_coa_id => l_adr_accounting_coa_id
83346 , p_adr_code => 'PI_INTERORG_PAYABLES'
83347 , p_adr_type_code => 'S'
83348 , p_component_type => l_component_type
83349 , p_component_code => l_component_code
83350 , p_component_type_code => l_component_type_code
83351 , p_component_appl_id => l_component_appl_id
83352 , p_amb_context_code => l_amb_context_code
83353 , p_side => 'NA'
83354 );
83355
83356
83357 --
83358 --
83359 END IF;
83360
83361 --
83362 -- Update the line information that should be overwritten
83363 --
83364 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
83365 p_header_num => 1);
83366 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
83367
83368 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
83369
83370 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
83371 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
83372 END IF;
83373
83374 --
83375 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
83376 --
83377 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
83378 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
83379 ELSE
83380 ---------------------------------------------------------------------------------------------------
83381 -- 4262811a Switch Sign
83382 ---------------------------------------------------------------------------------------------------
83383 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
83384 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
83385 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83386 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
83387 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83388 -- 5132302
83389 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
83390 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83391
83392 END IF;
83393
83394 -- 4955764
83395 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
83396 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
83397
83398
83399 XLA_AE_LINES_PKG.ValidateCurrentLine;
83400 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
83401
83402 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
83403 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
83404 ,p_balance_type_code => l_balance_type_code);
83405
83406 END IF;
83407
83408 -----------------------------------------------------------------------------------------
83409 -- 4262811 Multiperiod Accounting
83410 -----------------------------------------------------------------------------------------
83411 -- No MPA option is assigned.
83412
83413
83414 END IF;
83415 END IF;
83416 --
83417
83418 --
83419 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83420 trace
83421 (p_msg => 'END of AcctLineType_170'
83422 ,p_level => C_LEVEL_PROCEDURE
83423 ,p_module => l_log_module);
83424 END IF;
83425 --
83426 EXCEPTION
83427 WHEN xla_exceptions_pkg.application_exception THEN
83428 RAISE;
83429 WHEN OTHERS THEN
83430 xla_exceptions_pkg.raise_message
83431 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_170');
83432 END AcctLineType_170;
83433 --
83434
83435 ---------------------------------------
83436 --
83437 -- PRIVATE FUNCTION
83438 -- AcctLineType_171
83439 --
83440 ---------------------------------------
83441 PROCEDURE AcctLineType_171 (
83442 p_application_id IN NUMBER
83443 ,p_event_id IN NUMBER
83444 ,p_calculate_acctd_flag IN VARCHAR2
83445 ,p_calculate_g_l_flag IN VARCHAR2
83446 ,p_actual_flag IN OUT VARCHAR2
83447 ,p_balance_type_code OUT VARCHAR2
83448 ,p_gain_or_loss_ref OUT VARCHAR2
83449
83450 --TRANSACTION_ID
83451 , p_source_1 IN NUMBER
83452 --Item Concatenated Segments
83453 , p_source_2 IN VARCHAR2
83454 --Transaction Quantity
83455 , p_source_3 IN NUMBER
83456 --Transaction Unit of Measure Code
83457 , p_source_4 IN VARCHAR2
83458 --Inventory Transaction Type Description
83459 , p_source_5 IN VARCHAR2
83460 --Cost Management Default Account
83461 , p_source_11 IN NUMBER
83462 --DISTRIBUTION_IDENTIFIER
83463 , p_source_84 IN NUMBER
83464 --Distribution Type
83465 , p_source_85 IN VARCHAR2
83466 , p_source_85_meaning IN VARCHAR2
83467 --Entered Currency Code
83468 , p_source_88 IN VARCHAR2
83469 --Entered Amount
83470 , p_source_91 IN NUMBER
83471 --Currency Conversion Date
83472 , p_source_92 IN DATE
83473 --Currency Conversion Rate
83474 , p_source_93 IN NUMBER
83475 --Currency Conversion Type
83476 , p_source_94 IN VARCHAR2
83477 --Accounted Amount
83478 , p_source_95 IN NUMBER
83479 --Accounting Line Type
83480 , p_source_97 IN NUMBER
83481 )
83482 IS
83483
83484 l_component_type VARCHAR2(80);
83485 l_component_code VARCHAR2(30);
83486 l_component_type_code VARCHAR2(1);
83487 l_component_appl_id INTEGER;
83488 l_amb_context_code VARCHAR2(30);
83489 l_entity_code VARCHAR2(30);
83490 l_event_class_code VARCHAR2(30);
83491 l_ae_header_id NUMBER;
83492 l_event_type_code VARCHAR2(30);
83493 l_line_definition_code VARCHAR2(30);
83494 l_line_definition_owner_code VARCHAR2(1);
83495 --
83496 -- adr variables
83497 l_segment VARCHAR2(30);
83498 l_ccid NUMBER;
83499 l_adr_transaction_coa_id NUMBER;
83500 l_adr_accounting_coa_id NUMBER;
83501 l_adr_flexfield_segment_code VARCHAR2(30);
83502 l_adr_flex_value_set_id NUMBER;
83503 l_adr_value_type_code VARCHAR2(30);
83504 l_adr_value_combination_id NUMBER;
83505 l_adr_value_segment_code VARCHAR2(30);
83506
83507 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
83508 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
83509 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
83510 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
83511
83512 -- 4262811 Variables ------------------------------------------------------------------------------------------
83513 l_entered_amt_idx NUMBER;
83514 l_accted_amt_idx NUMBER;
83515 l_acc_rev_flag VARCHAR2(1);
83516 l_accrual_line_num NUMBER;
83517 l_tmp_amt NUMBER;
83518 l_acc_rev_natural_side_code VARCHAR2(1);
83519
83520 l_num_entries NUMBER;
83521 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
83522 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
83523 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
83524 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
83525 l_recog_line_1 NUMBER;
83526 l_recog_line_2 NUMBER;
83527
83528 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
83529 l_bflow_applied_to_amt NUMBER; -- 5132302
83530 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
83531
83532 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
83533
83534 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
83535 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
83536
83537 ---------------------------------------------------------------------------------------------------------------
83538
83539
83540 --
83541 -- bulk performance
83542 --
83543 l_balance_type_code VARCHAR2(1);
83544 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
83545 l_log_module VARCHAR2(240);
83546
83547 --
83548 -- Upgrade strategy
83549 --
83550 l_actual_upg_option VARCHAR2(1);
83551 l_enc_upg_option VARCHAR2(1);
83552
83553 --
83554 BEGIN
83555 --
83556 IF g_log_enabled THEN
83557 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_171';
83558 END IF;
83559 --
83560 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83561
83562 trace
83563 (p_msg => 'BEGIN of AcctLineType_171'
83564 ,p_level => C_LEVEL_PROCEDURE
83565 ,p_module => l_log_module);
83566
83567 END IF;
83568 --
83569 l_component_type := 'AMB_JLT';
83570 l_component_code := 'INTERORG_PAYABLES';
83571 l_component_type_code := 'S';
83572 l_component_appl_id := 707;
83573 l_amb_context_code := 'DEFAULT';
83574 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
83575 l_event_class_code := 'USER_DEFINE';
83576 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
83577 l_line_definition_owner_code := 'S';
83578 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
83579 --
83580 l_balance_type_code := 'A';
83581 l_segment := NULL;
83582 l_ccid := NULL;
83583 l_adr_transaction_coa_id := NULL;
83584 l_adr_accounting_coa_id := NULL;
83585 l_adr_flexfield_segment_code := NULL;
83586 l_adr_flex_value_set_id := NULL;
83587 l_adr_value_type_code := NULL;
83588 l_adr_value_combination_id := NULL;
83589 l_adr_value_segment_code := NULL;
83590
83591 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
83592 l_bflow_class_code := ''; -- 4219869 Business Flow
83593 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
83594 l_budgetary_control_flag := 'N';
83595
83596 l_bflow_applied_to_amt_idx := NULL; -- 5132302
83597 l_bflow_applied_to_amt := NULL; -- 5132302
83598 l_entered_amt_idx := NULL; -- 4262811
83599 l_accted_amt_idx := NULL; -- 4262811
83600 l_acc_rev_flag := NULL; -- 4262811
83601 l_accrual_line_num := NULL; -- 4262811
83602 l_tmp_amt := NULL; -- 4262811
83603 --
83604
83605 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
83606 l_balance_type_code <> 'B' THEN
83607 IF NVL(p_source_97,9E125) = 9
83608 THEN
83609
83610 --
83611 XLA_AE_LINES_PKG.SetNewLine;
83612
83613 p_balance_type_code := l_balance_type_code;
83614 -- set the flag so later we will know whether the gain loss line needs to be created
83615
83616 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
83617 p_actual_flag :='A';
83618 END IF;
83619
83620 --
83621 -- bulk performance
83622 --
83623 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
83624 p_header_num => 0); -- 4262811
83625 --
83626 -- set accounting line options
83627 --
83628 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
83629 p_natural_side_code => 'D'
83630 , p_gain_or_loss_flag => 'N'
83631 , p_gl_transfer_mode_code => 'S'
83632 , p_acct_entry_type_code => 'A'
83633 , p_switch_side_flag => 'Y'
83634 , p_merge_duplicate_code => 'N'
83635 );
83636 --
83637 l_acc_rev_natural_side_code := 'C'; -- 4262811
83638 --
83639 --
83640 -- set accounting line type info
83641 --
83642 xla_ae_lines_pkg.SetAcctLineType
83643 (p_component_type => l_component_type
83644 ,p_event_type_code => l_event_type_code
83645 ,p_line_definition_owner_code => l_line_definition_owner_code
83646 ,p_line_definition_code => l_line_definition_code
83647 ,p_accounting_line_code => l_component_code
83648 ,p_accounting_line_type_code => l_component_type_code
83649 ,p_accounting_line_appl_id => l_component_appl_id
83650 ,p_amb_context_code => l_amb_context_code
83651 ,p_entity_code => l_entity_code
83652 ,p_event_class_code => l_event_class_code);
83653 --
83654 -- set accounting class
83655 --
83656 xla_ae_lines_pkg.SetAcctClass(
83657 p_accounting_class_code => 'INTERORG_PAYABLES'
83658 , p_ae_header_id => l_ae_header_id
83659 );
83660
83661 --
83662 -- set rounding class
83663 --
83664 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
83665 'INTERORG_PAYABLES';
83666
83667 --
83668 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
83669 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
83670 --
83671 -- bulk performance
83672 --
83673 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
83674
83675 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
83676 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
83677
83678 -- 4955764
83679 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
83680 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
83681
83682 -- 4458381 Public Sector Enh
83683
83684 --
83685 -- set accounting attributes for the line type
83686 --
83687 l_entered_amt_idx := 3;
83688 l_accted_amt_idx := 8;
83689 l_bflow_applied_to_amt_idx := NULL; -- 5132302
83690 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
83691 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
83692 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
83693 l_rec_acct_attrs.array_char_value(2) := p_source_85;
83694 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
83695 l_rec_acct_attrs.array_num_value(3) := p_source_91;
83696 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
83697 l_rec_acct_attrs.array_char_value(4) := p_source_88;
83698 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
83699 l_rec_acct_attrs.array_date_value(5) := p_source_92;
83700 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
83701 l_rec_acct_attrs.array_num_value(6) := p_source_93;
83702 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
83703 l_rec_acct_attrs.array_char_value(7) := p_source_94;
83704 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
83705 l_rec_acct_attrs.array_num_value(8) := p_source_95;
83706
83707 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
83708 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
83709
83710 ---------------------------------------------------------------------------------------------------------------
83711 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
83712 ---------------------------------------------------------------------------------------------------------------
83713 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
83714
83715 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
83716 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
83717
83718 IF xla_accounting_cache_pkg.GetValueChar
83719 (p_source_code => 'LEDGER_CATEGORY_CODE'
83720 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
83721 AND l_bflow_method_code = 'PRIOR_ENTRY'
83722 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
83723 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
83724 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
83725 )
83726 THEN
83727 xla_ae_lines_pkg.BflowUpgEntry
83728 (p_business_method_code => l_bflow_method_code
83729 ,p_business_class_code => l_bflow_class_code
83730 ,p_balance_type => l_balance_type_code);
83731 ELSE
83732 NULL;
83733 -- No business flow processing for business flow method of NONE.
83734 END IF;
83735
83736 --
83737 -- call analytical criteria
83738 --
83739
83740 --
83741 -- call description
83742 --
83743
83744 xla_ae_lines_pkg.SetLineDescription(
83745 p_ae_header_id => l_ae_header_id
83746 ,p_description => Description_1 (
83747 p_application_id => p_application_id
83748 , p_ae_header_id => l_ae_header_id
83749 , p_source_1 => p_source_1
83750 , p_source_2 => p_source_2
83751 , p_source_3 => p_source_3
83752 , p_source_4 => p_source_4
83753 , p_source_5 => p_source_5
83754 )
83755 );
83756
83757
83758 --
83759 -- call ADRs
83760 -- Bug 4922099
83761 --
83762 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
83763 (NVL(l_actual_upg_option, 'N') = 'O') OR
83764 (NVL(l_enc_upg_option, 'N') = 'O')
83765 )
83766 THEN
83767 NULL;
83768 --
83769 --
83770
83771 l_ccid := AcctDerRule_6(
83772 p_application_id => p_application_id
83773 , p_ae_header_id => l_ae_header_id
83774 , p_source_11 => p_source_11
83775 , x_transaction_coa_id => l_adr_transaction_coa_id
83776 , x_accounting_coa_id => l_adr_accounting_coa_id
83777 , x_value_type_code => l_adr_value_type_code
83778 , p_side => 'NA'
83779 );
83780
83781 xla_ae_lines_pkg.set_ccid(
83782 p_code_combination_id => l_ccid
83783 , p_value_type_code => l_adr_value_type_code
83784 , p_transaction_coa_id => l_adr_transaction_coa_id
83785 , p_accounting_coa_id => l_adr_accounting_coa_id
83786 , p_adr_code => 'CST_DEFAULT'
83787 , p_adr_type_code => 'S'
83788 , p_component_type => l_component_type
83789 , p_component_code => l_component_code
83790 , p_component_type_code => l_component_type_code
83791 , p_component_appl_id => l_component_appl_id
83792 , p_amb_context_code => l_amb_context_code
83793 , p_side => 'NA'
83794 );
83795
83796
83797 --
83798 --
83799 END IF;
83800 --
83801 -- Bug 4922099
83802 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
83803 (NVL(l_enc_upg_option, 'N') = 'O')
83804 ) AND
83805 (l_bflow_method_code = 'PRIOR_ENTRY')
83806 )
83807 THEN
83808 IF
83809 --
83810 1 = 2
83811 --
83812 THEN
83813 xla_accounting_err_pkg.build_message
83814 (p_appli_s_name => 'XLA'
83815 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
83816 ,p_token_1 => 'LINE_NUMBER'
83817 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
83818 ,p_token_2 => 'LINE_TYPE_NAME'
83819 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
83820 l_component_type
83821 ,l_component_code
83822 ,l_component_type_code
83823 ,l_component_appl_id
83824 ,l_amb_context_code
83825 ,l_entity_code
83826 ,l_event_class_code
83827 )
83828 ,p_token_3 => 'OWNER'
83829 ,p_value_3 => xla_lookups_pkg.get_meaning(
83830 p_lookup_type => 'XLA_OWNER_TYPE'
83831 ,p_lookup_code => l_component_type_code
83832 )
83833 ,p_token_4 => 'PRODUCT_NAME'
83834 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
83835 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
83836 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
83837 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
83838 ,p_ae_header_id => NULL
83839 );
83840
83841 IF (C_LEVEL_ERROR>= g_log_level) THEN
83842 trace
83843 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
83844 ,p_level => C_LEVEL_ERROR
83845 ,p_module => l_log_module);
83846 END IF;
83847 END IF;
83848 END IF;
83849 --
83850 --
83851 ------------------------------------------------------------------------------------------------
83852 -- 4219869 Business Flow
83853 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
83854 -- Prior Entry. Currently, the following code is always generated.
83855 ------------------------------------------------------------------------------------------------
83856 XLA_AE_LINES_PKG.ValidateCurrentLine;
83857
83858 ------------------------------------------------------------------------------------
83859 -- 4219869 Business Flow
83860 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
83861 ------------------------------------------------------------------------------------
83862 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
83863
83864 ----------------------------------------------------------------------------------
83865 -- 4219869 Business Flow
83866 -- Update journal entry status -- Need to generate this within IF <condition>
83867 ----------------------------------------------------------------------------------
83868 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
83869 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
83870 ,p_balance_type_code => l_balance_type_code
83871 );
83872
83873 -------------------------------------------------------------------------------------------
83874 -- 4262811 - Generate the Accrual Reversal lines
83875 -------------------------------------------------------------------------------------------
83876 BEGIN
83877 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
83878 (g_array_event(p_event_id).array_value_num('header_index'));
83879 IF l_acc_rev_flag IS NULL THEN
83880 l_acc_rev_flag := 'N';
83881 END IF;
83882 EXCEPTION
83883 WHEN OTHERS THEN
83884 l_acc_rev_flag := 'N';
83885 END;
83886 --
83887 IF (l_acc_rev_flag = 'Y') THEN
83888
83889 -- 4645092 ------------------------------------------------------------------------------
83890 -- To allow MPA report to determine if it should generate report process
83891 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
83892 ------------------------------------------------------------------------------------------
83893
83894 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
83895 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
83896 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
83897 -- call ADRs
83898 -- Bug 4922099
83899 --
83900 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
83901 (NVL(l_actual_upg_option, 'N') = 'O') OR
83902 (NVL(l_enc_upg_option, 'N') = 'O')
83903 )
83904 THEN
83905 NULL;
83906 --
83907 --
83908
83909 l_ccid := AcctDerRule_6(
83910 p_application_id => p_application_id
83911 , p_ae_header_id => l_ae_header_id
83912 , p_source_11 => p_source_11
83913 , x_transaction_coa_id => l_adr_transaction_coa_id
83914 , x_accounting_coa_id => l_adr_accounting_coa_id
83915 , x_value_type_code => l_adr_value_type_code
83916 , p_side => 'NA'
83917 );
83918
83919 xla_ae_lines_pkg.set_ccid(
83920 p_code_combination_id => l_ccid
83921 , p_value_type_code => l_adr_value_type_code
83922 , p_transaction_coa_id => l_adr_transaction_coa_id
83923 , p_accounting_coa_id => l_adr_accounting_coa_id
83924 , p_adr_code => 'CST_DEFAULT'
83925 , p_adr_type_code => 'S'
83926 , p_component_type => l_component_type
83927 , p_component_code => l_component_code
83928 , p_component_type_code => l_component_type_code
83929 , p_component_appl_id => l_component_appl_id
83930 , p_amb_context_code => l_amb_context_code
83931 , p_side => 'NA'
83932 );
83933
83934
83935 --
83936 --
83937 END IF;
83938
83939 --
83940 -- Update the line information that should be overwritten
83941 --
83942 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
83943 p_header_num => 1);
83944 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
83945
83946 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
83947
83948 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
83949 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
83950 END IF;
83951
83952 --
83953 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
83954 --
83955 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
83956 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
83957 ELSE
83958 ---------------------------------------------------------------------------------------------------
83959 -- 4262811a Switch Sign
83960 ---------------------------------------------------------------------------------------------------
83961 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
83962 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
83963 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83964 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
83965 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83966 -- 5132302
83967 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
83968 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
83969
83970 END IF;
83971
83972 -- 4955764
83973 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
83974 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
83975
83976
83977 XLA_AE_LINES_PKG.ValidateCurrentLine;
83978 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
83979
83980 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
83981 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
83982 ,p_balance_type_code => l_balance_type_code);
83983
83984 END IF;
83985
83986 -----------------------------------------------------------------------------------------
83987 -- 4262811 Multiperiod Accounting
83988 -----------------------------------------------------------------------------------------
83989 -- No MPA option is assigned.
83990
83991
83992 END IF;
83993 END IF;
83994 --
83995
83996 --
83997 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
83998 trace
83999 (p_msg => 'END of AcctLineType_171'
84000 ,p_level => C_LEVEL_PROCEDURE
84001 ,p_module => l_log_module);
84002 END IF;
84003 --
84004 EXCEPTION
84005 WHEN xla_exceptions_pkg.application_exception THEN
84006 RAISE;
84007 WHEN OTHERS THEN
84008 xla_exceptions_pkg.raise_message
84009 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_171');
84010 END AcctLineType_171;
84011 --
84012
84013 ---------------------------------------
84014 --
84015 -- PRIVATE FUNCTION
84016 -- AcctLineType_172
84017 --
84018 ---------------------------------------
84019 PROCEDURE AcctLineType_172 (
84020 p_application_id IN NUMBER
84021 ,p_event_id IN NUMBER
84022 ,p_calculate_acctd_flag IN VARCHAR2
84023 ,p_calculate_g_l_flag IN VARCHAR2
84024 ,p_actual_flag IN OUT VARCHAR2
84025 ,p_balance_type_code OUT VARCHAR2
84026 ,p_gain_or_loss_ref OUT VARCHAR2
84027
84028 --TRANSACTION_ID
84029 , p_source_1 IN NUMBER
84030 --Item Concatenated Segments
84031 , p_source_2 IN VARCHAR2
84032 --Transaction Quantity
84033 , p_source_3 IN NUMBER
84034 --Transaction Unit of Measure Code
84035 , p_source_4 IN VARCHAR2
84036 --Inventory Transaction Type Description
84037 , p_source_5 IN VARCHAR2
84038 --Interorg Payables Account
84039 , p_source_35 IN NUMBER
84040 --DISTRIBUTION_IDENTIFIER
84041 , p_source_84 IN NUMBER
84042 --Distribution Type
84043 , p_source_85 IN VARCHAR2
84044 , p_source_85_meaning IN VARCHAR2
84045 --Entered Currency Code
84046 , p_source_88 IN VARCHAR2
84047 --Entered Amount
84048 , p_source_91 IN NUMBER
84049 --Currency Conversion Date
84050 , p_source_92 IN DATE
84051 --Currency Conversion Rate
84052 , p_source_93 IN NUMBER
84053 --Currency Conversion Type
84054 , p_source_94 IN VARCHAR2
84055 --Accounted Amount
84056 , p_source_95 IN NUMBER
84057 --Accounting Line Type
84058 , p_source_97 IN NUMBER
84059 )
84060 IS
84061
84062 l_component_type VARCHAR2(80);
84063 l_component_code VARCHAR2(30);
84064 l_component_type_code VARCHAR2(1);
84065 l_component_appl_id INTEGER;
84066 l_amb_context_code VARCHAR2(30);
84067 l_entity_code VARCHAR2(30);
84068 l_event_class_code VARCHAR2(30);
84069 l_ae_header_id NUMBER;
84070 l_event_type_code VARCHAR2(30);
84071 l_line_definition_code VARCHAR2(30);
84072 l_line_definition_owner_code VARCHAR2(1);
84073 --
84074 -- adr variables
84075 l_segment VARCHAR2(30);
84076 l_ccid NUMBER;
84077 l_adr_transaction_coa_id NUMBER;
84078 l_adr_accounting_coa_id NUMBER;
84079 l_adr_flexfield_segment_code VARCHAR2(30);
84080 l_adr_flex_value_set_id NUMBER;
84081 l_adr_value_type_code VARCHAR2(30);
84082 l_adr_value_combination_id NUMBER;
84083 l_adr_value_segment_code VARCHAR2(30);
84084
84085 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
84086 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
84087 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
84088 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
84089
84090 -- 4262811 Variables ------------------------------------------------------------------------------------------
84091 l_entered_amt_idx NUMBER;
84092 l_accted_amt_idx NUMBER;
84093 l_acc_rev_flag VARCHAR2(1);
84094 l_accrual_line_num NUMBER;
84095 l_tmp_amt NUMBER;
84096 l_acc_rev_natural_side_code VARCHAR2(1);
84097
84098 l_num_entries NUMBER;
84099 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
84100 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
84101 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
84102 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
84103 l_recog_line_1 NUMBER;
84104 l_recog_line_2 NUMBER;
84105
84106 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
84107 l_bflow_applied_to_amt NUMBER; -- 5132302
84108 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
84109
84110 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
84111
84112 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
84113 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
84114
84115 ---------------------------------------------------------------------------------------------------------------
84116
84117
84118 --
84119 -- bulk performance
84120 --
84121 l_balance_type_code VARCHAR2(1);
84122 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
84123 l_log_module VARCHAR2(240);
84124
84125 --
84126 -- Upgrade strategy
84127 --
84128 l_actual_upg_option VARCHAR2(1);
84129 l_enc_upg_option VARCHAR2(1);
84130
84131 --
84132 BEGIN
84133 --
84134 IF g_log_enabled THEN
84135 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_172';
84136 END IF;
84137 --
84138 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
84139
84140 trace
84141 (p_msg => 'BEGIN of AcctLineType_172'
84142 ,p_level => C_LEVEL_PROCEDURE
84143 ,p_module => l_log_module);
84144
84145 END IF;
84146 --
84147 l_component_type := 'AMB_JLT';
84148 l_component_code := 'INTERORG_PAYABLES';
84149 l_component_type_code := 'S';
84150 l_component_appl_id := 707;
84151 l_amb_context_code := 'DEFAULT';
84152 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
84153 l_event_class_code := 'USER_DEFINE';
84154 l_event_type_code := 'UDIR_INTERORG_SHIP';
84155 l_line_definition_owner_code := 'S';
84156 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
84157 --
84158 l_balance_type_code := 'A';
84159 l_segment := NULL;
84160 l_ccid := NULL;
84161 l_adr_transaction_coa_id := NULL;
84162 l_adr_accounting_coa_id := NULL;
84163 l_adr_flexfield_segment_code := NULL;
84164 l_adr_flex_value_set_id := NULL;
84165 l_adr_value_type_code := NULL;
84166 l_adr_value_combination_id := NULL;
84167 l_adr_value_segment_code := NULL;
84168
84169 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
84170 l_bflow_class_code := ''; -- 4219869 Business Flow
84171 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
84172 l_budgetary_control_flag := 'N';
84173
84174 l_bflow_applied_to_amt_idx := NULL; -- 5132302
84175 l_bflow_applied_to_amt := NULL; -- 5132302
84176 l_entered_amt_idx := NULL; -- 4262811
84177 l_accted_amt_idx := NULL; -- 4262811
84178 l_acc_rev_flag := NULL; -- 4262811
84179 l_accrual_line_num := NULL; -- 4262811
84180 l_tmp_amt := NULL; -- 4262811
84181 --
84182
84183 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
84184 l_balance_type_code <> 'B' THEN
84185 IF NVL(p_source_97,9E125) = 9
84186 THEN
84187
84188 --
84189 XLA_AE_LINES_PKG.SetNewLine;
84190
84191 p_balance_type_code := l_balance_type_code;
84192 -- set the flag so later we will know whether the gain loss line needs to be created
84193
84194 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
84195 p_actual_flag :='A';
84196 END IF;
84197
84198 --
84199 -- bulk performance
84200 --
84201 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
84202 p_header_num => 0); -- 4262811
84203 --
84204 -- set accounting line options
84205 --
84206 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
84207 p_natural_side_code => 'D'
84208 , p_gain_or_loss_flag => 'N'
84209 , p_gl_transfer_mode_code => 'S'
84210 , p_acct_entry_type_code => 'A'
84211 , p_switch_side_flag => 'Y'
84212 , p_merge_duplicate_code => 'N'
84213 );
84214 --
84215 l_acc_rev_natural_side_code := 'C'; -- 4262811
84216 --
84217 --
84218 -- set accounting line type info
84219 --
84220 xla_ae_lines_pkg.SetAcctLineType
84221 (p_component_type => l_component_type
84222 ,p_event_type_code => l_event_type_code
84223 ,p_line_definition_owner_code => l_line_definition_owner_code
84224 ,p_line_definition_code => l_line_definition_code
84225 ,p_accounting_line_code => l_component_code
84226 ,p_accounting_line_type_code => l_component_type_code
84227 ,p_accounting_line_appl_id => l_component_appl_id
84228 ,p_amb_context_code => l_amb_context_code
84229 ,p_entity_code => l_entity_code
84230 ,p_event_class_code => l_event_class_code);
84231 --
84232 -- set accounting class
84233 --
84234 xla_ae_lines_pkg.SetAcctClass(
84235 p_accounting_class_code => 'INTERORG_PAYABLES'
84236 , p_ae_header_id => l_ae_header_id
84237 );
84238
84239 --
84240 -- set rounding class
84241 --
84242 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
84243 'INTERORG_PAYABLES';
84244
84245 --
84246 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
84247 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
84248 --
84249 -- bulk performance
84250 --
84251 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
84252
84253 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
84254 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
84255
84256 -- 4955764
84257 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
84258 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
84259
84260 -- 4458381 Public Sector Enh
84261
84262 --
84263 -- set accounting attributes for the line type
84264 --
84265 l_entered_amt_idx := 3;
84266 l_accted_amt_idx := 8;
84267 l_bflow_applied_to_amt_idx := NULL; -- 5132302
84268 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
84269 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
84270 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
84271 l_rec_acct_attrs.array_char_value(2) := p_source_85;
84272 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
84273 l_rec_acct_attrs.array_num_value(3) := p_source_91;
84274 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
84275 l_rec_acct_attrs.array_char_value(4) := p_source_88;
84276 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
84277 l_rec_acct_attrs.array_date_value(5) := p_source_92;
84278 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
84279 l_rec_acct_attrs.array_num_value(6) := p_source_93;
84280 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
84281 l_rec_acct_attrs.array_char_value(7) := p_source_94;
84282 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
84283 l_rec_acct_attrs.array_num_value(8) := p_source_95;
84284
84285 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
84286 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
84287
84288 ---------------------------------------------------------------------------------------------------------------
84289 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
84290 ---------------------------------------------------------------------------------------------------------------
84291 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
84292
84293 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
84294 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
84295
84296 IF xla_accounting_cache_pkg.GetValueChar
84297 (p_source_code => 'LEDGER_CATEGORY_CODE'
84298 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
84299 AND l_bflow_method_code = 'PRIOR_ENTRY'
84300 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
84301 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
84302 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
84303 )
84304 THEN
84305 xla_ae_lines_pkg.BflowUpgEntry
84306 (p_business_method_code => l_bflow_method_code
84307 ,p_business_class_code => l_bflow_class_code
84308 ,p_balance_type => l_balance_type_code);
84309 ELSE
84310 NULL;
84311 -- No business flow processing for business flow method of NONE.
84312 END IF;
84313
84314 --
84315 -- call analytical criteria
84316 --
84317
84318 --
84319 -- call description
84320 --
84321
84322 xla_ae_lines_pkg.SetLineDescription(
84323 p_ae_header_id => l_ae_header_id
84324 ,p_description => Description_1 (
84325 p_application_id => p_application_id
84326 , p_ae_header_id => l_ae_header_id
84327 , p_source_1 => p_source_1
84328 , p_source_2 => p_source_2
84329 , p_source_3 => p_source_3
84330 , p_source_4 => p_source_4
84331 , p_source_5 => p_source_5
84332 )
84333 );
84334
84335
84336 --
84337 -- call ADRs
84338 -- Bug 4922099
84339 --
84340 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
84341 (NVL(l_actual_upg_option, 'N') = 'O') OR
84342 (NVL(l_enc_upg_option, 'N') = 'O')
84343 )
84344 THEN
84345 NULL;
84346 --
84347 --
84348
84349 l_ccid := AcctDerRule_20(
84350 p_application_id => p_application_id
84351 , p_ae_header_id => l_ae_header_id
84352 , p_source_35 => p_source_35
84353 , x_transaction_coa_id => l_adr_transaction_coa_id
84354 , x_accounting_coa_id => l_adr_accounting_coa_id
84355 , x_value_type_code => l_adr_value_type_code
84356 , p_side => 'NA'
84357 );
84358
84359 xla_ae_lines_pkg.set_ccid(
84360 p_code_combination_id => l_ccid
84361 , p_value_type_code => l_adr_value_type_code
84362 , p_transaction_coa_id => l_adr_transaction_coa_id
84363 , p_accounting_coa_id => l_adr_accounting_coa_id
84364 , p_adr_code => 'PI_INTERORG_PAYABLES'
84365 , p_adr_type_code => 'S'
84366 , p_component_type => l_component_type
84367 , p_component_code => l_component_code
84368 , p_component_type_code => l_component_type_code
84369 , p_component_appl_id => l_component_appl_id
84370 , p_amb_context_code => l_amb_context_code
84371 , p_side => 'NA'
84372 );
84373
84374
84375 --
84376 --
84377 END IF;
84378 --
84379 -- Bug 4922099
84380 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
84381 (NVL(l_enc_upg_option, 'N') = 'O')
84382 ) AND
84383 (l_bflow_method_code = 'PRIOR_ENTRY')
84384 )
84385 THEN
84386 IF
84387 --
84388 1 = 2
84389 --
84390 THEN
84391 xla_accounting_err_pkg.build_message
84392 (p_appli_s_name => 'XLA'
84393 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
84394 ,p_token_1 => 'LINE_NUMBER'
84395 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
84396 ,p_token_2 => 'LINE_TYPE_NAME'
84397 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
84398 l_component_type
84399 ,l_component_code
84400 ,l_component_type_code
84401 ,l_component_appl_id
84402 ,l_amb_context_code
84403 ,l_entity_code
84404 ,l_event_class_code
84405 )
84406 ,p_token_3 => 'OWNER'
84407 ,p_value_3 => xla_lookups_pkg.get_meaning(
84408 p_lookup_type => 'XLA_OWNER_TYPE'
84409 ,p_lookup_code => l_component_type_code
84410 )
84411 ,p_token_4 => 'PRODUCT_NAME'
84412 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
84413 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
84414 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
84415 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
84416 ,p_ae_header_id => NULL
84417 );
84418
84419 IF (C_LEVEL_ERROR>= g_log_level) THEN
84420 trace
84421 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
84422 ,p_level => C_LEVEL_ERROR
84423 ,p_module => l_log_module);
84424 END IF;
84425 END IF;
84426 END IF;
84427 --
84428 --
84429 ------------------------------------------------------------------------------------------------
84430 -- 4219869 Business Flow
84431 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
84432 -- Prior Entry. Currently, the following code is always generated.
84433 ------------------------------------------------------------------------------------------------
84434 XLA_AE_LINES_PKG.ValidateCurrentLine;
84435
84436 ------------------------------------------------------------------------------------
84437 -- 4219869 Business Flow
84438 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
84439 ------------------------------------------------------------------------------------
84440 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
84441
84442 ----------------------------------------------------------------------------------
84443 -- 4219869 Business Flow
84444 -- Update journal entry status -- Need to generate this within IF <condition>
84445 ----------------------------------------------------------------------------------
84446 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
84447 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
84448 ,p_balance_type_code => l_balance_type_code
84449 );
84450
84451 -------------------------------------------------------------------------------------------
84452 -- 4262811 - Generate the Accrual Reversal lines
84453 -------------------------------------------------------------------------------------------
84454 BEGIN
84455 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
84456 (g_array_event(p_event_id).array_value_num('header_index'));
84457 IF l_acc_rev_flag IS NULL THEN
84458 l_acc_rev_flag := 'N';
84459 END IF;
84460 EXCEPTION
84461 WHEN OTHERS THEN
84462 l_acc_rev_flag := 'N';
84463 END;
84464 --
84465 IF (l_acc_rev_flag = 'Y') THEN
84466
84467 -- 4645092 ------------------------------------------------------------------------------
84468 -- To allow MPA report to determine if it should generate report process
84469 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
84470 ------------------------------------------------------------------------------------------
84471
84472 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
84473 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
84474 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
84475 -- call ADRs
84476 -- Bug 4922099
84477 --
84478 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
84479 (NVL(l_actual_upg_option, 'N') = 'O') OR
84480 (NVL(l_enc_upg_option, 'N') = 'O')
84481 )
84482 THEN
84483 NULL;
84484 --
84485 --
84486
84487 l_ccid := AcctDerRule_20(
84488 p_application_id => p_application_id
84489 , p_ae_header_id => l_ae_header_id
84490 , p_source_35 => p_source_35
84491 , x_transaction_coa_id => l_adr_transaction_coa_id
84492 , x_accounting_coa_id => l_adr_accounting_coa_id
84493 , x_value_type_code => l_adr_value_type_code
84494 , p_side => 'NA'
84495 );
84496
84497 xla_ae_lines_pkg.set_ccid(
84498 p_code_combination_id => l_ccid
84499 , p_value_type_code => l_adr_value_type_code
84500 , p_transaction_coa_id => l_adr_transaction_coa_id
84501 , p_accounting_coa_id => l_adr_accounting_coa_id
84502 , p_adr_code => 'PI_INTERORG_PAYABLES'
84503 , p_adr_type_code => 'S'
84504 , p_component_type => l_component_type
84505 , p_component_code => l_component_code
84506 , p_component_type_code => l_component_type_code
84507 , p_component_appl_id => l_component_appl_id
84508 , p_amb_context_code => l_amb_context_code
84509 , p_side => 'NA'
84510 );
84511
84512
84513 --
84514 --
84515 END IF;
84516
84517 --
84518 -- Update the line information that should be overwritten
84519 --
84520 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
84521 p_header_num => 1);
84522 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
84523
84524 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
84525
84526 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
84527 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
84528 END IF;
84529
84530 --
84531 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
84532 --
84533 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
84534 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
84535 ELSE
84536 ---------------------------------------------------------------------------------------------------
84537 -- 4262811a Switch Sign
84538 ---------------------------------------------------------------------------------------------------
84539 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
84540 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
84541 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
84542 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
84543 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
84544 -- 5132302
84545 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
84546 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
84547
84548 END IF;
84549
84550 -- 4955764
84551 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
84552 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
84553
84554
84555 XLA_AE_LINES_PKG.ValidateCurrentLine;
84556 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
84557
84558 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
84559 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
84560 ,p_balance_type_code => l_balance_type_code);
84561
84562 END IF;
84563
84564 -----------------------------------------------------------------------------------------
84565 -- 4262811 Multiperiod Accounting
84566 -----------------------------------------------------------------------------------------
84567 -- No MPA option is assigned.
84568
84569
84570 END IF;
84571 END IF;
84572 --
84573
84574 --
84575 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
84576 trace
84577 (p_msg => 'END of AcctLineType_172'
84578 ,p_level => C_LEVEL_PROCEDURE
84579 ,p_module => l_log_module);
84580 END IF;
84581 --
84582 EXCEPTION
84583 WHEN xla_exceptions_pkg.application_exception THEN
84584 RAISE;
84585 WHEN OTHERS THEN
84586 xla_exceptions_pkg.raise_message
84587 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_172');
84588 END AcctLineType_172;
84589 --
84590
84591 ---------------------------------------
84592 --
84593 -- PRIVATE FUNCTION
84594 -- AcctLineType_173
84595 --
84596 ---------------------------------------
84597 PROCEDURE AcctLineType_173 (
84598 p_application_id IN NUMBER
84599 ,p_event_id IN NUMBER
84600 ,p_calculate_acctd_flag IN VARCHAR2
84601 ,p_calculate_g_l_flag IN VARCHAR2
84602 ,p_actual_flag IN OUT VARCHAR2
84603 ,p_balance_type_code OUT VARCHAR2
84604 ,p_gain_or_loss_ref OUT VARCHAR2
84605
84606 --TRANSACTION_ID
84607 , p_source_1 IN NUMBER
84608 --Item Concatenated Segments
84609 , p_source_2 IN VARCHAR2
84610 --Transaction Quantity
84611 , p_source_3 IN NUMBER
84612 --Transaction Unit of Measure Code
84613 , p_source_4 IN VARCHAR2
84614 --Inventory Transaction Type Description
84615 , p_source_5 IN VARCHAR2
84616 --Cost Management Default Account
84617 , p_source_11 IN NUMBER
84618 --Applied to Application ID
84619 , p_source_79 IN NUMBER
84620 --Applied to Distribution Link Type
84621 , p_source_80 IN VARCHAR2
84622 --Applied to Entity Code
84623 , p_source_81 IN VARCHAR2
84624 --DISTRIBUTION_IDENTIFIER
84625 , p_source_84 IN NUMBER
84626 --Distribution Type
84627 , p_source_85 IN VARCHAR2
84628 , p_source_85_meaning IN VARCHAR2
84629 --Encumbrance Reversal Amount Entered
84630 , p_source_87 IN NUMBER
84631 --Entered Currency Code
84632 , p_source_88 IN VARCHAR2
84633 --Transaction Encumbrance Reversal Amount
84634 , p_source_89 IN NUMBER
84635 --Entered Amount
84636 , p_source_91 IN NUMBER
84637 --Currency Conversion Date
84638 , p_source_92 IN DATE
84639 --Currency Conversion Rate
84640 , p_source_93 IN NUMBER
84641 --Currency Conversion Type
84642 , p_source_94 IN VARCHAR2
84643 --Accounted Amount
84644 , p_source_95 IN NUMBER
84645 --Accounting Line Type
84646 , p_source_97 IN NUMBER
84647 --Costing Encumbrance Upgrade Option
84648 , p_source_100 IN VARCHAR2
84649 --TXN_PO_DISTRIBUTION_ID
84650 , p_source_101 IN NUMBER
84651 --TXN_PO_HEADER_ID
84652 , p_source_102 IN NUMBER
84653 --Requisition Budget Account
84654 , p_source_103 IN NUMBER
84655 --Requisition Encumbrance Type Identifier
84656 , p_source_104 IN NUMBER
84657 )
84658 IS
84659
84660 l_component_type VARCHAR2(80);
84661 l_component_code VARCHAR2(30);
84662 l_component_type_code VARCHAR2(1);
84663 l_component_appl_id INTEGER;
84664 l_amb_context_code VARCHAR2(30);
84665 l_entity_code VARCHAR2(30);
84666 l_event_class_code VARCHAR2(30);
84667 l_ae_header_id NUMBER;
84668 l_event_type_code VARCHAR2(30);
84669 l_line_definition_code VARCHAR2(30);
84670 l_line_definition_owner_code VARCHAR2(1);
84671 --
84672 -- adr variables
84673 l_segment VARCHAR2(30);
84674 l_ccid NUMBER;
84675 l_adr_transaction_coa_id NUMBER;
84676 l_adr_accounting_coa_id NUMBER;
84677 l_adr_flexfield_segment_code VARCHAR2(30);
84678 l_adr_flex_value_set_id NUMBER;
84679 l_adr_value_type_code VARCHAR2(30);
84680 l_adr_value_combination_id NUMBER;
84681 l_adr_value_segment_code VARCHAR2(30);
84682
84683 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
84684 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
84685 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
84686 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
84687
84688 -- 4262811 Variables ------------------------------------------------------------------------------------------
84689 l_entered_amt_idx NUMBER;
84690 l_accted_amt_idx NUMBER;
84691 l_acc_rev_flag VARCHAR2(1);
84692 l_accrual_line_num NUMBER;
84693 l_tmp_amt NUMBER;
84694 l_acc_rev_natural_side_code VARCHAR2(1);
84695
84696 l_num_entries NUMBER;
84697 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
84698 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
84699 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
84700 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
84701 l_recog_line_1 NUMBER;
84702 l_recog_line_2 NUMBER;
84703
84704 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
84705 l_bflow_applied_to_amt NUMBER; -- 5132302
84706 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
84707
84708 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
84709
84710 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
84711 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
84712
84713 ---------------------------------------------------------------------------------------------------------------
84714
84715
84716 --
84717 -- bulk performance
84718 --
84719 l_balance_type_code VARCHAR2(1);
84720 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
84721 l_log_module VARCHAR2(240);
84722
84723 --
84724 -- Upgrade strategy
84725 --
84726 l_actual_upg_option VARCHAR2(1);
84727 l_enc_upg_option VARCHAR2(1);
84728
84729 --
84730 BEGIN
84731 --
84732 IF g_log_enabled THEN
84733 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_173';
84734 END IF;
84735 --
84736 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
84737
84738 trace
84739 (p_msg => 'BEGIN of AcctLineType_173'
84740 ,p_level => C_LEVEL_PROCEDURE
84741 ,p_module => l_log_module);
84742
84743 END IF;
84744 --
84745 l_component_type := 'AMB_JLT';
84746 l_component_code := 'INTERORG_PAYABLES';
84747 l_component_type_code := 'S';
84748 l_component_appl_id := 707;
84749 l_amb_context_code := 'DEFAULT';
84750 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
84751 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
84752 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
84753 l_line_definition_owner_code := 'S';
84754 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
84755 --
84756 l_balance_type_code := 'A';
84757 l_segment := NULL;
84758 l_ccid := NULL;
84759 l_adr_transaction_coa_id := NULL;
84760 l_adr_accounting_coa_id := NULL;
84761 l_adr_flexfield_segment_code := NULL;
84762 l_adr_flex_value_set_id := NULL;
84763 l_adr_value_type_code := NULL;
84764 l_adr_value_combination_id := NULL;
84765 l_adr_value_segment_code := NULL;
84766
84767 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
84768 l_bflow_class_code := ''; -- 4219869 Business Flow
84769 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
84770 l_budgetary_control_flag := 'N';
84771
84772 l_bflow_applied_to_amt_idx := NULL; -- 5132302
84773 l_bflow_applied_to_amt := NULL; -- 5132302
84774 l_entered_amt_idx := NULL; -- 4262811
84775 l_accted_amt_idx := NULL; -- 4262811
84776 l_acc_rev_flag := NULL; -- 4262811
84777 l_accrual_line_num := NULL; -- 4262811
84778 l_tmp_amt := NULL; -- 4262811
84779 --
84780
84781 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
84782 l_balance_type_code <> 'B' THEN
84783 IF NVL(p_source_97,9E125) = 9
84784 THEN
84785
84786 --
84787 XLA_AE_LINES_PKG.SetNewLine;
84788
84789 p_balance_type_code := l_balance_type_code;
84790 -- set the flag so later we will know whether the gain loss line needs to be created
84791
84792 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
84793 p_actual_flag :='A';
84794 END IF;
84795
84796 --
84797 -- bulk performance
84798 --
84799 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
84800 p_header_num => 0); -- 4262811
84801 --
84802 -- set accounting line options
84803 --
84804 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
84805 p_natural_side_code => 'D'
84806 , p_gain_or_loss_flag => 'N'
84807 , p_gl_transfer_mode_code => 'S'
84808 , p_acct_entry_type_code => 'A'
84809 , p_switch_side_flag => 'Y'
84810 , p_merge_duplicate_code => 'N'
84811 );
84812 --
84813 l_acc_rev_natural_side_code := 'C'; -- 4262811
84814 --
84815 --
84816 -- set accounting line type info
84817 --
84818 xla_ae_lines_pkg.SetAcctLineType
84819 (p_component_type => l_component_type
84820 ,p_event_type_code => l_event_type_code
84821 ,p_line_definition_owner_code => l_line_definition_owner_code
84822 ,p_line_definition_code => l_line_definition_code
84823 ,p_accounting_line_code => l_component_code
84824 ,p_accounting_line_type_code => l_component_type_code
84825 ,p_accounting_line_appl_id => l_component_appl_id
84826 ,p_amb_context_code => l_amb_context_code
84827 ,p_entity_code => l_entity_code
84828 ,p_event_class_code => l_event_class_code);
84829 --
84830 -- set accounting class
84831 --
84832 xla_ae_lines_pkg.SetAcctClass(
84833 p_accounting_class_code => 'INTERORG_PAYABLES'
84834 , p_ae_header_id => l_ae_header_id
84835 );
84836
84837 --
84838 -- set rounding class
84839 --
84840 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
84841 'INTERORG_PAYABLES';
84842
84843 --
84844 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
84845 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
84846 --
84847 -- bulk performance
84848 --
84849 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
84850
84851 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
84852 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
84853
84854 -- 4955764
84855 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
84856 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
84857
84858 -- 4458381 Public Sector Enh
84859
84860 --
84861 -- set accounting attributes for the line type
84862 --
84863 l_entered_amt_idx := 17;
84864 l_accted_amt_idx := 22;
84865 l_bflow_applied_to_amt_idx := NULL; -- 5132302
84866 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
84867 l_rec_acct_attrs.array_num_value(1) := p_source_79;
84868 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
84869 l_rec_acct_attrs.array_char_value(2) := p_source_80;
84870 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
84871 l_rec_acct_attrs.array_char_value(3) := p_source_81;
84872 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
84873 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
84874 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
84875 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
84876 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
84877 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
84878 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
84879 l_rec_acct_attrs.array_char_value(7) := p_source_85;
84880 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
84881 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
84882 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
84883 l_rec_acct_attrs.array_num_value(9) := p_source_87;
84884 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
84885 l_rec_acct_attrs.array_char_value(10) := p_source_88;
84886 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
84887 l_rec_acct_attrs.array_num_value(11) := p_source_89;
84888 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
84889 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
84890 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
84891 l_rec_acct_attrs.array_num_value(13) := p_source_87;
84892 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
84893 l_rec_acct_attrs.array_char_value(14) := p_source_88;
84894 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
84895 l_rec_acct_attrs.array_num_value(15) := p_source_89;
84896 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
84897 l_rec_acct_attrs.array_char_value(16) := p_source_100;
84898 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
84899 l_rec_acct_attrs.array_num_value(17) := p_source_91;
84900 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
84901 l_rec_acct_attrs.array_char_value(18) := p_source_88;
84902 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
84903 l_rec_acct_attrs.array_date_value(19) := p_source_92;
84904 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
84905 l_rec_acct_attrs.array_num_value(20) := p_source_93;
84906 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
84907 l_rec_acct_attrs.array_char_value(21) := p_source_94;
84908 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
84909 l_rec_acct_attrs.array_num_value(22) := p_source_95;
84910 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
84911 l_rec_acct_attrs.array_num_value(23) := p_source_104;
84912 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
84913 l_rec_acct_attrs.array_num_value(24) := p_source_104;
84914
84915 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
84916 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
84917
84918 ---------------------------------------------------------------------------------------------------------------
84919 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
84920 ---------------------------------------------------------------------------------------------------------------
84921 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
84922
84923 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
84924 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
84925
84926 IF xla_accounting_cache_pkg.GetValueChar
84927 (p_source_code => 'LEDGER_CATEGORY_CODE'
84928 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
84929 AND l_bflow_method_code = 'PRIOR_ENTRY'
84930 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
84931 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
84932 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
84933 )
84934 THEN
84935 xla_ae_lines_pkg.BflowUpgEntry
84936 (p_business_method_code => l_bflow_method_code
84937 ,p_business_class_code => l_bflow_class_code
84938 ,p_balance_type => l_balance_type_code);
84939 ELSE
84940 NULL;
84941 -- No business flow processing for business flow method of NONE.
84942 END IF;
84943
84944 --
84945 -- call analytical criteria
84946 --
84947
84948 --
84949 -- call description
84950 --
84951
84952 xla_ae_lines_pkg.SetLineDescription(
84953 p_ae_header_id => l_ae_header_id
84954 ,p_description => Description_1 (
84955 p_application_id => p_application_id
84956 , p_ae_header_id => l_ae_header_id
84957 , p_source_1 => p_source_1
84958 , p_source_2 => p_source_2
84959 , p_source_3 => p_source_3
84960 , p_source_4 => p_source_4
84961 , p_source_5 => p_source_5
84962 )
84963 );
84964
84965
84966 --
84967 -- call ADRs
84968 -- Bug 4922099
84969 --
84970 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
84971 (NVL(l_actual_upg_option, 'N') = 'O') OR
84972 (NVL(l_enc_upg_option, 'N') = 'O')
84973 )
84974 THEN
84975 NULL;
84976 --
84977 --
84978
84979 l_ccid := AcctDerRule_6(
84980 p_application_id => p_application_id
84981 , p_ae_header_id => l_ae_header_id
84982 , p_source_11 => p_source_11
84983 , x_transaction_coa_id => l_adr_transaction_coa_id
84984 , x_accounting_coa_id => l_adr_accounting_coa_id
84985 , x_value_type_code => l_adr_value_type_code
84986 , p_side => 'NA'
84987 );
84988
84989 xla_ae_lines_pkg.set_ccid(
84990 p_code_combination_id => l_ccid
84991 , p_value_type_code => l_adr_value_type_code
84992 , p_transaction_coa_id => l_adr_transaction_coa_id
84993 , p_accounting_coa_id => l_adr_accounting_coa_id
84994 , p_adr_code => 'CST_DEFAULT'
84995 , p_adr_type_code => 'S'
84996 , p_component_type => l_component_type
84997 , p_component_code => l_component_code
84998 , p_component_type_code => l_component_type_code
84999 , p_component_appl_id => l_component_appl_id
85000 , p_amb_context_code => l_amb_context_code
85001 , p_side => 'NA'
85002 );
85003
85004
85005 --
85006 --
85007 END IF;
85008 --
85009 -- Bug 4922099
85010 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
85011 (NVL(l_enc_upg_option, 'N') = 'O')
85012 ) AND
85013 (l_bflow_method_code = 'PRIOR_ENTRY')
85014 )
85015 THEN
85016 IF
85017 --
85018 1 = 2
85019 --
85020 THEN
85021 xla_accounting_err_pkg.build_message
85022 (p_appli_s_name => 'XLA'
85023 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
85024 ,p_token_1 => 'LINE_NUMBER'
85025 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
85026 ,p_token_2 => 'LINE_TYPE_NAME'
85027 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
85028 l_component_type
85029 ,l_component_code
85030 ,l_component_type_code
85031 ,l_component_appl_id
85032 ,l_amb_context_code
85033 ,l_entity_code
85034 ,l_event_class_code
85035 )
85036 ,p_token_3 => 'OWNER'
85037 ,p_value_3 => xla_lookups_pkg.get_meaning(
85038 p_lookup_type => 'XLA_OWNER_TYPE'
85039 ,p_lookup_code => l_component_type_code
85040 )
85041 ,p_token_4 => 'PRODUCT_NAME'
85042 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
85043 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
85044 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
85045 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
85046 ,p_ae_header_id => NULL
85047 );
85048
85049 IF (C_LEVEL_ERROR>= g_log_level) THEN
85050 trace
85051 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
85052 ,p_level => C_LEVEL_ERROR
85053 ,p_module => l_log_module);
85054 END IF;
85055 END IF;
85056 END IF;
85057 --
85058 --
85059 ------------------------------------------------------------------------------------------------
85060 -- 4219869 Business Flow
85061 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
85062 -- Prior Entry. Currently, the following code is always generated.
85063 ------------------------------------------------------------------------------------------------
85064 XLA_AE_LINES_PKG.ValidateCurrentLine;
85065
85066 ------------------------------------------------------------------------------------
85067 -- 4219869 Business Flow
85068 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
85069 ------------------------------------------------------------------------------------
85070 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
85071
85072 ----------------------------------------------------------------------------------
85073 -- 4219869 Business Flow
85074 -- Update journal entry status -- Need to generate this within IF <condition>
85075 ----------------------------------------------------------------------------------
85076 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
85077 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
85078 ,p_balance_type_code => l_balance_type_code
85079 );
85080
85081 -------------------------------------------------------------------------------------------
85082 -- 4262811 - Generate the Accrual Reversal lines
85083 -------------------------------------------------------------------------------------------
85084 BEGIN
85085 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
85086 (g_array_event(p_event_id).array_value_num('header_index'));
85087 IF l_acc_rev_flag IS NULL THEN
85088 l_acc_rev_flag := 'N';
85089 END IF;
85090 EXCEPTION
85091 WHEN OTHERS THEN
85092 l_acc_rev_flag := 'N';
85093 END;
85094 --
85095 IF (l_acc_rev_flag = 'Y') THEN
85096
85097 -- 4645092 ------------------------------------------------------------------------------
85098 -- To allow MPA report to determine if it should generate report process
85099 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
85100 ------------------------------------------------------------------------------------------
85101
85102 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
85103 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
85104 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
85105 -- call ADRs
85106 -- Bug 4922099
85107 --
85108 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
85109 (NVL(l_actual_upg_option, 'N') = 'O') OR
85110 (NVL(l_enc_upg_option, 'N') = 'O')
85111 )
85112 THEN
85113 NULL;
85114 --
85115 --
85116
85117 l_ccid := AcctDerRule_6(
85118 p_application_id => p_application_id
85119 , p_ae_header_id => l_ae_header_id
85120 , p_source_11 => p_source_11
85121 , x_transaction_coa_id => l_adr_transaction_coa_id
85122 , x_accounting_coa_id => l_adr_accounting_coa_id
85123 , x_value_type_code => l_adr_value_type_code
85124 , p_side => 'NA'
85125 );
85126
85127 xla_ae_lines_pkg.set_ccid(
85128 p_code_combination_id => l_ccid
85129 , p_value_type_code => l_adr_value_type_code
85130 , p_transaction_coa_id => l_adr_transaction_coa_id
85131 , p_accounting_coa_id => l_adr_accounting_coa_id
85132 , p_adr_code => 'CST_DEFAULT'
85133 , p_adr_type_code => 'S'
85134 , p_component_type => l_component_type
85135 , p_component_code => l_component_code
85136 , p_component_type_code => l_component_type_code
85137 , p_component_appl_id => l_component_appl_id
85138 , p_amb_context_code => l_amb_context_code
85139 , p_side => 'NA'
85140 );
85141
85142
85143 --
85144 --
85145 END IF;
85146
85147 --
85148 -- Update the line information that should be overwritten
85149 --
85150 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
85151 p_header_num => 1);
85152 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
85153
85154 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
85155
85156 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
85157 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
85158 END IF;
85159
85160 --
85161 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
85162 --
85163 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
85164 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
85165 ELSE
85166 ---------------------------------------------------------------------------------------------------
85167 -- 4262811a Switch Sign
85168 ---------------------------------------------------------------------------------------------------
85169 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
85170 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
85171 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85172 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
85173 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85174 -- 5132302
85175 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
85176 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85177
85178 END IF;
85179
85180 -- 4955764
85181 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
85182 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
85183
85184
85185 XLA_AE_LINES_PKG.ValidateCurrentLine;
85186 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
85187
85188 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
85189 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
85190 ,p_balance_type_code => l_balance_type_code);
85191
85192 END IF;
85193
85194 -----------------------------------------------------------------------------------------
85195 -- 4262811 Multiperiod Accounting
85196 -----------------------------------------------------------------------------------------
85197 -- No MPA option is assigned.
85198
85199
85200 END IF;
85201 END IF;
85202 --
85203
85204 --
85205 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
85206 trace
85207 (p_msg => 'END of AcctLineType_173'
85208 ,p_level => C_LEVEL_PROCEDURE
85209 ,p_module => l_log_module);
85210 END IF;
85211 --
85212 EXCEPTION
85213 WHEN xla_exceptions_pkg.application_exception THEN
85214 RAISE;
85215 WHEN OTHERS THEN
85216 xla_exceptions_pkg.raise_message
85217 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_173');
85218 END AcctLineType_173;
85219 --
85220
85221 ---------------------------------------
85222 --
85223 -- PRIVATE FUNCTION
85224 -- AcctLineType_174
85225 --
85226 ---------------------------------------
85227 PROCEDURE AcctLineType_174 (
85228 p_application_id IN NUMBER
85229 ,p_event_id IN NUMBER
85230 ,p_calculate_acctd_flag IN VARCHAR2
85231 ,p_calculate_g_l_flag IN VARCHAR2
85232 ,p_actual_flag IN OUT VARCHAR2
85233 ,p_balance_type_code OUT VARCHAR2
85234 ,p_gain_or_loss_ref OUT VARCHAR2
85235
85236 --TRANSACTION_ID
85237 , p_source_1 IN NUMBER
85238 --Item Concatenated Segments
85239 , p_source_2 IN VARCHAR2
85240 --Transaction Quantity
85241 , p_source_3 IN NUMBER
85242 --Transaction Unit of Measure Code
85243 , p_source_4 IN VARCHAR2
85244 --Inventory Transaction Type Description
85245 , p_source_5 IN VARCHAR2
85246 --Interorg Payables Account
85247 , p_source_35 IN NUMBER
85248 --DISTRIBUTION_IDENTIFIER
85249 , p_source_84 IN NUMBER
85250 --Distribution Type
85251 , p_source_85 IN VARCHAR2
85252 , p_source_85_meaning IN VARCHAR2
85253 --Entered Currency Code
85254 , p_source_88 IN VARCHAR2
85255 --Entered Amount
85256 , p_source_91 IN NUMBER
85257 --Currency Conversion Date
85258 , p_source_92 IN DATE
85259 --Currency Conversion Rate
85260 , p_source_93 IN NUMBER
85261 --Currency Conversion Type
85262 , p_source_94 IN VARCHAR2
85263 --Accounted Amount
85264 , p_source_95 IN NUMBER
85265 --Accounting Line Type
85266 , p_source_97 IN NUMBER
85267 )
85268 IS
85269
85270 l_component_type VARCHAR2(80);
85271 l_component_code VARCHAR2(30);
85272 l_component_type_code VARCHAR2(1);
85273 l_component_appl_id INTEGER;
85274 l_amb_context_code VARCHAR2(30);
85275 l_entity_code VARCHAR2(30);
85276 l_event_class_code VARCHAR2(30);
85277 l_ae_header_id NUMBER;
85278 l_event_type_code VARCHAR2(30);
85279 l_line_definition_code VARCHAR2(30);
85280 l_line_definition_owner_code VARCHAR2(1);
85281 --
85282 -- adr variables
85283 l_segment VARCHAR2(30);
85284 l_ccid NUMBER;
85285 l_adr_transaction_coa_id NUMBER;
85286 l_adr_accounting_coa_id NUMBER;
85287 l_adr_flexfield_segment_code VARCHAR2(30);
85288 l_adr_flex_value_set_id NUMBER;
85289 l_adr_value_type_code VARCHAR2(30);
85290 l_adr_value_combination_id NUMBER;
85291 l_adr_value_segment_code VARCHAR2(30);
85292
85293 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
85294 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
85295 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
85296 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
85297
85298 -- 4262811 Variables ------------------------------------------------------------------------------------------
85299 l_entered_amt_idx NUMBER;
85300 l_accted_amt_idx NUMBER;
85301 l_acc_rev_flag VARCHAR2(1);
85302 l_accrual_line_num NUMBER;
85303 l_tmp_amt NUMBER;
85304 l_acc_rev_natural_side_code VARCHAR2(1);
85305
85306 l_num_entries NUMBER;
85307 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
85308 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
85309 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
85310 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
85311 l_recog_line_1 NUMBER;
85312 l_recog_line_2 NUMBER;
85313
85314 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
85315 l_bflow_applied_to_amt NUMBER; -- 5132302
85316 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
85317
85318 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
85319
85320 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
85321 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
85322
85323 ---------------------------------------------------------------------------------------------------------------
85324
85325
85326 --
85327 -- bulk performance
85328 --
85329 l_balance_type_code VARCHAR2(1);
85330 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
85331 l_log_module VARCHAR2(240);
85332
85333 --
85334 -- Upgrade strategy
85335 --
85336 l_actual_upg_option VARCHAR2(1);
85337 l_enc_upg_option VARCHAR2(1);
85338
85339 --
85340 BEGIN
85341 --
85342 IF g_log_enabled THEN
85343 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_174';
85344 END IF;
85345 --
85346 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
85347
85348 trace
85349 (p_msg => 'BEGIN of AcctLineType_174'
85350 ,p_level => C_LEVEL_PROCEDURE
85351 ,p_module => l_log_module);
85352
85353 END IF;
85354 --
85355 l_component_type := 'AMB_JLT';
85356 l_component_code := 'INTERORG_PAYABLES';
85357 l_component_type_code := 'S';
85358 l_component_appl_id := 707;
85359 l_amb_context_code := 'DEFAULT';
85360 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
85361 l_event_class_code := 'USER_DEFINE';
85362 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
85363 l_line_definition_owner_code := 'S';
85364 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
85365 --
85366 l_balance_type_code := 'A';
85367 l_segment := NULL;
85368 l_ccid := NULL;
85369 l_adr_transaction_coa_id := NULL;
85370 l_adr_accounting_coa_id := NULL;
85371 l_adr_flexfield_segment_code := NULL;
85372 l_adr_flex_value_set_id := NULL;
85373 l_adr_value_type_code := NULL;
85374 l_adr_value_combination_id := NULL;
85375 l_adr_value_segment_code := NULL;
85376
85377 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
85378 l_bflow_class_code := ''; -- 4219869 Business Flow
85379 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
85380 l_budgetary_control_flag := 'N';
85381
85382 l_bflow_applied_to_amt_idx := NULL; -- 5132302
85383 l_bflow_applied_to_amt := NULL; -- 5132302
85384 l_entered_amt_idx := NULL; -- 4262811
85385 l_accted_amt_idx := NULL; -- 4262811
85386 l_acc_rev_flag := NULL; -- 4262811
85387 l_accrual_line_num := NULL; -- 4262811
85388 l_tmp_amt := NULL; -- 4262811
85389 --
85390
85391 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
85392 l_balance_type_code <> 'B' THEN
85393 IF NVL(p_source_97,9E125) = 9
85394 THEN
85395
85396 --
85397 XLA_AE_LINES_PKG.SetNewLine;
85398
85399 p_balance_type_code := l_balance_type_code;
85400 -- set the flag so later we will know whether the gain loss line needs to be created
85401
85402 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
85403 p_actual_flag :='A';
85404 END IF;
85405
85406 --
85407 -- bulk performance
85408 --
85409 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
85410 p_header_num => 0); -- 4262811
85411 --
85412 -- set accounting line options
85413 --
85414 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
85415 p_natural_side_code => 'D'
85416 , p_gain_or_loss_flag => 'N'
85417 , p_gl_transfer_mode_code => 'S'
85418 , p_acct_entry_type_code => 'A'
85419 , p_switch_side_flag => 'Y'
85420 , p_merge_duplicate_code => 'N'
85421 );
85422 --
85423 l_acc_rev_natural_side_code := 'C'; -- 4262811
85424 --
85425 --
85426 -- set accounting line type info
85427 --
85428 xla_ae_lines_pkg.SetAcctLineType
85429 (p_component_type => l_component_type
85430 ,p_event_type_code => l_event_type_code
85431 ,p_line_definition_owner_code => l_line_definition_owner_code
85432 ,p_line_definition_code => l_line_definition_code
85433 ,p_accounting_line_code => l_component_code
85434 ,p_accounting_line_type_code => l_component_type_code
85435 ,p_accounting_line_appl_id => l_component_appl_id
85436 ,p_amb_context_code => l_amb_context_code
85437 ,p_entity_code => l_entity_code
85438 ,p_event_class_code => l_event_class_code);
85439 --
85440 -- set accounting class
85441 --
85442 xla_ae_lines_pkg.SetAcctClass(
85443 p_accounting_class_code => 'INTERORG_PAYABLES'
85444 , p_ae_header_id => l_ae_header_id
85445 );
85446
85447 --
85448 -- set rounding class
85449 --
85450 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
85451 'INTERORG_PAYABLES';
85452
85453 --
85454 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
85455 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
85456 --
85457 -- bulk performance
85458 --
85459 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
85460
85461 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
85462 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
85463
85464 -- 4955764
85465 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
85466 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
85467
85468 -- 4458381 Public Sector Enh
85469
85470 --
85471 -- set accounting attributes for the line type
85472 --
85473 l_entered_amt_idx := 3;
85474 l_accted_amt_idx := 8;
85475 l_bflow_applied_to_amt_idx := NULL; -- 5132302
85476 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
85477 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
85478 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
85479 l_rec_acct_attrs.array_char_value(2) := p_source_85;
85480 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
85481 l_rec_acct_attrs.array_num_value(3) := p_source_91;
85482 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
85483 l_rec_acct_attrs.array_char_value(4) := p_source_88;
85484 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
85485 l_rec_acct_attrs.array_date_value(5) := p_source_92;
85486 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
85487 l_rec_acct_attrs.array_num_value(6) := p_source_93;
85488 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
85489 l_rec_acct_attrs.array_char_value(7) := p_source_94;
85490 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
85491 l_rec_acct_attrs.array_num_value(8) := p_source_95;
85492
85493 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
85494 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
85495
85496 ---------------------------------------------------------------------------------------------------------------
85497 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
85498 ---------------------------------------------------------------------------------------------------------------
85499 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
85500
85501 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
85502 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
85503
85504 IF xla_accounting_cache_pkg.GetValueChar
85505 (p_source_code => 'LEDGER_CATEGORY_CODE'
85506 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
85507 AND l_bflow_method_code = 'PRIOR_ENTRY'
85508 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
85509 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
85510 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
85511 )
85512 THEN
85513 xla_ae_lines_pkg.BflowUpgEntry
85514 (p_business_method_code => l_bflow_method_code
85515 ,p_business_class_code => l_bflow_class_code
85516 ,p_balance_type => l_balance_type_code);
85517 ELSE
85518 NULL;
85519 -- No business flow processing for business flow method of NONE.
85520 END IF;
85521
85522 --
85523 -- call analytical criteria
85524 --
85525
85526 --
85527 -- call description
85528 --
85529
85530 xla_ae_lines_pkg.SetLineDescription(
85531 p_ae_header_id => l_ae_header_id
85532 ,p_description => Description_1 (
85533 p_application_id => p_application_id
85534 , p_ae_header_id => l_ae_header_id
85535 , p_source_1 => p_source_1
85536 , p_source_2 => p_source_2
85537 , p_source_3 => p_source_3
85538 , p_source_4 => p_source_4
85539 , p_source_5 => p_source_5
85540 )
85541 );
85542
85543
85544 --
85545 -- call ADRs
85546 -- Bug 4922099
85547 --
85548 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
85549 (NVL(l_actual_upg_option, 'N') = 'O') OR
85550 (NVL(l_enc_upg_option, 'N') = 'O')
85551 )
85552 THEN
85553 NULL;
85554 --
85555 --
85556
85557 l_ccid := AcctDerRule_20(
85558 p_application_id => p_application_id
85559 , p_ae_header_id => l_ae_header_id
85560 , p_source_35 => p_source_35
85561 , x_transaction_coa_id => l_adr_transaction_coa_id
85562 , x_accounting_coa_id => l_adr_accounting_coa_id
85563 , x_value_type_code => l_adr_value_type_code
85564 , p_side => 'NA'
85565 );
85566
85567 xla_ae_lines_pkg.set_ccid(
85568 p_code_combination_id => l_ccid
85569 , p_value_type_code => l_adr_value_type_code
85570 , p_transaction_coa_id => l_adr_transaction_coa_id
85571 , p_accounting_coa_id => l_adr_accounting_coa_id
85572 , p_adr_code => 'PI_INTERORG_PAYABLES'
85573 , p_adr_type_code => 'S'
85574 , p_component_type => l_component_type
85575 , p_component_code => l_component_code
85576 , p_component_type_code => l_component_type_code
85577 , p_component_appl_id => l_component_appl_id
85578 , p_amb_context_code => l_amb_context_code
85579 , p_side => 'NA'
85580 );
85581
85582
85583 --
85584 --
85585 END IF;
85586 --
85587 -- Bug 4922099
85588 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
85589 (NVL(l_enc_upg_option, 'N') = 'O')
85590 ) AND
85591 (l_bflow_method_code = 'PRIOR_ENTRY')
85592 )
85593 THEN
85594 IF
85595 --
85596 1 = 2
85597 --
85598 THEN
85599 xla_accounting_err_pkg.build_message
85600 (p_appli_s_name => 'XLA'
85601 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
85602 ,p_token_1 => 'LINE_NUMBER'
85603 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
85604 ,p_token_2 => 'LINE_TYPE_NAME'
85605 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
85606 l_component_type
85607 ,l_component_code
85608 ,l_component_type_code
85609 ,l_component_appl_id
85610 ,l_amb_context_code
85611 ,l_entity_code
85612 ,l_event_class_code
85613 )
85614 ,p_token_3 => 'OWNER'
85615 ,p_value_3 => xla_lookups_pkg.get_meaning(
85616 p_lookup_type => 'XLA_OWNER_TYPE'
85617 ,p_lookup_code => l_component_type_code
85618 )
85619 ,p_token_4 => 'PRODUCT_NAME'
85620 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
85621 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
85622 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
85623 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
85624 ,p_ae_header_id => NULL
85625 );
85626
85627 IF (C_LEVEL_ERROR>= g_log_level) THEN
85628 trace
85629 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
85630 ,p_level => C_LEVEL_ERROR
85631 ,p_module => l_log_module);
85632 END IF;
85633 END IF;
85634 END IF;
85635 --
85636 --
85637 ------------------------------------------------------------------------------------------------
85638 -- 4219869 Business Flow
85639 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
85640 -- Prior Entry. Currently, the following code is always generated.
85641 ------------------------------------------------------------------------------------------------
85642 XLA_AE_LINES_PKG.ValidateCurrentLine;
85643
85644 ------------------------------------------------------------------------------------
85645 -- 4219869 Business Flow
85646 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
85647 ------------------------------------------------------------------------------------
85648 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
85649
85650 ----------------------------------------------------------------------------------
85651 -- 4219869 Business Flow
85652 -- Update journal entry status -- Need to generate this within IF <condition>
85653 ----------------------------------------------------------------------------------
85654 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
85655 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
85656 ,p_balance_type_code => l_balance_type_code
85657 );
85658
85659 -------------------------------------------------------------------------------------------
85660 -- 4262811 - Generate the Accrual Reversal lines
85661 -------------------------------------------------------------------------------------------
85662 BEGIN
85663 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
85664 (g_array_event(p_event_id).array_value_num('header_index'));
85665 IF l_acc_rev_flag IS NULL THEN
85666 l_acc_rev_flag := 'N';
85667 END IF;
85668 EXCEPTION
85669 WHEN OTHERS THEN
85670 l_acc_rev_flag := 'N';
85671 END;
85672 --
85673 IF (l_acc_rev_flag = 'Y') THEN
85674
85675 -- 4645092 ------------------------------------------------------------------------------
85676 -- To allow MPA report to determine if it should generate report process
85677 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
85678 ------------------------------------------------------------------------------------------
85679
85680 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
85681 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
85682 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
85683 -- call ADRs
85684 -- Bug 4922099
85685 --
85686 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
85687 (NVL(l_actual_upg_option, 'N') = 'O') OR
85688 (NVL(l_enc_upg_option, 'N') = 'O')
85689 )
85690 THEN
85691 NULL;
85692 --
85693 --
85694
85695 l_ccid := AcctDerRule_20(
85696 p_application_id => p_application_id
85697 , p_ae_header_id => l_ae_header_id
85698 , p_source_35 => p_source_35
85699 , x_transaction_coa_id => l_adr_transaction_coa_id
85700 , x_accounting_coa_id => l_adr_accounting_coa_id
85701 , x_value_type_code => l_adr_value_type_code
85702 , p_side => 'NA'
85703 );
85704
85705 xla_ae_lines_pkg.set_ccid(
85706 p_code_combination_id => l_ccid
85707 , p_value_type_code => l_adr_value_type_code
85708 , p_transaction_coa_id => l_adr_transaction_coa_id
85709 , p_accounting_coa_id => l_adr_accounting_coa_id
85710 , p_adr_code => 'PI_INTERORG_PAYABLES'
85711 , p_adr_type_code => 'S'
85712 , p_component_type => l_component_type
85713 , p_component_code => l_component_code
85714 , p_component_type_code => l_component_type_code
85715 , p_component_appl_id => l_component_appl_id
85716 , p_amb_context_code => l_amb_context_code
85717 , p_side => 'NA'
85718 );
85719
85720
85721 --
85722 --
85723 END IF;
85724
85725 --
85726 -- Update the line information that should be overwritten
85727 --
85728 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
85729 p_header_num => 1);
85730 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
85731
85732 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
85733
85734 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
85735 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
85736 END IF;
85737
85738 --
85739 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
85740 --
85741 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
85742 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
85743 ELSE
85744 ---------------------------------------------------------------------------------------------------
85745 -- 4262811a Switch Sign
85746 ---------------------------------------------------------------------------------------------------
85747 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
85748 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
85749 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85750 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
85751 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85752 -- 5132302
85753 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
85754 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
85755
85756 END IF;
85757
85758 -- 4955764
85759 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
85760 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
85761
85762
85763 XLA_AE_LINES_PKG.ValidateCurrentLine;
85764 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
85765
85766 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
85767 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
85768 ,p_balance_type_code => l_balance_type_code);
85769
85770 END IF;
85771
85772 -----------------------------------------------------------------------------------------
85773 -- 4262811 Multiperiod Accounting
85774 -----------------------------------------------------------------------------------------
85775 -- No MPA option is assigned.
85776
85777
85778 END IF;
85779 END IF;
85780 --
85781
85782 --
85783 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
85784 trace
85785 (p_msg => 'END of AcctLineType_174'
85786 ,p_level => C_LEVEL_PROCEDURE
85787 ,p_module => l_log_module);
85788 END IF;
85789 --
85790 EXCEPTION
85791 WHEN xla_exceptions_pkg.application_exception THEN
85792 RAISE;
85793 WHEN OTHERS THEN
85794 xla_exceptions_pkg.raise_message
85795 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_174');
85796 END AcctLineType_174;
85797 --
85798
85799 ---------------------------------------
85800 --
85801 -- PRIVATE FUNCTION
85802 -- AcctLineType_175
85803 --
85804 ---------------------------------------
85805 PROCEDURE AcctLineType_175 (
85806 p_application_id IN NUMBER
85807 ,p_event_id IN NUMBER
85808 ,p_calculate_acctd_flag IN VARCHAR2
85809 ,p_calculate_g_l_flag IN VARCHAR2
85810 ,p_actual_flag IN OUT VARCHAR2
85811 ,p_balance_type_code OUT VARCHAR2
85812 ,p_gain_or_loss_ref OUT VARCHAR2
85813
85814 --TRANSACTION_ID
85815 , p_source_1 IN NUMBER
85816 --Item Concatenated Segments
85817 , p_source_2 IN VARCHAR2
85818 --Transaction Quantity
85819 , p_source_3 IN NUMBER
85820 --Transaction Unit of Measure Code
85821 , p_source_4 IN VARCHAR2
85822 --Inventory Transaction Type Description
85823 , p_source_5 IN VARCHAR2
85824 --Cost Management Default Account
85825 , p_source_11 IN NUMBER
85826 --DISTRIBUTION_IDENTIFIER
85827 , p_source_84 IN NUMBER
85828 --Distribution Type
85829 , p_source_85 IN VARCHAR2
85830 , p_source_85_meaning IN VARCHAR2
85831 --Entered Currency Code
85832 , p_source_88 IN VARCHAR2
85833 --Entered Amount
85834 , p_source_91 IN NUMBER
85835 --Currency Conversion Date
85836 , p_source_92 IN DATE
85837 --Currency Conversion Rate
85838 , p_source_93 IN NUMBER
85839 --Currency Conversion Type
85840 , p_source_94 IN VARCHAR2
85841 --Accounted Amount
85842 , p_source_95 IN NUMBER
85843 --Accounting Line Type
85844 , p_source_97 IN NUMBER
85845 )
85846 IS
85847
85848 l_component_type VARCHAR2(80);
85849 l_component_code VARCHAR2(30);
85850 l_component_type_code VARCHAR2(1);
85851 l_component_appl_id INTEGER;
85852 l_amb_context_code VARCHAR2(30);
85853 l_entity_code VARCHAR2(30);
85854 l_event_class_code VARCHAR2(30);
85855 l_ae_header_id NUMBER;
85856 l_event_type_code VARCHAR2(30);
85857 l_line_definition_code VARCHAR2(30);
85858 l_line_definition_owner_code VARCHAR2(1);
85859 --
85860 -- adr variables
85861 l_segment VARCHAR2(30);
85862 l_ccid NUMBER;
85863 l_adr_transaction_coa_id NUMBER;
85864 l_adr_accounting_coa_id NUMBER;
85865 l_adr_flexfield_segment_code VARCHAR2(30);
85866 l_adr_flex_value_set_id NUMBER;
85867 l_adr_value_type_code VARCHAR2(30);
85868 l_adr_value_combination_id NUMBER;
85869 l_adr_value_segment_code VARCHAR2(30);
85870
85871 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
85872 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
85873 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
85874 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
85875
85876 -- 4262811 Variables ------------------------------------------------------------------------------------------
85877 l_entered_amt_idx NUMBER;
85878 l_accted_amt_idx NUMBER;
85879 l_acc_rev_flag VARCHAR2(1);
85880 l_accrual_line_num NUMBER;
85881 l_tmp_amt NUMBER;
85882 l_acc_rev_natural_side_code VARCHAR2(1);
85883
85884 l_num_entries NUMBER;
85885 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
85886 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
85887 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
85888 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
85889 l_recog_line_1 NUMBER;
85890 l_recog_line_2 NUMBER;
85891
85892 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
85893 l_bflow_applied_to_amt NUMBER; -- 5132302
85894 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
85895
85896 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
85897
85898 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
85899 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
85900
85901 ---------------------------------------------------------------------------------------------------------------
85902
85903
85904 --
85905 -- bulk performance
85906 --
85907 l_balance_type_code VARCHAR2(1);
85908 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
85909 l_log_module VARCHAR2(240);
85910
85911 --
85912 -- Upgrade strategy
85913 --
85914 l_actual_upg_option VARCHAR2(1);
85915 l_enc_upg_option VARCHAR2(1);
85916
85917 --
85918 BEGIN
85919 --
85920 IF g_log_enabled THEN
85921 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_175';
85922 END IF;
85923 --
85924 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
85925
85926 trace
85927 (p_msg => 'BEGIN of AcctLineType_175'
85928 ,p_level => C_LEVEL_PROCEDURE
85929 ,p_module => l_log_module);
85930
85931 END IF;
85932 --
85933 l_component_type := 'AMB_JLT';
85934 l_component_code := 'INTERORG_PROFIT_OPM';
85935 l_component_type_code := 'S';
85936 l_component_appl_id := 707;
85937 l_amb_context_code := 'DEFAULT';
85938 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
85939 l_event_class_code := 'USER_DEFINE';
85940 l_event_type_code := 'UDIR_INTERORG_SHIP';
85941 l_line_definition_owner_code := 'S';
85942 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
85943 --
85944 l_balance_type_code := 'A';
85945 l_segment := NULL;
85946 l_ccid := NULL;
85947 l_adr_transaction_coa_id := NULL;
85948 l_adr_accounting_coa_id := NULL;
85949 l_adr_flexfield_segment_code := NULL;
85950 l_adr_flex_value_set_id := NULL;
85951 l_adr_value_type_code := NULL;
85952 l_adr_value_combination_id := NULL;
85953 l_adr_value_segment_code := NULL;
85954
85955 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
85956 l_bflow_class_code := ''; -- 4219869 Business Flow
85957 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
85958 l_budgetary_control_flag := 'N';
85959
85960 l_bflow_applied_to_amt_idx := NULL; -- 5132302
85961 l_bflow_applied_to_amt := NULL; -- 5132302
85962 l_entered_amt_idx := NULL; -- 4262811
85963 l_accted_amt_idx := NULL; -- 4262811
85964 l_acc_rev_flag := NULL; -- 4262811
85965 l_accrual_line_num := NULL; -- 4262811
85966 l_tmp_amt := NULL; -- 4262811
85967 --
85968
85969 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
85970 l_balance_type_code <> 'B' THEN
85971 IF NVL(p_source_97,9E125) = 34
85972 THEN
85973
85974 --
85975 XLA_AE_LINES_PKG.SetNewLine;
85976
85977 p_balance_type_code := l_balance_type_code;
85978 -- set the flag so later we will know whether the gain loss line needs to be created
85979
85980 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
85981 p_actual_flag :='A';
85982 END IF;
85983
85984 --
85985 -- bulk performance
85986 --
85987 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
85988 p_header_num => 0); -- 4262811
85989 --
85990 -- set accounting line options
85991 --
85992 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
85993 p_natural_side_code => 'D'
85994 , p_gain_or_loss_flag => 'N'
85995 , p_gl_transfer_mode_code => 'S'
85996 , p_acct_entry_type_code => 'A'
85997 , p_switch_side_flag => 'Y'
85998 , p_merge_duplicate_code => 'N'
85999 );
86000 --
86001 l_acc_rev_natural_side_code := 'C'; -- 4262811
86002 --
86003 --
86004 -- set accounting line type info
86005 --
86006 xla_ae_lines_pkg.SetAcctLineType
86007 (p_component_type => l_component_type
86008 ,p_event_type_code => l_event_type_code
86009 ,p_line_definition_owner_code => l_line_definition_owner_code
86010 ,p_line_definition_code => l_line_definition_code
86011 ,p_accounting_line_code => l_component_code
86012 ,p_accounting_line_type_code => l_component_type_code
86013 ,p_accounting_line_appl_id => l_component_appl_id
86014 ,p_amb_context_code => l_amb_context_code
86015 ,p_entity_code => l_entity_code
86016 ,p_event_class_code => l_event_class_code);
86017 --
86018 -- set accounting class
86019 --
86020 xla_ae_lines_pkg.SetAcctClass(
86021 p_accounting_class_code => 'INTERORG_PROFIT'
86022 , p_ae_header_id => l_ae_header_id
86023 );
86024
86025 --
86026 -- set rounding class
86027 --
86028 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
86029 'INTERORG_PROFIT';
86030
86031 --
86032 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
86033 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
86034 --
86035 -- bulk performance
86036 --
86037 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
86038
86039 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
86040 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
86041
86042 -- 4955764
86043 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
86044 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
86045
86046 -- 4458381 Public Sector Enh
86047
86048 --
86049 -- set accounting attributes for the line type
86050 --
86051 l_entered_amt_idx := 3;
86052 l_accted_amt_idx := 8;
86053 l_bflow_applied_to_amt_idx := NULL; -- 5132302
86054 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
86055 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
86056 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
86057 l_rec_acct_attrs.array_char_value(2) := p_source_85;
86058 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
86059 l_rec_acct_attrs.array_num_value(3) := p_source_91;
86060 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
86061 l_rec_acct_attrs.array_char_value(4) := p_source_88;
86062 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
86063 l_rec_acct_attrs.array_date_value(5) := p_source_92;
86064 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
86065 l_rec_acct_attrs.array_num_value(6) := p_source_93;
86066 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
86067 l_rec_acct_attrs.array_char_value(7) := p_source_94;
86068 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
86069 l_rec_acct_attrs.array_num_value(8) := p_source_95;
86070
86071 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
86072 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
86073
86074 ---------------------------------------------------------------------------------------------------------------
86075 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
86076 ---------------------------------------------------------------------------------------------------------------
86077 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
86078
86079 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
86080 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
86081
86082 IF xla_accounting_cache_pkg.GetValueChar
86083 (p_source_code => 'LEDGER_CATEGORY_CODE'
86084 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
86085 AND l_bflow_method_code = 'PRIOR_ENTRY'
86086 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
86087 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
86088 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
86089 )
86090 THEN
86091 xla_ae_lines_pkg.BflowUpgEntry
86092 (p_business_method_code => l_bflow_method_code
86093 ,p_business_class_code => l_bflow_class_code
86094 ,p_balance_type => l_balance_type_code);
86095 ELSE
86096 NULL;
86097 -- No business flow processing for business flow method of NONE.
86098 END IF;
86099
86100 --
86101 -- call analytical criteria
86102 --
86103
86104 --
86105 -- call description
86106 --
86107
86108 xla_ae_lines_pkg.SetLineDescription(
86109 p_ae_header_id => l_ae_header_id
86110 ,p_description => Description_1 (
86111 p_application_id => p_application_id
86112 , p_ae_header_id => l_ae_header_id
86113 , p_source_1 => p_source_1
86114 , p_source_2 => p_source_2
86115 , p_source_3 => p_source_3
86116 , p_source_4 => p_source_4
86117 , p_source_5 => p_source_5
86118 )
86119 );
86120
86121
86122 --
86123 -- call ADRs
86124 -- Bug 4922099
86125 --
86126 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
86127 (NVL(l_actual_upg_option, 'N') = 'O') OR
86128 (NVL(l_enc_upg_option, 'N') = 'O')
86129 )
86130 THEN
86131 NULL;
86132 --
86133 --
86134
86135 l_ccid := AcctDerRule_6(
86136 p_application_id => p_application_id
86137 , p_ae_header_id => l_ae_header_id
86138 , p_source_11 => p_source_11
86139 , x_transaction_coa_id => l_adr_transaction_coa_id
86140 , x_accounting_coa_id => l_adr_accounting_coa_id
86141 , x_value_type_code => l_adr_value_type_code
86142 , p_side => 'NA'
86143 );
86144
86145 xla_ae_lines_pkg.set_ccid(
86146 p_code_combination_id => l_ccid
86147 , p_value_type_code => l_adr_value_type_code
86148 , p_transaction_coa_id => l_adr_transaction_coa_id
86149 , p_accounting_coa_id => l_adr_accounting_coa_id
86150 , p_adr_code => 'CST_DEFAULT'
86151 , p_adr_type_code => 'S'
86152 , p_component_type => l_component_type
86153 , p_component_code => l_component_code
86154 , p_component_type_code => l_component_type_code
86155 , p_component_appl_id => l_component_appl_id
86156 , p_amb_context_code => l_amb_context_code
86157 , p_side => 'NA'
86158 );
86159
86160
86161 --
86162 --
86163 END IF;
86164 --
86165 -- Bug 4922099
86166 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
86167 (NVL(l_enc_upg_option, 'N') = 'O')
86168 ) AND
86169 (l_bflow_method_code = 'PRIOR_ENTRY')
86170 )
86171 THEN
86172 IF
86173 --
86174 1 = 2
86175 --
86176 THEN
86177 xla_accounting_err_pkg.build_message
86178 (p_appli_s_name => 'XLA'
86179 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
86180 ,p_token_1 => 'LINE_NUMBER'
86181 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
86182 ,p_token_2 => 'LINE_TYPE_NAME'
86183 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
86184 l_component_type
86185 ,l_component_code
86186 ,l_component_type_code
86187 ,l_component_appl_id
86188 ,l_amb_context_code
86189 ,l_entity_code
86190 ,l_event_class_code
86191 )
86192 ,p_token_3 => 'OWNER'
86193 ,p_value_3 => xla_lookups_pkg.get_meaning(
86194 p_lookup_type => 'XLA_OWNER_TYPE'
86195 ,p_lookup_code => l_component_type_code
86196 )
86197 ,p_token_4 => 'PRODUCT_NAME'
86198 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
86199 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
86200 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
86201 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
86202 ,p_ae_header_id => NULL
86203 );
86204
86205 IF (C_LEVEL_ERROR>= g_log_level) THEN
86206 trace
86207 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
86208 ,p_level => C_LEVEL_ERROR
86209 ,p_module => l_log_module);
86210 END IF;
86211 END IF;
86212 END IF;
86213 --
86214 --
86215 ------------------------------------------------------------------------------------------------
86216 -- 4219869 Business Flow
86217 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
86218 -- Prior Entry. Currently, the following code is always generated.
86219 ------------------------------------------------------------------------------------------------
86220 XLA_AE_LINES_PKG.ValidateCurrentLine;
86221
86222 ------------------------------------------------------------------------------------
86223 -- 4219869 Business Flow
86224 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
86225 ------------------------------------------------------------------------------------
86226 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
86227
86228 ----------------------------------------------------------------------------------
86229 -- 4219869 Business Flow
86230 -- Update journal entry status -- Need to generate this within IF <condition>
86231 ----------------------------------------------------------------------------------
86232 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
86233 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
86234 ,p_balance_type_code => l_balance_type_code
86235 );
86236
86237 -------------------------------------------------------------------------------------------
86238 -- 4262811 - Generate the Accrual Reversal lines
86239 -------------------------------------------------------------------------------------------
86240 BEGIN
86241 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
86242 (g_array_event(p_event_id).array_value_num('header_index'));
86243 IF l_acc_rev_flag IS NULL THEN
86244 l_acc_rev_flag := 'N';
86245 END IF;
86246 EXCEPTION
86247 WHEN OTHERS THEN
86248 l_acc_rev_flag := 'N';
86249 END;
86250 --
86251 IF (l_acc_rev_flag = 'Y') THEN
86252
86253 -- 4645092 ------------------------------------------------------------------------------
86254 -- To allow MPA report to determine if it should generate report process
86255 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
86256 ------------------------------------------------------------------------------------------
86257
86258 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
86259 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
86260 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
86261 -- call ADRs
86262 -- Bug 4922099
86263 --
86264 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
86265 (NVL(l_actual_upg_option, 'N') = 'O') OR
86266 (NVL(l_enc_upg_option, 'N') = 'O')
86267 )
86268 THEN
86269 NULL;
86270 --
86271 --
86272
86273 l_ccid := AcctDerRule_6(
86274 p_application_id => p_application_id
86275 , p_ae_header_id => l_ae_header_id
86276 , p_source_11 => p_source_11
86277 , x_transaction_coa_id => l_adr_transaction_coa_id
86278 , x_accounting_coa_id => l_adr_accounting_coa_id
86279 , x_value_type_code => l_adr_value_type_code
86280 , p_side => 'NA'
86281 );
86282
86283 xla_ae_lines_pkg.set_ccid(
86284 p_code_combination_id => l_ccid
86285 , p_value_type_code => l_adr_value_type_code
86286 , p_transaction_coa_id => l_adr_transaction_coa_id
86287 , p_accounting_coa_id => l_adr_accounting_coa_id
86288 , p_adr_code => 'CST_DEFAULT'
86289 , p_adr_type_code => 'S'
86290 , p_component_type => l_component_type
86291 , p_component_code => l_component_code
86292 , p_component_type_code => l_component_type_code
86293 , p_component_appl_id => l_component_appl_id
86294 , p_amb_context_code => l_amb_context_code
86295 , p_side => 'NA'
86296 );
86297
86298
86299 --
86300 --
86301 END IF;
86302
86303 --
86304 -- Update the line information that should be overwritten
86305 --
86306 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
86307 p_header_num => 1);
86308 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
86309
86310 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
86311
86312 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
86313 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
86314 END IF;
86315
86316 --
86317 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
86318 --
86319 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
86320 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
86321 ELSE
86322 ---------------------------------------------------------------------------------------------------
86323 -- 4262811a Switch Sign
86324 ---------------------------------------------------------------------------------------------------
86325 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
86326 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
86327 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86328 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
86329 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86330 -- 5132302
86331 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
86332 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86333
86334 END IF;
86335
86336 -- 4955764
86337 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
86338 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
86339
86340
86341 XLA_AE_LINES_PKG.ValidateCurrentLine;
86342 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
86343
86344 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
86345 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
86346 ,p_balance_type_code => l_balance_type_code);
86347
86348 END IF;
86349
86350 -----------------------------------------------------------------------------------------
86351 -- 4262811 Multiperiod Accounting
86352 -----------------------------------------------------------------------------------------
86353 -- No MPA option is assigned.
86354
86355
86356 END IF;
86357 END IF;
86358 --
86359
86360 --
86361 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
86362 trace
86363 (p_msg => 'END of AcctLineType_175'
86364 ,p_level => C_LEVEL_PROCEDURE
86365 ,p_module => l_log_module);
86366 END IF;
86367 --
86368 EXCEPTION
86369 WHEN xla_exceptions_pkg.application_exception THEN
86370 RAISE;
86371 WHEN OTHERS THEN
86372 xla_exceptions_pkg.raise_message
86373 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_175');
86374 END AcctLineType_175;
86375 --
86376
86377 ---------------------------------------
86378 --
86379 -- PRIVATE FUNCTION
86380 -- AcctLineType_176
86381 --
86382 ---------------------------------------
86383 PROCEDURE AcctLineType_176 (
86384 p_application_id IN NUMBER
86385 ,p_event_id IN NUMBER
86386 ,p_calculate_acctd_flag IN VARCHAR2
86387 ,p_calculate_g_l_flag IN VARCHAR2
86388 ,p_actual_flag IN OUT VARCHAR2
86389 ,p_balance_type_code OUT VARCHAR2
86390 ,p_gain_or_loss_ref OUT VARCHAR2
86391
86392 --TRANSACTION_ID
86393 , p_source_1 IN NUMBER
86394 --Item Concatenated Segments
86395 , p_source_2 IN VARCHAR2
86396 --Transaction Quantity
86397 , p_source_3 IN NUMBER
86398 --Transaction Unit of Measure Code
86399 , p_source_4 IN VARCHAR2
86400 --Inventory Transaction Type Description
86401 , p_source_5 IN VARCHAR2
86402 --Cost Management Default Account
86403 , p_source_11 IN NUMBER
86404 --DISTRIBUTION_IDENTIFIER
86405 , p_source_84 IN NUMBER
86406 --Distribution Type
86407 , p_source_85 IN VARCHAR2
86408 , p_source_85_meaning IN VARCHAR2
86409 --Entered Currency Code
86410 , p_source_88 IN VARCHAR2
86411 --Entered Amount
86412 , p_source_91 IN NUMBER
86413 --Currency Conversion Date
86414 , p_source_92 IN DATE
86415 --Currency Conversion Rate
86416 , p_source_93 IN NUMBER
86417 --Currency Conversion Type
86418 , p_source_94 IN VARCHAR2
86419 --Accounted Amount
86420 , p_source_95 IN NUMBER
86421 --Accounting Line Type
86422 , p_source_97 IN NUMBER
86423 )
86424 IS
86425
86426 l_component_type VARCHAR2(80);
86427 l_component_code VARCHAR2(30);
86428 l_component_type_code VARCHAR2(1);
86429 l_component_appl_id INTEGER;
86430 l_amb_context_code VARCHAR2(30);
86431 l_entity_code VARCHAR2(30);
86432 l_event_class_code VARCHAR2(30);
86433 l_ae_header_id NUMBER;
86434 l_event_type_code VARCHAR2(30);
86435 l_line_definition_code VARCHAR2(30);
86436 l_line_definition_owner_code VARCHAR2(1);
86437 --
86438 -- adr variables
86439 l_segment VARCHAR2(30);
86440 l_ccid NUMBER;
86441 l_adr_transaction_coa_id NUMBER;
86442 l_adr_accounting_coa_id NUMBER;
86443 l_adr_flexfield_segment_code VARCHAR2(30);
86444 l_adr_flex_value_set_id NUMBER;
86445 l_adr_value_type_code VARCHAR2(30);
86446 l_adr_value_combination_id NUMBER;
86447 l_adr_value_segment_code VARCHAR2(30);
86448
86449 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
86450 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
86451 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
86452 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
86453
86454 -- 4262811 Variables ------------------------------------------------------------------------------------------
86455 l_entered_amt_idx NUMBER;
86456 l_accted_amt_idx NUMBER;
86457 l_acc_rev_flag VARCHAR2(1);
86458 l_accrual_line_num NUMBER;
86459 l_tmp_amt NUMBER;
86460 l_acc_rev_natural_side_code VARCHAR2(1);
86461
86462 l_num_entries NUMBER;
86463 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
86464 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
86465 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
86466 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
86467 l_recog_line_1 NUMBER;
86468 l_recog_line_2 NUMBER;
86469
86470 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
86471 l_bflow_applied_to_amt NUMBER; -- 5132302
86472 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
86473
86474 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
86475
86476 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
86477 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
86478
86479 ---------------------------------------------------------------------------------------------------------------
86480
86481
86482 --
86483 -- bulk performance
86484 --
86485 l_balance_type_code VARCHAR2(1);
86486 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
86487 l_log_module VARCHAR2(240);
86488
86489 --
86490 -- Upgrade strategy
86491 --
86492 l_actual_upg_option VARCHAR2(1);
86493 l_enc_upg_option VARCHAR2(1);
86494
86495 --
86496 BEGIN
86497 --
86498 IF g_log_enabled THEN
86499 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_176';
86500 END IF;
86501 --
86502 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
86503
86504 trace
86505 (p_msg => 'BEGIN of AcctLineType_176'
86506 ,p_level => C_LEVEL_PROCEDURE
86507 ,p_module => l_log_module);
86508
86509 END IF;
86510 --
86511 l_component_type := 'AMB_JLT';
86512 l_component_code := 'INTERORG_PROFIT_OPM';
86513 l_component_type_code := 'S';
86514 l_component_appl_id := 707;
86515 l_amb_context_code := 'DEFAULT';
86516 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
86517 l_event_class_code := 'USER_DEFINE';
86518 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
86519 l_line_definition_owner_code := 'S';
86520 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
86521 --
86522 l_balance_type_code := 'A';
86523 l_segment := NULL;
86524 l_ccid := NULL;
86525 l_adr_transaction_coa_id := NULL;
86526 l_adr_accounting_coa_id := NULL;
86527 l_adr_flexfield_segment_code := NULL;
86528 l_adr_flex_value_set_id := NULL;
86529 l_adr_value_type_code := NULL;
86530 l_adr_value_combination_id := NULL;
86531 l_adr_value_segment_code := NULL;
86532
86533 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
86534 l_bflow_class_code := ''; -- 4219869 Business Flow
86535 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
86536 l_budgetary_control_flag := 'N';
86537
86538 l_bflow_applied_to_amt_idx := NULL; -- 5132302
86539 l_bflow_applied_to_amt := NULL; -- 5132302
86540 l_entered_amt_idx := NULL; -- 4262811
86541 l_accted_amt_idx := NULL; -- 4262811
86542 l_acc_rev_flag := NULL; -- 4262811
86543 l_accrual_line_num := NULL; -- 4262811
86544 l_tmp_amt := NULL; -- 4262811
86545 --
86546
86547 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
86548 l_balance_type_code <> 'B' THEN
86549 IF NVL(p_source_97,9E125) = 34
86550 THEN
86551
86552 --
86553 XLA_AE_LINES_PKG.SetNewLine;
86554
86555 p_balance_type_code := l_balance_type_code;
86556 -- set the flag so later we will know whether the gain loss line needs to be created
86557
86558 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
86559 p_actual_flag :='A';
86560 END IF;
86561
86562 --
86563 -- bulk performance
86564 --
86565 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
86566 p_header_num => 0); -- 4262811
86567 --
86568 -- set accounting line options
86569 --
86570 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
86571 p_natural_side_code => 'D'
86572 , p_gain_or_loss_flag => 'N'
86573 , p_gl_transfer_mode_code => 'S'
86574 , p_acct_entry_type_code => 'A'
86575 , p_switch_side_flag => 'Y'
86576 , p_merge_duplicate_code => 'N'
86577 );
86578 --
86579 l_acc_rev_natural_side_code := 'C'; -- 4262811
86580 --
86581 --
86582 -- set accounting line type info
86583 --
86584 xla_ae_lines_pkg.SetAcctLineType
86585 (p_component_type => l_component_type
86586 ,p_event_type_code => l_event_type_code
86587 ,p_line_definition_owner_code => l_line_definition_owner_code
86588 ,p_line_definition_code => l_line_definition_code
86589 ,p_accounting_line_code => l_component_code
86590 ,p_accounting_line_type_code => l_component_type_code
86591 ,p_accounting_line_appl_id => l_component_appl_id
86592 ,p_amb_context_code => l_amb_context_code
86593 ,p_entity_code => l_entity_code
86594 ,p_event_class_code => l_event_class_code);
86595 --
86596 -- set accounting class
86597 --
86598 xla_ae_lines_pkg.SetAcctClass(
86599 p_accounting_class_code => 'INTERORG_PROFIT'
86600 , p_ae_header_id => l_ae_header_id
86601 );
86602
86603 --
86604 -- set rounding class
86605 --
86606 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
86607 'INTERORG_PROFIT';
86608
86609 --
86610 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
86611 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
86612 --
86613 -- bulk performance
86614 --
86615 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
86616
86617 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
86618 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
86619
86620 -- 4955764
86621 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
86622 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
86623
86624 -- 4458381 Public Sector Enh
86625
86626 --
86627 -- set accounting attributes for the line type
86628 --
86629 l_entered_amt_idx := 3;
86630 l_accted_amt_idx := 8;
86631 l_bflow_applied_to_amt_idx := NULL; -- 5132302
86632 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
86633 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
86634 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
86635 l_rec_acct_attrs.array_char_value(2) := p_source_85;
86636 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
86637 l_rec_acct_attrs.array_num_value(3) := p_source_91;
86638 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
86639 l_rec_acct_attrs.array_char_value(4) := p_source_88;
86640 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
86641 l_rec_acct_attrs.array_date_value(5) := p_source_92;
86642 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
86643 l_rec_acct_attrs.array_num_value(6) := p_source_93;
86644 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
86645 l_rec_acct_attrs.array_char_value(7) := p_source_94;
86646 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
86647 l_rec_acct_attrs.array_num_value(8) := p_source_95;
86648
86649 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
86650 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
86651
86652 ---------------------------------------------------------------------------------------------------------------
86653 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
86654 ---------------------------------------------------------------------------------------------------------------
86655 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
86656
86657 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
86658 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
86659
86660 IF xla_accounting_cache_pkg.GetValueChar
86661 (p_source_code => 'LEDGER_CATEGORY_CODE'
86662 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
86663 AND l_bflow_method_code = 'PRIOR_ENTRY'
86664 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
86665 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
86666 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
86667 )
86668 THEN
86669 xla_ae_lines_pkg.BflowUpgEntry
86670 (p_business_method_code => l_bflow_method_code
86671 ,p_business_class_code => l_bflow_class_code
86672 ,p_balance_type => l_balance_type_code);
86673 ELSE
86674 NULL;
86675 -- No business flow processing for business flow method of NONE.
86676 END IF;
86677
86678 --
86679 -- call analytical criteria
86680 --
86681
86682 --
86683 -- call description
86684 --
86685
86686 xla_ae_lines_pkg.SetLineDescription(
86687 p_ae_header_id => l_ae_header_id
86688 ,p_description => Description_1 (
86689 p_application_id => p_application_id
86690 , p_ae_header_id => l_ae_header_id
86691 , p_source_1 => p_source_1
86692 , p_source_2 => p_source_2
86693 , p_source_3 => p_source_3
86694 , p_source_4 => p_source_4
86695 , p_source_5 => p_source_5
86696 )
86697 );
86698
86699
86700 --
86701 -- call ADRs
86702 -- Bug 4922099
86703 --
86704 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
86705 (NVL(l_actual_upg_option, 'N') = 'O') OR
86706 (NVL(l_enc_upg_option, 'N') = 'O')
86707 )
86708 THEN
86709 NULL;
86710 --
86711 --
86712
86713 l_ccid := AcctDerRule_6(
86714 p_application_id => p_application_id
86715 , p_ae_header_id => l_ae_header_id
86716 , p_source_11 => p_source_11
86717 , x_transaction_coa_id => l_adr_transaction_coa_id
86718 , x_accounting_coa_id => l_adr_accounting_coa_id
86719 , x_value_type_code => l_adr_value_type_code
86720 , p_side => 'NA'
86721 );
86722
86723 xla_ae_lines_pkg.set_ccid(
86724 p_code_combination_id => l_ccid
86725 , p_value_type_code => l_adr_value_type_code
86726 , p_transaction_coa_id => l_adr_transaction_coa_id
86727 , p_accounting_coa_id => l_adr_accounting_coa_id
86728 , p_adr_code => 'CST_DEFAULT'
86729 , p_adr_type_code => 'S'
86730 , p_component_type => l_component_type
86731 , p_component_code => l_component_code
86732 , p_component_type_code => l_component_type_code
86733 , p_component_appl_id => l_component_appl_id
86734 , p_amb_context_code => l_amb_context_code
86735 , p_side => 'NA'
86736 );
86737
86738
86739 --
86740 --
86741 END IF;
86742 --
86743 -- Bug 4922099
86744 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
86745 (NVL(l_enc_upg_option, 'N') = 'O')
86746 ) AND
86747 (l_bflow_method_code = 'PRIOR_ENTRY')
86748 )
86749 THEN
86750 IF
86751 --
86752 1 = 2
86753 --
86754 THEN
86755 xla_accounting_err_pkg.build_message
86756 (p_appli_s_name => 'XLA'
86757 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
86758 ,p_token_1 => 'LINE_NUMBER'
86759 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
86760 ,p_token_2 => 'LINE_TYPE_NAME'
86761 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
86762 l_component_type
86763 ,l_component_code
86764 ,l_component_type_code
86765 ,l_component_appl_id
86766 ,l_amb_context_code
86767 ,l_entity_code
86768 ,l_event_class_code
86769 )
86770 ,p_token_3 => 'OWNER'
86771 ,p_value_3 => xla_lookups_pkg.get_meaning(
86772 p_lookup_type => 'XLA_OWNER_TYPE'
86773 ,p_lookup_code => l_component_type_code
86774 )
86775 ,p_token_4 => 'PRODUCT_NAME'
86776 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
86777 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
86778 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
86779 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
86780 ,p_ae_header_id => NULL
86781 );
86782
86783 IF (C_LEVEL_ERROR>= g_log_level) THEN
86784 trace
86785 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
86786 ,p_level => C_LEVEL_ERROR
86787 ,p_module => l_log_module);
86788 END IF;
86789 END IF;
86790 END IF;
86791 --
86792 --
86793 ------------------------------------------------------------------------------------------------
86794 -- 4219869 Business Flow
86795 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
86796 -- Prior Entry. Currently, the following code is always generated.
86797 ------------------------------------------------------------------------------------------------
86798 XLA_AE_LINES_PKG.ValidateCurrentLine;
86799
86800 ------------------------------------------------------------------------------------
86801 -- 4219869 Business Flow
86802 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
86803 ------------------------------------------------------------------------------------
86804 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
86805
86806 ----------------------------------------------------------------------------------
86807 -- 4219869 Business Flow
86808 -- Update journal entry status -- Need to generate this within IF <condition>
86809 ----------------------------------------------------------------------------------
86810 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
86811 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
86812 ,p_balance_type_code => l_balance_type_code
86813 );
86814
86815 -------------------------------------------------------------------------------------------
86816 -- 4262811 - Generate the Accrual Reversal lines
86817 -------------------------------------------------------------------------------------------
86818 BEGIN
86819 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
86820 (g_array_event(p_event_id).array_value_num('header_index'));
86821 IF l_acc_rev_flag IS NULL THEN
86822 l_acc_rev_flag := 'N';
86823 END IF;
86824 EXCEPTION
86825 WHEN OTHERS THEN
86826 l_acc_rev_flag := 'N';
86827 END;
86828 --
86829 IF (l_acc_rev_flag = 'Y') THEN
86830
86831 -- 4645092 ------------------------------------------------------------------------------
86832 -- To allow MPA report to determine if it should generate report process
86833 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
86834 ------------------------------------------------------------------------------------------
86835
86836 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
86837 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
86838 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
86839 -- call ADRs
86840 -- Bug 4922099
86841 --
86842 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
86843 (NVL(l_actual_upg_option, 'N') = 'O') OR
86844 (NVL(l_enc_upg_option, 'N') = 'O')
86845 )
86846 THEN
86847 NULL;
86848 --
86849 --
86850
86851 l_ccid := AcctDerRule_6(
86852 p_application_id => p_application_id
86853 , p_ae_header_id => l_ae_header_id
86854 , p_source_11 => p_source_11
86855 , x_transaction_coa_id => l_adr_transaction_coa_id
86856 , x_accounting_coa_id => l_adr_accounting_coa_id
86857 , x_value_type_code => l_adr_value_type_code
86858 , p_side => 'NA'
86859 );
86860
86861 xla_ae_lines_pkg.set_ccid(
86862 p_code_combination_id => l_ccid
86863 , p_value_type_code => l_adr_value_type_code
86864 , p_transaction_coa_id => l_adr_transaction_coa_id
86865 , p_accounting_coa_id => l_adr_accounting_coa_id
86866 , p_adr_code => 'CST_DEFAULT'
86867 , p_adr_type_code => 'S'
86868 , p_component_type => l_component_type
86869 , p_component_code => l_component_code
86870 , p_component_type_code => l_component_type_code
86871 , p_component_appl_id => l_component_appl_id
86872 , p_amb_context_code => l_amb_context_code
86873 , p_side => 'NA'
86874 );
86875
86876
86877 --
86878 --
86879 END IF;
86880
86881 --
86882 -- Update the line information that should be overwritten
86883 --
86884 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
86885 p_header_num => 1);
86886 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
86887
86888 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
86889
86890 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
86891 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
86892 END IF;
86893
86894 --
86895 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
86896 --
86897 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
86898 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
86899 ELSE
86900 ---------------------------------------------------------------------------------------------------
86901 -- 4262811a Switch Sign
86902 ---------------------------------------------------------------------------------------------------
86903 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
86904 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
86905 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86906 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
86907 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86908 -- 5132302
86909 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
86910 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
86911
86912 END IF;
86913
86914 -- 4955764
86915 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
86916 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
86917
86918
86919 XLA_AE_LINES_PKG.ValidateCurrentLine;
86920 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
86921
86922 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
86923 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
86924 ,p_balance_type_code => l_balance_type_code);
86925
86926 END IF;
86927
86928 -----------------------------------------------------------------------------------------
86929 -- 4262811 Multiperiod Accounting
86930 -----------------------------------------------------------------------------------------
86931 -- No MPA option is assigned.
86932
86933
86934 END IF;
86935 END IF;
86936 --
86937
86938 --
86939 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
86940 trace
86941 (p_msg => 'END of AcctLineType_176'
86942 ,p_level => C_LEVEL_PROCEDURE
86943 ,p_module => l_log_module);
86944 END IF;
86945 --
86946 EXCEPTION
86947 WHEN xla_exceptions_pkg.application_exception THEN
86948 RAISE;
86949 WHEN OTHERS THEN
86950 xla_exceptions_pkg.raise_message
86951 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_176');
86952 END AcctLineType_176;
86953 --
86954
86955 ---------------------------------------
86956 --
86957 -- PRIVATE FUNCTION
86958 -- AcctLineType_177
86959 --
86960 ---------------------------------------
86961 PROCEDURE AcctLineType_177 (
86962 p_application_id IN NUMBER
86963 ,p_event_id IN NUMBER
86964 ,p_calculate_acctd_flag IN VARCHAR2
86965 ,p_calculate_g_l_flag IN VARCHAR2
86966 ,p_actual_flag IN OUT VARCHAR2
86967 ,p_balance_type_code OUT VARCHAR2
86968 ,p_gain_or_loss_ref OUT VARCHAR2
86969
86970 --TRANSACTION_ID
86971 , p_source_1 IN NUMBER
86972 --Item Concatenated Segments
86973 , p_source_2 IN VARCHAR2
86974 --Transaction Quantity
86975 , p_source_3 IN NUMBER
86976 --Transaction Unit of Measure Code
86977 , p_source_4 IN VARCHAR2
86978 --Inventory Transaction Type Description
86979 , p_source_5 IN VARCHAR2
86980 --Cost Management Default Account
86981 , p_source_11 IN NUMBER
86982 --DISTRIBUTION_IDENTIFIER
86983 , p_source_84 IN NUMBER
86984 --Distribution Type
86985 , p_source_85 IN VARCHAR2
86986 , p_source_85_meaning IN VARCHAR2
86987 --Entered Currency Code
86988 , p_source_88 IN VARCHAR2
86989 --Entered Amount
86990 , p_source_91 IN NUMBER
86991 --Currency Conversion Date
86992 , p_source_92 IN DATE
86993 --Currency Conversion Rate
86994 , p_source_93 IN NUMBER
86995 --Currency Conversion Type
86996 , p_source_94 IN VARCHAR2
86997 --Accounted Amount
86998 , p_source_95 IN NUMBER
86999 --Accounting Line Type
87000 , p_source_97 IN NUMBER
87001 )
87002 IS
87003
87004 l_component_type VARCHAR2(80);
87005 l_component_code VARCHAR2(30);
87006 l_component_type_code VARCHAR2(1);
87007 l_component_appl_id INTEGER;
87008 l_amb_context_code VARCHAR2(30);
87009 l_entity_code VARCHAR2(30);
87010 l_event_class_code VARCHAR2(30);
87011 l_ae_header_id NUMBER;
87012 l_event_type_code VARCHAR2(30);
87013 l_line_definition_code VARCHAR2(30);
87014 l_line_definition_owner_code VARCHAR2(1);
87015 --
87016 -- adr variables
87017 l_segment VARCHAR2(30);
87018 l_ccid NUMBER;
87019 l_adr_transaction_coa_id NUMBER;
87020 l_adr_accounting_coa_id NUMBER;
87021 l_adr_flexfield_segment_code VARCHAR2(30);
87022 l_adr_flex_value_set_id NUMBER;
87023 l_adr_value_type_code VARCHAR2(30);
87024 l_adr_value_combination_id NUMBER;
87025 l_adr_value_segment_code VARCHAR2(30);
87026
87027 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
87028 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
87029 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
87030 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
87031
87032 -- 4262811 Variables ------------------------------------------------------------------------------------------
87033 l_entered_amt_idx NUMBER;
87034 l_accted_amt_idx NUMBER;
87035 l_acc_rev_flag VARCHAR2(1);
87036 l_accrual_line_num NUMBER;
87037 l_tmp_amt NUMBER;
87038 l_acc_rev_natural_side_code VARCHAR2(1);
87039
87040 l_num_entries NUMBER;
87041 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
87042 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
87043 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
87044 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
87045 l_recog_line_1 NUMBER;
87046 l_recog_line_2 NUMBER;
87047
87048 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
87049 l_bflow_applied_to_amt NUMBER; -- 5132302
87050 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
87051
87052 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
87053
87054 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
87055 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
87056
87057 ---------------------------------------------------------------------------------------------------------------
87058
87059
87060 --
87061 -- bulk performance
87062 --
87063 l_balance_type_code VARCHAR2(1);
87064 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
87065 l_log_module VARCHAR2(240);
87066
87067 --
87068 -- Upgrade strategy
87069 --
87070 l_actual_upg_option VARCHAR2(1);
87071 l_enc_upg_option VARCHAR2(1);
87072
87073 --
87074 BEGIN
87075 --
87076 IF g_log_enabled THEN
87077 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_177';
87078 END IF;
87079 --
87080 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
87081
87082 trace
87083 (p_msg => 'BEGIN of AcctLineType_177'
87084 ,p_level => C_LEVEL_PROCEDURE
87085 ,p_module => l_log_module);
87086
87087 END IF;
87088 --
87089 l_component_type := 'AMB_JLT';
87090 l_component_code := 'INTERORG_PROFIT_OPM';
87091 l_component_type_code := 'S';
87092 l_component_appl_id := 707;
87093 l_amb_context_code := 'DEFAULT';
87094 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
87095 l_event_class_code := 'INT_ORDER_TO_EXP';
87096 l_event_type_code := 'INT_ORDER_ISSUE_NO_TP';
87097 l_line_definition_owner_code := 'S';
87098 l_line_definition_code := 'PI_INT_ORDER_ISSUE_NO_TP';
87099 --
87100 l_balance_type_code := 'A';
87101 l_segment := NULL;
87102 l_ccid := NULL;
87103 l_adr_transaction_coa_id := NULL;
87104 l_adr_accounting_coa_id := NULL;
87105 l_adr_flexfield_segment_code := NULL;
87106 l_adr_flex_value_set_id := NULL;
87107 l_adr_value_type_code := NULL;
87108 l_adr_value_combination_id := NULL;
87109 l_adr_value_segment_code := NULL;
87110
87111 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
87112 l_bflow_class_code := ''; -- 4219869 Business Flow
87113 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
87114 l_budgetary_control_flag := 'N';
87115
87116 l_bflow_applied_to_amt_idx := NULL; -- 5132302
87117 l_bflow_applied_to_amt := NULL; -- 5132302
87118 l_entered_amt_idx := NULL; -- 4262811
87119 l_accted_amt_idx := NULL; -- 4262811
87120 l_acc_rev_flag := NULL; -- 4262811
87121 l_accrual_line_num := NULL; -- 4262811
87122 l_tmp_amt := NULL; -- 4262811
87123 --
87124
87125 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
87126 l_balance_type_code <> 'B' THEN
87127 IF NVL(p_source_97,9E125) = 34
87128 THEN
87129
87130 --
87131 XLA_AE_LINES_PKG.SetNewLine;
87132
87133 p_balance_type_code := l_balance_type_code;
87134 -- set the flag so later we will know whether the gain loss line needs to be created
87135
87136 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
87137 p_actual_flag :='A';
87138 END IF;
87139
87140 --
87141 -- bulk performance
87142 --
87143 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
87144 p_header_num => 0); -- 4262811
87145 --
87146 -- set accounting line options
87147 --
87148 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
87149 p_natural_side_code => 'D'
87150 , p_gain_or_loss_flag => 'N'
87151 , p_gl_transfer_mode_code => 'S'
87152 , p_acct_entry_type_code => 'A'
87153 , p_switch_side_flag => 'Y'
87154 , p_merge_duplicate_code => 'N'
87155 );
87156 --
87157 l_acc_rev_natural_side_code := 'C'; -- 4262811
87158 --
87159 --
87160 -- set accounting line type info
87161 --
87162 xla_ae_lines_pkg.SetAcctLineType
87163 (p_component_type => l_component_type
87164 ,p_event_type_code => l_event_type_code
87165 ,p_line_definition_owner_code => l_line_definition_owner_code
87166 ,p_line_definition_code => l_line_definition_code
87167 ,p_accounting_line_code => l_component_code
87168 ,p_accounting_line_type_code => l_component_type_code
87169 ,p_accounting_line_appl_id => l_component_appl_id
87170 ,p_amb_context_code => l_amb_context_code
87171 ,p_entity_code => l_entity_code
87172 ,p_event_class_code => l_event_class_code);
87173 --
87174 -- set accounting class
87175 --
87176 xla_ae_lines_pkg.SetAcctClass(
87177 p_accounting_class_code => 'INTERORG_PROFIT'
87178 , p_ae_header_id => l_ae_header_id
87179 );
87180
87181 --
87182 -- set rounding class
87183 --
87184 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
87185 'INTERORG_PROFIT';
87186
87187 --
87188 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
87189 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
87190 --
87191 -- bulk performance
87192 --
87193 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
87194
87195 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
87196 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
87197
87198 -- 4955764
87199 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
87200 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
87201
87202 -- 4458381 Public Sector Enh
87203
87204 --
87205 -- set accounting attributes for the line type
87206 --
87207 l_entered_amt_idx := 3;
87208 l_accted_amt_idx := 8;
87209 l_bflow_applied_to_amt_idx := NULL; -- 5132302
87210 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
87211 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
87212 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
87213 l_rec_acct_attrs.array_char_value(2) := p_source_85;
87214 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
87215 l_rec_acct_attrs.array_num_value(3) := p_source_91;
87216 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
87217 l_rec_acct_attrs.array_char_value(4) := p_source_88;
87218 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
87219 l_rec_acct_attrs.array_date_value(5) := p_source_92;
87220 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
87221 l_rec_acct_attrs.array_num_value(6) := p_source_93;
87222 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
87223 l_rec_acct_attrs.array_char_value(7) := p_source_94;
87224 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
87225 l_rec_acct_attrs.array_num_value(8) := p_source_95;
87226
87227 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
87228 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
87229
87230 ---------------------------------------------------------------------------------------------------------------
87231 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
87232 ---------------------------------------------------------------------------------------------------------------
87233 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
87234
87235 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
87236 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
87237
87238 IF xla_accounting_cache_pkg.GetValueChar
87239 (p_source_code => 'LEDGER_CATEGORY_CODE'
87240 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
87241 AND l_bflow_method_code = 'PRIOR_ENTRY'
87242 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
87243 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
87244 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
87245 )
87246 THEN
87247 xla_ae_lines_pkg.BflowUpgEntry
87248 (p_business_method_code => l_bflow_method_code
87249 ,p_business_class_code => l_bflow_class_code
87250 ,p_balance_type => l_balance_type_code);
87251 ELSE
87252 NULL;
87253 -- No business flow processing for business flow method of NONE.
87254 END IF;
87255
87256 --
87257 -- call analytical criteria
87258 --
87259
87260 --
87261 -- call description
87262 --
87263
87264 xla_ae_lines_pkg.SetLineDescription(
87265 p_ae_header_id => l_ae_header_id
87266 ,p_description => Description_1 (
87267 p_application_id => p_application_id
87268 , p_ae_header_id => l_ae_header_id
87269 , p_source_1 => p_source_1
87270 , p_source_2 => p_source_2
87271 , p_source_3 => p_source_3
87272 , p_source_4 => p_source_4
87273 , p_source_5 => p_source_5
87274 )
87275 );
87276
87277
87278 --
87279 -- call ADRs
87280 -- Bug 4922099
87281 --
87282 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
87283 (NVL(l_actual_upg_option, 'N') = 'O') OR
87284 (NVL(l_enc_upg_option, 'N') = 'O')
87285 )
87286 THEN
87287 NULL;
87288 --
87289 --
87290
87291 l_ccid := AcctDerRule_6(
87292 p_application_id => p_application_id
87293 , p_ae_header_id => l_ae_header_id
87294 , p_source_11 => p_source_11
87295 , x_transaction_coa_id => l_adr_transaction_coa_id
87296 , x_accounting_coa_id => l_adr_accounting_coa_id
87297 , x_value_type_code => l_adr_value_type_code
87298 , p_side => 'NA'
87299 );
87300
87301 xla_ae_lines_pkg.set_ccid(
87302 p_code_combination_id => l_ccid
87303 , p_value_type_code => l_adr_value_type_code
87304 , p_transaction_coa_id => l_adr_transaction_coa_id
87305 , p_accounting_coa_id => l_adr_accounting_coa_id
87306 , p_adr_code => 'CST_DEFAULT'
87307 , p_adr_type_code => 'S'
87308 , p_component_type => l_component_type
87309 , p_component_code => l_component_code
87310 , p_component_type_code => l_component_type_code
87311 , p_component_appl_id => l_component_appl_id
87312 , p_amb_context_code => l_amb_context_code
87313 , p_side => 'NA'
87314 );
87315
87316
87317 --
87318 --
87319 END IF;
87320 --
87321 -- Bug 4922099
87322 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
87323 (NVL(l_enc_upg_option, 'N') = 'O')
87324 ) AND
87325 (l_bflow_method_code = 'PRIOR_ENTRY')
87326 )
87327 THEN
87328 IF
87329 --
87330 1 = 2
87331 --
87332 THEN
87333 xla_accounting_err_pkg.build_message
87334 (p_appli_s_name => 'XLA'
87335 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
87336 ,p_token_1 => 'LINE_NUMBER'
87337 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
87338 ,p_token_2 => 'LINE_TYPE_NAME'
87339 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
87340 l_component_type
87341 ,l_component_code
87342 ,l_component_type_code
87343 ,l_component_appl_id
87344 ,l_amb_context_code
87345 ,l_entity_code
87346 ,l_event_class_code
87347 )
87348 ,p_token_3 => 'OWNER'
87349 ,p_value_3 => xla_lookups_pkg.get_meaning(
87350 p_lookup_type => 'XLA_OWNER_TYPE'
87351 ,p_lookup_code => l_component_type_code
87352 )
87353 ,p_token_4 => 'PRODUCT_NAME'
87354 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
87355 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
87356 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
87357 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
87358 ,p_ae_header_id => NULL
87359 );
87360
87361 IF (C_LEVEL_ERROR>= g_log_level) THEN
87362 trace
87363 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
87364 ,p_level => C_LEVEL_ERROR
87365 ,p_module => l_log_module);
87366 END IF;
87367 END IF;
87368 END IF;
87369 --
87370 --
87371 ------------------------------------------------------------------------------------------------
87372 -- 4219869 Business Flow
87373 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
87374 -- Prior Entry. Currently, the following code is always generated.
87375 ------------------------------------------------------------------------------------------------
87376 XLA_AE_LINES_PKG.ValidateCurrentLine;
87377
87378 ------------------------------------------------------------------------------------
87379 -- 4219869 Business Flow
87380 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
87381 ------------------------------------------------------------------------------------
87382 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
87383
87384 ----------------------------------------------------------------------------------
87385 -- 4219869 Business Flow
87386 -- Update journal entry status -- Need to generate this within IF <condition>
87387 ----------------------------------------------------------------------------------
87388 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
87389 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
87390 ,p_balance_type_code => l_balance_type_code
87391 );
87392
87393 -------------------------------------------------------------------------------------------
87394 -- 4262811 - Generate the Accrual Reversal lines
87395 -------------------------------------------------------------------------------------------
87396 BEGIN
87397 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
87398 (g_array_event(p_event_id).array_value_num('header_index'));
87399 IF l_acc_rev_flag IS NULL THEN
87400 l_acc_rev_flag := 'N';
87401 END IF;
87402 EXCEPTION
87403 WHEN OTHERS THEN
87404 l_acc_rev_flag := 'N';
87405 END;
87406 --
87407 IF (l_acc_rev_flag = 'Y') THEN
87408
87409 -- 4645092 ------------------------------------------------------------------------------
87410 -- To allow MPA report to determine if it should generate report process
87411 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
87412 ------------------------------------------------------------------------------------------
87413
87414 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
87415 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
87416 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
87417 -- call ADRs
87418 -- Bug 4922099
87419 --
87420 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
87421 (NVL(l_actual_upg_option, 'N') = 'O') OR
87422 (NVL(l_enc_upg_option, 'N') = 'O')
87423 )
87424 THEN
87425 NULL;
87426 --
87427 --
87428
87429 l_ccid := AcctDerRule_6(
87430 p_application_id => p_application_id
87431 , p_ae_header_id => l_ae_header_id
87432 , p_source_11 => p_source_11
87433 , x_transaction_coa_id => l_adr_transaction_coa_id
87434 , x_accounting_coa_id => l_adr_accounting_coa_id
87435 , x_value_type_code => l_adr_value_type_code
87436 , p_side => 'NA'
87437 );
87438
87439 xla_ae_lines_pkg.set_ccid(
87440 p_code_combination_id => l_ccid
87441 , p_value_type_code => l_adr_value_type_code
87442 , p_transaction_coa_id => l_adr_transaction_coa_id
87443 , p_accounting_coa_id => l_adr_accounting_coa_id
87444 , p_adr_code => 'CST_DEFAULT'
87445 , p_adr_type_code => 'S'
87446 , p_component_type => l_component_type
87447 , p_component_code => l_component_code
87448 , p_component_type_code => l_component_type_code
87449 , p_component_appl_id => l_component_appl_id
87450 , p_amb_context_code => l_amb_context_code
87451 , p_side => 'NA'
87452 );
87453
87454
87455 --
87456 --
87457 END IF;
87458
87459 --
87460 -- Update the line information that should be overwritten
87461 --
87462 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
87463 p_header_num => 1);
87464 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
87465
87466 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
87467
87468 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
87469 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
87470 END IF;
87471
87472 --
87473 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
87474 --
87475 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
87476 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
87477 ELSE
87478 ---------------------------------------------------------------------------------------------------
87479 -- 4262811a Switch Sign
87480 ---------------------------------------------------------------------------------------------------
87481 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
87482 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
87483 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
87484 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
87485 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
87486 -- 5132302
87487 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
87488 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
87489
87490 END IF;
87491
87492 -- 4955764
87493 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
87494 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
87495
87496
87497 XLA_AE_LINES_PKG.ValidateCurrentLine;
87498 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
87499
87500 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
87501 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
87502 ,p_balance_type_code => l_balance_type_code);
87503
87504 END IF;
87505
87506 -----------------------------------------------------------------------------------------
87507 -- 4262811 Multiperiod Accounting
87508 -----------------------------------------------------------------------------------------
87509 -- No MPA option is assigned.
87510
87511
87512 END IF;
87513 END IF;
87514 --
87515
87516 --
87517 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
87518 trace
87519 (p_msg => 'END of AcctLineType_177'
87520 ,p_level => C_LEVEL_PROCEDURE
87521 ,p_module => l_log_module);
87522 END IF;
87523 --
87524 EXCEPTION
87525 WHEN xla_exceptions_pkg.application_exception THEN
87526 RAISE;
87527 WHEN OTHERS THEN
87528 xla_exceptions_pkg.raise_message
87529 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_177');
87530 END AcctLineType_177;
87531 --
87532
87533 ---------------------------------------
87534 --
87535 -- PRIVATE FUNCTION
87536 -- AcctLineType_178
87537 --
87538 ---------------------------------------
87539 PROCEDURE AcctLineType_178 (
87540 p_application_id IN NUMBER
87541 ,p_event_id IN NUMBER
87542 ,p_calculate_acctd_flag IN VARCHAR2
87543 ,p_calculate_g_l_flag IN VARCHAR2
87544 ,p_actual_flag IN OUT VARCHAR2
87545 ,p_balance_type_code OUT VARCHAR2
87546 ,p_gain_or_loss_ref OUT VARCHAR2
87547
87548 --Cost Management Default Account
87549 , p_source_11 IN NUMBER
87550 --DISTRIBUTION_IDENTIFIER
87551 , p_source_84 IN NUMBER
87552 --Distribution Type
87553 , p_source_85 IN VARCHAR2
87554 , p_source_85_meaning IN VARCHAR2
87555 --Entered Currency Code
87556 , p_source_88 IN VARCHAR2
87557 --Entered Amount
87558 , p_source_91 IN NUMBER
87559 --Currency Conversion Date
87560 , p_source_92 IN DATE
87561 --Currency Conversion Rate
87562 , p_source_93 IN NUMBER
87563 --Currency Conversion Type
87564 , p_source_94 IN VARCHAR2
87565 --Accounted Amount
87566 , p_source_95 IN NUMBER
87567 --Accounting Line Type
87568 , p_source_97 IN NUMBER
87569 )
87570 IS
87571
87572 l_component_type VARCHAR2(80);
87573 l_component_code VARCHAR2(30);
87574 l_component_type_code VARCHAR2(1);
87575 l_component_appl_id INTEGER;
87576 l_amb_context_code VARCHAR2(30);
87577 l_entity_code VARCHAR2(30);
87578 l_event_class_code VARCHAR2(30);
87579 l_ae_header_id NUMBER;
87580 l_event_type_code VARCHAR2(30);
87581 l_line_definition_code VARCHAR2(30);
87582 l_line_definition_owner_code VARCHAR2(1);
87583 --
87584 -- adr variables
87585 l_segment VARCHAR2(30);
87586 l_ccid NUMBER;
87587 l_adr_transaction_coa_id NUMBER;
87588 l_adr_accounting_coa_id NUMBER;
87589 l_adr_flexfield_segment_code VARCHAR2(30);
87590 l_adr_flex_value_set_id NUMBER;
87591 l_adr_value_type_code VARCHAR2(30);
87592 l_adr_value_combination_id NUMBER;
87593 l_adr_value_segment_code VARCHAR2(30);
87594
87595 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
87596 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
87597 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
87598 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
87599
87600 -- 4262811 Variables ------------------------------------------------------------------------------------------
87601 l_entered_amt_idx NUMBER;
87602 l_accted_amt_idx NUMBER;
87603 l_acc_rev_flag VARCHAR2(1);
87604 l_accrual_line_num NUMBER;
87605 l_tmp_amt NUMBER;
87606 l_acc_rev_natural_side_code VARCHAR2(1);
87607
87608 l_num_entries NUMBER;
87609 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
87610 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
87611 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
87612 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
87613 l_recog_line_1 NUMBER;
87614 l_recog_line_2 NUMBER;
87615
87616 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
87617 l_bflow_applied_to_amt NUMBER; -- 5132302
87618 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
87619
87620 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
87621
87622 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
87623 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
87624
87625 ---------------------------------------------------------------------------------------------------------------
87626
87627
87628 --
87629 -- bulk performance
87630 --
87631 l_balance_type_code VARCHAR2(1);
87632 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
87633 l_log_module VARCHAR2(240);
87634
87635 --
87636 -- Upgrade strategy
87637 --
87638 l_actual_upg_option VARCHAR2(1);
87639 l_enc_upg_option VARCHAR2(1);
87640
87641 --
87642 BEGIN
87643 --
87644 IF g_log_enabled THEN
87645 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_178';
87646 END IF;
87647 --
87648 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
87649
87650 trace
87651 (p_msg => 'BEGIN of AcctLineType_178'
87652 ,p_level => C_LEVEL_PROCEDURE
87653 ,p_module => l_log_module);
87654
87655 END IF;
87656 --
87657 l_component_type := 'AMB_JLT';
87658 l_component_code := 'INTERORG_PROFIT_OPM';
87659 l_component_type_code := 'S';
87660 l_component_appl_id := 707;
87661 l_amb_context_code := 'DEFAULT';
87662 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
87663 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
87664 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
87665 l_line_definition_owner_code := 'S';
87666 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
87667 --
87668 l_balance_type_code := 'A';
87669 l_segment := NULL;
87670 l_ccid := NULL;
87671 l_adr_transaction_coa_id := NULL;
87672 l_adr_accounting_coa_id := NULL;
87673 l_adr_flexfield_segment_code := NULL;
87674 l_adr_flex_value_set_id := NULL;
87675 l_adr_value_type_code := NULL;
87676 l_adr_value_combination_id := NULL;
87677 l_adr_value_segment_code := NULL;
87678
87679 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
87680 l_bflow_class_code := ''; -- 4219869 Business Flow
87681 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
87682 l_budgetary_control_flag := 'N';
87683
87684 l_bflow_applied_to_amt_idx := NULL; -- 5132302
87685 l_bflow_applied_to_amt := NULL; -- 5132302
87686 l_entered_amt_idx := NULL; -- 4262811
87687 l_accted_amt_idx := NULL; -- 4262811
87688 l_acc_rev_flag := NULL; -- 4262811
87689 l_accrual_line_num := NULL; -- 4262811
87690 l_tmp_amt := NULL; -- 4262811
87691 --
87692
87693 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
87694 l_balance_type_code <> 'B' THEN
87695 IF NVL(p_source_97,9E125) = 34
87696 THEN
87697
87698 --
87699 XLA_AE_LINES_PKG.SetNewLine;
87700
87701 p_balance_type_code := l_balance_type_code;
87702 -- set the flag so later we will know whether the gain loss line needs to be created
87703
87704 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
87705 p_actual_flag :='A';
87706 END IF;
87707
87708 --
87709 -- bulk performance
87710 --
87711 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
87712 p_header_num => 0); -- 4262811
87713 --
87714 -- set accounting line options
87715 --
87716 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
87717 p_natural_side_code => 'D'
87718 , p_gain_or_loss_flag => 'N'
87719 , p_gl_transfer_mode_code => 'S'
87720 , p_acct_entry_type_code => 'A'
87721 , p_switch_side_flag => 'Y'
87722 , p_merge_duplicate_code => 'N'
87723 );
87724 --
87725 l_acc_rev_natural_side_code := 'C'; -- 4262811
87726 --
87727 --
87728 -- set accounting line type info
87729 --
87730 xla_ae_lines_pkg.SetAcctLineType
87731 (p_component_type => l_component_type
87732 ,p_event_type_code => l_event_type_code
87733 ,p_line_definition_owner_code => l_line_definition_owner_code
87734 ,p_line_definition_code => l_line_definition_code
87735 ,p_accounting_line_code => l_component_code
87736 ,p_accounting_line_type_code => l_component_type_code
87737 ,p_accounting_line_appl_id => l_component_appl_id
87738 ,p_amb_context_code => l_amb_context_code
87739 ,p_entity_code => l_entity_code
87740 ,p_event_class_code => l_event_class_code);
87741 --
87742 -- set accounting class
87743 --
87744 xla_ae_lines_pkg.SetAcctClass(
87745 p_accounting_class_code => 'INTERORG_PROFIT'
87746 , p_ae_header_id => l_ae_header_id
87747 );
87748
87749 --
87750 -- set rounding class
87751 --
87752 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
87753 'INTERORG_PROFIT';
87754
87755 --
87756 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
87757 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
87758 --
87759 -- bulk performance
87760 --
87761 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
87762
87763 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
87764 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
87765
87766 -- 4955764
87767 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
87768 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
87769
87770 -- 4458381 Public Sector Enh
87771
87772 --
87773 -- set accounting attributes for the line type
87774 --
87775 l_entered_amt_idx := 3;
87776 l_accted_amt_idx := 8;
87777 l_bflow_applied_to_amt_idx := NULL; -- 5132302
87778 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
87779 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
87780 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
87781 l_rec_acct_attrs.array_char_value(2) := p_source_85;
87782 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
87783 l_rec_acct_attrs.array_num_value(3) := p_source_91;
87784 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
87785 l_rec_acct_attrs.array_char_value(4) := p_source_88;
87786 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
87787 l_rec_acct_attrs.array_date_value(5) := p_source_92;
87788 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
87789 l_rec_acct_attrs.array_num_value(6) := p_source_93;
87790 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
87791 l_rec_acct_attrs.array_char_value(7) := p_source_94;
87792 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
87793 l_rec_acct_attrs.array_num_value(8) := p_source_95;
87794
87795 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
87796 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
87797
87798 ---------------------------------------------------------------------------------------------------------------
87799 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
87800 ---------------------------------------------------------------------------------------------------------------
87801 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
87802
87803 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
87804 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
87805
87806 IF xla_accounting_cache_pkg.GetValueChar
87807 (p_source_code => 'LEDGER_CATEGORY_CODE'
87808 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
87809 AND l_bflow_method_code = 'PRIOR_ENTRY'
87810 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
87811 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
87812 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
87813 )
87814 THEN
87815 xla_ae_lines_pkg.BflowUpgEntry
87816 (p_business_method_code => l_bflow_method_code
87817 ,p_business_class_code => l_bflow_class_code
87818 ,p_balance_type => l_balance_type_code);
87819 ELSE
87820 NULL;
87821 -- No business flow processing for business flow method of NONE.
87822 END IF;
87823
87824 --
87825 -- call analytical criteria
87826 --
87827
87828 --
87829 -- call description
87830 --
87831 -- No description or it is inherited.
87832 --
87833 -- call ADRs
87834 -- Bug 4922099
87835 --
87836 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
87837 (NVL(l_actual_upg_option, 'N') = 'O') OR
87838 (NVL(l_enc_upg_option, 'N') = 'O')
87839 )
87840 THEN
87841 NULL;
87842 --
87843 --
87844
87845 l_ccid := AcctDerRule_6(
87846 p_application_id => p_application_id
87847 , p_ae_header_id => l_ae_header_id
87848 , p_source_11 => p_source_11
87849 , x_transaction_coa_id => l_adr_transaction_coa_id
87850 , x_accounting_coa_id => l_adr_accounting_coa_id
87851 , x_value_type_code => l_adr_value_type_code
87852 , p_side => 'NA'
87853 );
87854
87855 xla_ae_lines_pkg.set_ccid(
87856 p_code_combination_id => l_ccid
87857 , p_value_type_code => l_adr_value_type_code
87858 , p_transaction_coa_id => l_adr_transaction_coa_id
87859 , p_accounting_coa_id => l_adr_accounting_coa_id
87860 , p_adr_code => 'CST_DEFAULT'
87861 , p_adr_type_code => 'S'
87862 , p_component_type => l_component_type
87863 , p_component_code => l_component_code
87864 , p_component_type_code => l_component_type_code
87865 , p_component_appl_id => l_component_appl_id
87866 , p_amb_context_code => l_amb_context_code
87867 , p_side => 'NA'
87868 );
87869
87870
87871 --
87872 --
87873 END IF;
87874 --
87875 -- Bug 4922099
87876 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
87877 (NVL(l_enc_upg_option, 'N') = 'O')
87878 ) AND
87879 (l_bflow_method_code = 'PRIOR_ENTRY')
87880 )
87881 THEN
87882 IF
87883 --
87884 1 = 2
87885 --
87886 THEN
87887 xla_accounting_err_pkg.build_message
87888 (p_appli_s_name => 'XLA'
87889 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
87890 ,p_token_1 => 'LINE_NUMBER'
87891 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
87892 ,p_token_2 => 'LINE_TYPE_NAME'
87893 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
87894 l_component_type
87895 ,l_component_code
87896 ,l_component_type_code
87897 ,l_component_appl_id
87898 ,l_amb_context_code
87899 ,l_entity_code
87900 ,l_event_class_code
87901 )
87902 ,p_token_3 => 'OWNER'
87903 ,p_value_3 => xla_lookups_pkg.get_meaning(
87904 p_lookup_type => 'XLA_OWNER_TYPE'
87905 ,p_lookup_code => l_component_type_code
87906 )
87907 ,p_token_4 => 'PRODUCT_NAME'
87908 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
87909 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
87910 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
87911 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
87912 ,p_ae_header_id => NULL
87913 );
87914
87915 IF (C_LEVEL_ERROR>= g_log_level) THEN
87916 trace
87917 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
87918 ,p_level => C_LEVEL_ERROR
87919 ,p_module => l_log_module);
87920 END IF;
87921 END IF;
87922 END IF;
87923 --
87924 --
87925 ------------------------------------------------------------------------------------------------
87926 -- 4219869 Business Flow
87927 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
87928 -- Prior Entry. Currently, the following code is always generated.
87929 ------------------------------------------------------------------------------------------------
87930 XLA_AE_LINES_PKG.ValidateCurrentLine;
87931
87932 ------------------------------------------------------------------------------------
87933 -- 4219869 Business Flow
87934 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
87935 ------------------------------------------------------------------------------------
87936 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
87937
87938 ----------------------------------------------------------------------------------
87939 -- 4219869 Business Flow
87940 -- Update journal entry status -- Need to generate this within IF <condition>
87941 ----------------------------------------------------------------------------------
87942 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
87943 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
87944 ,p_balance_type_code => l_balance_type_code
87945 );
87946
87947 -------------------------------------------------------------------------------------------
87948 -- 4262811 - Generate the Accrual Reversal lines
87949 -------------------------------------------------------------------------------------------
87950 BEGIN
87951 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
87952 (g_array_event(p_event_id).array_value_num('header_index'));
87953 IF l_acc_rev_flag IS NULL THEN
87954 l_acc_rev_flag := 'N';
87955 END IF;
87956 EXCEPTION
87957 WHEN OTHERS THEN
87958 l_acc_rev_flag := 'N';
87959 END;
87960 --
87961 IF (l_acc_rev_flag = 'Y') THEN
87962
87963 -- 4645092 ------------------------------------------------------------------------------
87964 -- To allow MPA report to determine if it should generate report process
87965 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
87966 ------------------------------------------------------------------------------------------
87967
87968 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
87969 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
87970 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
87971 -- call ADRs
87972 -- Bug 4922099
87973 --
87974 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
87975 (NVL(l_actual_upg_option, 'N') = 'O') OR
87976 (NVL(l_enc_upg_option, 'N') = 'O')
87977 )
87978 THEN
87979 NULL;
87980 --
87981 --
87982
87983 l_ccid := AcctDerRule_6(
87984 p_application_id => p_application_id
87985 , p_ae_header_id => l_ae_header_id
87986 , p_source_11 => p_source_11
87987 , x_transaction_coa_id => l_adr_transaction_coa_id
87988 , x_accounting_coa_id => l_adr_accounting_coa_id
87989 , x_value_type_code => l_adr_value_type_code
87990 , p_side => 'NA'
87991 );
87992
87993 xla_ae_lines_pkg.set_ccid(
87994 p_code_combination_id => l_ccid
87995 , p_value_type_code => l_adr_value_type_code
87996 , p_transaction_coa_id => l_adr_transaction_coa_id
87997 , p_accounting_coa_id => l_adr_accounting_coa_id
87998 , p_adr_code => 'CST_DEFAULT'
87999 , p_adr_type_code => 'S'
88000 , p_component_type => l_component_type
88001 , p_component_code => l_component_code
88002 , p_component_type_code => l_component_type_code
88003 , p_component_appl_id => l_component_appl_id
88004 , p_amb_context_code => l_amb_context_code
88005 , p_side => 'NA'
88006 );
88007
88008
88009 --
88010 --
88011 END IF;
88012
88013 --
88014 -- Update the line information that should be overwritten
88015 --
88016 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
88017 p_header_num => 1);
88018 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
88019
88020 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
88021
88022 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
88023 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
88024 END IF;
88025
88026 --
88027 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
88028 --
88029 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
88030 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
88031 ELSE
88032 ---------------------------------------------------------------------------------------------------
88033 -- 4262811a Switch Sign
88034 ---------------------------------------------------------------------------------------------------
88035 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
88036 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
88037 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88038 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
88039 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88040 -- 5132302
88041 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
88042 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88043
88044 END IF;
88045
88046 -- 4955764
88047 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
88048 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
88049
88050
88051 XLA_AE_LINES_PKG.ValidateCurrentLine;
88052 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
88053
88054 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
88055 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
88056 ,p_balance_type_code => l_balance_type_code);
88057
88058 END IF;
88059
88060 -----------------------------------------------------------------------------------------
88061 -- 4262811 Multiperiod Accounting
88062 -----------------------------------------------------------------------------------------
88063 -- No MPA option is assigned.
88064
88065
88066 END IF;
88067 END IF;
88068 --
88069
88070 --
88071 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
88072 trace
88073 (p_msg => 'END of AcctLineType_178'
88074 ,p_level => C_LEVEL_PROCEDURE
88075 ,p_module => l_log_module);
88076 END IF;
88077 --
88078 EXCEPTION
88079 WHEN xla_exceptions_pkg.application_exception THEN
88080 RAISE;
88081 WHEN OTHERS THEN
88082 xla_exceptions_pkg.raise_message
88083 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_178');
88084 END AcctLineType_178;
88085 --
88086
88087 ---------------------------------------
88088 --
88089 -- PRIVATE FUNCTION
88090 -- AcctLineType_179
88091 --
88092 ---------------------------------------
88093 PROCEDURE AcctLineType_179 (
88094 p_application_id IN NUMBER
88095 ,p_event_id IN NUMBER
88096 ,p_calculate_acctd_flag IN VARCHAR2
88097 ,p_calculate_g_l_flag IN VARCHAR2
88098 ,p_actual_flag IN OUT VARCHAR2
88099 ,p_balance_type_code OUT VARCHAR2
88100 ,p_gain_or_loss_ref OUT VARCHAR2
88101
88102 --TRANSACTION_ID
88103 , p_source_1 IN NUMBER
88104 --Item Concatenated Segments
88105 , p_source_2 IN VARCHAR2
88106 --Transaction Quantity
88107 , p_source_3 IN NUMBER
88108 --Transaction Unit of Measure Code
88109 , p_source_4 IN VARCHAR2
88110 --Inventory Transaction Type Description
88111 , p_source_5 IN VARCHAR2
88112 --Cost Management Default Account
88113 , p_source_11 IN NUMBER
88114 --DISTRIBUTION_IDENTIFIER
88115 , p_source_84 IN NUMBER
88116 --Distribution Type
88117 , p_source_85 IN VARCHAR2
88118 , p_source_85_meaning IN VARCHAR2
88119 --Entered Currency Code
88120 , p_source_88 IN VARCHAR2
88121 --Entered Amount
88122 , p_source_91 IN NUMBER
88123 --Currency Conversion Date
88124 , p_source_92 IN DATE
88125 --Currency Conversion Rate
88126 , p_source_93 IN NUMBER
88127 --Currency Conversion Type
88128 , p_source_94 IN VARCHAR2
88129 --Accounted Amount
88130 , p_source_95 IN NUMBER
88131 --Accounting Line Type
88132 , p_source_97 IN NUMBER
88133 )
88134 IS
88135
88136 l_component_type VARCHAR2(80);
88137 l_component_code VARCHAR2(30);
88138 l_component_type_code VARCHAR2(1);
88139 l_component_appl_id INTEGER;
88140 l_amb_context_code VARCHAR2(30);
88141 l_entity_code VARCHAR2(30);
88142 l_event_class_code VARCHAR2(30);
88143 l_ae_header_id NUMBER;
88144 l_event_type_code VARCHAR2(30);
88145 l_line_definition_code VARCHAR2(30);
88146 l_line_definition_owner_code VARCHAR2(1);
88147 --
88148 -- adr variables
88149 l_segment VARCHAR2(30);
88150 l_ccid NUMBER;
88151 l_adr_transaction_coa_id NUMBER;
88152 l_adr_accounting_coa_id NUMBER;
88153 l_adr_flexfield_segment_code VARCHAR2(30);
88154 l_adr_flex_value_set_id NUMBER;
88155 l_adr_value_type_code VARCHAR2(30);
88156 l_adr_value_combination_id NUMBER;
88157 l_adr_value_segment_code VARCHAR2(30);
88158
88159 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
88160 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
88161 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
88162 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
88163
88164 -- 4262811 Variables ------------------------------------------------------------------------------------------
88165 l_entered_amt_idx NUMBER;
88166 l_accted_amt_idx NUMBER;
88167 l_acc_rev_flag VARCHAR2(1);
88168 l_accrual_line_num NUMBER;
88169 l_tmp_amt NUMBER;
88170 l_acc_rev_natural_side_code VARCHAR2(1);
88171
88172 l_num_entries NUMBER;
88173 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
88174 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
88175 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
88176 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
88177 l_recog_line_1 NUMBER;
88178 l_recog_line_2 NUMBER;
88179
88180 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
88181 l_bflow_applied_to_amt NUMBER; -- 5132302
88182 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
88183
88184 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
88185
88186 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
88187 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
88188
88189 ---------------------------------------------------------------------------------------------------------------
88190
88191
88192 --
88193 -- bulk performance
88194 --
88195 l_balance_type_code VARCHAR2(1);
88196 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
88197 l_log_module VARCHAR2(240);
88198
88199 --
88200 -- Upgrade strategy
88201 --
88202 l_actual_upg_option VARCHAR2(1);
88203 l_enc_upg_option VARCHAR2(1);
88204
88205 --
88206 BEGIN
88207 --
88208 IF g_log_enabled THEN
88209 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_179';
88210 END IF;
88211 --
88212 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
88213
88214 trace
88215 (p_msg => 'BEGIN of AcctLineType_179'
88216 ,p_level => C_LEVEL_PROCEDURE
88217 ,p_module => l_log_module);
88218
88219 END IF;
88220 --
88221 l_component_type := 'AMB_JLT';
88222 l_component_code := 'INTERORG_PROFIT_OPM';
88223 l_component_type_code := 'S';
88224 l_component_appl_id := 707;
88225 l_amb_context_code := 'DEFAULT';
88226 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
88227 l_event_class_code := 'USER_DEFINE';
88228 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
88229 l_line_definition_owner_code := 'S';
88230 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
88231 --
88232 l_balance_type_code := 'A';
88233 l_segment := NULL;
88234 l_ccid := NULL;
88235 l_adr_transaction_coa_id := NULL;
88236 l_adr_accounting_coa_id := NULL;
88237 l_adr_flexfield_segment_code := NULL;
88238 l_adr_flex_value_set_id := NULL;
88239 l_adr_value_type_code := NULL;
88240 l_adr_value_combination_id := NULL;
88241 l_adr_value_segment_code := NULL;
88242
88243 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
88244 l_bflow_class_code := ''; -- 4219869 Business Flow
88245 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
88246 l_budgetary_control_flag := 'N';
88247
88248 l_bflow_applied_to_amt_idx := NULL; -- 5132302
88249 l_bflow_applied_to_amt := NULL; -- 5132302
88250 l_entered_amt_idx := NULL; -- 4262811
88251 l_accted_amt_idx := NULL; -- 4262811
88252 l_acc_rev_flag := NULL; -- 4262811
88253 l_accrual_line_num := NULL; -- 4262811
88254 l_tmp_amt := NULL; -- 4262811
88255 --
88256
88257 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
88258 l_balance_type_code <> 'B' THEN
88259 IF NVL(p_source_97,9E125) = 34
88260 THEN
88261
88262 --
88263 XLA_AE_LINES_PKG.SetNewLine;
88264
88265 p_balance_type_code := l_balance_type_code;
88266 -- set the flag so later we will know whether the gain loss line needs to be created
88267
88268 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
88269 p_actual_flag :='A';
88270 END IF;
88271
88272 --
88273 -- bulk performance
88274 --
88275 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
88276 p_header_num => 0); -- 4262811
88277 --
88278 -- set accounting line options
88279 --
88280 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
88281 p_natural_side_code => 'D'
88282 , p_gain_or_loss_flag => 'N'
88283 , p_gl_transfer_mode_code => 'S'
88284 , p_acct_entry_type_code => 'A'
88285 , p_switch_side_flag => 'Y'
88286 , p_merge_duplicate_code => 'N'
88287 );
88288 --
88289 l_acc_rev_natural_side_code := 'C'; -- 4262811
88290 --
88291 --
88292 -- set accounting line type info
88293 --
88294 xla_ae_lines_pkg.SetAcctLineType
88295 (p_component_type => l_component_type
88296 ,p_event_type_code => l_event_type_code
88297 ,p_line_definition_owner_code => l_line_definition_owner_code
88298 ,p_line_definition_code => l_line_definition_code
88299 ,p_accounting_line_code => l_component_code
88300 ,p_accounting_line_type_code => l_component_type_code
88301 ,p_accounting_line_appl_id => l_component_appl_id
88302 ,p_amb_context_code => l_amb_context_code
88303 ,p_entity_code => l_entity_code
88304 ,p_event_class_code => l_event_class_code);
88305 --
88306 -- set accounting class
88307 --
88308 xla_ae_lines_pkg.SetAcctClass(
88309 p_accounting_class_code => 'INTERORG_PROFIT'
88310 , p_ae_header_id => l_ae_header_id
88311 );
88312
88313 --
88314 -- set rounding class
88315 --
88316 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
88317 'INTERORG_PROFIT';
88318
88319 --
88320 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
88321 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
88322 --
88323 -- bulk performance
88324 --
88325 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
88326
88327 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
88328 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
88329
88330 -- 4955764
88331 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
88332 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
88333
88334 -- 4458381 Public Sector Enh
88335
88336 --
88337 -- set accounting attributes for the line type
88338 --
88339 l_entered_amt_idx := 3;
88340 l_accted_amt_idx := 8;
88341 l_bflow_applied_to_amt_idx := NULL; -- 5132302
88342 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
88343 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
88344 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
88345 l_rec_acct_attrs.array_char_value(2) := p_source_85;
88346 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
88347 l_rec_acct_attrs.array_num_value(3) := p_source_91;
88348 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
88349 l_rec_acct_attrs.array_char_value(4) := p_source_88;
88350 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
88351 l_rec_acct_attrs.array_date_value(5) := p_source_92;
88352 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
88353 l_rec_acct_attrs.array_num_value(6) := p_source_93;
88354 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
88355 l_rec_acct_attrs.array_char_value(7) := p_source_94;
88356 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
88357 l_rec_acct_attrs.array_num_value(8) := p_source_95;
88358
88359 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
88360 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
88361
88362 ---------------------------------------------------------------------------------------------------------------
88363 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
88364 ---------------------------------------------------------------------------------------------------------------
88365 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
88366
88367 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
88368 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
88369
88370 IF xla_accounting_cache_pkg.GetValueChar
88371 (p_source_code => 'LEDGER_CATEGORY_CODE'
88372 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
88373 AND l_bflow_method_code = 'PRIOR_ENTRY'
88374 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
88375 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
88376 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
88377 )
88378 THEN
88379 xla_ae_lines_pkg.BflowUpgEntry
88380 (p_business_method_code => l_bflow_method_code
88381 ,p_business_class_code => l_bflow_class_code
88382 ,p_balance_type => l_balance_type_code);
88383 ELSE
88384 NULL;
88385 -- No business flow processing for business flow method of NONE.
88386 END IF;
88387
88388 --
88389 -- call analytical criteria
88390 --
88391
88392 --
88393 -- call description
88394 --
88395
88396 xla_ae_lines_pkg.SetLineDescription(
88397 p_ae_header_id => l_ae_header_id
88398 ,p_description => Description_1 (
88399 p_application_id => p_application_id
88400 , p_ae_header_id => l_ae_header_id
88401 , p_source_1 => p_source_1
88402 , p_source_2 => p_source_2
88403 , p_source_3 => p_source_3
88404 , p_source_4 => p_source_4
88405 , p_source_5 => p_source_5
88406 )
88407 );
88408
88409
88410 --
88411 -- call ADRs
88412 -- Bug 4922099
88413 --
88414 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
88415 (NVL(l_actual_upg_option, 'N') = 'O') OR
88416 (NVL(l_enc_upg_option, 'N') = 'O')
88417 )
88418 THEN
88419 NULL;
88420 --
88421 --
88422
88423 l_ccid := AcctDerRule_6(
88424 p_application_id => p_application_id
88425 , p_ae_header_id => l_ae_header_id
88426 , p_source_11 => p_source_11
88427 , x_transaction_coa_id => l_adr_transaction_coa_id
88428 , x_accounting_coa_id => l_adr_accounting_coa_id
88429 , x_value_type_code => l_adr_value_type_code
88430 , p_side => 'NA'
88431 );
88432
88433 xla_ae_lines_pkg.set_ccid(
88434 p_code_combination_id => l_ccid
88435 , p_value_type_code => l_adr_value_type_code
88436 , p_transaction_coa_id => l_adr_transaction_coa_id
88437 , p_accounting_coa_id => l_adr_accounting_coa_id
88438 , p_adr_code => 'CST_DEFAULT'
88439 , p_adr_type_code => 'S'
88440 , p_component_type => l_component_type
88441 , p_component_code => l_component_code
88442 , p_component_type_code => l_component_type_code
88443 , p_component_appl_id => l_component_appl_id
88444 , p_amb_context_code => l_amb_context_code
88445 , p_side => 'NA'
88446 );
88447
88448
88449 --
88450 --
88451 END IF;
88452 --
88453 -- Bug 4922099
88454 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
88455 (NVL(l_enc_upg_option, 'N') = 'O')
88456 ) AND
88457 (l_bflow_method_code = 'PRIOR_ENTRY')
88458 )
88459 THEN
88460 IF
88461 --
88462 1 = 2
88463 --
88464 THEN
88465 xla_accounting_err_pkg.build_message
88466 (p_appli_s_name => 'XLA'
88467 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
88468 ,p_token_1 => 'LINE_NUMBER'
88469 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
88470 ,p_token_2 => 'LINE_TYPE_NAME'
88471 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
88472 l_component_type
88473 ,l_component_code
88474 ,l_component_type_code
88475 ,l_component_appl_id
88476 ,l_amb_context_code
88477 ,l_entity_code
88478 ,l_event_class_code
88479 )
88480 ,p_token_3 => 'OWNER'
88481 ,p_value_3 => xla_lookups_pkg.get_meaning(
88482 p_lookup_type => 'XLA_OWNER_TYPE'
88483 ,p_lookup_code => l_component_type_code
88484 )
88485 ,p_token_4 => 'PRODUCT_NAME'
88486 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
88487 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
88488 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
88489 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
88490 ,p_ae_header_id => NULL
88491 );
88492
88493 IF (C_LEVEL_ERROR>= g_log_level) THEN
88494 trace
88495 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
88496 ,p_level => C_LEVEL_ERROR
88497 ,p_module => l_log_module);
88498 END IF;
88499 END IF;
88500 END IF;
88501 --
88502 --
88503 ------------------------------------------------------------------------------------------------
88504 -- 4219869 Business Flow
88505 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
88506 -- Prior Entry. Currently, the following code is always generated.
88507 ------------------------------------------------------------------------------------------------
88508 XLA_AE_LINES_PKG.ValidateCurrentLine;
88509
88510 ------------------------------------------------------------------------------------
88511 -- 4219869 Business Flow
88512 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
88513 ------------------------------------------------------------------------------------
88514 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
88515
88516 ----------------------------------------------------------------------------------
88517 -- 4219869 Business Flow
88518 -- Update journal entry status -- Need to generate this within IF <condition>
88519 ----------------------------------------------------------------------------------
88520 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
88521 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
88522 ,p_balance_type_code => l_balance_type_code
88523 );
88524
88525 -------------------------------------------------------------------------------------------
88526 -- 4262811 - Generate the Accrual Reversal lines
88527 -------------------------------------------------------------------------------------------
88528 BEGIN
88529 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
88530 (g_array_event(p_event_id).array_value_num('header_index'));
88531 IF l_acc_rev_flag IS NULL THEN
88532 l_acc_rev_flag := 'N';
88533 END IF;
88534 EXCEPTION
88535 WHEN OTHERS THEN
88536 l_acc_rev_flag := 'N';
88537 END;
88538 --
88539 IF (l_acc_rev_flag = 'Y') THEN
88540
88541 -- 4645092 ------------------------------------------------------------------------------
88542 -- To allow MPA report to determine if it should generate report process
88543 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
88544 ------------------------------------------------------------------------------------------
88545
88546 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
88547 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
88548 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
88549 -- call ADRs
88550 -- Bug 4922099
88551 --
88552 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
88553 (NVL(l_actual_upg_option, 'N') = 'O') OR
88554 (NVL(l_enc_upg_option, 'N') = 'O')
88555 )
88556 THEN
88557 NULL;
88558 --
88559 --
88560
88561 l_ccid := AcctDerRule_6(
88562 p_application_id => p_application_id
88563 , p_ae_header_id => l_ae_header_id
88564 , p_source_11 => p_source_11
88565 , x_transaction_coa_id => l_adr_transaction_coa_id
88566 , x_accounting_coa_id => l_adr_accounting_coa_id
88567 , x_value_type_code => l_adr_value_type_code
88568 , p_side => 'NA'
88569 );
88570
88571 xla_ae_lines_pkg.set_ccid(
88572 p_code_combination_id => l_ccid
88573 , p_value_type_code => l_adr_value_type_code
88574 , p_transaction_coa_id => l_adr_transaction_coa_id
88575 , p_accounting_coa_id => l_adr_accounting_coa_id
88576 , p_adr_code => 'CST_DEFAULT'
88577 , p_adr_type_code => 'S'
88578 , p_component_type => l_component_type
88579 , p_component_code => l_component_code
88580 , p_component_type_code => l_component_type_code
88581 , p_component_appl_id => l_component_appl_id
88582 , p_amb_context_code => l_amb_context_code
88583 , p_side => 'NA'
88584 );
88585
88586
88587 --
88588 --
88589 END IF;
88590
88591 --
88592 -- Update the line information that should be overwritten
88593 --
88594 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
88595 p_header_num => 1);
88596 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
88597
88598 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
88599
88600 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
88601 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
88602 END IF;
88603
88604 --
88605 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
88606 --
88607 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
88608 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
88609 ELSE
88610 ---------------------------------------------------------------------------------------------------
88611 -- 4262811a Switch Sign
88612 ---------------------------------------------------------------------------------------------------
88613 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
88614 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
88615 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88616 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
88617 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88618 -- 5132302
88619 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
88620 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
88621
88622 END IF;
88623
88624 -- 4955764
88625 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
88626 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
88627
88628
88629 XLA_AE_LINES_PKG.ValidateCurrentLine;
88630 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
88631
88632 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
88633 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
88634 ,p_balance_type_code => l_balance_type_code);
88635
88636 END IF;
88637
88638 -----------------------------------------------------------------------------------------
88639 -- 4262811 Multiperiod Accounting
88640 -----------------------------------------------------------------------------------------
88641 -- No MPA option is assigned.
88642
88643
88644 END IF;
88645 END IF;
88646 --
88647
88648 --
88649 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
88650 trace
88651 (p_msg => 'END of AcctLineType_179'
88652 ,p_level => C_LEVEL_PROCEDURE
88653 ,p_module => l_log_module);
88654 END IF;
88655 --
88656 EXCEPTION
88657 WHEN xla_exceptions_pkg.application_exception THEN
88658 RAISE;
88659 WHEN OTHERS THEN
88660 xla_exceptions_pkg.raise_message
88661 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_179');
88662 END AcctLineType_179;
88663 --
88664
88665 ---------------------------------------
88666 --
88667 -- PRIVATE FUNCTION
88668 -- AcctLineType_180
88669 --
88670 ---------------------------------------
88671 PROCEDURE AcctLineType_180 (
88672 p_application_id IN NUMBER
88673 ,p_event_id IN NUMBER
88674 ,p_calculate_acctd_flag IN VARCHAR2
88675 ,p_calculate_g_l_flag IN VARCHAR2
88676 ,p_actual_flag IN OUT VARCHAR2
88677 ,p_balance_type_code OUT VARCHAR2
88678 ,p_gain_or_loss_ref OUT VARCHAR2
88679
88680 --TRANSACTION_ID
88681 , p_source_1 IN NUMBER
88682 --Item Concatenated Segments
88683 , p_source_2 IN VARCHAR2
88684 --Transaction Quantity
88685 , p_source_3 IN NUMBER
88686 --Transaction Unit of Measure Code
88687 , p_source_4 IN VARCHAR2
88688 --Inventory Transaction Type Description
88689 , p_source_5 IN VARCHAR2
88690 --Cost Management Default Account
88691 , p_source_11 IN NUMBER
88692 --DISTRIBUTION_IDENTIFIER
88693 , p_source_84 IN NUMBER
88694 --Distribution Type
88695 , p_source_85 IN VARCHAR2
88696 , p_source_85_meaning IN VARCHAR2
88697 --Entered Currency Code
88698 , p_source_88 IN VARCHAR2
88699 --Entered Amount
88700 , p_source_91 IN NUMBER
88701 --Currency Conversion Date
88702 , p_source_92 IN DATE
88703 --Currency Conversion Rate
88704 , p_source_93 IN NUMBER
88705 --Currency Conversion Type
88706 , p_source_94 IN VARCHAR2
88707 --Accounted Amount
88708 , p_source_95 IN NUMBER
88709 --Accounting Line Type
88710 , p_source_97 IN NUMBER
88711 )
88712 IS
88713
88714 l_component_type VARCHAR2(80);
88715 l_component_code VARCHAR2(30);
88716 l_component_type_code VARCHAR2(1);
88717 l_component_appl_id INTEGER;
88718 l_amb_context_code VARCHAR2(30);
88719 l_entity_code VARCHAR2(30);
88720 l_event_class_code VARCHAR2(30);
88721 l_ae_header_id NUMBER;
88722 l_event_type_code VARCHAR2(30);
88723 l_line_definition_code VARCHAR2(30);
88724 l_line_definition_owner_code VARCHAR2(1);
88725 --
88726 -- adr variables
88727 l_segment VARCHAR2(30);
88728 l_ccid NUMBER;
88729 l_adr_transaction_coa_id NUMBER;
88730 l_adr_accounting_coa_id NUMBER;
88731 l_adr_flexfield_segment_code VARCHAR2(30);
88732 l_adr_flex_value_set_id NUMBER;
88733 l_adr_value_type_code VARCHAR2(30);
88734 l_adr_value_combination_id NUMBER;
88735 l_adr_value_segment_code VARCHAR2(30);
88736
88737 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
88738 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
88739 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
88740 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
88741
88742 -- 4262811 Variables ------------------------------------------------------------------------------------------
88743 l_entered_amt_idx NUMBER;
88744 l_accted_amt_idx NUMBER;
88745 l_acc_rev_flag VARCHAR2(1);
88746 l_accrual_line_num NUMBER;
88747 l_tmp_amt NUMBER;
88748 l_acc_rev_natural_side_code VARCHAR2(1);
88749
88750 l_num_entries NUMBER;
88751 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
88752 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
88753 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
88754 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
88755 l_recog_line_1 NUMBER;
88756 l_recog_line_2 NUMBER;
88757
88758 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
88759 l_bflow_applied_to_amt NUMBER; -- 5132302
88760 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
88761
88762 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
88763
88764 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
88765 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
88766
88767 ---------------------------------------------------------------------------------------------------------------
88768
88769
88770 --
88771 -- bulk performance
88772 --
88773 l_balance_type_code VARCHAR2(1);
88774 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
88775 l_log_module VARCHAR2(240);
88776
88777 --
88778 -- Upgrade strategy
88779 --
88780 l_actual_upg_option VARCHAR2(1);
88781 l_enc_upg_option VARCHAR2(1);
88782
88783 --
88784 BEGIN
88785 --
88786 IF g_log_enabled THEN
88787 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_180';
88788 END IF;
88789 --
88790 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
88791
88792 trace
88793 (p_msg => 'BEGIN of AcctLineType_180'
88794 ,p_level => C_LEVEL_PROCEDURE
88795 ,p_module => l_log_module);
88796
88797 END IF;
88798 --
88799 l_component_type := 'AMB_JLT';
88800 l_component_code := 'INTERORG_PROFIT_OPM';
88801 l_component_type_code := 'S';
88802 l_component_appl_id := 707;
88803 l_amb_context_code := 'DEFAULT';
88804 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
88805 l_event_class_code := 'INT_ORDER_TO_EXP';
88806 l_event_type_code := 'EXP_REQ_RCPT_TP';
88807 l_line_definition_owner_code := 'S';
88808 l_line_definition_code := 'PI_EXP_REQ_RCPT_TP';
88809 --
88810 l_balance_type_code := 'A';
88811 l_segment := NULL;
88812 l_ccid := NULL;
88813 l_adr_transaction_coa_id := NULL;
88814 l_adr_accounting_coa_id := NULL;
88815 l_adr_flexfield_segment_code := NULL;
88816 l_adr_flex_value_set_id := NULL;
88817 l_adr_value_type_code := NULL;
88818 l_adr_value_combination_id := NULL;
88819 l_adr_value_segment_code := NULL;
88820
88821 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
88822 l_bflow_class_code := ''; -- 4219869 Business Flow
88823 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
88824 l_budgetary_control_flag := 'N';
88825
88826 l_bflow_applied_to_amt_idx := NULL; -- 5132302
88827 l_bflow_applied_to_amt := NULL; -- 5132302
88828 l_entered_amt_idx := NULL; -- 4262811
88829 l_accted_amt_idx := NULL; -- 4262811
88830 l_acc_rev_flag := NULL; -- 4262811
88831 l_accrual_line_num := NULL; -- 4262811
88832 l_tmp_amt := NULL; -- 4262811
88833 --
88834
88835 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
88836 l_balance_type_code <> 'B' THEN
88837 IF NVL(p_source_97,9E125) = 34
88838 THEN
88839
88840 --
88841 XLA_AE_LINES_PKG.SetNewLine;
88842
88843 p_balance_type_code := l_balance_type_code;
88844 -- set the flag so later we will know whether the gain loss line needs to be created
88845
88846 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
88847 p_actual_flag :='A';
88848 END IF;
88849
88850 --
88851 -- bulk performance
88852 --
88853 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
88854 p_header_num => 0); -- 4262811
88855 --
88856 -- set accounting line options
88857 --
88858 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
88859 p_natural_side_code => 'D'
88860 , p_gain_or_loss_flag => 'N'
88861 , p_gl_transfer_mode_code => 'S'
88862 , p_acct_entry_type_code => 'A'
88863 , p_switch_side_flag => 'Y'
88864 , p_merge_duplicate_code => 'N'
88865 );
88866 --
88867 l_acc_rev_natural_side_code := 'C'; -- 4262811
88868 --
88869 --
88870 -- set accounting line type info
88871 --
88872 xla_ae_lines_pkg.SetAcctLineType
88873 (p_component_type => l_component_type
88874 ,p_event_type_code => l_event_type_code
88875 ,p_line_definition_owner_code => l_line_definition_owner_code
88876 ,p_line_definition_code => l_line_definition_code
88877 ,p_accounting_line_code => l_component_code
88878 ,p_accounting_line_type_code => l_component_type_code
88879 ,p_accounting_line_appl_id => l_component_appl_id
88880 ,p_amb_context_code => l_amb_context_code
88881 ,p_entity_code => l_entity_code
88882 ,p_event_class_code => l_event_class_code);
88883 --
88884 -- set accounting class
88885 --
88886 xla_ae_lines_pkg.SetAcctClass(
88887 p_accounting_class_code => 'INTERORG_PROFIT'
88888 , p_ae_header_id => l_ae_header_id
88889 );
88890
88891 --
88892 -- set rounding class
88893 --
88894 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
88895 'INTERORG_PROFIT';
88896
88897 --
88898 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
88899 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
88900 --
88901 -- bulk performance
88902 --
88903 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
88904
88905 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
88906 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
88907
88908 -- 4955764
88909 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
88910 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
88911
88912 -- 4458381 Public Sector Enh
88913
88914 --
88915 -- set accounting attributes for the line type
88916 --
88917 l_entered_amt_idx := 3;
88918 l_accted_amt_idx := 8;
88919 l_bflow_applied_to_amt_idx := NULL; -- 5132302
88920 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
88921 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
88922 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
88923 l_rec_acct_attrs.array_char_value(2) := p_source_85;
88924 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
88925 l_rec_acct_attrs.array_num_value(3) := p_source_91;
88926 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
88927 l_rec_acct_attrs.array_char_value(4) := p_source_88;
88928 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
88929 l_rec_acct_attrs.array_date_value(5) := p_source_92;
88930 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
88931 l_rec_acct_attrs.array_num_value(6) := p_source_93;
88932 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
88933 l_rec_acct_attrs.array_char_value(7) := p_source_94;
88934 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
88935 l_rec_acct_attrs.array_num_value(8) := p_source_95;
88936
88937 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
88938 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
88939
88940 ---------------------------------------------------------------------------------------------------------------
88941 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
88942 ---------------------------------------------------------------------------------------------------------------
88943 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
88944
88945 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
88946 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
88947
88948 IF xla_accounting_cache_pkg.GetValueChar
88949 (p_source_code => 'LEDGER_CATEGORY_CODE'
88950 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
88951 AND l_bflow_method_code = 'PRIOR_ENTRY'
88952 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
88953 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
88954 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
88955 )
88956 THEN
88957 xla_ae_lines_pkg.BflowUpgEntry
88958 (p_business_method_code => l_bflow_method_code
88959 ,p_business_class_code => l_bflow_class_code
88960 ,p_balance_type => l_balance_type_code);
88961 ELSE
88962 NULL;
88963 -- No business flow processing for business flow method of NONE.
88964 END IF;
88965
88966 --
88967 -- call analytical criteria
88968 --
88969
88970 --
88971 -- call description
88972 --
88973
88974 xla_ae_lines_pkg.SetLineDescription(
88975 p_ae_header_id => l_ae_header_id
88976 ,p_description => Description_1 (
88977 p_application_id => p_application_id
88978 , p_ae_header_id => l_ae_header_id
88979 , p_source_1 => p_source_1
88980 , p_source_2 => p_source_2
88981 , p_source_3 => p_source_3
88982 , p_source_4 => p_source_4
88983 , p_source_5 => p_source_5
88984 )
88985 );
88986
88987
88988 --
88989 -- call ADRs
88990 -- Bug 4922099
88991 --
88992 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
88993 (NVL(l_actual_upg_option, 'N') = 'O') OR
88994 (NVL(l_enc_upg_option, 'N') = 'O')
88995 )
88996 THEN
88997 NULL;
88998 --
88999 --
89000
89001 l_ccid := AcctDerRule_6(
89002 p_application_id => p_application_id
89003 , p_ae_header_id => l_ae_header_id
89004 , p_source_11 => p_source_11
89005 , x_transaction_coa_id => l_adr_transaction_coa_id
89006 , x_accounting_coa_id => l_adr_accounting_coa_id
89007 , x_value_type_code => l_adr_value_type_code
89008 , p_side => 'NA'
89009 );
89010
89011 xla_ae_lines_pkg.set_ccid(
89012 p_code_combination_id => l_ccid
89013 , p_value_type_code => l_adr_value_type_code
89014 , p_transaction_coa_id => l_adr_transaction_coa_id
89015 , p_accounting_coa_id => l_adr_accounting_coa_id
89016 , p_adr_code => 'CST_DEFAULT'
89017 , p_adr_type_code => 'S'
89018 , p_component_type => l_component_type
89019 , p_component_code => l_component_code
89020 , p_component_type_code => l_component_type_code
89021 , p_component_appl_id => l_component_appl_id
89022 , p_amb_context_code => l_amb_context_code
89023 , p_side => 'NA'
89024 );
89025
89026
89027 --
89028 --
89029 END IF;
89030 --
89031 -- Bug 4922099
89032 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
89033 (NVL(l_enc_upg_option, 'N') = 'O')
89034 ) AND
89035 (l_bflow_method_code = 'PRIOR_ENTRY')
89036 )
89037 THEN
89038 IF
89039 --
89040 1 = 2
89041 --
89042 THEN
89043 xla_accounting_err_pkg.build_message
89044 (p_appli_s_name => 'XLA'
89045 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
89046 ,p_token_1 => 'LINE_NUMBER'
89047 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
89048 ,p_token_2 => 'LINE_TYPE_NAME'
89049 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
89050 l_component_type
89051 ,l_component_code
89052 ,l_component_type_code
89053 ,l_component_appl_id
89054 ,l_amb_context_code
89055 ,l_entity_code
89056 ,l_event_class_code
89057 )
89058 ,p_token_3 => 'OWNER'
89059 ,p_value_3 => xla_lookups_pkg.get_meaning(
89060 p_lookup_type => 'XLA_OWNER_TYPE'
89061 ,p_lookup_code => l_component_type_code
89062 )
89063 ,p_token_4 => 'PRODUCT_NAME'
89064 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
89065 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
89066 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
89067 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
89068 ,p_ae_header_id => NULL
89069 );
89070
89071 IF (C_LEVEL_ERROR>= g_log_level) THEN
89072 trace
89073 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
89074 ,p_level => C_LEVEL_ERROR
89075 ,p_module => l_log_module);
89076 END IF;
89077 END IF;
89078 END IF;
89079 --
89080 --
89081 ------------------------------------------------------------------------------------------------
89082 -- 4219869 Business Flow
89083 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
89084 -- Prior Entry. Currently, the following code is always generated.
89085 ------------------------------------------------------------------------------------------------
89086 XLA_AE_LINES_PKG.ValidateCurrentLine;
89087
89088 ------------------------------------------------------------------------------------
89089 -- 4219869 Business Flow
89090 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
89091 ------------------------------------------------------------------------------------
89092 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
89093
89094 ----------------------------------------------------------------------------------
89095 -- 4219869 Business Flow
89096 -- Update journal entry status -- Need to generate this within IF <condition>
89097 ----------------------------------------------------------------------------------
89098 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
89099 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
89100 ,p_balance_type_code => l_balance_type_code
89101 );
89102
89103 -------------------------------------------------------------------------------------------
89104 -- 4262811 - Generate the Accrual Reversal lines
89105 -------------------------------------------------------------------------------------------
89106 BEGIN
89107 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
89108 (g_array_event(p_event_id).array_value_num('header_index'));
89109 IF l_acc_rev_flag IS NULL THEN
89110 l_acc_rev_flag := 'N';
89111 END IF;
89112 EXCEPTION
89113 WHEN OTHERS THEN
89114 l_acc_rev_flag := 'N';
89115 END;
89116 --
89117 IF (l_acc_rev_flag = 'Y') THEN
89118
89119 -- 4645092 ------------------------------------------------------------------------------
89120 -- To allow MPA report to determine if it should generate report process
89121 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
89122 ------------------------------------------------------------------------------------------
89123
89124 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
89125 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
89126 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
89127 -- call ADRs
89128 -- Bug 4922099
89129 --
89130 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
89131 (NVL(l_actual_upg_option, 'N') = 'O') OR
89132 (NVL(l_enc_upg_option, 'N') = 'O')
89133 )
89134 THEN
89135 NULL;
89136 --
89137 --
89138
89139 l_ccid := AcctDerRule_6(
89140 p_application_id => p_application_id
89141 , p_ae_header_id => l_ae_header_id
89142 , p_source_11 => p_source_11
89143 , x_transaction_coa_id => l_adr_transaction_coa_id
89144 , x_accounting_coa_id => l_adr_accounting_coa_id
89145 , x_value_type_code => l_adr_value_type_code
89146 , p_side => 'NA'
89147 );
89148
89149 xla_ae_lines_pkg.set_ccid(
89150 p_code_combination_id => l_ccid
89151 , p_value_type_code => l_adr_value_type_code
89152 , p_transaction_coa_id => l_adr_transaction_coa_id
89153 , p_accounting_coa_id => l_adr_accounting_coa_id
89154 , p_adr_code => 'CST_DEFAULT'
89155 , p_adr_type_code => 'S'
89156 , p_component_type => l_component_type
89157 , p_component_code => l_component_code
89158 , p_component_type_code => l_component_type_code
89159 , p_component_appl_id => l_component_appl_id
89160 , p_amb_context_code => l_amb_context_code
89161 , p_side => 'NA'
89162 );
89163
89164
89165 --
89166 --
89167 END IF;
89168
89169 --
89170 -- Update the line information that should be overwritten
89171 --
89172 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
89173 p_header_num => 1);
89174 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
89175
89176 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
89177
89178 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
89179 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
89180 END IF;
89181
89182 --
89183 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
89184 --
89185 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
89186 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
89187 ELSE
89188 ---------------------------------------------------------------------------------------------------
89189 -- 4262811a Switch Sign
89190 ---------------------------------------------------------------------------------------------------
89191 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
89192 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
89193 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89194 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
89195 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89196 -- 5132302
89197 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
89198 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89199
89200 END IF;
89201
89202 -- 4955764
89203 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
89204 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
89205
89206
89207 XLA_AE_LINES_PKG.ValidateCurrentLine;
89208 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
89209
89210 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
89211 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
89212 ,p_balance_type_code => l_balance_type_code);
89213
89214 END IF;
89215
89216 -----------------------------------------------------------------------------------------
89217 -- 4262811 Multiperiod Accounting
89218 -----------------------------------------------------------------------------------------
89219 -- No MPA option is assigned.
89220
89221
89222 END IF;
89223 END IF;
89224 --
89225
89226 --
89227 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
89228 trace
89229 (p_msg => 'END of AcctLineType_180'
89230 ,p_level => C_LEVEL_PROCEDURE
89231 ,p_module => l_log_module);
89232 END IF;
89233 --
89234 EXCEPTION
89235 WHEN xla_exceptions_pkg.application_exception THEN
89236 RAISE;
89237 WHEN OTHERS THEN
89238 xla_exceptions_pkg.raise_message
89239 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_180');
89240 END AcctLineType_180;
89241 --
89242
89243 ---------------------------------------
89244 --
89245 -- PRIVATE FUNCTION
89246 -- AcctLineType_181
89247 --
89248 ---------------------------------------
89249 PROCEDURE AcctLineType_181 (
89250 p_application_id IN NUMBER
89251 ,p_event_id IN NUMBER
89252 ,p_calculate_acctd_flag IN VARCHAR2
89253 ,p_calculate_g_l_flag IN VARCHAR2
89254 ,p_actual_flag IN OUT VARCHAR2
89255 ,p_balance_type_code OUT VARCHAR2
89256 ,p_gain_or_loss_ref OUT VARCHAR2
89257
89258 --TRANSACTION_ID
89259 , p_source_1 IN NUMBER
89260 --Item Concatenated Segments
89261 , p_source_2 IN VARCHAR2
89262 --Transaction Quantity
89263 , p_source_3 IN NUMBER
89264 --Transaction Unit of Measure Code
89265 , p_source_4 IN VARCHAR2
89266 --Inventory Transaction Type Description
89267 , p_source_5 IN VARCHAR2
89268 --Cost Management Default Account
89269 , p_source_11 IN NUMBER
89270 --DISTRIBUTION_IDENTIFIER
89271 , p_source_84 IN NUMBER
89272 --Distribution Type
89273 , p_source_85 IN VARCHAR2
89274 , p_source_85_meaning IN VARCHAR2
89275 --Entered Currency Code
89276 , p_source_88 IN VARCHAR2
89277 --Entered Amount
89278 , p_source_91 IN NUMBER
89279 --Currency Conversion Date
89280 , p_source_92 IN DATE
89281 --Currency Conversion Rate
89282 , p_source_93 IN NUMBER
89283 --Currency Conversion Type
89284 , p_source_94 IN VARCHAR2
89285 --Accounted Amount
89286 , p_source_95 IN NUMBER
89287 --Accounting Line Type
89288 , p_source_97 IN NUMBER
89289 )
89290 IS
89291
89292 l_component_type VARCHAR2(80);
89293 l_component_code VARCHAR2(30);
89294 l_component_type_code VARCHAR2(1);
89295 l_component_appl_id INTEGER;
89296 l_amb_context_code VARCHAR2(30);
89297 l_entity_code VARCHAR2(30);
89298 l_event_class_code VARCHAR2(30);
89299 l_ae_header_id NUMBER;
89300 l_event_type_code VARCHAR2(30);
89301 l_line_definition_code VARCHAR2(30);
89302 l_line_definition_owner_code VARCHAR2(1);
89303 --
89304 -- adr variables
89305 l_segment VARCHAR2(30);
89306 l_ccid NUMBER;
89307 l_adr_transaction_coa_id NUMBER;
89308 l_adr_accounting_coa_id NUMBER;
89309 l_adr_flexfield_segment_code VARCHAR2(30);
89310 l_adr_flex_value_set_id NUMBER;
89311 l_adr_value_type_code VARCHAR2(30);
89312 l_adr_value_combination_id NUMBER;
89313 l_adr_value_segment_code VARCHAR2(30);
89314
89315 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
89316 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
89317 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
89318 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
89319
89320 -- 4262811 Variables ------------------------------------------------------------------------------------------
89321 l_entered_amt_idx NUMBER;
89322 l_accted_amt_idx NUMBER;
89323 l_acc_rev_flag VARCHAR2(1);
89324 l_accrual_line_num NUMBER;
89325 l_tmp_amt NUMBER;
89326 l_acc_rev_natural_side_code VARCHAR2(1);
89327
89328 l_num_entries NUMBER;
89329 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
89330 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
89331 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
89332 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
89333 l_recog_line_1 NUMBER;
89334 l_recog_line_2 NUMBER;
89335
89336 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
89337 l_bflow_applied_to_amt NUMBER; -- 5132302
89338 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
89339
89340 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
89341
89342 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
89343 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
89344
89345 ---------------------------------------------------------------------------------------------------------------
89346
89347
89348 --
89349 -- bulk performance
89350 --
89351 l_balance_type_code VARCHAR2(1);
89352 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
89353 l_log_module VARCHAR2(240);
89354
89355 --
89356 -- Upgrade strategy
89357 --
89358 l_actual_upg_option VARCHAR2(1);
89359 l_enc_upg_option VARCHAR2(1);
89360
89361 --
89362 BEGIN
89363 --
89364 IF g_log_enabled THEN
89365 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_181';
89366 END IF;
89367 --
89368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
89369
89370 trace
89371 (p_msg => 'BEGIN of AcctLineType_181'
89372 ,p_level => C_LEVEL_PROCEDURE
89373 ,p_module => l_log_module);
89374
89375 END IF;
89376 --
89377 l_component_type := 'AMB_JLT';
89378 l_component_code := 'INTERORG_PROFIT_OPM';
89379 l_component_type_code := 'S';
89380 l_component_appl_id := 707;
89381 l_amb_context_code := 'DEFAULT';
89382 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
89383 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
89384 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
89385 l_line_definition_owner_code := 'S';
89386 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
89387 --
89388 l_balance_type_code := 'A';
89389 l_segment := NULL;
89390 l_ccid := NULL;
89391 l_adr_transaction_coa_id := NULL;
89392 l_adr_accounting_coa_id := NULL;
89393 l_adr_flexfield_segment_code := NULL;
89394 l_adr_flex_value_set_id := NULL;
89395 l_adr_value_type_code := NULL;
89396 l_adr_value_combination_id := NULL;
89397 l_adr_value_segment_code := NULL;
89398
89399 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
89400 l_bflow_class_code := ''; -- 4219869 Business Flow
89401 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
89402 l_budgetary_control_flag := 'N';
89403
89404 l_bflow_applied_to_amt_idx := NULL; -- 5132302
89405 l_bflow_applied_to_amt := NULL; -- 5132302
89406 l_entered_amt_idx := NULL; -- 4262811
89407 l_accted_amt_idx := NULL; -- 4262811
89408 l_acc_rev_flag := NULL; -- 4262811
89409 l_accrual_line_num := NULL; -- 4262811
89410 l_tmp_amt := NULL; -- 4262811
89411 --
89412
89413 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
89414 l_balance_type_code <> 'B' THEN
89415 IF NVL(p_source_97,9E125) = 34
89416 THEN
89417
89418 --
89419 XLA_AE_LINES_PKG.SetNewLine;
89420
89421 p_balance_type_code := l_balance_type_code;
89422 -- set the flag so later we will know whether the gain loss line needs to be created
89423
89424 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
89425 p_actual_flag :='A';
89426 END IF;
89427
89428 --
89429 -- bulk performance
89430 --
89431 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
89432 p_header_num => 0); -- 4262811
89433 --
89434 -- set accounting line options
89435 --
89436 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
89437 p_natural_side_code => 'D'
89438 , p_gain_or_loss_flag => 'N'
89439 , p_gl_transfer_mode_code => 'S'
89440 , p_acct_entry_type_code => 'A'
89441 , p_switch_side_flag => 'Y'
89442 , p_merge_duplicate_code => 'N'
89443 );
89444 --
89445 l_acc_rev_natural_side_code := 'C'; -- 4262811
89446 --
89447 --
89448 -- set accounting line type info
89449 --
89450 xla_ae_lines_pkg.SetAcctLineType
89451 (p_component_type => l_component_type
89452 ,p_event_type_code => l_event_type_code
89453 ,p_line_definition_owner_code => l_line_definition_owner_code
89454 ,p_line_definition_code => l_line_definition_code
89455 ,p_accounting_line_code => l_component_code
89456 ,p_accounting_line_type_code => l_component_type_code
89457 ,p_accounting_line_appl_id => l_component_appl_id
89458 ,p_amb_context_code => l_amb_context_code
89459 ,p_entity_code => l_entity_code
89460 ,p_event_class_code => l_event_class_code);
89461 --
89462 -- set accounting class
89463 --
89464 xla_ae_lines_pkg.SetAcctClass(
89465 p_accounting_class_code => 'INTERORG_PROFIT'
89466 , p_ae_header_id => l_ae_header_id
89467 );
89468
89469 --
89470 -- set rounding class
89471 --
89472 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
89473 'INTERORG_PROFIT';
89474
89475 --
89476 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
89477 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
89478 --
89479 -- bulk performance
89480 --
89481 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
89482
89483 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
89484 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
89485
89486 -- 4955764
89487 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
89488 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
89489
89490 -- 4458381 Public Sector Enh
89491
89492 --
89493 -- set accounting attributes for the line type
89494 --
89495 l_entered_amt_idx := 3;
89496 l_accted_amt_idx := 8;
89497 l_bflow_applied_to_amt_idx := NULL; -- 5132302
89498 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
89499 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
89500 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
89501 l_rec_acct_attrs.array_char_value(2) := p_source_85;
89502 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
89503 l_rec_acct_attrs.array_num_value(3) := p_source_91;
89504 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
89505 l_rec_acct_attrs.array_char_value(4) := p_source_88;
89506 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
89507 l_rec_acct_attrs.array_date_value(5) := p_source_92;
89508 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
89509 l_rec_acct_attrs.array_num_value(6) := p_source_93;
89510 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
89511 l_rec_acct_attrs.array_char_value(7) := p_source_94;
89512 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
89513 l_rec_acct_attrs.array_num_value(8) := p_source_95;
89514
89515 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
89516 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
89517
89518 ---------------------------------------------------------------------------------------------------------------
89519 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
89520 ---------------------------------------------------------------------------------------------------------------
89521 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
89522
89523 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
89524 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
89525
89526 IF xla_accounting_cache_pkg.GetValueChar
89527 (p_source_code => 'LEDGER_CATEGORY_CODE'
89528 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
89529 AND l_bflow_method_code = 'PRIOR_ENTRY'
89530 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
89531 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
89532 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
89533 )
89534 THEN
89535 xla_ae_lines_pkg.BflowUpgEntry
89536 (p_business_method_code => l_bflow_method_code
89537 ,p_business_class_code => l_bflow_class_code
89538 ,p_balance_type => l_balance_type_code);
89539 ELSE
89540 NULL;
89541 -- No business flow processing for business flow method of NONE.
89542 END IF;
89543
89544 --
89545 -- call analytical criteria
89546 --
89547
89548 --
89549 -- call description
89550 --
89551
89552 xla_ae_lines_pkg.SetLineDescription(
89553 p_ae_header_id => l_ae_header_id
89554 ,p_description => Description_1 (
89555 p_application_id => p_application_id
89556 , p_ae_header_id => l_ae_header_id
89557 , p_source_1 => p_source_1
89558 , p_source_2 => p_source_2
89559 , p_source_3 => p_source_3
89560 , p_source_4 => p_source_4
89561 , p_source_5 => p_source_5
89562 )
89563 );
89564
89565
89566 --
89567 -- call ADRs
89568 -- Bug 4922099
89569 --
89570 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
89571 (NVL(l_actual_upg_option, 'N') = 'O') OR
89572 (NVL(l_enc_upg_option, 'N') = 'O')
89573 )
89574 THEN
89575 NULL;
89576 --
89577 --
89578
89579 l_ccid := AcctDerRule_6(
89580 p_application_id => p_application_id
89581 , p_ae_header_id => l_ae_header_id
89582 , p_source_11 => p_source_11
89583 , x_transaction_coa_id => l_adr_transaction_coa_id
89584 , x_accounting_coa_id => l_adr_accounting_coa_id
89585 , x_value_type_code => l_adr_value_type_code
89586 , p_side => 'NA'
89587 );
89588
89589 xla_ae_lines_pkg.set_ccid(
89590 p_code_combination_id => l_ccid
89591 , p_value_type_code => l_adr_value_type_code
89592 , p_transaction_coa_id => l_adr_transaction_coa_id
89593 , p_accounting_coa_id => l_adr_accounting_coa_id
89594 , p_adr_code => 'CST_DEFAULT'
89595 , p_adr_type_code => 'S'
89596 , p_component_type => l_component_type
89597 , p_component_code => l_component_code
89598 , p_component_type_code => l_component_type_code
89599 , p_component_appl_id => l_component_appl_id
89600 , p_amb_context_code => l_amb_context_code
89601 , p_side => 'NA'
89602 );
89603
89604
89605 --
89606 --
89607 END IF;
89608 --
89609 -- Bug 4922099
89610 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
89611 (NVL(l_enc_upg_option, 'N') = 'O')
89612 ) AND
89613 (l_bflow_method_code = 'PRIOR_ENTRY')
89614 )
89615 THEN
89616 IF
89617 --
89618 1 = 2
89619 --
89620 THEN
89621 xla_accounting_err_pkg.build_message
89622 (p_appli_s_name => 'XLA'
89623 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
89624 ,p_token_1 => 'LINE_NUMBER'
89625 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
89626 ,p_token_2 => 'LINE_TYPE_NAME'
89627 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
89628 l_component_type
89629 ,l_component_code
89630 ,l_component_type_code
89631 ,l_component_appl_id
89632 ,l_amb_context_code
89633 ,l_entity_code
89634 ,l_event_class_code
89635 )
89636 ,p_token_3 => 'OWNER'
89637 ,p_value_3 => xla_lookups_pkg.get_meaning(
89638 p_lookup_type => 'XLA_OWNER_TYPE'
89639 ,p_lookup_code => l_component_type_code
89640 )
89641 ,p_token_4 => 'PRODUCT_NAME'
89642 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
89643 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
89644 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
89645 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
89646 ,p_ae_header_id => NULL
89647 );
89648
89649 IF (C_LEVEL_ERROR>= g_log_level) THEN
89650 trace
89651 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
89652 ,p_level => C_LEVEL_ERROR
89653 ,p_module => l_log_module);
89654 END IF;
89655 END IF;
89656 END IF;
89657 --
89658 --
89659 ------------------------------------------------------------------------------------------------
89660 -- 4219869 Business Flow
89661 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
89662 -- Prior Entry. Currently, the following code is always generated.
89663 ------------------------------------------------------------------------------------------------
89664 XLA_AE_LINES_PKG.ValidateCurrentLine;
89665
89666 ------------------------------------------------------------------------------------
89667 -- 4219869 Business Flow
89668 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
89669 ------------------------------------------------------------------------------------
89670 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
89671
89672 ----------------------------------------------------------------------------------
89673 -- 4219869 Business Flow
89674 -- Update journal entry status -- Need to generate this within IF <condition>
89675 ----------------------------------------------------------------------------------
89676 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
89677 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
89678 ,p_balance_type_code => l_balance_type_code
89679 );
89680
89681 -------------------------------------------------------------------------------------------
89682 -- 4262811 - Generate the Accrual Reversal lines
89683 -------------------------------------------------------------------------------------------
89684 BEGIN
89685 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
89686 (g_array_event(p_event_id).array_value_num('header_index'));
89687 IF l_acc_rev_flag IS NULL THEN
89688 l_acc_rev_flag := 'N';
89689 END IF;
89690 EXCEPTION
89691 WHEN OTHERS THEN
89692 l_acc_rev_flag := 'N';
89693 END;
89694 --
89695 IF (l_acc_rev_flag = 'Y') THEN
89696
89697 -- 4645092 ------------------------------------------------------------------------------
89698 -- To allow MPA report to determine if it should generate report process
89699 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
89700 ------------------------------------------------------------------------------------------
89701
89702 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
89703 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
89704 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
89705 -- call ADRs
89706 -- Bug 4922099
89707 --
89708 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
89709 (NVL(l_actual_upg_option, 'N') = 'O') OR
89710 (NVL(l_enc_upg_option, 'N') = 'O')
89711 )
89712 THEN
89713 NULL;
89714 --
89715 --
89716
89717 l_ccid := AcctDerRule_6(
89718 p_application_id => p_application_id
89719 , p_ae_header_id => l_ae_header_id
89720 , p_source_11 => p_source_11
89721 , x_transaction_coa_id => l_adr_transaction_coa_id
89722 , x_accounting_coa_id => l_adr_accounting_coa_id
89723 , x_value_type_code => l_adr_value_type_code
89724 , p_side => 'NA'
89725 );
89726
89727 xla_ae_lines_pkg.set_ccid(
89728 p_code_combination_id => l_ccid
89729 , p_value_type_code => l_adr_value_type_code
89730 , p_transaction_coa_id => l_adr_transaction_coa_id
89731 , p_accounting_coa_id => l_adr_accounting_coa_id
89732 , p_adr_code => 'CST_DEFAULT'
89733 , p_adr_type_code => 'S'
89734 , p_component_type => l_component_type
89735 , p_component_code => l_component_code
89736 , p_component_type_code => l_component_type_code
89737 , p_component_appl_id => l_component_appl_id
89738 , p_amb_context_code => l_amb_context_code
89739 , p_side => 'NA'
89740 );
89741
89742
89743 --
89744 --
89745 END IF;
89746
89747 --
89748 -- Update the line information that should be overwritten
89749 --
89750 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
89751 p_header_num => 1);
89752 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
89753
89754 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
89755
89756 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
89757 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
89758 END IF;
89759
89760 --
89761 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
89762 --
89763 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
89764 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
89765 ELSE
89766 ---------------------------------------------------------------------------------------------------
89767 -- 4262811a Switch Sign
89768 ---------------------------------------------------------------------------------------------------
89769 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
89770 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
89771 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89772 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
89773 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89774 -- 5132302
89775 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
89776 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
89777
89778 END IF;
89779
89780 -- 4955764
89781 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
89782 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
89783
89784
89785 XLA_AE_LINES_PKG.ValidateCurrentLine;
89786 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
89787
89788 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
89789 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
89790 ,p_balance_type_code => l_balance_type_code);
89791
89792 END IF;
89793
89794 -----------------------------------------------------------------------------------------
89795 -- 4262811 Multiperiod Accounting
89796 -----------------------------------------------------------------------------------------
89797 -- No MPA option is assigned.
89798
89799
89800 END IF;
89801 END IF;
89802 --
89803
89804 --
89805 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
89806 trace
89807 (p_msg => 'END of AcctLineType_181'
89808 ,p_level => C_LEVEL_PROCEDURE
89809 ,p_module => l_log_module);
89810 END IF;
89811 --
89812 EXCEPTION
89813 WHEN xla_exceptions_pkg.application_exception THEN
89814 RAISE;
89815 WHEN OTHERS THEN
89816 xla_exceptions_pkg.raise_message
89817 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_181');
89818 END AcctLineType_181;
89819 --
89820
89821 ---------------------------------------
89822 --
89823 -- PRIVATE FUNCTION
89824 -- AcctLineType_182
89825 --
89826 ---------------------------------------
89827 PROCEDURE AcctLineType_182 (
89828 p_application_id IN NUMBER
89829 ,p_event_id IN NUMBER
89830 ,p_calculate_acctd_flag IN VARCHAR2
89831 ,p_calculate_g_l_flag IN VARCHAR2
89832 ,p_actual_flag IN OUT VARCHAR2
89833 ,p_balance_type_code OUT VARCHAR2
89834 ,p_gain_or_loss_ref OUT VARCHAR2
89835
89836 --TRANSACTION_ID
89837 , p_source_1 IN NUMBER
89838 --Item Concatenated Segments
89839 , p_source_2 IN VARCHAR2
89840 --Transaction Quantity
89841 , p_source_3 IN NUMBER
89842 --Transaction Unit of Measure Code
89843 , p_source_4 IN VARCHAR2
89844 --Inventory Transaction Type Description
89845 , p_source_5 IN VARCHAR2
89846 --Cost Management Default Account
89847 , p_source_11 IN NUMBER
89848 --DISTRIBUTION_IDENTIFIER
89849 , p_source_84 IN NUMBER
89850 --Distribution Type
89851 , p_source_85 IN VARCHAR2
89852 , p_source_85_meaning IN VARCHAR2
89853 --Entered Currency Code
89854 , p_source_88 IN VARCHAR2
89855 --Entered Amount
89856 , p_source_91 IN NUMBER
89857 --Currency Conversion Date
89858 , p_source_92 IN DATE
89859 --Currency Conversion Rate
89860 , p_source_93 IN NUMBER
89861 --Currency Conversion Type
89862 , p_source_94 IN VARCHAR2
89863 --Accounted Amount
89864 , p_source_95 IN NUMBER
89865 --Accounting Line Type
89866 , p_source_97 IN NUMBER
89867 )
89868 IS
89869
89870 l_component_type VARCHAR2(80);
89871 l_component_code VARCHAR2(30);
89872 l_component_type_code VARCHAR2(1);
89873 l_component_appl_id INTEGER;
89874 l_amb_context_code VARCHAR2(30);
89875 l_entity_code VARCHAR2(30);
89876 l_event_class_code VARCHAR2(30);
89877 l_ae_header_id NUMBER;
89878 l_event_type_code VARCHAR2(30);
89879 l_line_definition_code VARCHAR2(30);
89880 l_line_definition_owner_code VARCHAR2(1);
89881 --
89882 -- adr variables
89883 l_segment VARCHAR2(30);
89884 l_ccid NUMBER;
89885 l_adr_transaction_coa_id NUMBER;
89886 l_adr_accounting_coa_id NUMBER;
89887 l_adr_flexfield_segment_code VARCHAR2(30);
89888 l_adr_flex_value_set_id NUMBER;
89889 l_adr_value_type_code VARCHAR2(30);
89890 l_adr_value_combination_id NUMBER;
89891 l_adr_value_segment_code VARCHAR2(30);
89892
89893 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
89894 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
89895 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
89896 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
89897
89898 -- 4262811 Variables ------------------------------------------------------------------------------------------
89899 l_entered_amt_idx NUMBER;
89900 l_accted_amt_idx NUMBER;
89901 l_acc_rev_flag VARCHAR2(1);
89902 l_accrual_line_num NUMBER;
89903 l_tmp_amt NUMBER;
89904 l_acc_rev_natural_side_code VARCHAR2(1);
89905
89906 l_num_entries NUMBER;
89907 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
89908 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
89909 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
89910 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
89911 l_recog_line_1 NUMBER;
89912 l_recog_line_2 NUMBER;
89913
89914 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
89915 l_bflow_applied_to_amt NUMBER; -- 5132302
89916 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
89917
89918 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
89919
89920 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
89921 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
89922
89923 ---------------------------------------------------------------------------------------------------------------
89924
89925
89926 --
89927 -- bulk performance
89928 --
89929 l_balance_type_code VARCHAR2(1);
89930 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
89931 l_log_module VARCHAR2(240);
89932
89933 --
89934 -- Upgrade strategy
89935 --
89936 l_actual_upg_option VARCHAR2(1);
89937 l_enc_upg_option VARCHAR2(1);
89938
89939 --
89940 BEGIN
89941 --
89942 IF g_log_enabled THEN
89943 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_182';
89944 END IF;
89945 --
89946 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
89947
89948 trace
89949 (p_msg => 'BEGIN of AcctLineType_182'
89950 ,p_level => C_LEVEL_PROCEDURE
89951 ,p_module => l_log_module);
89952
89953 END IF;
89954 --
89955 l_component_type := 'AMB_JLT';
89956 l_component_code := 'INTERORG_PROFIT_OPM';
89957 l_component_type_code := 'S';
89958 l_component_appl_id := 707;
89959 l_amb_context_code := 'DEFAULT';
89960 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
89961 l_event_class_code := 'USER_DEFINE';
89962 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
89963 l_line_definition_owner_code := 'S';
89964 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
89965 --
89966 l_balance_type_code := 'A';
89967 l_segment := NULL;
89968 l_ccid := NULL;
89969 l_adr_transaction_coa_id := NULL;
89970 l_adr_accounting_coa_id := NULL;
89971 l_adr_flexfield_segment_code := NULL;
89972 l_adr_flex_value_set_id := NULL;
89973 l_adr_value_type_code := NULL;
89974 l_adr_value_combination_id := NULL;
89975 l_adr_value_segment_code := NULL;
89976
89977 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
89978 l_bflow_class_code := ''; -- 4219869 Business Flow
89979 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
89980 l_budgetary_control_flag := 'N';
89981
89982 l_bflow_applied_to_amt_idx := NULL; -- 5132302
89983 l_bflow_applied_to_amt := NULL; -- 5132302
89984 l_entered_amt_idx := NULL; -- 4262811
89985 l_accted_amt_idx := NULL; -- 4262811
89986 l_acc_rev_flag := NULL; -- 4262811
89987 l_accrual_line_num := NULL; -- 4262811
89988 l_tmp_amt := NULL; -- 4262811
89989 --
89990
89991 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
89992 l_balance_type_code <> 'B' THEN
89993 IF NVL(p_source_97,9E125) = 34
89994 THEN
89995
89996 --
89997 XLA_AE_LINES_PKG.SetNewLine;
89998
89999 p_balance_type_code := l_balance_type_code;
90000 -- set the flag so later we will know whether the gain loss line needs to be created
90001
90002 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
90003 p_actual_flag :='A';
90004 END IF;
90005
90006 --
90007 -- bulk performance
90008 --
90009 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
90010 p_header_num => 0); -- 4262811
90011 --
90012 -- set accounting line options
90013 --
90014 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
90015 p_natural_side_code => 'D'
90016 , p_gain_or_loss_flag => 'N'
90017 , p_gl_transfer_mode_code => 'S'
90018 , p_acct_entry_type_code => 'A'
90019 , p_switch_side_flag => 'Y'
90020 , p_merge_duplicate_code => 'N'
90021 );
90022 --
90023 l_acc_rev_natural_side_code := 'C'; -- 4262811
90024 --
90025 --
90026 -- set accounting line type info
90027 --
90028 xla_ae_lines_pkg.SetAcctLineType
90029 (p_component_type => l_component_type
90030 ,p_event_type_code => l_event_type_code
90031 ,p_line_definition_owner_code => l_line_definition_owner_code
90032 ,p_line_definition_code => l_line_definition_code
90033 ,p_accounting_line_code => l_component_code
90034 ,p_accounting_line_type_code => l_component_type_code
90035 ,p_accounting_line_appl_id => l_component_appl_id
90036 ,p_amb_context_code => l_amb_context_code
90037 ,p_entity_code => l_entity_code
90038 ,p_event_class_code => l_event_class_code);
90039 --
90040 -- set accounting class
90041 --
90042 xla_ae_lines_pkg.SetAcctClass(
90043 p_accounting_class_code => 'INTERORG_PROFIT'
90044 , p_ae_header_id => l_ae_header_id
90045 );
90046
90047 --
90048 -- set rounding class
90049 --
90050 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
90051 'INTERORG_PROFIT';
90052
90053 --
90054 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
90055 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
90056 --
90057 -- bulk performance
90058 --
90059 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
90060
90061 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
90062 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
90063
90064 -- 4955764
90065 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
90066 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
90067
90068 -- 4458381 Public Sector Enh
90069
90070 --
90071 -- set accounting attributes for the line type
90072 --
90073 l_entered_amt_idx := 3;
90074 l_accted_amt_idx := 8;
90075 l_bflow_applied_to_amt_idx := NULL; -- 5132302
90076 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
90077 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
90078 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
90079 l_rec_acct_attrs.array_char_value(2) := p_source_85;
90080 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
90081 l_rec_acct_attrs.array_num_value(3) := p_source_91;
90082 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
90083 l_rec_acct_attrs.array_char_value(4) := p_source_88;
90084 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
90085 l_rec_acct_attrs.array_date_value(5) := p_source_92;
90086 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
90087 l_rec_acct_attrs.array_num_value(6) := p_source_93;
90088 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
90089 l_rec_acct_attrs.array_char_value(7) := p_source_94;
90090 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
90091 l_rec_acct_attrs.array_num_value(8) := p_source_95;
90092
90093 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
90094 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
90095
90096 ---------------------------------------------------------------------------------------------------------------
90097 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
90098 ---------------------------------------------------------------------------------------------------------------
90099 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
90100
90101 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
90102 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
90103
90104 IF xla_accounting_cache_pkg.GetValueChar
90105 (p_source_code => 'LEDGER_CATEGORY_CODE'
90106 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
90107 AND l_bflow_method_code = 'PRIOR_ENTRY'
90108 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
90109 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
90110 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
90111 )
90112 THEN
90113 xla_ae_lines_pkg.BflowUpgEntry
90114 (p_business_method_code => l_bflow_method_code
90115 ,p_business_class_code => l_bflow_class_code
90116 ,p_balance_type => l_balance_type_code);
90117 ELSE
90118 NULL;
90119 -- No business flow processing for business flow method of NONE.
90120 END IF;
90121
90122 --
90123 -- call analytical criteria
90124 --
90125
90126 --
90127 -- call description
90128 --
90129
90130 xla_ae_lines_pkg.SetLineDescription(
90131 p_ae_header_id => l_ae_header_id
90132 ,p_description => Description_1 (
90133 p_application_id => p_application_id
90134 , p_ae_header_id => l_ae_header_id
90135 , p_source_1 => p_source_1
90136 , p_source_2 => p_source_2
90137 , p_source_3 => p_source_3
90138 , p_source_4 => p_source_4
90139 , p_source_5 => p_source_5
90140 )
90141 );
90142
90143
90144 --
90145 -- call ADRs
90146 -- Bug 4922099
90147 --
90148 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
90149 (NVL(l_actual_upg_option, 'N') = 'O') OR
90150 (NVL(l_enc_upg_option, 'N') = 'O')
90151 )
90152 THEN
90153 NULL;
90154 --
90155 --
90156
90157 l_ccid := AcctDerRule_6(
90158 p_application_id => p_application_id
90159 , p_ae_header_id => l_ae_header_id
90160 , p_source_11 => p_source_11
90161 , x_transaction_coa_id => l_adr_transaction_coa_id
90162 , x_accounting_coa_id => l_adr_accounting_coa_id
90163 , x_value_type_code => l_adr_value_type_code
90164 , p_side => 'NA'
90165 );
90166
90167 xla_ae_lines_pkg.set_ccid(
90168 p_code_combination_id => l_ccid
90169 , p_value_type_code => l_adr_value_type_code
90170 , p_transaction_coa_id => l_adr_transaction_coa_id
90171 , p_accounting_coa_id => l_adr_accounting_coa_id
90172 , p_adr_code => 'CST_DEFAULT'
90173 , p_adr_type_code => 'S'
90174 , p_component_type => l_component_type
90175 , p_component_code => l_component_code
90176 , p_component_type_code => l_component_type_code
90177 , p_component_appl_id => l_component_appl_id
90178 , p_amb_context_code => l_amb_context_code
90179 , p_side => 'NA'
90180 );
90181
90182
90183 --
90184 --
90185 END IF;
90186 --
90187 -- Bug 4922099
90188 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
90189 (NVL(l_enc_upg_option, 'N') = 'O')
90190 ) AND
90191 (l_bflow_method_code = 'PRIOR_ENTRY')
90192 )
90193 THEN
90194 IF
90195 --
90196 1 = 2
90197 --
90198 THEN
90199 xla_accounting_err_pkg.build_message
90200 (p_appli_s_name => 'XLA'
90201 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
90202 ,p_token_1 => 'LINE_NUMBER'
90203 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
90204 ,p_token_2 => 'LINE_TYPE_NAME'
90205 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
90206 l_component_type
90207 ,l_component_code
90208 ,l_component_type_code
90209 ,l_component_appl_id
90210 ,l_amb_context_code
90211 ,l_entity_code
90212 ,l_event_class_code
90213 )
90214 ,p_token_3 => 'OWNER'
90215 ,p_value_3 => xla_lookups_pkg.get_meaning(
90216 p_lookup_type => 'XLA_OWNER_TYPE'
90217 ,p_lookup_code => l_component_type_code
90218 )
90219 ,p_token_4 => 'PRODUCT_NAME'
90220 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
90221 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
90222 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
90223 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
90224 ,p_ae_header_id => NULL
90225 );
90226
90227 IF (C_LEVEL_ERROR>= g_log_level) THEN
90228 trace
90229 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
90230 ,p_level => C_LEVEL_ERROR
90231 ,p_module => l_log_module);
90232 END IF;
90233 END IF;
90234 END IF;
90235 --
90236 --
90237 ------------------------------------------------------------------------------------------------
90238 -- 4219869 Business Flow
90239 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
90240 -- Prior Entry. Currently, the following code is always generated.
90241 ------------------------------------------------------------------------------------------------
90242 XLA_AE_LINES_PKG.ValidateCurrentLine;
90243
90244 ------------------------------------------------------------------------------------
90245 -- 4219869 Business Flow
90246 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
90247 ------------------------------------------------------------------------------------
90248 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
90249
90250 ----------------------------------------------------------------------------------
90251 -- 4219869 Business Flow
90252 -- Update journal entry status -- Need to generate this within IF <condition>
90253 ----------------------------------------------------------------------------------
90254 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
90255 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
90256 ,p_balance_type_code => l_balance_type_code
90257 );
90258
90259 -------------------------------------------------------------------------------------------
90260 -- 4262811 - Generate the Accrual Reversal lines
90261 -------------------------------------------------------------------------------------------
90262 BEGIN
90263 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
90264 (g_array_event(p_event_id).array_value_num('header_index'));
90265 IF l_acc_rev_flag IS NULL THEN
90266 l_acc_rev_flag := 'N';
90267 END IF;
90268 EXCEPTION
90269 WHEN OTHERS THEN
90270 l_acc_rev_flag := 'N';
90271 END;
90272 --
90273 IF (l_acc_rev_flag = 'Y') THEN
90274
90275 -- 4645092 ------------------------------------------------------------------------------
90276 -- To allow MPA report to determine if it should generate report process
90277 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
90278 ------------------------------------------------------------------------------------------
90279
90280 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
90281 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
90282 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
90283 -- call ADRs
90284 -- Bug 4922099
90285 --
90286 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
90287 (NVL(l_actual_upg_option, 'N') = 'O') OR
90288 (NVL(l_enc_upg_option, 'N') = 'O')
90289 )
90290 THEN
90291 NULL;
90292 --
90293 --
90294
90295 l_ccid := AcctDerRule_6(
90296 p_application_id => p_application_id
90297 , p_ae_header_id => l_ae_header_id
90298 , p_source_11 => p_source_11
90299 , x_transaction_coa_id => l_adr_transaction_coa_id
90300 , x_accounting_coa_id => l_adr_accounting_coa_id
90301 , x_value_type_code => l_adr_value_type_code
90302 , p_side => 'NA'
90303 );
90304
90305 xla_ae_lines_pkg.set_ccid(
90306 p_code_combination_id => l_ccid
90307 , p_value_type_code => l_adr_value_type_code
90308 , p_transaction_coa_id => l_adr_transaction_coa_id
90309 , p_accounting_coa_id => l_adr_accounting_coa_id
90310 , p_adr_code => 'CST_DEFAULT'
90311 , p_adr_type_code => 'S'
90312 , p_component_type => l_component_type
90313 , p_component_code => l_component_code
90314 , p_component_type_code => l_component_type_code
90315 , p_component_appl_id => l_component_appl_id
90316 , p_amb_context_code => l_amb_context_code
90317 , p_side => 'NA'
90318 );
90319
90320
90321 --
90322 --
90323 END IF;
90324
90325 --
90326 -- Update the line information that should be overwritten
90327 --
90328 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
90329 p_header_num => 1);
90330 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
90331
90332 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
90333
90334 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
90335 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
90336 END IF;
90337
90338 --
90339 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
90340 --
90341 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
90342 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
90343 ELSE
90344 ---------------------------------------------------------------------------------------------------
90345 -- 4262811a Switch Sign
90346 ---------------------------------------------------------------------------------------------------
90347 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
90348 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
90349 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90350 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
90351 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90352 -- 5132302
90353 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
90354 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90355
90356 END IF;
90357
90358 -- 4955764
90359 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
90360 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
90361
90362
90363 XLA_AE_LINES_PKG.ValidateCurrentLine;
90364 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
90365
90366 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
90367 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
90368 ,p_balance_type_code => l_balance_type_code);
90369
90370 END IF;
90371
90372 -----------------------------------------------------------------------------------------
90373 -- 4262811 Multiperiod Accounting
90374 -----------------------------------------------------------------------------------------
90375 -- No MPA option is assigned.
90376
90377
90378 END IF;
90379 END IF;
90380 --
90381
90382 --
90383 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
90384 trace
90385 (p_msg => 'END of AcctLineType_182'
90386 ,p_level => C_LEVEL_PROCEDURE
90387 ,p_module => l_log_module);
90388 END IF;
90389 --
90390 EXCEPTION
90391 WHEN xla_exceptions_pkg.application_exception THEN
90392 RAISE;
90393 WHEN OTHERS THEN
90394 xla_exceptions_pkg.raise_message
90395 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_182');
90396 END AcctLineType_182;
90397 --
90398
90399 ---------------------------------------
90400 --
90401 -- PRIVATE FUNCTION
90402 -- AcctLineType_183
90403 --
90404 ---------------------------------------
90405 PROCEDURE AcctLineType_183 (
90406 p_application_id IN NUMBER
90407 ,p_event_id IN NUMBER
90408 ,p_calculate_acctd_flag IN VARCHAR2
90409 ,p_calculate_g_l_flag IN VARCHAR2
90410 ,p_actual_flag IN OUT VARCHAR2
90411 ,p_balance_type_code OUT VARCHAR2
90412 ,p_gain_or_loss_ref OUT VARCHAR2
90413
90414 --TRANSACTION_ID
90415 , p_source_1 IN NUMBER
90416 --Item Concatenated Segments
90417 , p_source_2 IN VARCHAR2
90418 --Transaction Quantity
90419 , p_source_3 IN NUMBER
90420 --Transaction Unit of Measure Code
90421 , p_source_4 IN VARCHAR2
90422 --Inventory Transaction Type Description
90423 , p_source_5 IN VARCHAR2
90424 --Cost Management Default Account
90425 , p_source_11 IN NUMBER
90426 --DISTRIBUTION_IDENTIFIER
90427 , p_source_84 IN NUMBER
90428 --Distribution Type
90429 , p_source_85 IN VARCHAR2
90430 , p_source_85_meaning IN VARCHAR2
90431 --Entered Currency Code
90432 , p_source_88 IN VARCHAR2
90433 --Entered Amount
90434 , p_source_91 IN NUMBER
90435 --Currency Conversion Date
90436 , p_source_92 IN DATE
90437 --Currency Conversion Rate
90438 , p_source_93 IN NUMBER
90439 --Currency Conversion Type
90440 , p_source_94 IN VARCHAR2
90441 --Accounted Amount
90442 , p_source_95 IN NUMBER
90443 --Accounting Line Type
90444 , p_source_97 IN NUMBER
90445 )
90446 IS
90447
90448 l_component_type VARCHAR2(80);
90449 l_component_code VARCHAR2(30);
90450 l_component_type_code VARCHAR2(1);
90451 l_component_appl_id INTEGER;
90452 l_amb_context_code VARCHAR2(30);
90453 l_entity_code VARCHAR2(30);
90454 l_event_class_code VARCHAR2(30);
90455 l_ae_header_id NUMBER;
90456 l_event_type_code VARCHAR2(30);
90457 l_line_definition_code VARCHAR2(30);
90458 l_line_definition_owner_code VARCHAR2(1);
90459 --
90460 -- adr variables
90461 l_segment VARCHAR2(30);
90462 l_ccid NUMBER;
90463 l_adr_transaction_coa_id NUMBER;
90464 l_adr_accounting_coa_id NUMBER;
90465 l_adr_flexfield_segment_code VARCHAR2(30);
90466 l_adr_flex_value_set_id NUMBER;
90467 l_adr_value_type_code VARCHAR2(30);
90468 l_adr_value_combination_id NUMBER;
90469 l_adr_value_segment_code VARCHAR2(30);
90470
90471 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
90472 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
90473 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
90474 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
90475
90476 -- 4262811 Variables ------------------------------------------------------------------------------------------
90477 l_entered_amt_idx NUMBER;
90478 l_accted_amt_idx NUMBER;
90479 l_acc_rev_flag VARCHAR2(1);
90480 l_accrual_line_num NUMBER;
90481 l_tmp_amt NUMBER;
90482 l_acc_rev_natural_side_code VARCHAR2(1);
90483
90484 l_num_entries NUMBER;
90485 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
90486 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
90487 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
90488 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
90489 l_recog_line_1 NUMBER;
90490 l_recog_line_2 NUMBER;
90491
90492 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
90493 l_bflow_applied_to_amt NUMBER; -- 5132302
90494 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
90495
90496 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
90497
90498 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
90499 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
90500
90501 ---------------------------------------------------------------------------------------------------------------
90502
90503
90504 --
90505 -- bulk performance
90506 --
90507 l_balance_type_code VARCHAR2(1);
90508 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
90509 l_log_module VARCHAR2(240);
90510
90511 --
90512 -- Upgrade strategy
90513 --
90514 l_actual_upg_option VARCHAR2(1);
90515 l_enc_upg_option VARCHAR2(1);
90516
90517 --
90518 BEGIN
90519 --
90520 IF g_log_enabled THEN
90521 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_183';
90522 END IF;
90523 --
90524 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
90525
90526 trace
90527 (p_msg => 'BEGIN of AcctLineType_183'
90528 ,p_level => C_LEVEL_PROCEDURE
90529 ,p_module => l_log_module);
90530
90531 END IF;
90532 --
90533 l_component_type := 'AMB_JLT';
90534 l_component_code := 'INTERORG_PROFIT_OPM';
90535 l_component_type_code := 'S';
90536 l_component_appl_id := 707;
90537 l_amb_context_code := 'DEFAULT';
90538 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
90539 l_event_class_code := 'DIR_INTERORG_SHIP';
90540 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
90541 l_line_definition_owner_code := 'S';
90542 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
90543 --
90544 l_balance_type_code := 'A';
90545 l_segment := NULL;
90546 l_ccid := NULL;
90547 l_adr_transaction_coa_id := NULL;
90548 l_adr_accounting_coa_id := NULL;
90549 l_adr_flexfield_segment_code := NULL;
90550 l_adr_flex_value_set_id := NULL;
90551 l_adr_value_type_code := NULL;
90552 l_adr_value_combination_id := NULL;
90553 l_adr_value_segment_code := NULL;
90554
90555 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
90556 l_bflow_class_code := ''; -- 4219869 Business Flow
90557 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
90558 l_budgetary_control_flag := 'N';
90559
90560 l_bflow_applied_to_amt_idx := NULL; -- 5132302
90561 l_bflow_applied_to_amt := NULL; -- 5132302
90562 l_entered_amt_idx := NULL; -- 4262811
90563 l_accted_amt_idx := NULL; -- 4262811
90564 l_acc_rev_flag := NULL; -- 4262811
90565 l_accrual_line_num := NULL; -- 4262811
90566 l_tmp_amt := NULL; -- 4262811
90567 --
90568
90569 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
90570 l_balance_type_code <> 'B' THEN
90571 IF NVL(p_source_97,9E125) = 34
90572 THEN
90573
90574 --
90575 XLA_AE_LINES_PKG.SetNewLine;
90576
90577 p_balance_type_code := l_balance_type_code;
90578 -- set the flag so later we will know whether the gain loss line needs to be created
90579
90580 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
90581 p_actual_flag :='A';
90582 END IF;
90583
90584 --
90585 -- bulk performance
90586 --
90587 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
90588 p_header_num => 0); -- 4262811
90589 --
90590 -- set accounting line options
90591 --
90592 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
90593 p_natural_side_code => 'D'
90594 , p_gain_or_loss_flag => 'N'
90595 , p_gl_transfer_mode_code => 'S'
90596 , p_acct_entry_type_code => 'A'
90597 , p_switch_side_flag => 'Y'
90598 , p_merge_duplicate_code => 'N'
90599 );
90600 --
90601 l_acc_rev_natural_side_code := 'C'; -- 4262811
90602 --
90603 --
90604 -- set accounting line type info
90605 --
90606 xla_ae_lines_pkg.SetAcctLineType
90607 (p_component_type => l_component_type
90608 ,p_event_type_code => l_event_type_code
90609 ,p_line_definition_owner_code => l_line_definition_owner_code
90610 ,p_line_definition_code => l_line_definition_code
90611 ,p_accounting_line_code => l_component_code
90612 ,p_accounting_line_type_code => l_component_type_code
90613 ,p_accounting_line_appl_id => l_component_appl_id
90614 ,p_amb_context_code => l_amb_context_code
90615 ,p_entity_code => l_entity_code
90616 ,p_event_class_code => l_event_class_code);
90617 --
90618 -- set accounting class
90619 --
90620 xla_ae_lines_pkg.SetAcctClass(
90621 p_accounting_class_code => 'INTERORG_PROFIT'
90622 , p_ae_header_id => l_ae_header_id
90623 );
90624
90625 --
90626 -- set rounding class
90627 --
90628 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
90629 'INTERORG_PROFIT';
90630
90631 --
90632 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
90633 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
90634 --
90635 -- bulk performance
90636 --
90637 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
90638
90639 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
90640 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
90641
90642 -- 4955764
90643 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
90644 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
90645
90646 -- 4458381 Public Sector Enh
90647
90648 --
90649 -- set accounting attributes for the line type
90650 --
90651 l_entered_amt_idx := 3;
90652 l_accted_amt_idx := 8;
90653 l_bflow_applied_to_amt_idx := NULL; -- 5132302
90654 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
90655 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
90656 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
90657 l_rec_acct_attrs.array_char_value(2) := p_source_85;
90658 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
90659 l_rec_acct_attrs.array_num_value(3) := p_source_91;
90660 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
90661 l_rec_acct_attrs.array_char_value(4) := p_source_88;
90662 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
90663 l_rec_acct_attrs.array_date_value(5) := p_source_92;
90664 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
90665 l_rec_acct_attrs.array_num_value(6) := p_source_93;
90666 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
90667 l_rec_acct_attrs.array_char_value(7) := p_source_94;
90668 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
90669 l_rec_acct_attrs.array_num_value(8) := p_source_95;
90670
90671 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
90672 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
90673
90674 ---------------------------------------------------------------------------------------------------------------
90675 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
90676 ---------------------------------------------------------------------------------------------------------------
90677 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
90678
90679 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
90680 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
90681
90682 IF xla_accounting_cache_pkg.GetValueChar
90683 (p_source_code => 'LEDGER_CATEGORY_CODE'
90684 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
90685 AND l_bflow_method_code = 'PRIOR_ENTRY'
90686 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
90687 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
90688 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
90689 )
90690 THEN
90691 xla_ae_lines_pkg.BflowUpgEntry
90692 (p_business_method_code => l_bflow_method_code
90693 ,p_business_class_code => l_bflow_class_code
90694 ,p_balance_type => l_balance_type_code);
90695 ELSE
90696 NULL;
90697 -- No business flow processing for business flow method of NONE.
90698 END IF;
90699
90700 --
90701 -- call analytical criteria
90702 --
90703
90704 --
90705 -- call description
90706 --
90707
90708 xla_ae_lines_pkg.SetLineDescription(
90709 p_ae_header_id => l_ae_header_id
90710 ,p_description => Description_1 (
90711 p_application_id => p_application_id
90712 , p_ae_header_id => l_ae_header_id
90713 , p_source_1 => p_source_1
90714 , p_source_2 => p_source_2
90715 , p_source_3 => p_source_3
90716 , p_source_4 => p_source_4
90717 , p_source_5 => p_source_5
90718 )
90719 );
90720
90721
90722 --
90723 -- call ADRs
90724 -- Bug 4922099
90725 --
90726 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
90727 (NVL(l_actual_upg_option, 'N') = 'O') OR
90728 (NVL(l_enc_upg_option, 'N') = 'O')
90729 )
90730 THEN
90731 NULL;
90732 --
90733 --
90734
90735 l_ccid := AcctDerRule_6(
90736 p_application_id => p_application_id
90737 , p_ae_header_id => l_ae_header_id
90738 , p_source_11 => p_source_11
90739 , x_transaction_coa_id => l_adr_transaction_coa_id
90740 , x_accounting_coa_id => l_adr_accounting_coa_id
90741 , x_value_type_code => l_adr_value_type_code
90742 , p_side => 'NA'
90743 );
90744
90745 xla_ae_lines_pkg.set_ccid(
90746 p_code_combination_id => l_ccid
90747 , p_value_type_code => l_adr_value_type_code
90748 , p_transaction_coa_id => l_adr_transaction_coa_id
90749 , p_accounting_coa_id => l_adr_accounting_coa_id
90750 , p_adr_code => 'CST_DEFAULT'
90751 , p_adr_type_code => 'S'
90752 , p_component_type => l_component_type
90753 , p_component_code => l_component_code
90754 , p_component_type_code => l_component_type_code
90755 , p_component_appl_id => l_component_appl_id
90756 , p_amb_context_code => l_amb_context_code
90757 , p_side => 'NA'
90758 );
90759
90760
90761 --
90762 --
90763 END IF;
90764 --
90765 -- Bug 4922099
90766 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
90767 (NVL(l_enc_upg_option, 'N') = 'O')
90768 ) AND
90769 (l_bflow_method_code = 'PRIOR_ENTRY')
90770 )
90771 THEN
90772 IF
90773 --
90774 1 = 2
90775 --
90776 THEN
90777 xla_accounting_err_pkg.build_message
90778 (p_appli_s_name => 'XLA'
90779 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
90780 ,p_token_1 => 'LINE_NUMBER'
90781 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
90782 ,p_token_2 => 'LINE_TYPE_NAME'
90783 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
90784 l_component_type
90785 ,l_component_code
90786 ,l_component_type_code
90787 ,l_component_appl_id
90788 ,l_amb_context_code
90789 ,l_entity_code
90790 ,l_event_class_code
90791 )
90792 ,p_token_3 => 'OWNER'
90793 ,p_value_3 => xla_lookups_pkg.get_meaning(
90794 p_lookup_type => 'XLA_OWNER_TYPE'
90795 ,p_lookup_code => l_component_type_code
90796 )
90797 ,p_token_4 => 'PRODUCT_NAME'
90798 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
90799 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
90800 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
90801 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
90802 ,p_ae_header_id => NULL
90803 );
90804
90805 IF (C_LEVEL_ERROR>= g_log_level) THEN
90806 trace
90807 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
90808 ,p_level => C_LEVEL_ERROR
90809 ,p_module => l_log_module);
90810 END IF;
90811 END IF;
90812 END IF;
90813 --
90814 --
90815 ------------------------------------------------------------------------------------------------
90816 -- 4219869 Business Flow
90817 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
90818 -- Prior Entry. Currently, the following code is always generated.
90819 ------------------------------------------------------------------------------------------------
90820 XLA_AE_LINES_PKG.ValidateCurrentLine;
90821
90822 ------------------------------------------------------------------------------------
90823 -- 4219869 Business Flow
90824 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
90825 ------------------------------------------------------------------------------------
90826 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
90827
90828 ----------------------------------------------------------------------------------
90829 -- 4219869 Business Flow
90830 -- Update journal entry status -- Need to generate this within IF <condition>
90831 ----------------------------------------------------------------------------------
90832 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
90833 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
90834 ,p_balance_type_code => l_balance_type_code
90835 );
90836
90837 -------------------------------------------------------------------------------------------
90838 -- 4262811 - Generate the Accrual Reversal lines
90839 -------------------------------------------------------------------------------------------
90840 BEGIN
90841 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
90842 (g_array_event(p_event_id).array_value_num('header_index'));
90843 IF l_acc_rev_flag IS NULL THEN
90844 l_acc_rev_flag := 'N';
90845 END IF;
90846 EXCEPTION
90847 WHEN OTHERS THEN
90848 l_acc_rev_flag := 'N';
90849 END;
90850 --
90851 IF (l_acc_rev_flag = 'Y') THEN
90852
90853 -- 4645092 ------------------------------------------------------------------------------
90854 -- To allow MPA report to determine if it should generate report process
90855 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
90856 ------------------------------------------------------------------------------------------
90857
90858 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
90859 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
90860 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
90861 -- call ADRs
90862 -- Bug 4922099
90863 --
90864 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
90865 (NVL(l_actual_upg_option, 'N') = 'O') OR
90866 (NVL(l_enc_upg_option, 'N') = 'O')
90867 )
90868 THEN
90869 NULL;
90870 --
90871 --
90872
90873 l_ccid := AcctDerRule_6(
90874 p_application_id => p_application_id
90875 , p_ae_header_id => l_ae_header_id
90876 , p_source_11 => p_source_11
90877 , x_transaction_coa_id => l_adr_transaction_coa_id
90878 , x_accounting_coa_id => l_adr_accounting_coa_id
90879 , x_value_type_code => l_adr_value_type_code
90880 , p_side => 'NA'
90881 );
90882
90883 xla_ae_lines_pkg.set_ccid(
90884 p_code_combination_id => l_ccid
90885 , p_value_type_code => l_adr_value_type_code
90886 , p_transaction_coa_id => l_adr_transaction_coa_id
90887 , p_accounting_coa_id => l_adr_accounting_coa_id
90888 , p_adr_code => 'CST_DEFAULT'
90889 , p_adr_type_code => 'S'
90890 , p_component_type => l_component_type
90891 , p_component_code => l_component_code
90892 , p_component_type_code => l_component_type_code
90893 , p_component_appl_id => l_component_appl_id
90894 , p_amb_context_code => l_amb_context_code
90895 , p_side => 'NA'
90896 );
90897
90898
90899 --
90900 --
90901 END IF;
90902
90903 --
90904 -- Update the line information that should be overwritten
90905 --
90906 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
90907 p_header_num => 1);
90908 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
90909
90910 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
90911
90912 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
90913 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
90914 END IF;
90915
90916 --
90917 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
90918 --
90919 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
90920 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
90921 ELSE
90922 ---------------------------------------------------------------------------------------------------
90923 -- 4262811a Switch Sign
90924 ---------------------------------------------------------------------------------------------------
90925 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
90926 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
90927 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90928 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
90929 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90930 -- 5132302
90931 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
90932 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
90933
90934 END IF;
90935
90936 -- 4955764
90937 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
90938 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
90939
90940
90941 XLA_AE_LINES_PKG.ValidateCurrentLine;
90942 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
90943
90944 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
90945 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
90946 ,p_balance_type_code => l_balance_type_code);
90947
90948 END IF;
90949
90950 -----------------------------------------------------------------------------------------
90951 -- 4262811 Multiperiod Accounting
90952 -----------------------------------------------------------------------------------------
90953 -- No MPA option is assigned.
90954
90955
90956 END IF;
90957 END IF;
90958 --
90959
90960 --
90961 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
90962 trace
90963 (p_msg => 'END of AcctLineType_183'
90964 ,p_level => C_LEVEL_PROCEDURE
90965 ,p_module => l_log_module);
90966 END IF;
90967 --
90968 EXCEPTION
90969 WHEN xla_exceptions_pkg.application_exception THEN
90970 RAISE;
90971 WHEN OTHERS THEN
90972 xla_exceptions_pkg.raise_message
90973 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_183');
90974 END AcctLineType_183;
90975 --
90976
90977 ---------------------------------------
90978 --
90979 -- PRIVATE FUNCTION
90980 -- AcctLineType_184
90981 --
90982 ---------------------------------------
90983 PROCEDURE AcctLineType_184 (
90984 p_application_id IN NUMBER
90985 ,p_event_id IN NUMBER
90986 ,p_calculate_acctd_flag IN VARCHAR2
90987 ,p_calculate_g_l_flag IN VARCHAR2
90988 ,p_actual_flag IN OUT VARCHAR2
90989 ,p_balance_type_code OUT VARCHAR2
90990 ,p_gain_or_loss_ref OUT VARCHAR2
90991
90992 --TRANSACTION_ID
90993 , p_source_1 IN NUMBER
90994 --Item Concatenated Segments
90995 , p_source_2 IN VARCHAR2
90996 --Transaction Quantity
90997 , p_source_3 IN NUMBER
90998 --Transaction Unit of Measure Code
90999 , p_source_4 IN VARCHAR2
91000 --Inventory Transaction Type Description
91001 , p_source_5 IN VARCHAR2
91002 --Cost Management Default Account
91003 , p_source_11 IN NUMBER
91004 --DISTRIBUTION_IDENTIFIER
91005 , p_source_84 IN NUMBER
91006 --Distribution Type
91007 , p_source_85 IN VARCHAR2
91008 , p_source_85_meaning IN VARCHAR2
91009 --Entered Currency Code
91010 , p_source_88 IN VARCHAR2
91011 --Entered Amount
91012 , p_source_91 IN NUMBER
91013 --Currency Conversion Date
91014 , p_source_92 IN DATE
91015 --Currency Conversion Rate
91016 , p_source_93 IN NUMBER
91017 --Currency Conversion Type
91018 , p_source_94 IN VARCHAR2
91019 --Accounted Amount
91020 , p_source_95 IN NUMBER
91021 --Accounting Line Type
91022 , p_source_97 IN NUMBER
91023 )
91024 IS
91025
91026 l_component_type VARCHAR2(80);
91027 l_component_code VARCHAR2(30);
91028 l_component_type_code VARCHAR2(1);
91029 l_component_appl_id INTEGER;
91030 l_amb_context_code VARCHAR2(30);
91031 l_entity_code VARCHAR2(30);
91032 l_event_class_code VARCHAR2(30);
91033 l_ae_header_id NUMBER;
91034 l_event_type_code VARCHAR2(30);
91035 l_line_definition_code VARCHAR2(30);
91036 l_line_definition_owner_code VARCHAR2(1);
91037 --
91038 -- adr variables
91039 l_segment VARCHAR2(30);
91040 l_ccid NUMBER;
91041 l_adr_transaction_coa_id NUMBER;
91042 l_adr_accounting_coa_id NUMBER;
91043 l_adr_flexfield_segment_code VARCHAR2(30);
91044 l_adr_flex_value_set_id NUMBER;
91045 l_adr_value_type_code VARCHAR2(30);
91046 l_adr_value_combination_id NUMBER;
91047 l_adr_value_segment_code VARCHAR2(30);
91048
91049 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
91050 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
91051 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
91052 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
91053
91054 -- 4262811 Variables ------------------------------------------------------------------------------------------
91055 l_entered_amt_idx NUMBER;
91056 l_accted_amt_idx NUMBER;
91057 l_acc_rev_flag VARCHAR2(1);
91058 l_accrual_line_num NUMBER;
91059 l_tmp_amt NUMBER;
91060 l_acc_rev_natural_side_code VARCHAR2(1);
91061
91062 l_num_entries NUMBER;
91063 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
91064 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
91065 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
91066 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
91067 l_recog_line_1 NUMBER;
91068 l_recog_line_2 NUMBER;
91069
91070 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
91071 l_bflow_applied_to_amt NUMBER; -- 5132302
91072 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
91073
91074 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
91075
91076 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
91077 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
91078
91079 ---------------------------------------------------------------------------------------------------------------
91080
91081
91082 --
91083 -- bulk performance
91084 --
91085 l_balance_type_code VARCHAR2(1);
91086 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
91087 l_log_module VARCHAR2(240);
91088
91089 --
91090 -- Upgrade strategy
91091 --
91092 l_actual_upg_option VARCHAR2(1);
91093 l_enc_upg_option VARCHAR2(1);
91094
91095 --
91096 BEGIN
91097 --
91098 IF g_log_enabled THEN
91099 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_184';
91100 END IF;
91101 --
91102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
91103
91104 trace
91105 (p_msg => 'BEGIN of AcctLineType_184'
91106 ,p_level => C_LEVEL_PROCEDURE
91107 ,p_module => l_log_module);
91108
91109 END IF;
91110 --
91111 l_component_type := 'AMB_JLT';
91112 l_component_code := 'INTERORG_PROFIT_OPM';
91113 l_component_type_code := 'S';
91114 l_component_appl_id := 707;
91115 l_amb_context_code := 'DEFAULT';
91116 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
91117 l_event_class_code := 'INT_ORDER_TO_EXP';
91118 l_event_type_code := 'EXP_REQ_RCPT_NO_TP';
91119 l_line_definition_owner_code := 'S';
91120 l_line_definition_code := 'PI_EXP_REQ_RCPT_NO_TP';
91121 --
91122 l_balance_type_code := 'A';
91123 l_segment := NULL;
91124 l_ccid := NULL;
91125 l_adr_transaction_coa_id := NULL;
91126 l_adr_accounting_coa_id := NULL;
91127 l_adr_flexfield_segment_code := NULL;
91128 l_adr_flex_value_set_id := NULL;
91129 l_adr_value_type_code := NULL;
91130 l_adr_value_combination_id := NULL;
91131 l_adr_value_segment_code := NULL;
91132
91133 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
91134 l_bflow_class_code := ''; -- 4219869 Business Flow
91135 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
91136 l_budgetary_control_flag := 'N';
91137
91138 l_bflow_applied_to_amt_idx := NULL; -- 5132302
91139 l_bflow_applied_to_amt := NULL; -- 5132302
91140 l_entered_amt_idx := NULL; -- 4262811
91141 l_accted_amt_idx := NULL; -- 4262811
91142 l_acc_rev_flag := NULL; -- 4262811
91143 l_accrual_line_num := NULL; -- 4262811
91144 l_tmp_amt := NULL; -- 4262811
91145 --
91146
91147 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
91148 l_balance_type_code <> 'B' THEN
91149 IF NVL(p_source_97,9E125) = 34
91150 THEN
91151
91152 --
91153 XLA_AE_LINES_PKG.SetNewLine;
91154
91155 p_balance_type_code := l_balance_type_code;
91156 -- set the flag so later we will know whether the gain loss line needs to be created
91157
91158 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
91159 p_actual_flag :='A';
91160 END IF;
91161
91162 --
91163 -- bulk performance
91164 --
91165 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
91166 p_header_num => 0); -- 4262811
91167 --
91168 -- set accounting line options
91169 --
91170 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
91171 p_natural_side_code => 'D'
91172 , p_gain_or_loss_flag => 'N'
91173 , p_gl_transfer_mode_code => 'S'
91174 , p_acct_entry_type_code => 'A'
91175 , p_switch_side_flag => 'Y'
91176 , p_merge_duplicate_code => 'N'
91177 );
91178 --
91179 l_acc_rev_natural_side_code := 'C'; -- 4262811
91180 --
91181 --
91182 -- set accounting line type info
91183 --
91184 xla_ae_lines_pkg.SetAcctLineType
91185 (p_component_type => l_component_type
91186 ,p_event_type_code => l_event_type_code
91187 ,p_line_definition_owner_code => l_line_definition_owner_code
91188 ,p_line_definition_code => l_line_definition_code
91189 ,p_accounting_line_code => l_component_code
91190 ,p_accounting_line_type_code => l_component_type_code
91191 ,p_accounting_line_appl_id => l_component_appl_id
91192 ,p_amb_context_code => l_amb_context_code
91193 ,p_entity_code => l_entity_code
91194 ,p_event_class_code => l_event_class_code);
91195 --
91196 -- set accounting class
91197 --
91198 xla_ae_lines_pkg.SetAcctClass(
91199 p_accounting_class_code => 'INTERORG_PROFIT'
91200 , p_ae_header_id => l_ae_header_id
91201 );
91202
91203 --
91204 -- set rounding class
91205 --
91206 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
91207 'INTERORG_PROFIT';
91208
91209 --
91210 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
91211 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
91212 --
91213 -- bulk performance
91214 --
91215 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
91216
91217 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
91218 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
91219
91220 -- 4955764
91221 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
91222 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
91223
91224 -- 4458381 Public Sector Enh
91225
91226 --
91227 -- set accounting attributes for the line type
91228 --
91229 l_entered_amt_idx := 3;
91230 l_accted_amt_idx := 8;
91231 l_bflow_applied_to_amt_idx := NULL; -- 5132302
91232 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
91233 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
91234 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
91235 l_rec_acct_attrs.array_char_value(2) := p_source_85;
91236 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
91237 l_rec_acct_attrs.array_num_value(3) := p_source_91;
91238 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
91239 l_rec_acct_attrs.array_char_value(4) := p_source_88;
91240 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
91241 l_rec_acct_attrs.array_date_value(5) := p_source_92;
91242 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
91243 l_rec_acct_attrs.array_num_value(6) := p_source_93;
91244 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
91245 l_rec_acct_attrs.array_char_value(7) := p_source_94;
91246 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
91247 l_rec_acct_attrs.array_num_value(8) := p_source_95;
91248
91249 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
91250 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
91251
91252 ---------------------------------------------------------------------------------------------------------------
91253 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
91254 ---------------------------------------------------------------------------------------------------------------
91255 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
91256
91257 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
91258 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
91259
91260 IF xla_accounting_cache_pkg.GetValueChar
91261 (p_source_code => 'LEDGER_CATEGORY_CODE'
91262 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
91263 AND l_bflow_method_code = 'PRIOR_ENTRY'
91264 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
91265 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
91266 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
91267 )
91268 THEN
91269 xla_ae_lines_pkg.BflowUpgEntry
91270 (p_business_method_code => l_bflow_method_code
91271 ,p_business_class_code => l_bflow_class_code
91272 ,p_balance_type => l_balance_type_code);
91273 ELSE
91274 NULL;
91275 -- No business flow processing for business flow method of NONE.
91276 END IF;
91277
91278 --
91279 -- call analytical criteria
91280 --
91281
91282 --
91283 -- call description
91284 --
91285
91286 xla_ae_lines_pkg.SetLineDescription(
91287 p_ae_header_id => l_ae_header_id
91288 ,p_description => Description_1 (
91289 p_application_id => p_application_id
91290 , p_ae_header_id => l_ae_header_id
91291 , p_source_1 => p_source_1
91292 , p_source_2 => p_source_2
91293 , p_source_3 => p_source_3
91294 , p_source_4 => p_source_4
91295 , p_source_5 => p_source_5
91296 )
91297 );
91298
91299
91300 --
91301 -- call ADRs
91302 -- Bug 4922099
91303 --
91304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
91305 (NVL(l_actual_upg_option, 'N') = 'O') OR
91306 (NVL(l_enc_upg_option, 'N') = 'O')
91307 )
91308 THEN
91309 NULL;
91310 --
91311 --
91312
91313 l_ccid := AcctDerRule_6(
91314 p_application_id => p_application_id
91315 , p_ae_header_id => l_ae_header_id
91316 , p_source_11 => p_source_11
91317 , x_transaction_coa_id => l_adr_transaction_coa_id
91318 , x_accounting_coa_id => l_adr_accounting_coa_id
91319 , x_value_type_code => l_adr_value_type_code
91320 , p_side => 'NA'
91321 );
91322
91323 xla_ae_lines_pkg.set_ccid(
91324 p_code_combination_id => l_ccid
91325 , p_value_type_code => l_adr_value_type_code
91326 , p_transaction_coa_id => l_adr_transaction_coa_id
91327 , p_accounting_coa_id => l_adr_accounting_coa_id
91328 , p_adr_code => 'CST_DEFAULT'
91329 , p_adr_type_code => 'S'
91330 , p_component_type => l_component_type
91331 , p_component_code => l_component_code
91332 , p_component_type_code => l_component_type_code
91333 , p_component_appl_id => l_component_appl_id
91334 , p_amb_context_code => l_amb_context_code
91335 , p_side => 'NA'
91336 );
91337
91338
91339 --
91340 --
91341 END IF;
91342 --
91343 -- Bug 4922099
91344 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
91345 (NVL(l_enc_upg_option, 'N') = 'O')
91346 ) AND
91347 (l_bflow_method_code = 'PRIOR_ENTRY')
91348 )
91349 THEN
91350 IF
91351 --
91352 1 = 2
91353 --
91354 THEN
91355 xla_accounting_err_pkg.build_message
91356 (p_appli_s_name => 'XLA'
91357 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
91358 ,p_token_1 => 'LINE_NUMBER'
91359 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
91360 ,p_token_2 => 'LINE_TYPE_NAME'
91361 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
91362 l_component_type
91363 ,l_component_code
91364 ,l_component_type_code
91365 ,l_component_appl_id
91366 ,l_amb_context_code
91367 ,l_entity_code
91368 ,l_event_class_code
91369 )
91370 ,p_token_3 => 'OWNER'
91371 ,p_value_3 => xla_lookups_pkg.get_meaning(
91372 p_lookup_type => 'XLA_OWNER_TYPE'
91373 ,p_lookup_code => l_component_type_code
91374 )
91375 ,p_token_4 => 'PRODUCT_NAME'
91376 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
91377 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
91378 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
91379 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
91380 ,p_ae_header_id => NULL
91381 );
91382
91383 IF (C_LEVEL_ERROR>= g_log_level) THEN
91384 trace
91385 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
91386 ,p_level => C_LEVEL_ERROR
91387 ,p_module => l_log_module);
91388 END IF;
91389 END IF;
91390 END IF;
91391 --
91392 --
91393 ------------------------------------------------------------------------------------------------
91394 -- 4219869 Business Flow
91395 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
91396 -- Prior Entry. Currently, the following code is always generated.
91397 ------------------------------------------------------------------------------------------------
91398 XLA_AE_LINES_PKG.ValidateCurrentLine;
91399
91400 ------------------------------------------------------------------------------------
91401 -- 4219869 Business Flow
91402 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
91403 ------------------------------------------------------------------------------------
91404 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
91405
91406 ----------------------------------------------------------------------------------
91407 -- 4219869 Business Flow
91408 -- Update journal entry status -- Need to generate this within IF <condition>
91409 ----------------------------------------------------------------------------------
91410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
91411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
91412 ,p_balance_type_code => l_balance_type_code
91413 );
91414
91415 -------------------------------------------------------------------------------------------
91416 -- 4262811 - Generate the Accrual Reversal lines
91417 -------------------------------------------------------------------------------------------
91418 BEGIN
91419 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
91420 (g_array_event(p_event_id).array_value_num('header_index'));
91421 IF l_acc_rev_flag IS NULL THEN
91422 l_acc_rev_flag := 'N';
91423 END IF;
91424 EXCEPTION
91425 WHEN OTHERS THEN
91426 l_acc_rev_flag := 'N';
91427 END;
91428 --
91429 IF (l_acc_rev_flag = 'Y') THEN
91430
91431 -- 4645092 ------------------------------------------------------------------------------
91432 -- To allow MPA report to determine if it should generate report process
91433 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
91434 ------------------------------------------------------------------------------------------
91435
91436 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
91437 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
91438 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
91439 -- call ADRs
91440 -- Bug 4922099
91441 --
91442 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
91443 (NVL(l_actual_upg_option, 'N') = 'O') OR
91444 (NVL(l_enc_upg_option, 'N') = 'O')
91445 )
91446 THEN
91447 NULL;
91448 --
91449 --
91450
91451 l_ccid := AcctDerRule_6(
91452 p_application_id => p_application_id
91453 , p_ae_header_id => l_ae_header_id
91454 , p_source_11 => p_source_11
91455 , x_transaction_coa_id => l_adr_transaction_coa_id
91456 , x_accounting_coa_id => l_adr_accounting_coa_id
91457 , x_value_type_code => l_adr_value_type_code
91458 , p_side => 'NA'
91459 );
91460
91461 xla_ae_lines_pkg.set_ccid(
91462 p_code_combination_id => l_ccid
91463 , p_value_type_code => l_adr_value_type_code
91464 , p_transaction_coa_id => l_adr_transaction_coa_id
91465 , p_accounting_coa_id => l_adr_accounting_coa_id
91466 , p_adr_code => 'CST_DEFAULT'
91467 , p_adr_type_code => 'S'
91468 , p_component_type => l_component_type
91469 , p_component_code => l_component_code
91470 , p_component_type_code => l_component_type_code
91471 , p_component_appl_id => l_component_appl_id
91472 , p_amb_context_code => l_amb_context_code
91473 , p_side => 'NA'
91474 );
91475
91476
91477 --
91478 --
91479 END IF;
91480
91481 --
91482 -- Update the line information that should be overwritten
91483 --
91484 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
91485 p_header_num => 1);
91486 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
91487
91488 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
91489
91490 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
91491 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
91492 END IF;
91493
91494 --
91495 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
91496 --
91497 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
91498 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
91499 ELSE
91500 ---------------------------------------------------------------------------------------------------
91501 -- 4262811a Switch Sign
91502 ---------------------------------------------------------------------------------------------------
91503 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
91504 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
91505 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
91506 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
91507 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
91508 -- 5132302
91509 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
91510 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
91511
91512 END IF;
91513
91514 -- 4955764
91515 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
91516 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
91517
91518
91519 XLA_AE_LINES_PKG.ValidateCurrentLine;
91520 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
91521
91522 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
91523 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
91524 ,p_balance_type_code => l_balance_type_code);
91525
91526 END IF;
91527
91528 -----------------------------------------------------------------------------------------
91529 -- 4262811 Multiperiod Accounting
91530 -----------------------------------------------------------------------------------------
91531 -- No MPA option is assigned.
91532
91533
91534 END IF;
91535 END IF;
91536 --
91537
91538 --
91539 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
91540 trace
91541 (p_msg => 'END of AcctLineType_184'
91542 ,p_level => C_LEVEL_PROCEDURE
91543 ,p_module => l_log_module);
91544 END IF;
91545 --
91546 EXCEPTION
91547 WHEN xla_exceptions_pkg.application_exception THEN
91548 RAISE;
91549 WHEN OTHERS THEN
91550 xla_exceptions_pkg.raise_message
91551 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_184');
91552 END AcctLineType_184;
91553 --
91554
91555 ---------------------------------------
91556 --
91557 -- PRIVATE FUNCTION
91558 -- AcctLineType_185
91559 --
91560 ---------------------------------------
91561 PROCEDURE AcctLineType_185 (
91562 p_application_id IN NUMBER
91563 ,p_event_id IN NUMBER
91564 ,p_calculate_acctd_flag IN VARCHAR2
91565 ,p_calculate_g_l_flag IN VARCHAR2
91566 ,p_actual_flag IN OUT VARCHAR2
91567 ,p_balance_type_code OUT VARCHAR2
91568 ,p_gain_or_loss_ref OUT VARCHAR2
91569
91570 --TRANSACTION_ID
91571 , p_source_1 IN NUMBER
91572 --Item Concatenated Segments
91573 , p_source_2 IN VARCHAR2
91574 --Transaction Quantity
91575 , p_source_3 IN NUMBER
91576 --Transaction Unit of Measure Code
91577 , p_source_4 IN VARCHAR2
91578 --Inventory Transaction Type Description
91579 , p_source_5 IN VARCHAR2
91580 --Cost Management Default Account
91581 , p_source_11 IN NUMBER
91582 --DISTRIBUTION_IDENTIFIER
91583 , p_source_84 IN NUMBER
91584 --Distribution Type
91585 , p_source_85 IN VARCHAR2
91586 , p_source_85_meaning IN VARCHAR2
91587 --Entered Currency Code
91588 , p_source_88 IN VARCHAR2
91589 --Entered Amount
91590 , p_source_91 IN NUMBER
91591 --Currency Conversion Date
91592 , p_source_92 IN DATE
91593 --Currency Conversion Rate
91594 , p_source_93 IN NUMBER
91595 --Currency Conversion Type
91596 , p_source_94 IN VARCHAR2
91597 --Accounted Amount
91598 , p_source_95 IN NUMBER
91599 --Accounting Line Type
91600 , p_source_97 IN NUMBER
91601 )
91602 IS
91603
91604 l_component_type VARCHAR2(80);
91605 l_component_code VARCHAR2(30);
91606 l_component_type_code VARCHAR2(1);
91607 l_component_appl_id INTEGER;
91608 l_amb_context_code VARCHAR2(30);
91609 l_entity_code VARCHAR2(30);
91610 l_event_class_code VARCHAR2(30);
91611 l_ae_header_id NUMBER;
91612 l_event_type_code VARCHAR2(30);
91613 l_line_definition_code VARCHAR2(30);
91614 l_line_definition_owner_code VARCHAR2(1);
91615 --
91616 -- adr variables
91617 l_segment VARCHAR2(30);
91618 l_ccid NUMBER;
91619 l_adr_transaction_coa_id NUMBER;
91620 l_adr_accounting_coa_id NUMBER;
91621 l_adr_flexfield_segment_code VARCHAR2(30);
91622 l_adr_flex_value_set_id NUMBER;
91623 l_adr_value_type_code VARCHAR2(30);
91624 l_adr_value_combination_id NUMBER;
91625 l_adr_value_segment_code VARCHAR2(30);
91626
91627 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
91628 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
91629 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
91630 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
91631
91632 -- 4262811 Variables ------------------------------------------------------------------------------------------
91633 l_entered_amt_idx NUMBER;
91634 l_accted_amt_idx NUMBER;
91635 l_acc_rev_flag VARCHAR2(1);
91636 l_accrual_line_num NUMBER;
91637 l_tmp_amt NUMBER;
91638 l_acc_rev_natural_side_code VARCHAR2(1);
91639
91640 l_num_entries NUMBER;
91641 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
91642 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
91643 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
91644 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
91645 l_recog_line_1 NUMBER;
91646 l_recog_line_2 NUMBER;
91647
91648 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
91649 l_bflow_applied_to_amt NUMBER; -- 5132302
91650 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
91651
91652 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
91653
91654 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
91655 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
91656
91657 ---------------------------------------------------------------------------------------------------------------
91658
91659
91660 --
91661 -- bulk performance
91662 --
91663 l_balance_type_code VARCHAR2(1);
91664 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
91665 l_log_module VARCHAR2(240);
91666
91667 --
91668 -- Upgrade strategy
91669 --
91670 l_actual_upg_option VARCHAR2(1);
91671 l_enc_upg_option VARCHAR2(1);
91672
91673 --
91674 BEGIN
91675 --
91676 IF g_log_enabled THEN
91677 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_185';
91678 END IF;
91679 --
91680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
91681
91682 trace
91683 (p_msg => 'BEGIN of AcctLineType_185'
91684 ,p_level => C_LEVEL_PROCEDURE
91685 ,p_module => l_log_module);
91686
91687 END IF;
91688 --
91689 l_component_type := 'AMB_JLT';
91690 l_component_code := 'INTERORG_PROFIT_OPM';
91691 l_component_type_code := 'S';
91692 l_component_appl_id := 707;
91693 l_amb_context_code := 'DEFAULT';
91694 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
91695 l_event_class_code := 'INT_ORDER_TO_EXP';
91696 l_event_type_code := 'INT_ORDER_ISSUE_TP';
91697 l_line_definition_owner_code := 'S';
91698 l_line_definition_code := 'PI_INT_ORDER_ISSUE_TP';
91699 --
91700 l_balance_type_code := 'A';
91701 l_segment := NULL;
91702 l_ccid := NULL;
91703 l_adr_transaction_coa_id := NULL;
91704 l_adr_accounting_coa_id := NULL;
91705 l_adr_flexfield_segment_code := NULL;
91706 l_adr_flex_value_set_id := NULL;
91707 l_adr_value_type_code := NULL;
91708 l_adr_value_combination_id := NULL;
91709 l_adr_value_segment_code := NULL;
91710
91711 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
91712 l_bflow_class_code := ''; -- 4219869 Business Flow
91713 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
91714 l_budgetary_control_flag := 'N';
91715
91716 l_bflow_applied_to_amt_idx := NULL; -- 5132302
91717 l_bflow_applied_to_amt := NULL; -- 5132302
91718 l_entered_amt_idx := NULL; -- 4262811
91719 l_accted_amt_idx := NULL; -- 4262811
91720 l_acc_rev_flag := NULL; -- 4262811
91721 l_accrual_line_num := NULL; -- 4262811
91722 l_tmp_amt := NULL; -- 4262811
91723 --
91724
91725 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
91726 l_balance_type_code <> 'B' THEN
91727 IF NVL(p_source_97,9E125) = 34
91728 THEN
91729
91730 --
91731 XLA_AE_LINES_PKG.SetNewLine;
91732
91733 p_balance_type_code := l_balance_type_code;
91734 -- set the flag so later we will know whether the gain loss line needs to be created
91735
91736 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
91737 p_actual_flag :='A';
91738 END IF;
91739
91740 --
91741 -- bulk performance
91742 --
91743 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
91744 p_header_num => 0); -- 4262811
91745 --
91746 -- set accounting line options
91747 --
91748 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
91749 p_natural_side_code => 'D'
91750 , p_gain_or_loss_flag => 'N'
91751 , p_gl_transfer_mode_code => 'S'
91752 , p_acct_entry_type_code => 'A'
91753 , p_switch_side_flag => 'Y'
91754 , p_merge_duplicate_code => 'N'
91755 );
91756 --
91757 l_acc_rev_natural_side_code := 'C'; -- 4262811
91758 --
91759 --
91760 -- set accounting line type info
91761 --
91762 xla_ae_lines_pkg.SetAcctLineType
91763 (p_component_type => l_component_type
91764 ,p_event_type_code => l_event_type_code
91765 ,p_line_definition_owner_code => l_line_definition_owner_code
91766 ,p_line_definition_code => l_line_definition_code
91767 ,p_accounting_line_code => l_component_code
91768 ,p_accounting_line_type_code => l_component_type_code
91769 ,p_accounting_line_appl_id => l_component_appl_id
91770 ,p_amb_context_code => l_amb_context_code
91771 ,p_entity_code => l_entity_code
91772 ,p_event_class_code => l_event_class_code);
91773 --
91774 -- set accounting class
91775 --
91776 xla_ae_lines_pkg.SetAcctClass(
91777 p_accounting_class_code => 'INTERORG_PROFIT'
91778 , p_ae_header_id => l_ae_header_id
91779 );
91780
91781 --
91782 -- set rounding class
91783 --
91784 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
91785 'INTERORG_PROFIT';
91786
91787 --
91788 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
91789 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
91790 --
91791 -- bulk performance
91792 --
91793 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
91794
91795 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
91796 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
91797
91798 -- 4955764
91799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
91800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
91801
91802 -- 4458381 Public Sector Enh
91803
91804 --
91805 -- set accounting attributes for the line type
91806 --
91807 l_entered_amt_idx := 3;
91808 l_accted_amt_idx := 8;
91809 l_bflow_applied_to_amt_idx := NULL; -- 5132302
91810 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
91811 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
91812 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
91813 l_rec_acct_attrs.array_char_value(2) := p_source_85;
91814 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
91815 l_rec_acct_attrs.array_num_value(3) := p_source_91;
91816 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
91817 l_rec_acct_attrs.array_char_value(4) := p_source_88;
91818 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
91819 l_rec_acct_attrs.array_date_value(5) := p_source_92;
91820 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
91821 l_rec_acct_attrs.array_num_value(6) := p_source_93;
91822 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
91823 l_rec_acct_attrs.array_char_value(7) := p_source_94;
91824 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
91825 l_rec_acct_attrs.array_num_value(8) := p_source_95;
91826
91827 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
91828 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
91829
91830 ---------------------------------------------------------------------------------------------------------------
91831 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
91832 ---------------------------------------------------------------------------------------------------------------
91833 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
91834
91835 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
91836 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
91837
91838 IF xla_accounting_cache_pkg.GetValueChar
91839 (p_source_code => 'LEDGER_CATEGORY_CODE'
91840 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
91841 AND l_bflow_method_code = 'PRIOR_ENTRY'
91842 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
91843 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
91844 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
91845 )
91846 THEN
91847 xla_ae_lines_pkg.BflowUpgEntry
91848 (p_business_method_code => l_bflow_method_code
91849 ,p_business_class_code => l_bflow_class_code
91850 ,p_balance_type => l_balance_type_code);
91851 ELSE
91852 NULL;
91853 -- No business flow processing for business flow method of NONE.
91854 END IF;
91855
91856 --
91857 -- call analytical criteria
91858 --
91859
91860 --
91861 -- call description
91862 --
91863
91864 xla_ae_lines_pkg.SetLineDescription(
91865 p_ae_header_id => l_ae_header_id
91866 ,p_description => Description_1 (
91867 p_application_id => p_application_id
91868 , p_ae_header_id => l_ae_header_id
91869 , p_source_1 => p_source_1
91870 , p_source_2 => p_source_2
91871 , p_source_3 => p_source_3
91872 , p_source_4 => p_source_4
91873 , p_source_5 => p_source_5
91874 )
91875 );
91876
91877
91878 --
91879 -- call ADRs
91880 -- Bug 4922099
91881 --
91882 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
91883 (NVL(l_actual_upg_option, 'N') = 'O') OR
91884 (NVL(l_enc_upg_option, 'N') = 'O')
91885 )
91886 THEN
91887 NULL;
91888 --
91889 --
91890
91891 l_ccid := AcctDerRule_6(
91892 p_application_id => p_application_id
91893 , p_ae_header_id => l_ae_header_id
91894 , p_source_11 => p_source_11
91895 , x_transaction_coa_id => l_adr_transaction_coa_id
91896 , x_accounting_coa_id => l_adr_accounting_coa_id
91897 , x_value_type_code => l_adr_value_type_code
91898 , p_side => 'NA'
91899 );
91900
91901 xla_ae_lines_pkg.set_ccid(
91902 p_code_combination_id => l_ccid
91903 , p_value_type_code => l_adr_value_type_code
91904 , p_transaction_coa_id => l_adr_transaction_coa_id
91905 , p_accounting_coa_id => l_adr_accounting_coa_id
91906 , p_adr_code => 'CST_DEFAULT'
91907 , p_adr_type_code => 'S'
91908 , p_component_type => l_component_type
91909 , p_component_code => l_component_code
91910 , p_component_type_code => l_component_type_code
91911 , p_component_appl_id => l_component_appl_id
91912 , p_amb_context_code => l_amb_context_code
91913 , p_side => 'NA'
91914 );
91915
91916
91917 --
91918 --
91919 END IF;
91920 --
91921 -- Bug 4922099
91922 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
91923 (NVL(l_enc_upg_option, 'N') = 'O')
91924 ) AND
91925 (l_bflow_method_code = 'PRIOR_ENTRY')
91926 )
91927 THEN
91928 IF
91929 --
91930 1 = 2
91931 --
91932 THEN
91933 xla_accounting_err_pkg.build_message
91934 (p_appli_s_name => 'XLA'
91935 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
91936 ,p_token_1 => 'LINE_NUMBER'
91937 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
91938 ,p_token_2 => 'LINE_TYPE_NAME'
91939 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
91940 l_component_type
91941 ,l_component_code
91942 ,l_component_type_code
91943 ,l_component_appl_id
91944 ,l_amb_context_code
91945 ,l_entity_code
91946 ,l_event_class_code
91947 )
91948 ,p_token_3 => 'OWNER'
91949 ,p_value_3 => xla_lookups_pkg.get_meaning(
91950 p_lookup_type => 'XLA_OWNER_TYPE'
91951 ,p_lookup_code => l_component_type_code
91952 )
91953 ,p_token_4 => 'PRODUCT_NAME'
91954 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
91955 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
91956 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
91957 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
91958 ,p_ae_header_id => NULL
91959 );
91960
91961 IF (C_LEVEL_ERROR>= g_log_level) THEN
91962 trace
91963 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
91964 ,p_level => C_LEVEL_ERROR
91965 ,p_module => l_log_module);
91966 END IF;
91967 END IF;
91968 END IF;
91969 --
91970 --
91971 ------------------------------------------------------------------------------------------------
91972 -- 4219869 Business Flow
91973 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
91974 -- Prior Entry. Currently, the following code is always generated.
91975 ------------------------------------------------------------------------------------------------
91976 XLA_AE_LINES_PKG.ValidateCurrentLine;
91977
91978 ------------------------------------------------------------------------------------
91979 -- 4219869 Business Flow
91980 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
91981 ------------------------------------------------------------------------------------
91982 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
91983
91984 ----------------------------------------------------------------------------------
91985 -- 4219869 Business Flow
91986 -- Update journal entry status -- Need to generate this within IF <condition>
91987 ----------------------------------------------------------------------------------
91988 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
91989 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
91990 ,p_balance_type_code => l_balance_type_code
91991 );
91992
91993 -------------------------------------------------------------------------------------------
91994 -- 4262811 - Generate the Accrual Reversal lines
91995 -------------------------------------------------------------------------------------------
91996 BEGIN
91997 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
91998 (g_array_event(p_event_id).array_value_num('header_index'));
91999 IF l_acc_rev_flag IS NULL THEN
92000 l_acc_rev_flag := 'N';
92001 END IF;
92002 EXCEPTION
92003 WHEN OTHERS THEN
92004 l_acc_rev_flag := 'N';
92005 END;
92006 --
92007 IF (l_acc_rev_flag = 'Y') THEN
92008
92009 -- 4645092 ------------------------------------------------------------------------------
92010 -- To allow MPA report to determine if it should generate report process
92011 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
92012 ------------------------------------------------------------------------------------------
92013
92014 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
92015 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
92016 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
92017 -- call ADRs
92018 -- Bug 4922099
92019 --
92020 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
92021 (NVL(l_actual_upg_option, 'N') = 'O') OR
92022 (NVL(l_enc_upg_option, 'N') = 'O')
92023 )
92024 THEN
92025 NULL;
92026 --
92027 --
92028
92029 l_ccid := AcctDerRule_6(
92030 p_application_id => p_application_id
92031 , p_ae_header_id => l_ae_header_id
92032 , p_source_11 => p_source_11
92033 , x_transaction_coa_id => l_adr_transaction_coa_id
92034 , x_accounting_coa_id => l_adr_accounting_coa_id
92035 , x_value_type_code => l_adr_value_type_code
92036 , p_side => 'NA'
92037 );
92038
92039 xla_ae_lines_pkg.set_ccid(
92040 p_code_combination_id => l_ccid
92041 , p_value_type_code => l_adr_value_type_code
92042 , p_transaction_coa_id => l_adr_transaction_coa_id
92043 , p_accounting_coa_id => l_adr_accounting_coa_id
92044 , p_adr_code => 'CST_DEFAULT'
92045 , p_adr_type_code => 'S'
92046 , p_component_type => l_component_type
92047 , p_component_code => l_component_code
92048 , p_component_type_code => l_component_type_code
92049 , p_component_appl_id => l_component_appl_id
92050 , p_amb_context_code => l_amb_context_code
92051 , p_side => 'NA'
92052 );
92053
92054
92055 --
92056 --
92057 END IF;
92058
92059 --
92060 -- Update the line information that should be overwritten
92061 --
92062 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
92063 p_header_num => 1);
92064 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
92065
92066 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
92067
92068 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
92069 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
92070 END IF;
92071
92072 --
92073 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
92074 --
92075 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
92076 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
92077 ELSE
92078 ---------------------------------------------------------------------------------------------------
92079 -- 4262811a Switch Sign
92080 ---------------------------------------------------------------------------------------------------
92081 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
92082 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
92083 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92084 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
92085 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92086 -- 5132302
92087 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
92088 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92089
92090 END IF;
92091
92092 -- 4955764
92093 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
92094 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
92095
92096
92097 XLA_AE_LINES_PKG.ValidateCurrentLine;
92098 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
92099
92100 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
92101 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
92102 ,p_balance_type_code => l_balance_type_code);
92103
92104 END IF;
92105
92106 -----------------------------------------------------------------------------------------
92107 -- 4262811 Multiperiod Accounting
92108 -----------------------------------------------------------------------------------------
92109 -- No MPA option is assigned.
92110
92111
92112 END IF;
92113 END IF;
92114 --
92115
92116 --
92117 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
92118 trace
92119 (p_msg => 'END of AcctLineType_185'
92120 ,p_level => C_LEVEL_PROCEDURE
92121 ,p_module => l_log_module);
92122 END IF;
92123 --
92124 EXCEPTION
92125 WHEN xla_exceptions_pkg.application_exception THEN
92126 RAISE;
92127 WHEN OTHERS THEN
92128 xla_exceptions_pkg.raise_message
92129 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_185');
92130 END AcctLineType_185;
92131 --
92132
92133 ---------------------------------------
92134 --
92135 -- PRIVATE FUNCTION
92136 -- AcctLineType_186
92137 --
92138 ---------------------------------------
92139 PROCEDURE AcctLineType_186 (
92140 p_application_id IN NUMBER
92141 ,p_event_id IN NUMBER
92142 ,p_calculate_acctd_flag IN VARCHAR2
92143 ,p_calculate_g_l_flag IN VARCHAR2
92144 ,p_actual_flag IN OUT VARCHAR2
92145 ,p_balance_type_code OUT VARCHAR2
92146 ,p_gain_or_loss_ref OUT VARCHAR2
92147
92148 --TRANSACTION_ID
92149 , p_source_1 IN NUMBER
92150 --Item Concatenated Segments
92151 , p_source_2 IN VARCHAR2
92152 --Transaction Quantity
92153 , p_source_3 IN NUMBER
92154 --Transaction Unit of Measure Code
92155 , p_source_4 IN VARCHAR2
92156 --Inventory Transaction Type Description
92157 , p_source_5 IN VARCHAR2
92158 --Interorg Receivables Account
92159 , p_source_59 IN NUMBER
92160 --DISTRIBUTION_IDENTIFIER
92161 , p_source_84 IN NUMBER
92162 --Distribution Type
92163 , p_source_85 IN VARCHAR2
92164 , p_source_85_meaning IN VARCHAR2
92165 --Entered Currency Code
92166 , p_source_88 IN VARCHAR2
92167 --Entered Amount
92168 , p_source_91 IN NUMBER
92169 --Currency Conversion Date
92170 , p_source_92 IN DATE
92171 --Currency Conversion Rate
92172 , p_source_93 IN NUMBER
92173 --Currency Conversion Type
92174 , p_source_94 IN VARCHAR2
92175 --Accounted Amount
92176 , p_source_95 IN NUMBER
92177 --Accounting Line Type
92178 , p_source_97 IN NUMBER
92179 )
92180 IS
92181
92182 l_component_type VARCHAR2(80);
92183 l_component_code VARCHAR2(30);
92184 l_component_type_code VARCHAR2(1);
92185 l_component_appl_id INTEGER;
92186 l_amb_context_code VARCHAR2(30);
92187 l_entity_code VARCHAR2(30);
92188 l_event_class_code VARCHAR2(30);
92189 l_ae_header_id NUMBER;
92190 l_event_type_code VARCHAR2(30);
92191 l_line_definition_code VARCHAR2(30);
92192 l_line_definition_owner_code VARCHAR2(1);
92193 --
92194 -- adr variables
92195 l_segment VARCHAR2(30);
92196 l_ccid NUMBER;
92197 l_adr_transaction_coa_id NUMBER;
92198 l_adr_accounting_coa_id NUMBER;
92199 l_adr_flexfield_segment_code VARCHAR2(30);
92200 l_adr_flex_value_set_id NUMBER;
92201 l_adr_value_type_code VARCHAR2(30);
92202 l_adr_value_combination_id NUMBER;
92203 l_adr_value_segment_code VARCHAR2(30);
92204
92205 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
92206 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
92207 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
92208 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
92209
92210 -- 4262811 Variables ------------------------------------------------------------------------------------------
92211 l_entered_amt_idx NUMBER;
92212 l_accted_amt_idx NUMBER;
92213 l_acc_rev_flag VARCHAR2(1);
92214 l_accrual_line_num NUMBER;
92215 l_tmp_amt NUMBER;
92216 l_acc_rev_natural_side_code VARCHAR2(1);
92217
92218 l_num_entries NUMBER;
92219 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
92220 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
92221 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
92222 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
92223 l_recog_line_1 NUMBER;
92224 l_recog_line_2 NUMBER;
92225
92226 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
92227 l_bflow_applied_to_amt NUMBER; -- 5132302
92228 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
92229
92230 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
92231
92232 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
92233 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
92234
92235 ---------------------------------------------------------------------------------------------------------------
92236
92237
92238 --
92239 -- bulk performance
92240 --
92241 l_balance_type_code VARCHAR2(1);
92242 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
92243 l_log_module VARCHAR2(240);
92244
92245 --
92246 -- Upgrade strategy
92247 --
92248 l_actual_upg_option VARCHAR2(1);
92249 l_enc_upg_option VARCHAR2(1);
92250
92251 --
92252 BEGIN
92253 --
92254 IF g_log_enabled THEN
92255 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_186';
92256 END IF;
92257 --
92258 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
92259
92260 trace
92261 (p_msg => 'BEGIN of AcctLineType_186'
92262 ,p_level => C_LEVEL_PROCEDURE
92263 ,p_module => l_log_module);
92264
92265 END IF;
92266 --
92267 l_component_type := 'AMB_JLT';
92268 l_component_code := 'INTERORG_RECEIVABLES';
92269 l_component_type_code := 'S';
92270 l_component_appl_id := 707;
92271 l_amb_context_code := 'DEFAULT';
92272 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
92273 l_event_class_code := 'USER_DEFINE';
92274 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
92275 l_line_definition_owner_code := 'S';
92276 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
92277 --
92278 l_balance_type_code := 'A';
92279 l_segment := NULL;
92280 l_ccid := NULL;
92281 l_adr_transaction_coa_id := NULL;
92282 l_adr_accounting_coa_id := NULL;
92283 l_adr_flexfield_segment_code := NULL;
92284 l_adr_flex_value_set_id := NULL;
92285 l_adr_value_type_code := NULL;
92286 l_adr_value_combination_id := NULL;
92287 l_adr_value_segment_code := NULL;
92288
92289 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
92290 l_bflow_class_code := ''; -- 4219869 Business Flow
92291 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
92292 l_budgetary_control_flag := 'N';
92293
92294 l_bflow_applied_to_amt_idx := NULL; -- 5132302
92295 l_bflow_applied_to_amt := NULL; -- 5132302
92296 l_entered_amt_idx := NULL; -- 4262811
92297 l_accted_amt_idx := NULL; -- 4262811
92298 l_acc_rev_flag := NULL; -- 4262811
92299 l_accrual_line_num := NULL; -- 4262811
92300 l_tmp_amt := NULL; -- 4262811
92301 --
92302
92303 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
92304 l_balance_type_code <> 'B' THEN
92305 IF NVL(p_source_97,9E125) = 10
92306 THEN
92307
92308 --
92309 XLA_AE_LINES_PKG.SetNewLine;
92310
92311 p_balance_type_code := l_balance_type_code;
92312 -- set the flag so later we will know whether the gain loss line needs to be created
92313
92314 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
92315 p_actual_flag :='A';
92316 END IF;
92317
92318 --
92319 -- bulk performance
92320 --
92321 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
92322 p_header_num => 0); -- 4262811
92323 --
92324 -- set accounting line options
92325 --
92326 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
92327 p_natural_side_code => 'D'
92328 , p_gain_or_loss_flag => 'N'
92329 , p_gl_transfer_mode_code => 'S'
92330 , p_acct_entry_type_code => 'A'
92331 , p_switch_side_flag => 'Y'
92332 , p_merge_duplicate_code => 'N'
92333 );
92334 --
92335 l_acc_rev_natural_side_code := 'C'; -- 4262811
92336 --
92337 --
92338 -- set accounting line type info
92339 --
92340 xla_ae_lines_pkg.SetAcctLineType
92341 (p_component_type => l_component_type
92342 ,p_event_type_code => l_event_type_code
92343 ,p_line_definition_owner_code => l_line_definition_owner_code
92344 ,p_line_definition_code => l_line_definition_code
92345 ,p_accounting_line_code => l_component_code
92346 ,p_accounting_line_type_code => l_component_type_code
92347 ,p_accounting_line_appl_id => l_component_appl_id
92348 ,p_amb_context_code => l_amb_context_code
92349 ,p_entity_code => l_entity_code
92350 ,p_event_class_code => l_event_class_code);
92351 --
92352 -- set accounting class
92353 --
92354 xla_ae_lines_pkg.SetAcctClass(
92355 p_accounting_class_code => 'INTERORG_RECEIVABLES'
92356 , p_ae_header_id => l_ae_header_id
92357 );
92358
92359 --
92360 -- set rounding class
92361 --
92362 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
92363 'INTERORG_RECEIVABLES';
92364
92365 --
92366 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
92367 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
92368 --
92369 -- bulk performance
92370 --
92371 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
92372
92373 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
92374 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
92375
92376 -- 4955764
92377 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
92378 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
92379
92380 -- 4458381 Public Sector Enh
92381
92382 --
92383 -- set accounting attributes for the line type
92384 --
92385 l_entered_amt_idx := 3;
92386 l_accted_amt_idx := 8;
92387 l_bflow_applied_to_amt_idx := NULL; -- 5132302
92388 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
92389 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
92390 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
92391 l_rec_acct_attrs.array_char_value(2) := p_source_85;
92392 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
92393 l_rec_acct_attrs.array_num_value(3) := p_source_91;
92394 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
92395 l_rec_acct_attrs.array_char_value(4) := p_source_88;
92396 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
92397 l_rec_acct_attrs.array_date_value(5) := p_source_92;
92398 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
92399 l_rec_acct_attrs.array_num_value(6) := p_source_93;
92400 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
92401 l_rec_acct_attrs.array_char_value(7) := p_source_94;
92402 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
92403 l_rec_acct_attrs.array_num_value(8) := p_source_95;
92404
92405 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
92406 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
92407
92408 ---------------------------------------------------------------------------------------------------------------
92409 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
92410 ---------------------------------------------------------------------------------------------------------------
92411 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
92412
92413 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
92414 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
92415
92416 IF xla_accounting_cache_pkg.GetValueChar
92417 (p_source_code => 'LEDGER_CATEGORY_CODE'
92418 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
92419 AND l_bflow_method_code = 'PRIOR_ENTRY'
92420 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
92421 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
92422 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
92423 )
92424 THEN
92425 xla_ae_lines_pkg.BflowUpgEntry
92426 (p_business_method_code => l_bflow_method_code
92427 ,p_business_class_code => l_bflow_class_code
92428 ,p_balance_type => l_balance_type_code);
92429 ELSE
92430 NULL;
92431 -- No business flow processing for business flow method of NONE.
92432 END IF;
92433
92434 --
92435 -- call analytical criteria
92436 --
92437
92438 --
92439 -- call description
92440 --
92441
92442 xla_ae_lines_pkg.SetLineDescription(
92443 p_ae_header_id => l_ae_header_id
92444 ,p_description => Description_1 (
92445 p_application_id => p_application_id
92446 , p_ae_header_id => l_ae_header_id
92447 , p_source_1 => p_source_1
92448 , p_source_2 => p_source_2
92449 , p_source_3 => p_source_3
92450 , p_source_4 => p_source_4
92451 , p_source_5 => p_source_5
92452 )
92453 );
92454
92455
92456 --
92457 -- call ADRs
92458 -- Bug 4922099
92459 --
92460 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
92461 (NVL(l_actual_upg_option, 'N') = 'O') OR
92462 (NVL(l_enc_upg_option, 'N') = 'O')
92463 )
92464 THEN
92465 NULL;
92466 --
92467 --
92468
92469 l_ccid := AcctDerRule_33(
92470 p_application_id => p_application_id
92471 , p_ae_header_id => l_ae_header_id
92472 , p_source_59 => p_source_59
92473 , x_transaction_coa_id => l_adr_transaction_coa_id
92474 , x_accounting_coa_id => l_adr_accounting_coa_id
92475 , x_value_type_code => l_adr_value_type_code
92476 , p_side => 'NA'
92477 );
92478
92479 xla_ae_lines_pkg.set_ccid(
92480 p_code_combination_id => l_ccid
92481 , p_value_type_code => l_adr_value_type_code
92482 , p_transaction_coa_id => l_adr_transaction_coa_id
92483 , p_accounting_coa_id => l_adr_accounting_coa_id
92484 , p_adr_code => 'PI_RECEIVABLES'
92485 , p_adr_type_code => 'S'
92486 , p_component_type => l_component_type
92487 , p_component_code => l_component_code
92488 , p_component_type_code => l_component_type_code
92489 , p_component_appl_id => l_component_appl_id
92490 , p_amb_context_code => l_amb_context_code
92491 , p_side => 'NA'
92492 );
92493
92494
92495 --
92496 --
92497 END IF;
92498 --
92499 -- Bug 4922099
92500 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
92501 (NVL(l_enc_upg_option, 'N') = 'O')
92502 ) AND
92503 (l_bflow_method_code = 'PRIOR_ENTRY')
92504 )
92505 THEN
92506 IF
92507 --
92508 1 = 2
92509 --
92510 THEN
92511 xla_accounting_err_pkg.build_message
92512 (p_appli_s_name => 'XLA'
92513 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
92514 ,p_token_1 => 'LINE_NUMBER'
92515 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
92516 ,p_token_2 => 'LINE_TYPE_NAME'
92517 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
92518 l_component_type
92519 ,l_component_code
92520 ,l_component_type_code
92521 ,l_component_appl_id
92522 ,l_amb_context_code
92523 ,l_entity_code
92524 ,l_event_class_code
92525 )
92526 ,p_token_3 => 'OWNER'
92527 ,p_value_3 => xla_lookups_pkg.get_meaning(
92528 p_lookup_type => 'XLA_OWNER_TYPE'
92529 ,p_lookup_code => l_component_type_code
92530 )
92531 ,p_token_4 => 'PRODUCT_NAME'
92532 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
92533 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
92534 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
92535 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
92536 ,p_ae_header_id => NULL
92537 );
92538
92539 IF (C_LEVEL_ERROR>= g_log_level) THEN
92540 trace
92541 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
92542 ,p_level => C_LEVEL_ERROR
92543 ,p_module => l_log_module);
92544 END IF;
92545 END IF;
92546 END IF;
92547 --
92548 --
92549 ------------------------------------------------------------------------------------------------
92550 -- 4219869 Business Flow
92551 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
92552 -- Prior Entry. Currently, the following code is always generated.
92553 ------------------------------------------------------------------------------------------------
92554 XLA_AE_LINES_PKG.ValidateCurrentLine;
92555
92556 ------------------------------------------------------------------------------------
92557 -- 4219869 Business Flow
92558 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
92559 ------------------------------------------------------------------------------------
92560 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
92561
92562 ----------------------------------------------------------------------------------
92563 -- 4219869 Business Flow
92564 -- Update journal entry status -- Need to generate this within IF <condition>
92565 ----------------------------------------------------------------------------------
92566 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
92567 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
92568 ,p_balance_type_code => l_balance_type_code
92569 );
92570
92571 -------------------------------------------------------------------------------------------
92572 -- 4262811 - Generate the Accrual Reversal lines
92573 -------------------------------------------------------------------------------------------
92574 BEGIN
92575 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
92576 (g_array_event(p_event_id).array_value_num('header_index'));
92577 IF l_acc_rev_flag IS NULL THEN
92578 l_acc_rev_flag := 'N';
92579 END IF;
92580 EXCEPTION
92581 WHEN OTHERS THEN
92582 l_acc_rev_flag := 'N';
92583 END;
92584 --
92585 IF (l_acc_rev_flag = 'Y') THEN
92586
92587 -- 4645092 ------------------------------------------------------------------------------
92588 -- To allow MPA report to determine if it should generate report process
92589 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
92590 ------------------------------------------------------------------------------------------
92591
92592 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
92593 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
92594 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
92595 -- call ADRs
92596 -- Bug 4922099
92597 --
92598 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
92599 (NVL(l_actual_upg_option, 'N') = 'O') OR
92600 (NVL(l_enc_upg_option, 'N') = 'O')
92601 )
92602 THEN
92603 NULL;
92604 --
92605 --
92606
92607 l_ccid := AcctDerRule_33(
92608 p_application_id => p_application_id
92609 , p_ae_header_id => l_ae_header_id
92610 , p_source_59 => p_source_59
92611 , x_transaction_coa_id => l_adr_transaction_coa_id
92612 , x_accounting_coa_id => l_adr_accounting_coa_id
92613 , x_value_type_code => l_adr_value_type_code
92614 , p_side => 'NA'
92615 );
92616
92617 xla_ae_lines_pkg.set_ccid(
92618 p_code_combination_id => l_ccid
92619 , p_value_type_code => l_adr_value_type_code
92620 , p_transaction_coa_id => l_adr_transaction_coa_id
92621 , p_accounting_coa_id => l_adr_accounting_coa_id
92622 , p_adr_code => 'PI_RECEIVABLES'
92623 , p_adr_type_code => 'S'
92624 , p_component_type => l_component_type
92625 , p_component_code => l_component_code
92626 , p_component_type_code => l_component_type_code
92627 , p_component_appl_id => l_component_appl_id
92628 , p_amb_context_code => l_amb_context_code
92629 , p_side => 'NA'
92630 );
92631
92632
92633 --
92634 --
92635 END IF;
92636
92637 --
92638 -- Update the line information that should be overwritten
92639 --
92640 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
92641 p_header_num => 1);
92642 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
92643
92644 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
92645
92646 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
92647 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
92648 END IF;
92649
92650 --
92651 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
92652 --
92653 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
92654 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
92655 ELSE
92656 ---------------------------------------------------------------------------------------------------
92657 -- 4262811a Switch Sign
92658 ---------------------------------------------------------------------------------------------------
92659 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
92660 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
92661 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92662 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
92663 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92664 -- 5132302
92665 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
92666 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
92667
92668 END IF;
92669
92670 -- 4955764
92671 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
92672 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
92673
92674
92675 XLA_AE_LINES_PKG.ValidateCurrentLine;
92676 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
92677
92678 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
92679 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
92680 ,p_balance_type_code => l_balance_type_code);
92681
92682 END IF;
92683
92684 -----------------------------------------------------------------------------------------
92685 -- 4262811 Multiperiod Accounting
92686 -----------------------------------------------------------------------------------------
92687 -- No MPA option is assigned.
92688
92689
92690 END IF;
92691 END IF;
92692 --
92693
92694 --
92695 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
92696 trace
92697 (p_msg => 'END of AcctLineType_186'
92698 ,p_level => C_LEVEL_PROCEDURE
92699 ,p_module => l_log_module);
92700 END IF;
92701 --
92702 EXCEPTION
92703 WHEN xla_exceptions_pkg.application_exception THEN
92704 RAISE;
92705 WHEN OTHERS THEN
92706 xla_exceptions_pkg.raise_message
92707 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_186');
92708 END AcctLineType_186;
92709 --
92710
92711 ---------------------------------------
92712 --
92713 -- PRIVATE FUNCTION
92714 -- AcctLineType_187
92715 --
92716 ---------------------------------------
92717 PROCEDURE AcctLineType_187 (
92718 p_application_id IN NUMBER
92719 ,p_event_id IN NUMBER
92720 ,p_calculate_acctd_flag IN VARCHAR2
92721 ,p_calculate_g_l_flag IN VARCHAR2
92722 ,p_actual_flag IN OUT VARCHAR2
92723 ,p_balance_type_code OUT VARCHAR2
92724 ,p_gain_or_loss_ref OUT VARCHAR2
92725
92726 --TRANSACTION_ID
92727 , p_source_1 IN NUMBER
92728 --Item Concatenated Segments
92729 , p_source_2 IN VARCHAR2
92730 --Transaction Quantity
92731 , p_source_3 IN NUMBER
92732 --Transaction Unit of Measure Code
92733 , p_source_4 IN VARCHAR2
92734 --Inventory Transaction Type Description
92735 , p_source_5 IN VARCHAR2
92736 --Interorg Receivables Account
92737 , p_source_59 IN NUMBER
92738 --DISTRIBUTION_IDENTIFIER
92739 , p_source_84 IN NUMBER
92740 --Distribution Type
92741 , p_source_85 IN VARCHAR2
92742 , p_source_85_meaning IN VARCHAR2
92743 --Entered Currency Code
92744 , p_source_88 IN VARCHAR2
92745 --Entered Amount
92746 , p_source_91 IN NUMBER
92747 --Currency Conversion Date
92748 , p_source_92 IN DATE
92749 --Currency Conversion Rate
92750 , p_source_93 IN NUMBER
92751 --Currency Conversion Type
92752 , p_source_94 IN VARCHAR2
92753 --Accounted Amount
92754 , p_source_95 IN NUMBER
92755 --Accounting Line Type
92756 , p_source_97 IN NUMBER
92757 )
92758 IS
92759
92760 l_component_type VARCHAR2(80);
92761 l_component_code VARCHAR2(30);
92762 l_component_type_code VARCHAR2(1);
92763 l_component_appl_id INTEGER;
92764 l_amb_context_code VARCHAR2(30);
92765 l_entity_code VARCHAR2(30);
92766 l_event_class_code VARCHAR2(30);
92767 l_ae_header_id NUMBER;
92768 l_event_type_code VARCHAR2(30);
92769 l_line_definition_code VARCHAR2(30);
92770 l_line_definition_owner_code VARCHAR2(1);
92771 --
92772 -- adr variables
92773 l_segment VARCHAR2(30);
92774 l_ccid NUMBER;
92775 l_adr_transaction_coa_id NUMBER;
92776 l_adr_accounting_coa_id NUMBER;
92777 l_adr_flexfield_segment_code VARCHAR2(30);
92778 l_adr_flex_value_set_id NUMBER;
92779 l_adr_value_type_code VARCHAR2(30);
92780 l_adr_value_combination_id NUMBER;
92781 l_adr_value_segment_code VARCHAR2(30);
92782
92783 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
92784 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
92785 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
92786 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
92787
92788 -- 4262811 Variables ------------------------------------------------------------------------------------------
92789 l_entered_amt_idx NUMBER;
92790 l_accted_amt_idx NUMBER;
92791 l_acc_rev_flag VARCHAR2(1);
92792 l_accrual_line_num NUMBER;
92793 l_tmp_amt NUMBER;
92794 l_acc_rev_natural_side_code VARCHAR2(1);
92795
92796 l_num_entries NUMBER;
92797 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
92798 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
92799 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
92800 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
92801 l_recog_line_1 NUMBER;
92802 l_recog_line_2 NUMBER;
92803
92804 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
92805 l_bflow_applied_to_amt NUMBER; -- 5132302
92806 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
92807
92808 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
92809
92810 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
92811 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
92812
92813 ---------------------------------------------------------------------------------------------------------------
92814
92815
92816 --
92817 -- bulk performance
92818 --
92819 l_balance_type_code VARCHAR2(1);
92820 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
92821 l_log_module VARCHAR2(240);
92822
92823 --
92824 -- Upgrade strategy
92825 --
92826 l_actual_upg_option VARCHAR2(1);
92827 l_enc_upg_option VARCHAR2(1);
92828
92829 --
92830 BEGIN
92831 --
92832 IF g_log_enabled THEN
92833 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_187';
92834 END IF;
92835 --
92836 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
92837
92838 trace
92839 (p_msg => 'BEGIN of AcctLineType_187'
92840 ,p_level => C_LEVEL_PROCEDURE
92841 ,p_module => l_log_module);
92842
92843 END IF;
92844 --
92845 l_component_type := 'AMB_JLT';
92846 l_component_code := 'INTERORG_RECEIVABLES';
92847 l_component_type_code := 'S';
92848 l_component_appl_id := 707;
92849 l_amb_context_code := 'DEFAULT';
92850 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
92851 l_event_class_code := 'INT_ORDER_TO_EXP';
92852 l_event_type_code := 'INT_ORDER_ISSUE_TP';
92853 l_line_definition_owner_code := 'S';
92854 l_line_definition_code := 'PI_INT_ORDER_ISSUE_TP';
92855 --
92856 l_balance_type_code := 'A';
92857 l_segment := NULL;
92858 l_ccid := NULL;
92859 l_adr_transaction_coa_id := NULL;
92860 l_adr_accounting_coa_id := NULL;
92861 l_adr_flexfield_segment_code := NULL;
92862 l_adr_flex_value_set_id := NULL;
92863 l_adr_value_type_code := NULL;
92864 l_adr_value_combination_id := NULL;
92865 l_adr_value_segment_code := NULL;
92866
92867 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
92868 l_bflow_class_code := ''; -- 4219869 Business Flow
92869 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
92870 l_budgetary_control_flag := 'N';
92871
92872 l_bflow_applied_to_amt_idx := NULL; -- 5132302
92873 l_bflow_applied_to_amt := NULL; -- 5132302
92874 l_entered_amt_idx := NULL; -- 4262811
92875 l_accted_amt_idx := NULL; -- 4262811
92876 l_acc_rev_flag := NULL; -- 4262811
92877 l_accrual_line_num := NULL; -- 4262811
92878 l_tmp_amt := NULL; -- 4262811
92879 --
92880
92881 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
92882 l_balance_type_code <> 'B' THEN
92883 IF NVL(p_source_97,9E125) = 10
92884 THEN
92885
92886 --
92887 XLA_AE_LINES_PKG.SetNewLine;
92888
92889 p_balance_type_code := l_balance_type_code;
92890 -- set the flag so later we will know whether the gain loss line needs to be created
92891
92892 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
92893 p_actual_flag :='A';
92894 END IF;
92895
92896 --
92897 -- bulk performance
92898 --
92899 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
92900 p_header_num => 0); -- 4262811
92901 --
92902 -- set accounting line options
92903 --
92904 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
92905 p_natural_side_code => 'D'
92906 , p_gain_or_loss_flag => 'N'
92907 , p_gl_transfer_mode_code => 'S'
92908 , p_acct_entry_type_code => 'A'
92909 , p_switch_side_flag => 'Y'
92910 , p_merge_duplicate_code => 'N'
92911 );
92912 --
92913 l_acc_rev_natural_side_code := 'C'; -- 4262811
92914 --
92915 --
92916 -- set accounting line type info
92917 --
92918 xla_ae_lines_pkg.SetAcctLineType
92919 (p_component_type => l_component_type
92920 ,p_event_type_code => l_event_type_code
92921 ,p_line_definition_owner_code => l_line_definition_owner_code
92922 ,p_line_definition_code => l_line_definition_code
92923 ,p_accounting_line_code => l_component_code
92924 ,p_accounting_line_type_code => l_component_type_code
92925 ,p_accounting_line_appl_id => l_component_appl_id
92926 ,p_amb_context_code => l_amb_context_code
92927 ,p_entity_code => l_entity_code
92928 ,p_event_class_code => l_event_class_code);
92929 --
92930 -- set accounting class
92931 --
92932 xla_ae_lines_pkg.SetAcctClass(
92933 p_accounting_class_code => 'INTERORG_RECEIVABLES'
92934 , p_ae_header_id => l_ae_header_id
92935 );
92936
92937 --
92938 -- set rounding class
92939 --
92940 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
92941 'INTERORG_RECEIVABLES';
92942
92943 --
92944 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
92945 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
92946 --
92947 -- bulk performance
92948 --
92949 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
92950
92951 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
92952 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
92953
92954 -- 4955764
92955 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
92956 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
92957
92958 -- 4458381 Public Sector Enh
92959
92960 --
92961 -- set accounting attributes for the line type
92962 --
92963 l_entered_amt_idx := 3;
92964 l_accted_amt_idx := 8;
92965 l_bflow_applied_to_amt_idx := NULL; -- 5132302
92966 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
92967 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
92968 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
92969 l_rec_acct_attrs.array_char_value(2) := p_source_85;
92970 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
92971 l_rec_acct_attrs.array_num_value(3) := p_source_91;
92972 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
92973 l_rec_acct_attrs.array_char_value(4) := p_source_88;
92974 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
92975 l_rec_acct_attrs.array_date_value(5) := p_source_92;
92976 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
92977 l_rec_acct_attrs.array_num_value(6) := p_source_93;
92978 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
92979 l_rec_acct_attrs.array_char_value(7) := p_source_94;
92980 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
92981 l_rec_acct_attrs.array_num_value(8) := p_source_95;
92982
92983 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
92984 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
92985
92986 ---------------------------------------------------------------------------------------------------------------
92987 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
92988 ---------------------------------------------------------------------------------------------------------------
92989 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
92990
92991 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
92992 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
92993
92994 IF xla_accounting_cache_pkg.GetValueChar
92995 (p_source_code => 'LEDGER_CATEGORY_CODE'
92996 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
92997 AND l_bflow_method_code = 'PRIOR_ENTRY'
92998 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
92999 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
93000 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
93001 )
93002 THEN
93003 xla_ae_lines_pkg.BflowUpgEntry
93004 (p_business_method_code => l_bflow_method_code
93005 ,p_business_class_code => l_bflow_class_code
93006 ,p_balance_type => l_balance_type_code);
93007 ELSE
93008 NULL;
93009 -- No business flow processing for business flow method of NONE.
93010 END IF;
93011
93012 --
93013 -- call analytical criteria
93014 --
93015
93016 --
93017 -- call description
93018 --
93019
93020 xla_ae_lines_pkg.SetLineDescription(
93021 p_ae_header_id => l_ae_header_id
93022 ,p_description => Description_1 (
93023 p_application_id => p_application_id
93024 , p_ae_header_id => l_ae_header_id
93025 , p_source_1 => p_source_1
93026 , p_source_2 => p_source_2
93027 , p_source_3 => p_source_3
93028 , p_source_4 => p_source_4
93029 , p_source_5 => p_source_5
93030 )
93031 );
93032
93033
93034 --
93035 -- call ADRs
93036 -- Bug 4922099
93037 --
93038 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
93039 (NVL(l_actual_upg_option, 'N') = 'O') OR
93040 (NVL(l_enc_upg_option, 'N') = 'O')
93041 )
93042 THEN
93043 NULL;
93044 --
93045 --
93046
93047 l_ccid := AcctDerRule_33(
93048 p_application_id => p_application_id
93049 , p_ae_header_id => l_ae_header_id
93050 , p_source_59 => p_source_59
93051 , x_transaction_coa_id => l_adr_transaction_coa_id
93052 , x_accounting_coa_id => l_adr_accounting_coa_id
93053 , x_value_type_code => l_adr_value_type_code
93054 , p_side => 'NA'
93055 );
93056
93057 xla_ae_lines_pkg.set_ccid(
93058 p_code_combination_id => l_ccid
93059 , p_value_type_code => l_adr_value_type_code
93060 , p_transaction_coa_id => l_adr_transaction_coa_id
93061 , p_accounting_coa_id => l_adr_accounting_coa_id
93062 , p_adr_code => 'PI_RECEIVABLES'
93063 , p_adr_type_code => 'S'
93064 , p_component_type => l_component_type
93065 , p_component_code => l_component_code
93066 , p_component_type_code => l_component_type_code
93067 , p_component_appl_id => l_component_appl_id
93068 , p_amb_context_code => l_amb_context_code
93069 , p_side => 'NA'
93070 );
93071
93072
93073 --
93074 --
93075 END IF;
93076 --
93077 -- Bug 4922099
93078 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
93079 (NVL(l_enc_upg_option, 'N') = 'O')
93080 ) AND
93081 (l_bflow_method_code = 'PRIOR_ENTRY')
93082 )
93083 THEN
93084 IF
93085 --
93086 1 = 2
93087 --
93088 THEN
93089 xla_accounting_err_pkg.build_message
93090 (p_appli_s_name => 'XLA'
93091 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
93092 ,p_token_1 => 'LINE_NUMBER'
93093 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
93094 ,p_token_2 => 'LINE_TYPE_NAME'
93095 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
93096 l_component_type
93097 ,l_component_code
93098 ,l_component_type_code
93099 ,l_component_appl_id
93100 ,l_amb_context_code
93101 ,l_entity_code
93102 ,l_event_class_code
93103 )
93104 ,p_token_3 => 'OWNER'
93105 ,p_value_3 => xla_lookups_pkg.get_meaning(
93106 p_lookup_type => 'XLA_OWNER_TYPE'
93107 ,p_lookup_code => l_component_type_code
93108 )
93109 ,p_token_4 => 'PRODUCT_NAME'
93110 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
93111 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
93112 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
93113 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
93114 ,p_ae_header_id => NULL
93115 );
93116
93117 IF (C_LEVEL_ERROR>= g_log_level) THEN
93118 trace
93119 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
93120 ,p_level => C_LEVEL_ERROR
93121 ,p_module => l_log_module);
93122 END IF;
93123 END IF;
93124 END IF;
93125 --
93126 --
93127 ------------------------------------------------------------------------------------------------
93128 -- 4219869 Business Flow
93129 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
93130 -- Prior Entry. Currently, the following code is always generated.
93131 ------------------------------------------------------------------------------------------------
93132 XLA_AE_LINES_PKG.ValidateCurrentLine;
93133
93134 ------------------------------------------------------------------------------------
93135 -- 4219869 Business Flow
93136 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
93137 ------------------------------------------------------------------------------------
93138 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
93139
93140 ----------------------------------------------------------------------------------
93141 -- 4219869 Business Flow
93142 -- Update journal entry status -- Need to generate this within IF <condition>
93143 ----------------------------------------------------------------------------------
93144 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
93145 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
93146 ,p_balance_type_code => l_balance_type_code
93147 );
93148
93149 -------------------------------------------------------------------------------------------
93150 -- 4262811 - Generate the Accrual Reversal lines
93151 -------------------------------------------------------------------------------------------
93152 BEGIN
93153 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
93154 (g_array_event(p_event_id).array_value_num('header_index'));
93155 IF l_acc_rev_flag IS NULL THEN
93156 l_acc_rev_flag := 'N';
93157 END IF;
93158 EXCEPTION
93159 WHEN OTHERS THEN
93160 l_acc_rev_flag := 'N';
93161 END;
93162 --
93163 IF (l_acc_rev_flag = 'Y') THEN
93164
93165 -- 4645092 ------------------------------------------------------------------------------
93166 -- To allow MPA report to determine if it should generate report process
93167 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
93168 ------------------------------------------------------------------------------------------
93169
93170 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
93171 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
93172 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
93173 -- call ADRs
93174 -- Bug 4922099
93175 --
93176 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
93177 (NVL(l_actual_upg_option, 'N') = 'O') OR
93178 (NVL(l_enc_upg_option, 'N') = 'O')
93179 )
93180 THEN
93181 NULL;
93182 --
93183 --
93184
93185 l_ccid := AcctDerRule_33(
93186 p_application_id => p_application_id
93187 , p_ae_header_id => l_ae_header_id
93188 , p_source_59 => p_source_59
93189 , x_transaction_coa_id => l_adr_transaction_coa_id
93190 , x_accounting_coa_id => l_adr_accounting_coa_id
93191 , x_value_type_code => l_adr_value_type_code
93192 , p_side => 'NA'
93193 );
93194
93195 xla_ae_lines_pkg.set_ccid(
93196 p_code_combination_id => l_ccid
93197 , p_value_type_code => l_adr_value_type_code
93198 , p_transaction_coa_id => l_adr_transaction_coa_id
93199 , p_accounting_coa_id => l_adr_accounting_coa_id
93200 , p_adr_code => 'PI_RECEIVABLES'
93201 , p_adr_type_code => 'S'
93202 , p_component_type => l_component_type
93203 , p_component_code => l_component_code
93204 , p_component_type_code => l_component_type_code
93205 , p_component_appl_id => l_component_appl_id
93206 , p_amb_context_code => l_amb_context_code
93207 , p_side => 'NA'
93208 );
93209
93210
93211 --
93212 --
93213 END IF;
93214
93215 --
93216 -- Update the line information that should be overwritten
93217 --
93218 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
93219 p_header_num => 1);
93220 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
93221
93222 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
93223
93224 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
93225 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
93226 END IF;
93227
93228 --
93229 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
93230 --
93231 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
93232 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
93233 ELSE
93234 ---------------------------------------------------------------------------------------------------
93235 -- 4262811a Switch Sign
93236 ---------------------------------------------------------------------------------------------------
93237 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
93238 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
93239 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93240 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
93241 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93242 -- 5132302
93243 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
93244 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93245
93246 END IF;
93247
93248 -- 4955764
93249 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
93250 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
93251
93252
93253 XLA_AE_LINES_PKG.ValidateCurrentLine;
93254 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
93255
93256 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
93257 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
93258 ,p_balance_type_code => l_balance_type_code);
93259
93260 END IF;
93261
93262 -----------------------------------------------------------------------------------------
93263 -- 4262811 Multiperiod Accounting
93264 -----------------------------------------------------------------------------------------
93265 -- No MPA option is assigned.
93266
93267
93268 END IF;
93269 END IF;
93270 --
93271
93272 --
93273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
93274 trace
93275 (p_msg => 'END of AcctLineType_187'
93276 ,p_level => C_LEVEL_PROCEDURE
93277 ,p_module => l_log_module);
93278 END IF;
93279 --
93280 EXCEPTION
93281 WHEN xla_exceptions_pkg.application_exception THEN
93282 RAISE;
93283 WHEN OTHERS THEN
93284 xla_exceptions_pkg.raise_message
93285 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_187');
93286 END AcctLineType_187;
93287 --
93288
93289 ---------------------------------------
93290 --
93291 -- PRIVATE FUNCTION
93292 -- AcctLineType_188
93293 --
93294 ---------------------------------------
93295 PROCEDURE AcctLineType_188 (
93296 p_application_id IN NUMBER
93297 ,p_event_id IN NUMBER
93298 ,p_calculate_acctd_flag IN VARCHAR2
93299 ,p_calculate_g_l_flag IN VARCHAR2
93300 ,p_actual_flag IN OUT VARCHAR2
93301 ,p_balance_type_code OUT VARCHAR2
93302 ,p_gain_or_loss_ref OUT VARCHAR2
93303
93304 --TRANSACTION_ID
93305 , p_source_1 IN NUMBER
93306 --Item Concatenated Segments
93307 , p_source_2 IN VARCHAR2
93308 --Transaction Quantity
93309 , p_source_3 IN NUMBER
93310 --Transaction Unit of Measure Code
93311 , p_source_4 IN VARCHAR2
93312 --Inventory Transaction Type Description
93313 , p_source_5 IN VARCHAR2
93314 --Interorg Receivables Account
93315 , p_source_59 IN NUMBER
93316 --DISTRIBUTION_IDENTIFIER
93317 , p_source_84 IN NUMBER
93318 --Distribution Type
93319 , p_source_85 IN VARCHAR2
93320 , p_source_85_meaning IN VARCHAR2
93321 --Entered Currency Code
93322 , p_source_88 IN VARCHAR2
93323 --Entered Amount
93324 , p_source_91 IN NUMBER
93325 --Currency Conversion Date
93326 , p_source_92 IN DATE
93327 --Currency Conversion Rate
93328 , p_source_93 IN NUMBER
93329 --Currency Conversion Type
93330 , p_source_94 IN VARCHAR2
93331 --Accounted Amount
93332 , p_source_95 IN NUMBER
93333 --Accounting Line Type
93334 , p_source_97 IN NUMBER
93335 )
93336 IS
93337
93338 l_component_type VARCHAR2(80);
93339 l_component_code VARCHAR2(30);
93340 l_component_type_code VARCHAR2(1);
93341 l_component_appl_id INTEGER;
93342 l_amb_context_code VARCHAR2(30);
93343 l_entity_code VARCHAR2(30);
93344 l_event_class_code VARCHAR2(30);
93345 l_ae_header_id NUMBER;
93346 l_event_type_code VARCHAR2(30);
93347 l_line_definition_code VARCHAR2(30);
93348 l_line_definition_owner_code VARCHAR2(1);
93349 --
93350 -- adr variables
93351 l_segment VARCHAR2(30);
93352 l_ccid NUMBER;
93353 l_adr_transaction_coa_id NUMBER;
93354 l_adr_accounting_coa_id NUMBER;
93355 l_adr_flexfield_segment_code VARCHAR2(30);
93356 l_adr_flex_value_set_id NUMBER;
93357 l_adr_value_type_code VARCHAR2(30);
93358 l_adr_value_combination_id NUMBER;
93359 l_adr_value_segment_code VARCHAR2(30);
93360
93361 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
93362 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
93363 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
93364 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
93365
93366 -- 4262811 Variables ------------------------------------------------------------------------------------------
93367 l_entered_amt_idx NUMBER;
93368 l_accted_amt_idx NUMBER;
93369 l_acc_rev_flag VARCHAR2(1);
93370 l_accrual_line_num NUMBER;
93371 l_tmp_amt NUMBER;
93372 l_acc_rev_natural_side_code VARCHAR2(1);
93373
93374 l_num_entries NUMBER;
93375 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
93376 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
93377 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
93378 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
93379 l_recog_line_1 NUMBER;
93380 l_recog_line_2 NUMBER;
93381
93382 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
93383 l_bflow_applied_to_amt NUMBER; -- 5132302
93384 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
93385
93386 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
93387
93388 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
93389 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
93390
93391 ---------------------------------------------------------------------------------------------------------------
93392
93393
93394 --
93395 -- bulk performance
93396 --
93397 l_balance_type_code VARCHAR2(1);
93398 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
93399 l_log_module VARCHAR2(240);
93400
93401 --
93402 -- Upgrade strategy
93403 --
93404 l_actual_upg_option VARCHAR2(1);
93405 l_enc_upg_option VARCHAR2(1);
93406
93407 --
93408 BEGIN
93409 --
93410 IF g_log_enabled THEN
93411 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_188';
93412 END IF;
93413 --
93414 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
93415
93416 trace
93417 (p_msg => 'BEGIN of AcctLineType_188'
93418 ,p_level => C_LEVEL_PROCEDURE
93419 ,p_module => l_log_module);
93420
93421 END IF;
93422 --
93423 l_component_type := 'AMB_JLT';
93424 l_component_code := 'INTERORG_RECEIVABLES';
93425 l_component_type_code := 'S';
93426 l_component_appl_id := 707;
93427 l_amb_context_code := 'DEFAULT';
93428 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
93429 l_event_class_code := 'USER_DEFINE';
93430 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_TP';
93431 l_line_definition_owner_code := 'S';
93432 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_TP';
93433 --
93434 l_balance_type_code := 'A';
93435 l_segment := NULL;
93436 l_ccid := NULL;
93437 l_adr_transaction_coa_id := NULL;
93438 l_adr_accounting_coa_id := NULL;
93439 l_adr_flexfield_segment_code := NULL;
93440 l_adr_flex_value_set_id := NULL;
93441 l_adr_value_type_code := NULL;
93442 l_adr_value_combination_id := NULL;
93443 l_adr_value_segment_code := NULL;
93444
93445 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
93446 l_bflow_class_code := ''; -- 4219869 Business Flow
93447 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
93448 l_budgetary_control_flag := 'N';
93449
93450 l_bflow_applied_to_amt_idx := NULL; -- 5132302
93451 l_bflow_applied_to_amt := NULL; -- 5132302
93452 l_entered_amt_idx := NULL; -- 4262811
93453 l_accted_amt_idx := NULL; -- 4262811
93454 l_acc_rev_flag := NULL; -- 4262811
93455 l_accrual_line_num := NULL; -- 4262811
93456 l_tmp_amt := NULL; -- 4262811
93457 --
93458
93459 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
93460 l_balance_type_code <> 'B' THEN
93461 IF NVL(p_source_97,9E125) = 10
93462 THEN
93463
93464 --
93465 XLA_AE_LINES_PKG.SetNewLine;
93466
93467 p_balance_type_code := l_balance_type_code;
93468 -- set the flag so later we will know whether the gain loss line needs to be created
93469
93470 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
93471 p_actual_flag :='A';
93472 END IF;
93473
93474 --
93475 -- bulk performance
93476 --
93477 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
93478 p_header_num => 0); -- 4262811
93479 --
93480 -- set accounting line options
93481 --
93482 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
93483 p_natural_side_code => 'D'
93484 , p_gain_or_loss_flag => 'N'
93485 , p_gl_transfer_mode_code => 'S'
93486 , p_acct_entry_type_code => 'A'
93487 , p_switch_side_flag => 'Y'
93488 , p_merge_duplicate_code => 'N'
93489 );
93490 --
93491 l_acc_rev_natural_side_code := 'C'; -- 4262811
93492 --
93493 --
93494 -- set accounting line type info
93495 --
93496 xla_ae_lines_pkg.SetAcctLineType
93497 (p_component_type => l_component_type
93498 ,p_event_type_code => l_event_type_code
93499 ,p_line_definition_owner_code => l_line_definition_owner_code
93500 ,p_line_definition_code => l_line_definition_code
93501 ,p_accounting_line_code => l_component_code
93502 ,p_accounting_line_type_code => l_component_type_code
93503 ,p_accounting_line_appl_id => l_component_appl_id
93504 ,p_amb_context_code => l_amb_context_code
93505 ,p_entity_code => l_entity_code
93506 ,p_event_class_code => l_event_class_code);
93507 --
93508 -- set accounting class
93509 --
93510 xla_ae_lines_pkg.SetAcctClass(
93511 p_accounting_class_code => 'INTERORG_RECEIVABLES'
93512 , p_ae_header_id => l_ae_header_id
93513 );
93514
93515 --
93516 -- set rounding class
93517 --
93518 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
93519 'INTERORG_RECEIVABLES';
93520
93521 --
93522 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
93523 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
93524 --
93525 -- bulk performance
93526 --
93527 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
93528
93529 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
93530 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
93531
93532 -- 4955764
93533 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
93534 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
93535
93536 -- 4458381 Public Sector Enh
93537
93538 --
93539 -- set accounting attributes for the line type
93540 --
93541 l_entered_amt_idx := 3;
93542 l_accted_amt_idx := 8;
93543 l_bflow_applied_to_amt_idx := NULL; -- 5132302
93544 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
93545 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
93546 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
93547 l_rec_acct_attrs.array_char_value(2) := p_source_85;
93548 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
93549 l_rec_acct_attrs.array_num_value(3) := p_source_91;
93550 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
93551 l_rec_acct_attrs.array_char_value(4) := p_source_88;
93552 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
93553 l_rec_acct_attrs.array_date_value(5) := p_source_92;
93554 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
93555 l_rec_acct_attrs.array_num_value(6) := p_source_93;
93556 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
93557 l_rec_acct_attrs.array_char_value(7) := p_source_94;
93558 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
93559 l_rec_acct_attrs.array_num_value(8) := p_source_95;
93560
93561 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
93562 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
93563
93564 ---------------------------------------------------------------------------------------------------------------
93565 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
93566 ---------------------------------------------------------------------------------------------------------------
93567 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
93568
93569 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
93570 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
93571
93572 IF xla_accounting_cache_pkg.GetValueChar
93573 (p_source_code => 'LEDGER_CATEGORY_CODE'
93574 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
93575 AND l_bflow_method_code = 'PRIOR_ENTRY'
93576 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
93577 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
93578 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
93579 )
93580 THEN
93581 xla_ae_lines_pkg.BflowUpgEntry
93582 (p_business_method_code => l_bflow_method_code
93583 ,p_business_class_code => l_bflow_class_code
93584 ,p_balance_type => l_balance_type_code);
93585 ELSE
93586 NULL;
93587 -- No business flow processing for business flow method of NONE.
93588 END IF;
93589
93590 --
93591 -- call analytical criteria
93592 --
93593
93594 --
93595 -- call description
93596 --
93597
93598 xla_ae_lines_pkg.SetLineDescription(
93599 p_ae_header_id => l_ae_header_id
93600 ,p_description => Description_1 (
93601 p_application_id => p_application_id
93602 , p_ae_header_id => l_ae_header_id
93603 , p_source_1 => p_source_1
93604 , p_source_2 => p_source_2
93605 , p_source_3 => p_source_3
93606 , p_source_4 => p_source_4
93607 , p_source_5 => p_source_5
93608 )
93609 );
93610
93611
93612 --
93613 -- call ADRs
93614 -- Bug 4922099
93615 --
93616 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
93617 (NVL(l_actual_upg_option, 'N') = 'O') OR
93618 (NVL(l_enc_upg_option, 'N') = 'O')
93619 )
93620 THEN
93621 NULL;
93622 --
93623 --
93624
93625 l_ccid := AcctDerRule_33(
93626 p_application_id => p_application_id
93627 , p_ae_header_id => l_ae_header_id
93628 , p_source_59 => p_source_59
93629 , x_transaction_coa_id => l_adr_transaction_coa_id
93630 , x_accounting_coa_id => l_adr_accounting_coa_id
93631 , x_value_type_code => l_adr_value_type_code
93632 , p_side => 'NA'
93633 );
93634
93635 xla_ae_lines_pkg.set_ccid(
93636 p_code_combination_id => l_ccid
93637 , p_value_type_code => l_adr_value_type_code
93638 , p_transaction_coa_id => l_adr_transaction_coa_id
93639 , p_accounting_coa_id => l_adr_accounting_coa_id
93640 , p_adr_code => 'PI_RECEIVABLES'
93641 , p_adr_type_code => 'S'
93642 , p_component_type => l_component_type
93643 , p_component_code => l_component_code
93644 , p_component_type_code => l_component_type_code
93645 , p_component_appl_id => l_component_appl_id
93646 , p_amb_context_code => l_amb_context_code
93647 , p_side => 'NA'
93648 );
93649
93650
93651 --
93652 --
93653 END IF;
93654 --
93655 -- Bug 4922099
93656 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
93657 (NVL(l_enc_upg_option, 'N') = 'O')
93658 ) AND
93659 (l_bflow_method_code = 'PRIOR_ENTRY')
93660 )
93661 THEN
93662 IF
93663 --
93664 1 = 2
93665 --
93666 THEN
93667 xla_accounting_err_pkg.build_message
93668 (p_appli_s_name => 'XLA'
93669 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
93670 ,p_token_1 => 'LINE_NUMBER'
93671 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
93672 ,p_token_2 => 'LINE_TYPE_NAME'
93673 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
93674 l_component_type
93675 ,l_component_code
93676 ,l_component_type_code
93677 ,l_component_appl_id
93678 ,l_amb_context_code
93679 ,l_entity_code
93680 ,l_event_class_code
93681 )
93682 ,p_token_3 => 'OWNER'
93683 ,p_value_3 => xla_lookups_pkg.get_meaning(
93684 p_lookup_type => 'XLA_OWNER_TYPE'
93685 ,p_lookup_code => l_component_type_code
93686 )
93687 ,p_token_4 => 'PRODUCT_NAME'
93688 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
93689 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
93690 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
93691 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
93692 ,p_ae_header_id => NULL
93693 );
93694
93695 IF (C_LEVEL_ERROR>= g_log_level) THEN
93696 trace
93697 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
93698 ,p_level => C_LEVEL_ERROR
93699 ,p_module => l_log_module);
93700 END IF;
93701 END IF;
93702 END IF;
93703 --
93704 --
93705 ------------------------------------------------------------------------------------------------
93706 -- 4219869 Business Flow
93707 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
93708 -- Prior Entry. Currently, the following code is always generated.
93709 ------------------------------------------------------------------------------------------------
93710 XLA_AE_LINES_PKG.ValidateCurrentLine;
93711
93712 ------------------------------------------------------------------------------------
93713 -- 4219869 Business Flow
93714 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
93715 ------------------------------------------------------------------------------------
93716 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
93717
93718 ----------------------------------------------------------------------------------
93719 -- 4219869 Business Flow
93720 -- Update journal entry status -- Need to generate this within IF <condition>
93721 ----------------------------------------------------------------------------------
93722 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
93723 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
93724 ,p_balance_type_code => l_balance_type_code
93725 );
93726
93727 -------------------------------------------------------------------------------------------
93728 -- 4262811 - Generate the Accrual Reversal lines
93729 -------------------------------------------------------------------------------------------
93730 BEGIN
93731 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
93732 (g_array_event(p_event_id).array_value_num('header_index'));
93733 IF l_acc_rev_flag IS NULL THEN
93734 l_acc_rev_flag := 'N';
93735 END IF;
93736 EXCEPTION
93737 WHEN OTHERS THEN
93738 l_acc_rev_flag := 'N';
93739 END;
93740 --
93741 IF (l_acc_rev_flag = 'Y') THEN
93742
93743 -- 4645092 ------------------------------------------------------------------------------
93744 -- To allow MPA report to determine if it should generate report process
93745 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
93746 ------------------------------------------------------------------------------------------
93747
93748 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
93749 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
93750 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
93751 -- call ADRs
93752 -- Bug 4922099
93753 --
93754 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
93755 (NVL(l_actual_upg_option, 'N') = 'O') OR
93756 (NVL(l_enc_upg_option, 'N') = 'O')
93757 )
93758 THEN
93759 NULL;
93760 --
93761 --
93762
93763 l_ccid := AcctDerRule_33(
93764 p_application_id => p_application_id
93765 , p_ae_header_id => l_ae_header_id
93766 , p_source_59 => p_source_59
93767 , x_transaction_coa_id => l_adr_transaction_coa_id
93768 , x_accounting_coa_id => l_adr_accounting_coa_id
93769 , x_value_type_code => l_adr_value_type_code
93770 , p_side => 'NA'
93771 );
93772
93773 xla_ae_lines_pkg.set_ccid(
93774 p_code_combination_id => l_ccid
93775 , p_value_type_code => l_adr_value_type_code
93776 , p_transaction_coa_id => l_adr_transaction_coa_id
93777 , p_accounting_coa_id => l_adr_accounting_coa_id
93778 , p_adr_code => 'PI_RECEIVABLES'
93779 , p_adr_type_code => 'S'
93780 , p_component_type => l_component_type
93781 , p_component_code => l_component_code
93782 , p_component_type_code => l_component_type_code
93783 , p_component_appl_id => l_component_appl_id
93784 , p_amb_context_code => l_amb_context_code
93785 , p_side => 'NA'
93786 );
93787
93788
93789 --
93790 --
93791 END IF;
93792
93793 --
93794 -- Update the line information that should be overwritten
93795 --
93796 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
93797 p_header_num => 1);
93798 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
93799
93800 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
93801
93802 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
93803 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
93804 END IF;
93805
93806 --
93807 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
93808 --
93809 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
93810 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
93811 ELSE
93812 ---------------------------------------------------------------------------------------------------
93813 -- 4262811a Switch Sign
93814 ---------------------------------------------------------------------------------------------------
93815 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
93816 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
93817 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93818 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
93819 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93820 -- 5132302
93821 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
93822 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
93823
93824 END IF;
93825
93826 -- 4955764
93827 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
93828 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
93829
93830
93831 XLA_AE_LINES_PKG.ValidateCurrentLine;
93832 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
93833
93834 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
93835 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
93836 ,p_balance_type_code => l_balance_type_code);
93837
93838 END IF;
93839
93840 -----------------------------------------------------------------------------------------
93841 -- 4262811 Multiperiod Accounting
93842 -----------------------------------------------------------------------------------------
93843 -- No MPA option is assigned.
93844
93845
93846 END IF;
93847 END IF;
93848 --
93849
93850 --
93851 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
93852 trace
93853 (p_msg => 'END of AcctLineType_188'
93854 ,p_level => C_LEVEL_PROCEDURE
93855 ,p_module => l_log_module);
93856 END IF;
93857 --
93858 EXCEPTION
93859 WHEN xla_exceptions_pkg.application_exception THEN
93860 RAISE;
93861 WHEN OTHERS THEN
93862 xla_exceptions_pkg.raise_message
93863 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_188');
93864 END AcctLineType_188;
93865 --
93866
93867 ---------------------------------------
93868 --
93869 -- PRIVATE FUNCTION
93870 -- AcctLineType_189
93871 --
93872 ---------------------------------------
93873 PROCEDURE AcctLineType_189 (
93874 p_application_id IN NUMBER
93875 ,p_event_id IN NUMBER
93876 ,p_calculate_acctd_flag IN VARCHAR2
93877 ,p_calculate_g_l_flag IN VARCHAR2
93878 ,p_actual_flag IN OUT VARCHAR2
93879 ,p_balance_type_code OUT VARCHAR2
93880 ,p_gain_or_loss_ref OUT VARCHAR2
93881
93882 --TRANSACTION_ID
93883 , p_source_1 IN NUMBER
93884 --Item Concatenated Segments
93885 , p_source_2 IN VARCHAR2
93886 --Transaction Quantity
93887 , p_source_3 IN NUMBER
93888 --Transaction Unit of Measure Code
93889 , p_source_4 IN VARCHAR2
93890 --Inventory Transaction Type Description
93891 , p_source_5 IN VARCHAR2
93892 --Interorg Receivables Account
93893 , p_source_59 IN NUMBER
93894 --DISTRIBUTION_IDENTIFIER
93895 , p_source_84 IN NUMBER
93896 --Distribution Type
93897 , p_source_85 IN VARCHAR2
93898 , p_source_85_meaning IN VARCHAR2
93899 --Entered Currency Code
93900 , p_source_88 IN VARCHAR2
93901 --Entered Amount
93902 , p_source_91 IN NUMBER
93903 --Currency Conversion Date
93904 , p_source_92 IN DATE
93905 --Currency Conversion Rate
93906 , p_source_93 IN NUMBER
93907 --Currency Conversion Type
93908 , p_source_94 IN VARCHAR2
93909 --Accounted Amount
93910 , p_source_95 IN NUMBER
93911 --Accounting Line Type
93912 , p_source_97 IN NUMBER
93913 )
93914 IS
93915
93916 l_component_type VARCHAR2(80);
93917 l_component_code VARCHAR2(30);
93918 l_component_type_code VARCHAR2(1);
93919 l_component_appl_id INTEGER;
93920 l_amb_context_code VARCHAR2(30);
93921 l_entity_code VARCHAR2(30);
93922 l_event_class_code VARCHAR2(30);
93923 l_ae_header_id NUMBER;
93924 l_event_type_code VARCHAR2(30);
93925 l_line_definition_code VARCHAR2(30);
93926 l_line_definition_owner_code VARCHAR2(1);
93927 --
93928 -- adr variables
93929 l_segment VARCHAR2(30);
93930 l_ccid NUMBER;
93931 l_adr_transaction_coa_id NUMBER;
93932 l_adr_accounting_coa_id NUMBER;
93933 l_adr_flexfield_segment_code VARCHAR2(30);
93934 l_adr_flex_value_set_id NUMBER;
93935 l_adr_value_type_code VARCHAR2(30);
93936 l_adr_value_combination_id NUMBER;
93937 l_adr_value_segment_code VARCHAR2(30);
93938
93939 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
93940 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
93941 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
93942 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
93943
93944 -- 4262811 Variables ------------------------------------------------------------------------------------------
93945 l_entered_amt_idx NUMBER;
93946 l_accted_amt_idx NUMBER;
93947 l_acc_rev_flag VARCHAR2(1);
93948 l_accrual_line_num NUMBER;
93949 l_tmp_amt NUMBER;
93950 l_acc_rev_natural_side_code VARCHAR2(1);
93951
93952 l_num_entries NUMBER;
93953 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
93954 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
93955 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
93956 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
93957 l_recog_line_1 NUMBER;
93958 l_recog_line_2 NUMBER;
93959
93960 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
93961 l_bflow_applied_to_amt NUMBER; -- 5132302
93962 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
93963
93964 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
93965
93966 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
93967 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
93968
93969 ---------------------------------------------------------------------------------------------------------------
93970
93971
93972 --
93973 -- bulk performance
93974 --
93975 l_balance_type_code VARCHAR2(1);
93976 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
93977 l_log_module VARCHAR2(240);
93978
93979 --
93980 -- Upgrade strategy
93981 --
93982 l_actual_upg_option VARCHAR2(1);
93983 l_enc_upg_option VARCHAR2(1);
93984
93985 --
93986 BEGIN
93987 --
93988 IF g_log_enabled THEN
93989 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_189';
93990 END IF;
93991 --
93992 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
93993
93994 trace
93995 (p_msg => 'BEGIN of AcctLineType_189'
93996 ,p_level => C_LEVEL_PROCEDURE
93997 ,p_module => l_log_module);
93998
93999 END IF;
94000 --
94001 l_component_type := 'AMB_JLT';
94002 l_component_code := 'INTERORG_RECEIVABLES';
94003 l_component_type_code := 'S';
94004 l_component_appl_id := 707;
94005 l_amb_context_code := 'DEFAULT';
94006 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
94007 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
94008 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
94009 l_line_definition_owner_code := 'S';
94010 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
94011 --
94012 l_balance_type_code := 'A';
94013 l_segment := NULL;
94014 l_ccid := NULL;
94015 l_adr_transaction_coa_id := NULL;
94016 l_adr_accounting_coa_id := NULL;
94017 l_adr_flexfield_segment_code := NULL;
94018 l_adr_flex_value_set_id := NULL;
94019 l_adr_value_type_code := NULL;
94020 l_adr_value_combination_id := NULL;
94021 l_adr_value_segment_code := NULL;
94022
94023 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
94024 l_bflow_class_code := ''; -- 4219869 Business Flow
94025 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
94026 l_budgetary_control_flag := 'N';
94027
94028 l_bflow_applied_to_amt_idx := NULL; -- 5132302
94029 l_bflow_applied_to_amt := NULL; -- 5132302
94030 l_entered_amt_idx := NULL; -- 4262811
94031 l_accted_amt_idx := NULL; -- 4262811
94032 l_acc_rev_flag := NULL; -- 4262811
94033 l_accrual_line_num := NULL; -- 4262811
94034 l_tmp_amt := NULL; -- 4262811
94035 --
94036
94037 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
94038 l_balance_type_code <> 'B' THEN
94039 IF NVL(p_source_97,9E125) = 10
94040 THEN
94041
94042 --
94043 XLA_AE_LINES_PKG.SetNewLine;
94044
94045 p_balance_type_code := l_balance_type_code;
94046 -- set the flag so later we will know whether the gain loss line needs to be created
94047
94048 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
94049 p_actual_flag :='A';
94050 END IF;
94051
94052 --
94053 -- bulk performance
94054 --
94055 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
94056 p_header_num => 0); -- 4262811
94057 --
94058 -- set accounting line options
94059 --
94060 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
94061 p_natural_side_code => 'D'
94062 , p_gain_or_loss_flag => 'N'
94063 , p_gl_transfer_mode_code => 'S'
94064 , p_acct_entry_type_code => 'A'
94065 , p_switch_side_flag => 'Y'
94066 , p_merge_duplicate_code => 'N'
94067 );
94068 --
94069 l_acc_rev_natural_side_code := 'C'; -- 4262811
94070 --
94071 --
94072 -- set accounting line type info
94073 --
94074 xla_ae_lines_pkg.SetAcctLineType
94075 (p_component_type => l_component_type
94076 ,p_event_type_code => l_event_type_code
94077 ,p_line_definition_owner_code => l_line_definition_owner_code
94078 ,p_line_definition_code => l_line_definition_code
94079 ,p_accounting_line_code => l_component_code
94080 ,p_accounting_line_type_code => l_component_type_code
94081 ,p_accounting_line_appl_id => l_component_appl_id
94082 ,p_amb_context_code => l_amb_context_code
94083 ,p_entity_code => l_entity_code
94084 ,p_event_class_code => l_event_class_code);
94085 --
94086 -- set accounting class
94087 --
94088 xla_ae_lines_pkg.SetAcctClass(
94089 p_accounting_class_code => 'INTERORG_RECEIVABLES'
94090 , p_ae_header_id => l_ae_header_id
94091 );
94092
94093 --
94094 -- set rounding class
94095 --
94096 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
94097 'INTERORG_RECEIVABLES';
94098
94099 --
94100 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
94101 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
94102 --
94103 -- bulk performance
94104 --
94105 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
94106
94107 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
94108 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
94109
94110 -- 4955764
94111 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
94112 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
94113
94114 -- 4458381 Public Sector Enh
94115
94116 --
94117 -- set accounting attributes for the line type
94118 --
94119 l_entered_amt_idx := 3;
94120 l_accted_amt_idx := 8;
94121 l_bflow_applied_to_amt_idx := NULL; -- 5132302
94122 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
94123 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
94124 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
94125 l_rec_acct_attrs.array_char_value(2) := p_source_85;
94126 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
94127 l_rec_acct_attrs.array_num_value(3) := p_source_91;
94128 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
94129 l_rec_acct_attrs.array_char_value(4) := p_source_88;
94130 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
94131 l_rec_acct_attrs.array_date_value(5) := p_source_92;
94132 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
94133 l_rec_acct_attrs.array_num_value(6) := p_source_93;
94134 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
94135 l_rec_acct_attrs.array_char_value(7) := p_source_94;
94136 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
94137 l_rec_acct_attrs.array_num_value(8) := p_source_95;
94138
94139 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
94140 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
94141
94142 ---------------------------------------------------------------------------------------------------------------
94143 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
94144 ---------------------------------------------------------------------------------------------------------------
94145 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
94146
94147 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
94148 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
94149
94150 IF xla_accounting_cache_pkg.GetValueChar
94151 (p_source_code => 'LEDGER_CATEGORY_CODE'
94152 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
94153 AND l_bflow_method_code = 'PRIOR_ENTRY'
94154 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
94155 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
94156 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
94157 )
94158 THEN
94159 xla_ae_lines_pkg.BflowUpgEntry
94160 (p_business_method_code => l_bflow_method_code
94161 ,p_business_class_code => l_bflow_class_code
94162 ,p_balance_type => l_balance_type_code);
94163 ELSE
94164 NULL;
94165 -- No business flow processing for business flow method of NONE.
94166 END IF;
94167
94168 --
94169 -- call analytical criteria
94170 --
94171
94172 --
94173 -- call description
94174 --
94175
94176 xla_ae_lines_pkg.SetLineDescription(
94177 p_ae_header_id => l_ae_header_id
94178 ,p_description => Description_1 (
94179 p_application_id => p_application_id
94180 , p_ae_header_id => l_ae_header_id
94181 , p_source_1 => p_source_1
94182 , p_source_2 => p_source_2
94183 , p_source_3 => p_source_3
94184 , p_source_4 => p_source_4
94185 , p_source_5 => p_source_5
94186 )
94187 );
94188
94189
94190 --
94191 -- call ADRs
94192 -- Bug 4922099
94193 --
94194 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
94195 (NVL(l_actual_upg_option, 'N') = 'O') OR
94196 (NVL(l_enc_upg_option, 'N') = 'O')
94197 )
94198 THEN
94199 NULL;
94200 --
94201 --
94202
94203 l_ccid := AcctDerRule_33(
94204 p_application_id => p_application_id
94205 , p_ae_header_id => l_ae_header_id
94206 , p_source_59 => p_source_59
94207 , x_transaction_coa_id => l_adr_transaction_coa_id
94208 , x_accounting_coa_id => l_adr_accounting_coa_id
94209 , x_value_type_code => l_adr_value_type_code
94210 , p_side => 'NA'
94211 );
94212
94213 xla_ae_lines_pkg.set_ccid(
94214 p_code_combination_id => l_ccid
94215 , p_value_type_code => l_adr_value_type_code
94216 , p_transaction_coa_id => l_adr_transaction_coa_id
94217 , p_accounting_coa_id => l_adr_accounting_coa_id
94218 , p_adr_code => 'PI_RECEIVABLES'
94219 , p_adr_type_code => 'S'
94220 , p_component_type => l_component_type
94221 , p_component_code => l_component_code
94222 , p_component_type_code => l_component_type_code
94223 , p_component_appl_id => l_component_appl_id
94224 , p_amb_context_code => l_amb_context_code
94225 , p_side => 'NA'
94226 );
94227
94228
94229 --
94230 --
94231 END IF;
94232 --
94233 -- Bug 4922099
94234 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
94235 (NVL(l_enc_upg_option, 'N') = 'O')
94236 ) AND
94237 (l_bflow_method_code = 'PRIOR_ENTRY')
94238 )
94239 THEN
94240 IF
94241 --
94242 1 = 2
94243 --
94244 THEN
94245 xla_accounting_err_pkg.build_message
94246 (p_appli_s_name => 'XLA'
94247 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
94248 ,p_token_1 => 'LINE_NUMBER'
94249 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
94250 ,p_token_2 => 'LINE_TYPE_NAME'
94251 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
94252 l_component_type
94253 ,l_component_code
94254 ,l_component_type_code
94255 ,l_component_appl_id
94256 ,l_amb_context_code
94257 ,l_entity_code
94258 ,l_event_class_code
94259 )
94260 ,p_token_3 => 'OWNER'
94261 ,p_value_3 => xla_lookups_pkg.get_meaning(
94262 p_lookup_type => 'XLA_OWNER_TYPE'
94263 ,p_lookup_code => l_component_type_code
94264 )
94265 ,p_token_4 => 'PRODUCT_NAME'
94266 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
94267 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
94268 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
94269 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
94270 ,p_ae_header_id => NULL
94271 );
94272
94273 IF (C_LEVEL_ERROR>= g_log_level) THEN
94274 trace
94275 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
94276 ,p_level => C_LEVEL_ERROR
94277 ,p_module => l_log_module);
94278 END IF;
94279 END IF;
94280 END IF;
94281 --
94282 --
94283 ------------------------------------------------------------------------------------------------
94284 -- 4219869 Business Flow
94285 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
94286 -- Prior Entry. Currently, the following code is always generated.
94287 ------------------------------------------------------------------------------------------------
94288 XLA_AE_LINES_PKG.ValidateCurrentLine;
94289
94290 ------------------------------------------------------------------------------------
94291 -- 4219869 Business Flow
94292 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
94293 ------------------------------------------------------------------------------------
94294 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
94295
94296 ----------------------------------------------------------------------------------
94297 -- 4219869 Business Flow
94298 -- Update journal entry status -- Need to generate this within IF <condition>
94299 ----------------------------------------------------------------------------------
94300 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
94301 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
94302 ,p_balance_type_code => l_balance_type_code
94303 );
94304
94305 -------------------------------------------------------------------------------------------
94306 -- 4262811 - Generate the Accrual Reversal lines
94307 -------------------------------------------------------------------------------------------
94308 BEGIN
94309 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
94310 (g_array_event(p_event_id).array_value_num('header_index'));
94311 IF l_acc_rev_flag IS NULL THEN
94312 l_acc_rev_flag := 'N';
94313 END IF;
94314 EXCEPTION
94315 WHEN OTHERS THEN
94316 l_acc_rev_flag := 'N';
94317 END;
94318 --
94319 IF (l_acc_rev_flag = 'Y') THEN
94320
94321 -- 4645092 ------------------------------------------------------------------------------
94322 -- To allow MPA report to determine if it should generate report process
94323 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
94324 ------------------------------------------------------------------------------------------
94325
94326 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
94327 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
94328 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
94329 -- call ADRs
94330 -- Bug 4922099
94331 --
94332 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
94333 (NVL(l_actual_upg_option, 'N') = 'O') OR
94334 (NVL(l_enc_upg_option, 'N') = 'O')
94335 )
94336 THEN
94337 NULL;
94338 --
94339 --
94340
94341 l_ccid := AcctDerRule_33(
94342 p_application_id => p_application_id
94343 , p_ae_header_id => l_ae_header_id
94344 , p_source_59 => p_source_59
94345 , x_transaction_coa_id => l_adr_transaction_coa_id
94346 , x_accounting_coa_id => l_adr_accounting_coa_id
94347 , x_value_type_code => l_adr_value_type_code
94348 , p_side => 'NA'
94349 );
94350
94351 xla_ae_lines_pkg.set_ccid(
94352 p_code_combination_id => l_ccid
94353 , p_value_type_code => l_adr_value_type_code
94354 , p_transaction_coa_id => l_adr_transaction_coa_id
94355 , p_accounting_coa_id => l_adr_accounting_coa_id
94356 , p_adr_code => 'PI_RECEIVABLES'
94357 , p_adr_type_code => 'S'
94358 , p_component_type => l_component_type
94359 , p_component_code => l_component_code
94360 , p_component_type_code => l_component_type_code
94361 , p_component_appl_id => l_component_appl_id
94362 , p_amb_context_code => l_amb_context_code
94363 , p_side => 'NA'
94364 );
94365
94366
94367 --
94368 --
94369 END IF;
94370
94371 --
94372 -- Update the line information that should be overwritten
94373 --
94374 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
94375 p_header_num => 1);
94376 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
94377
94378 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
94379
94380 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
94381 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
94382 END IF;
94383
94384 --
94385 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
94386 --
94387 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
94388 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
94389 ELSE
94390 ---------------------------------------------------------------------------------------------------
94391 -- 4262811a Switch Sign
94392 ---------------------------------------------------------------------------------------------------
94393 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
94394 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
94395 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94396 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
94397 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94398 -- 5132302
94399 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
94400 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94401
94402 END IF;
94403
94404 -- 4955764
94405 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
94406 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
94407
94408
94409 XLA_AE_LINES_PKG.ValidateCurrentLine;
94410 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
94411
94412 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
94413 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
94414 ,p_balance_type_code => l_balance_type_code);
94415
94416 END IF;
94417
94418 -----------------------------------------------------------------------------------------
94419 -- 4262811 Multiperiod Accounting
94420 -----------------------------------------------------------------------------------------
94421 -- No MPA option is assigned.
94422
94423
94424 END IF;
94425 END IF;
94426 --
94427
94428 --
94429 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
94430 trace
94431 (p_msg => 'END of AcctLineType_189'
94432 ,p_level => C_LEVEL_PROCEDURE
94433 ,p_module => l_log_module);
94434 END IF;
94435 --
94436 EXCEPTION
94437 WHEN xla_exceptions_pkg.application_exception THEN
94438 RAISE;
94439 WHEN OTHERS THEN
94440 xla_exceptions_pkg.raise_message
94441 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_189');
94442 END AcctLineType_189;
94443 --
94444
94445 ---------------------------------------
94446 --
94447 -- PRIVATE FUNCTION
94448 -- AcctLineType_190
94449 --
94450 ---------------------------------------
94451 PROCEDURE AcctLineType_190 (
94452 p_application_id IN NUMBER
94453 ,p_event_id IN NUMBER
94454 ,p_calculate_acctd_flag IN VARCHAR2
94455 ,p_calculate_g_l_flag IN VARCHAR2
94456 ,p_actual_flag IN OUT VARCHAR2
94457 ,p_balance_type_code OUT VARCHAR2
94458 ,p_gain_or_loss_ref OUT VARCHAR2
94459
94460 --TRANSACTION_ID
94461 , p_source_1 IN NUMBER
94462 --Item Concatenated Segments
94463 , p_source_2 IN VARCHAR2
94464 --Transaction Quantity
94465 , p_source_3 IN NUMBER
94466 --Transaction Unit of Measure Code
94467 , p_source_4 IN VARCHAR2
94468 --Inventory Transaction Type Description
94469 , p_source_5 IN VARCHAR2
94470 --Interorg Receivables Account
94471 , p_source_59 IN NUMBER
94472 --DISTRIBUTION_IDENTIFIER
94473 , p_source_84 IN NUMBER
94474 --Distribution Type
94475 , p_source_85 IN VARCHAR2
94476 , p_source_85_meaning IN VARCHAR2
94477 --Entered Currency Code
94478 , p_source_88 IN VARCHAR2
94479 --Entered Amount
94480 , p_source_91 IN NUMBER
94481 --Currency Conversion Date
94482 , p_source_92 IN DATE
94483 --Currency Conversion Rate
94484 , p_source_93 IN NUMBER
94485 --Currency Conversion Type
94486 , p_source_94 IN VARCHAR2
94487 --Accounted Amount
94488 , p_source_95 IN NUMBER
94489 --Accounting Line Type
94490 , p_source_97 IN NUMBER
94491 )
94492 IS
94493
94494 l_component_type VARCHAR2(80);
94495 l_component_code VARCHAR2(30);
94496 l_component_type_code VARCHAR2(1);
94497 l_component_appl_id INTEGER;
94498 l_amb_context_code VARCHAR2(30);
94499 l_entity_code VARCHAR2(30);
94500 l_event_class_code VARCHAR2(30);
94501 l_ae_header_id NUMBER;
94502 l_event_type_code VARCHAR2(30);
94503 l_line_definition_code VARCHAR2(30);
94504 l_line_definition_owner_code VARCHAR2(1);
94505 --
94506 -- adr variables
94507 l_segment VARCHAR2(30);
94508 l_ccid NUMBER;
94509 l_adr_transaction_coa_id NUMBER;
94510 l_adr_accounting_coa_id NUMBER;
94511 l_adr_flexfield_segment_code VARCHAR2(30);
94512 l_adr_flex_value_set_id NUMBER;
94513 l_adr_value_type_code VARCHAR2(30);
94514 l_adr_value_combination_id NUMBER;
94515 l_adr_value_segment_code VARCHAR2(30);
94516
94517 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
94518 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
94519 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
94520 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
94521
94522 -- 4262811 Variables ------------------------------------------------------------------------------------------
94523 l_entered_amt_idx NUMBER;
94524 l_accted_amt_idx NUMBER;
94525 l_acc_rev_flag VARCHAR2(1);
94526 l_accrual_line_num NUMBER;
94527 l_tmp_amt NUMBER;
94528 l_acc_rev_natural_side_code VARCHAR2(1);
94529
94530 l_num_entries NUMBER;
94531 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
94532 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
94533 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
94534 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
94535 l_recog_line_1 NUMBER;
94536 l_recog_line_2 NUMBER;
94537
94538 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
94539 l_bflow_applied_to_amt NUMBER; -- 5132302
94540 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
94541
94542 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
94543
94544 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
94545 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
94546
94547 ---------------------------------------------------------------------------------------------------------------
94548
94549
94550 --
94551 -- bulk performance
94552 --
94553 l_balance_type_code VARCHAR2(1);
94554 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
94555 l_log_module VARCHAR2(240);
94556
94557 --
94558 -- Upgrade strategy
94559 --
94560 l_actual_upg_option VARCHAR2(1);
94561 l_enc_upg_option VARCHAR2(1);
94562
94563 --
94564 BEGIN
94565 --
94566 IF g_log_enabled THEN
94567 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_190';
94568 END IF;
94569 --
94570 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
94571
94572 trace
94573 (p_msg => 'BEGIN of AcctLineType_190'
94574 ,p_level => C_LEVEL_PROCEDURE
94575 ,p_module => l_log_module);
94576
94577 END IF;
94578 --
94579 l_component_type := 'AMB_JLT';
94580 l_component_code := 'INTERORG_RECEIVABLES';
94581 l_component_type_code := 'S';
94582 l_component_appl_id := 707;
94583 l_amb_context_code := 'DEFAULT';
94584 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
94585 l_event_class_code := 'INT_ORDER_TO_EXP';
94586 l_event_type_code := 'INT_ORDER_ISSUE_NO_TP';
94587 l_line_definition_owner_code := 'S';
94588 l_line_definition_code := 'PI_INT_ORDER_ISSUE_NO_TP';
94589 --
94590 l_balance_type_code := 'A';
94591 l_segment := NULL;
94592 l_ccid := NULL;
94593 l_adr_transaction_coa_id := NULL;
94594 l_adr_accounting_coa_id := NULL;
94595 l_adr_flexfield_segment_code := NULL;
94596 l_adr_flex_value_set_id := NULL;
94597 l_adr_value_type_code := NULL;
94598 l_adr_value_combination_id := NULL;
94599 l_adr_value_segment_code := NULL;
94600
94601 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
94602 l_bflow_class_code := ''; -- 4219869 Business Flow
94603 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
94604 l_budgetary_control_flag := 'N';
94605
94606 l_bflow_applied_to_amt_idx := NULL; -- 5132302
94607 l_bflow_applied_to_amt := NULL; -- 5132302
94608 l_entered_amt_idx := NULL; -- 4262811
94609 l_accted_amt_idx := NULL; -- 4262811
94610 l_acc_rev_flag := NULL; -- 4262811
94611 l_accrual_line_num := NULL; -- 4262811
94612 l_tmp_amt := NULL; -- 4262811
94613 --
94614
94615 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
94616 l_balance_type_code <> 'B' THEN
94617 IF NVL(p_source_97,9E125) = 10
94618 THEN
94619
94620 --
94621 XLA_AE_LINES_PKG.SetNewLine;
94622
94623 p_balance_type_code := l_balance_type_code;
94624 -- set the flag so later we will know whether the gain loss line needs to be created
94625
94626 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
94627 p_actual_flag :='A';
94628 END IF;
94629
94630 --
94631 -- bulk performance
94632 --
94633 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
94634 p_header_num => 0); -- 4262811
94635 --
94636 -- set accounting line options
94637 --
94638 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
94639 p_natural_side_code => 'D'
94640 , p_gain_or_loss_flag => 'N'
94641 , p_gl_transfer_mode_code => 'S'
94642 , p_acct_entry_type_code => 'A'
94643 , p_switch_side_flag => 'Y'
94644 , p_merge_duplicate_code => 'N'
94645 );
94646 --
94647 l_acc_rev_natural_side_code := 'C'; -- 4262811
94648 --
94649 --
94650 -- set accounting line type info
94651 --
94652 xla_ae_lines_pkg.SetAcctLineType
94653 (p_component_type => l_component_type
94654 ,p_event_type_code => l_event_type_code
94655 ,p_line_definition_owner_code => l_line_definition_owner_code
94656 ,p_line_definition_code => l_line_definition_code
94657 ,p_accounting_line_code => l_component_code
94658 ,p_accounting_line_type_code => l_component_type_code
94659 ,p_accounting_line_appl_id => l_component_appl_id
94660 ,p_amb_context_code => l_amb_context_code
94661 ,p_entity_code => l_entity_code
94662 ,p_event_class_code => l_event_class_code);
94663 --
94664 -- set accounting class
94665 --
94666 xla_ae_lines_pkg.SetAcctClass(
94667 p_accounting_class_code => 'INTERORG_RECEIVABLES'
94668 , p_ae_header_id => l_ae_header_id
94669 );
94670
94671 --
94672 -- set rounding class
94673 --
94674 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
94675 'INTERORG_RECEIVABLES';
94676
94677 --
94678 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
94679 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
94680 --
94681 -- bulk performance
94682 --
94683 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
94684
94685 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
94686 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
94687
94688 -- 4955764
94689 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
94690 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
94691
94692 -- 4458381 Public Sector Enh
94693
94694 --
94695 -- set accounting attributes for the line type
94696 --
94697 l_entered_amt_idx := 3;
94698 l_accted_amt_idx := 8;
94699 l_bflow_applied_to_amt_idx := NULL; -- 5132302
94700 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
94701 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
94702 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
94703 l_rec_acct_attrs.array_char_value(2) := p_source_85;
94704 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
94705 l_rec_acct_attrs.array_num_value(3) := p_source_91;
94706 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
94707 l_rec_acct_attrs.array_char_value(4) := p_source_88;
94708 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
94709 l_rec_acct_attrs.array_date_value(5) := p_source_92;
94710 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
94711 l_rec_acct_attrs.array_num_value(6) := p_source_93;
94712 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
94713 l_rec_acct_attrs.array_char_value(7) := p_source_94;
94714 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
94715 l_rec_acct_attrs.array_num_value(8) := p_source_95;
94716
94717 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
94718 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
94719
94720 ---------------------------------------------------------------------------------------------------------------
94721 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
94722 ---------------------------------------------------------------------------------------------------------------
94723 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
94724
94725 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
94726 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
94727
94728 IF xla_accounting_cache_pkg.GetValueChar
94729 (p_source_code => 'LEDGER_CATEGORY_CODE'
94730 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
94731 AND l_bflow_method_code = 'PRIOR_ENTRY'
94732 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
94733 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
94734 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
94735 )
94736 THEN
94737 xla_ae_lines_pkg.BflowUpgEntry
94738 (p_business_method_code => l_bflow_method_code
94739 ,p_business_class_code => l_bflow_class_code
94740 ,p_balance_type => l_balance_type_code);
94741 ELSE
94742 NULL;
94743 -- No business flow processing for business flow method of NONE.
94744 END IF;
94745
94746 --
94747 -- call analytical criteria
94748 --
94749
94750 --
94751 -- call description
94752 --
94753
94754 xla_ae_lines_pkg.SetLineDescription(
94755 p_ae_header_id => l_ae_header_id
94756 ,p_description => Description_1 (
94757 p_application_id => p_application_id
94758 , p_ae_header_id => l_ae_header_id
94759 , p_source_1 => p_source_1
94760 , p_source_2 => p_source_2
94761 , p_source_3 => p_source_3
94762 , p_source_4 => p_source_4
94763 , p_source_5 => p_source_5
94764 )
94765 );
94766
94767
94768 --
94769 -- call ADRs
94770 -- Bug 4922099
94771 --
94772 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
94773 (NVL(l_actual_upg_option, 'N') = 'O') OR
94774 (NVL(l_enc_upg_option, 'N') = 'O')
94775 )
94776 THEN
94777 NULL;
94778 --
94779 --
94780
94781 l_ccid := AcctDerRule_33(
94782 p_application_id => p_application_id
94783 , p_ae_header_id => l_ae_header_id
94784 , p_source_59 => p_source_59
94785 , x_transaction_coa_id => l_adr_transaction_coa_id
94786 , x_accounting_coa_id => l_adr_accounting_coa_id
94787 , x_value_type_code => l_adr_value_type_code
94788 , p_side => 'NA'
94789 );
94790
94791 xla_ae_lines_pkg.set_ccid(
94792 p_code_combination_id => l_ccid
94793 , p_value_type_code => l_adr_value_type_code
94794 , p_transaction_coa_id => l_adr_transaction_coa_id
94795 , p_accounting_coa_id => l_adr_accounting_coa_id
94796 , p_adr_code => 'PI_RECEIVABLES'
94797 , p_adr_type_code => 'S'
94798 , p_component_type => l_component_type
94799 , p_component_code => l_component_code
94800 , p_component_type_code => l_component_type_code
94801 , p_component_appl_id => l_component_appl_id
94802 , p_amb_context_code => l_amb_context_code
94803 , p_side => 'NA'
94804 );
94805
94806
94807 --
94808 --
94809 END IF;
94810 --
94811 -- Bug 4922099
94812 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
94813 (NVL(l_enc_upg_option, 'N') = 'O')
94814 ) AND
94815 (l_bflow_method_code = 'PRIOR_ENTRY')
94816 )
94817 THEN
94818 IF
94819 --
94820 1 = 2
94821 --
94822 THEN
94823 xla_accounting_err_pkg.build_message
94824 (p_appli_s_name => 'XLA'
94825 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
94826 ,p_token_1 => 'LINE_NUMBER'
94827 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
94828 ,p_token_2 => 'LINE_TYPE_NAME'
94829 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
94830 l_component_type
94831 ,l_component_code
94832 ,l_component_type_code
94833 ,l_component_appl_id
94834 ,l_amb_context_code
94835 ,l_entity_code
94836 ,l_event_class_code
94837 )
94838 ,p_token_3 => 'OWNER'
94839 ,p_value_3 => xla_lookups_pkg.get_meaning(
94840 p_lookup_type => 'XLA_OWNER_TYPE'
94841 ,p_lookup_code => l_component_type_code
94842 )
94843 ,p_token_4 => 'PRODUCT_NAME'
94844 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
94845 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
94846 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
94847 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
94848 ,p_ae_header_id => NULL
94849 );
94850
94851 IF (C_LEVEL_ERROR>= g_log_level) THEN
94852 trace
94853 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
94854 ,p_level => C_LEVEL_ERROR
94855 ,p_module => l_log_module);
94856 END IF;
94857 END IF;
94858 END IF;
94859 --
94860 --
94861 ------------------------------------------------------------------------------------------------
94862 -- 4219869 Business Flow
94863 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
94864 -- Prior Entry. Currently, the following code is always generated.
94865 ------------------------------------------------------------------------------------------------
94866 XLA_AE_LINES_PKG.ValidateCurrentLine;
94867
94868 ------------------------------------------------------------------------------------
94869 -- 4219869 Business Flow
94870 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
94871 ------------------------------------------------------------------------------------
94872 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
94873
94874 ----------------------------------------------------------------------------------
94875 -- 4219869 Business Flow
94876 -- Update journal entry status -- Need to generate this within IF <condition>
94877 ----------------------------------------------------------------------------------
94878 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
94879 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
94880 ,p_balance_type_code => l_balance_type_code
94881 );
94882
94883 -------------------------------------------------------------------------------------------
94884 -- 4262811 - Generate the Accrual Reversal lines
94885 -------------------------------------------------------------------------------------------
94886 BEGIN
94887 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
94888 (g_array_event(p_event_id).array_value_num('header_index'));
94889 IF l_acc_rev_flag IS NULL THEN
94890 l_acc_rev_flag := 'N';
94891 END IF;
94892 EXCEPTION
94893 WHEN OTHERS THEN
94894 l_acc_rev_flag := 'N';
94895 END;
94896 --
94897 IF (l_acc_rev_flag = 'Y') THEN
94898
94899 -- 4645092 ------------------------------------------------------------------------------
94900 -- To allow MPA report to determine if it should generate report process
94901 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
94902 ------------------------------------------------------------------------------------------
94903
94904 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
94905 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
94906 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
94907 -- call ADRs
94908 -- Bug 4922099
94909 --
94910 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
94911 (NVL(l_actual_upg_option, 'N') = 'O') OR
94912 (NVL(l_enc_upg_option, 'N') = 'O')
94913 )
94914 THEN
94915 NULL;
94916 --
94917 --
94918
94919 l_ccid := AcctDerRule_33(
94920 p_application_id => p_application_id
94921 , p_ae_header_id => l_ae_header_id
94922 , p_source_59 => p_source_59
94923 , x_transaction_coa_id => l_adr_transaction_coa_id
94924 , x_accounting_coa_id => l_adr_accounting_coa_id
94925 , x_value_type_code => l_adr_value_type_code
94926 , p_side => 'NA'
94927 );
94928
94929 xla_ae_lines_pkg.set_ccid(
94930 p_code_combination_id => l_ccid
94931 , p_value_type_code => l_adr_value_type_code
94932 , p_transaction_coa_id => l_adr_transaction_coa_id
94933 , p_accounting_coa_id => l_adr_accounting_coa_id
94934 , p_adr_code => 'PI_RECEIVABLES'
94935 , p_adr_type_code => 'S'
94936 , p_component_type => l_component_type
94937 , p_component_code => l_component_code
94938 , p_component_type_code => l_component_type_code
94939 , p_component_appl_id => l_component_appl_id
94940 , p_amb_context_code => l_amb_context_code
94941 , p_side => 'NA'
94942 );
94943
94944
94945 --
94946 --
94947 END IF;
94948
94949 --
94950 -- Update the line information that should be overwritten
94951 --
94952 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
94953 p_header_num => 1);
94954 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
94955
94956 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
94957
94958 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
94959 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
94960 END IF;
94961
94962 --
94963 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
94964 --
94965 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
94966 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
94967 ELSE
94968 ---------------------------------------------------------------------------------------------------
94969 -- 4262811a Switch Sign
94970 ---------------------------------------------------------------------------------------------------
94971 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
94972 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
94973 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94974 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
94975 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94976 -- 5132302
94977 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
94978 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
94979
94980 END IF;
94981
94982 -- 4955764
94983 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
94984 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
94985
94986
94987 XLA_AE_LINES_PKG.ValidateCurrentLine;
94988 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
94989
94990 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
94991 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
94992 ,p_balance_type_code => l_balance_type_code);
94993
94994 END IF;
94995
94996 -----------------------------------------------------------------------------------------
94997 -- 4262811 Multiperiod Accounting
94998 -----------------------------------------------------------------------------------------
94999 -- No MPA option is assigned.
95000
95001
95002 END IF;
95003 END IF;
95004 --
95005
95006 --
95007 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
95008 trace
95009 (p_msg => 'END of AcctLineType_190'
95010 ,p_level => C_LEVEL_PROCEDURE
95011 ,p_module => l_log_module);
95012 END IF;
95013 --
95014 EXCEPTION
95015 WHEN xla_exceptions_pkg.application_exception THEN
95016 RAISE;
95017 WHEN OTHERS THEN
95018 xla_exceptions_pkg.raise_message
95019 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_190');
95020 END AcctLineType_190;
95021 --
95022
95023 ---------------------------------------
95024 --
95025 -- PRIVATE FUNCTION
95026 -- AcctLineType_191
95027 --
95028 ---------------------------------------
95029 PROCEDURE AcctLineType_191 (
95030 p_application_id IN NUMBER
95031 ,p_event_id IN NUMBER
95032 ,p_calculate_acctd_flag IN VARCHAR2
95033 ,p_calculate_g_l_flag IN VARCHAR2
95034 ,p_actual_flag IN OUT VARCHAR2
95035 ,p_balance_type_code OUT VARCHAR2
95036 ,p_gain_or_loss_ref OUT VARCHAR2
95037
95038 --TRANSACTION_ID
95039 , p_source_1 IN NUMBER
95040 --Item Concatenated Segments
95041 , p_source_2 IN VARCHAR2
95042 --Transaction Quantity
95043 , p_source_3 IN NUMBER
95044 --Transaction Unit of Measure Code
95045 , p_source_4 IN VARCHAR2
95046 --Inventory Transaction Type Description
95047 , p_source_5 IN VARCHAR2
95048 --Interorg Receivables Account
95049 , p_source_59 IN NUMBER
95050 --DISTRIBUTION_IDENTIFIER
95051 , p_source_84 IN NUMBER
95052 --Distribution Type
95053 , p_source_85 IN VARCHAR2
95054 , p_source_85_meaning IN VARCHAR2
95055 --Entered Currency Code
95056 , p_source_88 IN VARCHAR2
95057 --Entered Amount
95058 , p_source_91 IN NUMBER
95059 --Currency Conversion Date
95060 , p_source_92 IN DATE
95061 --Currency Conversion Rate
95062 , p_source_93 IN NUMBER
95063 --Currency Conversion Type
95064 , p_source_94 IN VARCHAR2
95065 --Accounted Amount
95066 , p_source_95 IN NUMBER
95067 --Accounting Line Type
95068 , p_source_97 IN NUMBER
95069 )
95070 IS
95071
95072 l_component_type VARCHAR2(80);
95073 l_component_code VARCHAR2(30);
95074 l_component_type_code VARCHAR2(1);
95075 l_component_appl_id INTEGER;
95076 l_amb_context_code VARCHAR2(30);
95077 l_entity_code VARCHAR2(30);
95078 l_event_class_code VARCHAR2(30);
95079 l_ae_header_id NUMBER;
95080 l_event_type_code VARCHAR2(30);
95081 l_line_definition_code VARCHAR2(30);
95082 l_line_definition_owner_code VARCHAR2(1);
95083 --
95084 -- adr variables
95085 l_segment VARCHAR2(30);
95086 l_ccid NUMBER;
95087 l_adr_transaction_coa_id NUMBER;
95088 l_adr_accounting_coa_id NUMBER;
95089 l_adr_flexfield_segment_code VARCHAR2(30);
95090 l_adr_flex_value_set_id NUMBER;
95091 l_adr_value_type_code VARCHAR2(30);
95092 l_adr_value_combination_id NUMBER;
95093 l_adr_value_segment_code VARCHAR2(30);
95094
95095 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
95096 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
95097 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
95098 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
95099
95100 -- 4262811 Variables ------------------------------------------------------------------------------------------
95101 l_entered_amt_idx NUMBER;
95102 l_accted_amt_idx NUMBER;
95103 l_acc_rev_flag VARCHAR2(1);
95104 l_accrual_line_num NUMBER;
95105 l_tmp_amt NUMBER;
95106 l_acc_rev_natural_side_code VARCHAR2(1);
95107
95108 l_num_entries NUMBER;
95109 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
95110 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
95111 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
95112 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
95113 l_recog_line_1 NUMBER;
95114 l_recog_line_2 NUMBER;
95115
95116 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
95117 l_bflow_applied_to_amt NUMBER; -- 5132302
95118 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
95119
95120 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
95121
95122 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
95123 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
95124
95125 ---------------------------------------------------------------------------------------------------------------
95126
95127
95128 --
95129 -- bulk performance
95130 --
95131 l_balance_type_code VARCHAR2(1);
95132 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
95133 l_log_module VARCHAR2(240);
95134
95135 --
95136 -- Upgrade strategy
95137 --
95138 l_actual_upg_option VARCHAR2(1);
95139 l_enc_upg_option VARCHAR2(1);
95140
95141 --
95142 BEGIN
95143 --
95144 IF g_log_enabled THEN
95145 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_191';
95146 END IF;
95147 --
95148 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
95149
95150 trace
95151 (p_msg => 'BEGIN of AcctLineType_191'
95152 ,p_level => C_LEVEL_PROCEDURE
95153 ,p_module => l_log_module);
95154
95155 END IF;
95156 --
95157 l_component_type := 'AMB_JLT';
95158 l_component_code := 'INTERORG_RECEIVABLES';
95159 l_component_type_code := 'S';
95160 l_component_appl_id := 707;
95161 l_amb_context_code := 'DEFAULT';
95162 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
95163 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
95164 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_TP';
95165 l_line_definition_owner_code := 'S';
95166 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_TP';
95167 --
95168 l_balance_type_code := 'A';
95169 l_segment := NULL;
95170 l_ccid := NULL;
95171 l_adr_transaction_coa_id := NULL;
95172 l_adr_accounting_coa_id := NULL;
95173 l_adr_flexfield_segment_code := NULL;
95174 l_adr_flex_value_set_id := NULL;
95175 l_adr_value_type_code := NULL;
95176 l_adr_value_combination_id := NULL;
95177 l_adr_value_segment_code := NULL;
95178
95179 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
95180 l_bflow_class_code := ''; -- 4219869 Business Flow
95181 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
95182 l_budgetary_control_flag := 'N';
95183
95184 l_bflow_applied_to_amt_idx := NULL; -- 5132302
95185 l_bflow_applied_to_amt := NULL; -- 5132302
95186 l_entered_amt_idx := NULL; -- 4262811
95187 l_accted_amt_idx := NULL; -- 4262811
95188 l_acc_rev_flag := NULL; -- 4262811
95189 l_accrual_line_num := NULL; -- 4262811
95190 l_tmp_amt := NULL; -- 4262811
95191 --
95192
95193 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
95194 l_balance_type_code <> 'B' THEN
95195 IF NVL(p_source_97,9E125) = 10
95196 THEN
95197
95198 --
95199 XLA_AE_LINES_PKG.SetNewLine;
95200
95201 p_balance_type_code := l_balance_type_code;
95202 -- set the flag so later we will know whether the gain loss line needs to be created
95203
95204 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
95205 p_actual_flag :='A';
95206 END IF;
95207
95208 --
95209 -- bulk performance
95210 --
95211 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
95212 p_header_num => 0); -- 4262811
95213 --
95214 -- set accounting line options
95215 --
95216 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
95217 p_natural_side_code => 'D'
95218 , p_gain_or_loss_flag => 'N'
95219 , p_gl_transfer_mode_code => 'S'
95220 , p_acct_entry_type_code => 'A'
95221 , p_switch_side_flag => 'Y'
95222 , p_merge_duplicate_code => 'N'
95223 );
95224 --
95225 l_acc_rev_natural_side_code := 'C'; -- 4262811
95226 --
95227 --
95228 -- set accounting line type info
95229 --
95230 xla_ae_lines_pkg.SetAcctLineType
95231 (p_component_type => l_component_type
95232 ,p_event_type_code => l_event_type_code
95233 ,p_line_definition_owner_code => l_line_definition_owner_code
95234 ,p_line_definition_code => l_line_definition_code
95235 ,p_accounting_line_code => l_component_code
95236 ,p_accounting_line_type_code => l_component_type_code
95237 ,p_accounting_line_appl_id => l_component_appl_id
95238 ,p_amb_context_code => l_amb_context_code
95239 ,p_entity_code => l_entity_code
95240 ,p_event_class_code => l_event_class_code);
95241 --
95242 -- set accounting class
95243 --
95244 xla_ae_lines_pkg.SetAcctClass(
95245 p_accounting_class_code => 'INTERORG_RECEIVABLES'
95246 , p_ae_header_id => l_ae_header_id
95247 );
95248
95249 --
95250 -- set rounding class
95251 --
95252 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
95253 'INTERORG_RECEIVABLES';
95254
95255 --
95256 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
95257 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
95258 --
95259 -- bulk performance
95260 --
95261 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
95262
95263 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
95264 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
95265
95266 -- 4955764
95267 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
95268 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
95269
95270 -- 4458381 Public Sector Enh
95271
95272 --
95273 -- set accounting attributes for the line type
95274 --
95275 l_entered_amt_idx := 3;
95276 l_accted_amt_idx := 8;
95277 l_bflow_applied_to_amt_idx := NULL; -- 5132302
95278 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
95279 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
95280 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
95281 l_rec_acct_attrs.array_char_value(2) := p_source_85;
95282 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
95283 l_rec_acct_attrs.array_num_value(3) := p_source_91;
95284 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
95285 l_rec_acct_attrs.array_char_value(4) := p_source_88;
95286 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
95287 l_rec_acct_attrs.array_date_value(5) := p_source_92;
95288 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
95289 l_rec_acct_attrs.array_num_value(6) := p_source_93;
95290 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
95291 l_rec_acct_attrs.array_char_value(7) := p_source_94;
95292 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
95293 l_rec_acct_attrs.array_num_value(8) := p_source_95;
95294
95295 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
95296 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
95297
95298 ---------------------------------------------------------------------------------------------------------------
95299 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
95300 ---------------------------------------------------------------------------------------------------------------
95301 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
95302
95303 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
95304 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
95305
95306 IF xla_accounting_cache_pkg.GetValueChar
95307 (p_source_code => 'LEDGER_CATEGORY_CODE'
95308 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
95309 AND l_bflow_method_code = 'PRIOR_ENTRY'
95310 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
95311 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
95312 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
95313 )
95314 THEN
95315 xla_ae_lines_pkg.BflowUpgEntry
95316 (p_business_method_code => l_bflow_method_code
95317 ,p_business_class_code => l_bflow_class_code
95318 ,p_balance_type => l_balance_type_code);
95319 ELSE
95320 NULL;
95321 -- No business flow processing for business flow method of NONE.
95322 END IF;
95323
95324 --
95325 -- call analytical criteria
95326 --
95327
95328 --
95329 -- call description
95330 --
95331
95332 xla_ae_lines_pkg.SetLineDescription(
95333 p_ae_header_id => l_ae_header_id
95334 ,p_description => Description_1 (
95335 p_application_id => p_application_id
95336 , p_ae_header_id => l_ae_header_id
95337 , p_source_1 => p_source_1
95338 , p_source_2 => p_source_2
95339 , p_source_3 => p_source_3
95340 , p_source_4 => p_source_4
95341 , p_source_5 => p_source_5
95342 )
95343 );
95344
95345
95346 --
95347 -- call ADRs
95348 -- Bug 4922099
95349 --
95350 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
95351 (NVL(l_actual_upg_option, 'N') = 'O') OR
95352 (NVL(l_enc_upg_option, 'N') = 'O')
95353 )
95354 THEN
95355 NULL;
95356 --
95357 --
95358
95359 l_ccid := AcctDerRule_33(
95360 p_application_id => p_application_id
95361 , p_ae_header_id => l_ae_header_id
95362 , p_source_59 => p_source_59
95363 , x_transaction_coa_id => l_adr_transaction_coa_id
95364 , x_accounting_coa_id => l_adr_accounting_coa_id
95365 , x_value_type_code => l_adr_value_type_code
95366 , p_side => 'NA'
95367 );
95368
95369 xla_ae_lines_pkg.set_ccid(
95370 p_code_combination_id => l_ccid
95371 , p_value_type_code => l_adr_value_type_code
95372 , p_transaction_coa_id => l_adr_transaction_coa_id
95373 , p_accounting_coa_id => l_adr_accounting_coa_id
95374 , p_adr_code => 'PI_RECEIVABLES'
95375 , p_adr_type_code => 'S'
95376 , p_component_type => l_component_type
95377 , p_component_code => l_component_code
95378 , p_component_type_code => l_component_type_code
95379 , p_component_appl_id => l_component_appl_id
95380 , p_amb_context_code => l_amb_context_code
95381 , p_side => 'NA'
95382 );
95383
95384
95385 --
95386 --
95387 END IF;
95388 --
95389 -- Bug 4922099
95390 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
95391 (NVL(l_enc_upg_option, 'N') = 'O')
95392 ) AND
95393 (l_bflow_method_code = 'PRIOR_ENTRY')
95394 )
95395 THEN
95396 IF
95397 --
95398 1 = 2
95399 --
95400 THEN
95401 xla_accounting_err_pkg.build_message
95402 (p_appli_s_name => 'XLA'
95403 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
95404 ,p_token_1 => 'LINE_NUMBER'
95405 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
95406 ,p_token_2 => 'LINE_TYPE_NAME'
95407 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
95408 l_component_type
95409 ,l_component_code
95410 ,l_component_type_code
95411 ,l_component_appl_id
95412 ,l_amb_context_code
95413 ,l_entity_code
95414 ,l_event_class_code
95415 )
95416 ,p_token_3 => 'OWNER'
95417 ,p_value_3 => xla_lookups_pkg.get_meaning(
95418 p_lookup_type => 'XLA_OWNER_TYPE'
95419 ,p_lookup_code => l_component_type_code
95420 )
95421 ,p_token_4 => 'PRODUCT_NAME'
95422 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
95423 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
95424 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
95425 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
95426 ,p_ae_header_id => NULL
95427 );
95428
95429 IF (C_LEVEL_ERROR>= g_log_level) THEN
95430 trace
95431 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
95432 ,p_level => C_LEVEL_ERROR
95433 ,p_module => l_log_module);
95434 END IF;
95435 END IF;
95436 END IF;
95437 --
95438 --
95439 ------------------------------------------------------------------------------------------------
95440 -- 4219869 Business Flow
95441 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
95442 -- Prior Entry. Currently, the following code is always generated.
95443 ------------------------------------------------------------------------------------------------
95444 XLA_AE_LINES_PKG.ValidateCurrentLine;
95445
95446 ------------------------------------------------------------------------------------
95447 -- 4219869 Business Flow
95448 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
95449 ------------------------------------------------------------------------------------
95450 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
95451
95452 ----------------------------------------------------------------------------------
95453 -- 4219869 Business Flow
95454 -- Update journal entry status -- Need to generate this within IF <condition>
95455 ----------------------------------------------------------------------------------
95456 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
95457 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
95458 ,p_balance_type_code => l_balance_type_code
95459 );
95460
95461 -------------------------------------------------------------------------------------------
95462 -- 4262811 - Generate the Accrual Reversal lines
95463 -------------------------------------------------------------------------------------------
95464 BEGIN
95465 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
95466 (g_array_event(p_event_id).array_value_num('header_index'));
95467 IF l_acc_rev_flag IS NULL THEN
95468 l_acc_rev_flag := 'N';
95469 END IF;
95470 EXCEPTION
95471 WHEN OTHERS THEN
95472 l_acc_rev_flag := 'N';
95473 END;
95474 --
95475 IF (l_acc_rev_flag = 'Y') THEN
95476
95477 -- 4645092 ------------------------------------------------------------------------------
95478 -- To allow MPA report to determine if it should generate report process
95479 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
95480 ------------------------------------------------------------------------------------------
95481
95482 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
95483 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
95484 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
95485 -- call ADRs
95486 -- Bug 4922099
95487 --
95488 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
95489 (NVL(l_actual_upg_option, 'N') = 'O') OR
95490 (NVL(l_enc_upg_option, 'N') = 'O')
95491 )
95492 THEN
95493 NULL;
95494 --
95495 --
95496
95497 l_ccid := AcctDerRule_33(
95498 p_application_id => p_application_id
95499 , p_ae_header_id => l_ae_header_id
95500 , p_source_59 => p_source_59
95501 , x_transaction_coa_id => l_adr_transaction_coa_id
95502 , x_accounting_coa_id => l_adr_accounting_coa_id
95503 , x_value_type_code => l_adr_value_type_code
95504 , p_side => 'NA'
95505 );
95506
95507 xla_ae_lines_pkg.set_ccid(
95508 p_code_combination_id => l_ccid
95509 , p_value_type_code => l_adr_value_type_code
95510 , p_transaction_coa_id => l_adr_transaction_coa_id
95511 , p_accounting_coa_id => l_adr_accounting_coa_id
95512 , p_adr_code => 'PI_RECEIVABLES'
95513 , p_adr_type_code => 'S'
95514 , p_component_type => l_component_type
95515 , p_component_code => l_component_code
95516 , p_component_type_code => l_component_type_code
95517 , p_component_appl_id => l_component_appl_id
95518 , p_amb_context_code => l_amb_context_code
95519 , p_side => 'NA'
95520 );
95521
95522
95523 --
95524 --
95525 END IF;
95526
95527 --
95528 -- Update the line information that should be overwritten
95529 --
95530 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
95531 p_header_num => 1);
95532 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
95533
95534 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
95535
95536 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
95537 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
95538 END IF;
95539
95540 --
95541 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
95542 --
95543 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
95544 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
95545 ELSE
95546 ---------------------------------------------------------------------------------------------------
95547 -- 4262811a Switch Sign
95548 ---------------------------------------------------------------------------------------------------
95549 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
95550 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
95551 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
95552 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
95553 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
95554 -- 5132302
95555 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
95556 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
95557
95558 END IF;
95559
95560 -- 4955764
95561 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
95562 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
95563
95564
95565 XLA_AE_LINES_PKG.ValidateCurrentLine;
95566 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
95567
95568 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
95569 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
95570 ,p_balance_type_code => l_balance_type_code);
95571
95572 END IF;
95573
95574 -----------------------------------------------------------------------------------------
95575 -- 4262811 Multiperiod Accounting
95576 -----------------------------------------------------------------------------------------
95577 -- No MPA option is assigned.
95578
95579
95580 END IF;
95581 END IF;
95582 --
95583
95584 --
95585 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
95586 trace
95587 (p_msg => 'END of AcctLineType_191'
95588 ,p_level => C_LEVEL_PROCEDURE
95589 ,p_module => l_log_module);
95590 END IF;
95591 --
95592 EXCEPTION
95593 WHEN xla_exceptions_pkg.application_exception THEN
95594 RAISE;
95595 WHEN OTHERS THEN
95596 xla_exceptions_pkg.raise_message
95597 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_191');
95598 END AcctLineType_191;
95599 --
95600
95601 ---------------------------------------
95602 --
95603 -- PRIVATE FUNCTION
95604 -- AcctLineType_192
95605 --
95606 ---------------------------------------
95607 PROCEDURE AcctLineType_192 (
95608 p_application_id IN NUMBER
95609 ,p_event_id IN NUMBER
95610 ,p_calculate_acctd_flag IN VARCHAR2
95611 ,p_calculate_g_l_flag IN VARCHAR2
95612 ,p_actual_flag IN OUT VARCHAR2
95613 ,p_balance_type_code OUT VARCHAR2
95614 ,p_gain_or_loss_ref OUT VARCHAR2
95615
95616 --Interorg Receivables Account
95617 , p_source_59 IN NUMBER
95618 --DISTRIBUTION_IDENTIFIER
95619 , p_source_84 IN NUMBER
95620 --Distribution Type
95621 , p_source_85 IN VARCHAR2
95622 , p_source_85_meaning IN VARCHAR2
95623 --Entered Currency Code
95624 , p_source_88 IN VARCHAR2
95625 --Entered Amount
95626 , p_source_91 IN NUMBER
95627 --Currency Conversion Date
95628 , p_source_92 IN DATE
95629 --Currency Conversion Rate
95630 , p_source_93 IN NUMBER
95631 --Currency Conversion Type
95632 , p_source_94 IN VARCHAR2
95633 --Accounted Amount
95634 , p_source_95 IN NUMBER
95635 --Accounting Line Type
95636 , p_source_97 IN NUMBER
95637 )
95638 IS
95639
95640 l_component_type VARCHAR2(80);
95641 l_component_code VARCHAR2(30);
95642 l_component_type_code VARCHAR2(1);
95643 l_component_appl_id INTEGER;
95644 l_amb_context_code VARCHAR2(30);
95645 l_entity_code VARCHAR2(30);
95646 l_event_class_code VARCHAR2(30);
95647 l_ae_header_id NUMBER;
95648 l_event_type_code VARCHAR2(30);
95649 l_line_definition_code VARCHAR2(30);
95650 l_line_definition_owner_code VARCHAR2(1);
95651 --
95652 -- adr variables
95653 l_segment VARCHAR2(30);
95654 l_ccid NUMBER;
95655 l_adr_transaction_coa_id NUMBER;
95656 l_adr_accounting_coa_id NUMBER;
95657 l_adr_flexfield_segment_code VARCHAR2(30);
95658 l_adr_flex_value_set_id NUMBER;
95659 l_adr_value_type_code VARCHAR2(30);
95660 l_adr_value_combination_id NUMBER;
95661 l_adr_value_segment_code VARCHAR2(30);
95662
95663 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
95664 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
95665 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
95666 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
95667
95668 -- 4262811 Variables ------------------------------------------------------------------------------------------
95669 l_entered_amt_idx NUMBER;
95670 l_accted_amt_idx NUMBER;
95671 l_acc_rev_flag VARCHAR2(1);
95672 l_accrual_line_num NUMBER;
95673 l_tmp_amt NUMBER;
95674 l_acc_rev_natural_side_code VARCHAR2(1);
95675
95676 l_num_entries NUMBER;
95677 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
95678 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
95679 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
95680 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
95681 l_recog_line_1 NUMBER;
95682 l_recog_line_2 NUMBER;
95683
95684 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
95685 l_bflow_applied_to_amt NUMBER; -- 5132302
95686 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
95687
95688 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
95689
95690 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
95691 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
95692
95693 ---------------------------------------------------------------------------------------------------------------
95694
95695
95696 --
95697 -- bulk performance
95698 --
95699 l_balance_type_code VARCHAR2(1);
95700 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
95701 l_log_module VARCHAR2(240);
95702
95703 --
95704 -- Upgrade strategy
95705 --
95706 l_actual_upg_option VARCHAR2(1);
95707 l_enc_upg_option VARCHAR2(1);
95708
95709 --
95710 BEGIN
95711 --
95712 IF g_log_enabled THEN
95713 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_192';
95714 END IF;
95715 --
95716 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
95717
95718 trace
95719 (p_msg => 'BEGIN of AcctLineType_192'
95720 ,p_level => C_LEVEL_PROCEDURE
95721 ,p_module => l_log_module);
95722
95723 END IF;
95724 --
95725 l_component_type := 'AMB_JLT';
95726 l_component_code := 'INTERORG_RECEIVABLES';
95727 l_component_type_code := 'S';
95728 l_component_appl_id := 707;
95729 l_amb_context_code := 'DEFAULT';
95730 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
95731 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
95732 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
95733 l_line_definition_owner_code := 'S';
95734 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
95735 --
95736 l_balance_type_code := 'A';
95737 l_segment := NULL;
95738 l_ccid := NULL;
95739 l_adr_transaction_coa_id := NULL;
95740 l_adr_accounting_coa_id := NULL;
95741 l_adr_flexfield_segment_code := NULL;
95742 l_adr_flex_value_set_id := NULL;
95743 l_adr_value_type_code := NULL;
95744 l_adr_value_combination_id := NULL;
95745 l_adr_value_segment_code := NULL;
95746
95747 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
95748 l_bflow_class_code := ''; -- 4219869 Business Flow
95749 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
95750 l_budgetary_control_flag := 'N';
95751
95752 l_bflow_applied_to_amt_idx := NULL; -- 5132302
95753 l_bflow_applied_to_amt := NULL; -- 5132302
95754 l_entered_amt_idx := NULL; -- 4262811
95755 l_accted_amt_idx := NULL; -- 4262811
95756 l_acc_rev_flag := NULL; -- 4262811
95757 l_accrual_line_num := NULL; -- 4262811
95758 l_tmp_amt := NULL; -- 4262811
95759 --
95760
95761 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
95762 l_balance_type_code <> 'B' THEN
95763 IF NVL(p_source_97,9E125) = 10
95764 THEN
95765
95766 --
95767 XLA_AE_LINES_PKG.SetNewLine;
95768
95769 p_balance_type_code := l_balance_type_code;
95770 -- set the flag so later we will know whether the gain loss line needs to be created
95771
95772 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
95773 p_actual_flag :='A';
95774 END IF;
95775
95776 --
95777 -- bulk performance
95778 --
95779 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
95780 p_header_num => 0); -- 4262811
95781 --
95782 -- set accounting line options
95783 --
95784 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
95785 p_natural_side_code => 'D'
95786 , p_gain_or_loss_flag => 'N'
95787 , p_gl_transfer_mode_code => 'S'
95788 , p_acct_entry_type_code => 'A'
95789 , p_switch_side_flag => 'Y'
95790 , p_merge_duplicate_code => 'N'
95791 );
95792 --
95793 l_acc_rev_natural_side_code := 'C'; -- 4262811
95794 --
95795 --
95796 -- set accounting line type info
95797 --
95798 xla_ae_lines_pkg.SetAcctLineType
95799 (p_component_type => l_component_type
95800 ,p_event_type_code => l_event_type_code
95801 ,p_line_definition_owner_code => l_line_definition_owner_code
95802 ,p_line_definition_code => l_line_definition_code
95803 ,p_accounting_line_code => l_component_code
95804 ,p_accounting_line_type_code => l_component_type_code
95805 ,p_accounting_line_appl_id => l_component_appl_id
95806 ,p_amb_context_code => l_amb_context_code
95807 ,p_entity_code => l_entity_code
95808 ,p_event_class_code => l_event_class_code);
95809 --
95810 -- set accounting class
95811 --
95812 xla_ae_lines_pkg.SetAcctClass(
95813 p_accounting_class_code => 'INTERORG_RECEIVABLES'
95814 , p_ae_header_id => l_ae_header_id
95815 );
95816
95817 --
95818 -- set rounding class
95819 --
95820 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
95821 'INTERORG_RECEIVABLES';
95822
95823 --
95824 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
95825 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
95826 --
95827 -- bulk performance
95828 --
95829 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
95830
95831 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
95832 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
95833
95834 -- 4955764
95835 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
95836 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
95837
95838 -- 4458381 Public Sector Enh
95839
95840 --
95841 -- set accounting attributes for the line type
95842 --
95843 l_entered_amt_idx := 3;
95844 l_accted_amt_idx := 8;
95845 l_bflow_applied_to_amt_idx := NULL; -- 5132302
95846 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
95847 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
95848 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
95849 l_rec_acct_attrs.array_char_value(2) := p_source_85;
95850 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
95851 l_rec_acct_attrs.array_num_value(3) := p_source_91;
95852 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
95853 l_rec_acct_attrs.array_char_value(4) := p_source_88;
95854 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
95855 l_rec_acct_attrs.array_date_value(5) := p_source_92;
95856 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
95857 l_rec_acct_attrs.array_num_value(6) := p_source_93;
95858 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
95859 l_rec_acct_attrs.array_char_value(7) := p_source_94;
95860 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
95861 l_rec_acct_attrs.array_num_value(8) := p_source_95;
95862
95863 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
95864 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
95865
95866 ---------------------------------------------------------------------------------------------------------------
95867 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
95868 ---------------------------------------------------------------------------------------------------------------
95869 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
95870
95871 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
95872 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
95873
95874 IF xla_accounting_cache_pkg.GetValueChar
95875 (p_source_code => 'LEDGER_CATEGORY_CODE'
95876 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
95877 AND l_bflow_method_code = 'PRIOR_ENTRY'
95878 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
95879 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
95880 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
95881 )
95882 THEN
95883 xla_ae_lines_pkg.BflowUpgEntry
95884 (p_business_method_code => l_bflow_method_code
95885 ,p_business_class_code => l_bflow_class_code
95886 ,p_balance_type => l_balance_type_code);
95887 ELSE
95888 NULL;
95889 -- No business flow processing for business flow method of NONE.
95890 END IF;
95891
95892 --
95893 -- call analytical criteria
95894 --
95895
95896 --
95897 -- call description
95898 --
95899 -- No description or it is inherited.
95900 --
95901 -- call ADRs
95902 -- Bug 4922099
95903 --
95904 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
95905 (NVL(l_actual_upg_option, 'N') = 'O') OR
95906 (NVL(l_enc_upg_option, 'N') = 'O')
95907 )
95908 THEN
95909 NULL;
95910 --
95911 --
95912
95913 l_ccid := AcctDerRule_33(
95914 p_application_id => p_application_id
95915 , p_ae_header_id => l_ae_header_id
95916 , p_source_59 => p_source_59
95917 , x_transaction_coa_id => l_adr_transaction_coa_id
95918 , x_accounting_coa_id => l_adr_accounting_coa_id
95919 , x_value_type_code => l_adr_value_type_code
95920 , p_side => 'NA'
95921 );
95922
95923 xla_ae_lines_pkg.set_ccid(
95924 p_code_combination_id => l_ccid
95925 , p_value_type_code => l_adr_value_type_code
95926 , p_transaction_coa_id => l_adr_transaction_coa_id
95927 , p_accounting_coa_id => l_adr_accounting_coa_id
95928 , p_adr_code => 'PI_RECEIVABLES'
95929 , p_adr_type_code => 'S'
95930 , p_component_type => l_component_type
95931 , p_component_code => l_component_code
95932 , p_component_type_code => l_component_type_code
95933 , p_component_appl_id => l_component_appl_id
95934 , p_amb_context_code => l_amb_context_code
95935 , p_side => 'NA'
95936 );
95937
95938
95939 --
95940 --
95941 END IF;
95942 --
95943 -- Bug 4922099
95944 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
95945 (NVL(l_enc_upg_option, 'N') = 'O')
95946 ) AND
95947 (l_bflow_method_code = 'PRIOR_ENTRY')
95948 )
95949 THEN
95950 IF
95951 --
95952 1 = 2
95953 --
95954 THEN
95955 xla_accounting_err_pkg.build_message
95956 (p_appli_s_name => 'XLA'
95957 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
95958 ,p_token_1 => 'LINE_NUMBER'
95959 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
95960 ,p_token_2 => 'LINE_TYPE_NAME'
95961 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
95962 l_component_type
95963 ,l_component_code
95964 ,l_component_type_code
95965 ,l_component_appl_id
95966 ,l_amb_context_code
95967 ,l_entity_code
95968 ,l_event_class_code
95969 )
95970 ,p_token_3 => 'OWNER'
95971 ,p_value_3 => xla_lookups_pkg.get_meaning(
95972 p_lookup_type => 'XLA_OWNER_TYPE'
95973 ,p_lookup_code => l_component_type_code
95974 )
95975 ,p_token_4 => 'PRODUCT_NAME'
95976 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
95977 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
95978 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
95979 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
95980 ,p_ae_header_id => NULL
95981 );
95982
95983 IF (C_LEVEL_ERROR>= g_log_level) THEN
95984 trace
95985 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
95986 ,p_level => C_LEVEL_ERROR
95987 ,p_module => l_log_module);
95988 END IF;
95989 END IF;
95990 END IF;
95991 --
95992 --
95993 ------------------------------------------------------------------------------------------------
95994 -- 4219869 Business Flow
95995 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
95996 -- Prior Entry. Currently, the following code is always generated.
95997 ------------------------------------------------------------------------------------------------
95998 XLA_AE_LINES_PKG.ValidateCurrentLine;
95999
96000 ------------------------------------------------------------------------------------
96001 -- 4219869 Business Flow
96002 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
96003 ------------------------------------------------------------------------------------
96004 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
96005
96006 ----------------------------------------------------------------------------------
96007 -- 4219869 Business Flow
96008 -- Update journal entry status -- Need to generate this within IF <condition>
96009 ----------------------------------------------------------------------------------
96010 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
96011 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
96012 ,p_balance_type_code => l_balance_type_code
96013 );
96014
96015 -------------------------------------------------------------------------------------------
96016 -- 4262811 - Generate the Accrual Reversal lines
96017 -------------------------------------------------------------------------------------------
96018 BEGIN
96019 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
96020 (g_array_event(p_event_id).array_value_num('header_index'));
96021 IF l_acc_rev_flag IS NULL THEN
96022 l_acc_rev_flag := 'N';
96023 END IF;
96024 EXCEPTION
96025 WHEN OTHERS THEN
96026 l_acc_rev_flag := 'N';
96027 END;
96028 --
96029 IF (l_acc_rev_flag = 'Y') THEN
96030
96031 -- 4645092 ------------------------------------------------------------------------------
96032 -- To allow MPA report to determine if it should generate report process
96033 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
96034 ------------------------------------------------------------------------------------------
96035
96036 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
96037 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
96038 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
96039 -- call ADRs
96040 -- Bug 4922099
96041 --
96042 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
96043 (NVL(l_actual_upg_option, 'N') = 'O') OR
96044 (NVL(l_enc_upg_option, 'N') = 'O')
96045 )
96046 THEN
96047 NULL;
96048 --
96049 --
96050
96051 l_ccid := AcctDerRule_33(
96052 p_application_id => p_application_id
96053 , p_ae_header_id => l_ae_header_id
96054 , p_source_59 => p_source_59
96055 , x_transaction_coa_id => l_adr_transaction_coa_id
96056 , x_accounting_coa_id => l_adr_accounting_coa_id
96057 , x_value_type_code => l_adr_value_type_code
96058 , p_side => 'NA'
96059 );
96060
96061 xla_ae_lines_pkg.set_ccid(
96062 p_code_combination_id => l_ccid
96063 , p_value_type_code => l_adr_value_type_code
96064 , p_transaction_coa_id => l_adr_transaction_coa_id
96065 , p_accounting_coa_id => l_adr_accounting_coa_id
96066 , p_adr_code => 'PI_RECEIVABLES'
96067 , p_adr_type_code => 'S'
96068 , p_component_type => l_component_type
96069 , p_component_code => l_component_code
96070 , p_component_type_code => l_component_type_code
96071 , p_component_appl_id => l_component_appl_id
96072 , p_amb_context_code => l_amb_context_code
96073 , p_side => 'NA'
96074 );
96075
96076
96077 --
96078 --
96079 END IF;
96080
96081 --
96082 -- Update the line information that should be overwritten
96083 --
96084 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
96085 p_header_num => 1);
96086 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
96087
96088 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
96089
96090 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
96091 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
96092 END IF;
96093
96094 --
96095 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
96096 --
96097 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
96098 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
96099 ELSE
96100 ---------------------------------------------------------------------------------------------------
96101 -- 4262811a Switch Sign
96102 ---------------------------------------------------------------------------------------------------
96103 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
96104 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
96105 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96106 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
96107 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96108 -- 5132302
96109 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
96110 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96111
96112 END IF;
96113
96114 -- 4955764
96115 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
96116 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
96117
96118
96119 XLA_AE_LINES_PKG.ValidateCurrentLine;
96120 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
96121
96122 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
96123 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
96124 ,p_balance_type_code => l_balance_type_code);
96125
96126 END IF;
96127
96128 -----------------------------------------------------------------------------------------
96129 -- 4262811 Multiperiod Accounting
96130 -----------------------------------------------------------------------------------------
96131 -- No MPA option is assigned.
96132
96133
96134 END IF;
96135 END IF;
96136 --
96137
96138 --
96139 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
96140 trace
96141 (p_msg => 'END of AcctLineType_192'
96142 ,p_level => C_LEVEL_PROCEDURE
96143 ,p_module => l_log_module);
96144 END IF;
96145 --
96146 EXCEPTION
96147 WHEN xla_exceptions_pkg.application_exception THEN
96148 RAISE;
96149 WHEN OTHERS THEN
96150 xla_exceptions_pkg.raise_message
96151 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_192');
96152 END AcctLineType_192;
96153 --
96154
96155 ---------------------------------------
96156 --
96157 -- PRIVATE FUNCTION
96158 -- AcctLineType_193
96159 --
96160 ---------------------------------------
96161 PROCEDURE AcctLineType_193 (
96162 p_application_id IN NUMBER
96163 ,p_event_id IN NUMBER
96164 ,p_calculate_acctd_flag IN VARCHAR2
96165 ,p_calculate_g_l_flag IN VARCHAR2
96166 ,p_actual_flag IN OUT VARCHAR2
96167 ,p_balance_type_code OUT VARCHAR2
96168 ,p_gain_or_loss_ref OUT VARCHAR2
96169
96170 --TRANSACTION_ID
96171 , p_source_1 IN NUMBER
96172 --Item Concatenated Segments
96173 , p_source_2 IN VARCHAR2
96174 --Transaction Quantity
96175 , p_source_3 IN NUMBER
96176 --Transaction Unit of Measure Code
96177 , p_source_4 IN VARCHAR2
96178 --Inventory Transaction Type Description
96179 , p_source_5 IN VARCHAR2
96180 --Interorg Receivables Account
96181 , p_source_59 IN NUMBER
96182 --DISTRIBUTION_IDENTIFIER
96183 , p_source_84 IN NUMBER
96184 --Distribution Type
96185 , p_source_85 IN VARCHAR2
96186 , p_source_85_meaning IN VARCHAR2
96187 --Entered Currency Code
96188 , p_source_88 IN VARCHAR2
96189 --Entered Amount
96190 , p_source_91 IN NUMBER
96191 --Currency Conversion Date
96192 , p_source_92 IN DATE
96193 --Currency Conversion Rate
96194 , p_source_93 IN NUMBER
96195 --Currency Conversion Type
96196 , p_source_94 IN VARCHAR2
96197 --Accounted Amount
96198 , p_source_95 IN NUMBER
96199 --Accounting Line Type
96200 , p_source_97 IN NUMBER
96201 )
96202 IS
96203
96204 l_component_type VARCHAR2(80);
96205 l_component_code VARCHAR2(30);
96206 l_component_type_code VARCHAR2(1);
96207 l_component_appl_id INTEGER;
96208 l_amb_context_code VARCHAR2(30);
96209 l_entity_code VARCHAR2(30);
96210 l_event_class_code VARCHAR2(30);
96211 l_ae_header_id NUMBER;
96212 l_event_type_code VARCHAR2(30);
96213 l_line_definition_code VARCHAR2(30);
96214 l_line_definition_owner_code VARCHAR2(1);
96215 --
96216 -- adr variables
96217 l_segment VARCHAR2(30);
96218 l_ccid NUMBER;
96219 l_adr_transaction_coa_id NUMBER;
96220 l_adr_accounting_coa_id NUMBER;
96221 l_adr_flexfield_segment_code VARCHAR2(30);
96222 l_adr_flex_value_set_id NUMBER;
96223 l_adr_value_type_code VARCHAR2(30);
96224 l_adr_value_combination_id NUMBER;
96225 l_adr_value_segment_code VARCHAR2(30);
96226
96227 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
96228 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
96229 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
96230 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
96231
96232 -- 4262811 Variables ------------------------------------------------------------------------------------------
96233 l_entered_amt_idx NUMBER;
96234 l_accted_amt_idx NUMBER;
96235 l_acc_rev_flag VARCHAR2(1);
96236 l_accrual_line_num NUMBER;
96237 l_tmp_amt NUMBER;
96238 l_acc_rev_natural_side_code VARCHAR2(1);
96239
96240 l_num_entries NUMBER;
96241 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
96242 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
96243 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
96244 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
96245 l_recog_line_1 NUMBER;
96246 l_recog_line_2 NUMBER;
96247
96248 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
96249 l_bflow_applied_to_amt NUMBER; -- 5132302
96250 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
96251
96252 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
96253
96254 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
96255 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
96256
96257 ---------------------------------------------------------------------------------------------------------------
96258
96259
96260 --
96261 -- bulk performance
96262 --
96263 l_balance_type_code VARCHAR2(1);
96264 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
96265 l_log_module VARCHAR2(240);
96266
96267 --
96268 -- Upgrade strategy
96269 --
96270 l_actual_upg_option VARCHAR2(1);
96271 l_enc_upg_option VARCHAR2(1);
96272
96273 --
96274 BEGIN
96275 --
96276 IF g_log_enabled THEN
96277 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_193';
96278 END IF;
96279 --
96280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
96281
96282 trace
96283 (p_msg => 'BEGIN of AcctLineType_193'
96284 ,p_level => C_LEVEL_PROCEDURE
96285 ,p_module => l_log_module);
96286
96287 END IF;
96288 --
96289 l_component_type := 'AMB_JLT';
96290 l_component_code := 'INTERORG_RECEIVABLES';
96291 l_component_type_code := 'S';
96292 l_component_appl_id := 707;
96293 l_amb_context_code := 'DEFAULT';
96294 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
96295 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
96296 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_TP';
96297 l_line_definition_owner_code := 'S';
96298 l_line_definition_code := 'PI_RCPT_SENDER_RCPT_TP';
96299 --
96300 l_balance_type_code := 'A';
96301 l_segment := NULL;
96302 l_ccid := NULL;
96303 l_adr_transaction_coa_id := NULL;
96304 l_adr_accounting_coa_id := NULL;
96305 l_adr_flexfield_segment_code := NULL;
96306 l_adr_flex_value_set_id := NULL;
96307 l_adr_value_type_code := NULL;
96308 l_adr_value_combination_id := NULL;
96309 l_adr_value_segment_code := NULL;
96310
96311 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
96312 l_bflow_class_code := ''; -- 4219869 Business Flow
96313 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
96314 l_budgetary_control_flag := 'N';
96315
96316 l_bflow_applied_to_amt_idx := NULL; -- 5132302
96317 l_bflow_applied_to_amt := NULL; -- 5132302
96318 l_entered_amt_idx := NULL; -- 4262811
96319 l_accted_amt_idx := NULL; -- 4262811
96320 l_acc_rev_flag := NULL; -- 4262811
96321 l_accrual_line_num := NULL; -- 4262811
96322 l_tmp_amt := NULL; -- 4262811
96323 --
96324
96325 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
96326 l_balance_type_code <> 'B' THEN
96327 IF NVL(p_source_97,9E125) = 10
96328 THEN
96329
96330 --
96331 XLA_AE_LINES_PKG.SetNewLine;
96332
96333 p_balance_type_code := l_balance_type_code;
96334 -- set the flag so later we will know whether the gain loss line needs to be created
96335
96336 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
96337 p_actual_flag :='A';
96338 END IF;
96339
96340 --
96341 -- bulk performance
96342 --
96343 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
96344 p_header_num => 0); -- 4262811
96345 --
96346 -- set accounting line options
96347 --
96348 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
96349 p_natural_side_code => 'D'
96350 , p_gain_or_loss_flag => 'N'
96351 , p_gl_transfer_mode_code => 'S'
96352 , p_acct_entry_type_code => 'A'
96353 , p_switch_side_flag => 'Y'
96354 , p_merge_duplicate_code => 'N'
96355 );
96356 --
96357 l_acc_rev_natural_side_code := 'C'; -- 4262811
96358 --
96359 --
96360 -- set accounting line type info
96361 --
96362 xla_ae_lines_pkg.SetAcctLineType
96363 (p_component_type => l_component_type
96364 ,p_event_type_code => l_event_type_code
96365 ,p_line_definition_owner_code => l_line_definition_owner_code
96366 ,p_line_definition_code => l_line_definition_code
96367 ,p_accounting_line_code => l_component_code
96368 ,p_accounting_line_type_code => l_component_type_code
96369 ,p_accounting_line_appl_id => l_component_appl_id
96370 ,p_amb_context_code => l_amb_context_code
96371 ,p_entity_code => l_entity_code
96372 ,p_event_class_code => l_event_class_code);
96373 --
96374 -- set accounting class
96375 --
96376 xla_ae_lines_pkg.SetAcctClass(
96377 p_accounting_class_code => 'INTERORG_RECEIVABLES'
96378 , p_ae_header_id => l_ae_header_id
96379 );
96380
96381 --
96382 -- set rounding class
96383 --
96384 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
96385 'INTERORG_RECEIVABLES';
96386
96387 --
96388 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
96389 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
96390 --
96391 -- bulk performance
96392 --
96393 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
96394
96395 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
96396 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
96397
96398 -- 4955764
96399 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
96400 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
96401
96402 -- 4458381 Public Sector Enh
96403
96404 --
96405 -- set accounting attributes for the line type
96406 --
96407 l_entered_amt_idx := 3;
96408 l_accted_amt_idx := 8;
96409 l_bflow_applied_to_amt_idx := NULL; -- 5132302
96410 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
96411 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
96412 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
96413 l_rec_acct_attrs.array_char_value(2) := p_source_85;
96414 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
96415 l_rec_acct_attrs.array_num_value(3) := p_source_91;
96416 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
96417 l_rec_acct_attrs.array_char_value(4) := p_source_88;
96418 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
96419 l_rec_acct_attrs.array_date_value(5) := p_source_92;
96420 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
96421 l_rec_acct_attrs.array_num_value(6) := p_source_93;
96422 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
96423 l_rec_acct_attrs.array_char_value(7) := p_source_94;
96424 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
96425 l_rec_acct_attrs.array_num_value(8) := p_source_95;
96426
96427 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
96428 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
96429
96430 ---------------------------------------------------------------------------------------------------------------
96431 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
96432 ---------------------------------------------------------------------------------------------------------------
96433 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
96434
96435 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
96436 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
96437
96438 IF xla_accounting_cache_pkg.GetValueChar
96439 (p_source_code => 'LEDGER_CATEGORY_CODE'
96440 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
96441 AND l_bflow_method_code = 'PRIOR_ENTRY'
96442 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
96443 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
96444 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
96445 )
96446 THEN
96447 xla_ae_lines_pkg.BflowUpgEntry
96448 (p_business_method_code => l_bflow_method_code
96449 ,p_business_class_code => l_bflow_class_code
96450 ,p_balance_type => l_balance_type_code);
96451 ELSE
96452 NULL;
96453 -- No business flow processing for business flow method of NONE.
96454 END IF;
96455
96456 --
96457 -- call analytical criteria
96458 --
96459
96460 --
96461 -- call description
96462 --
96463
96464 xla_ae_lines_pkg.SetLineDescription(
96465 p_ae_header_id => l_ae_header_id
96466 ,p_description => Description_1 (
96467 p_application_id => p_application_id
96468 , p_ae_header_id => l_ae_header_id
96469 , p_source_1 => p_source_1
96470 , p_source_2 => p_source_2
96471 , p_source_3 => p_source_3
96472 , p_source_4 => p_source_4
96473 , p_source_5 => p_source_5
96474 )
96475 );
96476
96477
96478 --
96479 -- call ADRs
96480 -- Bug 4922099
96481 --
96482 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
96483 (NVL(l_actual_upg_option, 'N') = 'O') OR
96484 (NVL(l_enc_upg_option, 'N') = 'O')
96485 )
96486 THEN
96487 NULL;
96488 --
96489 --
96490
96491 l_ccid := AcctDerRule_33(
96492 p_application_id => p_application_id
96493 , p_ae_header_id => l_ae_header_id
96494 , p_source_59 => p_source_59
96495 , x_transaction_coa_id => l_adr_transaction_coa_id
96496 , x_accounting_coa_id => l_adr_accounting_coa_id
96497 , x_value_type_code => l_adr_value_type_code
96498 , p_side => 'NA'
96499 );
96500
96501 xla_ae_lines_pkg.set_ccid(
96502 p_code_combination_id => l_ccid
96503 , p_value_type_code => l_adr_value_type_code
96504 , p_transaction_coa_id => l_adr_transaction_coa_id
96505 , p_accounting_coa_id => l_adr_accounting_coa_id
96506 , p_adr_code => 'PI_RECEIVABLES'
96507 , p_adr_type_code => 'S'
96508 , p_component_type => l_component_type
96509 , p_component_code => l_component_code
96510 , p_component_type_code => l_component_type_code
96511 , p_component_appl_id => l_component_appl_id
96512 , p_amb_context_code => l_amb_context_code
96513 , p_side => 'NA'
96514 );
96515
96516
96517 --
96518 --
96519 END IF;
96520 --
96521 -- Bug 4922099
96522 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
96523 (NVL(l_enc_upg_option, 'N') = 'O')
96524 ) AND
96525 (l_bflow_method_code = 'PRIOR_ENTRY')
96526 )
96527 THEN
96528 IF
96529 --
96530 1 = 2
96531 --
96532 THEN
96533 xla_accounting_err_pkg.build_message
96534 (p_appli_s_name => 'XLA'
96535 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
96536 ,p_token_1 => 'LINE_NUMBER'
96537 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
96538 ,p_token_2 => 'LINE_TYPE_NAME'
96539 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
96540 l_component_type
96541 ,l_component_code
96542 ,l_component_type_code
96543 ,l_component_appl_id
96544 ,l_amb_context_code
96545 ,l_entity_code
96546 ,l_event_class_code
96547 )
96548 ,p_token_3 => 'OWNER'
96549 ,p_value_3 => xla_lookups_pkg.get_meaning(
96550 p_lookup_type => 'XLA_OWNER_TYPE'
96551 ,p_lookup_code => l_component_type_code
96552 )
96553 ,p_token_4 => 'PRODUCT_NAME'
96554 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
96555 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
96556 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
96557 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
96558 ,p_ae_header_id => NULL
96559 );
96560
96561 IF (C_LEVEL_ERROR>= g_log_level) THEN
96562 trace
96563 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
96564 ,p_level => C_LEVEL_ERROR
96565 ,p_module => l_log_module);
96566 END IF;
96567 END IF;
96568 END IF;
96569 --
96570 --
96571 ------------------------------------------------------------------------------------------------
96572 -- 4219869 Business Flow
96573 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
96574 -- Prior Entry. Currently, the following code is always generated.
96575 ------------------------------------------------------------------------------------------------
96576 XLA_AE_LINES_PKG.ValidateCurrentLine;
96577
96578 ------------------------------------------------------------------------------------
96579 -- 4219869 Business Flow
96580 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
96581 ------------------------------------------------------------------------------------
96582 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
96583
96584 ----------------------------------------------------------------------------------
96585 -- 4219869 Business Flow
96586 -- Update journal entry status -- Need to generate this within IF <condition>
96587 ----------------------------------------------------------------------------------
96588 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
96589 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
96590 ,p_balance_type_code => l_balance_type_code
96591 );
96592
96593 -------------------------------------------------------------------------------------------
96594 -- 4262811 - Generate the Accrual Reversal lines
96595 -------------------------------------------------------------------------------------------
96596 BEGIN
96597 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
96598 (g_array_event(p_event_id).array_value_num('header_index'));
96599 IF l_acc_rev_flag IS NULL THEN
96600 l_acc_rev_flag := 'N';
96601 END IF;
96602 EXCEPTION
96603 WHEN OTHERS THEN
96604 l_acc_rev_flag := 'N';
96605 END;
96606 --
96607 IF (l_acc_rev_flag = 'Y') THEN
96608
96609 -- 4645092 ------------------------------------------------------------------------------
96610 -- To allow MPA report to determine if it should generate report process
96611 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
96612 ------------------------------------------------------------------------------------------
96613
96614 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
96615 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
96616 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
96617 -- call ADRs
96618 -- Bug 4922099
96619 --
96620 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
96621 (NVL(l_actual_upg_option, 'N') = 'O') OR
96622 (NVL(l_enc_upg_option, 'N') = 'O')
96623 )
96624 THEN
96625 NULL;
96626 --
96627 --
96628
96629 l_ccid := AcctDerRule_33(
96630 p_application_id => p_application_id
96631 , p_ae_header_id => l_ae_header_id
96632 , p_source_59 => p_source_59
96633 , x_transaction_coa_id => l_adr_transaction_coa_id
96634 , x_accounting_coa_id => l_adr_accounting_coa_id
96635 , x_value_type_code => l_adr_value_type_code
96636 , p_side => 'NA'
96637 );
96638
96639 xla_ae_lines_pkg.set_ccid(
96640 p_code_combination_id => l_ccid
96641 , p_value_type_code => l_adr_value_type_code
96642 , p_transaction_coa_id => l_adr_transaction_coa_id
96643 , p_accounting_coa_id => l_adr_accounting_coa_id
96644 , p_adr_code => 'PI_RECEIVABLES'
96645 , p_adr_type_code => 'S'
96646 , p_component_type => l_component_type
96647 , p_component_code => l_component_code
96648 , p_component_type_code => l_component_type_code
96649 , p_component_appl_id => l_component_appl_id
96650 , p_amb_context_code => l_amb_context_code
96651 , p_side => 'NA'
96652 );
96653
96654
96655 --
96656 --
96657 END IF;
96658
96659 --
96660 -- Update the line information that should be overwritten
96661 --
96662 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
96663 p_header_num => 1);
96664 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
96665
96666 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
96667
96668 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
96669 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
96670 END IF;
96671
96672 --
96673 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
96674 --
96675 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
96676 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
96677 ELSE
96678 ---------------------------------------------------------------------------------------------------
96679 -- 4262811a Switch Sign
96680 ---------------------------------------------------------------------------------------------------
96681 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
96682 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
96683 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96684 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
96685 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96686 -- 5132302
96687 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
96688 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
96689
96690 END IF;
96691
96692 -- 4955764
96693 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
96694 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
96695
96696
96697 XLA_AE_LINES_PKG.ValidateCurrentLine;
96698 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
96699
96700 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
96701 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
96702 ,p_balance_type_code => l_balance_type_code);
96703
96704 END IF;
96705
96706 -----------------------------------------------------------------------------------------
96707 -- 4262811 Multiperiod Accounting
96708 -----------------------------------------------------------------------------------------
96709 -- No MPA option is assigned.
96710
96711
96712 END IF;
96713 END IF;
96714 --
96715
96716 --
96717 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
96718 trace
96719 (p_msg => 'END of AcctLineType_193'
96720 ,p_level => C_LEVEL_PROCEDURE
96721 ,p_module => l_log_module);
96722 END IF;
96723 --
96724 EXCEPTION
96725 WHEN xla_exceptions_pkg.application_exception THEN
96726 RAISE;
96727 WHEN OTHERS THEN
96728 xla_exceptions_pkg.raise_message
96729 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_193');
96730 END AcctLineType_193;
96731 --
96732
96733 ---------------------------------------
96734 --
96735 -- PRIVATE FUNCTION
96736 -- AcctLineType_194
96737 --
96738 ---------------------------------------
96739 PROCEDURE AcctLineType_194 (
96740 p_application_id IN NUMBER
96741 ,p_event_id IN NUMBER
96742 ,p_calculate_acctd_flag IN VARCHAR2
96743 ,p_calculate_g_l_flag IN VARCHAR2
96744 ,p_actual_flag IN OUT VARCHAR2
96745 ,p_balance_type_code OUT VARCHAR2
96746 ,p_gain_or_loss_ref OUT VARCHAR2
96747
96748 --TRANSACTION_ID
96749 , p_source_1 IN NUMBER
96750 --Item Concatenated Segments
96751 , p_source_2 IN VARCHAR2
96752 --Transaction Quantity
96753 , p_source_3 IN NUMBER
96754 --Transaction Unit of Measure Code
96755 , p_source_4 IN VARCHAR2
96756 --Inventory Transaction Type Description
96757 , p_source_5 IN VARCHAR2
96758 --Interorg Receivables Account
96759 , p_source_59 IN NUMBER
96760 --DISTRIBUTION_IDENTIFIER
96761 , p_source_84 IN NUMBER
96762 --Distribution Type
96763 , p_source_85 IN VARCHAR2
96764 , p_source_85_meaning IN VARCHAR2
96765 --Entered Currency Code
96766 , p_source_88 IN VARCHAR2
96767 --Entered Amount
96768 , p_source_91 IN NUMBER
96769 --Currency Conversion Date
96770 , p_source_92 IN DATE
96771 --Currency Conversion Rate
96772 , p_source_93 IN NUMBER
96773 --Currency Conversion Type
96774 , p_source_94 IN VARCHAR2
96775 --Accounted Amount
96776 , p_source_95 IN NUMBER
96777 --Accounting Line Type
96778 , p_source_97 IN NUMBER
96779 )
96780 IS
96781
96782 l_component_type VARCHAR2(80);
96783 l_component_code VARCHAR2(30);
96784 l_component_type_code VARCHAR2(1);
96785 l_component_appl_id INTEGER;
96786 l_amb_context_code VARCHAR2(30);
96787 l_entity_code VARCHAR2(30);
96788 l_event_class_code VARCHAR2(30);
96789 l_ae_header_id NUMBER;
96790 l_event_type_code VARCHAR2(30);
96791 l_line_definition_code VARCHAR2(30);
96792 l_line_definition_owner_code VARCHAR2(1);
96793 --
96794 -- adr variables
96795 l_segment VARCHAR2(30);
96796 l_ccid NUMBER;
96797 l_adr_transaction_coa_id NUMBER;
96798 l_adr_accounting_coa_id NUMBER;
96799 l_adr_flexfield_segment_code VARCHAR2(30);
96800 l_adr_flex_value_set_id NUMBER;
96801 l_adr_value_type_code VARCHAR2(30);
96802 l_adr_value_combination_id NUMBER;
96803 l_adr_value_segment_code VARCHAR2(30);
96804
96805 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
96806 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
96807 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
96808 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
96809
96810 -- 4262811 Variables ------------------------------------------------------------------------------------------
96811 l_entered_amt_idx NUMBER;
96812 l_accted_amt_idx NUMBER;
96813 l_acc_rev_flag VARCHAR2(1);
96814 l_accrual_line_num NUMBER;
96815 l_tmp_amt NUMBER;
96816 l_acc_rev_natural_side_code VARCHAR2(1);
96817
96818 l_num_entries NUMBER;
96819 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
96820 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
96821 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
96822 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
96823 l_recog_line_1 NUMBER;
96824 l_recog_line_2 NUMBER;
96825
96826 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
96827 l_bflow_applied_to_amt NUMBER; -- 5132302
96828 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
96829
96830 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
96831
96832 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
96833 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
96834
96835 ---------------------------------------------------------------------------------------------------------------
96836
96837
96838 --
96839 -- bulk performance
96840 --
96841 l_balance_type_code VARCHAR2(1);
96842 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
96843 l_log_module VARCHAR2(240);
96844
96845 --
96846 -- Upgrade strategy
96847 --
96848 l_actual_upg_option VARCHAR2(1);
96849 l_enc_upg_option VARCHAR2(1);
96850
96851 --
96852 BEGIN
96853 --
96854 IF g_log_enabled THEN
96855 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_194';
96856 END IF;
96857 --
96858 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
96859
96860 trace
96861 (p_msg => 'BEGIN of AcctLineType_194'
96862 ,p_level => C_LEVEL_PROCEDURE
96863 ,p_module => l_log_module);
96864
96865 END IF;
96866 --
96867 l_component_type := 'AMB_JLT';
96868 l_component_code := 'INTERORG_RECEIVABLES';
96869 l_component_type_code := 'S';
96870 l_component_appl_id := 707;
96871 l_amb_context_code := 'DEFAULT';
96872 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
96873 l_event_class_code := 'USER_DEFINE';
96874 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
96875 l_line_definition_owner_code := 'S';
96876 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
96877 --
96878 l_balance_type_code := 'A';
96879 l_segment := NULL;
96880 l_ccid := NULL;
96881 l_adr_transaction_coa_id := NULL;
96882 l_adr_accounting_coa_id := NULL;
96883 l_adr_flexfield_segment_code := NULL;
96884 l_adr_flex_value_set_id := NULL;
96885 l_adr_value_type_code := NULL;
96886 l_adr_value_combination_id := NULL;
96887 l_adr_value_segment_code := NULL;
96888
96889 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
96890 l_bflow_class_code := ''; -- 4219869 Business Flow
96891 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
96892 l_budgetary_control_flag := 'N';
96893
96894 l_bflow_applied_to_amt_idx := NULL; -- 5132302
96895 l_bflow_applied_to_amt := NULL; -- 5132302
96896 l_entered_amt_idx := NULL; -- 4262811
96897 l_accted_amt_idx := NULL; -- 4262811
96898 l_acc_rev_flag := NULL; -- 4262811
96899 l_accrual_line_num := NULL; -- 4262811
96900 l_tmp_amt := NULL; -- 4262811
96901 --
96902
96903 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
96904 l_balance_type_code <> 'B' THEN
96905 IF NVL(p_source_97,9E125) = 10
96906 THEN
96907
96908 --
96909 XLA_AE_LINES_PKG.SetNewLine;
96910
96911 p_balance_type_code := l_balance_type_code;
96912 -- set the flag so later we will know whether the gain loss line needs to be created
96913
96914 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
96915 p_actual_flag :='A';
96916 END IF;
96917
96918 --
96919 -- bulk performance
96920 --
96921 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
96922 p_header_num => 0); -- 4262811
96923 --
96924 -- set accounting line options
96925 --
96926 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
96927 p_natural_side_code => 'D'
96928 , p_gain_or_loss_flag => 'N'
96929 , p_gl_transfer_mode_code => 'S'
96930 , p_acct_entry_type_code => 'A'
96931 , p_switch_side_flag => 'Y'
96932 , p_merge_duplicate_code => 'N'
96933 );
96934 --
96935 l_acc_rev_natural_side_code := 'C'; -- 4262811
96936 --
96937 --
96938 -- set accounting line type info
96939 --
96940 xla_ae_lines_pkg.SetAcctLineType
96941 (p_component_type => l_component_type
96942 ,p_event_type_code => l_event_type_code
96943 ,p_line_definition_owner_code => l_line_definition_owner_code
96944 ,p_line_definition_code => l_line_definition_code
96945 ,p_accounting_line_code => l_component_code
96946 ,p_accounting_line_type_code => l_component_type_code
96947 ,p_accounting_line_appl_id => l_component_appl_id
96948 ,p_amb_context_code => l_amb_context_code
96949 ,p_entity_code => l_entity_code
96950 ,p_event_class_code => l_event_class_code);
96951 --
96952 -- set accounting class
96953 --
96954 xla_ae_lines_pkg.SetAcctClass(
96955 p_accounting_class_code => 'INTERORG_RECEIVABLES'
96956 , p_ae_header_id => l_ae_header_id
96957 );
96958
96959 --
96960 -- set rounding class
96961 --
96962 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
96963 'INTERORG_RECEIVABLES';
96964
96965 --
96966 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
96967 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
96968 --
96969 -- bulk performance
96970 --
96971 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
96972
96973 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
96974 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
96975
96976 -- 4955764
96977 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
96978 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
96979
96980 -- 4458381 Public Sector Enh
96981
96982 --
96983 -- set accounting attributes for the line type
96984 --
96985 l_entered_amt_idx := 3;
96986 l_accted_amt_idx := 8;
96987 l_bflow_applied_to_amt_idx := NULL; -- 5132302
96988 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
96989 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
96990 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
96991 l_rec_acct_attrs.array_char_value(2) := p_source_85;
96992 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
96993 l_rec_acct_attrs.array_num_value(3) := p_source_91;
96994 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
96995 l_rec_acct_attrs.array_char_value(4) := p_source_88;
96996 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
96997 l_rec_acct_attrs.array_date_value(5) := p_source_92;
96998 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
96999 l_rec_acct_attrs.array_num_value(6) := p_source_93;
97000 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
97001 l_rec_acct_attrs.array_char_value(7) := p_source_94;
97002 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
97003 l_rec_acct_attrs.array_num_value(8) := p_source_95;
97004
97005 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
97006 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
97007
97008 ---------------------------------------------------------------------------------------------------------------
97009 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
97010 ---------------------------------------------------------------------------------------------------------------
97011 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
97012
97013 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
97014 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
97015
97016 IF xla_accounting_cache_pkg.GetValueChar
97017 (p_source_code => 'LEDGER_CATEGORY_CODE'
97018 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
97019 AND l_bflow_method_code = 'PRIOR_ENTRY'
97020 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
97021 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
97022 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
97023 )
97024 THEN
97025 xla_ae_lines_pkg.BflowUpgEntry
97026 (p_business_method_code => l_bflow_method_code
97027 ,p_business_class_code => l_bflow_class_code
97028 ,p_balance_type => l_balance_type_code);
97029 ELSE
97030 NULL;
97031 -- No business flow processing for business flow method of NONE.
97032 END IF;
97033
97034 --
97035 -- call analytical criteria
97036 --
97037
97038 --
97039 -- call description
97040 --
97041
97042 xla_ae_lines_pkg.SetLineDescription(
97043 p_ae_header_id => l_ae_header_id
97044 ,p_description => Description_1 (
97045 p_application_id => p_application_id
97046 , p_ae_header_id => l_ae_header_id
97047 , p_source_1 => p_source_1
97048 , p_source_2 => p_source_2
97049 , p_source_3 => p_source_3
97050 , p_source_4 => p_source_4
97051 , p_source_5 => p_source_5
97052 )
97053 );
97054
97055
97056 --
97057 -- call ADRs
97058 -- Bug 4922099
97059 --
97060 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
97061 (NVL(l_actual_upg_option, 'N') = 'O') OR
97062 (NVL(l_enc_upg_option, 'N') = 'O')
97063 )
97064 THEN
97065 NULL;
97066 --
97067 --
97068
97069 l_ccid := AcctDerRule_33(
97070 p_application_id => p_application_id
97071 , p_ae_header_id => l_ae_header_id
97072 , p_source_59 => p_source_59
97073 , x_transaction_coa_id => l_adr_transaction_coa_id
97074 , x_accounting_coa_id => l_adr_accounting_coa_id
97075 , x_value_type_code => l_adr_value_type_code
97076 , p_side => 'NA'
97077 );
97078
97079 xla_ae_lines_pkg.set_ccid(
97080 p_code_combination_id => l_ccid
97081 , p_value_type_code => l_adr_value_type_code
97082 , p_transaction_coa_id => l_adr_transaction_coa_id
97083 , p_accounting_coa_id => l_adr_accounting_coa_id
97084 , p_adr_code => 'PI_RECEIVABLES'
97085 , p_adr_type_code => 'S'
97086 , p_component_type => l_component_type
97087 , p_component_code => l_component_code
97088 , p_component_type_code => l_component_type_code
97089 , p_component_appl_id => l_component_appl_id
97090 , p_amb_context_code => l_amb_context_code
97091 , p_side => 'NA'
97092 );
97093
97094
97095 --
97096 --
97097 END IF;
97098 --
97099 -- Bug 4922099
97100 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
97101 (NVL(l_enc_upg_option, 'N') = 'O')
97102 ) AND
97103 (l_bflow_method_code = 'PRIOR_ENTRY')
97104 )
97105 THEN
97106 IF
97107 --
97108 1 = 2
97109 --
97110 THEN
97111 xla_accounting_err_pkg.build_message
97112 (p_appli_s_name => 'XLA'
97113 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
97114 ,p_token_1 => 'LINE_NUMBER'
97115 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
97116 ,p_token_2 => 'LINE_TYPE_NAME'
97117 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
97118 l_component_type
97119 ,l_component_code
97120 ,l_component_type_code
97121 ,l_component_appl_id
97122 ,l_amb_context_code
97123 ,l_entity_code
97124 ,l_event_class_code
97125 )
97126 ,p_token_3 => 'OWNER'
97127 ,p_value_3 => xla_lookups_pkg.get_meaning(
97128 p_lookup_type => 'XLA_OWNER_TYPE'
97129 ,p_lookup_code => l_component_type_code
97130 )
97131 ,p_token_4 => 'PRODUCT_NAME'
97132 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
97133 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
97134 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
97135 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
97136 ,p_ae_header_id => NULL
97137 );
97138
97139 IF (C_LEVEL_ERROR>= g_log_level) THEN
97140 trace
97141 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
97142 ,p_level => C_LEVEL_ERROR
97143 ,p_module => l_log_module);
97144 END IF;
97145 END IF;
97146 END IF;
97147 --
97148 --
97149 ------------------------------------------------------------------------------------------------
97150 -- 4219869 Business Flow
97151 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
97152 -- Prior Entry. Currently, the following code is always generated.
97153 ------------------------------------------------------------------------------------------------
97154 XLA_AE_LINES_PKG.ValidateCurrentLine;
97155
97156 ------------------------------------------------------------------------------------
97157 -- 4219869 Business Flow
97158 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
97159 ------------------------------------------------------------------------------------
97160 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
97161
97162 ----------------------------------------------------------------------------------
97163 -- 4219869 Business Flow
97164 -- Update journal entry status -- Need to generate this within IF <condition>
97165 ----------------------------------------------------------------------------------
97166 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
97167 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
97168 ,p_balance_type_code => l_balance_type_code
97169 );
97170
97171 -------------------------------------------------------------------------------------------
97172 -- 4262811 - Generate the Accrual Reversal lines
97173 -------------------------------------------------------------------------------------------
97174 BEGIN
97175 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
97176 (g_array_event(p_event_id).array_value_num('header_index'));
97177 IF l_acc_rev_flag IS NULL THEN
97178 l_acc_rev_flag := 'N';
97179 END IF;
97180 EXCEPTION
97181 WHEN OTHERS THEN
97182 l_acc_rev_flag := 'N';
97183 END;
97184 --
97185 IF (l_acc_rev_flag = 'Y') THEN
97186
97187 -- 4645092 ------------------------------------------------------------------------------
97188 -- To allow MPA report to determine if it should generate report process
97189 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
97190 ------------------------------------------------------------------------------------------
97191
97192 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
97193 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
97194 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
97195 -- call ADRs
97196 -- Bug 4922099
97197 --
97198 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
97199 (NVL(l_actual_upg_option, 'N') = 'O') OR
97200 (NVL(l_enc_upg_option, 'N') = 'O')
97201 )
97202 THEN
97203 NULL;
97204 --
97205 --
97206
97207 l_ccid := AcctDerRule_33(
97208 p_application_id => p_application_id
97209 , p_ae_header_id => l_ae_header_id
97210 , p_source_59 => p_source_59
97211 , x_transaction_coa_id => l_adr_transaction_coa_id
97212 , x_accounting_coa_id => l_adr_accounting_coa_id
97213 , x_value_type_code => l_adr_value_type_code
97214 , p_side => 'NA'
97215 );
97216
97217 xla_ae_lines_pkg.set_ccid(
97218 p_code_combination_id => l_ccid
97219 , p_value_type_code => l_adr_value_type_code
97220 , p_transaction_coa_id => l_adr_transaction_coa_id
97221 , p_accounting_coa_id => l_adr_accounting_coa_id
97222 , p_adr_code => 'PI_RECEIVABLES'
97223 , p_adr_type_code => 'S'
97224 , p_component_type => l_component_type
97225 , p_component_code => l_component_code
97226 , p_component_type_code => l_component_type_code
97227 , p_component_appl_id => l_component_appl_id
97228 , p_amb_context_code => l_amb_context_code
97229 , p_side => 'NA'
97230 );
97231
97232
97233 --
97234 --
97235 END IF;
97236
97237 --
97238 -- Update the line information that should be overwritten
97239 --
97240 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
97241 p_header_num => 1);
97242 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
97243
97244 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
97245
97246 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
97247 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
97248 END IF;
97249
97250 --
97251 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
97252 --
97253 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
97254 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
97255 ELSE
97256 ---------------------------------------------------------------------------------------------------
97257 -- 4262811a Switch Sign
97258 ---------------------------------------------------------------------------------------------------
97259 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
97260 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
97261 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97262 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
97263 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97264 -- 5132302
97265 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
97266 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97267
97268 END IF;
97269
97270 -- 4955764
97271 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
97272 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
97273
97274
97275 XLA_AE_LINES_PKG.ValidateCurrentLine;
97276 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
97277
97278 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
97279 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
97280 ,p_balance_type_code => l_balance_type_code);
97281
97282 END IF;
97283
97284 -----------------------------------------------------------------------------------------
97285 -- 4262811 Multiperiod Accounting
97286 -----------------------------------------------------------------------------------------
97287 -- No MPA option is assigned.
97288
97289
97290 END IF;
97291 END IF;
97292 --
97293
97294 --
97295 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
97296 trace
97297 (p_msg => 'END of AcctLineType_194'
97298 ,p_level => C_LEVEL_PROCEDURE
97299 ,p_module => l_log_module);
97300 END IF;
97301 --
97302 EXCEPTION
97303 WHEN xla_exceptions_pkg.application_exception THEN
97304 RAISE;
97305 WHEN OTHERS THEN
97306 xla_exceptions_pkg.raise_message
97307 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_194');
97308 END AcctLineType_194;
97309 --
97310
97311 ---------------------------------------
97312 --
97313 -- PRIVATE FUNCTION
97314 -- AcctLineType_195
97315 --
97316 ---------------------------------------
97317 PROCEDURE AcctLineType_195 (
97318 p_application_id IN NUMBER
97319 ,p_event_id IN NUMBER
97320 ,p_calculate_acctd_flag IN VARCHAR2
97321 ,p_calculate_g_l_flag IN VARCHAR2
97322 ,p_actual_flag IN OUT VARCHAR2
97323 ,p_balance_type_code OUT VARCHAR2
97324 ,p_gain_or_loss_ref OUT VARCHAR2
97325
97326 --Interorg Receivables Account
97327 , p_source_59 IN NUMBER
97328 --DISTRIBUTION_IDENTIFIER
97329 , p_source_84 IN NUMBER
97330 --Distribution Type
97331 , p_source_85 IN VARCHAR2
97332 , p_source_85_meaning IN VARCHAR2
97333 --Entered Currency Code
97334 , p_source_88 IN VARCHAR2
97335 --Entered Amount
97336 , p_source_91 IN NUMBER
97337 --Currency Conversion Date
97338 , p_source_92 IN DATE
97339 --Currency Conversion Rate
97340 , p_source_93 IN NUMBER
97341 --Currency Conversion Type
97342 , p_source_94 IN VARCHAR2
97343 --Accounted Amount
97344 , p_source_95 IN NUMBER
97345 --Accounting Line Type
97346 , p_source_97 IN NUMBER
97347 )
97348 IS
97349
97350 l_component_type VARCHAR2(80);
97351 l_component_code VARCHAR2(30);
97352 l_component_type_code VARCHAR2(1);
97353 l_component_appl_id INTEGER;
97354 l_amb_context_code VARCHAR2(30);
97355 l_entity_code VARCHAR2(30);
97356 l_event_class_code VARCHAR2(30);
97357 l_ae_header_id NUMBER;
97358 l_event_type_code VARCHAR2(30);
97359 l_line_definition_code VARCHAR2(30);
97360 l_line_definition_owner_code VARCHAR2(1);
97361 --
97362 -- adr variables
97363 l_segment VARCHAR2(30);
97364 l_ccid NUMBER;
97365 l_adr_transaction_coa_id NUMBER;
97366 l_adr_accounting_coa_id NUMBER;
97367 l_adr_flexfield_segment_code VARCHAR2(30);
97368 l_adr_flex_value_set_id NUMBER;
97369 l_adr_value_type_code VARCHAR2(30);
97370 l_adr_value_combination_id NUMBER;
97371 l_adr_value_segment_code VARCHAR2(30);
97372
97373 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
97374 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
97375 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
97376 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
97377
97378 -- 4262811 Variables ------------------------------------------------------------------------------------------
97379 l_entered_amt_idx NUMBER;
97380 l_accted_amt_idx NUMBER;
97381 l_acc_rev_flag VARCHAR2(1);
97382 l_accrual_line_num NUMBER;
97383 l_tmp_amt NUMBER;
97384 l_acc_rev_natural_side_code VARCHAR2(1);
97385
97386 l_num_entries NUMBER;
97387 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
97388 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
97389 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
97390 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
97391 l_recog_line_1 NUMBER;
97392 l_recog_line_2 NUMBER;
97393
97394 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
97395 l_bflow_applied_to_amt NUMBER; -- 5132302
97396 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
97397
97398 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
97399
97400 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
97401 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
97402
97403 ---------------------------------------------------------------------------------------------------------------
97404
97405
97406 --
97407 -- bulk performance
97408 --
97409 l_balance_type_code VARCHAR2(1);
97410 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
97411 l_log_module VARCHAR2(240);
97412
97413 --
97414 -- Upgrade strategy
97415 --
97416 l_actual_upg_option VARCHAR2(1);
97417 l_enc_upg_option VARCHAR2(1);
97418
97419 --
97420 BEGIN
97421 --
97422 IF g_log_enabled THEN
97423 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_195';
97424 END IF;
97425 --
97426 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
97427
97428 trace
97429 (p_msg => 'BEGIN of AcctLineType_195'
97430 ,p_level => C_LEVEL_PROCEDURE
97431 ,p_module => l_log_module);
97432
97433 END IF;
97434 --
97435 l_component_type := 'AMB_JLT';
97436 l_component_code := 'INTERORG_RECEIVABLES';
97437 l_component_type_code := 'S';
97438 l_component_appl_id := 707;
97439 l_amb_context_code := 'DEFAULT';
97440 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
97441 l_event_class_code := 'USER_DEFINE';
97442 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
97443 l_line_definition_owner_code := 'S';
97444 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
97445 --
97446 l_balance_type_code := 'A';
97447 l_segment := NULL;
97448 l_ccid := NULL;
97449 l_adr_transaction_coa_id := NULL;
97450 l_adr_accounting_coa_id := NULL;
97451 l_adr_flexfield_segment_code := NULL;
97452 l_adr_flex_value_set_id := NULL;
97453 l_adr_value_type_code := NULL;
97454 l_adr_value_combination_id := NULL;
97455 l_adr_value_segment_code := NULL;
97456
97457 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
97458 l_bflow_class_code := ''; -- 4219869 Business Flow
97459 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
97460 l_budgetary_control_flag := 'N';
97461
97462 l_bflow_applied_to_amt_idx := NULL; -- 5132302
97463 l_bflow_applied_to_amt := NULL; -- 5132302
97464 l_entered_amt_idx := NULL; -- 4262811
97465 l_accted_amt_idx := NULL; -- 4262811
97466 l_acc_rev_flag := NULL; -- 4262811
97467 l_accrual_line_num := NULL; -- 4262811
97468 l_tmp_amt := NULL; -- 4262811
97469 --
97470
97471 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
97472 l_balance_type_code <> 'B' THEN
97473 IF NVL(p_source_97,9E125) = 10
97474 THEN
97475
97476 --
97477 XLA_AE_LINES_PKG.SetNewLine;
97478
97479 p_balance_type_code := l_balance_type_code;
97480 -- set the flag so later we will know whether the gain loss line needs to be created
97481
97482 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
97483 p_actual_flag :='A';
97484 END IF;
97485
97486 --
97487 -- bulk performance
97488 --
97489 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
97490 p_header_num => 0); -- 4262811
97491 --
97492 -- set accounting line options
97493 --
97494 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
97495 p_natural_side_code => 'D'
97496 , p_gain_or_loss_flag => 'N'
97497 , p_gl_transfer_mode_code => 'S'
97498 , p_acct_entry_type_code => 'A'
97499 , p_switch_side_flag => 'Y'
97500 , p_merge_duplicate_code => 'N'
97501 );
97502 --
97503 l_acc_rev_natural_side_code := 'C'; -- 4262811
97504 --
97505 --
97506 -- set accounting line type info
97507 --
97508 xla_ae_lines_pkg.SetAcctLineType
97509 (p_component_type => l_component_type
97510 ,p_event_type_code => l_event_type_code
97511 ,p_line_definition_owner_code => l_line_definition_owner_code
97512 ,p_line_definition_code => l_line_definition_code
97513 ,p_accounting_line_code => l_component_code
97514 ,p_accounting_line_type_code => l_component_type_code
97515 ,p_accounting_line_appl_id => l_component_appl_id
97516 ,p_amb_context_code => l_amb_context_code
97517 ,p_entity_code => l_entity_code
97518 ,p_event_class_code => l_event_class_code);
97519 --
97520 -- set accounting class
97521 --
97522 xla_ae_lines_pkg.SetAcctClass(
97523 p_accounting_class_code => 'INTERORG_RECEIVABLES'
97524 , p_ae_header_id => l_ae_header_id
97525 );
97526
97527 --
97528 -- set rounding class
97529 --
97530 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
97531 'INTERORG_RECEIVABLES';
97532
97533 --
97534 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
97535 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
97536 --
97537 -- bulk performance
97538 --
97539 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
97540
97541 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
97542 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
97543
97544 -- 4955764
97545 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
97546 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
97547
97548 -- 4458381 Public Sector Enh
97549
97550 --
97551 -- set accounting attributes for the line type
97552 --
97553 l_entered_amt_idx := 3;
97554 l_accted_amt_idx := 8;
97555 l_bflow_applied_to_amt_idx := NULL; -- 5132302
97556 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
97557 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
97558 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
97559 l_rec_acct_attrs.array_char_value(2) := p_source_85;
97560 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
97561 l_rec_acct_attrs.array_num_value(3) := p_source_91;
97562 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
97563 l_rec_acct_attrs.array_char_value(4) := p_source_88;
97564 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
97565 l_rec_acct_attrs.array_date_value(5) := p_source_92;
97566 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
97567 l_rec_acct_attrs.array_num_value(6) := p_source_93;
97568 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
97569 l_rec_acct_attrs.array_char_value(7) := p_source_94;
97570 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
97571 l_rec_acct_attrs.array_num_value(8) := p_source_95;
97572
97573 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
97574 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
97575
97576 ---------------------------------------------------------------------------------------------------------------
97577 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
97578 ---------------------------------------------------------------------------------------------------------------
97579 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
97580
97581 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
97582 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
97583
97584 IF xla_accounting_cache_pkg.GetValueChar
97585 (p_source_code => 'LEDGER_CATEGORY_CODE'
97586 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
97587 AND l_bflow_method_code = 'PRIOR_ENTRY'
97588 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
97589 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
97590 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
97591 )
97592 THEN
97593 xla_ae_lines_pkg.BflowUpgEntry
97594 (p_business_method_code => l_bflow_method_code
97595 ,p_business_class_code => l_bflow_class_code
97596 ,p_balance_type => l_balance_type_code);
97597 ELSE
97598 NULL;
97599 -- No business flow processing for business flow method of NONE.
97600 END IF;
97601
97602 --
97603 -- call analytical criteria
97604 --
97605
97606 --
97607 -- call description
97608 --
97609 -- No description or it is inherited.
97610 --
97611 -- call ADRs
97612 -- Bug 4922099
97613 --
97614 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
97615 (NVL(l_actual_upg_option, 'N') = 'O') OR
97616 (NVL(l_enc_upg_option, 'N') = 'O')
97617 )
97618 THEN
97619 NULL;
97620 --
97621 --
97622
97623 l_ccid := AcctDerRule_33(
97624 p_application_id => p_application_id
97625 , p_ae_header_id => l_ae_header_id
97626 , p_source_59 => p_source_59
97627 , x_transaction_coa_id => l_adr_transaction_coa_id
97628 , x_accounting_coa_id => l_adr_accounting_coa_id
97629 , x_value_type_code => l_adr_value_type_code
97630 , p_side => 'NA'
97631 );
97632
97633 xla_ae_lines_pkg.set_ccid(
97634 p_code_combination_id => l_ccid
97635 , p_value_type_code => l_adr_value_type_code
97636 , p_transaction_coa_id => l_adr_transaction_coa_id
97637 , p_accounting_coa_id => l_adr_accounting_coa_id
97638 , p_adr_code => 'PI_RECEIVABLES'
97639 , p_adr_type_code => 'S'
97640 , p_component_type => l_component_type
97641 , p_component_code => l_component_code
97642 , p_component_type_code => l_component_type_code
97643 , p_component_appl_id => l_component_appl_id
97644 , p_amb_context_code => l_amb_context_code
97645 , p_side => 'NA'
97646 );
97647
97648
97649 --
97650 --
97651 END IF;
97652 --
97653 -- Bug 4922099
97654 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
97655 (NVL(l_enc_upg_option, 'N') = 'O')
97656 ) AND
97657 (l_bflow_method_code = 'PRIOR_ENTRY')
97658 )
97659 THEN
97660 IF
97661 --
97662 1 = 2
97663 --
97664 THEN
97665 xla_accounting_err_pkg.build_message
97666 (p_appli_s_name => 'XLA'
97667 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
97668 ,p_token_1 => 'LINE_NUMBER'
97669 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
97670 ,p_token_2 => 'LINE_TYPE_NAME'
97671 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
97672 l_component_type
97673 ,l_component_code
97674 ,l_component_type_code
97675 ,l_component_appl_id
97676 ,l_amb_context_code
97677 ,l_entity_code
97678 ,l_event_class_code
97679 )
97680 ,p_token_3 => 'OWNER'
97681 ,p_value_3 => xla_lookups_pkg.get_meaning(
97682 p_lookup_type => 'XLA_OWNER_TYPE'
97683 ,p_lookup_code => l_component_type_code
97684 )
97685 ,p_token_4 => 'PRODUCT_NAME'
97686 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
97687 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
97688 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
97689 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
97690 ,p_ae_header_id => NULL
97691 );
97692
97693 IF (C_LEVEL_ERROR>= g_log_level) THEN
97694 trace
97695 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
97696 ,p_level => C_LEVEL_ERROR
97697 ,p_module => l_log_module);
97698 END IF;
97699 END IF;
97700 END IF;
97701 --
97702 --
97703 ------------------------------------------------------------------------------------------------
97704 -- 4219869 Business Flow
97705 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
97706 -- Prior Entry. Currently, the following code is always generated.
97707 ------------------------------------------------------------------------------------------------
97708 XLA_AE_LINES_PKG.ValidateCurrentLine;
97709
97710 ------------------------------------------------------------------------------------
97711 -- 4219869 Business Flow
97712 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
97713 ------------------------------------------------------------------------------------
97714 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
97715
97716 ----------------------------------------------------------------------------------
97717 -- 4219869 Business Flow
97718 -- Update journal entry status -- Need to generate this within IF <condition>
97719 ----------------------------------------------------------------------------------
97720 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
97721 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
97722 ,p_balance_type_code => l_balance_type_code
97723 );
97724
97725 -------------------------------------------------------------------------------------------
97726 -- 4262811 - Generate the Accrual Reversal lines
97727 -------------------------------------------------------------------------------------------
97728 BEGIN
97729 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
97730 (g_array_event(p_event_id).array_value_num('header_index'));
97731 IF l_acc_rev_flag IS NULL THEN
97732 l_acc_rev_flag := 'N';
97733 END IF;
97734 EXCEPTION
97735 WHEN OTHERS THEN
97736 l_acc_rev_flag := 'N';
97737 END;
97738 --
97739 IF (l_acc_rev_flag = 'Y') THEN
97740
97741 -- 4645092 ------------------------------------------------------------------------------
97742 -- To allow MPA report to determine if it should generate report process
97743 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
97744 ------------------------------------------------------------------------------------------
97745
97746 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
97747 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
97748 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
97749 -- call ADRs
97750 -- Bug 4922099
97751 --
97752 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
97753 (NVL(l_actual_upg_option, 'N') = 'O') OR
97754 (NVL(l_enc_upg_option, 'N') = 'O')
97755 )
97756 THEN
97757 NULL;
97758 --
97759 --
97760
97761 l_ccid := AcctDerRule_33(
97762 p_application_id => p_application_id
97763 , p_ae_header_id => l_ae_header_id
97764 , p_source_59 => p_source_59
97765 , x_transaction_coa_id => l_adr_transaction_coa_id
97766 , x_accounting_coa_id => l_adr_accounting_coa_id
97767 , x_value_type_code => l_adr_value_type_code
97768 , p_side => 'NA'
97769 );
97770
97771 xla_ae_lines_pkg.set_ccid(
97772 p_code_combination_id => l_ccid
97773 , p_value_type_code => l_adr_value_type_code
97774 , p_transaction_coa_id => l_adr_transaction_coa_id
97775 , p_accounting_coa_id => l_adr_accounting_coa_id
97776 , p_adr_code => 'PI_RECEIVABLES'
97777 , p_adr_type_code => 'S'
97778 , p_component_type => l_component_type
97779 , p_component_code => l_component_code
97780 , p_component_type_code => l_component_type_code
97781 , p_component_appl_id => l_component_appl_id
97782 , p_amb_context_code => l_amb_context_code
97783 , p_side => 'NA'
97784 );
97785
97786
97787 --
97788 --
97789 END IF;
97790
97791 --
97792 -- Update the line information that should be overwritten
97793 --
97794 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
97795 p_header_num => 1);
97796 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
97797
97798 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
97799
97800 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
97801 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
97802 END IF;
97803
97804 --
97805 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
97806 --
97807 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
97808 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
97809 ELSE
97810 ---------------------------------------------------------------------------------------------------
97811 -- 4262811a Switch Sign
97812 ---------------------------------------------------------------------------------------------------
97813 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
97814 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
97815 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97816 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
97817 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97818 -- 5132302
97819 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
97820 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
97821
97822 END IF;
97823
97824 -- 4955764
97825 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
97826 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
97827
97828
97829 XLA_AE_LINES_PKG.ValidateCurrentLine;
97830 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
97831
97832 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
97833 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
97834 ,p_balance_type_code => l_balance_type_code);
97835
97836 END IF;
97837
97838 -----------------------------------------------------------------------------------------
97839 -- 4262811 Multiperiod Accounting
97840 -----------------------------------------------------------------------------------------
97841 -- No MPA option is assigned.
97842
97843
97844 END IF;
97845 END IF;
97846 --
97847
97848 --
97849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
97850 trace
97851 (p_msg => 'END of AcctLineType_195'
97852 ,p_level => C_LEVEL_PROCEDURE
97853 ,p_module => l_log_module);
97854 END IF;
97855 --
97856 EXCEPTION
97857 WHEN xla_exceptions_pkg.application_exception THEN
97858 RAISE;
97859 WHEN OTHERS THEN
97860 xla_exceptions_pkg.raise_message
97861 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_195');
97862 END AcctLineType_195;
97863 --
97864
97865 ---------------------------------------
97866 --
97867 -- PRIVATE FUNCTION
97868 -- AcctLineType_196
97869 --
97870 ---------------------------------------
97871 PROCEDURE AcctLineType_196 (
97872 p_application_id IN NUMBER
97873 ,p_event_id IN NUMBER
97874 ,p_calculate_acctd_flag IN VARCHAR2
97875 ,p_calculate_g_l_flag IN VARCHAR2
97876 ,p_actual_flag IN OUT VARCHAR2
97877 ,p_balance_type_code OUT VARCHAR2
97878 ,p_gain_or_loss_ref OUT VARCHAR2
97879
97880 --TRANSACTION_ID
97881 , p_source_1 IN NUMBER
97882 --Item Concatenated Segments
97883 , p_source_2 IN VARCHAR2
97884 --Transaction Quantity
97885 , p_source_3 IN NUMBER
97886 --Transaction Unit of Measure Code
97887 , p_source_4 IN VARCHAR2
97888 --Inventory Transaction Type Description
97889 , p_source_5 IN VARCHAR2
97890 --Interorg Receivables Account
97891 , p_source_59 IN NUMBER
97892 --DISTRIBUTION_IDENTIFIER
97893 , p_source_84 IN NUMBER
97894 --Distribution Type
97895 , p_source_85 IN VARCHAR2
97896 , p_source_85_meaning IN VARCHAR2
97897 --Entered Currency Code
97898 , p_source_88 IN VARCHAR2
97899 --Entered Amount
97900 , p_source_91 IN NUMBER
97901 --Currency Conversion Date
97902 , p_source_92 IN DATE
97903 --Currency Conversion Rate
97904 , p_source_93 IN NUMBER
97905 --Currency Conversion Type
97906 , p_source_94 IN VARCHAR2
97907 --Accounted Amount
97908 , p_source_95 IN NUMBER
97909 --Accounting Line Type
97910 , p_source_97 IN NUMBER
97911 )
97912 IS
97913
97914 l_component_type VARCHAR2(80);
97915 l_component_code VARCHAR2(30);
97916 l_component_type_code VARCHAR2(1);
97917 l_component_appl_id INTEGER;
97918 l_amb_context_code VARCHAR2(30);
97919 l_entity_code VARCHAR2(30);
97920 l_event_class_code VARCHAR2(30);
97921 l_ae_header_id NUMBER;
97922 l_event_type_code VARCHAR2(30);
97923 l_line_definition_code VARCHAR2(30);
97924 l_line_definition_owner_code VARCHAR2(1);
97925 --
97926 -- adr variables
97927 l_segment VARCHAR2(30);
97928 l_ccid NUMBER;
97929 l_adr_transaction_coa_id NUMBER;
97930 l_adr_accounting_coa_id NUMBER;
97931 l_adr_flexfield_segment_code VARCHAR2(30);
97932 l_adr_flex_value_set_id NUMBER;
97933 l_adr_value_type_code VARCHAR2(30);
97934 l_adr_value_combination_id NUMBER;
97935 l_adr_value_segment_code VARCHAR2(30);
97936
97937 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
97938 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
97939 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
97940 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
97941
97942 -- 4262811 Variables ------------------------------------------------------------------------------------------
97943 l_entered_amt_idx NUMBER;
97944 l_accted_amt_idx NUMBER;
97945 l_acc_rev_flag VARCHAR2(1);
97946 l_accrual_line_num NUMBER;
97947 l_tmp_amt NUMBER;
97948 l_acc_rev_natural_side_code VARCHAR2(1);
97949
97950 l_num_entries NUMBER;
97951 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
97952 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
97953 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
97954 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
97955 l_recog_line_1 NUMBER;
97956 l_recog_line_2 NUMBER;
97957
97958 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
97959 l_bflow_applied_to_amt NUMBER; -- 5132302
97960 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
97961
97962 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
97963
97964 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
97965 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
97966
97967 ---------------------------------------------------------------------------------------------------------------
97968
97969
97970 --
97971 -- bulk performance
97972 --
97973 l_balance_type_code VARCHAR2(1);
97974 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
97975 l_log_module VARCHAR2(240);
97976
97977 --
97978 -- Upgrade strategy
97979 --
97980 l_actual_upg_option VARCHAR2(1);
97981 l_enc_upg_option VARCHAR2(1);
97982
97983 --
97984 BEGIN
97985 --
97986 IF g_log_enabled THEN
97987 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_196';
97988 END IF;
97989 --
97990 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
97991
97992 trace
97993 (p_msg => 'BEGIN of AcctLineType_196'
97994 ,p_level => C_LEVEL_PROCEDURE
97995 ,p_module => l_log_module);
97996
97997 END IF;
97998 --
97999 l_component_type := 'AMB_JLT';
98000 l_component_code := 'INTERORG_RECEIVABLES';
98001 l_component_type_code := 'S';
98002 l_component_appl_id := 707;
98003 l_amb_context_code := 'DEFAULT';
98004 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
98005 l_event_class_code := 'DIR_INTERORG_SHIP';
98006 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
98007 l_line_definition_owner_code := 'S';
98008 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
98009 --
98010 l_balance_type_code := 'A';
98011 l_segment := NULL;
98012 l_ccid := NULL;
98013 l_adr_transaction_coa_id := NULL;
98014 l_adr_accounting_coa_id := NULL;
98015 l_adr_flexfield_segment_code := NULL;
98016 l_adr_flex_value_set_id := NULL;
98017 l_adr_value_type_code := NULL;
98018 l_adr_value_combination_id := NULL;
98019 l_adr_value_segment_code := NULL;
98020
98021 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
98022 l_bflow_class_code := ''; -- 4219869 Business Flow
98023 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
98024 l_budgetary_control_flag := 'N';
98025
98026 l_bflow_applied_to_amt_idx := NULL; -- 5132302
98027 l_bflow_applied_to_amt := NULL; -- 5132302
98028 l_entered_amt_idx := NULL; -- 4262811
98029 l_accted_amt_idx := NULL; -- 4262811
98030 l_acc_rev_flag := NULL; -- 4262811
98031 l_accrual_line_num := NULL; -- 4262811
98032 l_tmp_amt := NULL; -- 4262811
98033 --
98034
98035 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
98036 l_balance_type_code <> 'B' THEN
98037 IF NVL(p_source_97,9E125) = 10
98038 THEN
98039
98040 --
98041 XLA_AE_LINES_PKG.SetNewLine;
98042
98043 p_balance_type_code := l_balance_type_code;
98044 -- set the flag so later we will know whether the gain loss line needs to be created
98045
98046 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
98047 p_actual_flag :='A';
98048 END IF;
98049
98050 --
98051 -- bulk performance
98052 --
98053 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
98054 p_header_num => 0); -- 4262811
98055 --
98056 -- set accounting line options
98057 --
98058 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
98059 p_natural_side_code => 'D'
98060 , p_gain_or_loss_flag => 'N'
98061 , p_gl_transfer_mode_code => 'S'
98062 , p_acct_entry_type_code => 'A'
98063 , p_switch_side_flag => 'Y'
98064 , p_merge_duplicate_code => 'N'
98065 );
98066 --
98067 l_acc_rev_natural_side_code := 'C'; -- 4262811
98068 --
98069 --
98070 -- set accounting line type info
98071 --
98072 xla_ae_lines_pkg.SetAcctLineType
98073 (p_component_type => l_component_type
98074 ,p_event_type_code => l_event_type_code
98075 ,p_line_definition_owner_code => l_line_definition_owner_code
98076 ,p_line_definition_code => l_line_definition_code
98077 ,p_accounting_line_code => l_component_code
98078 ,p_accounting_line_type_code => l_component_type_code
98079 ,p_accounting_line_appl_id => l_component_appl_id
98080 ,p_amb_context_code => l_amb_context_code
98081 ,p_entity_code => l_entity_code
98082 ,p_event_class_code => l_event_class_code);
98083 --
98084 -- set accounting class
98085 --
98086 xla_ae_lines_pkg.SetAcctClass(
98087 p_accounting_class_code => 'INTERORG_RECEIVABLES'
98088 , p_ae_header_id => l_ae_header_id
98089 );
98090
98091 --
98092 -- set rounding class
98093 --
98094 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
98095 'INTERORG_RECEIVABLES';
98096
98097 --
98098 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
98099 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
98100 --
98101 -- bulk performance
98102 --
98103 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
98104
98105 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
98106 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
98107
98108 -- 4955764
98109 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
98110 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
98111
98112 -- 4458381 Public Sector Enh
98113
98114 --
98115 -- set accounting attributes for the line type
98116 --
98117 l_entered_amt_idx := 3;
98118 l_accted_amt_idx := 8;
98119 l_bflow_applied_to_amt_idx := NULL; -- 5132302
98120 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
98121 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
98122 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
98123 l_rec_acct_attrs.array_char_value(2) := p_source_85;
98124 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
98125 l_rec_acct_attrs.array_num_value(3) := p_source_91;
98126 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
98127 l_rec_acct_attrs.array_char_value(4) := p_source_88;
98128 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
98129 l_rec_acct_attrs.array_date_value(5) := p_source_92;
98130 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
98131 l_rec_acct_attrs.array_num_value(6) := p_source_93;
98132 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
98133 l_rec_acct_attrs.array_char_value(7) := p_source_94;
98134 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
98135 l_rec_acct_attrs.array_num_value(8) := p_source_95;
98136
98137 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
98138 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
98139
98140 ---------------------------------------------------------------------------------------------------------------
98141 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
98142 ---------------------------------------------------------------------------------------------------------------
98143 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
98144
98145 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
98146 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
98147
98148 IF xla_accounting_cache_pkg.GetValueChar
98149 (p_source_code => 'LEDGER_CATEGORY_CODE'
98150 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
98151 AND l_bflow_method_code = 'PRIOR_ENTRY'
98152 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
98153 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
98154 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
98155 )
98156 THEN
98157 xla_ae_lines_pkg.BflowUpgEntry
98158 (p_business_method_code => l_bflow_method_code
98159 ,p_business_class_code => l_bflow_class_code
98160 ,p_balance_type => l_balance_type_code);
98161 ELSE
98162 NULL;
98163 -- No business flow processing for business flow method of NONE.
98164 END IF;
98165
98166 --
98167 -- call analytical criteria
98168 --
98169
98170 --
98171 -- call description
98172 --
98173
98174 xla_ae_lines_pkg.SetLineDescription(
98175 p_ae_header_id => l_ae_header_id
98176 ,p_description => Description_1 (
98177 p_application_id => p_application_id
98178 , p_ae_header_id => l_ae_header_id
98179 , p_source_1 => p_source_1
98180 , p_source_2 => p_source_2
98181 , p_source_3 => p_source_3
98182 , p_source_4 => p_source_4
98183 , p_source_5 => p_source_5
98184 )
98185 );
98186
98187
98188 --
98189 -- call ADRs
98190 -- Bug 4922099
98191 --
98192 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
98193 (NVL(l_actual_upg_option, 'N') = 'O') OR
98194 (NVL(l_enc_upg_option, 'N') = 'O')
98195 )
98196 THEN
98197 NULL;
98198 --
98199 --
98200
98201 l_ccid := AcctDerRule_33(
98202 p_application_id => p_application_id
98203 , p_ae_header_id => l_ae_header_id
98204 , p_source_59 => p_source_59
98205 , x_transaction_coa_id => l_adr_transaction_coa_id
98206 , x_accounting_coa_id => l_adr_accounting_coa_id
98207 , x_value_type_code => l_adr_value_type_code
98208 , p_side => 'NA'
98209 );
98210
98211 xla_ae_lines_pkg.set_ccid(
98212 p_code_combination_id => l_ccid
98213 , p_value_type_code => l_adr_value_type_code
98214 , p_transaction_coa_id => l_adr_transaction_coa_id
98215 , p_accounting_coa_id => l_adr_accounting_coa_id
98216 , p_adr_code => 'PI_RECEIVABLES'
98217 , p_adr_type_code => 'S'
98218 , p_component_type => l_component_type
98219 , p_component_code => l_component_code
98220 , p_component_type_code => l_component_type_code
98221 , p_component_appl_id => l_component_appl_id
98222 , p_amb_context_code => l_amb_context_code
98223 , p_side => 'NA'
98224 );
98225
98226
98227 --
98228 --
98229 END IF;
98230 --
98231 -- Bug 4922099
98232 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
98233 (NVL(l_enc_upg_option, 'N') = 'O')
98234 ) AND
98235 (l_bflow_method_code = 'PRIOR_ENTRY')
98236 )
98237 THEN
98238 IF
98239 --
98240 1 = 2
98241 --
98242 THEN
98243 xla_accounting_err_pkg.build_message
98244 (p_appli_s_name => 'XLA'
98245 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
98246 ,p_token_1 => 'LINE_NUMBER'
98247 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
98248 ,p_token_2 => 'LINE_TYPE_NAME'
98249 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
98250 l_component_type
98251 ,l_component_code
98252 ,l_component_type_code
98253 ,l_component_appl_id
98254 ,l_amb_context_code
98255 ,l_entity_code
98256 ,l_event_class_code
98257 )
98258 ,p_token_3 => 'OWNER'
98259 ,p_value_3 => xla_lookups_pkg.get_meaning(
98260 p_lookup_type => 'XLA_OWNER_TYPE'
98261 ,p_lookup_code => l_component_type_code
98262 )
98263 ,p_token_4 => 'PRODUCT_NAME'
98264 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
98265 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
98266 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
98267 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
98268 ,p_ae_header_id => NULL
98269 );
98270
98271 IF (C_LEVEL_ERROR>= g_log_level) THEN
98272 trace
98273 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
98274 ,p_level => C_LEVEL_ERROR
98275 ,p_module => l_log_module);
98276 END IF;
98277 END IF;
98278 END IF;
98279 --
98280 --
98281 ------------------------------------------------------------------------------------------------
98282 -- 4219869 Business Flow
98283 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
98284 -- Prior Entry. Currently, the following code is always generated.
98285 ------------------------------------------------------------------------------------------------
98286 XLA_AE_LINES_PKG.ValidateCurrentLine;
98287
98288 ------------------------------------------------------------------------------------
98289 -- 4219869 Business Flow
98290 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
98291 ------------------------------------------------------------------------------------
98292 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
98293
98294 ----------------------------------------------------------------------------------
98295 -- 4219869 Business Flow
98296 -- Update journal entry status -- Need to generate this within IF <condition>
98297 ----------------------------------------------------------------------------------
98298 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
98299 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
98300 ,p_balance_type_code => l_balance_type_code
98301 );
98302
98303 -------------------------------------------------------------------------------------------
98304 -- 4262811 - Generate the Accrual Reversal lines
98305 -------------------------------------------------------------------------------------------
98306 BEGIN
98307 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
98308 (g_array_event(p_event_id).array_value_num('header_index'));
98309 IF l_acc_rev_flag IS NULL THEN
98310 l_acc_rev_flag := 'N';
98311 END IF;
98312 EXCEPTION
98313 WHEN OTHERS THEN
98314 l_acc_rev_flag := 'N';
98315 END;
98316 --
98317 IF (l_acc_rev_flag = 'Y') THEN
98318
98319 -- 4645092 ------------------------------------------------------------------------------
98320 -- To allow MPA report to determine if it should generate report process
98321 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
98322 ------------------------------------------------------------------------------------------
98323
98324 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
98325 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
98326 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
98327 -- call ADRs
98328 -- Bug 4922099
98329 --
98330 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
98331 (NVL(l_actual_upg_option, 'N') = 'O') OR
98332 (NVL(l_enc_upg_option, 'N') = 'O')
98333 )
98334 THEN
98335 NULL;
98336 --
98337 --
98338
98339 l_ccid := AcctDerRule_33(
98340 p_application_id => p_application_id
98341 , p_ae_header_id => l_ae_header_id
98342 , p_source_59 => p_source_59
98343 , x_transaction_coa_id => l_adr_transaction_coa_id
98344 , x_accounting_coa_id => l_adr_accounting_coa_id
98345 , x_value_type_code => l_adr_value_type_code
98346 , p_side => 'NA'
98347 );
98348
98349 xla_ae_lines_pkg.set_ccid(
98350 p_code_combination_id => l_ccid
98351 , p_value_type_code => l_adr_value_type_code
98352 , p_transaction_coa_id => l_adr_transaction_coa_id
98353 , p_accounting_coa_id => l_adr_accounting_coa_id
98354 , p_adr_code => 'PI_RECEIVABLES'
98355 , p_adr_type_code => 'S'
98356 , p_component_type => l_component_type
98357 , p_component_code => l_component_code
98358 , p_component_type_code => l_component_type_code
98359 , p_component_appl_id => l_component_appl_id
98360 , p_amb_context_code => l_amb_context_code
98361 , p_side => 'NA'
98362 );
98363
98364
98365 --
98366 --
98367 END IF;
98368
98369 --
98370 -- Update the line information that should be overwritten
98371 --
98372 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
98373 p_header_num => 1);
98374 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
98375
98376 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
98377
98378 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
98379 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
98380 END IF;
98381
98382 --
98383 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
98384 --
98385 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
98386 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
98387 ELSE
98388 ---------------------------------------------------------------------------------------------------
98389 -- 4262811a Switch Sign
98390 ---------------------------------------------------------------------------------------------------
98391 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
98392 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
98393 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98394 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
98395 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98396 -- 5132302
98397 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
98398 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98399
98400 END IF;
98401
98402 -- 4955764
98403 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
98404 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
98405
98406
98407 XLA_AE_LINES_PKG.ValidateCurrentLine;
98408 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
98409
98410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
98411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
98412 ,p_balance_type_code => l_balance_type_code);
98413
98414 END IF;
98415
98416 -----------------------------------------------------------------------------------------
98417 -- 4262811 Multiperiod Accounting
98418 -----------------------------------------------------------------------------------------
98419 -- No MPA option is assigned.
98420
98421
98422 END IF;
98423 END IF;
98424 --
98425
98426 --
98427 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
98428 trace
98429 (p_msg => 'END of AcctLineType_196'
98430 ,p_level => C_LEVEL_PROCEDURE
98431 ,p_module => l_log_module);
98432 END IF;
98433 --
98434 EXCEPTION
98435 WHEN xla_exceptions_pkg.application_exception THEN
98436 RAISE;
98437 WHEN OTHERS THEN
98438 xla_exceptions_pkg.raise_message
98439 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_196');
98440 END AcctLineType_196;
98441 --
98442
98443 ---------------------------------------
98444 --
98445 -- PRIVATE FUNCTION
98446 -- AcctLineType_197
98447 --
98448 ---------------------------------------
98449 PROCEDURE AcctLineType_197 (
98450 p_application_id IN NUMBER
98451 ,p_event_id IN NUMBER
98452 ,p_calculate_acctd_flag IN VARCHAR2
98453 ,p_calculate_g_l_flag IN VARCHAR2
98454 ,p_actual_flag IN OUT VARCHAR2
98455 ,p_balance_type_code OUT VARCHAR2
98456 ,p_gain_or_loss_ref OUT VARCHAR2
98457
98458 --TRANSACTION_ID
98459 , p_source_1 IN NUMBER
98460 --Item Concatenated Segments
98461 , p_source_2 IN VARCHAR2
98462 --Transaction Quantity
98463 , p_source_3 IN NUMBER
98464 --Transaction Unit of Measure Code
98465 , p_source_4 IN VARCHAR2
98466 --Inventory Transaction Type Description
98467 , p_source_5 IN VARCHAR2
98468 --Cost Management Default Account
98469 , p_source_11 IN NUMBER
98470 --DISTRIBUTION_IDENTIFIER
98471 , p_source_84 IN NUMBER
98472 --Distribution Type
98473 , p_source_85 IN VARCHAR2
98474 , p_source_85_meaning IN VARCHAR2
98475 --Entered Currency Code
98476 , p_source_88 IN VARCHAR2
98477 --Entered Amount
98478 , p_source_91 IN NUMBER
98479 --Currency Conversion Date
98480 , p_source_92 IN DATE
98481 --Currency Conversion Rate
98482 , p_source_93 IN NUMBER
98483 --Currency Conversion Type
98484 , p_source_94 IN VARCHAR2
98485 --Accounted Amount
98486 , p_source_95 IN NUMBER
98487 --Accounting Line Type
98488 , p_source_97 IN NUMBER
98489 )
98490 IS
98491
98492 l_component_type VARCHAR2(80);
98493 l_component_code VARCHAR2(30);
98494 l_component_type_code VARCHAR2(1);
98495 l_component_appl_id INTEGER;
98496 l_amb_context_code VARCHAR2(30);
98497 l_entity_code VARCHAR2(30);
98498 l_event_class_code VARCHAR2(30);
98499 l_ae_header_id NUMBER;
98500 l_event_type_code VARCHAR2(30);
98501 l_line_definition_code VARCHAR2(30);
98502 l_line_definition_owner_code VARCHAR2(1);
98503 --
98504 -- adr variables
98505 l_segment VARCHAR2(30);
98506 l_ccid NUMBER;
98507 l_adr_transaction_coa_id NUMBER;
98508 l_adr_accounting_coa_id NUMBER;
98509 l_adr_flexfield_segment_code VARCHAR2(30);
98510 l_adr_flex_value_set_id NUMBER;
98511 l_adr_value_type_code VARCHAR2(30);
98512 l_adr_value_combination_id NUMBER;
98513 l_adr_value_segment_code VARCHAR2(30);
98514
98515 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
98516 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
98517 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
98518 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
98519
98520 -- 4262811 Variables ------------------------------------------------------------------------------------------
98521 l_entered_amt_idx NUMBER;
98522 l_accted_amt_idx NUMBER;
98523 l_acc_rev_flag VARCHAR2(1);
98524 l_accrual_line_num NUMBER;
98525 l_tmp_amt NUMBER;
98526 l_acc_rev_natural_side_code VARCHAR2(1);
98527
98528 l_num_entries NUMBER;
98529 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
98530 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
98531 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
98532 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
98533 l_recog_line_1 NUMBER;
98534 l_recog_line_2 NUMBER;
98535
98536 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
98537 l_bflow_applied_to_amt NUMBER; -- 5132302
98538 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
98539
98540 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
98541
98542 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
98543 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
98544
98545 ---------------------------------------------------------------------------------------------------------------
98546
98547
98548 --
98549 -- bulk performance
98550 --
98551 l_balance_type_code VARCHAR2(1);
98552 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
98553 l_log_module VARCHAR2(240);
98554
98555 --
98556 -- Upgrade strategy
98557 --
98558 l_actual_upg_option VARCHAR2(1);
98559 l_enc_upg_option VARCHAR2(1);
98560
98561 --
98562 BEGIN
98563 --
98564 IF g_log_enabled THEN
98565 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_197';
98566 END IF;
98567 --
98568 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
98569
98570 trace
98571 (p_msg => 'BEGIN of AcctLineType_197'
98572 ,p_level => C_LEVEL_PROCEDURE
98573 ,p_module => l_log_module);
98574
98575 END IF;
98576 --
98577 l_component_type := 'AMB_JLT';
98578 l_component_code := 'INTERORG_RECEIVABLES';
98579 l_component_type_code := 'S';
98580 l_component_appl_id := 707;
98581 l_amb_context_code := 'DEFAULT';
98582 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
98583 l_event_class_code := 'INT_ORDER_TO_EXP';
98584 l_event_type_code := 'EXP_REQ_RCPT_TP';
98585 l_line_definition_owner_code := 'S';
98586 l_line_definition_code := 'PI_EXP_REQ_RCPT_TP';
98587 --
98588 l_balance_type_code := 'A';
98589 l_segment := NULL;
98590 l_ccid := NULL;
98591 l_adr_transaction_coa_id := NULL;
98592 l_adr_accounting_coa_id := NULL;
98593 l_adr_flexfield_segment_code := NULL;
98594 l_adr_flex_value_set_id := NULL;
98595 l_adr_value_type_code := NULL;
98596 l_adr_value_combination_id := NULL;
98597 l_adr_value_segment_code := NULL;
98598
98599 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
98600 l_bflow_class_code := ''; -- 4219869 Business Flow
98601 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
98602 l_budgetary_control_flag := 'N';
98603
98604 l_bflow_applied_to_amt_idx := NULL; -- 5132302
98605 l_bflow_applied_to_amt := NULL; -- 5132302
98606 l_entered_amt_idx := NULL; -- 4262811
98607 l_accted_amt_idx := NULL; -- 4262811
98608 l_acc_rev_flag := NULL; -- 4262811
98609 l_accrual_line_num := NULL; -- 4262811
98610 l_tmp_amt := NULL; -- 4262811
98611 --
98612
98613 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
98614 l_balance_type_code <> 'B' THEN
98615 IF NVL(p_source_97,9E125) = 10
98616 THEN
98617
98618 --
98619 XLA_AE_LINES_PKG.SetNewLine;
98620
98621 p_balance_type_code := l_balance_type_code;
98622 -- set the flag so later we will know whether the gain loss line needs to be created
98623
98624 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
98625 p_actual_flag :='A';
98626 END IF;
98627
98628 --
98629 -- bulk performance
98630 --
98631 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
98632 p_header_num => 0); -- 4262811
98633 --
98634 -- set accounting line options
98635 --
98636 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
98637 p_natural_side_code => 'D'
98638 , p_gain_or_loss_flag => 'N'
98639 , p_gl_transfer_mode_code => 'S'
98640 , p_acct_entry_type_code => 'A'
98641 , p_switch_side_flag => 'Y'
98642 , p_merge_duplicate_code => 'N'
98643 );
98644 --
98645 l_acc_rev_natural_side_code := 'C'; -- 4262811
98646 --
98647 --
98648 -- set accounting line type info
98649 --
98650 xla_ae_lines_pkg.SetAcctLineType
98651 (p_component_type => l_component_type
98652 ,p_event_type_code => l_event_type_code
98653 ,p_line_definition_owner_code => l_line_definition_owner_code
98654 ,p_line_definition_code => l_line_definition_code
98655 ,p_accounting_line_code => l_component_code
98656 ,p_accounting_line_type_code => l_component_type_code
98657 ,p_accounting_line_appl_id => l_component_appl_id
98658 ,p_amb_context_code => l_amb_context_code
98659 ,p_entity_code => l_entity_code
98660 ,p_event_class_code => l_event_class_code);
98661 --
98662 -- set accounting class
98663 --
98664 xla_ae_lines_pkg.SetAcctClass(
98665 p_accounting_class_code => 'INTERORG_RECEIVABLES'
98666 , p_ae_header_id => l_ae_header_id
98667 );
98668
98669 --
98670 -- set rounding class
98671 --
98672 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
98673 'INTERORG_RECEIVABLES';
98674
98675 --
98676 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
98677 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
98678 --
98679 -- bulk performance
98680 --
98681 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
98682
98683 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
98684 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
98685
98686 -- 4955764
98687 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
98688 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
98689
98690 -- 4458381 Public Sector Enh
98691
98692 --
98693 -- set accounting attributes for the line type
98694 --
98695 l_entered_amt_idx := 3;
98696 l_accted_amt_idx := 8;
98697 l_bflow_applied_to_amt_idx := NULL; -- 5132302
98698 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
98699 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
98700 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
98701 l_rec_acct_attrs.array_char_value(2) := p_source_85;
98702 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
98703 l_rec_acct_attrs.array_num_value(3) := p_source_91;
98704 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
98705 l_rec_acct_attrs.array_char_value(4) := p_source_88;
98706 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
98707 l_rec_acct_attrs.array_date_value(5) := p_source_92;
98708 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
98709 l_rec_acct_attrs.array_num_value(6) := p_source_93;
98710 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
98711 l_rec_acct_attrs.array_char_value(7) := p_source_94;
98712 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
98713 l_rec_acct_attrs.array_num_value(8) := p_source_95;
98714
98715 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
98716 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
98717
98718 ---------------------------------------------------------------------------------------------------------------
98719 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
98720 ---------------------------------------------------------------------------------------------------------------
98721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
98722
98723 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
98724 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
98725
98726 IF xla_accounting_cache_pkg.GetValueChar
98727 (p_source_code => 'LEDGER_CATEGORY_CODE'
98728 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
98729 AND l_bflow_method_code = 'PRIOR_ENTRY'
98730 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
98731 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
98732 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
98733 )
98734 THEN
98735 xla_ae_lines_pkg.BflowUpgEntry
98736 (p_business_method_code => l_bflow_method_code
98737 ,p_business_class_code => l_bflow_class_code
98738 ,p_balance_type => l_balance_type_code);
98739 ELSE
98740 NULL;
98741 -- No business flow processing for business flow method of NONE.
98742 END IF;
98743
98744 --
98745 -- call analytical criteria
98746 --
98747
98748 --
98749 -- call description
98750 --
98751
98752 xla_ae_lines_pkg.SetLineDescription(
98753 p_ae_header_id => l_ae_header_id
98754 ,p_description => Description_1 (
98755 p_application_id => p_application_id
98756 , p_ae_header_id => l_ae_header_id
98757 , p_source_1 => p_source_1
98758 , p_source_2 => p_source_2
98759 , p_source_3 => p_source_3
98760 , p_source_4 => p_source_4
98761 , p_source_5 => p_source_5
98762 )
98763 );
98764
98765
98766 --
98767 -- call ADRs
98768 -- Bug 4922099
98769 --
98770 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
98771 (NVL(l_actual_upg_option, 'N') = 'O') OR
98772 (NVL(l_enc_upg_option, 'N') = 'O')
98773 )
98774 THEN
98775 NULL;
98776 --
98777 --
98778
98779 l_ccid := AcctDerRule_6(
98780 p_application_id => p_application_id
98781 , p_ae_header_id => l_ae_header_id
98782 , p_source_11 => p_source_11
98783 , x_transaction_coa_id => l_adr_transaction_coa_id
98784 , x_accounting_coa_id => l_adr_accounting_coa_id
98785 , x_value_type_code => l_adr_value_type_code
98786 , p_side => 'NA'
98787 );
98788
98789 xla_ae_lines_pkg.set_ccid(
98790 p_code_combination_id => l_ccid
98791 , p_value_type_code => l_adr_value_type_code
98792 , p_transaction_coa_id => l_adr_transaction_coa_id
98793 , p_accounting_coa_id => l_adr_accounting_coa_id
98794 , p_adr_code => 'CST_DEFAULT'
98795 , p_adr_type_code => 'S'
98796 , p_component_type => l_component_type
98797 , p_component_code => l_component_code
98798 , p_component_type_code => l_component_type_code
98799 , p_component_appl_id => l_component_appl_id
98800 , p_amb_context_code => l_amb_context_code
98801 , p_side => 'NA'
98802 );
98803
98804
98805 --
98806 --
98807 END IF;
98808 --
98809 -- Bug 4922099
98810 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
98811 (NVL(l_enc_upg_option, 'N') = 'O')
98812 ) AND
98813 (l_bflow_method_code = 'PRIOR_ENTRY')
98814 )
98815 THEN
98816 IF
98817 --
98818 1 = 2
98819 --
98820 THEN
98821 xla_accounting_err_pkg.build_message
98822 (p_appli_s_name => 'XLA'
98823 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
98824 ,p_token_1 => 'LINE_NUMBER'
98825 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
98826 ,p_token_2 => 'LINE_TYPE_NAME'
98827 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
98828 l_component_type
98829 ,l_component_code
98830 ,l_component_type_code
98831 ,l_component_appl_id
98832 ,l_amb_context_code
98833 ,l_entity_code
98834 ,l_event_class_code
98835 )
98836 ,p_token_3 => 'OWNER'
98837 ,p_value_3 => xla_lookups_pkg.get_meaning(
98838 p_lookup_type => 'XLA_OWNER_TYPE'
98839 ,p_lookup_code => l_component_type_code
98840 )
98841 ,p_token_4 => 'PRODUCT_NAME'
98842 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
98843 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
98844 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
98845 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
98846 ,p_ae_header_id => NULL
98847 );
98848
98849 IF (C_LEVEL_ERROR>= g_log_level) THEN
98850 trace
98851 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
98852 ,p_level => C_LEVEL_ERROR
98853 ,p_module => l_log_module);
98854 END IF;
98855 END IF;
98856 END IF;
98857 --
98858 --
98859 ------------------------------------------------------------------------------------------------
98860 -- 4219869 Business Flow
98861 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
98862 -- Prior Entry. Currently, the following code is always generated.
98863 ------------------------------------------------------------------------------------------------
98864 XLA_AE_LINES_PKG.ValidateCurrentLine;
98865
98866 ------------------------------------------------------------------------------------
98867 -- 4219869 Business Flow
98868 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
98869 ------------------------------------------------------------------------------------
98870 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
98871
98872 ----------------------------------------------------------------------------------
98873 -- 4219869 Business Flow
98874 -- Update journal entry status -- Need to generate this within IF <condition>
98875 ----------------------------------------------------------------------------------
98876 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
98877 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
98878 ,p_balance_type_code => l_balance_type_code
98879 );
98880
98881 -------------------------------------------------------------------------------------------
98882 -- 4262811 - Generate the Accrual Reversal lines
98883 -------------------------------------------------------------------------------------------
98884 BEGIN
98885 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
98886 (g_array_event(p_event_id).array_value_num('header_index'));
98887 IF l_acc_rev_flag IS NULL THEN
98888 l_acc_rev_flag := 'N';
98889 END IF;
98890 EXCEPTION
98891 WHEN OTHERS THEN
98892 l_acc_rev_flag := 'N';
98893 END;
98894 --
98895 IF (l_acc_rev_flag = 'Y') THEN
98896
98897 -- 4645092 ------------------------------------------------------------------------------
98898 -- To allow MPA report to determine if it should generate report process
98899 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
98900 ------------------------------------------------------------------------------------------
98901
98902 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
98903 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
98904 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
98905 -- call ADRs
98906 -- Bug 4922099
98907 --
98908 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
98909 (NVL(l_actual_upg_option, 'N') = 'O') OR
98910 (NVL(l_enc_upg_option, 'N') = 'O')
98911 )
98912 THEN
98913 NULL;
98914 --
98915 --
98916
98917 l_ccid := AcctDerRule_6(
98918 p_application_id => p_application_id
98919 , p_ae_header_id => l_ae_header_id
98920 , p_source_11 => p_source_11
98921 , x_transaction_coa_id => l_adr_transaction_coa_id
98922 , x_accounting_coa_id => l_adr_accounting_coa_id
98923 , x_value_type_code => l_adr_value_type_code
98924 , p_side => 'NA'
98925 );
98926
98927 xla_ae_lines_pkg.set_ccid(
98928 p_code_combination_id => l_ccid
98929 , p_value_type_code => l_adr_value_type_code
98930 , p_transaction_coa_id => l_adr_transaction_coa_id
98931 , p_accounting_coa_id => l_adr_accounting_coa_id
98932 , p_adr_code => 'CST_DEFAULT'
98933 , p_adr_type_code => 'S'
98934 , p_component_type => l_component_type
98935 , p_component_code => l_component_code
98936 , p_component_type_code => l_component_type_code
98937 , p_component_appl_id => l_component_appl_id
98938 , p_amb_context_code => l_amb_context_code
98939 , p_side => 'NA'
98940 );
98941
98942
98943 --
98944 --
98945 END IF;
98946
98947 --
98948 -- Update the line information that should be overwritten
98949 --
98950 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
98951 p_header_num => 1);
98952 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
98953
98954 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
98955
98956 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
98957 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
98958 END IF;
98959
98960 --
98961 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
98962 --
98963 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
98964 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
98965 ELSE
98966 ---------------------------------------------------------------------------------------------------
98967 -- 4262811a Switch Sign
98968 ---------------------------------------------------------------------------------------------------
98969 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
98970 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
98971 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98972 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
98973 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98974 -- 5132302
98975 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
98976 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
98977
98978 END IF;
98979
98980 -- 4955764
98981 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
98982 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
98983
98984
98985 XLA_AE_LINES_PKG.ValidateCurrentLine;
98986 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
98987
98988 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
98989 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
98990 ,p_balance_type_code => l_balance_type_code);
98991
98992 END IF;
98993
98994 -----------------------------------------------------------------------------------------
98995 -- 4262811 Multiperiod Accounting
98996 -----------------------------------------------------------------------------------------
98997 -- No MPA option is assigned.
98998
98999
99000 END IF;
99001 END IF;
99002 --
99003
99004 --
99005 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
99006 trace
99007 (p_msg => 'END of AcctLineType_197'
99008 ,p_level => C_LEVEL_PROCEDURE
99009 ,p_module => l_log_module);
99010 END IF;
99011 --
99012 EXCEPTION
99013 WHEN xla_exceptions_pkg.application_exception THEN
99014 RAISE;
99015 WHEN OTHERS THEN
99016 xla_exceptions_pkg.raise_message
99017 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_197');
99018 END AcctLineType_197;
99019 --
99020
99021 ---------------------------------------
99022 --
99023 -- PRIVATE FUNCTION
99024 -- AcctLineType_198
99025 --
99026 ---------------------------------------
99027 PROCEDURE AcctLineType_198 (
99028 p_application_id IN NUMBER
99029 ,p_event_id IN NUMBER
99030 ,p_calculate_acctd_flag IN VARCHAR2
99031 ,p_calculate_g_l_flag IN VARCHAR2
99032 ,p_actual_flag IN OUT VARCHAR2
99033 ,p_balance_type_code OUT VARCHAR2
99034 ,p_gain_or_loss_ref OUT VARCHAR2
99035
99036 --TRANSACTION_ID
99037 , p_source_1 IN NUMBER
99038 --Item Concatenated Segments
99039 , p_source_2 IN VARCHAR2
99040 --Transaction Quantity
99041 , p_source_3 IN NUMBER
99042 --Transaction Unit of Measure Code
99043 , p_source_4 IN VARCHAR2
99044 --Inventory Transaction Type Description
99045 , p_source_5 IN VARCHAR2
99046 --Interorg Receivables Account
99047 , p_source_59 IN NUMBER
99048 --DISTRIBUTION_IDENTIFIER
99049 , p_source_84 IN NUMBER
99050 --Distribution Type
99051 , p_source_85 IN VARCHAR2
99052 , p_source_85_meaning IN VARCHAR2
99053 --Entered Currency Code
99054 , p_source_88 IN VARCHAR2
99055 --Entered Amount
99056 , p_source_91 IN NUMBER
99057 --Currency Conversion Date
99058 , p_source_92 IN DATE
99059 --Currency Conversion Rate
99060 , p_source_93 IN NUMBER
99061 --Currency Conversion Type
99062 , p_source_94 IN VARCHAR2
99063 --Accounted Amount
99064 , p_source_95 IN NUMBER
99065 --Accounting Line Type
99066 , p_source_97 IN NUMBER
99067 )
99068 IS
99069
99070 l_component_type VARCHAR2(80);
99071 l_component_code VARCHAR2(30);
99072 l_component_type_code VARCHAR2(1);
99073 l_component_appl_id INTEGER;
99074 l_amb_context_code VARCHAR2(30);
99075 l_entity_code VARCHAR2(30);
99076 l_event_class_code VARCHAR2(30);
99077 l_ae_header_id NUMBER;
99078 l_event_type_code VARCHAR2(30);
99079 l_line_definition_code VARCHAR2(30);
99080 l_line_definition_owner_code VARCHAR2(1);
99081 --
99082 -- adr variables
99083 l_segment VARCHAR2(30);
99084 l_ccid NUMBER;
99085 l_adr_transaction_coa_id NUMBER;
99086 l_adr_accounting_coa_id NUMBER;
99087 l_adr_flexfield_segment_code VARCHAR2(30);
99088 l_adr_flex_value_set_id NUMBER;
99089 l_adr_value_type_code VARCHAR2(30);
99090 l_adr_value_combination_id NUMBER;
99091 l_adr_value_segment_code VARCHAR2(30);
99092
99093 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
99094 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
99095 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
99096 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
99097
99098 -- 4262811 Variables ------------------------------------------------------------------------------------------
99099 l_entered_amt_idx NUMBER;
99100 l_accted_amt_idx NUMBER;
99101 l_acc_rev_flag VARCHAR2(1);
99102 l_accrual_line_num NUMBER;
99103 l_tmp_amt NUMBER;
99104 l_acc_rev_natural_side_code VARCHAR2(1);
99105
99106 l_num_entries NUMBER;
99107 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
99108 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
99109 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
99110 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
99111 l_recog_line_1 NUMBER;
99112 l_recog_line_2 NUMBER;
99113
99114 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
99115 l_bflow_applied_to_amt NUMBER; -- 5132302
99116 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
99117
99118 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
99119
99120 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
99121 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
99122
99123 ---------------------------------------------------------------------------------------------------------------
99124
99125
99126 --
99127 -- bulk performance
99128 --
99129 l_balance_type_code VARCHAR2(1);
99130 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
99131 l_log_module VARCHAR2(240);
99132
99133 --
99134 -- Upgrade strategy
99135 --
99136 l_actual_upg_option VARCHAR2(1);
99137 l_enc_upg_option VARCHAR2(1);
99138
99139 --
99140 BEGIN
99141 --
99142 IF g_log_enabled THEN
99143 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_198';
99144 END IF;
99145 --
99146 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
99147
99148 trace
99149 (p_msg => 'BEGIN of AcctLineType_198'
99150 ,p_level => C_LEVEL_PROCEDURE
99151 ,p_module => l_log_module);
99152
99153 END IF;
99154 --
99155 l_component_type := 'AMB_JLT';
99156 l_component_code := 'INTERORG_RECEIVABLES';
99157 l_component_type_code := 'S';
99158 l_component_appl_id := 707;
99159 l_amb_context_code := 'DEFAULT';
99160 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
99161 l_event_class_code := 'USER_DEFINE';
99162 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
99163 l_line_definition_owner_code := 'S';
99164 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
99165 --
99166 l_balance_type_code := 'A';
99167 l_segment := NULL;
99168 l_ccid := NULL;
99169 l_adr_transaction_coa_id := NULL;
99170 l_adr_accounting_coa_id := NULL;
99171 l_adr_flexfield_segment_code := NULL;
99172 l_adr_flex_value_set_id := NULL;
99173 l_adr_value_type_code := NULL;
99174 l_adr_value_combination_id := NULL;
99175 l_adr_value_segment_code := NULL;
99176
99177 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
99178 l_bflow_class_code := ''; -- 4219869 Business Flow
99179 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
99180 l_budgetary_control_flag := 'N';
99181
99182 l_bflow_applied_to_amt_idx := NULL; -- 5132302
99183 l_bflow_applied_to_amt := NULL; -- 5132302
99184 l_entered_amt_idx := NULL; -- 4262811
99185 l_accted_amt_idx := NULL; -- 4262811
99186 l_acc_rev_flag := NULL; -- 4262811
99187 l_accrual_line_num := NULL; -- 4262811
99188 l_tmp_amt := NULL; -- 4262811
99189 --
99190
99191 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
99192 l_balance_type_code <> 'B' THEN
99193 IF NVL(p_source_97,9E125) = 10
99194 THEN
99195
99196 --
99197 XLA_AE_LINES_PKG.SetNewLine;
99198
99199 p_balance_type_code := l_balance_type_code;
99200 -- set the flag so later we will know whether the gain loss line needs to be created
99201
99202 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
99203 p_actual_flag :='A';
99204 END IF;
99205
99206 --
99207 -- bulk performance
99208 --
99209 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
99210 p_header_num => 0); -- 4262811
99211 --
99212 -- set accounting line options
99213 --
99214 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
99215 p_natural_side_code => 'D'
99216 , p_gain_or_loss_flag => 'N'
99217 , p_gl_transfer_mode_code => 'S'
99218 , p_acct_entry_type_code => 'A'
99219 , p_switch_side_flag => 'Y'
99220 , p_merge_duplicate_code => 'N'
99221 );
99222 --
99223 l_acc_rev_natural_side_code := 'C'; -- 4262811
99224 --
99225 --
99226 -- set accounting line type info
99227 --
99228 xla_ae_lines_pkg.SetAcctLineType
99229 (p_component_type => l_component_type
99230 ,p_event_type_code => l_event_type_code
99231 ,p_line_definition_owner_code => l_line_definition_owner_code
99232 ,p_line_definition_code => l_line_definition_code
99233 ,p_accounting_line_code => l_component_code
99234 ,p_accounting_line_type_code => l_component_type_code
99235 ,p_accounting_line_appl_id => l_component_appl_id
99236 ,p_amb_context_code => l_amb_context_code
99237 ,p_entity_code => l_entity_code
99238 ,p_event_class_code => l_event_class_code);
99239 --
99240 -- set accounting class
99241 --
99242 xla_ae_lines_pkg.SetAcctClass(
99243 p_accounting_class_code => 'INTERORG_RECEIVABLES'
99244 , p_ae_header_id => l_ae_header_id
99245 );
99246
99247 --
99248 -- set rounding class
99249 --
99250 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
99251 'INTERORG_RECEIVABLES';
99252
99253 --
99254 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
99255 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
99256 --
99257 -- bulk performance
99258 --
99259 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
99260
99261 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
99262 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
99263
99264 -- 4955764
99265 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
99266 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
99267
99268 -- 4458381 Public Sector Enh
99269
99270 --
99271 -- set accounting attributes for the line type
99272 --
99273 l_entered_amt_idx := 3;
99274 l_accted_amt_idx := 8;
99275 l_bflow_applied_to_amt_idx := NULL; -- 5132302
99276 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
99277 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
99278 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
99279 l_rec_acct_attrs.array_char_value(2) := p_source_85;
99280 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
99281 l_rec_acct_attrs.array_num_value(3) := p_source_91;
99282 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
99283 l_rec_acct_attrs.array_char_value(4) := p_source_88;
99284 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
99285 l_rec_acct_attrs.array_date_value(5) := p_source_92;
99286 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
99287 l_rec_acct_attrs.array_num_value(6) := p_source_93;
99288 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
99289 l_rec_acct_attrs.array_char_value(7) := p_source_94;
99290 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
99291 l_rec_acct_attrs.array_num_value(8) := p_source_95;
99292
99293 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
99294 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
99295
99296 ---------------------------------------------------------------------------------------------------------------
99297 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
99298 ---------------------------------------------------------------------------------------------------------------
99299 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
99300
99301 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
99302 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
99303
99304 IF xla_accounting_cache_pkg.GetValueChar
99305 (p_source_code => 'LEDGER_CATEGORY_CODE'
99306 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
99307 AND l_bflow_method_code = 'PRIOR_ENTRY'
99308 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
99309 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
99310 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
99311 )
99312 THEN
99313 xla_ae_lines_pkg.BflowUpgEntry
99314 (p_business_method_code => l_bflow_method_code
99315 ,p_business_class_code => l_bflow_class_code
99316 ,p_balance_type => l_balance_type_code);
99317 ELSE
99318 NULL;
99319 -- No business flow processing for business flow method of NONE.
99320 END IF;
99321
99322 --
99323 -- call analytical criteria
99324 --
99325
99326 --
99327 -- call description
99328 --
99329
99330 xla_ae_lines_pkg.SetLineDescription(
99331 p_ae_header_id => l_ae_header_id
99332 ,p_description => Description_1 (
99333 p_application_id => p_application_id
99334 , p_ae_header_id => l_ae_header_id
99335 , p_source_1 => p_source_1
99336 , p_source_2 => p_source_2
99337 , p_source_3 => p_source_3
99338 , p_source_4 => p_source_4
99339 , p_source_5 => p_source_5
99340 )
99341 );
99342
99343
99344 --
99345 -- call ADRs
99346 -- Bug 4922099
99347 --
99348 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
99349 (NVL(l_actual_upg_option, 'N') = 'O') OR
99350 (NVL(l_enc_upg_option, 'N') = 'O')
99351 )
99352 THEN
99353 NULL;
99354 --
99355 --
99356
99357 l_ccid := AcctDerRule_33(
99358 p_application_id => p_application_id
99359 , p_ae_header_id => l_ae_header_id
99360 , p_source_59 => p_source_59
99361 , x_transaction_coa_id => l_adr_transaction_coa_id
99362 , x_accounting_coa_id => l_adr_accounting_coa_id
99363 , x_value_type_code => l_adr_value_type_code
99364 , p_side => 'NA'
99365 );
99366
99367 xla_ae_lines_pkg.set_ccid(
99368 p_code_combination_id => l_ccid
99369 , p_value_type_code => l_adr_value_type_code
99370 , p_transaction_coa_id => l_adr_transaction_coa_id
99371 , p_accounting_coa_id => l_adr_accounting_coa_id
99372 , p_adr_code => 'PI_RECEIVABLES'
99373 , p_adr_type_code => 'S'
99374 , p_component_type => l_component_type
99375 , p_component_code => l_component_code
99376 , p_component_type_code => l_component_type_code
99377 , p_component_appl_id => l_component_appl_id
99378 , p_amb_context_code => l_amb_context_code
99379 , p_side => 'NA'
99380 );
99381
99382
99383 --
99384 --
99385 END IF;
99386 --
99387 -- Bug 4922099
99388 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
99389 (NVL(l_enc_upg_option, 'N') = 'O')
99390 ) AND
99391 (l_bflow_method_code = 'PRIOR_ENTRY')
99392 )
99393 THEN
99394 IF
99395 --
99396 1 = 2
99397 --
99398 THEN
99399 xla_accounting_err_pkg.build_message
99400 (p_appli_s_name => 'XLA'
99401 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
99402 ,p_token_1 => 'LINE_NUMBER'
99403 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
99404 ,p_token_2 => 'LINE_TYPE_NAME'
99405 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
99406 l_component_type
99407 ,l_component_code
99408 ,l_component_type_code
99409 ,l_component_appl_id
99410 ,l_amb_context_code
99411 ,l_entity_code
99412 ,l_event_class_code
99413 )
99414 ,p_token_3 => 'OWNER'
99415 ,p_value_3 => xla_lookups_pkg.get_meaning(
99416 p_lookup_type => 'XLA_OWNER_TYPE'
99417 ,p_lookup_code => l_component_type_code
99418 )
99419 ,p_token_4 => 'PRODUCT_NAME'
99420 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
99421 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
99422 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
99423 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
99424 ,p_ae_header_id => NULL
99425 );
99426
99427 IF (C_LEVEL_ERROR>= g_log_level) THEN
99428 trace
99429 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
99430 ,p_level => C_LEVEL_ERROR
99431 ,p_module => l_log_module);
99432 END IF;
99433 END IF;
99434 END IF;
99435 --
99436 --
99437 ------------------------------------------------------------------------------------------------
99438 -- 4219869 Business Flow
99439 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
99440 -- Prior Entry. Currently, the following code is always generated.
99441 ------------------------------------------------------------------------------------------------
99442 XLA_AE_LINES_PKG.ValidateCurrentLine;
99443
99444 ------------------------------------------------------------------------------------
99445 -- 4219869 Business Flow
99446 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
99447 ------------------------------------------------------------------------------------
99448 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
99449
99450 ----------------------------------------------------------------------------------
99451 -- 4219869 Business Flow
99452 -- Update journal entry status -- Need to generate this within IF <condition>
99453 ----------------------------------------------------------------------------------
99454 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
99455 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
99456 ,p_balance_type_code => l_balance_type_code
99457 );
99458
99459 -------------------------------------------------------------------------------------------
99460 -- 4262811 - Generate the Accrual Reversal lines
99461 -------------------------------------------------------------------------------------------
99462 BEGIN
99463 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
99464 (g_array_event(p_event_id).array_value_num('header_index'));
99465 IF l_acc_rev_flag IS NULL THEN
99466 l_acc_rev_flag := 'N';
99467 END IF;
99468 EXCEPTION
99469 WHEN OTHERS THEN
99470 l_acc_rev_flag := 'N';
99471 END;
99472 --
99473 IF (l_acc_rev_flag = 'Y') THEN
99474
99475 -- 4645092 ------------------------------------------------------------------------------
99476 -- To allow MPA report to determine if it should generate report process
99477 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
99478 ------------------------------------------------------------------------------------------
99479
99480 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
99481 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
99482 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
99483 -- call ADRs
99484 -- Bug 4922099
99485 --
99486 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
99487 (NVL(l_actual_upg_option, 'N') = 'O') OR
99488 (NVL(l_enc_upg_option, 'N') = 'O')
99489 )
99490 THEN
99491 NULL;
99492 --
99493 --
99494
99495 l_ccid := AcctDerRule_33(
99496 p_application_id => p_application_id
99497 , p_ae_header_id => l_ae_header_id
99498 , p_source_59 => p_source_59
99499 , x_transaction_coa_id => l_adr_transaction_coa_id
99500 , x_accounting_coa_id => l_adr_accounting_coa_id
99501 , x_value_type_code => l_adr_value_type_code
99502 , p_side => 'NA'
99503 );
99504
99505 xla_ae_lines_pkg.set_ccid(
99506 p_code_combination_id => l_ccid
99507 , p_value_type_code => l_adr_value_type_code
99508 , p_transaction_coa_id => l_adr_transaction_coa_id
99509 , p_accounting_coa_id => l_adr_accounting_coa_id
99510 , p_adr_code => 'PI_RECEIVABLES'
99511 , p_adr_type_code => 'S'
99512 , p_component_type => l_component_type
99513 , p_component_code => l_component_code
99514 , p_component_type_code => l_component_type_code
99515 , p_component_appl_id => l_component_appl_id
99516 , p_amb_context_code => l_amb_context_code
99517 , p_side => 'NA'
99518 );
99519
99520
99521 --
99522 --
99523 END IF;
99524
99525 --
99526 -- Update the line information that should be overwritten
99527 --
99528 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
99529 p_header_num => 1);
99530 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
99531
99532 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
99533
99534 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
99535 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
99536 END IF;
99537
99538 --
99539 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
99540 --
99541 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
99542 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
99543 ELSE
99544 ---------------------------------------------------------------------------------------------------
99545 -- 4262811a Switch Sign
99546 ---------------------------------------------------------------------------------------------------
99547 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
99548 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
99549 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
99550 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
99551 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
99552 -- 5132302
99553 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
99554 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
99555
99556 END IF;
99557
99558 -- 4955764
99559 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
99560 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
99561
99562
99563 XLA_AE_LINES_PKG.ValidateCurrentLine;
99564 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
99565
99566 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
99567 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
99568 ,p_balance_type_code => l_balance_type_code);
99569
99570 END IF;
99571
99572 -----------------------------------------------------------------------------------------
99573 -- 4262811 Multiperiod Accounting
99574 -----------------------------------------------------------------------------------------
99575 -- No MPA option is assigned.
99576
99577
99578 END IF;
99579 END IF;
99580 --
99581
99582 --
99583 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
99584 trace
99585 (p_msg => 'END of AcctLineType_198'
99586 ,p_level => C_LEVEL_PROCEDURE
99587 ,p_module => l_log_module);
99588 END IF;
99589 --
99590 EXCEPTION
99591 WHEN xla_exceptions_pkg.application_exception THEN
99592 RAISE;
99593 WHEN OTHERS THEN
99594 xla_exceptions_pkg.raise_message
99595 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_198');
99596 END AcctLineType_198;
99597 --
99598
99599 ---------------------------------------
99600 --
99601 -- PRIVATE FUNCTION
99602 -- AcctLineType_199
99603 --
99604 ---------------------------------------
99605 PROCEDURE AcctLineType_199 (
99606 p_application_id IN NUMBER
99607 ,p_event_id IN NUMBER
99608 ,p_calculate_acctd_flag IN VARCHAR2
99609 ,p_calculate_g_l_flag IN VARCHAR2
99610 ,p_actual_flag IN OUT VARCHAR2
99611 ,p_balance_type_code OUT VARCHAR2
99612 ,p_gain_or_loss_ref OUT VARCHAR2
99613
99614 --TRANSACTION_ID
99615 , p_source_1 IN NUMBER
99616 --Item Concatenated Segments
99617 , p_source_2 IN VARCHAR2
99618 --Transaction Quantity
99619 , p_source_3 IN NUMBER
99620 --Transaction Unit of Measure Code
99621 , p_source_4 IN VARCHAR2
99622 --Inventory Transaction Type Description
99623 , p_source_5 IN VARCHAR2
99624 --Cost Management Default Account
99625 , p_source_11 IN NUMBER
99626 --Applied to Application ID
99627 , p_source_79 IN NUMBER
99628 --Applied to Distribution Link Type
99629 , p_source_80 IN VARCHAR2
99630 --Applied to Entity Code
99631 , p_source_81 IN VARCHAR2
99632 --DISTRIBUTION_IDENTIFIER
99633 , p_source_84 IN NUMBER
99634 --Distribution Type
99635 , p_source_85 IN VARCHAR2
99636 , p_source_85_meaning IN VARCHAR2
99637 --Encumbrance Reversal Amount Entered
99638 , p_source_87 IN NUMBER
99639 --Entered Currency Code
99640 , p_source_88 IN VARCHAR2
99641 --Transaction Encumbrance Reversal Amount
99642 , p_source_89 IN NUMBER
99643 --Entered Amount
99644 , p_source_91 IN NUMBER
99645 --Currency Conversion Date
99646 , p_source_92 IN DATE
99647 --Currency Conversion Rate
99648 , p_source_93 IN NUMBER
99649 --Currency Conversion Type
99650 , p_source_94 IN VARCHAR2
99651 --Accounted Amount
99652 , p_source_95 IN NUMBER
99653 --Accounting Line Type
99654 , p_source_97 IN NUMBER
99655 --Costing Encumbrance Upgrade Option
99656 , p_source_100 IN VARCHAR2
99657 --TXN_PO_DISTRIBUTION_ID
99658 , p_source_101 IN NUMBER
99659 --TXN_PO_HEADER_ID
99660 , p_source_102 IN NUMBER
99661 --Requisition Budget Account
99662 , p_source_103 IN NUMBER
99663 --Requisition Encumbrance Type Identifier
99664 , p_source_104 IN NUMBER
99665 )
99666 IS
99667
99668 l_component_type VARCHAR2(80);
99669 l_component_code VARCHAR2(30);
99670 l_component_type_code VARCHAR2(1);
99671 l_component_appl_id INTEGER;
99672 l_amb_context_code VARCHAR2(30);
99673 l_entity_code VARCHAR2(30);
99674 l_event_class_code VARCHAR2(30);
99675 l_ae_header_id NUMBER;
99676 l_event_type_code VARCHAR2(30);
99677 l_line_definition_code VARCHAR2(30);
99678 l_line_definition_owner_code VARCHAR2(1);
99679 --
99680 -- adr variables
99681 l_segment VARCHAR2(30);
99682 l_ccid NUMBER;
99683 l_adr_transaction_coa_id NUMBER;
99684 l_adr_accounting_coa_id NUMBER;
99685 l_adr_flexfield_segment_code VARCHAR2(30);
99686 l_adr_flex_value_set_id NUMBER;
99687 l_adr_value_type_code VARCHAR2(30);
99688 l_adr_value_combination_id NUMBER;
99689 l_adr_value_segment_code VARCHAR2(30);
99690
99691 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
99692 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
99693 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
99694 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
99695
99696 -- 4262811 Variables ------------------------------------------------------------------------------------------
99697 l_entered_amt_idx NUMBER;
99698 l_accted_amt_idx NUMBER;
99699 l_acc_rev_flag VARCHAR2(1);
99700 l_accrual_line_num NUMBER;
99701 l_tmp_amt NUMBER;
99702 l_acc_rev_natural_side_code VARCHAR2(1);
99703
99704 l_num_entries NUMBER;
99705 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
99706 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
99707 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
99708 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
99709 l_recog_line_1 NUMBER;
99710 l_recog_line_2 NUMBER;
99711
99712 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
99713 l_bflow_applied_to_amt NUMBER; -- 5132302
99714 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
99715
99716 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
99717
99718 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
99719 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
99720
99721 ---------------------------------------------------------------------------------------------------------------
99722
99723
99724 --
99725 -- bulk performance
99726 --
99727 l_balance_type_code VARCHAR2(1);
99728 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
99729 l_log_module VARCHAR2(240);
99730
99731 --
99732 -- Upgrade strategy
99733 --
99734 l_actual_upg_option VARCHAR2(1);
99735 l_enc_upg_option VARCHAR2(1);
99736
99737 --
99738 BEGIN
99739 --
99740 IF g_log_enabled THEN
99741 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_199';
99742 END IF;
99743 --
99744 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
99745
99746 trace
99747 (p_msg => 'BEGIN of AcctLineType_199'
99748 ,p_level => C_LEVEL_PROCEDURE
99749 ,p_module => l_log_module);
99750
99751 END IF;
99752 --
99753 l_component_type := 'AMB_JLT';
99754 l_component_code := 'INTERORG_RECEIVABLES';
99755 l_component_type_code := 'S';
99756 l_component_appl_id := 707;
99757 l_amb_context_code := 'DEFAULT';
99758 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
99759 l_event_class_code := 'DIR_INTERORG_RCPT';
99760 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
99761 l_line_definition_owner_code := 'S';
99762 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
99763 --
99764 l_balance_type_code := 'A';
99765 l_segment := NULL;
99766 l_ccid := NULL;
99767 l_adr_transaction_coa_id := NULL;
99768 l_adr_accounting_coa_id := NULL;
99769 l_adr_flexfield_segment_code := NULL;
99770 l_adr_flex_value_set_id := NULL;
99771 l_adr_value_type_code := NULL;
99772 l_adr_value_combination_id := NULL;
99773 l_adr_value_segment_code := NULL;
99774
99775 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
99776 l_bflow_class_code := ''; -- 4219869 Business Flow
99777 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
99778 l_budgetary_control_flag := 'N';
99779
99780 l_bflow_applied_to_amt_idx := NULL; -- 5132302
99781 l_bflow_applied_to_amt := NULL; -- 5132302
99782 l_entered_amt_idx := NULL; -- 4262811
99783 l_accted_amt_idx := NULL; -- 4262811
99784 l_acc_rev_flag := NULL; -- 4262811
99785 l_accrual_line_num := NULL; -- 4262811
99786 l_tmp_amt := NULL; -- 4262811
99787 --
99788
99789 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
99790 l_balance_type_code <> 'B' THEN
99791 IF NVL(p_source_97,9E125) = 10
99792 THEN
99793
99794 --
99795 XLA_AE_LINES_PKG.SetNewLine;
99796
99797 p_balance_type_code := l_balance_type_code;
99798 -- set the flag so later we will know whether the gain loss line needs to be created
99799
99800 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
99801 p_actual_flag :='A';
99802 END IF;
99803
99804 --
99805 -- bulk performance
99806 --
99807 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
99808 p_header_num => 0); -- 4262811
99809 --
99810 -- set accounting line options
99811 --
99812 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
99813 p_natural_side_code => 'D'
99814 , p_gain_or_loss_flag => 'N'
99815 , p_gl_transfer_mode_code => 'S'
99816 , p_acct_entry_type_code => 'A'
99817 , p_switch_side_flag => 'Y'
99818 , p_merge_duplicate_code => 'N'
99819 );
99820 --
99821 l_acc_rev_natural_side_code := 'C'; -- 4262811
99822 --
99823 --
99824 -- set accounting line type info
99825 --
99826 xla_ae_lines_pkg.SetAcctLineType
99827 (p_component_type => l_component_type
99828 ,p_event_type_code => l_event_type_code
99829 ,p_line_definition_owner_code => l_line_definition_owner_code
99830 ,p_line_definition_code => l_line_definition_code
99831 ,p_accounting_line_code => l_component_code
99832 ,p_accounting_line_type_code => l_component_type_code
99833 ,p_accounting_line_appl_id => l_component_appl_id
99834 ,p_amb_context_code => l_amb_context_code
99835 ,p_entity_code => l_entity_code
99836 ,p_event_class_code => l_event_class_code);
99837 --
99838 -- set accounting class
99839 --
99840 xla_ae_lines_pkg.SetAcctClass(
99841 p_accounting_class_code => 'INTERORG_RECEIVABLES'
99842 , p_ae_header_id => l_ae_header_id
99843 );
99844
99845 --
99846 -- set rounding class
99847 --
99848 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
99849 'INTERORG_RECEIVABLES';
99850
99851 --
99852 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
99853 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
99854 --
99855 -- bulk performance
99856 --
99857 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
99858
99859 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
99860 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
99861
99862 -- 4955764
99863 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
99864 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
99865
99866 -- 4458381 Public Sector Enh
99867
99868 --
99869 -- set accounting attributes for the line type
99870 --
99871 l_entered_amt_idx := 17;
99872 l_accted_amt_idx := 22;
99873 l_bflow_applied_to_amt_idx := NULL; -- 5132302
99874 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
99875 l_rec_acct_attrs.array_num_value(1) := p_source_79;
99876 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
99877 l_rec_acct_attrs.array_char_value(2) := p_source_80;
99878 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
99879 l_rec_acct_attrs.array_char_value(3) := p_source_81;
99880 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
99881 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
99882 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
99883 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
99884 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
99885 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
99886 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
99887 l_rec_acct_attrs.array_char_value(7) := p_source_85;
99888 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
99889 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
99890 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
99891 l_rec_acct_attrs.array_num_value(9) := p_source_87;
99892 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
99893 l_rec_acct_attrs.array_char_value(10) := p_source_88;
99894 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
99895 l_rec_acct_attrs.array_num_value(11) := p_source_89;
99896 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
99897 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
99898 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
99899 l_rec_acct_attrs.array_num_value(13) := p_source_87;
99900 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
99901 l_rec_acct_attrs.array_char_value(14) := p_source_88;
99902 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
99903 l_rec_acct_attrs.array_num_value(15) := p_source_89;
99904 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
99905 l_rec_acct_attrs.array_char_value(16) := p_source_100;
99906 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
99907 l_rec_acct_attrs.array_num_value(17) := p_source_91;
99908 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
99909 l_rec_acct_attrs.array_char_value(18) := p_source_88;
99910 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
99911 l_rec_acct_attrs.array_date_value(19) := p_source_92;
99912 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
99913 l_rec_acct_attrs.array_num_value(20) := p_source_93;
99914 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
99915 l_rec_acct_attrs.array_char_value(21) := p_source_94;
99916 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
99917 l_rec_acct_attrs.array_num_value(22) := p_source_95;
99918 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
99919 l_rec_acct_attrs.array_num_value(23) := p_source_104;
99920 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
99921 l_rec_acct_attrs.array_num_value(24) := p_source_104;
99922
99923 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
99924 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
99925
99926 ---------------------------------------------------------------------------------------------------------------
99927 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
99928 ---------------------------------------------------------------------------------------------------------------
99929 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
99930
99931 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
99932 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
99933
99934 IF xla_accounting_cache_pkg.GetValueChar
99935 (p_source_code => 'LEDGER_CATEGORY_CODE'
99936 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
99937 AND l_bflow_method_code = 'PRIOR_ENTRY'
99938 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
99939 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
99940 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
99941 )
99942 THEN
99943 xla_ae_lines_pkg.BflowUpgEntry
99944 (p_business_method_code => l_bflow_method_code
99945 ,p_business_class_code => l_bflow_class_code
99946 ,p_balance_type => l_balance_type_code);
99947 ELSE
99948 NULL;
99949 -- No business flow processing for business flow method of NONE.
99950 END IF;
99951
99952 --
99953 -- call analytical criteria
99954 --
99955
99956 --
99957 -- call description
99958 --
99959
99960 xla_ae_lines_pkg.SetLineDescription(
99961 p_ae_header_id => l_ae_header_id
99962 ,p_description => Description_1 (
99963 p_application_id => p_application_id
99964 , p_ae_header_id => l_ae_header_id
99965 , p_source_1 => p_source_1
99966 , p_source_2 => p_source_2
99967 , p_source_3 => p_source_3
99968 , p_source_4 => p_source_4
99969 , p_source_5 => p_source_5
99970 )
99971 );
99972
99973
99974 --
99975 -- call ADRs
99976 -- Bug 4922099
99977 --
99978 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
99979 (NVL(l_actual_upg_option, 'N') = 'O') OR
99980 (NVL(l_enc_upg_option, 'N') = 'O')
99981 )
99982 THEN
99983 NULL;
99984 --
99985 --
99986
99987 l_ccid := AcctDerRule_6(
99988 p_application_id => p_application_id
99989 , p_ae_header_id => l_ae_header_id
99990 , p_source_11 => p_source_11
99991 , x_transaction_coa_id => l_adr_transaction_coa_id
99992 , x_accounting_coa_id => l_adr_accounting_coa_id
99993 , x_value_type_code => l_adr_value_type_code
99994 , p_side => 'NA'
99995 );
99996
99997 xla_ae_lines_pkg.set_ccid(
99998 p_code_combination_id => l_ccid
99999 , p_value_type_code => l_adr_value_type_code
100000 , p_transaction_coa_id => l_adr_transaction_coa_id
100001 , p_accounting_coa_id => l_adr_accounting_coa_id
100002 , p_adr_code => 'CST_DEFAULT'
100003 , p_adr_type_code => 'S'
100004 , p_component_type => l_component_type
100005 , p_component_code => l_component_code
100006 , p_component_type_code => l_component_type_code
100007 , p_component_appl_id => l_component_appl_id
100008 , p_amb_context_code => l_amb_context_code
100009 , p_side => 'NA'
100010 );
100011
100012
100013 --
100014 --
100015 END IF;
100016 --
100017 -- Bug 4922099
100018 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
100019 (NVL(l_enc_upg_option, 'N') = 'O')
100020 ) AND
100021 (l_bflow_method_code = 'PRIOR_ENTRY')
100022 )
100023 THEN
100024 IF
100025 --
100026 1 = 2
100027 --
100028 THEN
100029 xla_accounting_err_pkg.build_message
100030 (p_appli_s_name => 'XLA'
100031 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
100032 ,p_token_1 => 'LINE_NUMBER'
100033 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
100034 ,p_token_2 => 'LINE_TYPE_NAME'
100035 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
100036 l_component_type
100037 ,l_component_code
100038 ,l_component_type_code
100039 ,l_component_appl_id
100040 ,l_amb_context_code
100041 ,l_entity_code
100042 ,l_event_class_code
100043 )
100044 ,p_token_3 => 'OWNER'
100045 ,p_value_3 => xla_lookups_pkg.get_meaning(
100046 p_lookup_type => 'XLA_OWNER_TYPE'
100047 ,p_lookup_code => l_component_type_code
100048 )
100049 ,p_token_4 => 'PRODUCT_NAME'
100050 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
100051 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
100052 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
100053 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
100054 ,p_ae_header_id => NULL
100055 );
100056
100057 IF (C_LEVEL_ERROR>= g_log_level) THEN
100058 trace
100059 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
100060 ,p_level => C_LEVEL_ERROR
100061 ,p_module => l_log_module);
100062 END IF;
100063 END IF;
100064 END IF;
100065 --
100066 --
100067 ------------------------------------------------------------------------------------------------
100068 -- 4219869 Business Flow
100069 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
100070 -- Prior Entry. Currently, the following code is always generated.
100071 ------------------------------------------------------------------------------------------------
100072 XLA_AE_LINES_PKG.ValidateCurrentLine;
100073
100074 ------------------------------------------------------------------------------------
100075 -- 4219869 Business Flow
100076 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
100077 ------------------------------------------------------------------------------------
100078 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
100079
100080 ----------------------------------------------------------------------------------
100081 -- 4219869 Business Flow
100082 -- Update journal entry status -- Need to generate this within IF <condition>
100083 ----------------------------------------------------------------------------------
100084 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
100085 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
100086 ,p_balance_type_code => l_balance_type_code
100087 );
100088
100089 -------------------------------------------------------------------------------------------
100090 -- 4262811 - Generate the Accrual Reversal lines
100091 -------------------------------------------------------------------------------------------
100092 BEGIN
100093 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
100094 (g_array_event(p_event_id).array_value_num('header_index'));
100095 IF l_acc_rev_flag IS NULL THEN
100096 l_acc_rev_flag := 'N';
100097 END IF;
100098 EXCEPTION
100099 WHEN OTHERS THEN
100100 l_acc_rev_flag := 'N';
100101 END;
100102 --
100103 IF (l_acc_rev_flag = 'Y') THEN
100104
100105 -- 4645092 ------------------------------------------------------------------------------
100106 -- To allow MPA report to determine if it should generate report process
100107 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
100108 ------------------------------------------------------------------------------------------
100109
100110 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
100111 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
100112 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
100113 -- call ADRs
100114 -- Bug 4922099
100115 --
100116 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
100117 (NVL(l_actual_upg_option, 'N') = 'O') OR
100118 (NVL(l_enc_upg_option, 'N') = 'O')
100119 )
100120 THEN
100121 NULL;
100122 --
100123 --
100124
100125 l_ccid := AcctDerRule_6(
100126 p_application_id => p_application_id
100127 , p_ae_header_id => l_ae_header_id
100128 , p_source_11 => p_source_11
100129 , x_transaction_coa_id => l_adr_transaction_coa_id
100130 , x_accounting_coa_id => l_adr_accounting_coa_id
100131 , x_value_type_code => l_adr_value_type_code
100132 , p_side => 'NA'
100133 );
100134
100135 xla_ae_lines_pkg.set_ccid(
100136 p_code_combination_id => l_ccid
100137 , p_value_type_code => l_adr_value_type_code
100138 , p_transaction_coa_id => l_adr_transaction_coa_id
100139 , p_accounting_coa_id => l_adr_accounting_coa_id
100140 , p_adr_code => 'CST_DEFAULT'
100141 , p_adr_type_code => 'S'
100142 , p_component_type => l_component_type
100143 , p_component_code => l_component_code
100144 , p_component_type_code => l_component_type_code
100145 , p_component_appl_id => l_component_appl_id
100146 , p_amb_context_code => l_amb_context_code
100147 , p_side => 'NA'
100148 );
100149
100150
100151 --
100152 --
100153 END IF;
100154
100155 --
100156 -- Update the line information that should be overwritten
100157 --
100158 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
100159 p_header_num => 1);
100160 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
100161
100162 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
100163
100164 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
100165 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
100166 END IF;
100167
100168 --
100169 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
100170 --
100171 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
100172 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
100173 ELSE
100174 ---------------------------------------------------------------------------------------------------
100175 -- 4262811a Switch Sign
100176 ---------------------------------------------------------------------------------------------------
100177 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
100178 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
100179 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100180 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
100181 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100182 -- 5132302
100183 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
100184 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100185
100186 END IF;
100187
100188 -- 4955764
100189 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
100190 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
100191
100192
100193 XLA_AE_LINES_PKG.ValidateCurrentLine;
100194 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
100195
100196 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
100197 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
100198 ,p_balance_type_code => l_balance_type_code);
100199
100200 END IF;
100201
100202 -----------------------------------------------------------------------------------------
100203 -- 4262811 Multiperiod Accounting
100204 -----------------------------------------------------------------------------------------
100205 -- No MPA option is assigned.
100206
100207
100208 END IF;
100209 END IF;
100210 --
100211
100212 --
100213 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
100214 trace
100215 (p_msg => 'END of AcctLineType_199'
100216 ,p_level => C_LEVEL_PROCEDURE
100217 ,p_module => l_log_module);
100218 END IF;
100219 --
100220 EXCEPTION
100221 WHEN xla_exceptions_pkg.application_exception THEN
100222 RAISE;
100223 WHEN OTHERS THEN
100224 xla_exceptions_pkg.raise_message
100225 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_199');
100226 END AcctLineType_199;
100227 --
100228
100229 ---------------------------------------
100230 --
100231 -- PRIVATE FUNCTION
100232 -- AcctLineType_200
100233 --
100234 ---------------------------------------
100235 PROCEDURE AcctLineType_200 (
100236 p_application_id IN NUMBER
100237 ,p_event_id IN NUMBER
100238 ,p_calculate_acctd_flag IN VARCHAR2
100239 ,p_calculate_g_l_flag IN VARCHAR2
100240 ,p_actual_flag IN OUT VARCHAR2
100241 ,p_balance_type_code OUT VARCHAR2
100242 ,p_gain_or_loss_ref OUT VARCHAR2
100243
100244 --TRANSACTION_ID
100245 , p_source_1 IN NUMBER
100246 --Item Concatenated Segments
100247 , p_source_2 IN VARCHAR2
100248 --Transaction Quantity
100249 , p_source_3 IN NUMBER
100250 --Transaction Unit of Measure Code
100251 , p_source_4 IN VARCHAR2
100252 --Inventory Transaction Type Description
100253 , p_source_5 IN VARCHAR2
100254 --Interorg Receivables Account
100255 , p_source_59 IN NUMBER
100256 --DISTRIBUTION_IDENTIFIER
100257 , p_source_84 IN NUMBER
100258 --Distribution Type
100259 , p_source_85 IN VARCHAR2
100260 , p_source_85_meaning IN VARCHAR2
100261 --Entered Currency Code
100262 , p_source_88 IN VARCHAR2
100263 --Entered Amount
100264 , p_source_91 IN NUMBER
100265 --Currency Conversion Date
100266 , p_source_92 IN DATE
100267 --Currency Conversion Rate
100268 , p_source_93 IN NUMBER
100269 --Currency Conversion Type
100270 , p_source_94 IN VARCHAR2
100271 --Accounted Amount
100272 , p_source_95 IN NUMBER
100273 --Accounting Line Type
100274 , p_source_97 IN NUMBER
100275 )
100276 IS
100277
100278 l_component_type VARCHAR2(80);
100279 l_component_code VARCHAR2(30);
100280 l_component_type_code VARCHAR2(1);
100281 l_component_appl_id INTEGER;
100282 l_amb_context_code VARCHAR2(30);
100283 l_entity_code VARCHAR2(30);
100284 l_event_class_code VARCHAR2(30);
100285 l_ae_header_id NUMBER;
100286 l_event_type_code VARCHAR2(30);
100287 l_line_definition_code VARCHAR2(30);
100288 l_line_definition_owner_code VARCHAR2(1);
100289 --
100290 -- adr variables
100291 l_segment VARCHAR2(30);
100292 l_ccid NUMBER;
100293 l_adr_transaction_coa_id NUMBER;
100294 l_adr_accounting_coa_id NUMBER;
100295 l_adr_flexfield_segment_code VARCHAR2(30);
100296 l_adr_flex_value_set_id NUMBER;
100297 l_adr_value_type_code VARCHAR2(30);
100298 l_adr_value_combination_id NUMBER;
100299 l_adr_value_segment_code VARCHAR2(30);
100300
100301 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
100302 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
100303 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
100304 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
100305
100306 -- 4262811 Variables ------------------------------------------------------------------------------------------
100307 l_entered_amt_idx NUMBER;
100308 l_accted_amt_idx NUMBER;
100309 l_acc_rev_flag VARCHAR2(1);
100310 l_accrual_line_num NUMBER;
100311 l_tmp_amt NUMBER;
100312 l_acc_rev_natural_side_code VARCHAR2(1);
100313
100314 l_num_entries NUMBER;
100315 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
100316 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
100317 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
100318 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
100319 l_recog_line_1 NUMBER;
100320 l_recog_line_2 NUMBER;
100321
100322 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
100323 l_bflow_applied_to_amt NUMBER; -- 5132302
100324 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
100325
100326 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
100327
100328 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
100329 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
100330
100331 ---------------------------------------------------------------------------------------------------------------
100332
100333
100334 --
100335 -- bulk performance
100336 --
100337 l_balance_type_code VARCHAR2(1);
100338 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
100339 l_log_module VARCHAR2(240);
100340
100341 --
100342 -- Upgrade strategy
100343 --
100344 l_actual_upg_option VARCHAR2(1);
100345 l_enc_upg_option VARCHAR2(1);
100346
100347 --
100348 BEGIN
100349 --
100350 IF g_log_enabled THEN
100351 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_200';
100352 END IF;
100353 --
100354 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
100355
100356 trace
100357 (p_msg => 'BEGIN of AcctLineType_200'
100358 ,p_level => C_LEVEL_PROCEDURE
100359 ,p_module => l_log_module);
100360
100361 END IF;
100362 --
100363 l_component_type := 'AMB_JLT';
100364 l_component_code := 'INTERORG_RECEIVABLES';
100365 l_component_type_code := 'S';
100366 l_component_appl_id := 707;
100367 l_amb_context_code := 'DEFAULT';
100368 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
100369 l_event_class_code := 'USER_DEFINE';
100370 l_event_type_code := 'UDIR_INTERORG_RCPT';
100371 l_line_definition_owner_code := 'S';
100372 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
100373 --
100374 l_balance_type_code := 'A';
100375 l_segment := NULL;
100376 l_ccid := NULL;
100377 l_adr_transaction_coa_id := NULL;
100378 l_adr_accounting_coa_id := NULL;
100379 l_adr_flexfield_segment_code := NULL;
100380 l_adr_flex_value_set_id := NULL;
100381 l_adr_value_type_code := NULL;
100382 l_adr_value_combination_id := NULL;
100383 l_adr_value_segment_code := NULL;
100384
100385 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
100386 l_bflow_class_code := ''; -- 4219869 Business Flow
100387 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
100388 l_budgetary_control_flag := 'N';
100389
100390 l_bflow_applied_to_amt_idx := NULL; -- 5132302
100391 l_bflow_applied_to_amt := NULL; -- 5132302
100392 l_entered_amt_idx := NULL; -- 4262811
100393 l_accted_amt_idx := NULL; -- 4262811
100394 l_acc_rev_flag := NULL; -- 4262811
100395 l_accrual_line_num := NULL; -- 4262811
100396 l_tmp_amt := NULL; -- 4262811
100397 --
100398
100399 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
100400 l_balance_type_code <> 'B' THEN
100401 IF NVL(p_source_97,9E125) = 10
100402 THEN
100403
100404 --
100405 XLA_AE_LINES_PKG.SetNewLine;
100406
100407 p_balance_type_code := l_balance_type_code;
100408 -- set the flag so later we will know whether the gain loss line needs to be created
100409
100410 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
100411 p_actual_flag :='A';
100412 END IF;
100413
100414 --
100415 -- bulk performance
100416 --
100417 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
100418 p_header_num => 0); -- 4262811
100419 --
100420 -- set accounting line options
100421 --
100422 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
100423 p_natural_side_code => 'D'
100424 , p_gain_or_loss_flag => 'N'
100425 , p_gl_transfer_mode_code => 'S'
100426 , p_acct_entry_type_code => 'A'
100427 , p_switch_side_flag => 'Y'
100428 , p_merge_duplicate_code => 'N'
100429 );
100430 --
100431 l_acc_rev_natural_side_code := 'C'; -- 4262811
100432 --
100433 --
100434 -- set accounting line type info
100435 --
100436 xla_ae_lines_pkg.SetAcctLineType
100437 (p_component_type => l_component_type
100438 ,p_event_type_code => l_event_type_code
100439 ,p_line_definition_owner_code => l_line_definition_owner_code
100440 ,p_line_definition_code => l_line_definition_code
100441 ,p_accounting_line_code => l_component_code
100442 ,p_accounting_line_type_code => l_component_type_code
100443 ,p_accounting_line_appl_id => l_component_appl_id
100444 ,p_amb_context_code => l_amb_context_code
100445 ,p_entity_code => l_entity_code
100446 ,p_event_class_code => l_event_class_code);
100447 --
100448 -- set accounting class
100449 --
100450 xla_ae_lines_pkg.SetAcctClass(
100451 p_accounting_class_code => 'INTERORG_RECEIVABLES'
100452 , p_ae_header_id => l_ae_header_id
100453 );
100454
100455 --
100456 -- set rounding class
100457 --
100458 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
100459 'INTERORG_RECEIVABLES';
100460
100461 --
100462 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
100463 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
100464 --
100465 -- bulk performance
100466 --
100467 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
100468
100469 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
100470 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
100471
100472 -- 4955764
100473 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
100474 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
100475
100476 -- 4458381 Public Sector Enh
100477
100478 --
100479 -- set accounting attributes for the line type
100480 --
100481 l_entered_amt_idx := 3;
100482 l_accted_amt_idx := 8;
100483 l_bflow_applied_to_amt_idx := NULL; -- 5132302
100484 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
100485 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
100486 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
100487 l_rec_acct_attrs.array_char_value(2) := p_source_85;
100488 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
100489 l_rec_acct_attrs.array_num_value(3) := p_source_91;
100490 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
100491 l_rec_acct_attrs.array_char_value(4) := p_source_88;
100492 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
100493 l_rec_acct_attrs.array_date_value(5) := p_source_92;
100494 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
100495 l_rec_acct_attrs.array_num_value(6) := p_source_93;
100496 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
100497 l_rec_acct_attrs.array_char_value(7) := p_source_94;
100498 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
100499 l_rec_acct_attrs.array_num_value(8) := p_source_95;
100500
100501 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
100502 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
100503
100504 ---------------------------------------------------------------------------------------------------------------
100505 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
100506 ---------------------------------------------------------------------------------------------------------------
100507 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
100508
100509 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
100510 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
100511
100512 IF xla_accounting_cache_pkg.GetValueChar
100513 (p_source_code => 'LEDGER_CATEGORY_CODE'
100514 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
100515 AND l_bflow_method_code = 'PRIOR_ENTRY'
100516 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
100517 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
100518 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
100519 )
100520 THEN
100521 xla_ae_lines_pkg.BflowUpgEntry
100522 (p_business_method_code => l_bflow_method_code
100523 ,p_business_class_code => l_bflow_class_code
100524 ,p_balance_type => l_balance_type_code);
100525 ELSE
100526 NULL;
100527 -- No business flow processing for business flow method of NONE.
100528 END IF;
100529
100530 --
100531 -- call analytical criteria
100532 --
100533
100534 --
100535 -- call description
100536 --
100537
100538 xla_ae_lines_pkg.SetLineDescription(
100539 p_ae_header_id => l_ae_header_id
100540 ,p_description => Description_1 (
100541 p_application_id => p_application_id
100542 , p_ae_header_id => l_ae_header_id
100543 , p_source_1 => p_source_1
100544 , p_source_2 => p_source_2
100545 , p_source_3 => p_source_3
100546 , p_source_4 => p_source_4
100547 , p_source_5 => p_source_5
100548 )
100549 );
100550
100551
100552 --
100553 -- call ADRs
100554 -- Bug 4922099
100555 --
100556 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
100557 (NVL(l_actual_upg_option, 'N') = 'O') OR
100558 (NVL(l_enc_upg_option, 'N') = 'O')
100559 )
100560 THEN
100561 NULL;
100562 --
100563 --
100564
100565 l_ccid := AcctDerRule_33(
100566 p_application_id => p_application_id
100567 , p_ae_header_id => l_ae_header_id
100568 , p_source_59 => p_source_59
100569 , x_transaction_coa_id => l_adr_transaction_coa_id
100570 , x_accounting_coa_id => l_adr_accounting_coa_id
100571 , x_value_type_code => l_adr_value_type_code
100572 , p_side => 'NA'
100573 );
100574
100575 xla_ae_lines_pkg.set_ccid(
100576 p_code_combination_id => l_ccid
100577 , p_value_type_code => l_adr_value_type_code
100578 , p_transaction_coa_id => l_adr_transaction_coa_id
100579 , p_accounting_coa_id => l_adr_accounting_coa_id
100580 , p_adr_code => 'PI_RECEIVABLES'
100581 , p_adr_type_code => 'S'
100582 , p_component_type => l_component_type
100583 , p_component_code => l_component_code
100584 , p_component_type_code => l_component_type_code
100585 , p_component_appl_id => l_component_appl_id
100586 , p_amb_context_code => l_amb_context_code
100587 , p_side => 'NA'
100588 );
100589
100590
100591 --
100592 --
100593 END IF;
100594 --
100595 -- Bug 4922099
100596 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
100597 (NVL(l_enc_upg_option, 'N') = 'O')
100598 ) AND
100599 (l_bflow_method_code = 'PRIOR_ENTRY')
100600 )
100601 THEN
100602 IF
100603 --
100604 1 = 2
100605 --
100606 THEN
100607 xla_accounting_err_pkg.build_message
100608 (p_appli_s_name => 'XLA'
100609 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
100610 ,p_token_1 => 'LINE_NUMBER'
100611 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
100612 ,p_token_2 => 'LINE_TYPE_NAME'
100613 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
100614 l_component_type
100615 ,l_component_code
100616 ,l_component_type_code
100617 ,l_component_appl_id
100618 ,l_amb_context_code
100619 ,l_entity_code
100620 ,l_event_class_code
100621 )
100622 ,p_token_3 => 'OWNER'
100623 ,p_value_3 => xla_lookups_pkg.get_meaning(
100624 p_lookup_type => 'XLA_OWNER_TYPE'
100625 ,p_lookup_code => l_component_type_code
100626 )
100627 ,p_token_4 => 'PRODUCT_NAME'
100628 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
100629 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
100630 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
100631 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
100632 ,p_ae_header_id => NULL
100633 );
100634
100635 IF (C_LEVEL_ERROR>= g_log_level) THEN
100636 trace
100637 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
100638 ,p_level => C_LEVEL_ERROR
100639 ,p_module => l_log_module);
100640 END IF;
100641 END IF;
100642 END IF;
100643 --
100644 --
100645 ------------------------------------------------------------------------------------------------
100646 -- 4219869 Business Flow
100647 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
100648 -- Prior Entry. Currently, the following code is always generated.
100649 ------------------------------------------------------------------------------------------------
100650 XLA_AE_LINES_PKG.ValidateCurrentLine;
100651
100652 ------------------------------------------------------------------------------------
100653 -- 4219869 Business Flow
100654 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
100655 ------------------------------------------------------------------------------------
100656 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
100657
100658 ----------------------------------------------------------------------------------
100659 -- 4219869 Business Flow
100660 -- Update journal entry status -- Need to generate this within IF <condition>
100661 ----------------------------------------------------------------------------------
100662 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
100663 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
100664 ,p_balance_type_code => l_balance_type_code
100665 );
100666
100667 -------------------------------------------------------------------------------------------
100668 -- 4262811 - Generate the Accrual Reversal lines
100669 -------------------------------------------------------------------------------------------
100670 BEGIN
100671 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
100672 (g_array_event(p_event_id).array_value_num('header_index'));
100673 IF l_acc_rev_flag IS NULL THEN
100674 l_acc_rev_flag := 'N';
100675 END IF;
100676 EXCEPTION
100677 WHEN OTHERS THEN
100678 l_acc_rev_flag := 'N';
100679 END;
100680 --
100681 IF (l_acc_rev_flag = 'Y') THEN
100682
100683 -- 4645092 ------------------------------------------------------------------------------
100684 -- To allow MPA report to determine if it should generate report process
100685 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
100686 ------------------------------------------------------------------------------------------
100687
100688 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
100689 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
100690 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
100691 -- call ADRs
100692 -- Bug 4922099
100693 --
100694 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
100695 (NVL(l_actual_upg_option, 'N') = 'O') OR
100696 (NVL(l_enc_upg_option, 'N') = 'O')
100697 )
100698 THEN
100699 NULL;
100700 --
100701 --
100702
100703 l_ccid := AcctDerRule_33(
100704 p_application_id => p_application_id
100705 , p_ae_header_id => l_ae_header_id
100706 , p_source_59 => p_source_59
100707 , x_transaction_coa_id => l_adr_transaction_coa_id
100708 , x_accounting_coa_id => l_adr_accounting_coa_id
100709 , x_value_type_code => l_adr_value_type_code
100710 , p_side => 'NA'
100711 );
100712
100713 xla_ae_lines_pkg.set_ccid(
100714 p_code_combination_id => l_ccid
100715 , p_value_type_code => l_adr_value_type_code
100716 , p_transaction_coa_id => l_adr_transaction_coa_id
100717 , p_accounting_coa_id => l_adr_accounting_coa_id
100718 , p_adr_code => 'PI_RECEIVABLES'
100719 , p_adr_type_code => 'S'
100720 , p_component_type => l_component_type
100721 , p_component_code => l_component_code
100722 , p_component_type_code => l_component_type_code
100723 , p_component_appl_id => l_component_appl_id
100724 , p_amb_context_code => l_amb_context_code
100725 , p_side => 'NA'
100726 );
100727
100728
100729 --
100730 --
100731 END IF;
100732
100733 --
100734 -- Update the line information that should be overwritten
100735 --
100736 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
100737 p_header_num => 1);
100738 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
100739
100740 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
100741
100742 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
100743 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
100744 END IF;
100745
100746 --
100747 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
100748 --
100749 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
100750 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
100751 ELSE
100752 ---------------------------------------------------------------------------------------------------
100753 -- 4262811a Switch Sign
100754 ---------------------------------------------------------------------------------------------------
100755 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
100756 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
100757 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100758 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
100759 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100760 -- 5132302
100761 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
100762 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
100763
100764 END IF;
100765
100766 -- 4955764
100767 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
100768 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
100769
100770
100771 XLA_AE_LINES_PKG.ValidateCurrentLine;
100772 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
100773
100774 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
100775 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
100776 ,p_balance_type_code => l_balance_type_code);
100777
100778 END IF;
100779
100780 -----------------------------------------------------------------------------------------
100781 -- 4262811 Multiperiod Accounting
100782 -----------------------------------------------------------------------------------------
100783 -- No MPA option is assigned.
100784
100785
100786 END IF;
100787 END IF;
100788 --
100789
100790 --
100791 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
100792 trace
100793 (p_msg => 'END of AcctLineType_200'
100794 ,p_level => C_LEVEL_PROCEDURE
100795 ,p_module => l_log_module);
100796 END IF;
100797 --
100798 EXCEPTION
100799 WHEN xla_exceptions_pkg.application_exception THEN
100800 RAISE;
100801 WHEN OTHERS THEN
100802 xla_exceptions_pkg.raise_message
100803 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_200');
100804 END AcctLineType_200;
100805 --
100806
100807 ---------------------------------------
100808 --
100809 -- PRIVATE FUNCTION
100810 -- AcctLineType_201
100811 --
100812 ---------------------------------------
100813 PROCEDURE AcctLineType_201 (
100814 p_application_id IN NUMBER
100815 ,p_event_id IN NUMBER
100816 ,p_calculate_acctd_flag IN VARCHAR2
100817 ,p_calculate_g_l_flag IN VARCHAR2
100818 ,p_actual_flag IN OUT VARCHAR2
100819 ,p_balance_type_code OUT VARCHAR2
100820 ,p_gain_or_loss_ref OUT VARCHAR2
100821
100822 --TRANSACTION_ID
100823 , p_source_1 IN NUMBER
100824 --Item Concatenated Segments
100825 , p_source_2 IN VARCHAR2
100826 --Transaction Quantity
100827 , p_source_3 IN NUMBER
100828 --Transaction Unit of Measure Code
100829 , p_source_4 IN VARCHAR2
100830 --Inventory Transaction Type Description
100831 , p_source_5 IN VARCHAR2
100832 --Cost Management Default Account
100833 , p_source_11 IN NUMBER
100834 --DISTRIBUTION_IDENTIFIER
100835 , p_source_84 IN NUMBER
100836 --Distribution Type
100837 , p_source_85 IN VARCHAR2
100838 , p_source_85_meaning IN VARCHAR2
100839 --Entered Currency Code
100840 , p_source_88 IN VARCHAR2
100841 --Entered Amount
100842 , p_source_91 IN NUMBER
100843 --Currency Conversion Date
100844 , p_source_92 IN DATE
100845 --Currency Conversion Rate
100846 , p_source_93 IN NUMBER
100847 --Currency Conversion Type
100848 , p_source_94 IN VARCHAR2
100849 --Accounted Amount
100850 , p_source_95 IN NUMBER
100851 --Accounting Line Type
100852 , p_source_97 IN NUMBER
100853 )
100854 IS
100855
100856 l_component_type VARCHAR2(80);
100857 l_component_code VARCHAR2(30);
100858 l_component_type_code VARCHAR2(1);
100859 l_component_appl_id INTEGER;
100860 l_amb_context_code VARCHAR2(30);
100861 l_entity_code VARCHAR2(30);
100862 l_event_class_code VARCHAR2(30);
100863 l_ae_header_id NUMBER;
100864 l_event_type_code VARCHAR2(30);
100865 l_line_definition_code VARCHAR2(30);
100866 l_line_definition_owner_code VARCHAR2(1);
100867 --
100868 -- adr variables
100869 l_segment VARCHAR2(30);
100870 l_ccid NUMBER;
100871 l_adr_transaction_coa_id NUMBER;
100872 l_adr_accounting_coa_id NUMBER;
100873 l_adr_flexfield_segment_code VARCHAR2(30);
100874 l_adr_flex_value_set_id NUMBER;
100875 l_adr_value_type_code VARCHAR2(30);
100876 l_adr_value_combination_id NUMBER;
100877 l_adr_value_segment_code VARCHAR2(30);
100878
100879 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
100880 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
100881 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
100882 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
100883
100884 -- 4262811 Variables ------------------------------------------------------------------------------------------
100885 l_entered_amt_idx NUMBER;
100886 l_accted_amt_idx NUMBER;
100887 l_acc_rev_flag VARCHAR2(1);
100888 l_accrual_line_num NUMBER;
100889 l_tmp_amt NUMBER;
100890 l_acc_rev_natural_side_code VARCHAR2(1);
100891
100892 l_num_entries NUMBER;
100893 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
100894 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
100895 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
100896 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
100897 l_recog_line_1 NUMBER;
100898 l_recog_line_2 NUMBER;
100899
100900 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
100901 l_bflow_applied_to_amt NUMBER; -- 5132302
100902 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
100903
100904 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
100905
100906 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
100907 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
100908
100909 ---------------------------------------------------------------------------------------------------------------
100910
100911
100912 --
100913 -- bulk performance
100914 --
100915 l_balance_type_code VARCHAR2(1);
100916 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
100917 l_log_module VARCHAR2(240);
100918
100919 --
100920 -- Upgrade strategy
100921 --
100922 l_actual_upg_option VARCHAR2(1);
100923 l_enc_upg_option VARCHAR2(1);
100924
100925 --
100926 BEGIN
100927 --
100928 IF g_log_enabled THEN
100929 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_201';
100930 END IF;
100931 --
100932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
100933
100934 trace
100935 (p_msg => 'BEGIN of AcctLineType_201'
100936 ,p_level => C_LEVEL_PROCEDURE
100937 ,p_module => l_log_module);
100938
100939 END IF;
100940 --
100941 l_component_type := 'AMB_JLT';
100942 l_component_code := 'INTERORG_RECEIVABLES';
100943 l_component_type_code := 'S';
100944 l_component_appl_id := 707;
100945 l_amb_context_code := 'DEFAULT';
100946 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
100947 l_event_class_code := 'INT_ORDER_TO_EXP';
100948 l_event_type_code := 'EXP_REQ_RCPT_NO_TP';
100949 l_line_definition_owner_code := 'S';
100950 l_line_definition_code := 'PI_EXP_REQ_RCPT_NO_TP';
100951 --
100952 l_balance_type_code := 'A';
100953 l_segment := NULL;
100954 l_ccid := NULL;
100955 l_adr_transaction_coa_id := NULL;
100956 l_adr_accounting_coa_id := NULL;
100957 l_adr_flexfield_segment_code := NULL;
100958 l_adr_flex_value_set_id := NULL;
100959 l_adr_value_type_code := NULL;
100960 l_adr_value_combination_id := NULL;
100961 l_adr_value_segment_code := NULL;
100962
100963 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
100964 l_bflow_class_code := ''; -- 4219869 Business Flow
100965 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
100966 l_budgetary_control_flag := 'N';
100967
100968 l_bflow_applied_to_amt_idx := NULL; -- 5132302
100969 l_bflow_applied_to_amt := NULL; -- 5132302
100970 l_entered_amt_idx := NULL; -- 4262811
100971 l_accted_amt_idx := NULL; -- 4262811
100972 l_acc_rev_flag := NULL; -- 4262811
100973 l_accrual_line_num := NULL; -- 4262811
100974 l_tmp_amt := NULL; -- 4262811
100975 --
100976
100977 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
100978 l_balance_type_code <> 'B' THEN
100979 IF NVL(p_source_97,9E125) = 10
100980 THEN
100981
100982 --
100983 XLA_AE_LINES_PKG.SetNewLine;
100984
100985 p_balance_type_code := l_balance_type_code;
100986 -- set the flag so later we will know whether the gain loss line needs to be created
100987
100988 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
100989 p_actual_flag :='A';
100990 END IF;
100991
100992 --
100993 -- bulk performance
100994 --
100995 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
100996 p_header_num => 0); -- 4262811
100997 --
100998 -- set accounting line options
100999 --
101000 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
101001 p_natural_side_code => 'D'
101002 , p_gain_or_loss_flag => 'N'
101003 , p_gl_transfer_mode_code => 'S'
101004 , p_acct_entry_type_code => 'A'
101005 , p_switch_side_flag => 'Y'
101006 , p_merge_duplicate_code => 'N'
101007 );
101008 --
101009 l_acc_rev_natural_side_code := 'C'; -- 4262811
101010 --
101011 --
101012 -- set accounting line type info
101013 --
101014 xla_ae_lines_pkg.SetAcctLineType
101015 (p_component_type => l_component_type
101016 ,p_event_type_code => l_event_type_code
101017 ,p_line_definition_owner_code => l_line_definition_owner_code
101018 ,p_line_definition_code => l_line_definition_code
101019 ,p_accounting_line_code => l_component_code
101020 ,p_accounting_line_type_code => l_component_type_code
101021 ,p_accounting_line_appl_id => l_component_appl_id
101022 ,p_amb_context_code => l_amb_context_code
101023 ,p_entity_code => l_entity_code
101024 ,p_event_class_code => l_event_class_code);
101025 --
101026 -- set accounting class
101027 --
101028 xla_ae_lines_pkg.SetAcctClass(
101029 p_accounting_class_code => 'INTERORG_RECEIVABLES'
101030 , p_ae_header_id => l_ae_header_id
101031 );
101032
101033 --
101034 -- set rounding class
101035 --
101036 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
101037 'INTERORG_RECEIVABLES';
101038
101039 --
101040 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
101041 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
101042 --
101043 -- bulk performance
101044 --
101045 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
101046
101047 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
101048 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
101049
101050 -- 4955764
101051 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
101052 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
101053
101054 -- 4458381 Public Sector Enh
101055
101056 --
101057 -- set accounting attributes for the line type
101058 --
101059 l_entered_amt_idx := 3;
101060 l_accted_amt_idx := 8;
101061 l_bflow_applied_to_amt_idx := NULL; -- 5132302
101062 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
101063 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
101064 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
101065 l_rec_acct_attrs.array_char_value(2) := p_source_85;
101066 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
101067 l_rec_acct_attrs.array_num_value(3) := p_source_91;
101068 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
101069 l_rec_acct_attrs.array_char_value(4) := p_source_88;
101070 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
101071 l_rec_acct_attrs.array_date_value(5) := p_source_92;
101072 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
101073 l_rec_acct_attrs.array_num_value(6) := p_source_93;
101074 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
101075 l_rec_acct_attrs.array_char_value(7) := p_source_94;
101076 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
101077 l_rec_acct_attrs.array_num_value(8) := p_source_95;
101078
101079 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
101080 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
101081
101082 ---------------------------------------------------------------------------------------------------------------
101083 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
101084 ---------------------------------------------------------------------------------------------------------------
101085 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
101086
101087 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
101088 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
101089
101090 IF xla_accounting_cache_pkg.GetValueChar
101091 (p_source_code => 'LEDGER_CATEGORY_CODE'
101092 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
101093 AND l_bflow_method_code = 'PRIOR_ENTRY'
101094 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
101095 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
101096 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
101097 )
101098 THEN
101099 xla_ae_lines_pkg.BflowUpgEntry
101100 (p_business_method_code => l_bflow_method_code
101101 ,p_business_class_code => l_bflow_class_code
101102 ,p_balance_type => l_balance_type_code);
101103 ELSE
101104 NULL;
101105 -- No business flow processing for business flow method of NONE.
101106 END IF;
101107
101108 --
101109 -- call analytical criteria
101110 --
101111
101112 --
101113 -- call description
101114 --
101115
101116 xla_ae_lines_pkg.SetLineDescription(
101117 p_ae_header_id => l_ae_header_id
101118 ,p_description => Description_1 (
101119 p_application_id => p_application_id
101120 , p_ae_header_id => l_ae_header_id
101121 , p_source_1 => p_source_1
101122 , p_source_2 => p_source_2
101123 , p_source_3 => p_source_3
101124 , p_source_4 => p_source_4
101125 , p_source_5 => p_source_5
101126 )
101127 );
101128
101129
101130 --
101131 -- call ADRs
101132 -- Bug 4922099
101133 --
101134 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
101135 (NVL(l_actual_upg_option, 'N') = 'O') OR
101136 (NVL(l_enc_upg_option, 'N') = 'O')
101137 )
101138 THEN
101139 NULL;
101140 --
101141 --
101142
101143 l_ccid := AcctDerRule_6(
101144 p_application_id => p_application_id
101145 , p_ae_header_id => l_ae_header_id
101146 , p_source_11 => p_source_11
101147 , x_transaction_coa_id => l_adr_transaction_coa_id
101148 , x_accounting_coa_id => l_adr_accounting_coa_id
101149 , x_value_type_code => l_adr_value_type_code
101150 , p_side => 'NA'
101151 );
101152
101153 xla_ae_lines_pkg.set_ccid(
101154 p_code_combination_id => l_ccid
101155 , p_value_type_code => l_adr_value_type_code
101156 , p_transaction_coa_id => l_adr_transaction_coa_id
101157 , p_accounting_coa_id => l_adr_accounting_coa_id
101158 , p_adr_code => 'CST_DEFAULT'
101159 , p_adr_type_code => 'S'
101160 , p_component_type => l_component_type
101161 , p_component_code => l_component_code
101162 , p_component_type_code => l_component_type_code
101163 , p_component_appl_id => l_component_appl_id
101164 , p_amb_context_code => l_amb_context_code
101165 , p_side => 'NA'
101166 );
101167
101168
101169 --
101170 --
101171 END IF;
101172 --
101173 -- Bug 4922099
101174 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
101175 (NVL(l_enc_upg_option, 'N') = 'O')
101176 ) AND
101177 (l_bflow_method_code = 'PRIOR_ENTRY')
101178 )
101179 THEN
101180 IF
101181 --
101182 1 = 2
101183 --
101184 THEN
101185 xla_accounting_err_pkg.build_message
101186 (p_appli_s_name => 'XLA'
101187 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
101188 ,p_token_1 => 'LINE_NUMBER'
101189 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
101190 ,p_token_2 => 'LINE_TYPE_NAME'
101191 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
101192 l_component_type
101193 ,l_component_code
101194 ,l_component_type_code
101195 ,l_component_appl_id
101196 ,l_amb_context_code
101197 ,l_entity_code
101198 ,l_event_class_code
101199 )
101200 ,p_token_3 => 'OWNER'
101201 ,p_value_3 => xla_lookups_pkg.get_meaning(
101202 p_lookup_type => 'XLA_OWNER_TYPE'
101203 ,p_lookup_code => l_component_type_code
101204 )
101205 ,p_token_4 => 'PRODUCT_NAME'
101206 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
101207 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
101208 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
101209 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
101210 ,p_ae_header_id => NULL
101211 );
101212
101213 IF (C_LEVEL_ERROR>= g_log_level) THEN
101214 trace
101215 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
101216 ,p_level => C_LEVEL_ERROR
101217 ,p_module => l_log_module);
101218 END IF;
101219 END IF;
101220 END IF;
101221 --
101222 --
101223 ------------------------------------------------------------------------------------------------
101224 -- 4219869 Business Flow
101225 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
101226 -- Prior Entry. Currently, the following code is always generated.
101227 ------------------------------------------------------------------------------------------------
101228 XLA_AE_LINES_PKG.ValidateCurrentLine;
101229
101230 ------------------------------------------------------------------------------------
101231 -- 4219869 Business Flow
101232 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
101233 ------------------------------------------------------------------------------------
101234 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
101235
101236 ----------------------------------------------------------------------------------
101237 -- 4219869 Business Flow
101238 -- Update journal entry status -- Need to generate this within IF <condition>
101239 ----------------------------------------------------------------------------------
101240 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
101241 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
101242 ,p_balance_type_code => l_balance_type_code
101243 );
101244
101245 -------------------------------------------------------------------------------------------
101246 -- 4262811 - Generate the Accrual Reversal lines
101247 -------------------------------------------------------------------------------------------
101248 BEGIN
101249 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
101250 (g_array_event(p_event_id).array_value_num('header_index'));
101251 IF l_acc_rev_flag IS NULL THEN
101252 l_acc_rev_flag := 'N';
101253 END IF;
101254 EXCEPTION
101255 WHEN OTHERS THEN
101256 l_acc_rev_flag := 'N';
101257 END;
101258 --
101259 IF (l_acc_rev_flag = 'Y') THEN
101260
101261 -- 4645092 ------------------------------------------------------------------------------
101262 -- To allow MPA report to determine if it should generate report process
101263 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
101264 ------------------------------------------------------------------------------------------
101265
101266 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
101267 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
101268 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
101269 -- call ADRs
101270 -- Bug 4922099
101271 --
101272 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
101273 (NVL(l_actual_upg_option, 'N') = 'O') OR
101274 (NVL(l_enc_upg_option, 'N') = 'O')
101275 )
101276 THEN
101277 NULL;
101278 --
101279 --
101280
101281 l_ccid := AcctDerRule_6(
101282 p_application_id => p_application_id
101283 , p_ae_header_id => l_ae_header_id
101284 , p_source_11 => p_source_11
101285 , x_transaction_coa_id => l_adr_transaction_coa_id
101286 , x_accounting_coa_id => l_adr_accounting_coa_id
101287 , x_value_type_code => l_adr_value_type_code
101288 , p_side => 'NA'
101289 );
101290
101291 xla_ae_lines_pkg.set_ccid(
101292 p_code_combination_id => l_ccid
101293 , p_value_type_code => l_adr_value_type_code
101294 , p_transaction_coa_id => l_adr_transaction_coa_id
101295 , p_accounting_coa_id => l_adr_accounting_coa_id
101296 , p_adr_code => 'CST_DEFAULT'
101297 , p_adr_type_code => 'S'
101298 , p_component_type => l_component_type
101299 , p_component_code => l_component_code
101300 , p_component_type_code => l_component_type_code
101301 , p_component_appl_id => l_component_appl_id
101302 , p_amb_context_code => l_amb_context_code
101303 , p_side => 'NA'
101304 );
101305
101306
101307 --
101308 --
101309 END IF;
101310
101311 --
101312 -- Update the line information that should be overwritten
101313 --
101314 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
101315 p_header_num => 1);
101316 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
101317
101318 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
101319
101320 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
101321 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
101322 END IF;
101323
101324 --
101325 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
101326 --
101327 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
101328 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
101329 ELSE
101330 ---------------------------------------------------------------------------------------------------
101331 -- 4262811a Switch Sign
101332 ---------------------------------------------------------------------------------------------------
101333 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
101334 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
101335 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101336 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
101337 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101338 -- 5132302
101339 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
101340 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101341
101342 END IF;
101343
101344 -- 4955764
101345 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
101346 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
101347
101348
101349 XLA_AE_LINES_PKG.ValidateCurrentLine;
101350 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
101351
101352 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
101353 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
101354 ,p_balance_type_code => l_balance_type_code);
101355
101356 END IF;
101357
101358 -----------------------------------------------------------------------------------------
101359 -- 4262811 Multiperiod Accounting
101360 -----------------------------------------------------------------------------------------
101361 -- No MPA option is assigned.
101362
101363
101364 END IF;
101365 END IF;
101366 --
101367
101368 --
101369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
101370 trace
101371 (p_msg => 'END of AcctLineType_201'
101372 ,p_level => C_LEVEL_PROCEDURE
101373 ,p_module => l_log_module);
101374 END IF;
101375 --
101376 EXCEPTION
101377 WHEN xla_exceptions_pkg.application_exception THEN
101378 RAISE;
101379 WHEN OTHERS THEN
101380 xla_exceptions_pkg.raise_message
101381 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_201');
101382 END AcctLineType_201;
101383 --
101384
101385 ---------------------------------------
101386 --
101387 -- PRIVATE FUNCTION
101388 -- AcctLineType_202
101389 --
101390 ---------------------------------------
101391 PROCEDURE AcctLineType_202 (
101392 p_application_id IN NUMBER
101393 ,p_event_id IN NUMBER
101394 ,p_calculate_acctd_flag IN VARCHAR2
101395 ,p_calculate_g_l_flag IN VARCHAR2
101396 ,p_actual_flag IN OUT VARCHAR2
101397 ,p_balance_type_code OUT VARCHAR2
101398 ,p_gain_or_loss_ref OUT VARCHAR2
101399
101400 --TRANSACTION_ID
101401 , p_source_1 IN NUMBER
101402 --Item Concatenated Segments
101403 , p_source_2 IN VARCHAR2
101404 --Transaction Quantity
101405 , p_source_3 IN NUMBER
101406 --Transaction Unit of Measure Code
101407 , p_source_4 IN VARCHAR2
101408 --Inventory Transaction Type Description
101409 , p_source_5 IN VARCHAR2
101410 --Interorg Receivables Account
101411 , p_source_59 IN NUMBER
101412 --DISTRIBUTION_IDENTIFIER
101413 , p_source_84 IN NUMBER
101414 --Distribution Type
101415 , p_source_85 IN VARCHAR2
101416 , p_source_85_meaning IN VARCHAR2
101417 --Entered Currency Code
101418 , p_source_88 IN VARCHAR2
101419 --Entered Amount
101420 , p_source_91 IN NUMBER
101421 --Currency Conversion Date
101422 , p_source_92 IN DATE
101423 --Currency Conversion Rate
101424 , p_source_93 IN NUMBER
101425 --Currency Conversion Type
101426 , p_source_94 IN VARCHAR2
101427 --Accounted Amount
101428 , p_source_95 IN NUMBER
101429 --Accounting Line Type
101430 , p_source_97 IN NUMBER
101431 )
101432 IS
101433
101434 l_component_type VARCHAR2(80);
101435 l_component_code VARCHAR2(30);
101436 l_component_type_code VARCHAR2(1);
101437 l_component_appl_id INTEGER;
101438 l_amb_context_code VARCHAR2(30);
101439 l_entity_code VARCHAR2(30);
101440 l_event_class_code VARCHAR2(30);
101441 l_ae_header_id NUMBER;
101442 l_event_type_code VARCHAR2(30);
101443 l_line_definition_code VARCHAR2(30);
101444 l_line_definition_owner_code VARCHAR2(1);
101445 --
101446 -- adr variables
101447 l_segment VARCHAR2(30);
101448 l_ccid NUMBER;
101449 l_adr_transaction_coa_id NUMBER;
101450 l_adr_accounting_coa_id NUMBER;
101451 l_adr_flexfield_segment_code VARCHAR2(30);
101452 l_adr_flex_value_set_id NUMBER;
101453 l_adr_value_type_code VARCHAR2(30);
101454 l_adr_value_combination_id NUMBER;
101455 l_adr_value_segment_code VARCHAR2(30);
101456
101457 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
101458 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
101459 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
101460 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
101461
101462 -- 4262811 Variables ------------------------------------------------------------------------------------------
101463 l_entered_amt_idx NUMBER;
101464 l_accted_amt_idx NUMBER;
101465 l_acc_rev_flag VARCHAR2(1);
101466 l_accrual_line_num NUMBER;
101467 l_tmp_amt NUMBER;
101468 l_acc_rev_natural_side_code VARCHAR2(1);
101469
101470 l_num_entries NUMBER;
101471 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
101472 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
101473 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
101474 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
101475 l_recog_line_1 NUMBER;
101476 l_recog_line_2 NUMBER;
101477
101478 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
101479 l_bflow_applied_to_amt NUMBER; -- 5132302
101480 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
101481
101482 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
101483
101484 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
101485 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
101486
101487 ---------------------------------------------------------------------------------------------------------------
101488
101489
101490 --
101491 -- bulk performance
101492 --
101493 l_balance_type_code VARCHAR2(1);
101494 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
101495 l_log_module VARCHAR2(240);
101496
101497 --
101498 -- Upgrade strategy
101499 --
101500 l_actual_upg_option VARCHAR2(1);
101501 l_enc_upg_option VARCHAR2(1);
101502
101503 --
101504 BEGIN
101505 --
101506 IF g_log_enabled THEN
101507 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_202';
101508 END IF;
101509 --
101510 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
101511
101512 trace
101513 (p_msg => 'BEGIN of AcctLineType_202'
101514 ,p_level => C_LEVEL_PROCEDURE
101515 ,p_module => l_log_module);
101516
101517 END IF;
101518 --
101519 l_component_type := 'AMB_JLT';
101520 l_component_code := 'INTERORG_RECEIVABLES';
101521 l_component_type_code := 'S';
101522 l_component_appl_id := 707;
101523 l_amb_context_code := 'DEFAULT';
101524 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
101525 l_event_class_code := 'USER_DEFINE';
101526 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
101527 l_line_definition_owner_code := 'S';
101528 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
101529 --
101530 l_balance_type_code := 'A';
101531 l_segment := NULL;
101532 l_ccid := NULL;
101533 l_adr_transaction_coa_id := NULL;
101534 l_adr_accounting_coa_id := NULL;
101535 l_adr_flexfield_segment_code := NULL;
101536 l_adr_flex_value_set_id := NULL;
101537 l_adr_value_type_code := NULL;
101538 l_adr_value_combination_id := NULL;
101539 l_adr_value_segment_code := NULL;
101540
101541 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
101542 l_bflow_class_code := ''; -- 4219869 Business Flow
101543 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
101544 l_budgetary_control_flag := 'N';
101545
101546 l_bflow_applied_to_amt_idx := NULL; -- 5132302
101547 l_bflow_applied_to_amt := NULL; -- 5132302
101548 l_entered_amt_idx := NULL; -- 4262811
101549 l_accted_amt_idx := NULL; -- 4262811
101550 l_acc_rev_flag := NULL; -- 4262811
101551 l_accrual_line_num := NULL; -- 4262811
101552 l_tmp_amt := NULL; -- 4262811
101553 --
101554
101555 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
101556 l_balance_type_code <> 'B' THEN
101557 IF NVL(p_source_97,9E125) = 10
101558 THEN
101559
101560 --
101561 XLA_AE_LINES_PKG.SetNewLine;
101562
101563 p_balance_type_code := l_balance_type_code;
101564 -- set the flag so later we will know whether the gain loss line needs to be created
101565
101566 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
101567 p_actual_flag :='A';
101568 END IF;
101569
101570 --
101571 -- bulk performance
101572 --
101573 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
101574 p_header_num => 0); -- 4262811
101575 --
101576 -- set accounting line options
101577 --
101578 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
101579 p_natural_side_code => 'D'
101580 , p_gain_or_loss_flag => 'N'
101581 , p_gl_transfer_mode_code => 'S'
101582 , p_acct_entry_type_code => 'A'
101583 , p_switch_side_flag => 'Y'
101584 , p_merge_duplicate_code => 'N'
101585 );
101586 --
101587 l_acc_rev_natural_side_code := 'C'; -- 4262811
101588 --
101589 --
101590 -- set accounting line type info
101591 --
101592 xla_ae_lines_pkg.SetAcctLineType
101593 (p_component_type => l_component_type
101594 ,p_event_type_code => l_event_type_code
101595 ,p_line_definition_owner_code => l_line_definition_owner_code
101596 ,p_line_definition_code => l_line_definition_code
101597 ,p_accounting_line_code => l_component_code
101598 ,p_accounting_line_type_code => l_component_type_code
101599 ,p_accounting_line_appl_id => l_component_appl_id
101600 ,p_amb_context_code => l_amb_context_code
101601 ,p_entity_code => l_entity_code
101602 ,p_event_class_code => l_event_class_code);
101603 --
101604 -- set accounting class
101605 --
101606 xla_ae_lines_pkg.SetAcctClass(
101607 p_accounting_class_code => 'INTERORG_RECEIVABLES'
101608 , p_ae_header_id => l_ae_header_id
101609 );
101610
101611 --
101612 -- set rounding class
101613 --
101614 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
101615 'INTERORG_RECEIVABLES';
101616
101617 --
101618 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
101619 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
101620 --
101621 -- bulk performance
101622 --
101623 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
101624
101625 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
101626 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
101627
101628 -- 4955764
101629 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
101630 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
101631
101632 -- 4458381 Public Sector Enh
101633
101634 --
101635 -- set accounting attributes for the line type
101636 --
101637 l_entered_amt_idx := 3;
101638 l_accted_amt_idx := 8;
101639 l_bflow_applied_to_amt_idx := NULL; -- 5132302
101640 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
101641 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
101642 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
101643 l_rec_acct_attrs.array_char_value(2) := p_source_85;
101644 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
101645 l_rec_acct_attrs.array_num_value(3) := p_source_91;
101646 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
101647 l_rec_acct_attrs.array_char_value(4) := p_source_88;
101648 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
101649 l_rec_acct_attrs.array_date_value(5) := p_source_92;
101650 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
101651 l_rec_acct_attrs.array_num_value(6) := p_source_93;
101652 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
101653 l_rec_acct_attrs.array_char_value(7) := p_source_94;
101654 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
101655 l_rec_acct_attrs.array_num_value(8) := p_source_95;
101656
101657 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
101658 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
101659
101660 ---------------------------------------------------------------------------------------------------------------
101661 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
101662 ---------------------------------------------------------------------------------------------------------------
101663 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
101664
101665 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
101666 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
101667
101668 IF xla_accounting_cache_pkg.GetValueChar
101669 (p_source_code => 'LEDGER_CATEGORY_CODE'
101670 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
101671 AND l_bflow_method_code = 'PRIOR_ENTRY'
101672 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
101673 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
101674 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
101675 )
101676 THEN
101677 xla_ae_lines_pkg.BflowUpgEntry
101678 (p_business_method_code => l_bflow_method_code
101679 ,p_business_class_code => l_bflow_class_code
101680 ,p_balance_type => l_balance_type_code);
101681 ELSE
101682 NULL;
101683 -- No business flow processing for business flow method of NONE.
101684 END IF;
101685
101686 --
101687 -- call analytical criteria
101688 --
101689
101690 --
101691 -- call description
101692 --
101693
101694 xla_ae_lines_pkg.SetLineDescription(
101695 p_ae_header_id => l_ae_header_id
101696 ,p_description => Description_1 (
101697 p_application_id => p_application_id
101698 , p_ae_header_id => l_ae_header_id
101699 , p_source_1 => p_source_1
101700 , p_source_2 => p_source_2
101701 , p_source_3 => p_source_3
101702 , p_source_4 => p_source_4
101703 , p_source_5 => p_source_5
101704 )
101705 );
101706
101707
101708 --
101709 -- call ADRs
101710 -- Bug 4922099
101711 --
101712 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
101713 (NVL(l_actual_upg_option, 'N') = 'O') OR
101714 (NVL(l_enc_upg_option, 'N') = 'O')
101715 )
101716 THEN
101717 NULL;
101718 --
101719 --
101720
101721 l_ccid := AcctDerRule_33(
101722 p_application_id => p_application_id
101723 , p_ae_header_id => l_ae_header_id
101724 , p_source_59 => p_source_59
101725 , x_transaction_coa_id => l_adr_transaction_coa_id
101726 , x_accounting_coa_id => l_adr_accounting_coa_id
101727 , x_value_type_code => l_adr_value_type_code
101728 , p_side => 'NA'
101729 );
101730
101731 xla_ae_lines_pkg.set_ccid(
101732 p_code_combination_id => l_ccid
101733 , p_value_type_code => l_adr_value_type_code
101734 , p_transaction_coa_id => l_adr_transaction_coa_id
101735 , p_accounting_coa_id => l_adr_accounting_coa_id
101736 , p_adr_code => 'PI_RECEIVABLES'
101737 , p_adr_type_code => 'S'
101738 , p_component_type => l_component_type
101739 , p_component_code => l_component_code
101740 , p_component_type_code => l_component_type_code
101741 , p_component_appl_id => l_component_appl_id
101742 , p_amb_context_code => l_amb_context_code
101743 , p_side => 'NA'
101744 );
101745
101746
101747 --
101748 --
101749 END IF;
101750 --
101751 -- Bug 4922099
101752 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
101753 (NVL(l_enc_upg_option, 'N') = 'O')
101754 ) AND
101755 (l_bflow_method_code = 'PRIOR_ENTRY')
101756 )
101757 THEN
101758 IF
101759 --
101760 1 = 2
101761 --
101762 THEN
101763 xla_accounting_err_pkg.build_message
101764 (p_appli_s_name => 'XLA'
101765 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
101766 ,p_token_1 => 'LINE_NUMBER'
101767 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
101768 ,p_token_2 => 'LINE_TYPE_NAME'
101769 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
101770 l_component_type
101771 ,l_component_code
101772 ,l_component_type_code
101773 ,l_component_appl_id
101774 ,l_amb_context_code
101775 ,l_entity_code
101776 ,l_event_class_code
101777 )
101778 ,p_token_3 => 'OWNER'
101779 ,p_value_3 => xla_lookups_pkg.get_meaning(
101780 p_lookup_type => 'XLA_OWNER_TYPE'
101781 ,p_lookup_code => l_component_type_code
101782 )
101783 ,p_token_4 => 'PRODUCT_NAME'
101784 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
101785 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
101786 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
101787 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
101788 ,p_ae_header_id => NULL
101789 );
101790
101791 IF (C_LEVEL_ERROR>= g_log_level) THEN
101792 trace
101793 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
101794 ,p_level => C_LEVEL_ERROR
101795 ,p_module => l_log_module);
101796 END IF;
101797 END IF;
101798 END IF;
101799 --
101800 --
101801 ------------------------------------------------------------------------------------------------
101802 -- 4219869 Business Flow
101803 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
101804 -- Prior Entry. Currently, the following code is always generated.
101805 ------------------------------------------------------------------------------------------------
101806 XLA_AE_LINES_PKG.ValidateCurrentLine;
101807
101808 ------------------------------------------------------------------------------------
101809 -- 4219869 Business Flow
101810 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
101811 ------------------------------------------------------------------------------------
101812 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
101813
101814 ----------------------------------------------------------------------------------
101815 -- 4219869 Business Flow
101816 -- Update journal entry status -- Need to generate this within IF <condition>
101817 ----------------------------------------------------------------------------------
101818 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
101819 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
101820 ,p_balance_type_code => l_balance_type_code
101821 );
101822
101823 -------------------------------------------------------------------------------------------
101824 -- 4262811 - Generate the Accrual Reversal lines
101825 -------------------------------------------------------------------------------------------
101826 BEGIN
101827 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
101828 (g_array_event(p_event_id).array_value_num('header_index'));
101829 IF l_acc_rev_flag IS NULL THEN
101830 l_acc_rev_flag := 'N';
101831 END IF;
101832 EXCEPTION
101833 WHEN OTHERS THEN
101834 l_acc_rev_flag := 'N';
101835 END;
101836 --
101837 IF (l_acc_rev_flag = 'Y') THEN
101838
101839 -- 4645092 ------------------------------------------------------------------------------
101840 -- To allow MPA report to determine if it should generate report process
101841 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
101842 ------------------------------------------------------------------------------------------
101843
101844 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
101845 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
101846 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
101847 -- call ADRs
101848 -- Bug 4922099
101849 --
101850 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
101851 (NVL(l_actual_upg_option, 'N') = 'O') OR
101852 (NVL(l_enc_upg_option, 'N') = 'O')
101853 )
101854 THEN
101855 NULL;
101856 --
101857 --
101858
101859 l_ccid := AcctDerRule_33(
101860 p_application_id => p_application_id
101861 , p_ae_header_id => l_ae_header_id
101862 , p_source_59 => p_source_59
101863 , x_transaction_coa_id => l_adr_transaction_coa_id
101864 , x_accounting_coa_id => l_adr_accounting_coa_id
101865 , x_value_type_code => l_adr_value_type_code
101866 , p_side => 'NA'
101867 );
101868
101869 xla_ae_lines_pkg.set_ccid(
101870 p_code_combination_id => l_ccid
101871 , p_value_type_code => l_adr_value_type_code
101872 , p_transaction_coa_id => l_adr_transaction_coa_id
101873 , p_accounting_coa_id => l_adr_accounting_coa_id
101874 , p_adr_code => 'PI_RECEIVABLES'
101875 , p_adr_type_code => 'S'
101876 , p_component_type => l_component_type
101877 , p_component_code => l_component_code
101878 , p_component_type_code => l_component_type_code
101879 , p_component_appl_id => l_component_appl_id
101880 , p_amb_context_code => l_amb_context_code
101881 , p_side => 'NA'
101882 );
101883
101884
101885 --
101886 --
101887 END IF;
101888
101889 --
101890 -- Update the line information that should be overwritten
101891 --
101892 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
101893 p_header_num => 1);
101894 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
101895
101896 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
101897
101898 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
101899 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
101900 END IF;
101901
101902 --
101903 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
101904 --
101905 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
101906 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
101907 ELSE
101908 ---------------------------------------------------------------------------------------------------
101909 -- 4262811a Switch Sign
101910 ---------------------------------------------------------------------------------------------------
101911 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
101912 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
101913 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101914 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
101915 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101916 -- 5132302
101917 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
101918 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
101919
101920 END IF;
101921
101922 -- 4955764
101923 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
101924 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
101925
101926
101927 XLA_AE_LINES_PKG.ValidateCurrentLine;
101928 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
101929
101930 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
101931 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
101932 ,p_balance_type_code => l_balance_type_code);
101933
101934 END IF;
101935
101936 -----------------------------------------------------------------------------------------
101937 -- 4262811 Multiperiod Accounting
101938 -----------------------------------------------------------------------------------------
101939 -- No MPA option is assigned.
101940
101941
101942 END IF;
101943 END IF;
101944 --
101945
101946 --
101947 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
101948 trace
101949 (p_msg => 'END of AcctLineType_202'
101950 ,p_level => C_LEVEL_PROCEDURE
101951 ,p_module => l_log_module);
101952 END IF;
101953 --
101954 EXCEPTION
101955 WHEN xla_exceptions_pkg.application_exception THEN
101956 RAISE;
101957 WHEN OTHERS THEN
101958 xla_exceptions_pkg.raise_message
101959 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_202');
101960 END AcctLineType_202;
101961 --
101962
101963 ---------------------------------------
101964 --
101965 -- PRIVATE FUNCTION
101966 -- AcctLineType_203
101967 --
101968 ---------------------------------------
101969 PROCEDURE AcctLineType_203 (
101970 p_application_id IN NUMBER
101971 ,p_event_id IN NUMBER
101972 ,p_calculate_acctd_flag IN VARCHAR2
101973 ,p_calculate_g_l_flag IN VARCHAR2
101974 ,p_actual_flag IN OUT VARCHAR2
101975 ,p_balance_type_code OUT VARCHAR2
101976 ,p_gain_or_loss_ref OUT VARCHAR2
101977
101978 --TRANSACTION_ID
101979 , p_source_1 IN NUMBER
101980 --Item Concatenated Segments
101981 , p_source_2 IN VARCHAR2
101982 --Transaction Quantity
101983 , p_source_3 IN NUMBER
101984 --Transaction Unit of Measure Code
101985 , p_source_4 IN VARCHAR2
101986 --Inventory Transaction Type Description
101987 , p_source_5 IN VARCHAR2
101988 --Interorg Receivables Account
101989 , p_source_59 IN NUMBER
101990 --DISTRIBUTION_IDENTIFIER
101991 , p_source_84 IN NUMBER
101992 --Distribution Type
101993 , p_source_85 IN VARCHAR2
101994 , p_source_85_meaning IN VARCHAR2
101995 --Entered Currency Code
101996 , p_source_88 IN VARCHAR2
101997 --Entered Amount
101998 , p_source_91 IN NUMBER
101999 --Currency Conversion Date
102000 , p_source_92 IN DATE
102001 --Currency Conversion Rate
102002 , p_source_93 IN NUMBER
102003 --Currency Conversion Type
102004 , p_source_94 IN VARCHAR2
102005 --Accounted Amount
102006 , p_source_95 IN NUMBER
102007 --Accounting Line Type
102008 , p_source_97 IN NUMBER
102009 )
102010 IS
102011
102012 l_component_type VARCHAR2(80);
102013 l_component_code VARCHAR2(30);
102014 l_component_type_code VARCHAR2(1);
102015 l_component_appl_id INTEGER;
102016 l_amb_context_code VARCHAR2(30);
102017 l_entity_code VARCHAR2(30);
102018 l_event_class_code VARCHAR2(30);
102019 l_ae_header_id NUMBER;
102020 l_event_type_code VARCHAR2(30);
102021 l_line_definition_code VARCHAR2(30);
102022 l_line_definition_owner_code VARCHAR2(1);
102023 --
102024 -- adr variables
102025 l_segment VARCHAR2(30);
102026 l_ccid NUMBER;
102027 l_adr_transaction_coa_id NUMBER;
102028 l_adr_accounting_coa_id NUMBER;
102029 l_adr_flexfield_segment_code VARCHAR2(30);
102030 l_adr_flex_value_set_id NUMBER;
102031 l_adr_value_type_code VARCHAR2(30);
102032 l_adr_value_combination_id NUMBER;
102033 l_adr_value_segment_code VARCHAR2(30);
102034
102035 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
102036 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
102037 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
102038 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
102039
102040 -- 4262811 Variables ------------------------------------------------------------------------------------------
102041 l_entered_amt_idx NUMBER;
102042 l_accted_amt_idx NUMBER;
102043 l_acc_rev_flag VARCHAR2(1);
102044 l_accrual_line_num NUMBER;
102045 l_tmp_amt NUMBER;
102046 l_acc_rev_natural_side_code VARCHAR2(1);
102047
102048 l_num_entries NUMBER;
102049 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
102050 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
102051 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
102052 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
102053 l_recog_line_1 NUMBER;
102054 l_recog_line_2 NUMBER;
102055
102056 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
102057 l_bflow_applied_to_amt NUMBER; -- 5132302
102058 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
102059
102060 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
102061
102062 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
102063 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
102064
102065 ---------------------------------------------------------------------------------------------------------------
102066
102067
102068 --
102069 -- bulk performance
102070 --
102071 l_balance_type_code VARCHAR2(1);
102072 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
102073 l_log_module VARCHAR2(240);
102074
102075 --
102076 -- Upgrade strategy
102077 --
102078 l_actual_upg_option VARCHAR2(1);
102079 l_enc_upg_option VARCHAR2(1);
102080
102081 --
102082 BEGIN
102083 --
102084 IF g_log_enabled THEN
102085 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_203';
102086 END IF;
102087 --
102088 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
102089
102090 trace
102091 (p_msg => 'BEGIN of AcctLineType_203'
102092 ,p_level => C_LEVEL_PROCEDURE
102093 ,p_module => l_log_module);
102094
102095 END IF;
102096 --
102097 l_component_type := 'AMB_JLT';
102098 l_component_code := 'INTERORG_RECEIVABLES';
102099 l_component_type_code := 'S';
102100 l_component_appl_id := 707;
102101 l_amb_context_code := 'DEFAULT';
102102 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
102103 l_event_class_code := 'USER_DEFINE';
102104 l_event_type_code := 'UDIR_INTERORG_SHIP';
102105 l_line_definition_owner_code := 'S';
102106 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
102107 --
102108 l_balance_type_code := 'A';
102109 l_segment := NULL;
102110 l_ccid := NULL;
102111 l_adr_transaction_coa_id := NULL;
102112 l_adr_accounting_coa_id := NULL;
102113 l_adr_flexfield_segment_code := NULL;
102114 l_adr_flex_value_set_id := NULL;
102115 l_adr_value_type_code := NULL;
102116 l_adr_value_combination_id := NULL;
102117 l_adr_value_segment_code := NULL;
102118
102119 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
102120 l_bflow_class_code := ''; -- 4219869 Business Flow
102121 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
102122 l_budgetary_control_flag := 'N';
102123
102124 l_bflow_applied_to_amt_idx := NULL; -- 5132302
102125 l_bflow_applied_to_amt := NULL; -- 5132302
102126 l_entered_amt_idx := NULL; -- 4262811
102127 l_accted_amt_idx := NULL; -- 4262811
102128 l_acc_rev_flag := NULL; -- 4262811
102129 l_accrual_line_num := NULL; -- 4262811
102130 l_tmp_amt := NULL; -- 4262811
102131 --
102132
102133 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
102134 l_balance_type_code <> 'B' THEN
102135 IF NVL(p_source_97,9E125) = 10
102136 THEN
102137
102138 --
102139 XLA_AE_LINES_PKG.SetNewLine;
102140
102141 p_balance_type_code := l_balance_type_code;
102142 -- set the flag so later we will know whether the gain loss line needs to be created
102143
102144 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
102145 p_actual_flag :='A';
102146 END IF;
102147
102148 --
102149 -- bulk performance
102150 --
102151 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
102152 p_header_num => 0); -- 4262811
102153 --
102154 -- set accounting line options
102155 --
102156 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
102157 p_natural_side_code => 'D'
102158 , p_gain_or_loss_flag => 'N'
102159 , p_gl_transfer_mode_code => 'S'
102160 , p_acct_entry_type_code => 'A'
102161 , p_switch_side_flag => 'Y'
102162 , p_merge_duplicate_code => 'N'
102163 );
102164 --
102165 l_acc_rev_natural_side_code := 'C'; -- 4262811
102166 --
102167 --
102168 -- set accounting line type info
102169 --
102170 xla_ae_lines_pkg.SetAcctLineType
102171 (p_component_type => l_component_type
102172 ,p_event_type_code => l_event_type_code
102173 ,p_line_definition_owner_code => l_line_definition_owner_code
102174 ,p_line_definition_code => l_line_definition_code
102175 ,p_accounting_line_code => l_component_code
102176 ,p_accounting_line_type_code => l_component_type_code
102177 ,p_accounting_line_appl_id => l_component_appl_id
102178 ,p_amb_context_code => l_amb_context_code
102179 ,p_entity_code => l_entity_code
102180 ,p_event_class_code => l_event_class_code);
102181 --
102182 -- set accounting class
102183 --
102184 xla_ae_lines_pkg.SetAcctClass(
102185 p_accounting_class_code => 'INTERORG_RECEIVABLES'
102186 , p_ae_header_id => l_ae_header_id
102187 );
102188
102189 --
102190 -- set rounding class
102191 --
102192 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
102193 'INTERORG_RECEIVABLES';
102194
102195 --
102196 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
102197 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
102198 --
102199 -- bulk performance
102200 --
102201 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
102202
102203 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
102204 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
102205
102206 -- 4955764
102207 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
102208 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
102209
102210 -- 4458381 Public Sector Enh
102211
102212 --
102213 -- set accounting attributes for the line type
102214 --
102215 l_entered_amt_idx := 3;
102216 l_accted_amt_idx := 8;
102217 l_bflow_applied_to_amt_idx := NULL; -- 5132302
102218 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
102219 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
102220 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
102221 l_rec_acct_attrs.array_char_value(2) := p_source_85;
102222 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
102223 l_rec_acct_attrs.array_num_value(3) := p_source_91;
102224 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
102225 l_rec_acct_attrs.array_char_value(4) := p_source_88;
102226 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
102227 l_rec_acct_attrs.array_date_value(5) := p_source_92;
102228 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
102229 l_rec_acct_attrs.array_num_value(6) := p_source_93;
102230 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
102231 l_rec_acct_attrs.array_char_value(7) := p_source_94;
102232 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
102233 l_rec_acct_attrs.array_num_value(8) := p_source_95;
102234
102235 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
102236 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
102237
102238 ---------------------------------------------------------------------------------------------------------------
102239 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
102240 ---------------------------------------------------------------------------------------------------------------
102241 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
102242
102243 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
102244 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
102245
102246 IF xla_accounting_cache_pkg.GetValueChar
102247 (p_source_code => 'LEDGER_CATEGORY_CODE'
102248 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
102249 AND l_bflow_method_code = 'PRIOR_ENTRY'
102250 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
102251 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
102252 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
102253 )
102254 THEN
102255 xla_ae_lines_pkg.BflowUpgEntry
102256 (p_business_method_code => l_bflow_method_code
102257 ,p_business_class_code => l_bflow_class_code
102258 ,p_balance_type => l_balance_type_code);
102259 ELSE
102260 NULL;
102261 -- No business flow processing for business flow method of NONE.
102262 END IF;
102263
102264 --
102265 -- call analytical criteria
102266 --
102267
102268 --
102269 -- call description
102270 --
102271
102272 xla_ae_lines_pkg.SetLineDescription(
102273 p_ae_header_id => l_ae_header_id
102274 ,p_description => Description_1 (
102275 p_application_id => p_application_id
102276 , p_ae_header_id => l_ae_header_id
102277 , p_source_1 => p_source_1
102278 , p_source_2 => p_source_2
102279 , p_source_3 => p_source_3
102280 , p_source_4 => p_source_4
102281 , p_source_5 => p_source_5
102282 )
102283 );
102284
102285
102286 --
102287 -- call ADRs
102288 -- Bug 4922099
102289 --
102290 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
102291 (NVL(l_actual_upg_option, 'N') = 'O') OR
102292 (NVL(l_enc_upg_option, 'N') = 'O')
102293 )
102294 THEN
102295 NULL;
102296 --
102297 --
102298
102299 l_ccid := AcctDerRule_33(
102300 p_application_id => p_application_id
102301 , p_ae_header_id => l_ae_header_id
102302 , p_source_59 => p_source_59
102303 , x_transaction_coa_id => l_adr_transaction_coa_id
102304 , x_accounting_coa_id => l_adr_accounting_coa_id
102305 , x_value_type_code => l_adr_value_type_code
102306 , p_side => 'NA'
102307 );
102308
102309 xla_ae_lines_pkg.set_ccid(
102310 p_code_combination_id => l_ccid
102311 , p_value_type_code => l_adr_value_type_code
102312 , p_transaction_coa_id => l_adr_transaction_coa_id
102313 , p_accounting_coa_id => l_adr_accounting_coa_id
102314 , p_adr_code => 'PI_RECEIVABLES'
102315 , p_adr_type_code => 'S'
102316 , p_component_type => l_component_type
102317 , p_component_code => l_component_code
102318 , p_component_type_code => l_component_type_code
102319 , p_component_appl_id => l_component_appl_id
102320 , p_amb_context_code => l_amb_context_code
102321 , p_side => 'NA'
102322 );
102323
102324
102325 --
102326 --
102327 END IF;
102328 --
102329 -- Bug 4922099
102330 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
102331 (NVL(l_enc_upg_option, 'N') = 'O')
102332 ) AND
102333 (l_bflow_method_code = 'PRIOR_ENTRY')
102334 )
102335 THEN
102336 IF
102337 --
102338 1 = 2
102339 --
102340 THEN
102341 xla_accounting_err_pkg.build_message
102342 (p_appli_s_name => 'XLA'
102343 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
102344 ,p_token_1 => 'LINE_NUMBER'
102345 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
102346 ,p_token_2 => 'LINE_TYPE_NAME'
102347 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
102348 l_component_type
102349 ,l_component_code
102350 ,l_component_type_code
102351 ,l_component_appl_id
102352 ,l_amb_context_code
102353 ,l_entity_code
102354 ,l_event_class_code
102355 )
102356 ,p_token_3 => 'OWNER'
102357 ,p_value_3 => xla_lookups_pkg.get_meaning(
102358 p_lookup_type => 'XLA_OWNER_TYPE'
102359 ,p_lookup_code => l_component_type_code
102360 )
102361 ,p_token_4 => 'PRODUCT_NAME'
102362 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
102363 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
102364 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
102365 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
102366 ,p_ae_header_id => NULL
102367 );
102368
102369 IF (C_LEVEL_ERROR>= g_log_level) THEN
102370 trace
102371 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
102372 ,p_level => C_LEVEL_ERROR
102373 ,p_module => l_log_module);
102374 END IF;
102375 END IF;
102376 END IF;
102377 --
102378 --
102379 ------------------------------------------------------------------------------------------------
102380 -- 4219869 Business Flow
102381 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
102382 -- Prior Entry. Currently, the following code is always generated.
102383 ------------------------------------------------------------------------------------------------
102384 XLA_AE_LINES_PKG.ValidateCurrentLine;
102385
102386 ------------------------------------------------------------------------------------
102387 -- 4219869 Business Flow
102388 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
102389 ------------------------------------------------------------------------------------
102390 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
102391
102392 ----------------------------------------------------------------------------------
102393 -- 4219869 Business Flow
102394 -- Update journal entry status -- Need to generate this within IF <condition>
102395 ----------------------------------------------------------------------------------
102396 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
102397 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
102398 ,p_balance_type_code => l_balance_type_code
102399 );
102400
102401 -------------------------------------------------------------------------------------------
102402 -- 4262811 - Generate the Accrual Reversal lines
102403 -------------------------------------------------------------------------------------------
102404 BEGIN
102405 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
102406 (g_array_event(p_event_id).array_value_num('header_index'));
102407 IF l_acc_rev_flag IS NULL THEN
102408 l_acc_rev_flag := 'N';
102409 END IF;
102410 EXCEPTION
102411 WHEN OTHERS THEN
102412 l_acc_rev_flag := 'N';
102413 END;
102414 --
102415 IF (l_acc_rev_flag = 'Y') THEN
102416
102417 -- 4645092 ------------------------------------------------------------------------------
102418 -- To allow MPA report to determine if it should generate report process
102419 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
102420 ------------------------------------------------------------------------------------------
102421
102422 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
102423 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
102424 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
102425 -- call ADRs
102426 -- Bug 4922099
102427 --
102428 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
102429 (NVL(l_actual_upg_option, 'N') = 'O') OR
102430 (NVL(l_enc_upg_option, 'N') = 'O')
102431 )
102432 THEN
102433 NULL;
102434 --
102435 --
102436
102437 l_ccid := AcctDerRule_33(
102438 p_application_id => p_application_id
102439 , p_ae_header_id => l_ae_header_id
102440 , p_source_59 => p_source_59
102441 , x_transaction_coa_id => l_adr_transaction_coa_id
102442 , x_accounting_coa_id => l_adr_accounting_coa_id
102443 , x_value_type_code => l_adr_value_type_code
102444 , p_side => 'NA'
102445 );
102446
102447 xla_ae_lines_pkg.set_ccid(
102448 p_code_combination_id => l_ccid
102449 , p_value_type_code => l_adr_value_type_code
102450 , p_transaction_coa_id => l_adr_transaction_coa_id
102451 , p_accounting_coa_id => l_adr_accounting_coa_id
102452 , p_adr_code => 'PI_RECEIVABLES'
102453 , p_adr_type_code => 'S'
102454 , p_component_type => l_component_type
102455 , p_component_code => l_component_code
102456 , p_component_type_code => l_component_type_code
102457 , p_component_appl_id => l_component_appl_id
102458 , p_amb_context_code => l_amb_context_code
102459 , p_side => 'NA'
102460 );
102461
102462
102463 --
102464 --
102465 END IF;
102466
102467 --
102468 -- Update the line information that should be overwritten
102469 --
102470 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
102471 p_header_num => 1);
102472 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
102473
102474 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
102475
102476 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
102477 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
102478 END IF;
102479
102480 --
102481 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
102482 --
102483 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
102484 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
102485 ELSE
102486 ---------------------------------------------------------------------------------------------------
102487 -- 4262811a Switch Sign
102488 ---------------------------------------------------------------------------------------------------
102489 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
102490 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
102491 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
102492 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
102493 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
102494 -- 5132302
102495 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
102496 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
102497
102498 END IF;
102499
102500 -- 4955764
102501 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
102502 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
102503
102504
102505 XLA_AE_LINES_PKG.ValidateCurrentLine;
102506 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
102507
102508 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
102509 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
102510 ,p_balance_type_code => l_balance_type_code);
102511
102512 END IF;
102513
102514 -----------------------------------------------------------------------------------------
102515 -- 4262811 Multiperiod Accounting
102516 -----------------------------------------------------------------------------------------
102517 -- No MPA option is assigned.
102518
102519
102520 END IF;
102521 END IF;
102522 --
102523
102524 --
102525 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
102526 trace
102527 (p_msg => 'END of AcctLineType_203'
102528 ,p_level => C_LEVEL_PROCEDURE
102529 ,p_module => l_log_module);
102530 END IF;
102531 --
102532 EXCEPTION
102533 WHEN xla_exceptions_pkg.application_exception THEN
102534 RAISE;
102535 WHEN OTHERS THEN
102536 xla_exceptions_pkg.raise_message
102537 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_203');
102538 END AcctLineType_203;
102539 --
102540
102541 ---------------------------------------
102542 --
102543 -- PRIVATE FUNCTION
102544 -- AcctLineType_204
102545 --
102546 ---------------------------------------
102547 PROCEDURE AcctLineType_204 (
102548 p_application_id IN NUMBER
102549 ,p_event_id IN NUMBER
102550 ,p_calculate_acctd_flag IN VARCHAR2
102551 ,p_calculate_g_l_flag IN VARCHAR2
102552 ,p_actual_flag IN OUT VARCHAR2
102553 ,p_balance_type_code OUT VARCHAR2
102554 ,p_gain_or_loss_ref OUT VARCHAR2
102555
102556 --TRANSACTION_ID
102557 , p_source_1 IN NUMBER
102558 --Item Concatenated Segments
102559 , p_source_2 IN VARCHAR2
102560 --Transaction Quantity
102561 , p_source_3 IN NUMBER
102562 --Transaction Unit of Measure Code
102563 , p_source_4 IN VARCHAR2
102564 --Inventory Transaction Type Description
102565 , p_source_5 IN VARCHAR2
102566 --Cost Management Default Account
102567 , p_source_11 IN NUMBER
102568 --DISTRIBUTION_IDENTIFIER
102569 , p_source_84 IN NUMBER
102570 --Distribution Type
102571 , p_source_85 IN VARCHAR2
102572 , p_source_85_meaning IN VARCHAR2
102573 --Entered Currency Code
102574 , p_source_88 IN VARCHAR2
102575 --Entered Amount
102576 , p_source_91 IN NUMBER
102577 --Currency Conversion Date
102578 , p_source_92 IN DATE
102579 --Currency Conversion Rate
102580 , p_source_93 IN NUMBER
102581 --Currency Conversion Type
102582 , p_source_94 IN VARCHAR2
102583 --Accounted Amount
102584 , p_source_95 IN NUMBER
102585 --Accounting Line Type
102586 , p_source_97 IN NUMBER
102587 )
102588 IS
102589
102590 l_component_type VARCHAR2(80);
102591 l_component_code VARCHAR2(30);
102592 l_component_type_code VARCHAR2(1);
102593 l_component_appl_id INTEGER;
102594 l_amb_context_code VARCHAR2(30);
102595 l_entity_code VARCHAR2(30);
102596 l_event_class_code VARCHAR2(30);
102597 l_ae_header_id NUMBER;
102598 l_event_type_code VARCHAR2(30);
102599 l_line_definition_code VARCHAR2(30);
102600 l_line_definition_owner_code VARCHAR2(1);
102601 --
102602 -- adr variables
102603 l_segment VARCHAR2(30);
102604 l_ccid NUMBER;
102605 l_adr_transaction_coa_id NUMBER;
102606 l_adr_accounting_coa_id NUMBER;
102607 l_adr_flexfield_segment_code VARCHAR2(30);
102608 l_adr_flex_value_set_id NUMBER;
102609 l_adr_value_type_code VARCHAR2(30);
102610 l_adr_value_combination_id NUMBER;
102611 l_adr_value_segment_code VARCHAR2(30);
102612
102613 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
102614 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
102615 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
102616 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
102617
102618 -- 4262811 Variables ------------------------------------------------------------------------------------------
102619 l_entered_amt_idx NUMBER;
102620 l_accted_amt_idx NUMBER;
102621 l_acc_rev_flag VARCHAR2(1);
102622 l_accrual_line_num NUMBER;
102623 l_tmp_amt NUMBER;
102624 l_acc_rev_natural_side_code VARCHAR2(1);
102625
102626 l_num_entries NUMBER;
102627 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
102628 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
102629 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
102630 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
102631 l_recog_line_1 NUMBER;
102632 l_recog_line_2 NUMBER;
102633
102634 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
102635 l_bflow_applied_to_amt NUMBER; -- 5132302
102636 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
102637
102638 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
102639
102640 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
102641 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
102642
102643 ---------------------------------------------------------------------------------------------------------------
102644
102645
102646 --
102647 -- bulk performance
102648 --
102649 l_balance_type_code VARCHAR2(1);
102650 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
102651 l_log_module VARCHAR2(240);
102652
102653 --
102654 -- Upgrade strategy
102655 --
102656 l_actual_upg_option VARCHAR2(1);
102657 l_enc_upg_option VARCHAR2(1);
102658
102659 --
102660 BEGIN
102661 --
102662 IF g_log_enabled THEN
102663 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_204';
102664 END IF;
102665 --
102666 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
102667
102668 trace
102669 (p_msg => 'BEGIN of AcctLineType_204'
102670 ,p_level => C_LEVEL_PROCEDURE
102671 ,p_module => l_log_module);
102672
102673 END IF;
102674 --
102675 l_component_type := 'AMB_JLT';
102676 l_component_code := 'INTERORG_TRANSFER_CREDIT';
102677 l_component_type_code := 'S';
102678 l_component_appl_id := 707;
102679 l_amb_context_code := 'DEFAULT';
102680 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
102681 l_event_class_code := 'USER_DEFINE';
102682 l_event_type_code := 'UDIR_INTERORG_RCPT';
102683 l_line_definition_owner_code := 'S';
102684 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
102685 --
102686 l_balance_type_code := 'A';
102687 l_segment := NULL;
102688 l_ccid := NULL;
102689 l_adr_transaction_coa_id := NULL;
102690 l_adr_accounting_coa_id := NULL;
102691 l_adr_flexfield_segment_code := NULL;
102692 l_adr_flex_value_set_id := NULL;
102693 l_adr_value_type_code := NULL;
102694 l_adr_value_combination_id := NULL;
102695 l_adr_value_segment_code := NULL;
102696
102697 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
102698 l_bflow_class_code := ''; -- 4219869 Business Flow
102699 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
102700 l_budgetary_control_flag := 'N';
102701
102702 l_bflow_applied_to_amt_idx := NULL; -- 5132302
102703 l_bflow_applied_to_amt := NULL; -- 5132302
102704 l_entered_amt_idx := NULL; -- 4262811
102705 l_accted_amt_idx := NULL; -- 4262811
102706 l_acc_rev_flag := NULL; -- 4262811
102707 l_accrual_line_num := NULL; -- 4262811
102708 l_tmp_amt := NULL; -- 4262811
102709 --
102710
102711 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
102712 l_balance_type_code <> 'B' THEN
102713 IF NVL(p_source_97,9E125) = 11
102714 THEN
102715
102716 --
102717 XLA_AE_LINES_PKG.SetNewLine;
102718
102719 p_balance_type_code := l_balance_type_code;
102720 -- set the flag so later we will know whether the gain loss line needs to be created
102721
102722 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
102723 p_actual_flag :='A';
102724 END IF;
102725
102726 --
102727 -- bulk performance
102728 --
102729 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
102730 p_header_num => 0); -- 4262811
102731 --
102732 -- set accounting line options
102733 --
102734 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
102735 p_natural_side_code => 'D'
102736 , p_gain_or_loss_flag => 'N'
102737 , p_gl_transfer_mode_code => 'S'
102738 , p_acct_entry_type_code => 'A'
102739 , p_switch_side_flag => 'Y'
102740 , p_merge_duplicate_code => 'N'
102741 );
102742 --
102743 l_acc_rev_natural_side_code := 'C'; -- 4262811
102744 --
102745 --
102746 -- set accounting line type info
102747 --
102748 xla_ae_lines_pkg.SetAcctLineType
102749 (p_component_type => l_component_type
102750 ,p_event_type_code => l_event_type_code
102751 ,p_line_definition_owner_code => l_line_definition_owner_code
102752 ,p_line_definition_code => l_line_definition_code
102753 ,p_accounting_line_code => l_component_code
102754 ,p_accounting_line_type_code => l_component_type_code
102755 ,p_accounting_line_appl_id => l_component_appl_id
102756 ,p_amb_context_code => l_amb_context_code
102757 ,p_entity_code => l_entity_code
102758 ,p_event_class_code => l_event_class_code);
102759 --
102760 -- set accounting class
102761 --
102762 xla_ae_lines_pkg.SetAcctClass(
102763 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
102764 , p_ae_header_id => l_ae_header_id
102765 );
102766
102767 --
102768 -- set rounding class
102769 --
102770 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
102771 'INTERORG_TRANSFER_CREDIT';
102772
102773 --
102774 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
102775 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
102776 --
102777 -- bulk performance
102778 --
102779 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
102780
102781 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
102782 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
102783
102784 -- 4955764
102785 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
102786 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
102787
102788 -- 4458381 Public Sector Enh
102789
102790 --
102791 -- set accounting attributes for the line type
102792 --
102793 l_entered_amt_idx := 3;
102794 l_accted_amt_idx := 8;
102795 l_bflow_applied_to_amt_idx := NULL; -- 5132302
102796 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
102797 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
102798 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
102799 l_rec_acct_attrs.array_char_value(2) := p_source_85;
102800 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
102801 l_rec_acct_attrs.array_num_value(3) := p_source_91;
102802 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
102803 l_rec_acct_attrs.array_char_value(4) := p_source_88;
102804 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
102805 l_rec_acct_attrs.array_date_value(5) := p_source_92;
102806 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
102807 l_rec_acct_attrs.array_num_value(6) := p_source_93;
102808 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
102809 l_rec_acct_attrs.array_char_value(7) := p_source_94;
102810 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
102811 l_rec_acct_attrs.array_num_value(8) := p_source_95;
102812
102813 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
102814 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
102815
102816 ---------------------------------------------------------------------------------------------------------------
102817 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
102818 ---------------------------------------------------------------------------------------------------------------
102819 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
102820
102821 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
102822 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
102823
102824 IF xla_accounting_cache_pkg.GetValueChar
102825 (p_source_code => 'LEDGER_CATEGORY_CODE'
102826 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
102827 AND l_bflow_method_code = 'PRIOR_ENTRY'
102828 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
102829 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
102830 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
102831 )
102832 THEN
102833 xla_ae_lines_pkg.BflowUpgEntry
102834 (p_business_method_code => l_bflow_method_code
102835 ,p_business_class_code => l_bflow_class_code
102836 ,p_balance_type => l_balance_type_code);
102837 ELSE
102838 NULL;
102839 -- No business flow processing for business flow method of NONE.
102840 END IF;
102841
102842 --
102843 -- call analytical criteria
102844 --
102845
102846 --
102847 -- call description
102848 --
102849
102850 xla_ae_lines_pkg.SetLineDescription(
102851 p_ae_header_id => l_ae_header_id
102852 ,p_description => Description_1 (
102853 p_application_id => p_application_id
102854 , p_ae_header_id => l_ae_header_id
102855 , p_source_1 => p_source_1
102856 , p_source_2 => p_source_2
102857 , p_source_3 => p_source_3
102858 , p_source_4 => p_source_4
102859 , p_source_5 => p_source_5
102860 )
102861 );
102862
102863
102864 --
102865 -- call ADRs
102866 -- Bug 4922099
102867 --
102868 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
102869 (NVL(l_actual_upg_option, 'N') = 'O') OR
102870 (NVL(l_enc_upg_option, 'N') = 'O')
102871 )
102872 THEN
102873 NULL;
102874 --
102875 --
102876
102877 l_ccid := AcctDerRule_6(
102878 p_application_id => p_application_id
102879 , p_ae_header_id => l_ae_header_id
102880 , p_source_11 => p_source_11
102881 , x_transaction_coa_id => l_adr_transaction_coa_id
102882 , x_accounting_coa_id => l_adr_accounting_coa_id
102883 , x_value_type_code => l_adr_value_type_code
102884 , p_side => 'NA'
102885 );
102886
102887 xla_ae_lines_pkg.set_ccid(
102888 p_code_combination_id => l_ccid
102889 , p_value_type_code => l_adr_value_type_code
102890 , p_transaction_coa_id => l_adr_transaction_coa_id
102891 , p_accounting_coa_id => l_adr_accounting_coa_id
102892 , p_adr_code => 'CST_DEFAULT'
102893 , p_adr_type_code => 'S'
102894 , p_component_type => l_component_type
102895 , p_component_code => l_component_code
102896 , p_component_type_code => l_component_type_code
102897 , p_component_appl_id => l_component_appl_id
102898 , p_amb_context_code => l_amb_context_code
102899 , p_side => 'NA'
102900 );
102901
102902
102903 --
102904 --
102905 END IF;
102906 --
102907 -- Bug 4922099
102908 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
102909 (NVL(l_enc_upg_option, 'N') = 'O')
102910 ) AND
102911 (l_bflow_method_code = 'PRIOR_ENTRY')
102912 )
102913 THEN
102914 IF
102915 --
102916 1 = 2
102917 --
102918 THEN
102919 xla_accounting_err_pkg.build_message
102920 (p_appli_s_name => 'XLA'
102921 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
102922 ,p_token_1 => 'LINE_NUMBER'
102923 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
102924 ,p_token_2 => 'LINE_TYPE_NAME'
102925 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
102926 l_component_type
102927 ,l_component_code
102928 ,l_component_type_code
102929 ,l_component_appl_id
102930 ,l_amb_context_code
102931 ,l_entity_code
102932 ,l_event_class_code
102933 )
102934 ,p_token_3 => 'OWNER'
102935 ,p_value_3 => xla_lookups_pkg.get_meaning(
102936 p_lookup_type => 'XLA_OWNER_TYPE'
102937 ,p_lookup_code => l_component_type_code
102938 )
102939 ,p_token_4 => 'PRODUCT_NAME'
102940 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
102941 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
102942 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
102943 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
102944 ,p_ae_header_id => NULL
102945 );
102946
102947 IF (C_LEVEL_ERROR>= g_log_level) THEN
102948 trace
102949 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
102950 ,p_level => C_LEVEL_ERROR
102951 ,p_module => l_log_module);
102952 END IF;
102953 END IF;
102954 END IF;
102955 --
102956 --
102957 ------------------------------------------------------------------------------------------------
102958 -- 4219869 Business Flow
102959 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
102960 -- Prior Entry. Currently, the following code is always generated.
102961 ------------------------------------------------------------------------------------------------
102962 XLA_AE_LINES_PKG.ValidateCurrentLine;
102963
102964 ------------------------------------------------------------------------------------
102965 -- 4219869 Business Flow
102966 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
102967 ------------------------------------------------------------------------------------
102968 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
102969
102970 ----------------------------------------------------------------------------------
102971 -- 4219869 Business Flow
102972 -- Update journal entry status -- Need to generate this within IF <condition>
102973 ----------------------------------------------------------------------------------
102974 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
102975 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
102976 ,p_balance_type_code => l_balance_type_code
102977 );
102978
102979 -------------------------------------------------------------------------------------------
102980 -- 4262811 - Generate the Accrual Reversal lines
102981 -------------------------------------------------------------------------------------------
102982 BEGIN
102983 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
102984 (g_array_event(p_event_id).array_value_num('header_index'));
102985 IF l_acc_rev_flag IS NULL THEN
102986 l_acc_rev_flag := 'N';
102987 END IF;
102988 EXCEPTION
102989 WHEN OTHERS THEN
102990 l_acc_rev_flag := 'N';
102991 END;
102992 --
102993 IF (l_acc_rev_flag = 'Y') THEN
102994
102995 -- 4645092 ------------------------------------------------------------------------------
102996 -- To allow MPA report to determine if it should generate report process
102997 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
102998 ------------------------------------------------------------------------------------------
102999
103000 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
103001 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
103002 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
103003 -- call ADRs
103004 -- Bug 4922099
103005 --
103006 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
103007 (NVL(l_actual_upg_option, 'N') = 'O') OR
103008 (NVL(l_enc_upg_option, 'N') = 'O')
103009 )
103010 THEN
103011 NULL;
103012 --
103013 --
103014
103015 l_ccid := AcctDerRule_6(
103016 p_application_id => p_application_id
103017 , p_ae_header_id => l_ae_header_id
103018 , p_source_11 => p_source_11
103019 , x_transaction_coa_id => l_adr_transaction_coa_id
103020 , x_accounting_coa_id => l_adr_accounting_coa_id
103021 , x_value_type_code => l_adr_value_type_code
103022 , p_side => 'NA'
103023 );
103024
103025 xla_ae_lines_pkg.set_ccid(
103026 p_code_combination_id => l_ccid
103027 , p_value_type_code => l_adr_value_type_code
103028 , p_transaction_coa_id => l_adr_transaction_coa_id
103029 , p_accounting_coa_id => l_adr_accounting_coa_id
103030 , p_adr_code => 'CST_DEFAULT'
103031 , p_adr_type_code => 'S'
103032 , p_component_type => l_component_type
103033 , p_component_code => l_component_code
103034 , p_component_type_code => l_component_type_code
103035 , p_component_appl_id => l_component_appl_id
103036 , p_amb_context_code => l_amb_context_code
103037 , p_side => 'NA'
103038 );
103039
103040
103041 --
103042 --
103043 END IF;
103044
103045 --
103046 -- Update the line information that should be overwritten
103047 --
103048 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
103049 p_header_num => 1);
103050 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
103051
103052 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
103053
103054 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
103055 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
103056 END IF;
103057
103058 --
103059 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
103060 --
103061 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
103062 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
103063 ELSE
103064 ---------------------------------------------------------------------------------------------------
103065 -- 4262811a Switch Sign
103066 ---------------------------------------------------------------------------------------------------
103067 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
103068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
103069 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
103071 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103072 -- 5132302
103073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
103074 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103075
103076 END IF;
103077
103078 -- 4955764
103079 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
103080 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
103081
103082
103083 XLA_AE_LINES_PKG.ValidateCurrentLine;
103084 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
103085
103086 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
103087 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
103088 ,p_balance_type_code => l_balance_type_code);
103089
103090 END IF;
103091
103092 -----------------------------------------------------------------------------------------
103093 -- 4262811 Multiperiod Accounting
103094 -----------------------------------------------------------------------------------------
103095 -- No MPA option is assigned.
103096
103097
103098 END IF;
103099 END IF;
103100 --
103101
103102 --
103103 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
103104 trace
103105 (p_msg => 'END of AcctLineType_204'
103106 ,p_level => C_LEVEL_PROCEDURE
103107 ,p_module => l_log_module);
103108 END IF;
103109 --
103110 EXCEPTION
103111 WHEN xla_exceptions_pkg.application_exception THEN
103112 RAISE;
103113 WHEN OTHERS THEN
103114 xla_exceptions_pkg.raise_message
103115 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_204');
103116 END AcctLineType_204;
103117 --
103118
103119 ---------------------------------------
103120 --
103121 -- PRIVATE FUNCTION
103122 -- AcctLineType_205
103123 --
103124 ---------------------------------------
103125 PROCEDURE AcctLineType_205 (
103126 p_application_id IN NUMBER
103127 ,p_event_id IN NUMBER
103128 ,p_calculate_acctd_flag IN VARCHAR2
103129 ,p_calculate_g_l_flag IN VARCHAR2
103130 ,p_actual_flag IN OUT VARCHAR2
103131 ,p_balance_type_code OUT VARCHAR2
103132 ,p_gain_or_loss_ref OUT VARCHAR2
103133
103134 --TRANSACTION_ID
103135 , p_source_1 IN NUMBER
103136 --Item Concatenated Segments
103137 , p_source_2 IN VARCHAR2
103138 --Transaction Quantity
103139 , p_source_3 IN NUMBER
103140 --Transaction Unit of Measure Code
103141 , p_source_4 IN VARCHAR2
103142 --Inventory Transaction Type Description
103143 , p_source_5 IN VARCHAR2
103144 --Cost Management Default Account
103145 , p_source_11 IN NUMBER
103146 --Applied to Application ID
103147 , p_source_79 IN NUMBER
103148 --Applied to Distribution Link Type
103149 , p_source_80 IN VARCHAR2
103150 --Applied to Entity Code
103151 , p_source_81 IN VARCHAR2
103152 --DISTRIBUTION_IDENTIFIER
103153 , p_source_84 IN NUMBER
103154 --Distribution Type
103155 , p_source_85 IN VARCHAR2
103156 , p_source_85_meaning IN VARCHAR2
103157 --Encumbrance Reversal Amount Entered
103158 , p_source_87 IN NUMBER
103159 --Entered Currency Code
103160 , p_source_88 IN VARCHAR2
103161 --Transaction Encumbrance Reversal Amount
103162 , p_source_89 IN NUMBER
103163 --Entered Amount
103164 , p_source_91 IN NUMBER
103165 --Currency Conversion Date
103166 , p_source_92 IN DATE
103167 --Currency Conversion Rate
103168 , p_source_93 IN NUMBER
103169 --Currency Conversion Type
103170 , p_source_94 IN VARCHAR2
103171 --Accounted Amount
103172 , p_source_95 IN NUMBER
103173 --Accounting Line Type
103174 , p_source_97 IN NUMBER
103175 --Costing Encumbrance Upgrade Option
103176 , p_source_100 IN VARCHAR2
103177 --TXN_PO_DISTRIBUTION_ID
103178 , p_source_101 IN NUMBER
103179 --TXN_PO_HEADER_ID
103180 , p_source_102 IN NUMBER
103181 --Requisition Budget Account
103182 , p_source_103 IN NUMBER
103183 --Requisition Encumbrance Type Identifier
103184 , p_source_104 IN NUMBER
103185 )
103186 IS
103187
103188 l_component_type VARCHAR2(80);
103189 l_component_code VARCHAR2(30);
103190 l_component_type_code VARCHAR2(1);
103191 l_component_appl_id INTEGER;
103192 l_amb_context_code VARCHAR2(30);
103193 l_entity_code VARCHAR2(30);
103194 l_event_class_code VARCHAR2(30);
103195 l_ae_header_id NUMBER;
103196 l_event_type_code VARCHAR2(30);
103197 l_line_definition_code VARCHAR2(30);
103198 l_line_definition_owner_code VARCHAR2(1);
103199 --
103200 -- adr variables
103201 l_segment VARCHAR2(30);
103202 l_ccid NUMBER;
103203 l_adr_transaction_coa_id NUMBER;
103204 l_adr_accounting_coa_id NUMBER;
103205 l_adr_flexfield_segment_code VARCHAR2(30);
103206 l_adr_flex_value_set_id NUMBER;
103207 l_adr_value_type_code VARCHAR2(30);
103208 l_adr_value_combination_id NUMBER;
103209 l_adr_value_segment_code VARCHAR2(30);
103210
103211 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
103212 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
103213 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
103214 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
103215
103216 -- 4262811 Variables ------------------------------------------------------------------------------------------
103217 l_entered_amt_idx NUMBER;
103218 l_accted_amt_idx NUMBER;
103219 l_acc_rev_flag VARCHAR2(1);
103220 l_accrual_line_num NUMBER;
103221 l_tmp_amt NUMBER;
103222 l_acc_rev_natural_side_code VARCHAR2(1);
103223
103224 l_num_entries NUMBER;
103225 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
103226 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
103227 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
103228 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
103229 l_recog_line_1 NUMBER;
103230 l_recog_line_2 NUMBER;
103231
103232 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
103233 l_bflow_applied_to_amt NUMBER; -- 5132302
103234 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
103235
103236 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
103237
103238 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
103239 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
103240
103241 ---------------------------------------------------------------------------------------------------------------
103242
103243
103244 --
103245 -- bulk performance
103246 --
103247 l_balance_type_code VARCHAR2(1);
103248 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
103249 l_log_module VARCHAR2(240);
103250
103251 --
103252 -- Upgrade strategy
103253 --
103254 l_actual_upg_option VARCHAR2(1);
103255 l_enc_upg_option VARCHAR2(1);
103256
103257 --
103258 BEGIN
103259 --
103260 IF g_log_enabled THEN
103261 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_205';
103262 END IF;
103263 --
103264 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
103265
103266 trace
103267 (p_msg => 'BEGIN of AcctLineType_205'
103268 ,p_level => C_LEVEL_PROCEDURE
103269 ,p_module => l_log_module);
103270
103271 END IF;
103272 --
103273 l_component_type := 'AMB_JLT';
103274 l_component_code := 'INTERORG_TRANSFER_CREDIT';
103275 l_component_type_code := 'S';
103276 l_component_appl_id := 707;
103277 l_amb_context_code := 'DEFAULT';
103278 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
103279 l_event_class_code := 'DIR_INTERORG_RCPT';
103280 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
103281 l_line_definition_owner_code := 'S';
103282 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
103283 --
103284 l_balance_type_code := 'A';
103285 l_segment := NULL;
103286 l_ccid := NULL;
103287 l_adr_transaction_coa_id := NULL;
103288 l_adr_accounting_coa_id := NULL;
103289 l_adr_flexfield_segment_code := NULL;
103290 l_adr_flex_value_set_id := NULL;
103291 l_adr_value_type_code := NULL;
103292 l_adr_value_combination_id := NULL;
103293 l_adr_value_segment_code := NULL;
103294
103295 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
103296 l_bflow_class_code := ''; -- 4219869 Business Flow
103297 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
103298 l_budgetary_control_flag := 'N';
103299
103300 l_bflow_applied_to_amt_idx := NULL; -- 5132302
103301 l_bflow_applied_to_amt := NULL; -- 5132302
103302 l_entered_amt_idx := NULL; -- 4262811
103303 l_accted_amt_idx := NULL; -- 4262811
103304 l_acc_rev_flag := NULL; -- 4262811
103305 l_accrual_line_num := NULL; -- 4262811
103306 l_tmp_amt := NULL; -- 4262811
103307 --
103308
103309 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
103310 l_balance_type_code <> 'B' THEN
103311 IF NVL(p_source_97,9E125) = 11
103312 THEN
103313
103314 --
103315 XLA_AE_LINES_PKG.SetNewLine;
103316
103317 p_balance_type_code := l_balance_type_code;
103318 -- set the flag so later we will know whether the gain loss line needs to be created
103319
103320 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
103321 p_actual_flag :='A';
103322 END IF;
103323
103324 --
103325 -- bulk performance
103326 --
103327 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
103328 p_header_num => 0); -- 4262811
103329 --
103330 -- set accounting line options
103331 --
103332 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
103333 p_natural_side_code => 'D'
103334 , p_gain_or_loss_flag => 'N'
103335 , p_gl_transfer_mode_code => 'S'
103336 , p_acct_entry_type_code => 'A'
103337 , p_switch_side_flag => 'Y'
103338 , p_merge_duplicate_code => 'N'
103339 );
103340 --
103341 l_acc_rev_natural_side_code := 'C'; -- 4262811
103342 --
103343 --
103344 -- set accounting line type info
103345 --
103346 xla_ae_lines_pkg.SetAcctLineType
103347 (p_component_type => l_component_type
103348 ,p_event_type_code => l_event_type_code
103349 ,p_line_definition_owner_code => l_line_definition_owner_code
103350 ,p_line_definition_code => l_line_definition_code
103351 ,p_accounting_line_code => l_component_code
103352 ,p_accounting_line_type_code => l_component_type_code
103353 ,p_accounting_line_appl_id => l_component_appl_id
103354 ,p_amb_context_code => l_amb_context_code
103355 ,p_entity_code => l_entity_code
103356 ,p_event_class_code => l_event_class_code);
103357 --
103358 -- set accounting class
103359 --
103360 xla_ae_lines_pkg.SetAcctClass(
103361 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
103362 , p_ae_header_id => l_ae_header_id
103363 );
103364
103365 --
103366 -- set rounding class
103367 --
103368 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
103369 'INTERORG_TRANSFER_CREDIT';
103370
103371 --
103372 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
103373 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
103374 --
103375 -- bulk performance
103376 --
103377 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
103378
103379 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
103380 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
103381
103382 -- 4955764
103383 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
103384 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
103385
103386 -- 4458381 Public Sector Enh
103387
103388 --
103389 -- set accounting attributes for the line type
103390 --
103391 l_entered_amt_idx := 17;
103392 l_accted_amt_idx := 22;
103393 l_bflow_applied_to_amt_idx := NULL; -- 5132302
103394 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
103395 l_rec_acct_attrs.array_num_value(1) := p_source_79;
103396 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
103397 l_rec_acct_attrs.array_char_value(2) := p_source_80;
103398 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
103399 l_rec_acct_attrs.array_char_value(3) := p_source_81;
103400 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
103401 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
103402 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
103403 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
103404 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
103405 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
103406 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
103407 l_rec_acct_attrs.array_char_value(7) := p_source_85;
103408 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
103409 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
103410 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
103411 l_rec_acct_attrs.array_num_value(9) := p_source_87;
103412 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
103413 l_rec_acct_attrs.array_char_value(10) := p_source_88;
103414 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
103415 l_rec_acct_attrs.array_num_value(11) := p_source_89;
103416 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
103417 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
103418 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
103419 l_rec_acct_attrs.array_num_value(13) := p_source_87;
103420 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
103421 l_rec_acct_attrs.array_char_value(14) := p_source_88;
103422 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
103423 l_rec_acct_attrs.array_num_value(15) := p_source_89;
103424 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
103425 l_rec_acct_attrs.array_char_value(16) := p_source_100;
103426 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
103427 l_rec_acct_attrs.array_num_value(17) := p_source_91;
103428 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
103429 l_rec_acct_attrs.array_char_value(18) := p_source_88;
103430 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
103431 l_rec_acct_attrs.array_date_value(19) := p_source_92;
103432 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
103433 l_rec_acct_attrs.array_num_value(20) := p_source_93;
103434 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
103435 l_rec_acct_attrs.array_char_value(21) := p_source_94;
103436 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
103437 l_rec_acct_attrs.array_num_value(22) := p_source_95;
103438 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
103439 l_rec_acct_attrs.array_num_value(23) := p_source_104;
103440 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
103441 l_rec_acct_attrs.array_num_value(24) := p_source_104;
103442
103443 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
103444 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
103445
103446 ---------------------------------------------------------------------------------------------------------------
103447 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
103448 ---------------------------------------------------------------------------------------------------------------
103449 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
103450
103451 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
103452 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
103453
103454 IF xla_accounting_cache_pkg.GetValueChar
103455 (p_source_code => 'LEDGER_CATEGORY_CODE'
103456 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
103457 AND l_bflow_method_code = 'PRIOR_ENTRY'
103458 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
103459 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
103460 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
103461 )
103462 THEN
103463 xla_ae_lines_pkg.BflowUpgEntry
103464 (p_business_method_code => l_bflow_method_code
103465 ,p_business_class_code => l_bflow_class_code
103466 ,p_balance_type => l_balance_type_code);
103467 ELSE
103468 NULL;
103469 -- No business flow processing for business flow method of NONE.
103470 END IF;
103471
103472 --
103473 -- call analytical criteria
103474 --
103475
103476 --
103477 -- call description
103478 --
103479
103480 xla_ae_lines_pkg.SetLineDescription(
103481 p_ae_header_id => l_ae_header_id
103482 ,p_description => Description_1 (
103483 p_application_id => p_application_id
103484 , p_ae_header_id => l_ae_header_id
103485 , p_source_1 => p_source_1
103486 , p_source_2 => p_source_2
103487 , p_source_3 => p_source_3
103488 , p_source_4 => p_source_4
103489 , p_source_5 => p_source_5
103490 )
103491 );
103492
103493
103494 --
103495 -- call ADRs
103496 -- Bug 4922099
103497 --
103498 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
103499 (NVL(l_actual_upg_option, 'N') = 'O') OR
103500 (NVL(l_enc_upg_option, 'N') = 'O')
103501 )
103502 THEN
103503 NULL;
103504 --
103505 --
103506
103507 l_ccid := AcctDerRule_6(
103508 p_application_id => p_application_id
103509 , p_ae_header_id => l_ae_header_id
103510 , p_source_11 => p_source_11
103511 , x_transaction_coa_id => l_adr_transaction_coa_id
103512 , x_accounting_coa_id => l_adr_accounting_coa_id
103513 , x_value_type_code => l_adr_value_type_code
103514 , p_side => 'NA'
103515 );
103516
103517 xla_ae_lines_pkg.set_ccid(
103518 p_code_combination_id => l_ccid
103519 , p_value_type_code => l_adr_value_type_code
103520 , p_transaction_coa_id => l_adr_transaction_coa_id
103521 , p_accounting_coa_id => l_adr_accounting_coa_id
103522 , p_adr_code => 'CST_DEFAULT'
103523 , p_adr_type_code => 'S'
103524 , p_component_type => l_component_type
103525 , p_component_code => l_component_code
103526 , p_component_type_code => l_component_type_code
103527 , p_component_appl_id => l_component_appl_id
103528 , p_amb_context_code => l_amb_context_code
103529 , p_side => 'NA'
103530 );
103531
103532
103533 --
103534 --
103535 END IF;
103536 --
103537 -- Bug 4922099
103538 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
103539 (NVL(l_enc_upg_option, 'N') = 'O')
103540 ) AND
103541 (l_bflow_method_code = 'PRIOR_ENTRY')
103542 )
103543 THEN
103544 IF
103545 --
103546 1 = 2
103547 --
103548 THEN
103549 xla_accounting_err_pkg.build_message
103550 (p_appli_s_name => 'XLA'
103551 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
103552 ,p_token_1 => 'LINE_NUMBER'
103553 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
103554 ,p_token_2 => 'LINE_TYPE_NAME'
103555 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
103556 l_component_type
103557 ,l_component_code
103558 ,l_component_type_code
103559 ,l_component_appl_id
103560 ,l_amb_context_code
103561 ,l_entity_code
103562 ,l_event_class_code
103563 )
103564 ,p_token_3 => 'OWNER'
103565 ,p_value_3 => xla_lookups_pkg.get_meaning(
103566 p_lookup_type => 'XLA_OWNER_TYPE'
103567 ,p_lookup_code => l_component_type_code
103568 )
103569 ,p_token_4 => 'PRODUCT_NAME'
103570 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
103571 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
103572 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
103573 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
103574 ,p_ae_header_id => NULL
103575 );
103576
103577 IF (C_LEVEL_ERROR>= g_log_level) THEN
103578 trace
103579 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
103580 ,p_level => C_LEVEL_ERROR
103581 ,p_module => l_log_module);
103582 END IF;
103583 END IF;
103584 END IF;
103585 --
103586 --
103587 ------------------------------------------------------------------------------------------------
103588 -- 4219869 Business Flow
103589 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
103590 -- Prior Entry. Currently, the following code is always generated.
103591 ------------------------------------------------------------------------------------------------
103592 XLA_AE_LINES_PKG.ValidateCurrentLine;
103593
103594 ------------------------------------------------------------------------------------
103595 -- 4219869 Business Flow
103596 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
103597 ------------------------------------------------------------------------------------
103598 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
103599
103600 ----------------------------------------------------------------------------------
103601 -- 4219869 Business Flow
103602 -- Update journal entry status -- Need to generate this within IF <condition>
103603 ----------------------------------------------------------------------------------
103604 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
103605 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
103606 ,p_balance_type_code => l_balance_type_code
103607 );
103608
103609 -------------------------------------------------------------------------------------------
103610 -- 4262811 - Generate the Accrual Reversal lines
103611 -------------------------------------------------------------------------------------------
103612 BEGIN
103613 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
103614 (g_array_event(p_event_id).array_value_num('header_index'));
103615 IF l_acc_rev_flag IS NULL THEN
103616 l_acc_rev_flag := 'N';
103617 END IF;
103618 EXCEPTION
103619 WHEN OTHERS THEN
103620 l_acc_rev_flag := 'N';
103621 END;
103622 --
103623 IF (l_acc_rev_flag = 'Y') THEN
103624
103625 -- 4645092 ------------------------------------------------------------------------------
103626 -- To allow MPA report to determine if it should generate report process
103627 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
103628 ------------------------------------------------------------------------------------------
103629
103630 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
103631 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
103632 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
103633 -- call ADRs
103634 -- Bug 4922099
103635 --
103636 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
103637 (NVL(l_actual_upg_option, 'N') = 'O') OR
103638 (NVL(l_enc_upg_option, 'N') = 'O')
103639 )
103640 THEN
103641 NULL;
103642 --
103643 --
103644
103645 l_ccid := AcctDerRule_6(
103646 p_application_id => p_application_id
103647 , p_ae_header_id => l_ae_header_id
103648 , p_source_11 => p_source_11
103649 , x_transaction_coa_id => l_adr_transaction_coa_id
103650 , x_accounting_coa_id => l_adr_accounting_coa_id
103651 , x_value_type_code => l_adr_value_type_code
103652 , p_side => 'NA'
103653 );
103654
103655 xla_ae_lines_pkg.set_ccid(
103656 p_code_combination_id => l_ccid
103657 , p_value_type_code => l_adr_value_type_code
103658 , p_transaction_coa_id => l_adr_transaction_coa_id
103659 , p_accounting_coa_id => l_adr_accounting_coa_id
103660 , p_adr_code => 'CST_DEFAULT'
103661 , p_adr_type_code => 'S'
103662 , p_component_type => l_component_type
103663 , p_component_code => l_component_code
103664 , p_component_type_code => l_component_type_code
103665 , p_component_appl_id => l_component_appl_id
103666 , p_amb_context_code => l_amb_context_code
103667 , p_side => 'NA'
103668 );
103669
103670
103671 --
103672 --
103673 END IF;
103674
103675 --
103676 -- Update the line information that should be overwritten
103677 --
103678 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
103679 p_header_num => 1);
103680 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
103681
103682 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
103683
103684 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
103685 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
103686 END IF;
103687
103688 --
103689 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
103690 --
103691 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
103692 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
103693 ELSE
103694 ---------------------------------------------------------------------------------------------------
103695 -- 4262811a Switch Sign
103696 ---------------------------------------------------------------------------------------------------
103697 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
103698 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
103699 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103700 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
103701 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103702 -- 5132302
103703 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
103704 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
103705
103706 END IF;
103707
103708 -- 4955764
103709 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
103710 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
103711
103712
103713 XLA_AE_LINES_PKG.ValidateCurrentLine;
103714 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
103715
103716 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
103717 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
103718 ,p_balance_type_code => l_balance_type_code);
103719
103720 END IF;
103721
103722 -----------------------------------------------------------------------------------------
103723 -- 4262811 Multiperiod Accounting
103724 -----------------------------------------------------------------------------------------
103725 -- No MPA option is assigned.
103726
103727
103728 END IF;
103729 END IF;
103730 --
103731
103732 --
103733 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
103734 trace
103735 (p_msg => 'END of AcctLineType_205'
103736 ,p_level => C_LEVEL_PROCEDURE
103737 ,p_module => l_log_module);
103738 END IF;
103739 --
103740 EXCEPTION
103741 WHEN xla_exceptions_pkg.application_exception THEN
103742 RAISE;
103743 WHEN OTHERS THEN
103744 xla_exceptions_pkg.raise_message
103745 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_205');
103746 END AcctLineType_205;
103747 --
103748
103749 ---------------------------------------
103750 --
103751 -- PRIVATE FUNCTION
103752 -- AcctLineType_206
103753 --
103754 ---------------------------------------
103755 PROCEDURE AcctLineType_206 (
103756 p_application_id IN NUMBER
103757 ,p_event_id IN NUMBER
103758 ,p_calculate_acctd_flag IN VARCHAR2
103759 ,p_calculate_g_l_flag IN VARCHAR2
103760 ,p_actual_flag IN OUT VARCHAR2
103761 ,p_balance_type_code OUT VARCHAR2
103762 ,p_gain_or_loss_ref OUT VARCHAR2
103763
103764 --TRANSACTION_ID
103765 , p_source_1 IN NUMBER
103766 --Item Concatenated Segments
103767 , p_source_2 IN VARCHAR2
103768 --Transaction Quantity
103769 , p_source_3 IN NUMBER
103770 --Transaction Unit of Measure Code
103771 , p_source_4 IN VARCHAR2
103772 --Inventory Transaction Type Description
103773 , p_source_5 IN VARCHAR2
103774 --Interorg Transfer Credit Account
103775 , p_source_40 IN NUMBER
103776 --DISTRIBUTION_IDENTIFIER
103777 , p_source_84 IN NUMBER
103778 --Distribution Type
103779 , p_source_85 IN VARCHAR2
103780 , p_source_85_meaning IN VARCHAR2
103781 --Entered Currency Code
103782 , p_source_88 IN VARCHAR2
103783 --Entered Amount
103784 , p_source_91 IN NUMBER
103785 --Currency Conversion Date
103786 , p_source_92 IN DATE
103787 --Currency Conversion Rate
103788 , p_source_93 IN NUMBER
103789 --Currency Conversion Type
103790 , p_source_94 IN VARCHAR2
103791 --Accounted Amount
103792 , p_source_95 IN NUMBER
103793 --Accounting Line Type
103794 , p_source_97 IN NUMBER
103795 )
103796 IS
103797
103798 l_component_type VARCHAR2(80);
103799 l_component_code VARCHAR2(30);
103800 l_component_type_code VARCHAR2(1);
103801 l_component_appl_id INTEGER;
103802 l_amb_context_code VARCHAR2(30);
103803 l_entity_code VARCHAR2(30);
103804 l_event_class_code VARCHAR2(30);
103805 l_ae_header_id NUMBER;
103806 l_event_type_code VARCHAR2(30);
103807 l_line_definition_code VARCHAR2(30);
103808 l_line_definition_owner_code VARCHAR2(1);
103809 --
103810 -- adr variables
103811 l_segment VARCHAR2(30);
103812 l_ccid NUMBER;
103813 l_adr_transaction_coa_id NUMBER;
103814 l_adr_accounting_coa_id NUMBER;
103815 l_adr_flexfield_segment_code VARCHAR2(30);
103816 l_adr_flex_value_set_id NUMBER;
103817 l_adr_value_type_code VARCHAR2(30);
103818 l_adr_value_combination_id NUMBER;
103819 l_adr_value_segment_code VARCHAR2(30);
103820
103821 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
103822 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
103823 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
103824 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
103825
103826 -- 4262811 Variables ------------------------------------------------------------------------------------------
103827 l_entered_amt_idx NUMBER;
103828 l_accted_amt_idx NUMBER;
103829 l_acc_rev_flag VARCHAR2(1);
103830 l_accrual_line_num NUMBER;
103831 l_tmp_amt NUMBER;
103832 l_acc_rev_natural_side_code VARCHAR2(1);
103833
103834 l_num_entries NUMBER;
103835 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
103836 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
103837 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
103838 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
103839 l_recog_line_1 NUMBER;
103840 l_recog_line_2 NUMBER;
103841
103842 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
103843 l_bflow_applied_to_amt NUMBER; -- 5132302
103844 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
103845
103846 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
103847
103848 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
103849 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
103850
103851 ---------------------------------------------------------------------------------------------------------------
103852
103853
103854 --
103855 -- bulk performance
103856 --
103857 l_balance_type_code VARCHAR2(1);
103858 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
103859 l_log_module VARCHAR2(240);
103860
103861 --
103862 -- Upgrade strategy
103863 --
103864 l_actual_upg_option VARCHAR2(1);
103865 l_enc_upg_option VARCHAR2(1);
103866
103867 --
103868 BEGIN
103869 --
103870 IF g_log_enabled THEN
103871 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_206';
103872 END IF;
103873 --
103874 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
103875
103876 trace
103877 (p_msg => 'BEGIN of AcctLineType_206'
103878 ,p_level => C_LEVEL_PROCEDURE
103879 ,p_module => l_log_module);
103880
103881 END IF;
103882 --
103883 l_component_type := 'AMB_JLT';
103884 l_component_code := 'INTERORG_TRANSFER_CREDIT';
103885 l_component_type_code := 'S';
103886 l_component_appl_id := 707;
103887 l_amb_context_code := 'DEFAULT';
103888 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
103889 l_event_class_code := 'USER_DEFINE';
103890 l_event_type_code := 'UDIR_INTERORG_SHIP';
103891 l_line_definition_owner_code := 'S';
103892 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
103893 --
103894 l_balance_type_code := 'A';
103895 l_segment := NULL;
103896 l_ccid := NULL;
103897 l_adr_transaction_coa_id := NULL;
103898 l_adr_accounting_coa_id := NULL;
103899 l_adr_flexfield_segment_code := NULL;
103900 l_adr_flex_value_set_id := NULL;
103901 l_adr_value_type_code := NULL;
103902 l_adr_value_combination_id := NULL;
103903 l_adr_value_segment_code := NULL;
103904
103905 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
103906 l_bflow_class_code := ''; -- 4219869 Business Flow
103907 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
103908 l_budgetary_control_flag := 'N';
103909
103910 l_bflow_applied_to_amt_idx := NULL; -- 5132302
103911 l_bflow_applied_to_amt := NULL; -- 5132302
103912 l_entered_amt_idx := NULL; -- 4262811
103913 l_accted_amt_idx := NULL; -- 4262811
103914 l_acc_rev_flag := NULL; -- 4262811
103915 l_accrual_line_num := NULL; -- 4262811
103916 l_tmp_amt := NULL; -- 4262811
103917 --
103918
103919 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
103920 l_balance_type_code <> 'B' THEN
103921 IF NVL(p_source_97,9E125) = 11
103922 THEN
103923
103924 --
103925 XLA_AE_LINES_PKG.SetNewLine;
103926
103927 p_balance_type_code := l_balance_type_code;
103928 -- set the flag so later we will know whether the gain loss line needs to be created
103929
103930 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
103931 p_actual_flag :='A';
103932 END IF;
103933
103934 --
103935 -- bulk performance
103936 --
103937 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
103938 p_header_num => 0); -- 4262811
103939 --
103940 -- set accounting line options
103941 --
103942 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
103943 p_natural_side_code => 'D'
103944 , p_gain_or_loss_flag => 'N'
103945 , p_gl_transfer_mode_code => 'S'
103946 , p_acct_entry_type_code => 'A'
103947 , p_switch_side_flag => 'Y'
103948 , p_merge_duplicate_code => 'N'
103949 );
103950 --
103951 l_acc_rev_natural_side_code := 'C'; -- 4262811
103952 --
103953 --
103954 -- set accounting line type info
103955 --
103956 xla_ae_lines_pkg.SetAcctLineType
103957 (p_component_type => l_component_type
103958 ,p_event_type_code => l_event_type_code
103959 ,p_line_definition_owner_code => l_line_definition_owner_code
103960 ,p_line_definition_code => l_line_definition_code
103961 ,p_accounting_line_code => l_component_code
103962 ,p_accounting_line_type_code => l_component_type_code
103963 ,p_accounting_line_appl_id => l_component_appl_id
103964 ,p_amb_context_code => l_amb_context_code
103965 ,p_entity_code => l_entity_code
103966 ,p_event_class_code => l_event_class_code);
103967 --
103968 -- set accounting class
103969 --
103970 xla_ae_lines_pkg.SetAcctClass(
103971 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
103972 , p_ae_header_id => l_ae_header_id
103973 );
103974
103975 --
103976 -- set rounding class
103977 --
103978 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
103979 'INTERORG_TRANSFER_CREDIT';
103980
103981 --
103982 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
103983 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
103984 --
103985 -- bulk performance
103986 --
103987 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
103988
103989 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
103990 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
103991
103992 -- 4955764
103993 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
103994 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
103995
103996 -- 4458381 Public Sector Enh
103997
103998 --
103999 -- set accounting attributes for the line type
104000 --
104001 l_entered_amt_idx := 3;
104002 l_accted_amt_idx := 8;
104003 l_bflow_applied_to_amt_idx := NULL; -- 5132302
104004 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
104005 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
104006 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
104007 l_rec_acct_attrs.array_char_value(2) := p_source_85;
104008 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
104009 l_rec_acct_attrs.array_num_value(3) := p_source_91;
104010 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
104011 l_rec_acct_attrs.array_char_value(4) := p_source_88;
104012 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
104013 l_rec_acct_attrs.array_date_value(5) := p_source_92;
104014 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
104015 l_rec_acct_attrs.array_num_value(6) := p_source_93;
104016 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
104017 l_rec_acct_attrs.array_char_value(7) := p_source_94;
104018 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
104019 l_rec_acct_attrs.array_num_value(8) := p_source_95;
104020
104021 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
104022 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
104023
104024 ---------------------------------------------------------------------------------------------------------------
104025 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
104026 ---------------------------------------------------------------------------------------------------------------
104027 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
104028
104029 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
104030 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
104031
104032 IF xla_accounting_cache_pkg.GetValueChar
104033 (p_source_code => 'LEDGER_CATEGORY_CODE'
104034 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
104035 AND l_bflow_method_code = 'PRIOR_ENTRY'
104036 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
104037 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
104038 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
104039 )
104040 THEN
104041 xla_ae_lines_pkg.BflowUpgEntry
104042 (p_business_method_code => l_bflow_method_code
104043 ,p_business_class_code => l_bflow_class_code
104044 ,p_balance_type => l_balance_type_code);
104045 ELSE
104046 NULL;
104047 -- No business flow processing for business flow method of NONE.
104048 END IF;
104049
104050 --
104051 -- call analytical criteria
104052 --
104053
104054 --
104055 -- call description
104056 --
104057
104058 xla_ae_lines_pkg.SetLineDescription(
104059 p_ae_header_id => l_ae_header_id
104060 ,p_description => Description_1 (
104061 p_application_id => p_application_id
104062 , p_ae_header_id => l_ae_header_id
104063 , p_source_1 => p_source_1
104064 , p_source_2 => p_source_2
104065 , p_source_3 => p_source_3
104066 , p_source_4 => p_source_4
104067 , p_source_5 => p_source_5
104068 )
104069 );
104070
104071
104072 --
104073 -- call ADRs
104074 -- Bug 4922099
104075 --
104076 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
104077 (NVL(l_actual_upg_option, 'N') = 'O') OR
104078 (NVL(l_enc_upg_option, 'N') = 'O')
104079 )
104080 THEN
104081 NULL;
104082 --
104083 --
104084
104085 l_ccid := AcctDerRule_24(
104086 p_application_id => p_application_id
104087 , p_ae_header_id => l_ae_header_id
104088 , p_source_40 => p_source_40
104089 , x_transaction_coa_id => l_adr_transaction_coa_id
104090 , x_accounting_coa_id => l_adr_accounting_coa_id
104091 , x_value_type_code => l_adr_value_type_code
104092 , p_side => 'NA'
104093 );
104094
104095 xla_ae_lines_pkg.set_ccid(
104096 p_code_combination_id => l_ccid
104097 , p_value_type_code => l_adr_value_type_code
104098 , p_transaction_coa_id => l_adr_transaction_coa_id
104099 , p_accounting_coa_id => l_adr_accounting_coa_id
104100 , p_adr_code => 'PI_INTERORG_TRANSFER'
104101 , p_adr_type_code => 'S'
104102 , p_component_type => l_component_type
104103 , p_component_code => l_component_code
104104 , p_component_type_code => l_component_type_code
104105 , p_component_appl_id => l_component_appl_id
104106 , p_amb_context_code => l_amb_context_code
104107 , p_side => 'NA'
104108 );
104109
104110
104111 --
104112 --
104113 END IF;
104114 --
104115 -- Bug 4922099
104116 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
104117 (NVL(l_enc_upg_option, 'N') = 'O')
104118 ) AND
104119 (l_bflow_method_code = 'PRIOR_ENTRY')
104120 )
104121 THEN
104122 IF
104123 --
104124 1 = 2
104125 --
104126 THEN
104127 xla_accounting_err_pkg.build_message
104128 (p_appli_s_name => 'XLA'
104129 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
104130 ,p_token_1 => 'LINE_NUMBER'
104131 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
104132 ,p_token_2 => 'LINE_TYPE_NAME'
104133 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
104134 l_component_type
104135 ,l_component_code
104136 ,l_component_type_code
104137 ,l_component_appl_id
104138 ,l_amb_context_code
104139 ,l_entity_code
104140 ,l_event_class_code
104141 )
104142 ,p_token_3 => 'OWNER'
104143 ,p_value_3 => xla_lookups_pkg.get_meaning(
104144 p_lookup_type => 'XLA_OWNER_TYPE'
104145 ,p_lookup_code => l_component_type_code
104146 )
104147 ,p_token_4 => 'PRODUCT_NAME'
104148 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
104149 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
104150 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
104151 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
104152 ,p_ae_header_id => NULL
104153 );
104154
104155 IF (C_LEVEL_ERROR>= g_log_level) THEN
104156 trace
104157 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
104158 ,p_level => C_LEVEL_ERROR
104159 ,p_module => l_log_module);
104160 END IF;
104161 END IF;
104162 END IF;
104163 --
104164 --
104165 ------------------------------------------------------------------------------------------------
104166 -- 4219869 Business Flow
104167 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
104168 -- Prior Entry. Currently, the following code is always generated.
104169 ------------------------------------------------------------------------------------------------
104170 XLA_AE_LINES_PKG.ValidateCurrentLine;
104171
104172 ------------------------------------------------------------------------------------
104173 -- 4219869 Business Flow
104174 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
104175 ------------------------------------------------------------------------------------
104176 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
104177
104178 ----------------------------------------------------------------------------------
104179 -- 4219869 Business Flow
104180 -- Update journal entry status -- Need to generate this within IF <condition>
104181 ----------------------------------------------------------------------------------
104182 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
104183 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
104184 ,p_balance_type_code => l_balance_type_code
104185 );
104186
104187 -------------------------------------------------------------------------------------------
104188 -- 4262811 - Generate the Accrual Reversal lines
104189 -------------------------------------------------------------------------------------------
104190 BEGIN
104191 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
104192 (g_array_event(p_event_id).array_value_num('header_index'));
104193 IF l_acc_rev_flag IS NULL THEN
104194 l_acc_rev_flag := 'N';
104195 END IF;
104196 EXCEPTION
104197 WHEN OTHERS THEN
104198 l_acc_rev_flag := 'N';
104199 END;
104200 --
104201 IF (l_acc_rev_flag = 'Y') THEN
104202
104203 -- 4645092 ------------------------------------------------------------------------------
104204 -- To allow MPA report to determine if it should generate report process
104205 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
104206 ------------------------------------------------------------------------------------------
104207
104208 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
104209 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
104210 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
104211 -- call ADRs
104212 -- Bug 4922099
104213 --
104214 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
104215 (NVL(l_actual_upg_option, 'N') = 'O') OR
104216 (NVL(l_enc_upg_option, 'N') = 'O')
104217 )
104218 THEN
104219 NULL;
104220 --
104221 --
104222
104223 l_ccid := AcctDerRule_24(
104224 p_application_id => p_application_id
104225 , p_ae_header_id => l_ae_header_id
104226 , p_source_40 => p_source_40
104227 , x_transaction_coa_id => l_adr_transaction_coa_id
104228 , x_accounting_coa_id => l_adr_accounting_coa_id
104229 , x_value_type_code => l_adr_value_type_code
104230 , p_side => 'NA'
104231 );
104232
104233 xla_ae_lines_pkg.set_ccid(
104234 p_code_combination_id => l_ccid
104235 , p_value_type_code => l_adr_value_type_code
104236 , p_transaction_coa_id => l_adr_transaction_coa_id
104237 , p_accounting_coa_id => l_adr_accounting_coa_id
104238 , p_adr_code => 'PI_INTERORG_TRANSFER'
104239 , p_adr_type_code => 'S'
104240 , p_component_type => l_component_type
104241 , p_component_code => l_component_code
104242 , p_component_type_code => l_component_type_code
104243 , p_component_appl_id => l_component_appl_id
104244 , p_amb_context_code => l_amb_context_code
104245 , p_side => 'NA'
104246 );
104247
104248
104249 --
104250 --
104251 END IF;
104252
104253 --
104254 -- Update the line information that should be overwritten
104255 --
104256 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
104257 p_header_num => 1);
104258 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
104259
104260 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
104261
104262 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
104263 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
104264 END IF;
104265
104266 --
104267 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
104268 --
104269 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
104270 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
104271 ELSE
104272 ---------------------------------------------------------------------------------------------------
104273 -- 4262811a Switch Sign
104274 ---------------------------------------------------------------------------------------------------
104275 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
104276 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
104277 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104278 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
104279 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104280 -- 5132302
104281 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
104282 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104283
104284 END IF;
104285
104286 -- 4955764
104287 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
104288 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
104289
104290
104291 XLA_AE_LINES_PKG.ValidateCurrentLine;
104292 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
104293
104294 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
104295 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
104296 ,p_balance_type_code => l_balance_type_code);
104297
104298 END IF;
104299
104300 -----------------------------------------------------------------------------------------
104301 -- 4262811 Multiperiod Accounting
104302 -----------------------------------------------------------------------------------------
104303 -- No MPA option is assigned.
104304
104305
104306 END IF;
104307 END IF;
104308 --
104309
104310 --
104311 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
104312 trace
104313 (p_msg => 'END of AcctLineType_206'
104314 ,p_level => C_LEVEL_PROCEDURE
104315 ,p_module => l_log_module);
104316 END IF;
104317 --
104318 EXCEPTION
104319 WHEN xla_exceptions_pkg.application_exception THEN
104320 RAISE;
104321 WHEN OTHERS THEN
104322 xla_exceptions_pkg.raise_message
104323 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_206');
104324 END AcctLineType_206;
104325 --
104326
104327 ---------------------------------------
104328 --
104329 -- PRIVATE FUNCTION
104330 -- AcctLineType_207
104331 --
104332 ---------------------------------------
104333 PROCEDURE AcctLineType_207 (
104334 p_application_id IN NUMBER
104335 ,p_event_id IN NUMBER
104336 ,p_calculate_acctd_flag IN VARCHAR2
104337 ,p_calculate_g_l_flag IN VARCHAR2
104338 ,p_actual_flag IN OUT VARCHAR2
104339 ,p_balance_type_code OUT VARCHAR2
104340 ,p_gain_or_loss_ref OUT VARCHAR2
104341
104342 --Interorg Transfer Credit Account
104343 , p_source_40 IN NUMBER
104344 --DISTRIBUTION_IDENTIFIER
104345 , p_source_84 IN NUMBER
104346 --Distribution Type
104347 , p_source_85 IN VARCHAR2
104348 , p_source_85_meaning IN VARCHAR2
104349 --Entered Currency Code
104350 , p_source_88 IN VARCHAR2
104351 --Entered Amount
104352 , p_source_91 IN NUMBER
104353 --Currency Conversion Date
104354 , p_source_92 IN DATE
104355 --Currency Conversion Rate
104356 , p_source_93 IN NUMBER
104357 --Currency Conversion Type
104358 , p_source_94 IN VARCHAR2
104359 --Accounted Amount
104360 , p_source_95 IN NUMBER
104361 --Accounting Line Type
104362 , p_source_97 IN NUMBER
104363 )
104364 IS
104365
104366 l_component_type VARCHAR2(80);
104367 l_component_code VARCHAR2(30);
104368 l_component_type_code VARCHAR2(1);
104369 l_component_appl_id INTEGER;
104370 l_amb_context_code VARCHAR2(30);
104371 l_entity_code VARCHAR2(30);
104372 l_event_class_code VARCHAR2(30);
104373 l_ae_header_id NUMBER;
104374 l_event_type_code VARCHAR2(30);
104375 l_line_definition_code VARCHAR2(30);
104376 l_line_definition_owner_code VARCHAR2(1);
104377 --
104378 -- adr variables
104379 l_segment VARCHAR2(30);
104380 l_ccid NUMBER;
104381 l_adr_transaction_coa_id NUMBER;
104382 l_adr_accounting_coa_id NUMBER;
104383 l_adr_flexfield_segment_code VARCHAR2(30);
104384 l_adr_flex_value_set_id NUMBER;
104385 l_adr_value_type_code VARCHAR2(30);
104386 l_adr_value_combination_id NUMBER;
104387 l_adr_value_segment_code VARCHAR2(30);
104388
104389 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
104390 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
104391 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
104392 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
104393
104394 -- 4262811 Variables ------------------------------------------------------------------------------------------
104395 l_entered_amt_idx NUMBER;
104396 l_accted_amt_idx NUMBER;
104397 l_acc_rev_flag VARCHAR2(1);
104398 l_accrual_line_num NUMBER;
104399 l_tmp_amt NUMBER;
104400 l_acc_rev_natural_side_code VARCHAR2(1);
104401
104402 l_num_entries NUMBER;
104403 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
104404 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
104405 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
104406 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
104407 l_recog_line_1 NUMBER;
104408 l_recog_line_2 NUMBER;
104409
104410 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
104411 l_bflow_applied_to_amt NUMBER; -- 5132302
104412 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
104413
104414 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
104415
104416 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
104417 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
104418
104419 ---------------------------------------------------------------------------------------------------------------
104420
104421
104422 --
104423 -- bulk performance
104424 --
104425 l_balance_type_code VARCHAR2(1);
104426 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
104427 l_log_module VARCHAR2(240);
104428
104429 --
104430 -- Upgrade strategy
104431 --
104432 l_actual_upg_option VARCHAR2(1);
104433 l_enc_upg_option VARCHAR2(1);
104434
104435 --
104436 BEGIN
104437 --
104438 IF g_log_enabled THEN
104439 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_207';
104440 END IF;
104441 --
104442 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
104443
104444 trace
104445 (p_msg => 'BEGIN of AcctLineType_207'
104446 ,p_level => C_LEVEL_PROCEDURE
104447 ,p_module => l_log_module);
104448
104449 END IF;
104450 --
104451 l_component_type := 'AMB_JLT';
104452 l_component_code := 'INTERORG_TRANSFER_CREDIT';
104453 l_component_type_code := 'S';
104454 l_component_appl_id := 707;
104455 l_amb_context_code := 'DEFAULT';
104456 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
104457 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
104458 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
104459 l_line_definition_owner_code := 'S';
104460 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
104461 --
104462 l_balance_type_code := 'A';
104463 l_segment := NULL;
104464 l_ccid := NULL;
104465 l_adr_transaction_coa_id := NULL;
104466 l_adr_accounting_coa_id := NULL;
104467 l_adr_flexfield_segment_code := NULL;
104468 l_adr_flex_value_set_id := NULL;
104469 l_adr_value_type_code := NULL;
104470 l_adr_value_combination_id := NULL;
104471 l_adr_value_segment_code := NULL;
104472
104473 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
104474 l_bflow_class_code := ''; -- 4219869 Business Flow
104475 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
104476 l_budgetary_control_flag := 'N';
104477
104478 l_bflow_applied_to_amt_idx := NULL; -- 5132302
104479 l_bflow_applied_to_amt := NULL; -- 5132302
104480 l_entered_amt_idx := NULL; -- 4262811
104481 l_accted_amt_idx := NULL; -- 4262811
104482 l_acc_rev_flag := NULL; -- 4262811
104483 l_accrual_line_num := NULL; -- 4262811
104484 l_tmp_amt := NULL; -- 4262811
104485 --
104486
104487 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
104488 l_balance_type_code <> 'B' THEN
104489 IF NVL(p_source_97,9E125) = 11
104490 THEN
104491
104492 --
104493 XLA_AE_LINES_PKG.SetNewLine;
104494
104495 p_balance_type_code := l_balance_type_code;
104496 -- set the flag so later we will know whether the gain loss line needs to be created
104497
104498 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
104499 p_actual_flag :='A';
104500 END IF;
104501
104502 --
104503 -- bulk performance
104504 --
104505 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
104506 p_header_num => 0); -- 4262811
104507 --
104508 -- set accounting line options
104509 --
104510 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
104511 p_natural_side_code => 'D'
104512 , p_gain_or_loss_flag => 'N'
104513 , p_gl_transfer_mode_code => 'S'
104514 , p_acct_entry_type_code => 'A'
104515 , p_switch_side_flag => 'Y'
104516 , p_merge_duplicate_code => 'N'
104517 );
104518 --
104519 l_acc_rev_natural_side_code := 'C'; -- 4262811
104520 --
104521 --
104522 -- set accounting line type info
104523 --
104524 xla_ae_lines_pkg.SetAcctLineType
104525 (p_component_type => l_component_type
104526 ,p_event_type_code => l_event_type_code
104527 ,p_line_definition_owner_code => l_line_definition_owner_code
104528 ,p_line_definition_code => l_line_definition_code
104529 ,p_accounting_line_code => l_component_code
104530 ,p_accounting_line_type_code => l_component_type_code
104531 ,p_accounting_line_appl_id => l_component_appl_id
104532 ,p_amb_context_code => l_amb_context_code
104533 ,p_entity_code => l_entity_code
104534 ,p_event_class_code => l_event_class_code);
104535 --
104536 -- set accounting class
104537 --
104538 xla_ae_lines_pkg.SetAcctClass(
104539 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
104540 , p_ae_header_id => l_ae_header_id
104541 );
104542
104543 --
104544 -- set rounding class
104545 --
104546 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
104547 'INTERORG_TRANSFER_CREDIT';
104548
104549 --
104550 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
104551 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
104552 --
104553 -- bulk performance
104554 --
104555 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
104556
104557 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
104558 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
104559
104560 -- 4955764
104561 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
104562 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
104563
104564 -- 4458381 Public Sector Enh
104565
104566 --
104567 -- set accounting attributes for the line type
104568 --
104569 l_entered_amt_idx := 3;
104570 l_accted_amt_idx := 8;
104571 l_bflow_applied_to_amt_idx := NULL; -- 5132302
104572 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
104573 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
104574 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
104575 l_rec_acct_attrs.array_char_value(2) := p_source_85;
104576 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
104577 l_rec_acct_attrs.array_num_value(3) := p_source_91;
104578 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
104579 l_rec_acct_attrs.array_char_value(4) := p_source_88;
104580 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
104581 l_rec_acct_attrs.array_date_value(5) := p_source_92;
104582 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
104583 l_rec_acct_attrs.array_num_value(6) := p_source_93;
104584 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
104585 l_rec_acct_attrs.array_char_value(7) := p_source_94;
104586 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
104587 l_rec_acct_attrs.array_num_value(8) := p_source_95;
104588
104589 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
104590 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
104591
104592 ---------------------------------------------------------------------------------------------------------------
104593 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
104594 ---------------------------------------------------------------------------------------------------------------
104595 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
104596
104597 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
104598 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
104599
104600 IF xla_accounting_cache_pkg.GetValueChar
104601 (p_source_code => 'LEDGER_CATEGORY_CODE'
104602 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
104603 AND l_bflow_method_code = 'PRIOR_ENTRY'
104604 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
104605 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
104606 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
104607 )
104608 THEN
104609 xla_ae_lines_pkg.BflowUpgEntry
104610 (p_business_method_code => l_bflow_method_code
104611 ,p_business_class_code => l_bflow_class_code
104612 ,p_balance_type => l_balance_type_code);
104613 ELSE
104614 NULL;
104615 -- No business flow processing for business flow method of NONE.
104616 END IF;
104617
104618 --
104619 -- call analytical criteria
104620 --
104621
104622 --
104623 -- call description
104624 --
104625 -- No description or it is inherited.
104626 --
104627 -- call ADRs
104628 -- Bug 4922099
104629 --
104630 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
104631 (NVL(l_actual_upg_option, 'N') = 'O') OR
104632 (NVL(l_enc_upg_option, 'N') = 'O')
104633 )
104634 THEN
104635 NULL;
104636 --
104637 --
104638
104639 l_ccid := AcctDerRule_24(
104640 p_application_id => p_application_id
104641 , p_ae_header_id => l_ae_header_id
104642 , p_source_40 => p_source_40
104643 , x_transaction_coa_id => l_adr_transaction_coa_id
104644 , x_accounting_coa_id => l_adr_accounting_coa_id
104645 , x_value_type_code => l_adr_value_type_code
104646 , p_side => 'NA'
104647 );
104648
104649 xla_ae_lines_pkg.set_ccid(
104650 p_code_combination_id => l_ccid
104651 , p_value_type_code => l_adr_value_type_code
104652 , p_transaction_coa_id => l_adr_transaction_coa_id
104653 , p_accounting_coa_id => l_adr_accounting_coa_id
104654 , p_adr_code => 'PI_INTERORG_TRANSFER'
104655 , p_adr_type_code => 'S'
104656 , p_component_type => l_component_type
104657 , p_component_code => l_component_code
104658 , p_component_type_code => l_component_type_code
104659 , p_component_appl_id => l_component_appl_id
104660 , p_amb_context_code => l_amb_context_code
104661 , p_side => 'NA'
104662 );
104663
104664
104665 --
104666 --
104667 END IF;
104668 --
104669 -- Bug 4922099
104670 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
104671 (NVL(l_enc_upg_option, 'N') = 'O')
104672 ) AND
104673 (l_bflow_method_code = 'PRIOR_ENTRY')
104674 )
104675 THEN
104676 IF
104677 --
104678 1 = 2
104679 --
104680 THEN
104681 xla_accounting_err_pkg.build_message
104682 (p_appli_s_name => 'XLA'
104683 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
104684 ,p_token_1 => 'LINE_NUMBER'
104685 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
104686 ,p_token_2 => 'LINE_TYPE_NAME'
104687 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
104688 l_component_type
104689 ,l_component_code
104690 ,l_component_type_code
104691 ,l_component_appl_id
104692 ,l_amb_context_code
104693 ,l_entity_code
104694 ,l_event_class_code
104695 )
104696 ,p_token_3 => 'OWNER'
104697 ,p_value_3 => xla_lookups_pkg.get_meaning(
104698 p_lookup_type => 'XLA_OWNER_TYPE'
104699 ,p_lookup_code => l_component_type_code
104700 )
104701 ,p_token_4 => 'PRODUCT_NAME'
104702 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
104703 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
104704 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
104705 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
104706 ,p_ae_header_id => NULL
104707 );
104708
104709 IF (C_LEVEL_ERROR>= g_log_level) THEN
104710 trace
104711 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
104712 ,p_level => C_LEVEL_ERROR
104713 ,p_module => l_log_module);
104714 END IF;
104715 END IF;
104716 END IF;
104717 --
104718 --
104719 ------------------------------------------------------------------------------------------------
104720 -- 4219869 Business Flow
104721 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
104722 -- Prior Entry. Currently, the following code is always generated.
104723 ------------------------------------------------------------------------------------------------
104724 XLA_AE_LINES_PKG.ValidateCurrentLine;
104725
104726 ------------------------------------------------------------------------------------
104727 -- 4219869 Business Flow
104728 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
104729 ------------------------------------------------------------------------------------
104730 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
104731
104732 ----------------------------------------------------------------------------------
104733 -- 4219869 Business Flow
104734 -- Update journal entry status -- Need to generate this within IF <condition>
104735 ----------------------------------------------------------------------------------
104736 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
104737 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
104738 ,p_balance_type_code => l_balance_type_code
104739 );
104740
104741 -------------------------------------------------------------------------------------------
104742 -- 4262811 - Generate the Accrual Reversal lines
104743 -------------------------------------------------------------------------------------------
104744 BEGIN
104745 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
104746 (g_array_event(p_event_id).array_value_num('header_index'));
104747 IF l_acc_rev_flag IS NULL THEN
104748 l_acc_rev_flag := 'N';
104749 END IF;
104750 EXCEPTION
104751 WHEN OTHERS THEN
104752 l_acc_rev_flag := 'N';
104753 END;
104754 --
104755 IF (l_acc_rev_flag = 'Y') THEN
104756
104757 -- 4645092 ------------------------------------------------------------------------------
104758 -- To allow MPA report to determine if it should generate report process
104759 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
104760 ------------------------------------------------------------------------------------------
104761
104762 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
104763 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
104764 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
104765 -- call ADRs
104766 -- Bug 4922099
104767 --
104768 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
104769 (NVL(l_actual_upg_option, 'N') = 'O') OR
104770 (NVL(l_enc_upg_option, 'N') = 'O')
104771 )
104772 THEN
104773 NULL;
104774 --
104775 --
104776
104777 l_ccid := AcctDerRule_24(
104778 p_application_id => p_application_id
104779 , p_ae_header_id => l_ae_header_id
104780 , p_source_40 => p_source_40
104781 , x_transaction_coa_id => l_adr_transaction_coa_id
104782 , x_accounting_coa_id => l_adr_accounting_coa_id
104783 , x_value_type_code => l_adr_value_type_code
104784 , p_side => 'NA'
104785 );
104786
104787 xla_ae_lines_pkg.set_ccid(
104788 p_code_combination_id => l_ccid
104789 , p_value_type_code => l_adr_value_type_code
104790 , p_transaction_coa_id => l_adr_transaction_coa_id
104791 , p_accounting_coa_id => l_adr_accounting_coa_id
104792 , p_adr_code => 'PI_INTERORG_TRANSFER'
104793 , p_adr_type_code => 'S'
104794 , p_component_type => l_component_type
104795 , p_component_code => l_component_code
104796 , p_component_type_code => l_component_type_code
104797 , p_component_appl_id => l_component_appl_id
104798 , p_amb_context_code => l_amb_context_code
104799 , p_side => 'NA'
104800 );
104801
104802
104803 --
104804 --
104805 END IF;
104806
104807 --
104808 -- Update the line information that should be overwritten
104809 --
104810 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
104811 p_header_num => 1);
104812 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
104813
104814 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
104815
104816 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
104817 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
104818 END IF;
104819
104820 --
104821 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
104822 --
104823 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
104824 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
104825 ELSE
104826 ---------------------------------------------------------------------------------------------------
104827 -- 4262811a Switch Sign
104828 ---------------------------------------------------------------------------------------------------
104829 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
104830 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
104831 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104832 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
104833 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104834 -- 5132302
104835 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
104836 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
104837
104838 END IF;
104839
104840 -- 4955764
104841 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
104842 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
104843
104844
104845 XLA_AE_LINES_PKG.ValidateCurrentLine;
104846 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
104847
104848 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
104849 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
104850 ,p_balance_type_code => l_balance_type_code);
104851
104852 END IF;
104853
104854 -----------------------------------------------------------------------------------------
104855 -- 4262811 Multiperiod Accounting
104856 -----------------------------------------------------------------------------------------
104857 -- No MPA option is assigned.
104858
104859
104860 END IF;
104861 END IF;
104862 --
104863
104864 --
104865 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
104866 trace
104867 (p_msg => 'END of AcctLineType_207'
104868 ,p_level => C_LEVEL_PROCEDURE
104869 ,p_module => l_log_module);
104870 END IF;
104871 --
104872 EXCEPTION
104873 WHEN xla_exceptions_pkg.application_exception THEN
104874 RAISE;
104875 WHEN OTHERS THEN
104876 xla_exceptions_pkg.raise_message
104877 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_207');
104878 END AcctLineType_207;
104879 --
104880
104881 ---------------------------------------
104882 --
104883 -- PRIVATE FUNCTION
104884 -- AcctLineType_208
104885 --
104886 ---------------------------------------
104887 PROCEDURE AcctLineType_208 (
104888 p_application_id IN NUMBER
104889 ,p_event_id IN NUMBER
104890 ,p_calculate_acctd_flag IN VARCHAR2
104891 ,p_calculate_g_l_flag IN VARCHAR2
104892 ,p_actual_flag IN OUT VARCHAR2
104893 ,p_balance_type_code OUT VARCHAR2
104894 ,p_gain_or_loss_ref OUT VARCHAR2
104895
104896 --TRANSACTION_ID
104897 , p_source_1 IN NUMBER
104898 --Item Concatenated Segments
104899 , p_source_2 IN VARCHAR2
104900 --Transaction Quantity
104901 , p_source_3 IN NUMBER
104902 --Transaction Unit of Measure Code
104903 , p_source_4 IN VARCHAR2
104904 --Inventory Transaction Type Description
104905 , p_source_5 IN VARCHAR2
104906 --Interorg Transfer Credit Account
104907 , p_source_40 IN NUMBER
104908 --DISTRIBUTION_IDENTIFIER
104909 , p_source_84 IN NUMBER
104910 --Distribution Type
104911 , p_source_85 IN VARCHAR2
104912 , p_source_85_meaning IN VARCHAR2
104913 --Entered Currency Code
104914 , p_source_88 IN VARCHAR2
104915 --Entered Amount
104916 , p_source_91 IN NUMBER
104917 --Currency Conversion Date
104918 , p_source_92 IN DATE
104919 --Currency Conversion Rate
104920 , p_source_93 IN NUMBER
104921 --Currency Conversion Type
104922 , p_source_94 IN VARCHAR2
104923 --Accounted Amount
104924 , p_source_95 IN NUMBER
104925 --Accounting Line Type
104926 , p_source_97 IN NUMBER
104927 )
104928 IS
104929
104930 l_component_type VARCHAR2(80);
104931 l_component_code VARCHAR2(30);
104932 l_component_type_code VARCHAR2(1);
104933 l_component_appl_id INTEGER;
104934 l_amb_context_code VARCHAR2(30);
104935 l_entity_code VARCHAR2(30);
104936 l_event_class_code VARCHAR2(30);
104937 l_ae_header_id NUMBER;
104938 l_event_type_code VARCHAR2(30);
104939 l_line_definition_code VARCHAR2(30);
104940 l_line_definition_owner_code VARCHAR2(1);
104941 --
104942 -- adr variables
104943 l_segment VARCHAR2(30);
104944 l_ccid NUMBER;
104945 l_adr_transaction_coa_id NUMBER;
104946 l_adr_accounting_coa_id NUMBER;
104947 l_adr_flexfield_segment_code VARCHAR2(30);
104948 l_adr_flex_value_set_id NUMBER;
104949 l_adr_value_type_code VARCHAR2(30);
104950 l_adr_value_combination_id NUMBER;
104951 l_adr_value_segment_code VARCHAR2(30);
104952
104953 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
104954 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
104955 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
104956 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
104957
104958 -- 4262811 Variables ------------------------------------------------------------------------------------------
104959 l_entered_amt_idx NUMBER;
104960 l_accted_amt_idx NUMBER;
104961 l_acc_rev_flag VARCHAR2(1);
104962 l_accrual_line_num NUMBER;
104963 l_tmp_amt NUMBER;
104964 l_acc_rev_natural_side_code VARCHAR2(1);
104965
104966 l_num_entries NUMBER;
104967 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
104968 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
104969 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
104970 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
104971 l_recog_line_1 NUMBER;
104972 l_recog_line_2 NUMBER;
104973
104974 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
104975 l_bflow_applied_to_amt NUMBER; -- 5132302
104976 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
104977
104978 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
104979
104980 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
104981 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
104982
104983 ---------------------------------------------------------------------------------------------------------------
104984
104985
104986 --
104987 -- bulk performance
104988 --
104989 l_balance_type_code VARCHAR2(1);
104990 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
104991 l_log_module VARCHAR2(240);
104992
104993 --
104994 -- Upgrade strategy
104995 --
104996 l_actual_upg_option VARCHAR2(1);
104997 l_enc_upg_option VARCHAR2(1);
104998
104999 --
105000 BEGIN
105001 --
105002 IF g_log_enabled THEN
105003 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_208';
105004 END IF;
105005 --
105006 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
105007
105008 trace
105009 (p_msg => 'BEGIN of AcctLineType_208'
105010 ,p_level => C_LEVEL_PROCEDURE
105011 ,p_module => l_log_module);
105012
105013 END IF;
105014 --
105015 l_component_type := 'AMB_JLT';
105016 l_component_code := 'INTERORG_TRANSFER_CREDIT';
105017 l_component_type_code := 'S';
105018 l_component_appl_id := 707;
105019 l_amb_context_code := 'DEFAULT';
105020 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
105021 l_event_class_code := 'USER_DEFINE';
105022 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
105023 l_line_definition_owner_code := 'S';
105024 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
105025 --
105026 l_balance_type_code := 'A';
105027 l_segment := NULL;
105028 l_ccid := NULL;
105029 l_adr_transaction_coa_id := NULL;
105030 l_adr_accounting_coa_id := NULL;
105031 l_adr_flexfield_segment_code := NULL;
105032 l_adr_flex_value_set_id := NULL;
105033 l_adr_value_type_code := NULL;
105034 l_adr_value_combination_id := NULL;
105035 l_adr_value_segment_code := NULL;
105036
105037 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
105038 l_bflow_class_code := ''; -- 4219869 Business Flow
105039 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
105040 l_budgetary_control_flag := 'N';
105041
105042 l_bflow_applied_to_amt_idx := NULL; -- 5132302
105043 l_bflow_applied_to_amt := NULL; -- 5132302
105044 l_entered_amt_idx := NULL; -- 4262811
105045 l_accted_amt_idx := NULL; -- 4262811
105046 l_acc_rev_flag := NULL; -- 4262811
105047 l_accrual_line_num := NULL; -- 4262811
105048 l_tmp_amt := NULL; -- 4262811
105049 --
105050
105051 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
105052 l_balance_type_code <> 'B' THEN
105053 IF NVL(p_source_97,9E125) = 11
105054 THEN
105055
105056 --
105057 XLA_AE_LINES_PKG.SetNewLine;
105058
105059 p_balance_type_code := l_balance_type_code;
105060 -- set the flag so later we will know whether the gain loss line needs to be created
105061
105062 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
105063 p_actual_flag :='A';
105064 END IF;
105065
105066 --
105067 -- bulk performance
105068 --
105069 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
105070 p_header_num => 0); -- 4262811
105071 --
105072 -- set accounting line options
105073 --
105074 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
105075 p_natural_side_code => 'D'
105076 , p_gain_or_loss_flag => 'N'
105077 , p_gl_transfer_mode_code => 'S'
105078 , p_acct_entry_type_code => 'A'
105079 , p_switch_side_flag => 'Y'
105080 , p_merge_duplicate_code => 'N'
105081 );
105082 --
105083 l_acc_rev_natural_side_code := 'C'; -- 4262811
105084 --
105085 --
105086 -- set accounting line type info
105087 --
105088 xla_ae_lines_pkg.SetAcctLineType
105089 (p_component_type => l_component_type
105090 ,p_event_type_code => l_event_type_code
105091 ,p_line_definition_owner_code => l_line_definition_owner_code
105092 ,p_line_definition_code => l_line_definition_code
105093 ,p_accounting_line_code => l_component_code
105094 ,p_accounting_line_type_code => l_component_type_code
105095 ,p_accounting_line_appl_id => l_component_appl_id
105096 ,p_amb_context_code => l_amb_context_code
105097 ,p_entity_code => l_entity_code
105098 ,p_event_class_code => l_event_class_code);
105099 --
105100 -- set accounting class
105101 --
105102 xla_ae_lines_pkg.SetAcctClass(
105103 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
105104 , p_ae_header_id => l_ae_header_id
105105 );
105106
105107 --
105108 -- set rounding class
105109 --
105110 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
105111 'INTERORG_TRANSFER_CREDIT';
105112
105113 --
105114 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
105115 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
105116 --
105117 -- bulk performance
105118 --
105119 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
105120
105121 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
105122 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
105123
105124 -- 4955764
105125 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
105126 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
105127
105128 -- 4458381 Public Sector Enh
105129
105130 --
105131 -- set accounting attributes for the line type
105132 --
105133 l_entered_amt_idx := 3;
105134 l_accted_amt_idx := 8;
105135 l_bflow_applied_to_amt_idx := NULL; -- 5132302
105136 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
105137 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
105138 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
105139 l_rec_acct_attrs.array_char_value(2) := p_source_85;
105140 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
105141 l_rec_acct_attrs.array_num_value(3) := p_source_91;
105142 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
105143 l_rec_acct_attrs.array_char_value(4) := p_source_88;
105144 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
105145 l_rec_acct_attrs.array_date_value(5) := p_source_92;
105146 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
105147 l_rec_acct_attrs.array_num_value(6) := p_source_93;
105148 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
105149 l_rec_acct_attrs.array_char_value(7) := p_source_94;
105150 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
105151 l_rec_acct_attrs.array_num_value(8) := p_source_95;
105152
105153 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
105154 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
105155
105156 ---------------------------------------------------------------------------------------------------------------
105157 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
105158 ---------------------------------------------------------------------------------------------------------------
105159 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
105160
105161 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
105162 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
105163
105164 IF xla_accounting_cache_pkg.GetValueChar
105165 (p_source_code => 'LEDGER_CATEGORY_CODE'
105166 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
105167 AND l_bflow_method_code = 'PRIOR_ENTRY'
105168 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
105169 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
105170 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
105171 )
105172 THEN
105173 xla_ae_lines_pkg.BflowUpgEntry
105174 (p_business_method_code => l_bflow_method_code
105175 ,p_business_class_code => l_bflow_class_code
105176 ,p_balance_type => l_balance_type_code);
105177 ELSE
105178 NULL;
105179 -- No business flow processing for business flow method of NONE.
105180 END IF;
105181
105182 --
105183 -- call analytical criteria
105184 --
105185
105186 --
105187 -- call description
105188 --
105189
105190 xla_ae_lines_pkg.SetLineDescription(
105191 p_ae_header_id => l_ae_header_id
105192 ,p_description => Description_1 (
105193 p_application_id => p_application_id
105194 , p_ae_header_id => l_ae_header_id
105195 , p_source_1 => p_source_1
105196 , p_source_2 => p_source_2
105197 , p_source_3 => p_source_3
105198 , p_source_4 => p_source_4
105199 , p_source_5 => p_source_5
105200 )
105201 );
105202
105203
105204 --
105205 -- call ADRs
105206 -- Bug 4922099
105207 --
105208 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
105209 (NVL(l_actual_upg_option, 'N') = 'O') OR
105210 (NVL(l_enc_upg_option, 'N') = 'O')
105211 )
105212 THEN
105213 NULL;
105214 --
105215 --
105216
105217 l_ccid := AcctDerRule_24(
105218 p_application_id => p_application_id
105219 , p_ae_header_id => l_ae_header_id
105220 , p_source_40 => p_source_40
105221 , x_transaction_coa_id => l_adr_transaction_coa_id
105222 , x_accounting_coa_id => l_adr_accounting_coa_id
105223 , x_value_type_code => l_adr_value_type_code
105224 , p_side => 'NA'
105225 );
105226
105227 xla_ae_lines_pkg.set_ccid(
105228 p_code_combination_id => l_ccid
105229 , p_value_type_code => l_adr_value_type_code
105230 , p_transaction_coa_id => l_adr_transaction_coa_id
105231 , p_accounting_coa_id => l_adr_accounting_coa_id
105232 , p_adr_code => 'PI_INTERORG_TRANSFER'
105233 , p_adr_type_code => 'S'
105234 , p_component_type => l_component_type
105235 , p_component_code => l_component_code
105236 , p_component_type_code => l_component_type_code
105237 , p_component_appl_id => l_component_appl_id
105238 , p_amb_context_code => l_amb_context_code
105239 , p_side => 'NA'
105240 );
105241
105242
105243 --
105244 --
105245 END IF;
105246 --
105247 -- Bug 4922099
105248 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
105249 (NVL(l_enc_upg_option, 'N') = 'O')
105250 ) AND
105251 (l_bflow_method_code = 'PRIOR_ENTRY')
105252 )
105253 THEN
105254 IF
105255 --
105256 1 = 2
105257 --
105258 THEN
105259 xla_accounting_err_pkg.build_message
105260 (p_appli_s_name => 'XLA'
105261 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
105262 ,p_token_1 => 'LINE_NUMBER'
105263 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
105264 ,p_token_2 => 'LINE_TYPE_NAME'
105265 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
105266 l_component_type
105267 ,l_component_code
105268 ,l_component_type_code
105269 ,l_component_appl_id
105270 ,l_amb_context_code
105271 ,l_entity_code
105272 ,l_event_class_code
105273 )
105274 ,p_token_3 => 'OWNER'
105275 ,p_value_3 => xla_lookups_pkg.get_meaning(
105276 p_lookup_type => 'XLA_OWNER_TYPE'
105277 ,p_lookup_code => l_component_type_code
105278 )
105279 ,p_token_4 => 'PRODUCT_NAME'
105280 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
105281 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
105282 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
105283 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
105284 ,p_ae_header_id => NULL
105285 );
105286
105287 IF (C_LEVEL_ERROR>= g_log_level) THEN
105288 trace
105289 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
105290 ,p_level => C_LEVEL_ERROR
105291 ,p_module => l_log_module);
105292 END IF;
105293 END IF;
105294 END IF;
105295 --
105296 --
105297 ------------------------------------------------------------------------------------------------
105298 -- 4219869 Business Flow
105299 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
105300 -- Prior Entry. Currently, the following code is always generated.
105301 ------------------------------------------------------------------------------------------------
105302 XLA_AE_LINES_PKG.ValidateCurrentLine;
105303
105304 ------------------------------------------------------------------------------------
105305 -- 4219869 Business Flow
105306 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
105307 ------------------------------------------------------------------------------------
105308 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
105309
105310 ----------------------------------------------------------------------------------
105311 -- 4219869 Business Flow
105312 -- Update journal entry status -- Need to generate this within IF <condition>
105313 ----------------------------------------------------------------------------------
105314 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
105315 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
105316 ,p_balance_type_code => l_balance_type_code
105317 );
105318
105319 -------------------------------------------------------------------------------------------
105320 -- 4262811 - Generate the Accrual Reversal lines
105321 -------------------------------------------------------------------------------------------
105322 BEGIN
105323 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
105324 (g_array_event(p_event_id).array_value_num('header_index'));
105325 IF l_acc_rev_flag IS NULL THEN
105326 l_acc_rev_flag := 'N';
105327 END IF;
105328 EXCEPTION
105329 WHEN OTHERS THEN
105330 l_acc_rev_flag := 'N';
105331 END;
105332 --
105333 IF (l_acc_rev_flag = 'Y') THEN
105334
105335 -- 4645092 ------------------------------------------------------------------------------
105336 -- To allow MPA report to determine if it should generate report process
105337 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
105338 ------------------------------------------------------------------------------------------
105339
105340 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
105341 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
105342 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
105343 -- call ADRs
105344 -- Bug 4922099
105345 --
105346 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
105347 (NVL(l_actual_upg_option, 'N') = 'O') OR
105348 (NVL(l_enc_upg_option, 'N') = 'O')
105349 )
105350 THEN
105351 NULL;
105352 --
105353 --
105354
105355 l_ccid := AcctDerRule_24(
105356 p_application_id => p_application_id
105357 , p_ae_header_id => l_ae_header_id
105358 , p_source_40 => p_source_40
105359 , x_transaction_coa_id => l_adr_transaction_coa_id
105360 , x_accounting_coa_id => l_adr_accounting_coa_id
105361 , x_value_type_code => l_adr_value_type_code
105362 , p_side => 'NA'
105363 );
105364
105365 xla_ae_lines_pkg.set_ccid(
105366 p_code_combination_id => l_ccid
105367 , p_value_type_code => l_adr_value_type_code
105368 , p_transaction_coa_id => l_adr_transaction_coa_id
105369 , p_accounting_coa_id => l_adr_accounting_coa_id
105370 , p_adr_code => 'PI_INTERORG_TRANSFER'
105371 , p_adr_type_code => 'S'
105372 , p_component_type => l_component_type
105373 , p_component_code => l_component_code
105374 , p_component_type_code => l_component_type_code
105375 , p_component_appl_id => l_component_appl_id
105376 , p_amb_context_code => l_amb_context_code
105377 , p_side => 'NA'
105378 );
105379
105380
105381 --
105382 --
105383 END IF;
105384
105385 --
105386 -- Update the line information that should be overwritten
105387 --
105388 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
105389 p_header_num => 1);
105390 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
105391
105392 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
105393
105394 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
105395 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
105396 END IF;
105397
105398 --
105399 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
105400 --
105401 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
105402 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
105403 ELSE
105404 ---------------------------------------------------------------------------------------------------
105405 -- 4262811a Switch Sign
105406 ---------------------------------------------------------------------------------------------------
105407 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
105408 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
105409 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105410 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
105411 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105412 -- 5132302
105413 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
105414 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105415
105416 END IF;
105417
105418 -- 4955764
105419 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
105420 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
105421
105422
105423 XLA_AE_LINES_PKG.ValidateCurrentLine;
105424 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
105425
105426 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
105427 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
105428 ,p_balance_type_code => l_balance_type_code);
105429
105430 END IF;
105431
105432 -----------------------------------------------------------------------------------------
105433 -- 4262811 Multiperiod Accounting
105434 -----------------------------------------------------------------------------------------
105435 -- No MPA option is assigned.
105436
105437
105438 END IF;
105439 END IF;
105440 --
105441
105442 --
105443 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
105444 trace
105445 (p_msg => 'END of AcctLineType_208'
105446 ,p_level => C_LEVEL_PROCEDURE
105447 ,p_module => l_log_module);
105448 END IF;
105449 --
105450 EXCEPTION
105451 WHEN xla_exceptions_pkg.application_exception THEN
105452 RAISE;
105453 WHEN OTHERS THEN
105454 xla_exceptions_pkg.raise_message
105455 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_208');
105456 END AcctLineType_208;
105457 --
105458
105459 ---------------------------------------
105460 --
105461 -- PRIVATE FUNCTION
105462 -- AcctLineType_209
105463 --
105464 ---------------------------------------
105465 PROCEDURE AcctLineType_209 (
105466 p_application_id IN NUMBER
105467 ,p_event_id IN NUMBER
105468 ,p_calculate_acctd_flag IN VARCHAR2
105469 ,p_calculate_g_l_flag IN VARCHAR2
105470 ,p_actual_flag IN OUT VARCHAR2
105471 ,p_balance_type_code OUT VARCHAR2
105472 ,p_gain_or_loss_ref OUT VARCHAR2
105473
105474 --TRANSACTION_ID
105475 , p_source_1 IN NUMBER
105476 --Item Concatenated Segments
105477 , p_source_2 IN VARCHAR2
105478 --Transaction Quantity
105479 , p_source_3 IN NUMBER
105480 --Transaction Unit of Measure Code
105481 , p_source_4 IN VARCHAR2
105482 --Inventory Transaction Type Description
105483 , p_source_5 IN VARCHAR2
105484 --Cost Management Default Account
105485 , p_source_11 IN NUMBER
105486 --DISTRIBUTION_IDENTIFIER
105487 , p_source_84 IN NUMBER
105488 --Distribution Type
105489 , p_source_85 IN VARCHAR2
105490 , p_source_85_meaning IN VARCHAR2
105491 --Entered Currency Code
105492 , p_source_88 IN VARCHAR2
105493 --Entered Amount
105494 , p_source_91 IN NUMBER
105495 --Currency Conversion Date
105496 , p_source_92 IN DATE
105497 --Currency Conversion Rate
105498 , p_source_93 IN NUMBER
105499 --Currency Conversion Type
105500 , p_source_94 IN VARCHAR2
105501 --Accounted Amount
105502 , p_source_95 IN NUMBER
105503 --Accounting Line Type
105504 , p_source_97 IN NUMBER
105505 )
105506 IS
105507
105508 l_component_type VARCHAR2(80);
105509 l_component_code VARCHAR2(30);
105510 l_component_type_code VARCHAR2(1);
105511 l_component_appl_id INTEGER;
105512 l_amb_context_code VARCHAR2(30);
105513 l_entity_code VARCHAR2(30);
105514 l_event_class_code VARCHAR2(30);
105515 l_ae_header_id NUMBER;
105516 l_event_type_code VARCHAR2(30);
105517 l_line_definition_code VARCHAR2(30);
105518 l_line_definition_owner_code VARCHAR2(1);
105519 --
105520 -- adr variables
105521 l_segment VARCHAR2(30);
105522 l_ccid NUMBER;
105523 l_adr_transaction_coa_id NUMBER;
105524 l_adr_accounting_coa_id NUMBER;
105525 l_adr_flexfield_segment_code VARCHAR2(30);
105526 l_adr_flex_value_set_id NUMBER;
105527 l_adr_value_type_code VARCHAR2(30);
105528 l_adr_value_combination_id NUMBER;
105529 l_adr_value_segment_code VARCHAR2(30);
105530
105531 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
105532 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
105533 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
105534 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
105535
105536 -- 4262811 Variables ------------------------------------------------------------------------------------------
105537 l_entered_amt_idx NUMBER;
105538 l_accted_amt_idx NUMBER;
105539 l_acc_rev_flag VARCHAR2(1);
105540 l_accrual_line_num NUMBER;
105541 l_tmp_amt NUMBER;
105542 l_acc_rev_natural_side_code VARCHAR2(1);
105543
105544 l_num_entries NUMBER;
105545 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
105546 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
105547 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
105548 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
105549 l_recog_line_1 NUMBER;
105550 l_recog_line_2 NUMBER;
105551
105552 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
105553 l_bflow_applied_to_amt NUMBER; -- 5132302
105554 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
105555
105556 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
105557
105558 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
105559 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
105560
105561 ---------------------------------------------------------------------------------------------------------------
105562
105563
105564 --
105565 -- bulk performance
105566 --
105567 l_balance_type_code VARCHAR2(1);
105568 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
105569 l_log_module VARCHAR2(240);
105570
105571 --
105572 -- Upgrade strategy
105573 --
105574 l_actual_upg_option VARCHAR2(1);
105575 l_enc_upg_option VARCHAR2(1);
105576
105577 --
105578 BEGIN
105579 --
105580 IF g_log_enabled THEN
105581 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_209';
105582 END IF;
105583 --
105584 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
105585
105586 trace
105587 (p_msg => 'BEGIN of AcctLineType_209'
105588 ,p_level => C_LEVEL_PROCEDURE
105589 ,p_module => l_log_module);
105590
105591 END IF;
105592 --
105593 l_component_type := 'AMB_JLT';
105594 l_component_code := 'INTERORG_TRANSFER_CREDIT';
105595 l_component_type_code := 'S';
105596 l_component_appl_id := 707;
105597 l_amb_context_code := 'DEFAULT';
105598 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
105599 l_event_class_code := 'USER_DEFINE';
105600 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
105601 l_line_definition_owner_code := 'S';
105602 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
105603 --
105604 l_balance_type_code := 'A';
105605 l_segment := NULL;
105606 l_ccid := NULL;
105607 l_adr_transaction_coa_id := NULL;
105608 l_adr_accounting_coa_id := NULL;
105609 l_adr_flexfield_segment_code := NULL;
105610 l_adr_flex_value_set_id := NULL;
105611 l_adr_value_type_code := NULL;
105612 l_adr_value_combination_id := NULL;
105613 l_adr_value_segment_code := NULL;
105614
105615 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
105616 l_bflow_class_code := ''; -- 4219869 Business Flow
105617 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
105618 l_budgetary_control_flag := 'N';
105619
105620 l_bflow_applied_to_amt_idx := NULL; -- 5132302
105621 l_bflow_applied_to_amt := NULL; -- 5132302
105622 l_entered_amt_idx := NULL; -- 4262811
105623 l_accted_amt_idx := NULL; -- 4262811
105624 l_acc_rev_flag := NULL; -- 4262811
105625 l_accrual_line_num := NULL; -- 4262811
105626 l_tmp_amt := NULL; -- 4262811
105627 --
105628
105629 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
105630 l_balance_type_code <> 'B' THEN
105631 IF NVL(p_source_97,9E125) = 11
105632 THEN
105633
105634 --
105635 XLA_AE_LINES_PKG.SetNewLine;
105636
105637 p_balance_type_code := l_balance_type_code;
105638 -- set the flag so later we will know whether the gain loss line needs to be created
105639
105640 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
105641 p_actual_flag :='A';
105642 END IF;
105643
105644 --
105645 -- bulk performance
105646 --
105647 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
105648 p_header_num => 0); -- 4262811
105649 --
105650 -- set accounting line options
105651 --
105652 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
105653 p_natural_side_code => 'D'
105654 , p_gain_or_loss_flag => 'N'
105655 , p_gl_transfer_mode_code => 'S'
105656 , p_acct_entry_type_code => 'A'
105657 , p_switch_side_flag => 'Y'
105658 , p_merge_duplicate_code => 'N'
105659 );
105660 --
105661 l_acc_rev_natural_side_code := 'C'; -- 4262811
105662 --
105663 --
105664 -- set accounting line type info
105665 --
105666 xla_ae_lines_pkg.SetAcctLineType
105667 (p_component_type => l_component_type
105668 ,p_event_type_code => l_event_type_code
105669 ,p_line_definition_owner_code => l_line_definition_owner_code
105670 ,p_line_definition_code => l_line_definition_code
105671 ,p_accounting_line_code => l_component_code
105672 ,p_accounting_line_type_code => l_component_type_code
105673 ,p_accounting_line_appl_id => l_component_appl_id
105674 ,p_amb_context_code => l_amb_context_code
105675 ,p_entity_code => l_entity_code
105676 ,p_event_class_code => l_event_class_code);
105677 --
105678 -- set accounting class
105679 --
105680 xla_ae_lines_pkg.SetAcctClass(
105681 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
105682 , p_ae_header_id => l_ae_header_id
105683 );
105684
105685 --
105686 -- set rounding class
105687 --
105688 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
105689 'INTERORG_TRANSFER_CREDIT';
105690
105691 --
105692 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
105693 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
105694 --
105695 -- bulk performance
105696 --
105697 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
105698
105699 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
105700 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
105701
105702 -- 4955764
105703 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
105704 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
105705
105706 -- 4458381 Public Sector Enh
105707
105708 --
105709 -- set accounting attributes for the line type
105710 --
105711 l_entered_amt_idx := 3;
105712 l_accted_amt_idx := 8;
105713 l_bflow_applied_to_amt_idx := NULL; -- 5132302
105714 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
105715 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
105716 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
105717 l_rec_acct_attrs.array_char_value(2) := p_source_85;
105718 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
105719 l_rec_acct_attrs.array_num_value(3) := p_source_91;
105720 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
105721 l_rec_acct_attrs.array_char_value(4) := p_source_88;
105722 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
105723 l_rec_acct_attrs.array_date_value(5) := p_source_92;
105724 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
105725 l_rec_acct_attrs.array_num_value(6) := p_source_93;
105726 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
105727 l_rec_acct_attrs.array_char_value(7) := p_source_94;
105728 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
105729 l_rec_acct_attrs.array_num_value(8) := p_source_95;
105730
105731 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
105732 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
105733
105734 ---------------------------------------------------------------------------------------------------------------
105735 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
105736 ---------------------------------------------------------------------------------------------------------------
105737 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
105738
105739 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
105740 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
105741
105742 IF xla_accounting_cache_pkg.GetValueChar
105743 (p_source_code => 'LEDGER_CATEGORY_CODE'
105744 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
105745 AND l_bflow_method_code = 'PRIOR_ENTRY'
105746 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
105747 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
105748 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
105749 )
105750 THEN
105751 xla_ae_lines_pkg.BflowUpgEntry
105752 (p_business_method_code => l_bflow_method_code
105753 ,p_business_class_code => l_bflow_class_code
105754 ,p_balance_type => l_balance_type_code);
105755 ELSE
105756 NULL;
105757 -- No business flow processing for business flow method of NONE.
105758 END IF;
105759
105760 --
105761 -- call analytical criteria
105762 --
105763
105764 --
105765 -- call description
105766 --
105767
105768 xla_ae_lines_pkg.SetLineDescription(
105769 p_ae_header_id => l_ae_header_id
105770 ,p_description => Description_1 (
105771 p_application_id => p_application_id
105772 , p_ae_header_id => l_ae_header_id
105773 , p_source_1 => p_source_1
105774 , p_source_2 => p_source_2
105775 , p_source_3 => p_source_3
105776 , p_source_4 => p_source_4
105777 , p_source_5 => p_source_5
105778 )
105779 );
105780
105781
105782 --
105783 -- call ADRs
105784 -- Bug 4922099
105785 --
105786 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
105787 (NVL(l_actual_upg_option, 'N') = 'O') OR
105788 (NVL(l_enc_upg_option, 'N') = 'O')
105789 )
105790 THEN
105791 NULL;
105792 --
105793 --
105794
105795 l_ccid := AcctDerRule_6(
105796 p_application_id => p_application_id
105797 , p_ae_header_id => l_ae_header_id
105798 , p_source_11 => p_source_11
105799 , x_transaction_coa_id => l_adr_transaction_coa_id
105800 , x_accounting_coa_id => l_adr_accounting_coa_id
105801 , x_value_type_code => l_adr_value_type_code
105802 , p_side => 'NA'
105803 );
105804
105805 xla_ae_lines_pkg.set_ccid(
105806 p_code_combination_id => l_ccid
105807 , p_value_type_code => l_adr_value_type_code
105808 , p_transaction_coa_id => l_adr_transaction_coa_id
105809 , p_accounting_coa_id => l_adr_accounting_coa_id
105810 , p_adr_code => 'CST_DEFAULT'
105811 , p_adr_type_code => 'S'
105812 , p_component_type => l_component_type
105813 , p_component_code => l_component_code
105814 , p_component_type_code => l_component_type_code
105815 , p_component_appl_id => l_component_appl_id
105816 , p_amb_context_code => l_amb_context_code
105817 , p_side => 'NA'
105818 );
105819
105820
105821 --
105822 --
105823 END IF;
105824 --
105825 -- Bug 4922099
105826 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
105827 (NVL(l_enc_upg_option, 'N') = 'O')
105828 ) AND
105829 (l_bflow_method_code = 'PRIOR_ENTRY')
105830 )
105831 THEN
105832 IF
105833 --
105834 1 = 2
105835 --
105836 THEN
105837 xla_accounting_err_pkg.build_message
105838 (p_appli_s_name => 'XLA'
105839 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
105840 ,p_token_1 => 'LINE_NUMBER'
105841 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
105842 ,p_token_2 => 'LINE_TYPE_NAME'
105843 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
105844 l_component_type
105845 ,l_component_code
105846 ,l_component_type_code
105847 ,l_component_appl_id
105848 ,l_amb_context_code
105849 ,l_entity_code
105850 ,l_event_class_code
105851 )
105852 ,p_token_3 => 'OWNER'
105853 ,p_value_3 => xla_lookups_pkg.get_meaning(
105854 p_lookup_type => 'XLA_OWNER_TYPE'
105855 ,p_lookup_code => l_component_type_code
105856 )
105857 ,p_token_4 => 'PRODUCT_NAME'
105858 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
105859 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
105860 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
105861 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
105862 ,p_ae_header_id => NULL
105863 );
105864
105865 IF (C_LEVEL_ERROR>= g_log_level) THEN
105866 trace
105867 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
105868 ,p_level => C_LEVEL_ERROR
105869 ,p_module => l_log_module);
105870 END IF;
105871 END IF;
105872 END IF;
105873 --
105874 --
105875 ------------------------------------------------------------------------------------------------
105876 -- 4219869 Business Flow
105877 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
105878 -- Prior Entry. Currently, the following code is always generated.
105879 ------------------------------------------------------------------------------------------------
105880 XLA_AE_LINES_PKG.ValidateCurrentLine;
105881
105882 ------------------------------------------------------------------------------------
105883 -- 4219869 Business Flow
105884 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
105885 ------------------------------------------------------------------------------------
105886 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
105887
105888 ----------------------------------------------------------------------------------
105889 -- 4219869 Business Flow
105890 -- Update journal entry status -- Need to generate this within IF <condition>
105891 ----------------------------------------------------------------------------------
105892 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
105893 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
105894 ,p_balance_type_code => l_balance_type_code
105895 );
105896
105897 -------------------------------------------------------------------------------------------
105898 -- 4262811 - Generate the Accrual Reversal lines
105899 -------------------------------------------------------------------------------------------
105900 BEGIN
105901 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
105902 (g_array_event(p_event_id).array_value_num('header_index'));
105903 IF l_acc_rev_flag IS NULL THEN
105904 l_acc_rev_flag := 'N';
105905 END IF;
105906 EXCEPTION
105907 WHEN OTHERS THEN
105908 l_acc_rev_flag := 'N';
105909 END;
105910 --
105911 IF (l_acc_rev_flag = 'Y') THEN
105912
105913 -- 4645092 ------------------------------------------------------------------------------
105914 -- To allow MPA report to determine if it should generate report process
105915 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
105916 ------------------------------------------------------------------------------------------
105917
105918 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
105919 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
105920 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
105921 -- call ADRs
105922 -- Bug 4922099
105923 --
105924 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
105925 (NVL(l_actual_upg_option, 'N') = 'O') OR
105926 (NVL(l_enc_upg_option, 'N') = 'O')
105927 )
105928 THEN
105929 NULL;
105930 --
105931 --
105932
105933 l_ccid := AcctDerRule_6(
105934 p_application_id => p_application_id
105935 , p_ae_header_id => l_ae_header_id
105936 , p_source_11 => p_source_11
105937 , x_transaction_coa_id => l_adr_transaction_coa_id
105938 , x_accounting_coa_id => l_adr_accounting_coa_id
105939 , x_value_type_code => l_adr_value_type_code
105940 , p_side => 'NA'
105941 );
105942
105943 xla_ae_lines_pkg.set_ccid(
105944 p_code_combination_id => l_ccid
105945 , p_value_type_code => l_adr_value_type_code
105946 , p_transaction_coa_id => l_adr_transaction_coa_id
105947 , p_accounting_coa_id => l_adr_accounting_coa_id
105948 , p_adr_code => 'CST_DEFAULT'
105949 , p_adr_type_code => 'S'
105950 , p_component_type => l_component_type
105951 , p_component_code => l_component_code
105952 , p_component_type_code => l_component_type_code
105953 , p_component_appl_id => l_component_appl_id
105954 , p_amb_context_code => l_amb_context_code
105955 , p_side => 'NA'
105956 );
105957
105958
105959 --
105960 --
105961 END IF;
105962
105963 --
105964 -- Update the line information that should be overwritten
105965 --
105966 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
105967 p_header_num => 1);
105968 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
105969
105970 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
105971
105972 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
105973 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
105974 END IF;
105975
105976 --
105977 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
105978 --
105979 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
105980 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
105981 ELSE
105982 ---------------------------------------------------------------------------------------------------
105983 -- 4262811a Switch Sign
105984 ---------------------------------------------------------------------------------------------------
105985 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
105986 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
105987 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105988 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
105989 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105990 -- 5132302
105991 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
105992 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
105993
105994 END IF;
105995
105996 -- 4955764
105997 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
105998 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
105999
106000
106001 XLA_AE_LINES_PKG.ValidateCurrentLine;
106002 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
106003
106004 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
106005 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
106006 ,p_balance_type_code => l_balance_type_code);
106007
106008 END IF;
106009
106010 -----------------------------------------------------------------------------------------
106011 -- 4262811 Multiperiod Accounting
106012 -----------------------------------------------------------------------------------------
106013 -- No MPA option is assigned.
106014
106015
106016 END IF;
106017 END IF;
106018 --
106019
106020 --
106021 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
106022 trace
106023 (p_msg => 'END of AcctLineType_209'
106024 ,p_level => C_LEVEL_PROCEDURE
106025 ,p_module => l_log_module);
106026 END IF;
106027 --
106028 EXCEPTION
106029 WHEN xla_exceptions_pkg.application_exception THEN
106030 RAISE;
106031 WHEN OTHERS THEN
106032 xla_exceptions_pkg.raise_message
106033 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_209');
106034 END AcctLineType_209;
106035 --
106036
106037 ---------------------------------------
106038 --
106039 -- PRIVATE FUNCTION
106040 -- AcctLineType_210
106041 --
106042 ---------------------------------------
106043 PROCEDURE AcctLineType_210 (
106044 p_application_id IN NUMBER
106045 ,p_event_id IN NUMBER
106046 ,p_calculate_acctd_flag IN VARCHAR2
106047 ,p_calculate_g_l_flag IN VARCHAR2
106048 ,p_actual_flag IN OUT VARCHAR2
106049 ,p_balance_type_code OUT VARCHAR2
106050 ,p_gain_or_loss_ref OUT VARCHAR2
106051
106052 --TRANSACTION_ID
106053 , p_source_1 IN NUMBER
106054 --Item Concatenated Segments
106055 , p_source_2 IN VARCHAR2
106056 --Transaction Quantity
106057 , p_source_3 IN NUMBER
106058 --Transaction Unit of Measure Code
106059 , p_source_4 IN VARCHAR2
106060 --Inventory Transaction Type Description
106061 , p_source_5 IN VARCHAR2
106062 --Interorg Transfer Credit Account
106063 , p_source_40 IN NUMBER
106064 --DISTRIBUTION_IDENTIFIER
106065 , p_source_84 IN NUMBER
106066 --Distribution Type
106067 , p_source_85 IN VARCHAR2
106068 , p_source_85_meaning IN VARCHAR2
106069 --Entered Currency Code
106070 , p_source_88 IN VARCHAR2
106071 --Entered Amount
106072 , p_source_91 IN NUMBER
106073 --Currency Conversion Date
106074 , p_source_92 IN DATE
106075 --Currency Conversion Rate
106076 , p_source_93 IN NUMBER
106077 --Currency Conversion Type
106078 , p_source_94 IN VARCHAR2
106079 --Accounted Amount
106080 , p_source_95 IN NUMBER
106081 --Accounting Line Type
106082 , p_source_97 IN NUMBER
106083 )
106084 IS
106085
106086 l_component_type VARCHAR2(80);
106087 l_component_code VARCHAR2(30);
106088 l_component_type_code VARCHAR2(1);
106089 l_component_appl_id INTEGER;
106090 l_amb_context_code VARCHAR2(30);
106091 l_entity_code VARCHAR2(30);
106092 l_event_class_code VARCHAR2(30);
106093 l_ae_header_id NUMBER;
106094 l_event_type_code VARCHAR2(30);
106095 l_line_definition_code VARCHAR2(30);
106096 l_line_definition_owner_code VARCHAR2(1);
106097 --
106098 -- adr variables
106099 l_segment VARCHAR2(30);
106100 l_ccid NUMBER;
106101 l_adr_transaction_coa_id NUMBER;
106102 l_adr_accounting_coa_id NUMBER;
106103 l_adr_flexfield_segment_code VARCHAR2(30);
106104 l_adr_flex_value_set_id NUMBER;
106105 l_adr_value_type_code VARCHAR2(30);
106106 l_adr_value_combination_id NUMBER;
106107 l_adr_value_segment_code VARCHAR2(30);
106108
106109 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
106110 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
106111 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
106112 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
106113
106114 -- 4262811 Variables ------------------------------------------------------------------------------------------
106115 l_entered_amt_idx NUMBER;
106116 l_accted_amt_idx NUMBER;
106117 l_acc_rev_flag VARCHAR2(1);
106118 l_accrual_line_num NUMBER;
106119 l_tmp_amt NUMBER;
106120 l_acc_rev_natural_side_code VARCHAR2(1);
106121
106122 l_num_entries NUMBER;
106123 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
106124 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
106125 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
106126 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
106127 l_recog_line_1 NUMBER;
106128 l_recog_line_2 NUMBER;
106129
106130 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
106131 l_bflow_applied_to_amt NUMBER; -- 5132302
106132 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
106133
106134 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
106135
106136 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
106137 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
106138
106139 ---------------------------------------------------------------------------------------------------------------
106140
106141
106142 --
106143 -- bulk performance
106144 --
106145 l_balance_type_code VARCHAR2(1);
106146 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
106147 l_log_module VARCHAR2(240);
106148
106149 --
106150 -- Upgrade strategy
106151 --
106152 l_actual_upg_option VARCHAR2(1);
106153 l_enc_upg_option VARCHAR2(1);
106154
106155 --
106156 BEGIN
106157 --
106158 IF g_log_enabled THEN
106159 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_210';
106160 END IF;
106161 --
106162 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
106163
106164 trace
106165 (p_msg => 'BEGIN of AcctLineType_210'
106166 ,p_level => C_LEVEL_PROCEDURE
106167 ,p_module => l_log_module);
106168
106169 END IF;
106170 --
106171 l_component_type := 'AMB_JLT';
106172 l_component_code := 'INTERORG_TRANSFER_CREDIT';
106173 l_component_type_code := 'S';
106174 l_component_appl_id := 707;
106175 l_amb_context_code := 'DEFAULT';
106176 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
106177 l_event_class_code := 'DIR_INTERORG_SHIP';
106178 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
106179 l_line_definition_owner_code := 'S';
106180 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
106181 --
106182 l_balance_type_code := 'A';
106183 l_segment := NULL;
106184 l_ccid := NULL;
106185 l_adr_transaction_coa_id := NULL;
106186 l_adr_accounting_coa_id := NULL;
106187 l_adr_flexfield_segment_code := NULL;
106188 l_adr_flex_value_set_id := NULL;
106189 l_adr_value_type_code := NULL;
106190 l_adr_value_combination_id := NULL;
106191 l_adr_value_segment_code := NULL;
106192
106193 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
106194 l_bflow_class_code := ''; -- 4219869 Business Flow
106195 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
106196 l_budgetary_control_flag := 'N';
106197
106198 l_bflow_applied_to_amt_idx := NULL; -- 5132302
106199 l_bflow_applied_to_amt := NULL; -- 5132302
106200 l_entered_amt_idx := NULL; -- 4262811
106201 l_accted_amt_idx := NULL; -- 4262811
106202 l_acc_rev_flag := NULL; -- 4262811
106203 l_accrual_line_num := NULL; -- 4262811
106204 l_tmp_amt := NULL; -- 4262811
106205 --
106206
106207 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
106208 l_balance_type_code <> 'B' THEN
106209 IF NVL(p_source_97,9E125) = 11
106210 THEN
106211
106212 --
106213 XLA_AE_LINES_PKG.SetNewLine;
106214
106215 p_balance_type_code := l_balance_type_code;
106216 -- set the flag so later we will know whether the gain loss line needs to be created
106217
106218 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
106219 p_actual_flag :='A';
106220 END IF;
106221
106222 --
106223 -- bulk performance
106224 --
106225 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
106226 p_header_num => 0); -- 4262811
106227 --
106228 -- set accounting line options
106229 --
106230 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
106231 p_natural_side_code => 'D'
106232 , p_gain_or_loss_flag => 'N'
106233 , p_gl_transfer_mode_code => 'S'
106234 , p_acct_entry_type_code => 'A'
106235 , p_switch_side_flag => 'Y'
106236 , p_merge_duplicate_code => 'N'
106237 );
106238 --
106239 l_acc_rev_natural_side_code := 'C'; -- 4262811
106240 --
106241 --
106242 -- set accounting line type info
106243 --
106244 xla_ae_lines_pkg.SetAcctLineType
106245 (p_component_type => l_component_type
106246 ,p_event_type_code => l_event_type_code
106247 ,p_line_definition_owner_code => l_line_definition_owner_code
106248 ,p_line_definition_code => l_line_definition_code
106249 ,p_accounting_line_code => l_component_code
106250 ,p_accounting_line_type_code => l_component_type_code
106251 ,p_accounting_line_appl_id => l_component_appl_id
106252 ,p_amb_context_code => l_amb_context_code
106253 ,p_entity_code => l_entity_code
106254 ,p_event_class_code => l_event_class_code);
106255 --
106256 -- set accounting class
106257 --
106258 xla_ae_lines_pkg.SetAcctClass(
106259 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
106260 , p_ae_header_id => l_ae_header_id
106261 );
106262
106263 --
106264 -- set rounding class
106265 --
106266 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
106267 'INTERORG_TRANSFER_CREDIT';
106268
106269 --
106270 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
106271 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
106272 --
106273 -- bulk performance
106274 --
106275 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
106276
106277 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
106278 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
106279
106280 -- 4955764
106281 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
106282 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
106283
106284 -- 4458381 Public Sector Enh
106285
106286 --
106287 -- set accounting attributes for the line type
106288 --
106289 l_entered_amt_idx := 3;
106290 l_accted_amt_idx := 8;
106291 l_bflow_applied_to_amt_idx := NULL; -- 5132302
106292 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
106293 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
106294 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
106295 l_rec_acct_attrs.array_char_value(2) := p_source_85;
106296 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
106297 l_rec_acct_attrs.array_num_value(3) := p_source_91;
106298 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
106299 l_rec_acct_attrs.array_char_value(4) := p_source_88;
106300 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
106301 l_rec_acct_attrs.array_date_value(5) := p_source_92;
106302 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
106303 l_rec_acct_attrs.array_num_value(6) := p_source_93;
106304 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
106305 l_rec_acct_attrs.array_char_value(7) := p_source_94;
106306 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
106307 l_rec_acct_attrs.array_num_value(8) := p_source_95;
106308
106309 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
106310 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
106311
106312 ---------------------------------------------------------------------------------------------------------------
106313 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
106314 ---------------------------------------------------------------------------------------------------------------
106315 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
106316
106317 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
106318 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
106319
106320 IF xla_accounting_cache_pkg.GetValueChar
106321 (p_source_code => 'LEDGER_CATEGORY_CODE'
106322 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
106323 AND l_bflow_method_code = 'PRIOR_ENTRY'
106324 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
106325 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
106326 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
106327 )
106328 THEN
106329 xla_ae_lines_pkg.BflowUpgEntry
106330 (p_business_method_code => l_bflow_method_code
106331 ,p_business_class_code => l_bflow_class_code
106332 ,p_balance_type => l_balance_type_code);
106333 ELSE
106334 NULL;
106335 -- No business flow processing for business flow method of NONE.
106336 END IF;
106337
106338 --
106339 -- call analytical criteria
106340 --
106341
106342 --
106343 -- call description
106344 --
106345
106346 xla_ae_lines_pkg.SetLineDescription(
106347 p_ae_header_id => l_ae_header_id
106348 ,p_description => Description_1 (
106349 p_application_id => p_application_id
106350 , p_ae_header_id => l_ae_header_id
106351 , p_source_1 => p_source_1
106352 , p_source_2 => p_source_2
106353 , p_source_3 => p_source_3
106354 , p_source_4 => p_source_4
106355 , p_source_5 => p_source_5
106356 )
106357 );
106358
106359
106360 --
106361 -- call ADRs
106362 -- Bug 4922099
106363 --
106364 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
106365 (NVL(l_actual_upg_option, 'N') = 'O') OR
106366 (NVL(l_enc_upg_option, 'N') = 'O')
106367 )
106368 THEN
106369 NULL;
106370 --
106371 --
106372
106373 l_ccid := AcctDerRule_24(
106374 p_application_id => p_application_id
106375 , p_ae_header_id => l_ae_header_id
106376 , p_source_40 => p_source_40
106377 , x_transaction_coa_id => l_adr_transaction_coa_id
106378 , x_accounting_coa_id => l_adr_accounting_coa_id
106379 , x_value_type_code => l_adr_value_type_code
106380 , p_side => 'NA'
106381 );
106382
106383 xla_ae_lines_pkg.set_ccid(
106384 p_code_combination_id => l_ccid
106385 , p_value_type_code => l_adr_value_type_code
106386 , p_transaction_coa_id => l_adr_transaction_coa_id
106387 , p_accounting_coa_id => l_adr_accounting_coa_id
106388 , p_adr_code => 'PI_INTERORG_TRANSFER'
106389 , p_adr_type_code => 'S'
106390 , p_component_type => l_component_type
106391 , p_component_code => l_component_code
106392 , p_component_type_code => l_component_type_code
106393 , p_component_appl_id => l_component_appl_id
106394 , p_amb_context_code => l_amb_context_code
106395 , p_side => 'NA'
106396 );
106397
106398
106399 --
106400 --
106401 END IF;
106402 --
106403 -- Bug 4922099
106404 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
106405 (NVL(l_enc_upg_option, 'N') = 'O')
106406 ) AND
106407 (l_bflow_method_code = 'PRIOR_ENTRY')
106408 )
106409 THEN
106410 IF
106411 --
106412 1 = 2
106413 --
106414 THEN
106415 xla_accounting_err_pkg.build_message
106416 (p_appli_s_name => 'XLA'
106417 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
106418 ,p_token_1 => 'LINE_NUMBER'
106419 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
106420 ,p_token_2 => 'LINE_TYPE_NAME'
106421 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
106422 l_component_type
106423 ,l_component_code
106424 ,l_component_type_code
106425 ,l_component_appl_id
106426 ,l_amb_context_code
106427 ,l_entity_code
106428 ,l_event_class_code
106429 )
106430 ,p_token_3 => 'OWNER'
106431 ,p_value_3 => xla_lookups_pkg.get_meaning(
106432 p_lookup_type => 'XLA_OWNER_TYPE'
106433 ,p_lookup_code => l_component_type_code
106434 )
106435 ,p_token_4 => 'PRODUCT_NAME'
106436 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
106437 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
106438 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
106439 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
106440 ,p_ae_header_id => NULL
106441 );
106442
106443 IF (C_LEVEL_ERROR>= g_log_level) THEN
106444 trace
106445 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
106446 ,p_level => C_LEVEL_ERROR
106447 ,p_module => l_log_module);
106448 END IF;
106449 END IF;
106450 END IF;
106451 --
106452 --
106453 ------------------------------------------------------------------------------------------------
106454 -- 4219869 Business Flow
106455 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
106456 -- Prior Entry. Currently, the following code is always generated.
106457 ------------------------------------------------------------------------------------------------
106458 XLA_AE_LINES_PKG.ValidateCurrentLine;
106459
106460 ------------------------------------------------------------------------------------
106461 -- 4219869 Business Flow
106462 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
106463 ------------------------------------------------------------------------------------
106464 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
106465
106466 ----------------------------------------------------------------------------------
106467 -- 4219869 Business Flow
106468 -- Update journal entry status -- Need to generate this within IF <condition>
106469 ----------------------------------------------------------------------------------
106470 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
106471 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
106472 ,p_balance_type_code => l_balance_type_code
106473 );
106474
106475 -------------------------------------------------------------------------------------------
106476 -- 4262811 - Generate the Accrual Reversal lines
106477 -------------------------------------------------------------------------------------------
106478 BEGIN
106479 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
106480 (g_array_event(p_event_id).array_value_num('header_index'));
106481 IF l_acc_rev_flag IS NULL THEN
106482 l_acc_rev_flag := 'N';
106483 END IF;
106484 EXCEPTION
106485 WHEN OTHERS THEN
106486 l_acc_rev_flag := 'N';
106487 END;
106488 --
106489 IF (l_acc_rev_flag = 'Y') THEN
106490
106491 -- 4645092 ------------------------------------------------------------------------------
106492 -- To allow MPA report to determine if it should generate report process
106493 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
106494 ------------------------------------------------------------------------------------------
106495
106496 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
106497 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
106498 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
106499 -- call ADRs
106500 -- Bug 4922099
106501 --
106502 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
106503 (NVL(l_actual_upg_option, 'N') = 'O') OR
106504 (NVL(l_enc_upg_option, 'N') = 'O')
106505 )
106506 THEN
106507 NULL;
106508 --
106509 --
106510
106511 l_ccid := AcctDerRule_24(
106512 p_application_id => p_application_id
106513 , p_ae_header_id => l_ae_header_id
106514 , p_source_40 => p_source_40
106515 , x_transaction_coa_id => l_adr_transaction_coa_id
106516 , x_accounting_coa_id => l_adr_accounting_coa_id
106517 , x_value_type_code => l_adr_value_type_code
106518 , p_side => 'NA'
106519 );
106520
106521 xla_ae_lines_pkg.set_ccid(
106522 p_code_combination_id => l_ccid
106523 , p_value_type_code => l_adr_value_type_code
106524 , p_transaction_coa_id => l_adr_transaction_coa_id
106525 , p_accounting_coa_id => l_adr_accounting_coa_id
106526 , p_adr_code => 'PI_INTERORG_TRANSFER'
106527 , p_adr_type_code => 'S'
106528 , p_component_type => l_component_type
106529 , p_component_code => l_component_code
106530 , p_component_type_code => l_component_type_code
106531 , p_component_appl_id => l_component_appl_id
106532 , p_amb_context_code => l_amb_context_code
106533 , p_side => 'NA'
106534 );
106535
106536
106537 --
106538 --
106539 END IF;
106540
106541 --
106542 -- Update the line information that should be overwritten
106543 --
106544 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
106545 p_header_num => 1);
106546 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
106547
106548 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
106549
106550 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
106551 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
106552 END IF;
106553
106554 --
106555 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
106556 --
106557 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
106558 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
106559 ELSE
106560 ---------------------------------------------------------------------------------------------------
106561 -- 4262811a Switch Sign
106562 ---------------------------------------------------------------------------------------------------
106563 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
106564 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
106565 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
106566 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
106567 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
106568 -- 5132302
106569 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
106570 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
106571
106572 END IF;
106573
106574 -- 4955764
106575 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
106576 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
106577
106578
106579 XLA_AE_LINES_PKG.ValidateCurrentLine;
106580 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
106581
106582 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
106583 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
106584 ,p_balance_type_code => l_balance_type_code);
106585
106586 END IF;
106587
106588 -----------------------------------------------------------------------------------------
106589 -- 4262811 Multiperiod Accounting
106590 -----------------------------------------------------------------------------------------
106591 -- No MPA option is assigned.
106592
106593
106594 END IF;
106595 END IF;
106596 --
106597
106598 --
106599 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
106600 trace
106601 (p_msg => 'END of AcctLineType_210'
106602 ,p_level => C_LEVEL_PROCEDURE
106603 ,p_module => l_log_module);
106604 END IF;
106605 --
106606 EXCEPTION
106607 WHEN xla_exceptions_pkg.application_exception THEN
106608 RAISE;
106609 WHEN OTHERS THEN
106610 xla_exceptions_pkg.raise_message
106611 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_210');
106612 END AcctLineType_210;
106613 --
106614
106615 ---------------------------------------
106616 --
106617 -- PRIVATE FUNCTION
106618 -- AcctLineType_211
106619 --
106620 ---------------------------------------
106621 PROCEDURE AcctLineType_211 (
106622 p_application_id IN NUMBER
106623 ,p_event_id IN NUMBER
106624 ,p_calculate_acctd_flag IN VARCHAR2
106625 ,p_calculate_g_l_flag IN VARCHAR2
106626 ,p_actual_flag IN OUT VARCHAR2
106627 ,p_balance_type_code OUT VARCHAR2
106628 ,p_gain_or_loss_ref OUT VARCHAR2
106629
106630 --TRANSACTION_ID
106631 , p_source_1 IN NUMBER
106632 --Item Concatenated Segments
106633 , p_source_2 IN VARCHAR2
106634 --Transaction Quantity
106635 , p_source_3 IN NUMBER
106636 --Transaction Unit of Measure Code
106637 , p_source_4 IN VARCHAR2
106638 --Inventory Transaction Type Description
106639 , p_source_5 IN VARCHAR2
106640 --Interorg Transfer Credit Account
106641 , p_source_40 IN NUMBER
106642 --DISTRIBUTION_IDENTIFIER
106643 , p_source_84 IN NUMBER
106644 --Distribution Type
106645 , p_source_85 IN VARCHAR2
106646 , p_source_85_meaning IN VARCHAR2
106647 --Entered Currency Code
106648 , p_source_88 IN VARCHAR2
106649 --Entered Amount
106650 , p_source_91 IN NUMBER
106651 --Currency Conversion Date
106652 , p_source_92 IN DATE
106653 --Currency Conversion Rate
106654 , p_source_93 IN NUMBER
106655 --Currency Conversion Type
106656 , p_source_94 IN VARCHAR2
106657 --Accounted Amount
106658 , p_source_95 IN NUMBER
106659 --Accounting Line Type
106660 , p_source_97 IN NUMBER
106661 )
106662 IS
106663
106664 l_component_type VARCHAR2(80);
106665 l_component_code VARCHAR2(30);
106666 l_component_type_code VARCHAR2(1);
106667 l_component_appl_id INTEGER;
106668 l_amb_context_code VARCHAR2(30);
106669 l_entity_code VARCHAR2(30);
106670 l_event_class_code VARCHAR2(30);
106671 l_ae_header_id NUMBER;
106672 l_event_type_code VARCHAR2(30);
106673 l_line_definition_code VARCHAR2(30);
106674 l_line_definition_owner_code VARCHAR2(1);
106675 --
106676 -- adr variables
106677 l_segment VARCHAR2(30);
106678 l_ccid NUMBER;
106679 l_adr_transaction_coa_id NUMBER;
106680 l_adr_accounting_coa_id NUMBER;
106681 l_adr_flexfield_segment_code VARCHAR2(30);
106682 l_adr_flex_value_set_id NUMBER;
106683 l_adr_value_type_code VARCHAR2(30);
106684 l_adr_value_combination_id NUMBER;
106685 l_adr_value_segment_code VARCHAR2(30);
106686
106687 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
106688 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
106689 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
106690 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
106691
106692 -- 4262811 Variables ------------------------------------------------------------------------------------------
106693 l_entered_amt_idx NUMBER;
106694 l_accted_amt_idx NUMBER;
106695 l_acc_rev_flag VARCHAR2(1);
106696 l_accrual_line_num NUMBER;
106697 l_tmp_amt NUMBER;
106698 l_acc_rev_natural_side_code VARCHAR2(1);
106699
106700 l_num_entries NUMBER;
106701 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
106702 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
106703 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
106704 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
106705 l_recog_line_1 NUMBER;
106706 l_recog_line_2 NUMBER;
106707
106708 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
106709 l_bflow_applied_to_amt NUMBER; -- 5132302
106710 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
106711
106712 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
106713
106714 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
106715 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
106716
106717 ---------------------------------------------------------------------------------------------------------------
106718
106719
106720 --
106721 -- bulk performance
106722 --
106723 l_balance_type_code VARCHAR2(1);
106724 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
106725 l_log_module VARCHAR2(240);
106726
106727 --
106728 -- Upgrade strategy
106729 --
106730 l_actual_upg_option VARCHAR2(1);
106731 l_enc_upg_option VARCHAR2(1);
106732
106733 --
106734 BEGIN
106735 --
106736 IF g_log_enabled THEN
106737 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_211';
106738 END IF;
106739 --
106740 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
106741
106742 trace
106743 (p_msg => 'BEGIN of AcctLineType_211'
106744 ,p_level => C_LEVEL_PROCEDURE
106745 ,p_module => l_log_module);
106746
106747 END IF;
106748 --
106749 l_component_type := 'AMB_JLT';
106750 l_component_code := 'INTERORG_TRANSFER_CREDIT';
106751 l_component_type_code := 'S';
106752 l_component_appl_id := 707;
106753 l_amb_context_code := 'DEFAULT';
106754 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
106755 l_event_class_code := 'USER_DEFINE';
106756 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
106757 l_line_definition_owner_code := 'S';
106758 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
106759 --
106760 l_balance_type_code := 'A';
106761 l_segment := NULL;
106762 l_ccid := NULL;
106763 l_adr_transaction_coa_id := NULL;
106764 l_adr_accounting_coa_id := NULL;
106765 l_adr_flexfield_segment_code := NULL;
106766 l_adr_flex_value_set_id := NULL;
106767 l_adr_value_type_code := NULL;
106768 l_adr_value_combination_id := NULL;
106769 l_adr_value_segment_code := NULL;
106770
106771 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
106772 l_bflow_class_code := ''; -- 4219869 Business Flow
106773 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
106774 l_budgetary_control_flag := 'N';
106775
106776 l_bflow_applied_to_amt_idx := NULL; -- 5132302
106777 l_bflow_applied_to_amt := NULL; -- 5132302
106778 l_entered_amt_idx := NULL; -- 4262811
106779 l_accted_amt_idx := NULL; -- 4262811
106780 l_acc_rev_flag := NULL; -- 4262811
106781 l_accrual_line_num := NULL; -- 4262811
106782 l_tmp_amt := NULL; -- 4262811
106783 --
106784
106785 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
106786 l_balance_type_code <> 'B' THEN
106787 IF NVL(p_source_97,9E125) = 11
106788 THEN
106789
106790 --
106791 XLA_AE_LINES_PKG.SetNewLine;
106792
106793 p_balance_type_code := l_balance_type_code;
106794 -- set the flag so later we will know whether the gain loss line needs to be created
106795
106796 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
106797 p_actual_flag :='A';
106798 END IF;
106799
106800 --
106801 -- bulk performance
106802 --
106803 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
106804 p_header_num => 0); -- 4262811
106805 --
106806 -- set accounting line options
106807 --
106808 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
106809 p_natural_side_code => 'D'
106810 , p_gain_or_loss_flag => 'N'
106811 , p_gl_transfer_mode_code => 'S'
106812 , p_acct_entry_type_code => 'A'
106813 , p_switch_side_flag => 'Y'
106814 , p_merge_duplicate_code => 'N'
106815 );
106816 --
106817 l_acc_rev_natural_side_code := 'C'; -- 4262811
106818 --
106819 --
106820 -- set accounting line type info
106821 --
106822 xla_ae_lines_pkg.SetAcctLineType
106823 (p_component_type => l_component_type
106824 ,p_event_type_code => l_event_type_code
106825 ,p_line_definition_owner_code => l_line_definition_owner_code
106826 ,p_line_definition_code => l_line_definition_code
106827 ,p_accounting_line_code => l_component_code
106828 ,p_accounting_line_type_code => l_component_type_code
106829 ,p_accounting_line_appl_id => l_component_appl_id
106830 ,p_amb_context_code => l_amb_context_code
106831 ,p_entity_code => l_entity_code
106832 ,p_event_class_code => l_event_class_code);
106833 --
106834 -- set accounting class
106835 --
106836 xla_ae_lines_pkg.SetAcctClass(
106837 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
106838 , p_ae_header_id => l_ae_header_id
106839 );
106840
106841 --
106842 -- set rounding class
106843 --
106844 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
106845 'INTERORG_TRANSFER_CREDIT';
106846
106847 --
106848 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
106849 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
106850 --
106851 -- bulk performance
106852 --
106853 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
106854
106855 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
106856 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
106857
106858 -- 4955764
106859 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
106860 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
106861
106862 -- 4458381 Public Sector Enh
106863
106864 --
106865 -- set accounting attributes for the line type
106866 --
106867 l_entered_amt_idx := 3;
106868 l_accted_amt_idx := 8;
106869 l_bflow_applied_to_amt_idx := NULL; -- 5132302
106870 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
106871 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
106872 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
106873 l_rec_acct_attrs.array_char_value(2) := p_source_85;
106874 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
106875 l_rec_acct_attrs.array_num_value(3) := p_source_91;
106876 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
106877 l_rec_acct_attrs.array_char_value(4) := p_source_88;
106878 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
106879 l_rec_acct_attrs.array_date_value(5) := p_source_92;
106880 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
106881 l_rec_acct_attrs.array_num_value(6) := p_source_93;
106882 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
106883 l_rec_acct_attrs.array_char_value(7) := p_source_94;
106884 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
106885 l_rec_acct_attrs.array_num_value(8) := p_source_95;
106886
106887 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
106888 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
106889
106890 ---------------------------------------------------------------------------------------------------------------
106891 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
106892 ---------------------------------------------------------------------------------------------------------------
106893 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
106894
106895 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
106896 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
106897
106898 IF xla_accounting_cache_pkg.GetValueChar
106899 (p_source_code => 'LEDGER_CATEGORY_CODE'
106900 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
106901 AND l_bflow_method_code = 'PRIOR_ENTRY'
106902 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
106903 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
106904 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
106905 )
106906 THEN
106907 xla_ae_lines_pkg.BflowUpgEntry
106908 (p_business_method_code => l_bflow_method_code
106909 ,p_business_class_code => l_bflow_class_code
106910 ,p_balance_type => l_balance_type_code);
106911 ELSE
106912 NULL;
106913 -- No business flow processing for business flow method of NONE.
106914 END IF;
106915
106916 --
106917 -- call analytical criteria
106918 --
106919
106920 --
106921 -- call description
106922 --
106923
106924 xla_ae_lines_pkg.SetLineDescription(
106925 p_ae_header_id => l_ae_header_id
106926 ,p_description => Description_1 (
106927 p_application_id => p_application_id
106928 , p_ae_header_id => l_ae_header_id
106929 , p_source_1 => p_source_1
106930 , p_source_2 => p_source_2
106931 , p_source_3 => p_source_3
106932 , p_source_4 => p_source_4
106933 , p_source_5 => p_source_5
106934 )
106935 );
106936
106937
106938 --
106939 -- call ADRs
106940 -- Bug 4922099
106941 --
106942 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
106943 (NVL(l_actual_upg_option, 'N') = 'O') OR
106944 (NVL(l_enc_upg_option, 'N') = 'O')
106945 )
106946 THEN
106947 NULL;
106948 --
106949 --
106950
106951 l_ccid := AcctDerRule_24(
106952 p_application_id => p_application_id
106953 , p_ae_header_id => l_ae_header_id
106954 , p_source_40 => p_source_40
106955 , x_transaction_coa_id => l_adr_transaction_coa_id
106956 , x_accounting_coa_id => l_adr_accounting_coa_id
106957 , x_value_type_code => l_adr_value_type_code
106958 , p_side => 'NA'
106959 );
106960
106961 xla_ae_lines_pkg.set_ccid(
106962 p_code_combination_id => l_ccid
106963 , p_value_type_code => l_adr_value_type_code
106964 , p_transaction_coa_id => l_adr_transaction_coa_id
106965 , p_accounting_coa_id => l_adr_accounting_coa_id
106966 , p_adr_code => 'PI_INTERORG_TRANSFER'
106967 , p_adr_type_code => 'S'
106968 , p_component_type => l_component_type
106969 , p_component_code => l_component_code
106970 , p_component_type_code => l_component_type_code
106971 , p_component_appl_id => l_component_appl_id
106972 , p_amb_context_code => l_amb_context_code
106973 , p_side => 'NA'
106974 );
106975
106976
106977 --
106978 --
106979 END IF;
106980 --
106981 -- Bug 4922099
106982 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
106983 (NVL(l_enc_upg_option, 'N') = 'O')
106984 ) AND
106985 (l_bflow_method_code = 'PRIOR_ENTRY')
106986 )
106987 THEN
106988 IF
106989 --
106990 1 = 2
106991 --
106992 THEN
106993 xla_accounting_err_pkg.build_message
106994 (p_appli_s_name => 'XLA'
106995 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
106996 ,p_token_1 => 'LINE_NUMBER'
106997 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
106998 ,p_token_2 => 'LINE_TYPE_NAME'
106999 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
107000 l_component_type
107001 ,l_component_code
107002 ,l_component_type_code
107003 ,l_component_appl_id
107004 ,l_amb_context_code
107005 ,l_entity_code
107006 ,l_event_class_code
107007 )
107008 ,p_token_3 => 'OWNER'
107009 ,p_value_3 => xla_lookups_pkg.get_meaning(
107010 p_lookup_type => 'XLA_OWNER_TYPE'
107011 ,p_lookup_code => l_component_type_code
107012 )
107013 ,p_token_4 => 'PRODUCT_NAME'
107014 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
107015 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
107016 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
107017 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
107018 ,p_ae_header_id => NULL
107019 );
107020
107021 IF (C_LEVEL_ERROR>= g_log_level) THEN
107022 trace
107023 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
107024 ,p_level => C_LEVEL_ERROR
107025 ,p_module => l_log_module);
107026 END IF;
107027 END IF;
107028 END IF;
107029 --
107030 --
107031 ------------------------------------------------------------------------------------------------
107032 -- 4219869 Business Flow
107033 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
107034 -- Prior Entry. Currently, the following code is always generated.
107035 ------------------------------------------------------------------------------------------------
107036 XLA_AE_LINES_PKG.ValidateCurrentLine;
107037
107038 ------------------------------------------------------------------------------------
107039 -- 4219869 Business Flow
107040 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
107041 ------------------------------------------------------------------------------------
107042 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
107043
107044 ----------------------------------------------------------------------------------
107045 -- 4219869 Business Flow
107046 -- Update journal entry status -- Need to generate this within IF <condition>
107047 ----------------------------------------------------------------------------------
107048 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
107049 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
107050 ,p_balance_type_code => l_balance_type_code
107051 );
107052
107053 -------------------------------------------------------------------------------------------
107054 -- 4262811 - Generate the Accrual Reversal lines
107055 -------------------------------------------------------------------------------------------
107056 BEGIN
107057 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
107058 (g_array_event(p_event_id).array_value_num('header_index'));
107059 IF l_acc_rev_flag IS NULL THEN
107060 l_acc_rev_flag := 'N';
107061 END IF;
107062 EXCEPTION
107063 WHEN OTHERS THEN
107064 l_acc_rev_flag := 'N';
107065 END;
107066 --
107067 IF (l_acc_rev_flag = 'Y') THEN
107068
107069 -- 4645092 ------------------------------------------------------------------------------
107070 -- To allow MPA report to determine if it should generate report process
107071 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
107072 ------------------------------------------------------------------------------------------
107073
107074 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
107075 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
107076 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
107077 -- call ADRs
107078 -- Bug 4922099
107079 --
107080 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
107081 (NVL(l_actual_upg_option, 'N') = 'O') OR
107082 (NVL(l_enc_upg_option, 'N') = 'O')
107083 )
107084 THEN
107085 NULL;
107086 --
107087 --
107088
107089 l_ccid := AcctDerRule_24(
107090 p_application_id => p_application_id
107091 , p_ae_header_id => l_ae_header_id
107092 , p_source_40 => p_source_40
107093 , x_transaction_coa_id => l_adr_transaction_coa_id
107094 , x_accounting_coa_id => l_adr_accounting_coa_id
107095 , x_value_type_code => l_adr_value_type_code
107096 , p_side => 'NA'
107097 );
107098
107099 xla_ae_lines_pkg.set_ccid(
107100 p_code_combination_id => l_ccid
107101 , p_value_type_code => l_adr_value_type_code
107102 , p_transaction_coa_id => l_adr_transaction_coa_id
107103 , p_accounting_coa_id => l_adr_accounting_coa_id
107104 , p_adr_code => 'PI_INTERORG_TRANSFER'
107105 , p_adr_type_code => 'S'
107106 , p_component_type => l_component_type
107107 , p_component_code => l_component_code
107108 , p_component_type_code => l_component_type_code
107109 , p_component_appl_id => l_component_appl_id
107110 , p_amb_context_code => l_amb_context_code
107111 , p_side => 'NA'
107112 );
107113
107114
107115 --
107116 --
107117 END IF;
107118
107119 --
107120 -- Update the line information that should be overwritten
107121 --
107122 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
107123 p_header_num => 1);
107124 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
107125
107126 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
107127
107128 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
107129 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
107130 END IF;
107131
107132 --
107133 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
107134 --
107135 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
107136 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
107137 ELSE
107138 ---------------------------------------------------------------------------------------------------
107139 -- 4262811a Switch Sign
107140 ---------------------------------------------------------------------------------------------------
107141 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
107142 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
107143 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107144 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
107145 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107146 -- 5132302
107147 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
107148 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107149
107150 END IF;
107151
107152 -- 4955764
107153 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
107154 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
107155
107156
107157 XLA_AE_LINES_PKG.ValidateCurrentLine;
107158 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
107159
107160 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
107161 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
107162 ,p_balance_type_code => l_balance_type_code);
107163
107164 END IF;
107165
107166 -----------------------------------------------------------------------------------------
107167 -- 4262811 Multiperiod Accounting
107168 -----------------------------------------------------------------------------------------
107169 -- No MPA option is assigned.
107170
107171
107172 END IF;
107173 END IF;
107174 --
107175
107176 --
107177 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
107178 trace
107179 (p_msg => 'END of AcctLineType_211'
107180 ,p_level => C_LEVEL_PROCEDURE
107181 ,p_module => l_log_module);
107182 END IF;
107183 --
107184 EXCEPTION
107185 WHEN xla_exceptions_pkg.application_exception THEN
107186 RAISE;
107187 WHEN OTHERS THEN
107188 xla_exceptions_pkg.raise_message
107189 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_211');
107190 END AcctLineType_211;
107191 --
107192
107193 ---------------------------------------
107194 --
107195 -- PRIVATE FUNCTION
107196 -- AcctLineType_212
107197 --
107198 ---------------------------------------
107199 PROCEDURE AcctLineType_212 (
107200 p_application_id IN NUMBER
107201 ,p_event_id IN NUMBER
107202 ,p_calculate_acctd_flag IN VARCHAR2
107203 ,p_calculate_g_l_flag IN VARCHAR2
107204 ,p_actual_flag IN OUT VARCHAR2
107205 ,p_balance_type_code OUT VARCHAR2
107206 ,p_gain_or_loss_ref OUT VARCHAR2
107207
107208 --TRANSACTION_ID
107209 , p_source_1 IN NUMBER
107210 --Item Concatenated Segments
107211 , p_source_2 IN VARCHAR2
107212 --Transaction Quantity
107213 , p_source_3 IN NUMBER
107214 --Transaction Unit of Measure Code
107215 , p_source_4 IN VARCHAR2
107216 --Inventory Transaction Type Description
107217 , p_source_5 IN VARCHAR2
107218 --Cost Management Default Account
107219 , p_source_11 IN NUMBER
107220 --DISTRIBUTION_IDENTIFIER
107221 , p_source_84 IN NUMBER
107222 --Distribution Type
107223 , p_source_85 IN VARCHAR2
107224 , p_source_85_meaning IN VARCHAR2
107225 --Entered Currency Code
107226 , p_source_88 IN VARCHAR2
107227 --Entered Amount
107228 , p_source_91 IN NUMBER
107229 --Currency Conversion Date
107230 , p_source_92 IN DATE
107231 --Currency Conversion Rate
107232 , p_source_93 IN NUMBER
107233 --Currency Conversion Type
107234 , p_source_94 IN VARCHAR2
107235 --Accounted Amount
107236 , p_source_95 IN NUMBER
107237 --Accounting Line Type
107238 , p_source_97 IN NUMBER
107239 )
107240 IS
107241
107242 l_component_type VARCHAR2(80);
107243 l_component_code VARCHAR2(30);
107244 l_component_type_code VARCHAR2(1);
107245 l_component_appl_id INTEGER;
107246 l_amb_context_code VARCHAR2(30);
107247 l_entity_code VARCHAR2(30);
107248 l_event_class_code VARCHAR2(30);
107249 l_ae_header_id NUMBER;
107250 l_event_type_code VARCHAR2(30);
107251 l_line_definition_code VARCHAR2(30);
107252 l_line_definition_owner_code VARCHAR2(1);
107253 --
107254 -- adr variables
107255 l_segment VARCHAR2(30);
107256 l_ccid NUMBER;
107257 l_adr_transaction_coa_id NUMBER;
107258 l_adr_accounting_coa_id NUMBER;
107259 l_adr_flexfield_segment_code VARCHAR2(30);
107260 l_adr_flex_value_set_id NUMBER;
107261 l_adr_value_type_code VARCHAR2(30);
107262 l_adr_value_combination_id NUMBER;
107263 l_adr_value_segment_code VARCHAR2(30);
107264
107265 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
107266 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
107267 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
107268 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
107269
107270 -- 4262811 Variables ------------------------------------------------------------------------------------------
107271 l_entered_amt_idx NUMBER;
107272 l_accted_amt_idx NUMBER;
107273 l_acc_rev_flag VARCHAR2(1);
107274 l_accrual_line_num NUMBER;
107275 l_tmp_amt NUMBER;
107276 l_acc_rev_natural_side_code VARCHAR2(1);
107277
107278 l_num_entries NUMBER;
107279 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
107280 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
107281 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
107282 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
107283 l_recog_line_1 NUMBER;
107284 l_recog_line_2 NUMBER;
107285
107286 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
107287 l_bflow_applied_to_amt NUMBER; -- 5132302
107288 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
107289
107290 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
107291
107292 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
107293 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
107294
107295 ---------------------------------------------------------------------------------------------------------------
107296
107297
107298 --
107299 -- bulk performance
107300 --
107301 l_balance_type_code VARCHAR2(1);
107302 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
107303 l_log_module VARCHAR2(240);
107304
107305 --
107306 -- Upgrade strategy
107307 --
107308 l_actual_upg_option VARCHAR2(1);
107309 l_enc_upg_option VARCHAR2(1);
107310
107311 --
107312 BEGIN
107313 --
107314 IF g_log_enabled THEN
107315 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_212';
107316 END IF;
107317 --
107318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
107319
107320 trace
107321 (p_msg => 'BEGIN of AcctLineType_212'
107322 ,p_level => C_LEVEL_PROCEDURE
107323 ,p_module => l_log_module);
107324
107325 END IF;
107326 --
107327 l_component_type := 'AMB_JLT';
107328 l_component_code := 'INTERORG_TRANSFER_CREDIT';
107329 l_component_type_code := 'S';
107330 l_component_appl_id := 707;
107331 l_amb_context_code := 'DEFAULT';
107332 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
107333 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
107334 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_TP';
107335 l_line_definition_owner_code := 'S';
107336 l_line_definition_code := 'PI_RCPT_SENDER_RCPT_TP';
107337 --
107338 l_balance_type_code := 'A';
107339 l_segment := NULL;
107340 l_ccid := NULL;
107341 l_adr_transaction_coa_id := NULL;
107342 l_adr_accounting_coa_id := NULL;
107343 l_adr_flexfield_segment_code := NULL;
107344 l_adr_flex_value_set_id := NULL;
107345 l_adr_value_type_code := NULL;
107346 l_adr_value_combination_id := NULL;
107347 l_adr_value_segment_code := NULL;
107348
107349 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
107350 l_bflow_class_code := ''; -- 4219869 Business Flow
107351 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
107352 l_budgetary_control_flag := 'N';
107353
107354 l_bflow_applied_to_amt_idx := NULL; -- 5132302
107355 l_bflow_applied_to_amt := NULL; -- 5132302
107356 l_entered_amt_idx := NULL; -- 4262811
107357 l_accted_amt_idx := NULL; -- 4262811
107358 l_acc_rev_flag := NULL; -- 4262811
107359 l_accrual_line_num := NULL; -- 4262811
107360 l_tmp_amt := NULL; -- 4262811
107361 --
107362
107363 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
107364 l_balance_type_code <> 'B' THEN
107365 IF NVL(p_source_97,9E125) = 11
107366 THEN
107367
107368 --
107369 XLA_AE_LINES_PKG.SetNewLine;
107370
107371 p_balance_type_code := l_balance_type_code;
107372 -- set the flag so later we will know whether the gain loss line needs to be created
107373
107374 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
107375 p_actual_flag :='A';
107376 END IF;
107377
107378 --
107379 -- bulk performance
107380 --
107381 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
107382 p_header_num => 0); -- 4262811
107383 --
107384 -- set accounting line options
107385 --
107386 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
107387 p_natural_side_code => 'D'
107388 , p_gain_or_loss_flag => 'N'
107389 , p_gl_transfer_mode_code => 'S'
107390 , p_acct_entry_type_code => 'A'
107391 , p_switch_side_flag => 'Y'
107392 , p_merge_duplicate_code => 'N'
107393 );
107394 --
107395 l_acc_rev_natural_side_code := 'C'; -- 4262811
107396 --
107397 --
107398 -- set accounting line type info
107399 --
107400 xla_ae_lines_pkg.SetAcctLineType
107401 (p_component_type => l_component_type
107402 ,p_event_type_code => l_event_type_code
107403 ,p_line_definition_owner_code => l_line_definition_owner_code
107404 ,p_line_definition_code => l_line_definition_code
107405 ,p_accounting_line_code => l_component_code
107406 ,p_accounting_line_type_code => l_component_type_code
107407 ,p_accounting_line_appl_id => l_component_appl_id
107408 ,p_amb_context_code => l_amb_context_code
107409 ,p_entity_code => l_entity_code
107410 ,p_event_class_code => l_event_class_code);
107411 --
107412 -- set accounting class
107413 --
107414 xla_ae_lines_pkg.SetAcctClass(
107415 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
107416 , p_ae_header_id => l_ae_header_id
107417 );
107418
107419 --
107420 -- set rounding class
107421 --
107422 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
107423 'INTERORG_TRANSFER_CREDIT';
107424
107425 --
107426 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
107427 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
107428 --
107429 -- bulk performance
107430 --
107431 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
107432
107433 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
107434 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
107435
107436 -- 4955764
107437 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
107438 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
107439
107440 -- 4458381 Public Sector Enh
107441
107442 --
107443 -- set accounting attributes for the line type
107444 --
107445 l_entered_amt_idx := 3;
107446 l_accted_amt_idx := 8;
107447 l_bflow_applied_to_amt_idx := NULL; -- 5132302
107448 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
107449 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
107450 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
107451 l_rec_acct_attrs.array_char_value(2) := p_source_85;
107452 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
107453 l_rec_acct_attrs.array_num_value(3) := p_source_91;
107454 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
107455 l_rec_acct_attrs.array_char_value(4) := p_source_88;
107456 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
107457 l_rec_acct_attrs.array_date_value(5) := p_source_92;
107458 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
107459 l_rec_acct_attrs.array_num_value(6) := p_source_93;
107460 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
107461 l_rec_acct_attrs.array_char_value(7) := p_source_94;
107462 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
107463 l_rec_acct_attrs.array_num_value(8) := p_source_95;
107464
107465 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
107466 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
107467
107468 ---------------------------------------------------------------------------------------------------------------
107469 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
107470 ---------------------------------------------------------------------------------------------------------------
107471 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
107472
107473 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
107474 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
107475
107476 IF xla_accounting_cache_pkg.GetValueChar
107477 (p_source_code => 'LEDGER_CATEGORY_CODE'
107478 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
107479 AND l_bflow_method_code = 'PRIOR_ENTRY'
107480 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
107481 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
107482 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
107483 )
107484 THEN
107485 xla_ae_lines_pkg.BflowUpgEntry
107486 (p_business_method_code => l_bflow_method_code
107487 ,p_business_class_code => l_bflow_class_code
107488 ,p_balance_type => l_balance_type_code);
107489 ELSE
107490 NULL;
107491 -- No business flow processing for business flow method of NONE.
107492 END IF;
107493
107494 --
107495 -- call analytical criteria
107496 --
107497
107498 --
107499 -- call description
107500 --
107501
107502 xla_ae_lines_pkg.SetLineDescription(
107503 p_ae_header_id => l_ae_header_id
107504 ,p_description => Description_1 (
107505 p_application_id => p_application_id
107506 , p_ae_header_id => l_ae_header_id
107507 , p_source_1 => p_source_1
107508 , p_source_2 => p_source_2
107509 , p_source_3 => p_source_3
107510 , p_source_4 => p_source_4
107511 , p_source_5 => p_source_5
107512 )
107513 );
107514
107515
107516 --
107517 -- call ADRs
107518 -- Bug 4922099
107519 --
107520 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
107521 (NVL(l_actual_upg_option, 'N') = 'O') OR
107522 (NVL(l_enc_upg_option, 'N') = 'O')
107523 )
107524 THEN
107525 NULL;
107526 --
107527 --
107528
107529 l_ccid := AcctDerRule_6(
107530 p_application_id => p_application_id
107531 , p_ae_header_id => l_ae_header_id
107532 , p_source_11 => p_source_11
107533 , x_transaction_coa_id => l_adr_transaction_coa_id
107534 , x_accounting_coa_id => l_adr_accounting_coa_id
107535 , x_value_type_code => l_adr_value_type_code
107536 , p_side => 'NA'
107537 );
107538
107539 xla_ae_lines_pkg.set_ccid(
107540 p_code_combination_id => l_ccid
107541 , p_value_type_code => l_adr_value_type_code
107542 , p_transaction_coa_id => l_adr_transaction_coa_id
107543 , p_accounting_coa_id => l_adr_accounting_coa_id
107544 , p_adr_code => 'CST_DEFAULT'
107545 , p_adr_type_code => 'S'
107546 , p_component_type => l_component_type
107547 , p_component_code => l_component_code
107548 , p_component_type_code => l_component_type_code
107549 , p_component_appl_id => l_component_appl_id
107550 , p_amb_context_code => l_amb_context_code
107551 , p_side => 'NA'
107552 );
107553
107554
107555 --
107556 --
107557 END IF;
107558 --
107559 -- Bug 4922099
107560 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
107561 (NVL(l_enc_upg_option, 'N') = 'O')
107562 ) AND
107563 (l_bflow_method_code = 'PRIOR_ENTRY')
107564 )
107565 THEN
107566 IF
107567 --
107568 1 = 2
107569 --
107570 THEN
107571 xla_accounting_err_pkg.build_message
107572 (p_appli_s_name => 'XLA'
107573 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
107574 ,p_token_1 => 'LINE_NUMBER'
107575 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
107576 ,p_token_2 => 'LINE_TYPE_NAME'
107577 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
107578 l_component_type
107579 ,l_component_code
107580 ,l_component_type_code
107581 ,l_component_appl_id
107582 ,l_amb_context_code
107583 ,l_entity_code
107584 ,l_event_class_code
107585 )
107586 ,p_token_3 => 'OWNER'
107587 ,p_value_3 => xla_lookups_pkg.get_meaning(
107588 p_lookup_type => 'XLA_OWNER_TYPE'
107589 ,p_lookup_code => l_component_type_code
107590 )
107591 ,p_token_4 => 'PRODUCT_NAME'
107592 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
107593 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
107594 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
107595 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
107596 ,p_ae_header_id => NULL
107597 );
107598
107599 IF (C_LEVEL_ERROR>= g_log_level) THEN
107600 trace
107601 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
107602 ,p_level => C_LEVEL_ERROR
107603 ,p_module => l_log_module);
107604 END IF;
107605 END IF;
107606 END IF;
107607 --
107608 --
107609 ------------------------------------------------------------------------------------------------
107610 -- 4219869 Business Flow
107611 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
107612 -- Prior Entry. Currently, the following code is always generated.
107613 ------------------------------------------------------------------------------------------------
107614 XLA_AE_LINES_PKG.ValidateCurrentLine;
107615
107616 ------------------------------------------------------------------------------------
107617 -- 4219869 Business Flow
107618 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
107619 ------------------------------------------------------------------------------------
107620 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
107621
107622 ----------------------------------------------------------------------------------
107623 -- 4219869 Business Flow
107624 -- Update journal entry status -- Need to generate this within IF <condition>
107625 ----------------------------------------------------------------------------------
107626 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
107627 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
107628 ,p_balance_type_code => l_balance_type_code
107629 );
107630
107631 -------------------------------------------------------------------------------------------
107632 -- 4262811 - Generate the Accrual Reversal lines
107633 -------------------------------------------------------------------------------------------
107634 BEGIN
107635 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
107636 (g_array_event(p_event_id).array_value_num('header_index'));
107637 IF l_acc_rev_flag IS NULL THEN
107638 l_acc_rev_flag := 'N';
107639 END IF;
107640 EXCEPTION
107641 WHEN OTHERS THEN
107642 l_acc_rev_flag := 'N';
107643 END;
107644 --
107645 IF (l_acc_rev_flag = 'Y') THEN
107646
107647 -- 4645092 ------------------------------------------------------------------------------
107648 -- To allow MPA report to determine if it should generate report process
107649 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
107650 ------------------------------------------------------------------------------------------
107651
107652 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
107653 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
107654 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
107655 -- call ADRs
107656 -- Bug 4922099
107657 --
107658 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
107659 (NVL(l_actual_upg_option, 'N') = 'O') OR
107660 (NVL(l_enc_upg_option, 'N') = 'O')
107661 )
107662 THEN
107663 NULL;
107664 --
107665 --
107666
107667 l_ccid := AcctDerRule_6(
107668 p_application_id => p_application_id
107669 , p_ae_header_id => l_ae_header_id
107670 , p_source_11 => p_source_11
107671 , x_transaction_coa_id => l_adr_transaction_coa_id
107672 , x_accounting_coa_id => l_adr_accounting_coa_id
107673 , x_value_type_code => l_adr_value_type_code
107674 , p_side => 'NA'
107675 );
107676
107677 xla_ae_lines_pkg.set_ccid(
107678 p_code_combination_id => l_ccid
107679 , p_value_type_code => l_adr_value_type_code
107680 , p_transaction_coa_id => l_adr_transaction_coa_id
107681 , p_accounting_coa_id => l_adr_accounting_coa_id
107682 , p_adr_code => 'CST_DEFAULT'
107683 , p_adr_type_code => 'S'
107684 , p_component_type => l_component_type
107685 , p_component_code => l_component_code
107686 , p_component_type_code => l_component_type_code
107687 , p_component_appl_id => l_component_appl_id
107688 , p_amb_context_code => l_amb_context_code
107689 , p_side => 'NA'
107690 );
107691
107692
107693 --
107694 --
107695 END IF;
107696
107697 --
107698 -- Update the line information that should be overwritten
107699 --
107700 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
107701 p_header_num => 1);
107702 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
107703
107704 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
107705
107706 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
107707 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
107708 END IF;
107709
107710 --
107711 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
107712 --
107713 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
107714 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
107715 ELSE
107716 ---------------------------------------------------------------------------------------------------
107717 -- 4262811a Switch Sign
107718 ---------------------------------------------------------------------------------------------------
107719 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
107720 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
107721 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107722 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
107723 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107724 -- 5132302
107725 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
107726 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
107727
107728 END IF;
107729
107730 -- 4955764
107731 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
107732 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
107733
107734
107735 XLA_AE_LINES_PKG.ValidateCurrentLine;
107736 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
107737
107738 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
107739 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
107740 ,p_balance_type_code => l_balance_type_code);
107741
107742 END IF;
107743
107744 -----------------------------------------------------------------------------------------
107745 -- 4262811 Multiperiod Accounting
107746 -----------------------------------------------------------------------------------------
107747 -- No MPA option is assigned.
107748
107749
107750 END IF;
107751 END IF;
107752 --
107753
107754 --
107755 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
107756 trace
107757 (p_msg => 'END of AcctLineType_212'
107758 ,p_level => C_LEVEL_PROCEDURE
107759 ,p_module => l_log_module);
107760 END IF;
107761 --
107762 EXCEPTION
107763 WHEN xla_exceptions_pkg.application_exception THEN
107764 RAISE;
107765 WHEN OTHERS THEN
107766 xla_exceptions_pkg.raise_message
107767 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_212');
107768 END AcctLineType_212;
107769 --
107770
107771 ---------------------------------------
107772 --
107773 -- PRIVATE FUNCTION
107774 -- AcctLineType_213
107775 --
107776 ---------------------------------------
107777 PROCEDURE AcctLineType_213 (
107778 p_application_id IN NUMBER
107779 ,p_event_id IN NUMBER
107780 ,p_calculate_acctd_flag IN VARCHAR2
107781 ,p_calculate_g_l_flag IN VARCHAR2
107782 ,p_actual_flag IN OUT VARCHAR2
107783 ,p_balance_type_code OUT VARCHAR2
107784 ,p_gain_or_loss_ref OUT VARCHAR2
107785
107786 --TRANSACTION_ID
107787 , p_source_1 IN NUMBER
107788 --Item Concatenated Segments
107789 , p_source_2 IN VARCHAR2
107790 --Transaction Quantity
107791 , p_source_3 IN NUMBER
107792 --Transaction Unit of Measure Code
107793 , p_source_4 IN VARCHAR2
107794 --Inventory Transaction Type Description
107795 , p_source_5 IN VARCHAR2
107796 --Interorg Transfer Credit Account
107797 , p_source_40 IN NUMBER
107798 --DISTRIBUTION_IDENTIFIER
107799 , p_source_84 IN NUMBER
107800 --Distribution Type
107801 , p_source_85 IN VARCHAR2
107802 , p_source_85_meaning IN VARCHAR2
107803 --Entered Currency Code
107804 , p_source_88 IN VARCHAR2
107805 --Entered Amount
107806 , p_source_91 IN NUMBER
107807 --Currency Conversion Date
107808 , p_source_92 IN DATE
107809 --Currency Conversion Rate
107810 , p_source_93 IN NUMBER
107811 --Currency Conversion Type
107812 , p_source_94 IN VARCHAR2
107813 --Accounted Amount
107814 , p_source_95 IN NUMBER
107815 --Accounting Line Type
107816 , p_source_97 IN NUMBER
107817 )
107818 IS
107819
107820 l_component_type VARCHAR2(80);
107821 l_component_code VARCHAR2(30);
107822 l_component_type_code VARCHAR2(1);
107823 l_component_appl_id INTEGER;
107824 l_amb_context_code VARCHAR2(30);
107825 l_entity_code VARCHAR2(30);
107826 l_event_class_code VARCHAR2(30);
107827 l_ae_header_id NUMBER;
107828 l_event_type_code VARCHAR2(30);
107829 l_line_definition_code VARCHAR2(30);
107830 l_line_definition_owner_code VARCHAR2(1);
107831 --
107832 -- adr variables
107833 l_segment VARCHAR2(30);
107834 l_ccid NUMBER;
107835 l_adr_transaction_coa_id NUMBER;
107836 l_adr_accounting_coa_id NUMBER;
107837 l_adr_flexfield_segment_code VARCHAR2(30);
107838 l_adr_flex_value_set_id NUMBER;
107839 l_adr_value_type_code VARCHAR2(30);
107840 l_adr_value_combination_id NUMBER;
107841 l_adr_value_segment_code VARCHAR2(30);
107842
107843 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
107844 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
107845 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
107846 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
107847
107848 -- 4262811 Variables ------------------------------------------------------------------------------------------
107849 l_entered_amt_idx NUMBER;
107850 l_accted_amt_idx NUMBER;
107851 l_acc_rev_flag VARCHAR2(1);
107852 l_accrual_line_num NUMBER;
107853 l_tmp_amt NUMBER;
107854 l_acc_rev_natural_side_code VARCHAR2(1);
107855
107856 l_num_entries NUMBER;
107857 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
107858 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
107859 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
107860 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
107861 l_recog_line_1 NUMBER;
107862 l_recog_line_2 NUMBER;
107863
107864 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
107865 l_bflow_applied_to_amt NUMBER; -- 5132302
107866 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
107867
107868 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
107869
107870 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
107871 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
107872
107873 ---------------------------------------------------------------------------------------------------------------
107874
107875
107876 --
107877 -- bulk performance
107878 --
107879 l_balance_type_code VARCHAR2(1);
107880 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
107881 l_log_module VARCHAR2(240);
107882
107883 --
107884 -- Upgrade strategy
107885 --
107886 l_actual_upg_option VARCHAR2(1);
107887 l_enc_upg_option VARCHAR2(1);
107888
107889 --
107890 BEGIN
107891 --
107892 IF g_log_enabled THEN
107893 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_213';
107894 END IF;
107895 --
107896 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
107897
107898 trace
107899 (p_msg => 'BEGIN of AcctLineType_213'
107900 ,p_level => C_LEVEL_PROCEDURE
107901 ,p_module => l_log_module);
107902
107903 END IF;
107904 --
107905 l_component_type := 'AMB_JLT';
107906 l_component_code := 'INTERORG_TRANSFER_CREDIT';
107907 l_component_type_code := 'S';
107908 l_component_appl_id := 707;
107909 l_amb_context_code := 'DEFAULT';
107910 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
107911 l_event_class_code := 'USER_DEFINE';
107912 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
107913 l_line_definition_owner_code := 'S';
107914 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
107915 --
107916 l_balance_type_code := 'A';
107917 l_segment := NULL;
107918 l_ccid := NULL;
107919 l_adr_transaction_coa_id := NULL;
107920 l_adr_accounting_coa_id := NULL;
107921 l_adr_flexfield_segment_code := NULL;
107922 l_adr_flex_value_set_id := NULL;
107923 l_adr_value_type_code := NULL;
107924 l_adr_value_combination_id := NULL;
107925 l_adr_value_segment_code := NULL;
107926
107927 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
107928 l_bflow_class_code := ''; -- 4219869 Business Flow
107929 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
107930 l_budgetary_control_flag := 'N';
107931
107932 l_bflow_applied_to_amt_idx := NULL; -- 5132302
107933 l_bflow_applied_to_amt := NULL; -- 5132302
107934 l_entered_amt_idx := NULL; -- 4262811
107935 l_accted_amt_idx := NULL; -- 4262811
107936 l_acc_rev_flag := NULL; -- 4262811
107937 l_accrual_line_num := NULL; -- 4262811
107938 l_tmp_amt := NULL; -- 4262811
107939 --
107940
107941 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
107942 l_balance_type_code <> 'B' THEN
107943 IF NVL(p_source_97,9E125) = 11
107944 THEN
107945
107946 --
107947 XLA_AE_LINES_PKG.SetNewLine;
107948
107949 p_balance_type_code := l_balance_type_code;
107950 -- set the flag so later we will know whether the gain loss line needs to be created
107951
107952 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
107953 p_actual_flag :='A';
107954 END IF;
107955
107956 --
107957 -- bulk performance
107958 --
107959 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
107960 p_header_num => 0); -- 4262811
107961 --
107962 -- set accounting line options
107963 --
107964 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
107965 p_natural_side_code => 'D'
107966 , p_gain_or_loss_flag => 'N'
107967 , p_gl_transfer_mode_code => 'S'
107968 , p_acct_entry_type_code => 'A'
107969 , p_switch_side_flag => 'Y'
107970 , p_merge_duplicate_code => 'N'
107971 );
107972 --
107973 l_acc_rev_natural_side_code := 'C'; -- 4262811
107974 --
107975 --
107976 -- set accounting line type info
107977 --
107978 xla_ae_lines_pkg.SetAcctLineType
107979 (p_component_type => l_component_type
107980 ,p_event_type_code => l_event_type_code
107981 ,p_line_definition_owner_code => l_line_definition_owner_code
107982 ,p_line_definition_code => l_line_definition_code
107983 ,p_accounting_line_code => l_component_code
107984 ,p_accounting_line_type_code => l_component_type_code
107985 ,p_accounting_line_appl_id => l_component_appl_id
107986 ,p_amb_context_code => l_amb_context_code
107987 ,p_entity_code => l_entity_code
107988 ,p_event_class_code => l_event_class_code);
107989 --
107990 -- set accounting class
107991 --
107992 xla_ae_lines_pkg.SetAcctClass(
107993 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
107994 , p_ae_header_id => l_ae_header_id
107995 );
107996
107997 --
107998 -- set rounding class
107999 --
108000 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
108001 'INTERORG_TRANSFER_CREDIT';
108002
108003 --
108004 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
108005 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
108006 --
108007 -- bulk performance
108008 --
108009 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
108010
108011 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
108012 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
108013
108014 -- 4955764
108015 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
108016 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
108017
108018 -- 4458381 Public Sector Enh
108019
108020 --
108021 -- set accounting attributes for the line type
108022 --
108023 l_entered_amt_idx := 3;
108024 l_accted_amt_idx := 8;
108025 l_bflow_applied_to_amt_idx := NULL; -- 5132302
108026 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
108027 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
108028 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
108029 l_rec_acct_attrs.array_char_value(2) := p_source_85;
108030 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
108031 l_rec_acct_attrs.array_num_value(3) := p_source_91;
108032 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
108033 l_rec_acct_attrs.array_char_value(4) := p_source_88;
108034 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
108035 l_rec_acct_attrs.array_date_value(5) := p_source_92;
108036 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
108037 l_rec_acct_attrs.array_num_value(6) := p_source_93;
108038 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
108039 l_rec_acct_attrs.array_char_value(7) := p_source_94;
108040 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
108041 l_rec_acct_attrs.array_num_value(8) := p_source_95;
108042
108043 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
108044 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
108045
108046 ---------------------------------------------------------------------------------------------------------------
108047 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
108048 ---------------------------------------------------------------------------------------------------------------
108049 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
108050
108051 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
108052 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
108053
108054 IF xla_accounting_cache_pkg.GetValueChar
108055 (p_source_code => 'LEDGER_CATEGORY_CODE'
108056 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
108057 AND l_bflow_method_code = 'PRIOR_ENTRY'
108058 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
108059 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
108060 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
108061 )
108062 THEN
108063 xla_ae_lines_pkg.BflowUpgEntry
108064 (p_business_method_code => l_bflow_method_code
108065 ,p_business_class_code => l_bflow_class_code
108066 ,p_balance_type => l_balance_type_code);
108067 ELSE
108068 NULL;
108069 -- No business flow processing for business flow method of NONE.
108070 END IF;
108071
108072 --
108073 -- call analytical criteria
108074 --
108075
108076 --
108077 -- call description
108078 --
108079
108080 xla_ae_lines_pkg.SetLineDescription(
108081 p_ae_header_id => l_ae_header_id
108082 ,p_description => Description_1 (
108083 p_application_id => p_application_id
108084 , p_ae_header_id => l_ae_header_id
108085 , p_source_1 => p_source_1
108086 , p_source_2 => p_source_2
108087 , p_source_3 => p_source_3
108088 , p_source_4 => p_source_4
108089 , p_source_5 => p_source_5
108090 )
108091 );
108092
108093
108094 --
108095 -- call ADRs
108096 -- Bug 4922099
108097 --
108098 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
108099 (NVL(l_actual_upg_option, 'N') = 'O') OR
108100 (NVL(l_enc_upg_option, 'N') = 'O')
108101 )
108102 THEN
108103 NULL;
108104 --
108105 --
108106
108107 l_ccid := AcctDerRule_24(
108108 p_application_id => p_application_id
108109 , p_ae_header_id => l_ae_header_id
108110 , p_source_40 => p_source_40
108111 , x_transaction_coa_id => l_adr_transaction_coa_id
108112 , x_accounting_coa_id => l_adr_accounting_coa_id
108113 , x_value_type_code => l_adr_value_type_code
108114 , p_side => 'NA'
108115 );
108116
108117 xla_ae_lines_pkg.set_ccid(
108118 p_code_combination_id => l_ccid
108119 , p_value_type_code => l_adr_value_type_code
108120 , p_transaction_coa_id => l_adr_transaction_coa_id
108121 , p_accounting_coa_id => l_adr_accounting_coa_id
108122 , p_adr_code => 'PI_INTERORG_TRANSFER'
108123 , p_adr_type_code => 'S'
108124 , p_component_type => l_component_type
108125 , p_component_code => l_component_code
108126 , p_component_type_code => l_component_type_code
108127 , p_component_appl_id => l_component_appl_id
108128 , p_amb_context_code => l_amb_context_code
108129 , p_side => 'NA'
108130 );
108131
108132
108133 --
108134 --
108135 END IF;
108136 --
108137 -- Bug 4922099
108138 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
108139 (NVL(l_enc_upg_option, 'N') = 'O')
108140 ) AND
108141 (l_bflow_method_code = 'PRIOR_ENTRY')
108142 )
108143 THEN
108144 IF
108145 --
108146 1 = 2
108147 --
108148 THEN
108149 xla_accounting_err_pkg.build_message
108150 (p_appli_s_name => 'XLA'
108151 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
108152 ,p_token_1 => 'LINE_NUMBER'
108153 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
108154 ,p_token_2 => 'LINE_TYPE_NAME'
108155 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
108156 l_component_type
108157 ,l_component_code
108158 ,l_component_type_code
108159 ,l_component_appl_id
108160 ,l_amb_context_code
108161 ,l_entity_code
108162 ,l_event_class_code
108163 )
108164 ,p_token_3 => 'OWNER'
108165 ,p_value_3 => xla_lookups_pkg.get_meaning(
108166 p_lookup_type => 'XLA_OWNER_TYPE'
108167 ,p_lookup_code => l_component_type_code
108168 )
108169 ,p_token_4 => 'PRODUCT_NAME'
108170 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
108171 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
108172 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
108173 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
108174 ,p_ae_header_id => NULL
108175 );
108176
108177 IF (C_LEVEL_ERROR>= g_log_level) THEN
108178 trace
108179 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
108180 ,p_level => C_LEVEL_ERROR
108181 ,p_module => l_log_module);
108182 END IF;
108183 END IF;
108184 END IF;
108185 --
108186 --
108187 ------------------------------------------------------------------------------------------------
108188 -- 4219869 Business Flow
108189 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
108190 -- Prior Entry. Currently, the following code is always generated.
108191 ------------------------------------------------------------------------------------------------
108192 XLA_AE_LINES_PKG.ValidateCurrentLine;
108193
108194 ------------------------------------------------------------------------------------
108195 -- 4219869 Business Flow
108196 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
108197 ------------------------------------------------------------------------------------
108198 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
108199
108200 ----------------------------------------------------------------------------------
108201 -- 4219869 Business Flow
108202 -- Update journal entry status -- Need to generate this within IF <condition>
108203 ----------------------------------------------------------------------------------
108204 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
108205 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
108206 ,p_balance_type_code => l_balance_type_code
108207 );
108208
108209 -------------------------------------------------------------------------------------------
108210 -- 4262811 - Generate the Accrual Reversal lines
108211 -------------------------------------------------------------------------------------------
108212 BEGIN
108213 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
108214 (g_array_event(p_event_id).array_value_num('header_index'));
108215 IF l_acc_rev_flag IS NULL THEN
108216 l_acc_rev_flag := 'N';
108217 END IF;
108218 EXCEPTION
108219 WHEN OTHERS THEN
108220 l_acc_rev_flag := 'N';
108221 END;
108222 --
108223 IF (l_acc_rev_flag = 'Y') THEN
108224
108225 -- 4645092 ------------------------------------------------------------------------------
108226 -- To allow MPA report to determine if it should generate report process
108227 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
108228 ------------------------------------------------------------------------------------------
108229
108230 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
108231 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
108232 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
108233 -- call ADRs
108234 -- Bug 4922099
108235 --
108236 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
108237 (NVL(l_actual_upg_option, 'N') = 'O') OR
108238 (NVL(l_enc_upg_option, 'N') = 'O')
108239 )
108240 THEN
108241 NULL;
108242 --
108243 --
108244
108245 l_ccid := AcctDerRule_24(
108246 p_application_id => p_application_id
108247 , p_ae_header_id => l_ae_header_id
108248 , p_source_40 => p_source_40
108249 , x_transaction_coa_id => l_adr_transaction_coa_id
108250 , x_accounting_coa_id => l_adr_accounting_coa_id
108251 , x_value_type_code => l_adr_value_type_code
108252 , p_side => 'NA'
108253 );
108254
108255 xla_ae_lines_pkg.set_ccid(
108256 p_code_combination_id => l_ccid
108257 , p_value_type_code => l_adr_value_type_code
108258 , p_transaction_coa_id => l_adr_transaction_coa_id
108259 , p_accounting_coa_id => l_adr_accounting_coa_id
108260 , p_adr_code => 'PI_INTERORG_TRANSFER'
108261 , p_adr_type_code => 'S'
108262 , p_component_type => l_component_type
108263 , p_component_code => l_component_code
108264 , p_component_type_code => l_component_type_code
108265 , p_component_appl_id => l_component_appl_id
108266 , p_amb_context_code => l_amb_context_code
108267 , p_side => 'NA'
108268 );
108269
108270
108271 --
108272 --
108273 END IF;
108274
108275 --
108276 -- Update the line information that should be overwritten
108277 --
108278 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
108279 p_header_num => 1);
108280 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
108281
108282 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
108283
108284 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
108285 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
108286 END IF;
108287
108288 --
108289 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
108290 --
108291 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
108292 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
108293 ELSE
108294 ---------------------------------------------------------------------------------------------------
108295 -- 4262811a Switch Sign
108296 ---------------------------------------------------------------------------------------------------
108297 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
108298 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
108299 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108300 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
108301 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108302 -- 5132302
108303 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
108304 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108305
108306 END IF;
108307
108308 -- 4955764
108309 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
108310 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
108311
108312
108313 XLA_AE_LINES_PKG.ValidateCurrentLine;
108314 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
108315
108316 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
108317 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
108318 ,p_balance_type_code => l_balance_type_code);
108319
108320 END IF;
108321
108322 -----------------------------------------------------------------------------------------
108323 -- 4262811 Multiperiod Accounting
108324 -----------------------------------------------------------------------------------------
108325 -- No MPA option is assigned.
108326
108327
108328 END IF;
108329 END IF;
108330 --
108331
108332 --
108333 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
108334 trace
108335 (p_msg => 'END of AcctLineType_213'
108336 ,p_level => C_LEVEL_PROCEDURE
108337 ,p_module => l_log_module);
108338 END IF;
108339 --
108340 EXCEPTION
108341 WHEN xla_exceptions_pkg.application_exception THEN
108342 RAISE;
108343 WHEN OTHERS THEN
108344 xla_exceptions_pkg.raise_message
108345 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_213');
108346 END AcctLineType_213;
108347 --
108348
108349 ---------------------------------------
108350 --
108351 -- PRIVATE FUNCTION
108352 -- AcctLineType_214
108353 --
108354 ---------------------------------------
108355 PROCEDURE AcctLineType_214 (
108356 p_application_id IN NUMBER
108357 ,p_event_id IN NUMBER
108358 ,p_calculate_acctd_flag IN VARCHAR2
108359 ,p_calculate_g_l_flag IN VARCHAR2
108360 ,p_actual_flag IN OUT VARCHAR2
108361 ,p_balance_type_code OUT VARCHAR2
108362 ,p_gain_or_loss_ref OUT VARCHAR2
108363
108364 --TRANSACTION_ID
108365 , p_source_1 IN NUMBER
108366 --Item Concatenated Segments
108367 , p_source_2 IN VARCHAR2
108368 --Transaction Quantity
108369 , p_source_3 IN NUMBER
108370 --Transaction Unit of Measure Code
108371 , p_source_4 IN VARCHAR2
108372 --Inventory Transaction Type Description
108373 , p_source_5 IN VARCHAR2
108374 --Interorg Transfer Credit Account
108375 , p_source_40 IN NUMBER
108376 --DISTRIBUTION_IDENTIFIER
108377 , p_source_84 IN NUMBER
108378 --Distribution Type
108379 , p_source_85 IN VARCHAR2
108380 , p_source_85_meaning IN VARCHAR2
108381 --Entered Currency Code
108382 , p_source_88 IN VARCHAR2
108383 --Entered Amount
108384 , p_source_91 IN NUMBER
108385 --Currency Conversion Date
108386 , p_source_92 IN DATE
108387 --Currency Conversion Rate
108388 , p_source_93 IN NUMBER
108389 --Currency Conversion Type
108390 , p_source_94 IN VARCHAR2
108391 --Accounted Amount
108392 , p_source_95 IN NUMBER
108393 --Accounting Line Type
108394 , p_source_97 IN NUMBER
108395 )
108396 IS
108397
108398 l_component_type VARCHAR2(80);
108399 l_component_code VARCHAR2(30);
108400 l_component_type_code VARCHAR2(1);
108401 l_component_appl_id INTEGER;
108402 l_amb_context_code VARCHAR2(30);
108403 l_entity_code VARCHAR2(30);
108404 l_event_class_code VARCHAR2(30);
108405 l_ae_header_id NUMBER;
108406 l_event_type_code VARCHAR2(30);
108407 l_line_definition_code VARCHAR2(30);
108408 l_line_definition_owner_code VARCHAR2(1);
108409 --
108410 -- adr variables
108411 l_segment VARCHAR2(30);
108412 l_ccid NUMBER;
108413 l_adr_transaction_coa_id NUMBER;
108414 l_adr_accounting_coa_id NUMBER;
108415 l_adr_flexfield_segment_code VARCHAR2(30);
108416 l_adr_flex_value_set_id NUMBER;
108417 l_adr_value_type_code VARCHAR2(30);
108418 l_adr_value_combination_id NUMBER;
108419 l_adr_value_segment_code VARCHAR2(30);
108420
108421 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
108422 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
108423 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
108424 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
108425
108426 -- 4262811 Variables ------------------------------------------------------------------------------------------
108427 l_entered_amt_idx NUMBER;
108428 l_accted_amt_idx NUMBER;
108429 l_acc_rev_flag VARCHAR2(1);
108430 l_accrual_line_num NUMBER;
108431 l_tmp_amt NUMBER;
108432 l_acc_rev_natural_side_code VARCHAR2(1);
108433
108434 l_num_entries NUMBER;
108435 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
108436 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
108437 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
108438 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
108439 l_recog_line_1 NUMBER;
108440 l_recog_line_2 NUMBER;
108441
108442 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
108443 l_bflow_applied_to_amt NUMBER; -- 5132302
108444 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
108445
108446 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
108447
108448 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
108449 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
108450
108451 ---------------------------------------------------------------------------------------------------------------
108452
108453
108454 --
108455 -- bulk performance
108456 --
108457 l_balance_type_code VARCHAR2(1);
108458 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
108459 l_log_module VARCHAR2(240);
108460
108461 --
108462 -- Upgrade strategy
108463 --
108464 l_actual_upg_option VARCHAR2(1);
108465 l_enc_upg_option VARCHAR2(1);
108466
108467 --
108468 BEGIN
108469 --
108470 IF g_log_enabled THEN
108471 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_214';
108472 END IF;
108473 --
108474 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
108475
108476 trace
108477 (p_msg => 'BEGIN of AcctLineType_214'
108478 ,p_level => C_LEVEL_PROCEDURE
108479 ,p_module => l_log_module);
108480
108481 END IF;
108482 --
108483 l_component_type := 'AMB_JLT';
108484 l_component_code := 'INTERORG_TRANSFER_CREDIT';
108485 l_component_type_code := 'S';
108486 l_component_appl_id := 707;
108487 l_amb_context_code := 'DEFAULT';
108488 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
108489 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
108490 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
108491 l_line_definition_owner_code := 'S';
108492 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
108493 --
108494 l_balance_type_code := 'A';
108495 l_segment := NULL;
108496 l_ccid := NULL;
108497 l_adr_transaction_coa_id := NULL;
108498 l_adr_accounting_coa_id := NULL;
108499 l_adr_flexfield_segment_code := NULL;
108500 l_adr_flex_value_set_id := NULL;
108501 l_adr_value_type_code := NULL;
108502 l_adr_value_combination_id := NULL;
108503 l_adr_value_segment_code := NULL;
108504
108505 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
108506 l_bflow_class_code := ''; -- 4219869 Business Flow
108507 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
108508 l_budgetary_control_flag := 'N';
108509
108510 l_bflow_applied_to_amt_idx := NULL; -- 5132302
108511 l_bflow_applied_to_amt := NULL; -- 5132302
108512 l_entered_amt_idx := NULL; -- 4262811
108513 l_accted_amt_idx := NULL; -- 4262811
108514 l_acc_rev_flag := NULL; -- 4262811
108515 l_accrual_line_num := NULL; -- 4262811
108516 l_tmp_amt := NULL; -- 4262811
108517 --
108518
108519 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
108520 l_balance_type_code <> 'B' THEN
108521 IF NVL(p_source_97,9E125) = 11
108522 THEN
108523
108524 --
108525 XLA_AE_LINES_PKG.SetNewLine;
108526
108527 p_balance_type_code := l_balance_type_code;
108528 -- set the flag so later we will know whether the gain loss line needs to be created
108529
108530 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
108531 p_actual_flag :='A';
108532 END IF;
108533
108534 --
108535 -- bulk performance
108536 --
108537 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
108538 p_header_num => 0); -- 4262811
108539 --
108540 -- set accounting line options
108541 --
108542 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
108543 p_natural_side_code => 'D'
108544 , p_gain_or_loss_flag => 'N'
108545 , p_gl_transfer_mode_code => 'S'
108546 , p_acct_entry_type_code => 'A'
108547 , p_switch_side_flag => 'Y'
108548 , p_merge_duplicate_code => 'N'
108549 );
108550 --
108551 l_acc_rev_natural_side_code := 'C'; -- 4262811
108552 --
108553 --
108554 -- set accounting line type info
108555 --
108556 xla_ae_lines_pkg.SetAcctLineType
108557 (p_component_type => l_component_type
108558 ,p_event_type_code => l_event_type_code
108559 ,p_line_definition_owner_code => l_line_definition_owner_code
108560 ,p_line_definition_code => l_line_definition_code
108561 ,p_accounting_line_code => l_component_code
108562 ,p_accounting_line_type_code => l_component_type_code
108563 ,p_accounting_line_appl_id => l_component_appl_id
108564 ,p_amb_context_code => l_amb_context_code
108565 ,p_entity_code => l_entity_code
108566 ,p_event_class_code => l_event_class_code);
108567 --
108568 -- set accounting class
108569 --
108570 xla_ae_lines_pkg.SetAcctClass(
108571 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
108572 , p_ae_header_id => l_ae_header_id
108573 );
108574
108575 --
108576 -- set rounding class
108577 --
108578 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
108579 'INTERORG_TRANSFER_CREDIT';
108580
108581 --
108582 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
108583 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
108584 --
108585 -- bulk performance
108586 --
108587 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
108588
108589 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
108590 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
108591
108592 -- 4955764
108593 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
108594 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
108595
108596 -- 4458381 Public Sector Enh
108597
108598 --
108599 -- set accounting attributes for the line type
108600 --
108601 l_entered_amt_idx := 3;
108602 l_accted_amt_idx := 8;
108603 l_bflow_applied_to_amt_idx := NULL; -- 5132302
108604 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
108605 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
108606 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
108607 l_rec_acct_attrs.array_char_value(2) := p_source_85;
108608 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
108609 l_rec_acct_attrs.array_num_value(3) := p_source_91;
108610 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
108611 l_rec_acct_attrs.array_char_value(4) := p_source_88;
108612 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
108613 l_rec_acct_attrs.array_date_value(5) := p_source_92;
108614 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
108615 l_rec_acct_attrs.array_num_value(6) := p_source_93;
108616 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
108617 l_rec_acct_attrs.array_char_value(7) := p_source_94;
108618 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
108619 l_rec_acct_attrs.array_num_value(8) := p_source_95;
108620
108621 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
108622 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
108623
108624 ---------------------------------------------------------------------------------------------------------------
108625 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
108626 ---------------------------------------------------------------------------------------------------------------
108627 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
108628
108629 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
108630 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
108631
108632 IF xla_accounting_cache_pkg.GetValueChar
108633 (p_source_code => 'LEDGER_CATEGORY_CODE'
108634 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
108635 AND l_bflow_method_code = 'PRIOR_ENTRY'
108636 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
108637 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
108638 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
108639 )
108640 THEN
108641 xla_ae_lines_pkg.BflowUpgEntry
108642 (p_business_method_code => l_bflow_method_code
108643 ,p_business_class_code => l_bflow_class_code
108644 ,p_balance_type => l_balance_type_code);
108645 ELSE
108646 NULL;
108647 -- No business flow processing for business flow method of NONE.
108648 END IF;
108649
108650 --
108651 -- call analytical criteria
108652 --
108653
108654 --
108655 -- call description
108656 --
108657
108658 xla_ae_lines_pkg.SetLineDescription(
108659 p_ae_header_id => l_ae_header_id
108660 ,p_description => Description_1 (
108661 p_application_id => p_application_id
108662 , p_ae_header_id => l_ae_header_id
108663 , p_source_1 => p_source_1
108664 , p_source_2 => p_source_2
108665 , p_source_3 => p_source_3
108666 , p_source_4 => p_source_4
108667 , p_source_5 => p_source_5
108668 )
108669 );
108670
108671
108672 --
108673 -- call ADRs
108674 -- Bug 4922099
108675 --
108676 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
108677 (NVL(l_actual_upg_option, 'N') = 'O') OR
108678 (NVL(l_enc_upg_option, 'N') = 'O')
108679 )
108680 THEN
108681 NULL;
108682 --
108683 --
108684
108685 l_ccid := AcctDerRule_24(
108686 p_application_id => p_application_id
108687 , p_ae_header_id => l_ae_header_id
108688 , p_source_40 => p_source_40
108689 , x_transaction_coa_id => l_adr_transaction_coa_id
108690 , x_accounting_coa_id => l_adr_accounting_coa_id
108691 , x_value_type_code => l_adr_value_type_code
108692 , p_side => 'NA'
108693 );
108694
108695 xla_ae_lines_pkg.set_ccid(
108696 p_code_combination_id => l_ccid
108697 , p_value_type_code => l_adr_value_type_code
108698 , p_transaction_coa_id => l_adr_transaction_coa_id
108699 , p_accounting_coa_id => l_adr_accounting_coa_id
108700 , p_adr_code => 'PI_INTERORG_TRANSFER'
108701 , p_adr_type_code => 'S'
108702 , p_component_type => l_component_type
108703 , p_component_code => l_component_code
108704 , p_component_type_code => l_component_type_code
108705 , p_component_appl_id => l_component_appl_id
108706 , p_amb_context_code => l_amb_context_code
108707 , p_side => 'NA'
108708 );
108709
108710
108711 --
108712 --
108713 END IF;
108714 --
108715 -- Bug 4922099
108716 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
108717 (NVL(l_enc_upg_option, 'N') = 'O')
108718 ) AND
108719 (l_bflow_method_code = 'PRIOR_ENTRY')
108720 )
108721 THEN
108722 IF
108723 --
108724 1 = 2
108725 --
108726 THEN
108727 xla_accounting_err_pkg.build_message
108728 (p_appli_s_name => 'XLA'
108729 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
108730 ,p_token_1 => 'LINE_NUMBER'
108731 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
108732 ,p_token_2 => 'LINE_TYPE_NAME'
108733 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
108734 l_component_type
108735 ,l_component_code
108736 ,l_component_type_code
108737 ,l_component_appl_id
108738 ,l_amb_context_code
108739 ,l_entity_code
108740 ,l_event_class_code
108741 )
108742 ,p_token_3 => 'OWNER'
108743 ,p_value_3 => xla_lookups_pkg.get_meaning(
108744 p_lookup_type => 'XLA_OWNER_TYPE'
108745 ,p_lookup_code => l_component_type_code
108746 )
108747 ,p_token_4 => 'PRODUCT_NAME'
108748 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
108749 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
108750 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
108751 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
108752 ,p_ae_header_id => NULL
108753 );
108754
108755 IF (C_LEVEL_ERROR>= g_log_level) THEN
108756 trace
108757 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
108758 ,p_level => C_LEVEL_ERROR
108759 ,p_module => l_log_module);
108760 END IF;
108761 END IF;
108762 END IF;
108763 --
108764 --
108765 ------------------------------------------------------------------------------------------------
108766 -- 4219869 Business Flow
108767 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
108768 -- Prior Entry. Currently, the following code is always generated.
108769 ------------------------------------------------------------------------------------------------
108770 XLA_AE_LINES_PKG.ValidateCurrentLine;
108771
108772 ------------------------------------------------------------------------------------
108773 -- 4219869 Business Flow
108774 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
108775 ------------------------------------------------------------------------------------
108776 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
108777
108778 ----------------------------------------------------------------------------------
108779 -- 4219869 Business Flow
108780 -- Update journal entry status -- Need to generate this within IF <condition>
108781 ----------------------------------------------------------------------------------
108782 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
108783 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
108784 ,p_balance_type_code => l_balance_type_code
108785 );
108786
108787 -------------------------------------------------------------------------------------------
108788 -- 4262811 - Generate the Accrual Reversal lines
108789 -------------------------------------------------------------------------------------------
108790 BEGIN
108791 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
108792 (g_array_event(p_event_id).array_value_num('header_index'));
108793 IF l_acc_rev_flag IS NULL THEN
108794 l_acc_rev_flag := 'N';
108795 END IF;
108796 EXCEPTION
108797 WHEN OTHERS THEN
108798 l_acc_rev_flag := 'N';
108799 END;
108800 --
108801 IF (l_acc_rev_flag = 'Y') THEN
108802
108803 -- 4645092 ------------------------------------------------------------------------------
108804 -- To allow MPA report to determine if it should generate report process
108805 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
108806 ------------------------------------------------------------------------------------------
108807
108808 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
108809 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
108810 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
108811 -- call ADRs
108812 -- Bug 4922099
108813 --
108814 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
108815 (NVL(l_actual_upg_option, 'N') = 'O') OR
108816 (NVL(l_enc_upg_option, 'N') = 'O')
108817 )
108818 THEN
108819 NULL;
108820 --
108821 --
108822
108823 l_ccid := AcctDerRule_24(
108824 p_application_id => p_application_id
108825 , p_ae_header_id => l_ae_header_id
108826 , p_source_40 => p_source_40
108827 , x_transaction_coa_id => l_adr_transaction_coa_id
108828 , x_accounting_coa_id => l_adr_accounting_coa_id
108829 , x_value_type_code => l_adr_value_type_code
108830 , p_side => 'NA'
108831 );
108832
108833 xla_ae_lines_pkg.set_ccid(
108834 p_code_combination_id => l_ccid
108835 , p_value_type_code => l_adr_value_type_code
108836 , p_transaction_coa_id => l_adr_transaction_coa_id
108837 , p_accounting_coa_id => l_adr_accounting_coa_id
108838 , p_adr_code => 'PI_INTERORG_TRANSFER'
108839 , p_adr_type_code => 'S'
108840 , p_component_type => l_component_type
108841 , p_component_code => l_component_code
108842 , p_component_type_code => l_component_type_code
108843 , p_component_appl_id => l_component_appl_id
108844 , p_amb_context_code => l_amb_context_code
108845 , p_side => 'NA'
108846 );
108847
108848
108849 --
108850 --
108851 END IF;
108852
108853 --
108854 -- Update the line information that should be overwritten
108855 --
108856 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
108857 p_header_num => 1);
108858 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
108859
108860 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
108861
108862 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
108863 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
108864 END IF;
108865
108866 --
108867 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
108868 --
108869 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
108870 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
108871 ELSE
108872 ---------------------------------------------------------------------------------------------------
108873 -- 4262811a Switch Sign
108874 ---------------------------------------------------------------------------------------------------
108875 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
108876 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
108877 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108878 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
108879 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108880 -- 5132302
108881 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
108882 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
108883
108884 END IF;
108885
108886 -- 4955764
108887 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
108888 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
108889
108890
108891 XLA_AE_LINES_PKG.ValidateCurrentLine;
108892 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
108893
108894 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
108895 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
108896 ,p_balance_type_code => l_balance_type_code);
108897
108898 END IF;
108899
108900 -----------------------------------------------------------------------------------------
108901 -- 4262811 Multiperiod Accounting
108902 -----------------------------------------------------------------------------------------
108903 -- No MPA option is assigned.
108904
108905
108906 END IF;
108907 END IF;
108908 --
108909
108910 --
108911 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
108912 trace
108913 (p_msg => 'END of AcctLineType_214'
108914 ,p_level => C_LEVEL_PROCEDURE
108915 ,p_module => l_log_module);
108916 END IF;
108917 --
108918 EXCEPTION
108919 WHEN xla_exceptions_pkg.application_exception THEN
108920 RAISE;
108921 WHEN OTHERS THEN
108922 xla_exceptions_pkg.raise_message
108923 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_214');
108924 END AcctLineType_214;
108925 --
108926
108927 ---------------------------------------
108928 --
108929 -- PRIVATE FUNCTION
108930 -- AcctLineType_215
108931 --
108932 ---------------------------------------
108933 PROCEDURE AcctLineType_215 (
108934 p_application_id IN NUMBER
108935 ,p_event_id IN NUMBER
108936 ,p_calculate_acctd_flag IN VARCHAR2
108937 ,p_calculate_g_l_flag IN VARCHAR2
108938 ,p_actual_flag IN OUT VARCHAR2
108939 ,p_balance_type_code OUT VARCHAR2
108940 ,p_gain_or_loss_ref OUT VARCHAR2
108941
108942 --Cost Management Default Account
108943 , p_source_11 IN NUMBER
108944 --DISTRIBUTION_IDENTIFIER
108945 , p_source_84 IN NUMBER
108946 --Distribution Type
108947 , p_source_85 IN VARCHAR2
108948 , p_source_85_meaning IN VARCHAR2
108949 --Entered Currency Code
108950 , p_source_88 IN VARCHAR2
108951 --Entered Amount
108952 , p_source_91 IN NUMBER
108953 --Currency Conversion Date
108954 , p_source_92 IN DATE
108955 --Currency Conversion Rate
108956 , p_source_93 IN NUMBER
108957 --Currency Conversion Type
108958 , p_source_94 IN VARCHAR2
108959 --Accounted Amount
108960 , p_source_95 IN NUMBER
108961 --Accounting Line Type
108962 , p_source_97 IN NUMBER
108963 )
108964 IS
108965
108966 l_component_type VARCHAR2(80);
108967 l_component_code VARCHAR2(30);
108968 l_component_type_code VARCHAR2(1);
108969 l_component_appl_id INTEGER;
108970 l_amb_context_code VARCHAR2(30);
108971 l_entity_code VARCHAR2(30);
108972 l_event_class_code VARCHAR2(30);
108973 l_ae_header_id NUMBER;
108974 l_event_type_code VARCHAR2(30);
108975 l_line_definition_code VARCHAR2(30);
108976 l_line_definition_owner_code VARCHAR2(1);
108977 --
108978 -- adr variables
108979 l_segment VARCHAR2(30);
108980 l_ccid NUMBER;
108981 l_adr_transaction_coa_id NUMBER;
108982 l_adr_accounting_coa_id NUMBER;
108983 l_adr_flexfield_segment_code VARCHAR2(30);
108984 l_adr_flex_value_set_id NUMBER;
108985 l_adr_value_type_code VARCHAR2(30);
108986 l_adr_value_combination_id NUMBER;
108987 l_adr_value_segment_code VARCHAR2(30);
108988
108989 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
108990 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
108991 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
108992 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
108993
108994 -- 4262811 Variables ------------------------------------------------------------------------------------------
108995 l_entered_amt_idx NUMBER;
108996 l_accted_amt_idx NUMBER;
108997 l_acc_rev_flag VARCHAR2(1);
108998 l_accrual_line_num NUMBER;
108999 l_tmp_amt NUMBER;
109000 l_acc_rev_natural_side_code VARCHAR2(1);
109001
109002 l_num_entries NUMBER;
109003 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
109004 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
109005 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
109006 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
109007 l_recog_line_1 NUMBER;
109008 l_recog_line_2 NUMBER;
109009
109010 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
109011 l_bflow_applied_to_amt NUMBER; -- 5132302
109012 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
109013
109014 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
109015
109016 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
109017 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
109018
109019 ---------------------------------------------------------------------------------------------------------------
109020
109021
109022 --
109023 -- bulk performance
109024 --
109025 l_balance_type_code VARCHAR2(1);
109026 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
109027 l_log_module VARCHAR2(240);
109028
109029 --
109030 -- Upgrade strategy
109031 --
109032 l_actual_upg_option VARCHAR2(1);
109033 l_enc_upg_option VARCHAR2(1);
109034
109035 --
109036 BEGIN
109037 --
109038 IF g_log_enabled THEN
109039 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_215';
109040 END IF;
109041 --
109042 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
109043
109044 trace
109045 (p_msg => 'BEGIN of AcctLineType_215'
109046 ,p_level => C_LEVEL_PROCEDURE
109047 ,p_module => l_log_module);
109048
109049 END IF;
109050 --
109051 l_component_type := 'AMB_JLT';
109052 l_component_code := 'INTERORG_TRANSFER_CREDIT';
109053 l_component_type_code := 'S';
109054 l_component_appl_id := 707;
109055 l_amb_context_code := 'DEFAULT';
109056 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
109057 l_event_class_code := 'USER_DEFINE';
109058 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
109059 l_line_definition_owner_code := 'S';
109060 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
109061 --
109062 l_balance_type_code := 'A';
109063 l_segment := NULL;
109064 l_ccid := NULL;
109065 l_adr_transaction_coa_id := NULL;
109066 l_adr_accounting_coa_id := NULL;
109067 l_adr_flexfield_segment_code := NULL;
109068 l_adr_flex_value_set_id := NULL;
109069 l_adr_value_type_code := NULL;
109070 l_adr_value_combination_id := NULL;
109071 l_adr_value_segment_code := NULL;
109072
109073 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
109074 l_bflow_class_code := ''; -- 4219869 Business Flow
109075 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
109076 l_budgetary_control_flag := 'N';
109077
109078 l_bflow_applied_to_amt_idx := NULL; -- 5132302
109079 l_bflow_applied_to_amt := NULL; -- 5132302
109080 l_entered_amt_idx := NULL; -- 4262811
109081 l_accted_amt_idx := NULL; -- 4262811
109082 l_acc_rev_flag := NULL; -- 4262811
109083 l_accrual_line_num := NULL; -- 4262811
109084 l_tmp_amt := NULL; -- 4262811
109085 --
109086
109087 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
109088 l_balance_type_code <> 'B' THEN
109089 IF NVL(p_source_97,9E125) = 11
109090 THEN
109091
109092 --
109093 XLA_AE_LINES_PKG.SetNewLine;
109094
109095 p_balance_type_code := l_balance_type_code;
109096 -- set the flag so later we will know whether the gain loss line needs to be created
109097
109098 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
109099 p_actual_flag :='A';
109100 END IF;
109101
109102 --
109103 -- bulk performance
109104 --
109105 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
109106 p_header_num => 0); -- 4262811
109107 --
109108 -- set accounting line options
109109 --
109110 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
109111 p_natural_side_code => 'D'
109112 , p_gain_or_loss_flag => 'N'
109113 , p_gl_transfer_mode_code => 'S'
109114 , p_acct_entry_type_code => 'A'
109115 , p_switch_side_flag => 'Y'
109116 , p_merge_duplicate_code => 'N'
109117 );
109118 --
109119 l_acc_rev_natural_side_code := 'C'; -- 4262811
109120 --
109121 --
109122 -- set accounting line type info
109123 --
109124 xla_ae_lines_pkg.SetAcctLineType
109125 (p_component_type => l_component_type
109126 ,p_event_type_code => l_event_type_code
109127 ,p_line_definition_owner_code => l_line_definition_owner_code
109128 ,p_line_definition_code => l_line_definition_code
109129 ,p_accounting_line_code => l_component_code
109130 ,p_accounting_line_type_code => l_component_type_code
109131 ,p_accounting_line_appl_id => l_component_appl_id
109132 ,p_amb_context_code => l_amb_context_code
109133 ,p_entity_code => l_entity_code
109134 ,p_event_class_code => l_event_class_code);
109135 --
109136 -- set accounting class
109137 --
109138 xla_ae_lines_pkg.SetAcctClass(
109139 p_accounting_class_code => 'INTERORG_TRANSFER_CREDIT'
109140 , p_ae_header_id => l_ae_header_id
109141 );
109142
109143 --
109144 -- set rounding class
109145 --
109146 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
109147 'INTERORG_TRANSFER_CREDIT';
109148
109149 --
109150 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
109151 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
109152 --
109153 -- bulk performance
109154 --
109155 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
109156
109157 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
109158 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
109159
109160 -- 4955764
109161 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
109162 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
109163
109164 -- 4458381 Public Sector Enh
109165
109166 --
109167 -- set accounting attributes for the line type
109168 --
109169 l_entered_amt_idx := 3;
109170 l_accted_amt_idx := 8;
109171 l_bflow_applied_to_amt_idx := NULL; -- 5132302
109172 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
109173 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
109174 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
109175 l_rec_acct_attrs.array_char_value(2) := p_source_85;
109176 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
109177 l_rec_acct_attrs.array_num_value(3) := p_source_91;
109178 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
109179 l_rec_acct_attrs.array_char_value(4) := p_source_88;
109180 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
109181 l_rec_acct_attrs.array_date_value(5) := p_source_92;
109182 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
109183 l_rec_acct_attrs.array_num_value(6) := p_source_93;
109184 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
109185 l_rec_acct_attrs.array_char_value(7) := p_source_94;
109186 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
109187 l_rec_acct_attrs.array_num_value(8) := p_source_95;
109188
109189 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
109190 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
109191
109192 ---------------------------------------------------------------------------------------------------------------
109193 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
109194 ---------------------------------------------------------------------------------------------------------------
109195 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
109196
109197 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
109198 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
109199
109200 IF xla_accounting_cache_pkg.GetValueChar
109201 (p_source_code => 'LEDGER_CATEGORY_CODE'
109202 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
109203 AND l_bflow_method_code = 'PRIOR_ENTRY'
109204 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
109205 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
109206 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
109207 )
109208 THEN
109209 xla_ae_lines_pkg.BflowUpgEntry
109210 (p_business_method_code => l_bflow_method_code
109211 ,p_business_class_code => l_bflow_class_code
109212 ,p_balance_type => l_balance_type_code);
109213 ELSE
109214 NULL;
109215 -- No business flow processing for business flow method of NONE.
109216 END IF;
109217
109218 --
109219 -- call analytical criteria
109220 --
109221
109222 --
109223 -- call description
109224 --
109225 -- No description or it is inherited.
109226 --
109227 -- call ADRs
109228 -- Bug 4922099
109229 --
109230 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
109231 (NVL(l_actual_upg_option, 'N') = 'O') OR
109232 (NVL(l_enc_upg_option, 'N') = 'O')
109233 )
109234 THEN
109235 NULL;
109236 --
109237 --
109238
109239 l_ccid := AcctDerRule_6(
109240 p_application_id => p_application_id
109241 , p_ae_header_id => l_ae_header_id
109242 , p_source_11 => p_source_11
109243 , x_transaction_coa_id => l_adr_transaction_coa_id
109244 , x_accounting_coa_id => l_adr_accounting_coa_id
109245 , x_value_type_code => l_adr_value_type_code
109246 , p_side => 'NA'
109247 );
109248
109249 xla_ae_lines_pkg.set_ccid(
109250 p_code_combination_id => l_ccid
109251 , p_value_type_code => l_adr_value_type_code
109252 , p_transaction_coa_id => l_adr_transaction_coa_id
109253 , p_accounting_coa_id => l_adr_accounting_coa_id
109254 , p_adr_code => 'CST_DEFAULT'
109255 , p_adr_type_code => 'S'
109256 , p_component_type => l_component_type
109257 , p_component_code => l_component_code
109258 , p_component_type_code => l_component_type_code
109259 , p_component_appl_id => l_component_appl_id
109260 , p_amb_context_code => l_amb_context_code
109261 , p_side => 'NA'
109262 );
109263
109264
109265 --
109266 --
109267 END IF;
109268 --
109269 -- Bug 4922099
109270 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
109271 (NVL(l_enc_upg_option, 'N') = 'O')
109272 ) AND
109273 (l_bflow_method_code = 'PRIOR_ENTRY')
109274 )
109275 THEN
109276 IF
109277 --
109278 1 = 2
109279 --
109280 THEN
109281 xla_accounting_err_pkg.build_message
109282 (p_appli_s_name => 'XLA'
109283 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
109284 ,p_token_1 => 'LINE_NUMBER'
109285 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
109286 ,p_token_2 => 'LINE_TYPE_NAME'
109287 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
109288 l_component_type
109289 ,l_component_code
109290 ,l_component_type_code
109291 ,l_component_appl_id
109292 ,l_amb_context_code
109293 ,l_entity_code
109294 ,l_event_class_code
109295 )
109296 ,p_token_3 => 'OWNER'
109297 ,p_value_3 => xla_lookups_pkg.get_meaning(
109298 p_lookup_type => 'XLA_OWNER_TYPE'
109299 ,p_lookup_code => l_component_type_code
109300 )
109301 ,p_token_4 => 'PRODUCT_NAME'
109302 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
109303 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
109304 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
109305 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
109306 ,p_ae_header_id => NULL
109307 );
109308
109309 IF (C_LEVEL_ERROR>= g_log_level) THEN
109310 trace
109311 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
109312 ,p_level => C_LEVEL_ERROR
109313 ,p_module => l_log_module);
109314 END IF;
109315 END IF;
109316 END IF;
109317 --
109318 --
109319 ------------------------------------------------------------------------------------------------
109320 -- 4219869 Business Flow
109321 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
109322 -- Prior Entry. Currently, the following code is always generated.
109323 ------------------------------------------------------------------------------------------------
109324 XLA_AE_LINES_PKG.ValidateCurrentLine;
109325
109326 ------------------------------------------------------------------------------------
109327 -- 4219869 Business Flow
109328 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
109329 ------------------------------------------------------------------------------------
109330 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
109331
109332 ----------------------------------------------------------------------------------
109333 -- 4219869 Business Flow
109334 -- Update journal entry status -- Need to generate this within IF <condition>
109335 ----------------------------------------------------------------------------------
109336 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
109337 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
109338 ,p_balance_type_code => l_balance_type_code
109339 );
109340
109341 -------------------------------------------------------------------------------------------
109342 -- 4262811 - Generate the Accrual Reversal lines
109343 -------------------------------------------------------------------------------------------
109344 BEGIN
109345 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
109346 (g_array_event(p_event_id).array_value_num('header_index'));
109347 IF l_acc_rev_flag IS NULL THEN
109348 l_acc_rev_flag := 'N';
109349 END IF;
109350 EXCEPTION
109351 WHEN OTHERS THEN
109352 l_acc_rev_flag := 'N';
109353 END;
109354 --
109355 IF (l_acc_rev_flag = 'Y') THEN
109356
109357 -- 4645092 ------------------------------------------------------------------------------
109358 -- To allow MPA report to determine if it should generate report process
109359 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
109360 ------------------------------------------------------------------------------------------
109361
109362 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
109363 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
109364 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
109365 -- call ADRs
109366 -- Bug 4922099
109367 --
109368 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
109369 (NVL(l_actual_upg_option, 'N') = 'O') OR
109370 (NVL(l_enc_upg_option, 'N') = 'O')
109371 )
109372 THEN
109373 NULL;
109374 --
109375 --
109376
109377 l_ccid := AcctDerRule_6(
109378 p_application_id => p_application_id
109379 , p_ae_header_id => l_ae_header_id
109380 , p_source_11 => p_source_11
109381 , x_transaction_coa_id => l_adr_transaction_coa_id
109382 , x_accounting_coa_id => l_adr_accounting_coa_id
109383 , x_value_type_code => l_adr_value_type_code
109384 , p_side => 'NA'
109385 );
109386
109387 xla_ae_lines_pkg.set_ccid(
109388 p_code_combination_id => l_ccid
109389 , p_value_type_code => l_adr_value_type_code
109390 , p_transaction_coa_id => l_adr_transaction_coa_id
109391 , p_accounting_coa_id => l_adr_accounting_coa_id
109392 , p_adr_code => 'CST_DEFAULT'
109393 , p_adr_type_code => 'S'
109394 , p_component_type => l_component_type
109395 , p_component_code => l_component_code
109396 , p_component_type_code => l_component_type_code
109397 , p_component_appl_id => l_component_appl_id
109398 , p_amb_context_code => l_amb_context_code
109399 , p_side => 'NA'
109400 );
109401
109402
109403 --
109404 --
109405 END IF;
109406
109407 --
109408 -- Update the line information that should be overwritten
109409 --
109410 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
109411 p_header_num => 1);
109412 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
109413
109414 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
109415
109416 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
109417 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
109418 END IF;
109419
109420 --
109421 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
109422 --
109423 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
109424 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
109425 ELSE
109426 ---------------------------------------------------------------------------------------------------
109427 -- 4262811a Switch Sign
109428 ---------------------------------------------------------------------------------------------------
109429 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
109430 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
109431 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
109432 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
109433 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
109434 -- 5132302
109435 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
109436 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
109437
109438 END IF;
109439
109440 -- 4955764
109441 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
109442 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
109443
109444
109445 XLA_AE_LINES_PKG.ValidateCurrentLine;
109446 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
109447
109448 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
109449 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
109450 ,p_balance_type_code => l_balance_type_code);
109451
109452 END IF;
109453
109454 -----------------------------------------------------------------------------------------
109455 -- 4262811 Multiperiod Accounting
109456 -----------------------------------------------------------------------------------------
109457 -- No MPA option is assigned.
109458
109459
109460 END IF;
109461 END IF;
109462 --
109463
109464 --
109465 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
109466 trace
109467 (p_msg => 'END of AcctLineType_215'
109468 ,p_level => C_LEVEL_PROCEDURE
109469 ,p_module => l_log_module);
109470 END IF;
109471 --
109472 EXCEPTION
109473 WHEN xla_exceptions_pkg.application_exception THEN
109474 RAISE;
109475 WHEN OTHERS THEN
109476 xla_exceptions_pkg.raise_message
109477 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_215');
109478 END AcctLineType_215;
109479 --
109480
109481 ---------------------------------------
109482 --
109483 -- PRIVATE FUNCTION
109484 -- AcctLineType_216
109485 --
109486 ---------------------------------------
109487 PROCEDURE AcctLineType_216 (
109488 p_application_id IN NUMBER
109489 ,p_event_id IN NUMBER
109490 ,p_calculate_acctd_flag IN VARCHAR2
109491 ,p_calculate_g_l_flag IN VARCHAR2
109492 ,p_actual_flag IN OUT VARCHAR2
109493 ,p_balance_type_code OUT VARCHAR2
109494 ,p_gain_or_loss_ref OUT VARCHAR2
109495
109496 --TRANSACTION_ID
109497 , p_source_1 IN NUMBER
109498 --Item Concatenated Segments
109499 , p_source_2 IN VARCHAR2
109500 --Transaction Quantity
109501 , p_source_3 IN NUMBER
109502 --Transaction Unit of Measure Code
109503 , p_source_4 IN VARCHAR2
109504 --Inventory Transaction Type Description
109505 , p_source_5 IN VARCHAR2
109506 --Cost Management Default Account
109507 , p_source_11 IN NUMBER
109508 --Cost Element Name
109509 , p_source_15 IN NUMBER
109510 --Primary Cost Method
109511 , p_source_39 IN NUMBER
109512 , p_source_39_meaning IN VARCHAR2
109513 --Product Line Accounting Category Material Account
109514 , p_source_41 IN NUMBER
109515 --Product Line Accounting Category Material Overhead Account
109516 , p_source_42 IN NUMBER
109517 --Product Line Accounting Category Resource Account
109518 , p_source_43 IN NUMBER
109519 --Product Line Accounting Category Outside Processing Account
109520 , p_source_44 IN NUMBER
109521 --Product Line Accounting Category Overhead Account
109522 , p_source_45 IN NUMBER
109523 --DISTRIBUTION_IDENTIFIER
109524 , p_source_84 IN NUMBER
109525 --Distribution Type
109526 , p_source_85 IN VARCHAR2
109527 , p_source_85_meaning IN VARCHAR2
109528 --Entered Currency Code
109529 , p_source_88 IN VARCHAR2
109530 --Entered Amount
109531 , p_source_91 IN NUMBER
109532 --Currency Conversion Date
109533 , p_source_92 IN DATE
109534 --Currency Conversion Rate
109535 , p_source_93 IN NUMBER
109536 --Currency Conversion Type
109537 , p_source_94 IN VARCHAR2
109538 --Accounted Amount
109539 , p_source_95 IN NUMBER
109540 --Accounting Line Type
109541 , p_source_97 IN NUMBER
109542 )
109543 IS
109544
109545 l_component_type VARCHAR2(80);
109546 l_component_code VARCHAR2(30);
109547 l_component_type_code VARCHAR2(1);
109548 l_component_appl_id INTEGER;
109549 l_amb_context_code VARCHAR2(30);
109550 l_entity_code VARCHAR2(30);
109551 l_event_class_code VARCHAR2(30);
109552 l_ae_header_id NUMBER;
109553 l_event_type_code VARCHAR2(30);
109554 l_line_definition_code VARCHAR2(30);
109555 l_line_definition_owner_code VARCHAR2(1);
109556 --
109557 -- adr variables
109558 l_segment VARCHAR2(30);
109559 l_ccid NUMBER;
109560 l_adr_transaction_coa_id NUMBER;
109561 l_adr_accounting_coa_id NUMBER;
109562 l_adr_flexfield_segment_code VARCHAR2(30);
109563 l_adr_flex_value_set_id NUMBER;
109564 l_adr_value_type_code VARCHAR2(30);
109565 l_adr_value_combination_id NUMBER;
109566 l_adr_value_segment_code VARCHAR2(30);
109567
109568 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
109569 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
109570 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
109571 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
109572
109573 -- 4262811 Variables ------------------------------------------------------------------------------------------
109574 l_entered_amt_idx NUMBER;
109575 l_accted_amt_idx NUMBER;
109576 l_acc_rev_flag VARCHAR2(1);
109577 l_accrual_line_num NUMBER;
109578 l_tmp_amt NUMBER;
109579 l_acc_rev_natural_side_code VARCHAR2(1);
109580
109581 l_num_entries NUMBER;
109582 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
109583 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
109584 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
109585 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
109586 l_recog_line_1 NUMBER;
109587 l_recog_line_2 NUMBER;
109588
109589 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
109590 l_bflow_applied_to_amt NUMBER; -- 5132302
109591 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
109592
109593 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
109594
109595 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
109596 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
109597
109598 ---------------------------------------------------------------------------------------------------------------
109599
109600
109601 --
109602 -- bulk performance
109603 --
109604 l_balance_type_code VARCHAR2(1);
109605 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
109606 l_log_module VARCHAR2(240);
109607
109608 --
109609 -- Upgrade strategy
109610 --
109611 l_actual_upg_option VARCHAR2(1);
109612 l_enc_upg_option VARCHAR2(1);
109613
109614 --
109615 BEGIN
109616 --
109617 IF g_log_enabled THEN
109618 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_216';
109619 END IF;
109620 --
109621 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
109622
109623 trace
109624 (p_msg => 'BEGIN of AcctLineType_216'
109625 ,p_level => C_LEVEL_PROCEDURE
109626 ,p_module => l_log_module);
109627
109628 END IF;
109629 --
109630 l_component_type := 'AMB_JLT';
109631 l_component_code := 'INTRANSIT_VALUATION';
109632 l_component_type_code := 'S';
109633 l_component_appl_id := 707;
109634 l_amb_context_code := 'DEFAULT';
109635 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
109636 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
109637 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
109638 l_line_definition_owner_code := 'S';
109639 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
109640 --
109641 l_balance_type_code := 'A';
109642 l_segment := NULL;
109643 l_ccid := NULL;
109644 l_adr_transaction_coa_id := NULL;
109645 l_adr_accounting_coa_id := NULL;
109646 l_adr_flexfield_segment_code := NULL;
109647 l_adr_flex_value_set_id := NULL;
109648 l_adr_value_type_code := NULL;
109649 l_adr_value_combination_id := NULL;
109650 l_adr_value_segment_code := NULL;
109651
109652 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
109653 l_bflow_class_code := ''; -- 4219869 Business Flow
109654 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
109655 l_budgetary_control_flag := 'N';
109656
109657 l_bflow_applied_to_amt_idx := NULL; -- 5132302
109658 l_bflow_applied_to_amt := NULL; -- 5132302
109659 l_entered_amt_idx := NULL; -- 4262811
109660 l_accted_amt_idx := NULL; -- 4262811
109661 l_acc_rev_flag := NULL; -- 4262811
109662 l_accrual_line_num := NULL; -- 4262811
109663 l_tmp_amt := NULL; -- 4262811
109664 --
109665
109666 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
109667 l_balance_type_code <> 'B' THEN
109668 IF NVL(p_source_97,9E125) = 14
109669 THEN
109670
109671 --
109672 XLA_AE_LINES_PKG.SetNewLine;
109673
109674 p_balance_type_code := l_balance_type_code;
109675 -- set the flag so later we will know whether the gain loss line needs to be created
109676
109677 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
109678 p_actual_flag :='A';
109679 END IF;
109680
109681 --
109682 -- bulk performance
109683 --
109684 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
109685 p_header_num => 0); -- 4262811
109686 --
109687 -- set accounting line options
109688 --
109689 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
109690 p_natural_side_code => 'D'
109691 , p_gain_or_loss_flag => 'N'
109692 , p_gl_transfer_mode_code => 'S'
109693 , p_acct_entry_type_code => 'A'
109694 , p_switch_side_flag => 'Y'
109695 , p_merge_duplicate_code => 'N'
109696 );
109697 --
109698 l_acc_rev_natural_side_code := 'C'; -- 4262811
109699 --
109700 --
109701 -- set accounting line type info
109702 --
109703 xla_ae_lines_pkg.SetAcctLineType
109704 (p_component_type => l_component_type
109705 ,p_event_type_code => l_event_type_code
109706 ,p_line_definition_owner_code => l_line_definition_owner_code
109707 ,p_line_definition_code => l_line_definition_code
109708 ,p_accounting_line_code => l_component_code
109709 ,p_accounting_line_type_code => l_component_type_code
109710 ,p_accounting_line_appl_id => l_component_appl_id
109711 ,p_amb_context_code => l_amb_context_code
109712 ,p_entity_code => l_entity_code
109713 ,p_event_class_code => l_event_class_code);
109714 --
109715 -- set accounting class
109716 --
109717 xla_ae_lines_pkg.SetAcctClass(
109718 p_accounting_class_code => 'INTRANSIT_VALUATION'
109719 , p_ae_header_id => l_ae_header_id
109720 );
109721
109722 --
109723 -- set rounding class
109724 --
109725 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
109726 'INTRANSIT_VALUATION';
109727
109728 --
109729 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
109730 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
109731 --
109732 -- bulk performance
109733 --
109734 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
109735
109736 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
109737 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
109738
109739 -- 4955764
109740 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
109741 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
109742
109743 -- 4458381 Public Sector Enh
109744
109745 --
109746 -- set accounting attributes for the line type
109747 --
109748 l_entered_amt_idx := 3;
109749 l_accted_amt_idx := 8;
109750 l_bflow_applied_to_amt_idx := NULL; -- 5132302
109751 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
109752 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
109753 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
109754 l_rec_acct_attrs.array_char_value(2) := p_source_85;
109755 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
109756 l_rec_acct_attrs.array_num_value(3) := p_source_91;
109757 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
109758 l_rec_acct_attrs.array_char_value(4) := p_source_88;
109759 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
109760 l_rec_acct_attrs.array_date_value(5) := p_source_92;
109761 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
109762 l_rec_acct_attrs.array_num_value(6) := p_source_93;
109763 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
109764 l_rec_acct_attrs.array_char_value(7) := p_source_94;
109765 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
109766 l_rec_acct_attrs.array_num_value(8) := p_source_95;
109767
109768 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
109769 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
109770
109771 ---------------------------------------------------------------------------------------------------------------
109772 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
109773 ---------------------------------------------------------------------------------------------------------------
109774 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
109775
109776 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
109777 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
109778
109779 IF xla_accounting_cache_pkg.GetValueChar
109780 (p_source_code => 'LEDGER_CATEGORY_CODE'
109781 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
109782 AND l_bflow_method_code = 'PRIOR_ENTRY'
109783 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
109784 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
109785 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
109786 )
109787 THEN
109788 xla_ae_lines_pkg.BflowUpgEntry
109789 (p_business_method_code => l_bflow_method_code
109790 ,p_business_class_code => l_bflow_class_code
109791 ,p_balance_type => l_balance_type_code);
109792 ELSE
109793 NULL;
109794 -- No business flow processing for business flow method of NONE.
109795 END IF;
109796
109797 --
109798 -- call analytical criteria
109799 --
109800
109801 --
109802 -- call description
109803 --
109804
109805 xla_ae_lines_pkg.SetLineDescription(
109806 p_ae_header_id => l_ae_header_id
109807 ,p_description => Description_1 (
109808 p_application_id => p_application_id
109809 , p_ae_header_id => l_ae_header_id
109810 , p_source_1 => p_source_1
109811 , p_source_2 => p_source_2
109812 , p_source_3 => p_source_3
109813 , p_source_4 => p_source_4
109814 , p_source_5 => p_source_5
109815 )
109816 );
109817
109818
109819 --
109820 -- call ADRs
109821 -- Bug 4922099
109822 --
109823 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
109824 (NVL(l_actual_upg_option, 'N') = 'O') OR
109825 (NVL(l_enc_upg_option, 'N') = 'O')
109826 )
109827 THEN
109828 NULL;
109829 --
109830 --
109831
109832 l_ccid := AcctDerRule_25(
109833 p_application_id => p_application_id
109834 , p_ae_header_id => l_ae_header_id
109835 , p_source_11 => p_source_11
109836 , p_source_15 => p_source_15
109837 , p_source_39 => p_source_39
109838 , p_source_39_meaning => p_source_39_meaning
109839 , p_source_41 => p_source_41
109840 , p_source_42 => p_source_42
109841 , p_source_43 => p_source_43
109842 , p_source_44 => p_source_44
109843 , p_source_45 => p_source_45
109844 , x_transaction_coa_id => l_adr_transaction_coa_id
109845 , x_accounting_coa_id => l_adr_accounting_coa_id
109846 , x_value_type_code => l_adr_value_type_code
109847 , p_side => 'NA'
109848 );
109849
109850 xla_ae_lines_pkg.set_ccid(
109851 p_code_combination_id => l_ccid
109852 , p_value_type_code => l_adr_value_type_code
109853 , p_transaction_coa_id => l_adr_transaction_coa_id
109854 , p_accounting_coa_id => l_adr_accounting_coa_id
109855 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
109856 , p_adr_type_code => 'S'
109857 , p_component_type => l_component_type
109858 , p_component_code => l_component_code
109859 , p_component_type_code => l_component_type_code
109860 , p_component_appl_id => l_component_appl_id
109861 , p_amb_context_code => l_amb_context_code
109862 , p_side => 'NA'
109863 );
109864
109865
109866 --
109867 --
109868 END IF;
109869 --
109870 -- Bug 4922099
109871 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
109872 (NVL(l_enc_upg_option, 'N') = 'O')
109873 ) AND
109874 (l_bflow_method_code = 'PRIOR_ENTRY')
109875 )
109876 THEN
109877 IF
109878 --
109879 1 = 2
109880 --
109881 THEN
109882 xla_accounting_err_pkg.build_message
109883 (p_appli_s_name => 'XLA'
109884 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
109885 ,p_token_1 => 'LINE_NUMBER'
109886 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
109887 ,p_token_2 => 'LINE_TYPE_NAME'
109888 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
109889 l_component_type
109890 ,l_component_code
109891 ,l_component_type_code
109892 ,l_component_appl_id
109893 ,l_amb_context_code
109894 ,l_entity_code
109895 ,l_event_class_code
109896 )
109897 ,p_token_3 => 'OWNER'
109898 ,p_value_3 => xla_lookups_pkg.get_meaning(
109899 p_lookup_type => 'XLA_OWNER_TYPE'
109900 ,p_lookup_code => l_component_type_code
109901 )
109902 ,p_token_4 => 'PRODUCT_NAME'
109903 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
109904 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
109905 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
109906 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
109907 ,p_ae_header_id => NULL
109908 );
109909
109910 IF (C_LEVEL_ERROR>= g_log_level) THEN
109911 trace
109912 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
109913 ,p_level => C_LEVEL_ERROR
109914 ,p_module => l_log_module);
109915 END IF;
109916 END IF;
109917 END IF;
109918 --
109919 --
109920 ------------------------------------------------------------------------------------------------
109921 -- 4219869 Business Flow
109922 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
109923 -- Prior Entry. Currently, the following code is always generated.
109924 ------------------------------------------------------------------------------------------------
109925 XLA_AE_LINES_PKG.ValidateCurrentLine;
109926
109927 ------------------------------------------------------------------------------------
109928 -- 4219869 Business Flow
109929 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
109930 ------------------------------------------------------------------------------------
109931 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
109932
109933 ----------------------------------------------------------------------------------
109934 -- 4219869 Business Flow
109935 -- Update journal entry status -- Need to generate this within IF <condition>
109936 ----------------------------------------------------------------------------------
109937 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
109938 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
109939 ,p_balance_type_code => l_balance_type_code
109940 );
109941
109942 -------------------------------------------------------------------------------------------
109943 -- 4262811 - Generate the Accrual Reversal lines
109944 -------------------------------------------------------------------------------------------
109945 BEGIN
109946 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
109947 (g_array_event(p_event_id).array_value_num('header_index'));
109948 IF l_acc_rev_flag IS NULL THEN
109949 l_acc_rev_flag := 'N';
109950 END IF;
109951 EXCEPTION
109952 WHEN OTHERS THEN
109953 l_acc_rev_flag := 'N';
109954 END;
109955 --
109956 IF (l_acc_rev_flag = 'Y') THEN
109957
109958 -- 4645092 ------------------------------------------------------------------------------
109959 -- To allow MPA report to determine if it should generate report process
109960 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
109961 ------------------------------------------------------------------------------------------
109962
109963 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
109964 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
109965 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
109966 -- call ADRs
109967 -- Bug 4922099
109968 --
109969 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
109970 (NVL(l_actual_upg_option, 'N') = 'O') OR
109971 (NVL(l_enc_upg_option, 'N') = 'O')
109972 )
109973 THEN
109974 NULL;
109975 --
109976 --
109977
109978 l_ccid := AcctDerRule_25(
109979 p_application_id => p_application_id
109980 , p_ae_header_id => l_ae_header_id
109981 , p_source_11 => p_source_11
109982 , p_source_15 => p_source_15
109983 , p_source_39 => p_source_39
109984 , p_source_39_meaning => p_source_39_meaning
109985 , p_source_41 => p_source_41
109986 , p_source_42 => p_source_42
109987 , p_source_43 => p_source_43
109988 , p_source_44 => p_source_44
109989 , p_source_45 => p_source_45
109990 , x_transaction_coa_id => l_adr_transaction_coa_id
109991 , x_accounting_coa_id => l_adr_accounting_coa_id
109992 , x_value_type_code => l_adr_value_type_code
109993 , p_side => 'NA'
109994 );
109995
109996 xla_ae_lines_pkg.set_ccid(
109997 p_code_combination_id => l_ccid
109998 , p_value_type_code => l_adr_value_type_code
109999 , p_transaction_coa_id => l_adr_transaction_coa_id
110000 , p_accounting_coa_id => l_adr_accounting_coa_id
110001 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
110002 , p_adr_type_code => 'S'
110003 , p_component_type => l_component_type
110004 , p_component_code => l_component_code
110005 , p_component_type_code => l_component_type_code
110006 , p_component_appl_id => l_component_appl_id
110007 , p_amb_context_code => l_amb_context_code
110008 , p_side => 'NA'
110009 );
110010
110011
110012 --
110013 --
110014 END IF;
110015
110016 --
110017 -- Update the line information that should be overwritten
110018 --
110019 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
110020 p_header_num => 1);
110021 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
110022
110023 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
110024
110025 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
110026 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
110027 END IF;
110028
110029 --
110030 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
110031 --
110032 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
110033 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
110034 ELSE
110035 ---------------------------------------------------------------------------------------------------
110036 -- 4262811a Switch Sign
110037 ---------------------------------------------------------------------------------------------------
110038 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
110039 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
110040 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110041 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
110042 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110043 -- 5132302
110044 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
110045 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110046
110047 END IF;
110048
110049 -- 4955764
110050 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
110051 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
110052
110053
110054 XLA_AE_LINES_PKG.ValidateCurrentLine;
110055 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
110056
110057 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
110058 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
110059 ,p_balance_type_code => l_balance_type_code);
110060
110061 END IF;
110062
110063 -----------------------------------------------------------------------------------------
110064 -- 4262811 Multiperiod Accounting
110065 -----------------------------------------------------------------------------------------
110066 -- No MPA option is assigned.
110067
110068
110069 END IF;
110070 END IF;
110071 --
110072
110073 --
110074 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
110075 trace
110076 (p_msg => 'END of AcctLineType_216'
110077 ,p_level => C_LEVEL_PROCEDURE
110078 ,p_module => l_log_module);
110079 END IF;
110080 --
110081 EXCEPTION
110082 WHEN xla_exceptions_pkg.application_exception THEN
110083 RAISE;
110084 WHEN OTHERS THEN
110085 xla_exceptions_pkg.raise_message
110086 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_216');
110087 END AcctLineType_216;
110088 --
110089
110090 ---------------------------------------
110091 --
110092 -- PRIVATE FUNCTION
110093 -- AcctLineType_217
110094 --
110095 ---------------------------------------
110096 PROCEDURE AcctLineType_217 (
110097 p_application_id IN NUMBER
110098 ,p_event_id IN NUMBER
110099 ,p_calculate_acctd_flag IN VARCHAR2
110100 ,p_calculate_g_l_flag IN VARCHAR2
110101 ,p_actual_flag IN OUT VARCHAR2
110102 ,p_balance_type_code OUT VARCHAR2
110103 ,p_gain_or_loss_ref OUT VARCHAR2
110104
110105 --TRANSACTION_ID
110106 , p_source_1 IN NUMBER
110107 --Item Concatenated Segments
110108 , p_source_2 IN VARCHAR2
110109 --Transaction Quantity
110110 , p_source_3 IN NUMBER
110111 --Transaction Unit of Measure Code
110112 , p_source_4 IN VARCHAR2
110113 --Inventory Transaction Type Description
110114 , p_source_5 IN VARCHAR2
110115 --Cost Management Default Account
110116 , p_source_11 IN NUMBER
110117 --Cost Element Name
110118 , p_source_15 IN NUMBER
110119 --Primary Cost Method
110120 , p_source_39 IN NUMBER
110121 , p_source_39_meaning IN VARCHAR2
110122 --Product Line Accounting Category Material Account
110123 , p_source_41 IN NUMBER
110124 --Product Line Accounting Category Material Overhead Account
110125 , p_source_42 IN NUMBER
110126 --Product Line Accounting Category Resource Account
110127 , p_source_43 IN NUMBER
110128 --Product Line Accounting Category Outside Processing Account
110129 , p_source_44 IN NUMBER
110130 --Product Line Accounting Category Overhead Account
110131 , p_source_45 IN NUMBER
110132 --Applied to Application ID
110133 , p_source_79 IN NUMBER
110134 --Applied to Distribution Link Type
110135 , p_source_80 IN VARCHAR2
110136 --Applied to Entity Code
110137 , p_source_81 IN VARCHAR2
110138 --DISTRIBUTION_IDENTIFIER
110139 , p_source_84 IN NUMBER
110140 --Distribution Type
110141 , p_source_85 IN VARCHAR2
110142 , p_source_85_meaning IN VARCHAR2
110143 --Encumbrance Reversal Amount Entered
110144 , p_source_87 IN NUMBER
110145 --Entered Currency Code
110146 , p_source_88 IN VARCHAR2
110147 --Transaction Encumbrance Reversal Amount
110148 , p_source_89 IN NUMBER
110149 --Entered Amount
110150 , p_source_91 IN NUMBER
110151 --Currency Conversion Date
110152 , p_source_92 IN DATE
110153 --Currency Conversion Rate
110154 , p_source_93 IN NUMBER
110155 --Currency Conversion Type
110156 , p_source_94 IN VARCHAR2
110157 --Accounted Amount
110158 , p_source_95 IN NUMBER
110159 --Accounting Line Type
110160 , p_source_97 IN NUMBER
110161 --Costing Encumbrance Upgrade Option
110162 , p_source_100 IN VARCHAR2
110163 --TXN_PO_DISTRIBUTION_ID
110164 , p_source_101 IN NUMBER
110165 --TXN_PO_HEADER_ID
110166 , p_source_102 IN NUMBER
110167 --Requisition Budget Account
110168 , p_source_103 IN NUMBER
110169 --Requisition Encumbrance Type Identifier
110170 , p_source_104 IN NUMBER
110171 )
110172 IS
110173
110174 l_component_type VARCHAR2(80);
110175 l_component_code VARCHAR2(30);
110176 l_component_type_code VARCHAR2(1);
110177 l_component_appl_id INTEGER;
110178 l_amb_context_code VARCHAR2(30);
110179 l_entity_code VARCHAR2(30);
110180 l_event_class_code VARCHAR2(30);
110181 l_ae_header_id NUMBER;
110182 l_event_type_code VARCHAR2(30);
110183 l_line_definition_code VARCHAR2(30);
110184 l_line_definition_owner_code VARCHAR2(1);
110185 --
110186 -- adr variables
110187 l_segment VARCHAR2(30);
110188 l_ccid NUMBER;
110189 l_adr_transaction_coa_id NUMBER;
110190 l_adr_accounting_coa_id NUMBER;
110191 l_adr_flexfield_segment_code VARCHAR2(30);
110192 l_adr_flex_value_set_id NUMBER;
110193 l_adr_value_type_code VARCHAR2(30);
110194 l_adr_value_combination_id NUMBER;
110195 l_adr_value_segment_code VARCHAR2(30);
110196
110197 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
110198 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
110199 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
110200 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
110201
110202 -- 4262811 Variables ------------------------------------------------------------------------------------------
110203 l_entered_amt_idx NUMBER;
110204 l_accted_amt_idx NUMBER;
110205 l_acc_rev_flag VARCHAR2(1);
110206 l_accrual_line_num NUMBER;
110207 l_tmp_amt NUMBER;
110208 l_acc_rev_natural_side_code VARCHAR2(1);
110209
110210 l_num_entries NUMBER;
110211 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
110212 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
110213 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
110214 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
110215 l_recog_line_1 NUMBER;
110216 l_recog_line_2 NUMBER;
110217
110218 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
110219 l_bflow_applied_to_amt NUMBER; -- 5132302
110220 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
110221
110222 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
110223
110224 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
110225 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
110226
110227 ---------------------------------------------------------------------------------------------------------------
110228
110229
110230 --
110231 -- bulk performance
110232 --
110233 l_balance_type_code VARCHAR2(1);
110234 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
110235 l_log_module VARCHAR2(240);
110236
110237 --
110238 -- Upgrade strategy
110239 --
110240 l_actual_upg_option VARCHAR2(1);
110241 l_enc_upg_option VARCHAR2(1);
110242
110243 --
110244 BEGIN
110245 --
110246 IF g_log_enabled THEN
110247 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_217';
110248 END IF;
110249 --
110250 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
110251
110252 trace
110253 (p_msg => 'BEGIN of AcctLineType_217'
110254 ,p_level => C_LEVEL_PROCEDURE
110255 ,p_module => l_log_module);
110256
110257 END IF;
110258 --
110259 l_component_type := 'AMB_JLT';
110260 l_component_code := 'INTRANSIT_VALUATION';
110261 l_component_type_code := 'S';
110262 l_component_appl_id := 707;
110263 l_amb_context_code := 'DEFAULT';
110264 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
110265 l_event_class_code := 'FOB_SHIP_RECIPIENT_RCPT';
110266 l_event_type_code := 'FOB_SHIP_RECIPIENT_RCPT';
110267 l_line_definition_owner_code := 'S';
110268 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_RCPT';
110269 --
110270 l_balance_type_code := 'A';
110271 l_segment := NULL;
110272 l_ccid := NULL;
110273 l_adr_transaction_coa_id := NULL;
110274 l_adr_accounting_coa_id := NULL;
110275 l_adr_flexfield_segment_code := NULL;
110276 l_adr_flex_value_set_id := NULL;
110277 l_adr_value_type_code := NULL;
110278 l_adr_value_combination_id := NULL;
110279 l_adr_value_segment_code := NULL;
110280
110281 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
110282 l_bflow_class_code := ''; -- 4219869 Business Flow
110283 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
110284 l_budgetary_control_flag := 'N';
110285
110286 l_bflow_applied_to_amt_idx := NULL; -- 5132302
110287 l_bflow_applied_to_amt := NULL; -- 5132302
110288 l_entered_amt_idx := NULL; -- 4262811
110289 l_accted_amt_idx := NULL; -- 4262811
110290 l_acc_rev_flag := NULL; -- 4262811
110291 l_accrual_line_num := NULL; -- 4262811
110292 l_tmp_amt := NULL; -- 4262811
110293 --
110294
110295 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
110296 l_balance_type_code <> 'B' THEN
110297 IF NVL(p_source_97,9E125) = 14
110298 THEN
110299
110300 --
110301 XLA_AE_LINES_PKG.SetNewLine;
110302
110303 p_balance_type_code := l_balance_type_code;
110304 -- set the flag so later we will know whether the gain loss line needs to be created
110305
110306 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
110307 p_actual_flag :='A';
110308 END IF;
110309
110310 --
110311 -- bulk performance
110312 --
110313 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
110314 p_header_num => 0); -- 4262811
110315 --
110316 -- set accounting line options
110317 --
110318 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
110319 p_natural_side_code => 'D'
110320 , p_gain_or_loss_flag => 'N'
110321 , p_gl_transfer_mode_code => 'S'
110322 , p_acct_entry_type_code => 'A'
110323 , p_switch_side_flag => 'Y'
110324 , p_merge_duplicate_code => 'N'
110325 );
110326 --
110327 l_acc_rev_natural_side_code := 'C'; -- 4262811
110328 --
110329 --
110330 -- set accounting line type info
110331 --
110332 xla_ae_lines_pkg.SetAcctLineType
110333 (p_component_type => l_component_type
110334 ,p_event_type_code => l_event_type_code
110335 ,p_line_definition_owner_code => l_line_definition_owner_code
110336 ,p_line_definition_code => l_line_definition_code
110337 ,p_accounting_line_code => l_component_code
110338 ,p_accounting_line_type_code => l_component_type_code
110339 ,p_accounting_line_appl_id => l_component_appl_id
110340 ,p_amb_context_code => l_amb_context_code
110341 ,p_entity_code => l_entity_code
110342 ,p_event_class_code => l_event_class_code);
110343 --
110344 -- set accounting class
110345 --
110346 xla_ae_lines_pkg.SetAcctClass(
110347 p_accounting_class_code => 'INTRANSIT_VALUATION'
110348 , p_ae_header_id => l_ae_header_id
110349 );
110350
110351 --
110352 -- set rounding class
110353 --
110354 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
110355 'INTRANSIT_VALUATION';
110356
110357 --
110358 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
110359 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
110360 --
110361 -- bulk performance
110362 --
110363 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
110364
110365 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
110366 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
110367
110368 -- 4955764
110369 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
110370 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
110371
110372 -- 4458381 Public Sector Enh
110373
110374 --
110375 -- set accounting attributes for the line type
110376 --
110377 l_entered_amt_idx := 17;
110378 l_accted_amt_idx := 22;
110379 l_bflow_applied_to_amt_idx := NULL; -- 5132302
110380 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
110381 l_rec_acct_attrs.array_num_value(1) := p_source_79;
110382 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
110383 l_rec_acct_attrs.array_char_value(2) := p_source_80;
110384 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
110385 l_rec_acct_attrs.array_char_value(3) := p_source_81;
110386 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
110387 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
110388 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
110389 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
110390 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
110391 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
110392 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
110393 l_rec_acct_attrs.array_char_value(7) := p_source_85;
110394 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
110395 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
110396 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
110397 l_rec_acct_attrs.array_num_value(9) := p_source_87;
110398 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
110399 l_rec_acct_attrs.array_char_value(10) := p_source_88;
110400 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
110401 l_rec_acct_attrs.array_num_value(11) := p_source_89;
110402 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
110403 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
110404 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
110405 l_rec_acct_attrs.array_num_value(13) := p_source_87;
110406 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
110407 l_rec_acct_attrs.array_char_value(14) := p_source_88;
110408 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
110409 l_rec_acct_attrs.array_num_value(15) := p_source_89;
110410 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
110411 l_rec_acct_attrs.array_char_value(16) := p_source_100;
110412 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
110413 l_rec_acct_attrs.array_num_value(17) := p_source_91;
110414 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
110415 l_rec_acct_attrs.array_char_value(18) := p_source_88;
110416 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
110417 l_rec_acct_attrs.array_date_value(19) := p_source_92;
110418 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
110419 l_rec_acct_attrs.array_num_value(20) := p_source_93;
110420 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
110421 l_rec_acct_attrs.array_char_value(21) := p_source_94;
110422 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
110423 l_rec_acct_attrs.array_num_value(22) := p_source_95;
110424 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
110425 l_rec_acct_attrs.array_num_value(23) := p_source_104;
110426 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
110427 l_rec_acct_attrs.array_num_value(24) := p_source_104;
110428
110429 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
110430 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
110431
110432 ---------------------------------------------------------------------------------------------------------------
110433 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
110434 ---------------------------------------------------------------------------------------------------------------
110435 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
110436
110437 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
110438 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
110439
110440 IF xla_accounting_cache_pkg.GetValueChar
110441 (p_source_code => 'LEDGER_CATEGORY_CODE'
110442 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
110443 AND l_bflow_method_code = 'PRIOR_ENTRY'
110444 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
110445 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
110446 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
110447 )
110448 THEN
110449 xla_ae_lines_pkg.BflowUpgEntry
110450 (p_business_method_code => l_bflow_method_code
110451 ,p_business_class_code => l_bflow_class_code
110452 ,p_balance_type => l_balance_type_code);
110453 ELSE
110454 NULL;
110455 -- No business flow processing for business flow method of NONE.
110456 END IF;
110457
110458 --
110459 -- call analytical criteria
110460 --
110461
110462 --
110463 -- call description
110464 --
110465
110466 xla_ae_lines_pkg.SetLineDescription(
110467 p_ae_header_id => l_ae_header_id
110468 ,p_description => Description_1 (
110469 p_application_id => p_application_id
110470 , p_ae_header_id => l_ae_header_id
110471 , p_source_1 => p_source_1
110472 , p_source_2 => p_source_2
110473 , p_source_3 => p_source_3
110474 , p_source_4 => p_source_4
110475 , p_source_5 => p_source_5
110476 )
110477 );
110478
110479
110480 --
110481 -- call ADRs
110482 -- Bug 4922099
110483 --
110484 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
110485 (NVL(l_actual_upg_option, 'N') = 'O') OR
110486 (NVL(l_enc_upg_option, 'N') = 'O')
110487 )
110488 THEN
110489 NULL;
110490 --
110491 --
110492
110493 l_ccid := AcctDerRule_25(
110494 p_application_id => p_application_id
110495 , p_ae_header_id => l_ae_header_id
110496 , p_source_11 => p_source_11
110497 , p_source_15 => p_source_15
110498 , p_source_39 => p_source_39
110499 , p_source_39_meaning => p_source_39_meaning
110500 , p_source_41 => p_source_41
110501 , p_source_42 => p_source_42
110502 , p_source_43 => p_source_43
110503 , p_source_44 => p_source_44
110504 , p_source_45 => p_source_45
110505 , x_transaction_coa_id => l_adr_transaction_coa_id
110506 , x_accounting_coa_id => l_adr_accounting_coa_id
110507 , x_value_type_code => l_adr_value_type_code
110508 , p_side => 'NA'
110509 );
110510
110511 xla_ae_lines_pkg.set_ccid(
110512 p_code_combination_id => l_ccid
110513 , p_value_type_code => l_adr_value_type_code
110514 , p_transaction_coa_id => l_adr_transaction_coa_id
110515 , p_accounting_coa_id => l_adr_accounting_coa_id
110516 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
110517 , p_adr_type_code => 'S'
110518 , p_component_type => l_component_type
110519 , p_component_code => l_component_code
110520 , p_component_type_code => l_component_type_code
110521 , p_component_appl_id => l_component_appl_id
110522 , p_amb_context_code => l_amb_context_code
110523 , p_side => 'NA'
110524 );
110525
110526
110527 --
110528 --
110529 END IF;
110530 --
110531 -- Bug 4922099
110532 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
110533 (NVL(l_enc_upg_option, 'N') = 'O')
110534 ) AND
110535 (l_bflow_method_code = 'PRIOR_ENTRY')
110536 )
110537 THEN
110538 IF
110539 --
110540 1 = 2
110541 --
110542 THEN
110543 xla_accounting_err_pkg.build_message
110544 (p_appli_s_name => 'XLA'
110545 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
110546 ,p_token_1 => 'LINE_NUMBER'
110547 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
110548 ,p_token_2 => 'LINE_TYPE_NAME'
110549 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
110550 l_component_type
110551 ,l_component_code
110552 ,l_component_type_code
110553 ,l_component_appl_id
110554 ,l_amb_context_code
110555 ,l_entity_code
110556 ,l_event_class_code
110557 )
110558 ,p_token_3 => 'OWNER'
110559 ,p_value_3 => xla_lookups_pkg.get_meaning(
110560 p_lookup_type => 'XLA_OWNER_TYPE'
110561 ,p_lookup_code => l_component_type_code
110562 )
110563 ,p_token_4 => 'PRODUCT_NAME'
110564 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
110565 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
110566 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
110567 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
110568 ,p_ae_header_id => NULL
110569 );
110570
110571 IF (C_LEVEL_ERROR>= g_log_level) THEN
110572 trace
110573 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
110574 ,p_level => C_LEVEL_ERROR
110575 ,p_module => l_log_module);
110576 END IF;
110577 END IF;
110578 END IF;
110579 --
110580 --
110581 ------------------------------------------------------------------------------------------------
110582 -- 4219869 Business Flow
110583 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
110584 -- Prior Entry. Currently, the following code is always generated.
110585 ------------------------------------------------------------------------------------------------
110586 XLA_AE_LINES_PKG.ValidateCurrentLine;
110587
110588 ------------------------------------------------------------------------------------
110589 -- 4219869 Business Flow
110590 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
110591 ------------------------------------------------------------------------------------
110592 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
110593
110594 ----------------------------------------------------------------------------------
110595 -- 4219869 Business Flow
110596 -- Update journal entry status -- Need to generate this within IF <condition>
110597 ----------------------------------------------------------------------------------
110598 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
110599 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
110600 ,p_balance_type_code => l_balance_type_code
110601 );
110602
110603 -------------------------------------------------------------------------------------------
110604 -- 4262811 - Generate the Accrual Reversal lines
110605 -------------------------------------------------------------------------------------------
110606 BEGIN
110607 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
110608 (g_array_event(p_event_id).array_value_num('header_index'));
110609 IF l_acc_rev_flag IS NULL THEN
110610 l_acc_rev_flag := 'N';
110611 END IF;
110612 EXCEPTION
110613 WHEN OTHERS THEN
110614 l_acc_rev_flag := 'N';
110615 END;
110616 --
110617 IF (l_acc_rev_flag = 'Y') THEN
110618
110619 -- 4645092 ------------------------------------------------------------------------------
110620 -- To allow MPA report to determine if it should generate report process
110621 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
110622 ------------------------------------------------------------------------------------------
110623
110624 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
110625 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
110626 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
110627 -- call ADRs
110628 -- Bug 4922099
110629 --
110630 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
110631 (NVL(l_actual_upg_option, 'N') = 'O') OR
110632 (NVL(l_enc_upg_option, 'N') = 'O')
110633 )
110634 THEN
110635 NULL;
110636 --
110637 --
110638
110639 l_ccid := AcctDerRule_25(
110640 p_application_id => p_application_id
110641 , p_ae_header_id => l_ae_header_id
110642 , p_source_11 => p_source_11
110643 , p_source_15 => p_source_15
110644 , p_source_39 => p_source_39
110645 , p_source_39_meaning => p_source_39_meaning
110646 , p_source_41 => p_source_41
110647 , p_source_42 => p_source_42
110648 , p_source_43 => p_source_43
110649 , p_source_44 => p_source_44
110650 , p_source_45 => p_source_45
110651 , x_transaction_coa_id => l_adr_transaction_coa_id
110652 , x_accounting_coa_id => l_adr_accounting_coa_id
110653 , x_value_type_code => l_adr_value_type_code
110654 , p_side => 'NA'
110655 );
110656
110657 xla_ae_lines_pkg.set_ccid(
110658 p_code_combination_id => l_ccid
110659 , p_value_type_code => l_adr_value_type_code
110660 , p_transaction_coa_id => l_adr_transaction_coa_id
110661 , p_accounting_coa_id => l_adr_accounting_coa_id
110662 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
110663 , p_adr_type_code => 'S'
110664 , p_component_type => l_component_type
110665 , p_component_code => l_component_code
110666 , p_component_type_code => l_component_type_code
110667 , p_component_appl_id => l_component_appl_id
110668 , p_amb_context_code => l_amb_context_code
110669 , p_side => 'NA'
110670 );
110671
110672
110673 --
110674 --
110675 END IF;
110676
110677 --
110678 -- Update the line information that should be overwritten
110679 --
110680 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
110681 p_header_num => 1);
110682 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
110683
110684 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
110685
110686 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
110687 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
110688 END IF;
110689
110690 --
110691 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
110692 --
110693 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
110694 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
110695 ELSE
110696 ---------------------------------------------------------------------------------------------------
110697 -- 4262811a Switch Sign
110698 ---------------------------------------------------------------------------------------------------
110699 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
110700 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
110701 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110702 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
110703 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110704 -- 5132302
110705 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
110706 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
110707
110708 END IF;
110709
110710 -- 4955764
110711 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
110712 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
110713
110714
110715 XLA_AE_LINES_PKG.ValidateCurrentLine;
110716 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
110717
110718 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
110719 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
110720 ,p_balance_type_code => l_balance_type_code);
110721
110722 END IF;
110723
110724 -----------------------------------------------------------------------------------------
110725 -- 4262811 Multiperiod Accounting
110726 -----------------------------------------------------------------------------------------
110727 -- No MPA option is assigned.
110728
110729
110730 END IF;
110731 END IF;
110732 --
110733
110734 --
110735 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
110736 trace
110737 (p_msg => 'END of AcctLineType_217'
110738 ,p_level => C_LEVEL_PROCEDURE
110739 ,p_module => l_log_module);
110740 END IF;
110741 --
110742 EXCEPTION
110743 WHEN xla_exceptions_pkg.application_exception THEN
110744 RAISE;
110745 WHEN OTHERS THEN
110746 xla_exceptions_pkg.raise_message
110747 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_217');
110748 END AcctLineType_217;
110749 --
110750
110751 ---------------------------------------
110752 --
110753 -- PRIVATE FUNCTION
110754 -- AcctLineType_218
110755 --
110756 ---------------------------------------
110757 PROCEDURE AcctLineType_218 (
110758 p_application_id IN NUMBER
110759 ,p_event_id IN NUMBER
110760 ,p_calculate_acctd_flag IN VARCHAR2
110761 ,p_calculate_g_l_flag IN VARCHAR2
110762 ,p_actual_flag IN OUT VARCHAR2
110763 ,p_balance_type_code OUT VARCHAR2
110764 ,p_gain_or_loss_ref OUT VARCHAR2
110765
110766 --TRANSACTION_ID
110767 , p_source_1 IN NUMBER
110768 --Item Concatenated Segments
110769 , p_source_2 IN VARCHAR2
110770 --Transaction Quantity
110771 , p_source_3 IN NUMBER
110772 --Transaction Unit of Measure Code
110773 , p_source_4 IN VARCHAR2
110774 --Inventory Transaction Type Description
110775 , p_source_5 IN VARCHAR2
110776 --Cost Management Default Account
110777 , p_source_11 IN NUMBER
110778 --Cost Element Name
110779 , p_source_15 IN NUMBER
110780 --Primary Cost Method
110781 , p_source_39 IN NUMBER
110782 , p_source_39_meaning IN VARCHAR2
110783 --Product Line Accounting Category Material Account
110784 , p_source_41 IN NUMBER
110785 --Product Line Accounting Category Material Overhead Account
110786 , p_source_42 IN NUMBER
110787 --Product Line Accounting Category Resource Account
110788 , p_source_43 IN NUMBER
110789 --Product Line Accounting Category Outside Processing Account
110790 , p_source_44 IN NUMBER
110791 --Product Line Accounting Category Overhead Account
110792 , p_source_45 IN NUMBER
110793 --DISTRIBUTION_IDENTIFIER
110794 , p_source_84 IN NUMBER
110795 --Distribution Type
110796 , p_source_85 IN VARCHAR2
110797 , p_source_85_meaning IN VARCHAR2
110798 --Entered Currency Code
110799 , p_source_88 IN VARCHAR2
110800 --Entered Amount
110801 , p_source_91 IN NUMBER
110802 --Currency Conversion Date
110803 , p_source_92 IN DATE
110804 --Currency Conversion Rate
110805 , p_source_93 IN NUMBER
110806 --Currency Conversion Type
110807 , p_source_94 IN VARCHAR2
110808 --Accounted Amount
110809 , p_source_95 IN NUMBER
110810 --Accounting Line Type
110811 , p_source_97 IN NUMBER
110812 )
110813 IS
110814
110815 l_component_type VARCHAR2(80);
110816 l_component_code VARCHAR2(30);
110817 l_component_type_code VARCHAR2(1);
110818 l_component_appl_id INTEGER;
110819 l_amb_context_code VARCHAR2(30);
110820 l_entity_code VARCHAR2(30);
110821 l_event_class_code VARCHAR2(30);
110822 l_ae_header_id NUMBER;
110823 l_event_type_code VARCHAR2(30);
110824 l_line_definition_code VARCHAR2(30);
110825 l_line_definition_owner_code VARCHAR2(1);
110826 --
110827 -- adr variables
110828 l_segment VARCHAR2(30);
110829 l_ccid NUMBER;
110830 l_adr_transaction_coa_id NUMBER;
110831 l_adr_accounting_coa_id NUMBER;
110832 l_adr_flexfield_segment_code VARCHAR2(30);
110833 l_adr_flex_value_set_id NUMBER;
110834 l_adr_value_type_code VARCHAR2(30);
110835 l_adr_value_combination_id NUMBER;
110836 l_adr_value_segment_code VARCHAR2(30);
110837
110838 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
110839 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
110840 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
110841 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
110842
110843 -- 4262811 Variables ------------------------------------------------------------------------------------------
110844 l_entered_amt_idx NUMBER;
110845 l_accted_amt_idx NUMBER;
110846 l_acc_rev_flag VARCHAR2(1);
110847 l_accrual_line_num NUMBER;
110848 l_tmp_amt NUMBER;
110849 l_acc_rev_natural_side_code VARCHAR2(1);
110850
110851 l_num_entries NUMBER;
110852 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
110853 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
110854 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
110855 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
110856 l_recog_line_1 NUMBER;
110857 l_recog_line_2 NUMBER;
110858
110859 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
110860 l_bflow_applied_to_amt NUMBER; -- 5132302
110861 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
110862
110863 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
110864
110865 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
110866 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
110867
110868 ---------------------------------------------------------------------------------------------------------------
110869
110870
110871 --
110872 -- bulk performance
110873 --
110874 l_balance_type_code VARCHAR2(1);
110875 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
110876 l_log_module VARCHAR2(240);
110877
110878 --
110879 -- Upgrade strategy
110880 --
110881 l_actual_upg_option VARCHAR2(1);
110882 l_enc_upg_option VARCHAR2(1);
110883
110884 --
110885 BEGIN
110886 --
110887 IF g_log_enabled THEN
110888 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_218';
110889 END IF;
110890 --
110891 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
110892
110893 trace
110894 (p_msg => 'BEGIN of AcctLineType_218'
110895 ,p_level => C_LEVEL_PROCEDURE
110896 ,p_module => l_log_module);
110897
110898 END IF;
110899 --
110900 l_component_type := 'AMB_JLT';
110901 l_component_code := 'INTRANSIT_VALUATION';
110902 l_component_type_code := 'S';
110903 l_component_appl_id := 707;
110904 l_amb_context_code := 'DEFAULT';
110905 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
110906 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
110907 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_TP';
110908 l_line_definition_owner_code := 'S';
110909 l_line_definition_code := 'PI_RCPT_SENDER_RCPT_TP';
110910 --
110911 l_balance_type_code := 'A';
110912 l_segment := NULL;
110913 l_ccid := NULL;
110914 l_adr_transaction_coa_id := NULL;
110915 l_adr_accounting_coa_id := NULL;
110916 l_adr_flexfield_segment_code := NULL;
110917 l_adr_flex_value_set_id := NULL;
110918 l_adr_value_type_code := NULL;
110919 l_adr_value_combination_id := NULL;
110920 l_adr_value_segment_code := NULL;
110921
110922 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
110923 l_bflow_class_code := ''; -- 4219869 Business Flow
110924 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
110925 l_budgetary_control_flag := 'N';
110926
110927 l_bflow_applied_to_amt_idx := NULL; -- 5132302
110928 l_bflow_applied_to_amt := NULL; -- 5132302
110929 l_entered_amt_idx := NULL; -- 4262811
110930 l_accted_amt_idx := NULL; -- 4262811
110931 l_acc_rev_flag := NULL; -- 4262811
110932 l_accrual_line_num := NULL; -- 4262811
110933 l_tmp_amt := NULL; -- 4262811
110934 --
110935
110936 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
110937 l_balance_type_code <> 'B' THEN
110938 IF NVL(p_source_97,9E125) = 14
110939 THEN
110940
110941 --
110942 XLA_AE_LINES_PKG.SetNewLine;
110943
110944 p_balance_type_code := l_balance_type_code;
110945 -- set the flag so later we will know whether the gain loss line needs to be created
110946
110947 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
110948 p_actual_flag :='A';
110949 END IF;
110950
110951 --
110952 -- bulk performance
110953 --
110954 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
110955 p_header_num => 0); -- 4262811
110956 --
110957 -- set accounting line options
110958 --
110959 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
110960 p_natural_side_code => 'D'
110961 , p_gain_or_loss_flag => 'N'
110962 , p_gl_transfer_mode_code => 'S'
110963 , p_acct_entry_type_code => 'A'
110964 , p_switch_side_flag => 'Y'
110965 , p_merge_duplicate_code => 'N'
110966 );
110967 --
110968 l_acc_rev_natural_side_code := 'C'; -- 4262811
110969 --
110970 --
110971 -- set accounting line type info
110972 --
110973 xla_ae_lines_pkg.SetAcctLineType
110974 (p_component_type => l_component_type
110975 ,p_event_type_code => l_event_type_code
110976 ,p_line_definition_owner_code => l_line_definition_owner_code
110977 ,p_line_definition_code => l_line_definition_code
110978 ,p_accounting_line_code => l_component_code
110979 ,p_accounting_line_type_code => l_component_type_code
110980 ,p_accounting_line_appl_id => l_component_appl_id
110981 ,p_amb_context_code => l_amb_context_code
110982 ,p_entity_code => l_entity_code
110983 ,p_event_class_code => l_event_class_code);
110984 --
110985 -- set accounting class
110986 --
110987 xla_ae_lines_pkg.SetAcctClass(
110988 p_accounting_class_code => 'INTRANSIT_VALUATION'
110989 , p_ae_header_id => l_ae_header_id
110990 );
110991
110992 --
110993 -- set rounding class
110994 --
110995 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
110996 'INTRANSIT_VALUATION';
110997
110998 --
110999 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
111000 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
111001 --
111002 -- bulk performance
111003 --
111004 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
111005
111006 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
111007 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
111008
111009 -- 4955764
111010 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
111011 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
111012
111013 -- 4458381 Public Sector Enh
111014
111015 --
111016 -- set accounting attributes for the line type
111017 --
111018 l_entered_amt_idx := 3;
111019 l_accted_amt_idx := 8;
111020 l_bflow_applied_to_amt_idx := NULL; -- 5132302
111021 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
111022 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
111023 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
111024 l_rec_acct_attrs.array_char_value(2) := p_source_85;
111025 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
111026 l_rec_acct_attrs.array_num_value(3) := p_source_91;
111027 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
111028 l_rec_acct_attrs.array_char_value(4) := p_source_88;
111029 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
111030 l_rec_acct_attrs.array_date_value(5) := p_source_92;
111031 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
111032 l_rec_acct_attrs.array_num_value(6) := p_source_93;
111033 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
111034 l_rec_acct_attrs.array_char_value(7) := p_source_94;
111035 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
111036 l_rec_acct_attrs.array_num_value(8) := p_source_95;
111037
111038 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
111039 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
111040
111041 ---------------------------------------------------------------------------------------------------------------
111042 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
111043 ---------------------------------------------------------------------------------------------------------------
111044 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
111045
111046 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
111047 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
111048
111049 IF xla_accounting_cache_pkg.GetValueChar
111050 (p_source_code => 'LEDGER_CATEGORY_CODE'
111051 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
111052 AND l_bflow_method_code = 'PRIOR_ENTRY'
111053 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
111054 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
111055 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
111056 )
111057 THEN
111058 xla_ae_lines_pkg.BflowUpgEntry
111059 (p_business_method_code => l_bflow_method_code
111060 ,p_business_class_code => l_bflow_class_code
111061 ,p_balance_type => l_balance_type_code);
111062 ELSE
111063 NULL;
111064 -- No business flow processing for business flow method of NONE.
111065 END IF;
111066
111067 --
111068 -- call analytical criteria
111069 --
111070
111071 --
111072 -- call description
111073 --
111074
111075 xla_ae_lines_pkg.SetLineDescription(
111076 p_ae_header_id => l_ae_header_id
111077 ,p_description => Description_1 (
111078 p_application_id => p_application_id
111079 , p_ae_header_id => l_ae_header_id
111080 , p_source_1 => p_source_1
111081 , p_source_2 => p_source_2
111082 , p_source_3 => p_source_3
111083 , p_source_4 => p_source_4
111084 , p_source_5 => p_source_5
111085 )
111086 );
111087
111088
111089 --
111090 -- call ADRs
111091 -- Bug 4922099
111092 --
111093 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
111094 (NVL(l_actual_upg_option, 'N') = 'O') OR
111095 (NVL(l_enc_upg_option, 'N') = 'O')
111096 )
111097 THEN
111098 NULL;
111099 --
111100 --
111101
111102 l_ccid := AcctDerRule_25(
111103 p_application_id => p_application_id
111104 , p_ae_header_id => l_ae_header_id
111105 , p_source_11 => p_source_11
111106 , p_source_15 => p_source_15
111107 , p_source_39 => p_source_39
111108 , p_source_39_meaning => p_source_39_meaning
111109 , p_source_41 => p_source_41
111110 , p_source_42 => p_source_42
111111 , p_source_43 => p_source_43
111112 , p_source_44 => p_source_44
111113 , p_source_45 => p_source_45
111114 , x_transaction_coa_id => l_adr_transaction_coa_id
111115 , x_accounting_coa_id => l_adr_accounting_coa_id
111116 , x_value_type_code => l_adr_value_type_code
111117 , p_side => 'NA'
111118 );
111119
111120 xla_ae_lines_pkg.set_ccid(
111121 p_code_combination_id => l_ccid
111122 , p_value_type_code => l_adr_value_type_code
111123 , p_transaction_coa_id => l_adr_transaction_coa_id
111124 , p_accounting_coa_id => l_adr_accounting_coa_id
111125 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
111126 , p_adr_type_code => 'S'
111127 , p_component_type => l_component_type
111128 , p_component_code => l_component_code
111129 , p_component_type_code => l_component_type_code
111130 , p_component_appl_id => l_component_appl_id
111131 , p_amb_context_code => l_amb_context_code
111132 , p_side => 'NA'
111133 );
111134
111135
111136 --
111137 --
111138 END IF;
111139 --
111140 -- Bug 4922099
111141 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
111142 (NVL(l_enc_upg_option, 'N') = 'O')
111143 ) AND
111144 (l_bflow_method_code = 'PRIOR_ENTRY')
111145 )
111146 THEN
111147 IF
111148 --
111149 1 = 2
111150 --
111151 THEN
111152 xla_accounting_err_pkg.build_message
111153 (p_appli_s_name => 'XLA'
111154 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
111155 ,p_token_1 => 'LINE_NUMBER'
111156 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
111157 ,p_token_2 => 'LINE_TYPE_NAME'
111158 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
111159 l_component_type
111160 ,l_component_code
111161 ,l_component_type_code
111162 ,l_component_appl_id
111163 ,l_amb_context_code
111164 ,l_entity_code
111165 ,l_event_class_code
111166 )
111167 ,p_token_3 => 'OWNER'
111168 ,p_value_3 => xla_lookups_pkg.get_meaning(
111169 p_lookup_type => 'XLA_OWNER_TYPE'
111170 ,p_lookup_code => l_component_type_code
111171 )
111172 ,p_token_4 => 'PRODUCT_NAME'
111173 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
111174 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
111175 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
111176 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
111177 ,p_ae_header_id => NULL
111178 );
111179
111180 IF (C_LEVEL_ERROR>= g_log_level) THEN
111181 trace
111182 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
111183 ,p_level => C_LEVEL_ERROR
111184 ,p_module => l_log_module);
111185 END IF;
111186 END IF;
111187 END IF;
111188 --
111189 --
111190 ------------------------------------------------------------------------------------------------
111191 -- 4219869 Business Flow
111192 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
111193 -- Prior Entry. Currently, the following code is always generated.
111194 ------------------------------------------------------------------------------------------------
111195 XLA_AE_LINES_PKG.ValidateCurrentLine;
111196
111197 ------------------------------------------------------------------------------------
111198 -- 4219869 Business Flow
111199 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
111200 ------------------------------------------------------------------------------------
111201 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
111202
111203 ----------------------------------------------------------------------------------
111204 -- 4219869 Business Flow
111205 -- Update journal entry status -- Need to generate this within IF <condition>
111206 ----------------------------------------------------------------------------------
111207 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
111208 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
111209 ,p_balance_type_code => l_balance_type_code
111210 );
111211
111212 -------------------------------------------------------------------------------------------
111213 -- 4262811 - Generate the Accrual Reversal lines
111214 -------------------------------------------------------------------------------------------
111215 BEGIN
111216 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
111217 (g_array_event(p_event_id).array_value_num('header_index'));
111218 IF l_acc_rev_flag IS NULL THEN
111219 l_acc_rev_flag := 'N';
111220 END IF;
111221 EXCEPTION
111222 WHEN OTHERS THEN
111223 l_acc_rev_flag := 'N';
111224 END;
111225 --
111226 IF (l_acc_rev_flag = 'Y') THEN
111227
111228 -- 4645092 ------------------------------------------------------------------------------
111229 -- To allow MPA report to determine if it should generate report process
111230 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
111231 ------------------------------------------------------------------------------------------
111232
111233 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
111234 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
111235 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
111236 -- call ADRs
111237 -- Bug 4922099
111238 --
111239 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
111240 (NVL(l_actual_upg_option, 'N') = 'O') OR
111241 (NVL(l_enc_upg_option, 'N') = 'O')
111242 )
111243 THEN
111244 NULL;
111245 --
111246 --
111247
111248 l_ccid := AcctDerRule_25(
111249 p_application_id => p_application_id
111250 , p_ae_header_id => l_ae_header_id
111251 , p_source_11 => p_source_11
111252 , p_source_15 => p_source_15
111253 , p_source_39 => p_source_39
111254 , p_source_39_meaning => p_source_39_meaning
111255 , p_source_41 => p_source_41
111256 , p_source_42 => p_source_42
111257 , p_source_43 => p_source_43
111258 , p_source_44 => p_source_44
111259 , p_source_45 => p_source_45
111260 , x_transaction_coa_id => l_adr_transaction_coa_id
111261 , x_accounting_coa_id => l_adr_accounting_coa_id
111262 , x_value_type_code => l_adr_value_type_code
111263 , p_side => 'NA'
111264 );
111265
111266 xla_ae_lines_pkg.set_ccid(
111267 p_code_combination_id => l_ccid
111268 , p_value_type_code => l_adr_value_type_code
111269 , p_transaction_coa_id => l_adr_transaction_coa_id
111270 , p_accounting_coa_id => l_adr_accounting_coa_id
111271 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
111272 , p_adr_type_code => 'S'
111273 , p_component_type => l_component_type
111274 , p_component_code => l_component_code
111275 , p_component_type_code => l_component_type_code
111276 , p_component_appl_id => l_component_appl_id
111277 , p_amb_context_code => l_amb_context_code
111278 , p_side => 'NA'
111279 );
111280
111281
111282 --
111283 --
111284 END IF;
111285
111286 --
111287 -- Update the line information that should be overwritten
111288 --
111289 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
111290 p_header_num => 1);
111291 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
111292
111293 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
111294
111295 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
111296 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
111297 END IF;
111298
111299 --
111300 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
111301 --
111302 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
111303 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
111304 ELSE
111305 ---------------------------------------------------------------------------------------------------
111306 -- 4262811a Switch Sign
111307 ---------------------------------------------------------------------------------------------------
111308 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
111309 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
111310 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111311 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
111312 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111313 -- 5132302
111314 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
111315 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111316
111317 END IF;
111318
111319 -- 4955764
111320 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
111321 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
111322
111323
111324 XLA_AE_LINES_PKG.ValidateCurrentLine;
111325 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
111326
111327 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
111328 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
111329 ,p_balance_type_code => l_balance_type_code);
111330
111331 END IF;
111332
111333 -----------------------------------------------------------------------------------------
111334 -- 4262811 Multiperiod Accounting
111335 -----------------------------------------------------------------------------------------
111336 -- No MPA option is assigned.
111337
111338
111339 END IF;
111340 END IF;
111341 --
111342
111343 --
111344 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
111345 trace
111346 (p_msg => 'END of AcctLineType_218'
111347 ,p_level => C_LEVEL_PROCEDURE
111348 ,p_module => l_log_module);
111349 END IF;
111350 --
111351 EXCEPTION
111352 WHEN xla_exceptions_pkg.application_exception THEN
111353 RAISE;
111354 WHEN OTHERS THEN
111355 xla_exceptions_pkg.raise_message
111356 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_218');
111357 END AcctLineType_218;
111358 --
111359
111360 ---------------------------------------
111361 --
111362 -- PRIVATE FUNCTION
111363 -- AcctLineType_219
111364 --
111365 ---------------------------------------
111366 PROCEDURE AcctLineType_219 (
111367 p_application_id IN NUMBER
111368 ,p_event_id IN NUMBER
111369 ,p_calculate_acctd_flag IN VARCHAR2
111370 ,p_calculate_g_l_flag IN VARCHAR2
111371 ,p_actual_flag IN OUT VARCHAR2
111372 ,p_balance_type_code OUT VARCHAR2
111373 ,p_gain_or_loss_ref OUT VARCHAR2
111374
111375 --TRANSACTION_ID
111376 , p_source_1 IN NUMBER
111377 --Item Concatenated Segments
111378 , p_source_2 IN VARCHAR2
111379 --Transaction Quantity
111380 , p_source_3 IN NUMBER
111381 --Transaction Unit of Measure Code
111382 , p_source_4 IN VARCHAR2
111383 --Inventory Transaction Type Description
111384 , p_source_5 IN VARCHAR2
111385 --Cost Management Default Account
111386 , p_source_11 IN NUMBER
111387 --Cost Element Name
111388 , p_source_15 IN NUMBER
111389 --Primary Cost Method
111390 , p_source_39 IN NUMBER
111391 , p_source_39_meaning IN VARCHAR2
111392 --Product Line Accounting Category Material Account
111393 , p_source_41 IN NUMBER
111394 --Product Line Accounting Category Material Overhead Account
111395 , p_source_42 IN NUMBER
111396 --Product Line Accounting Category Resource Account
111397 , p_source_43 IN NUMBER
111398 --Product Line Accounting Category Outside Processing Account
111399 , p_source_44 IN NUMBER
111400 --Product Line Accounting Category Overhead Account
111401 , p_source_45 IN NUMBER
111402 --DISTRIBUTION_IDENTIFIER
111403 , p_source_84 IN NUMBER
111404 --Distribution Type
111405 , p_source_85 IN VARCHAR2
111406 , p_source_85_meaning IN VARCHAR2
111407 --Entered Currency Code
111408 , p_source_88 IN VARCHAR2
111409 --Entered Amount
111410 , p_source_91 IN NUMBER
111411 --Currency Conversion Date
111412 , p_source_92 IN DATE
111413 --Currency Conversion Rate
111414 , p_source_93 IN NUMBER
111415 --Currency Conversion Type
111416 , p_source_94 IN VARCHAR2
111417 --Accounted Amount
111418 , p_source_95 IN NUMBER
111419 --Accounting Line Type
111420 , p_source_97 IN NUMBER
111421 )
111422 IS
111423
111424 l_component_type VARCHAR2(80);
111425 l_component_code VARCHAR2(30);
111426 l_component_type_code VARCHAR2(1);
111427 l_component_appl_id INTEGER;
111428 l_amb_context_code VARCHAR2(30);
111429 l_entity_code VARCHAR2(30);
111430 l_event_class_code VARCHAR2(30);
111431 l_ae_header_id NUMBER;
111432 l_event_type_code VARCHAR2(30);
111433 l_line_definition_code VARCHAR2(30);
111434 l_line_definition_owner_code VARCHAR2(1);
111435 --
111436 -- adr variables
111437 l_segment VARCHAR2(30);
111438 l_ccid NUMBER;
111439 l_adr_transaction_coa_id NUMBER;
111440 l_adr_accounting_coa_id NUMBER;
111441 l_adr_flexfield_segment_code VARCHAR2(30);
111442 l_adr_flex_value_set_id NUMBER;
111443 l_adr_value_type_code VARCHAR2(30);
111444 l_adr_value_combination_id NUMBER;
111445 l_adr_value_segment_code VARCHAR2(30);
111446
111447 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
111448 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
111449 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
111450 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
111451
111452 -- 4262811 Variables ------------------------------------------------------------------------------------------
111453 l_entered_amt_idx NUMBER;
111454 l_accted_amt_idx NUMBER;
111455 l_acc_rev_flag VARCHAR2(1);
111456 l_accrual_line_num NUMBER;
111457 l_tmp_amt NUMBER;
111458 l_acc_rev_natural_side_code VARCHAR2(1);
111459
111460 l_num_entries NUMBER;
111461 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
111462 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
111463 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
111464 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
111465 l_recog_line_1 NUMBER;
111466 l_recog_line_2 NUMBER;
111467
111468 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
111469 l_bflow_applied_to_amt NUMBER; -- 5132302
111470 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
111471
111472 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
111473
111474 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
111475 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
111476
111477 ---------------------------------------------------------------------------------------------------------------
111478
111479
111480 --
111481 -- bulk performance
111482 --
111483 l_balance_type_code VARCHAR2(1);
111484 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
111485 l_log_module VARCHAR2(240);
111486
111487 --
111488 -- Upgrade strategy
111489 --
111490 l_actual_upg_option VARCHAR2(1);
111491 l_enc_upg_option VARCHAR2(1);
111492
111493 --
111494 BEGIN
111495 --
111496 IF g_log_enabled THEN
111497 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_219';
111498 END IF;
111499 --
111500 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
111501
111502 trace
111503 (p_msg => 'BEGIN of AcctLineType_219'
111504 ,p_level => C_LEVEL_PROCEDURE
111505 ,p_module => l_log_module);
111506
111507 END IF;
111508 --
111509 l_component_type := 'AMB_JLT';
111510 l_component_code := 'INTRANSIT_VALUATION';
111511 l_component_type_code := 'S';
111512 l_component_appl_id := 707;
111513 l_amb_context_code := 'DEFAULT';
111514 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
111515 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
111516 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
111517 l_line_definition_owner_code := 'S';
111518 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
111519 --
111520 l_balance_type_code := 'A';
111521 l_segment := NULL;
111522 l_ccid := NULL;
111523 l_adr_transaction_coa_id := NULL;
111524 l_adr_accounting_coa_id := NULL;
111525 l_adr_flexfield_segment_code := NULL;
111526 l_adr_flex_value_set_id := NULL;
111527 l_adr_value_type_code := NULL;
111528 l_adr_value_combination_id := NULL;
111529 l_adr_value_segment_code := NULL;
111530
111531 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
111532 l_bflow_class_code := ''; -- 4219869 Business Flow
111533 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
111534 l_budgetary_control_flag := 'N';
111535
111536 l_bflow_applied_to_amt_idx := NULL; -- 5132302
111537 l_bflow_applied_to_amt := NULL; -- 5132302
111538 l_entered_amt_idx := NULL; -- 4262811
111539 l_accted_amt_idx := NULL; -- 4262811
111540 l_acc_rev_flag := NULL; -- 4262811
111541 l_accrual_line_num := NULL; -- 4262811
111542 l_tmp_amt := NULL; -- 4262811
111543 --
111544
111545 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
111546 l_balance_type_code <> 'B' THEN
111547 IF NVL(p_source_97,9E125) = 14
111548 THEN
111549
111550 --
111551 XLA_AE_LINES_PKG.SetNewLine;
111552
111553 p_balance_type_code := l_balance_type_code;
111554 -- set the flag so later we will know whether the gain loss line needs to be created
111555
111556 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
111557 p_actual_flag :='A';
111558 END IF;
111559
111560 --
111561 -- bulk performance
111562 --
111563 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
111564 p_header_num => 0); -- 4262811
111565 --
111566 -- set accounting line options
111567 --
111568 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
111569 p_natural_side_code => 'D'
111570 , p_gain_or_loss_flag => 'N'
111571 , p_gl_transfer_mode_code => 'S'
111572 , p_acct_entry_type_code => 'A'
111573 , p_switch_side_flag => 'Y'
111574 , p_merge_duplicate_code => 'N'
111575 );
111576 --
111577 l_acc_rev_natural_side_code := 'C'; -- 4262811
111578 --
111579 --
111580 -- set accounting line type info
111581 --
111582 xla_ae_lines_pkg.SetAcctLineType
111583 (p_component_type => l_component_type
111584 ,p_event_type_code => l_event_type_code
111585 ,p_line_definition_owner_code => l_line_definition_owner_code
111586 ,p_line_definition_code => l_line_definition_code
111587 ,p_accounting_line_code => l_component_code
111588 ,p_accounting_line_type_code => l_component_type_code
111589 ,p_accounting_line_appl_id => l_component_appl_id
111590 ,p_amb_context_code => l_amb_context_code
111591 ,p_entity_code => l_entity_code
111592 ,p_event_class_code => l_event_class_code);
111593 --
111594 -- set accounting class
111595 --
111596 xla_ae_lines_pkg.SetAcctClass(
111597 p_accounting_class_code => 'INTRANSIT_VALUATION'
111598 , p_ae_header_id => l_ae_header_id
111599 );
111600
111601 --
111602 -- set rounding class
111603 --
111604 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
111605 'INTRANSIT_VALUATION';
111606
111607 --
111608 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
111609 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
111610 --
111611 -- bulk performance
111612 --
111613 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
111614
111615 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
111616 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
111617
111618 -- 4955764
111619 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
111620 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
111621
111622 -- 4458381 Public Sector Enh
111623
111624 --
111625 -- set accounting attributes for the line type
111626 --
111627 l_entered_amt_idx := 3;
111628 l_accted_amt_idx := 8;
111629 l_bflow_applied_to_amt_idx := NULL; -- 5132302
111630 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
111631 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
111632 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
111633 l_rec_acct_attrs.array_char_value(2) := p_source_85;
111634 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
111635 l_rec_acct_attrs.array_num_value(3) := p_source_91;
111636 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
111637 l_rec_acct_attrs.array_char_value(4) := p_source_88;
111638 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
111639 l_rec_acct_attrs.array_date_value(5) := p_source_92;
111640 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
111641 l_rec_acct_attrs.array_num_value(6) := p_source_93;
111642 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
111643 l_rec_acct_attrs.array_char_value(7) := p_source_94;
111644 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
111645 l_rec_acct_attrs.array_num_value(8) := p_source_95;
111646
111647 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
111648 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
111649
111650 ---------------------------------------------------------------------------------------------------------------
111651 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
111652 ---------------------------------------------------------------------------------------------------------------
111653 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
111654
111655 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
111656 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
111657
111658 IF xla_accounting_cache_pkg.GetValueChar
111659 (p_source_code => 'LEDGER_CATEGORY_CODE'
111660 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
111661 AND l_bflow_method_code = 'PRIOR_ENTRY'
111662 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
111663 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
111664 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
111665 )
111666 THEN
111667 xla_ae_lines_pkg.BflowUpgEntry
111668 (p_business_method_code => l_bflow_method_code
111669 ,p_business_class_code => l_bflow_class_code
111670 ,p_balance_type => l_balance_type_code);
111671 ELSE
111672 NULL;
111673 -- No business flow processing for business flow method of NONE.
111674 END IF;
111675
111676 --
111677 -- call analytical criteria
111678 --
111679
111680 --
111681 -- call description
111682 --
111683
111684 xla_ae_lines_pkg.SetLineDescription(
111685 p_ae_header_id => l_ae_header_id
111686 ,p_description => Description_1 (
111687 p_application_id => p_application_id
111688 , p_ae_header_id => l_ae_header_id
111689 , p_source_1 => p_source_1
111690 , p_source_2 => p_source_2
111691 , p_source_3 => p_source_3
111692 , p_source_4 => p_source_4
111693 , p_source_5 => p_source_5
111694 )
111695 );
111696
111697
111698 --
111699 -- call ADRs
111700 -- Bug 4922099
111701 --
111702 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
111703 (NVL(l_actual_upg_option, 'N') = 'O') OR
111704 (NVL(l_enc_upg_option, 'N') = 'O')
111705 )
111706 THEN
111707 NULL;
111708 --
111709 --
111710
111711 l_ccid := AcctDerRule_25(
111712 p_application_id => p_application_id
111713 , p_ae_header_id => l_ae_header_id
111714 , p_source_11 => p_source_11
111715 , p_source_15 => p_source_15
111716 , p_source_39 => p_source_39
111717 , p_source_39_meaning => p_source_39_meaning
111718 , p_source_41 => p_source_41
111719 , p_source_42 => p_source_42
111720 , p_source_43 => p_source_43
111721 , p_source_44 => p_source_44
111722 , p_source_45 => p_source_45
111723 , x_transaction_coa_id => l_adr_transaction_coa_id
111724 , x_accounting_coa_id => l_adr_accounting_coa_id
111725 , x_value_type_code => l_adr_value_type_code
111726 , p_side => 'NA'
111727 );
111728
111729 xla_ae_lines_pkg.set_ccid(
111730 p_code_combination_id => l_ccid
111731 , p_value_type_code => l_adr_value_type_code
111732 , p_transaction_coa_id => l_adr_transaction_coa_id
111733 , p_accounting_coa_id => l_adr_accounting_coa_id
111734 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
111735 , p_adr_type_code => 'S'
111736 , p_component_type => l_component_type
111737 , p_component_code => l_component_code
111738 , p_component_type_code => l_component_type_code
111739 , p_component_appl_id => l_component_appl_id
111740 , p_amb_context_code => l_amb_context_code
111741 , p_side => 'NA'
111742 );
111743
111744
111745 --
111746 --
111747 END IF;
111748 --
111749 -- Bug 4922099
111750 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
111751 (NVL(l_enc_upg_option, 'N') = 'O')
111752 ) AND
111753 (l_bflow_method_code = 'PRIOR_ENTRY')
111754 )
111755 THEN
111756 IF
111757 --
111758 1 = 2
111759 --
111760 THEN
111761 xla_accounting_err_pkg.build_message
111762 (p_appli_s_name => 'XLA'
111763 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
111764 ,p_token_1 => 'LINE_NUMBER'
111765 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
111766 ,p_token_2 => 'LINE_TYPE_NAME'
111767 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
111768 l_component_type
111769 ,l_component_code
111770 ,l_component_type_code
111771 ,l_component_appl_id
111772 ,l_amb_context_code
111773 ,l_entity_code
111774 ,l_event_class_code
111775 )
111776 ,p_token_3 => 'OWNER'
111777 ,p_value_3 => xla_lookups_pkg.get_meaning(
111778 p_lookup_type => 'XLA_OWNER_TYPE'
111779 ,p_lookup_code => l_component_type_code
111780 )
111781 ,p_token_4 => 'PRODUCT_NAME'
111782 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
111783 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
111784 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
111785 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
111786 ,p_ae_header_id => NULL
111787 );
111788
111789 IF (C_LEVEL_ERROR>= g_log_level) THEN
111790 trace
111791 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
111792 ,p_level => C_LEVEL_ERROR
111793 ,p_module => l_log_module);
111794 END IF;
111795 END IF;
111796 END IF;
111797 --
111798 --
111799 ------------------------------------------------------------------------------------------------
111800 -- 4219869 Business Flow
111801 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
111802 -- Prior Entry. Currently, the following code is always generated.
111803 ------------------------------------------------------------------------------------------------
111804 XLA_AE_LINES_PKG.ValidateCurrentLine;
111805
111806 ------------------------------------------------------------------------------------
111807 -- 4219869 Business Flow
111808 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
111809 ------------------------------------------------------------------------------------
111810 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
111811
111812 ----------------------------------------------------------------------------------
111813 -- 4219869 Business Flow
111814 -- Update journal entry status -- Need to generate this within IF <condition>
111815 ----------------------------------------------------------------------------------
111816 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
111817 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
111818 ,p_balance_type_code => l_balance_type_code
111819 );
111820
111821 -------------------------------------------------------------------------------------------
111822 -- 4262811 - Generate the Accrual Reversal lines
111823 -------------------------------------------------------------------------------------------
111824 BEGIN
111825 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
111826 (g_array_event(p_event_id).array_value_num('header_index'));
111827 IF l_acc_rev_flag IS NULL THEN
111828 l_acc_rev_flag := 'N';
111829 END IF;
111830 EXCEPTION
111831 WHEN OTHERS THEN
111832 l_acc_rev_flag := 'N';
111833 END;
111834 --
111835 IF (l_acc_rev_flag = 'Y') THEN
111836
111837 -- 4645092 ------------------------------------------------------------------------------
111838 -- To allow MPA report to determine if it should generate report process
111839 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
111840 ------------------------------------------------------------------------------------------
111841
111842 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
111843 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
111844 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
111845 -- call ADRs
111846 -- Bug 4922099
111847 --
111848 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
111849 (NVL(l_actual_upg_option, 'N') = 'O') OR
111850 (NVL(l_enc_upg_option, 'N') = 'O')
111851 )
111852 THEN
111853 NULL;
111854 --
111855 --
111856
111857 l_ccid := AcctDerRule_25(
111858 p_application_id => p_application_id
111859 , p_ae_header_id => l_ae_header_id
111860 , p_source_11 => p_source_11
111861 , p_source_15 => p_source_15
111862 , p_source_39 => p_source_39
111863 , p_source_39_meaning => p_source_39_meaning
111864 , p_source_41 => p_source_41
111865 , p_source_42 => p_source_42
111866 , p_source_43 => p_source_43
111867 , p_source_44 => p_source_44
111868 , p_source_45 => p_source_45
111869 , x_transaction_coa_id => l_adr_transaction_coa_id
111870 , x_accounting_coa_id => l_adr_accounting_coa_id
111871 , x_value_type_code => l_adr_value_type_code
111872 , p_side => 'NA'
111873 );
111874
111875 xla_ae_lines_pkg.set_ccid(
111876 p_code_combination_id => l_ccid
111877 , p_value_type_code => l_adr_value_type_code
111878 , p_transaction_coa_id => l_adr_transaction_coa_id
111879 , p_accounting_coa_id => l_adr_accounting_coa_id
111880 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
111881 , p_adr_type_code => 'S'
111882 , p_component_type => l_component_type
111883 , p_component_code => l_component_code
111884 , p_component_type_code => l_component_type_code
111885 , p_component_appl_id => l_component_appl_id
111886 , p_amb_context_code => l_amb_context_code
111887 , p_side => 'NA'
111888 );
111889
111890
111891 --
111892 --
111893 END IF;
111894
111895 --
111896 -- Update the line information that should be overwritten
111897 --
111898 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
111899 p_header_num => 1);
111900 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
111901
111902 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
111903
111904 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
111905 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
111906 END IF;
111907
111908 --
111909 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
111910 --
111911 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
111912 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
111913 ELSE
111914 ---------------------------------------------------------------------------------------------------
111915 -- 4262811a Switch Sign
111916 ---------------------------------------------------------------------------------------------------
111917 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
111918 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
111919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111920 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
111921 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111922 -- 5132302
111923 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
111924 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
111925
111926 END IF;
111927
111928 -- 4955764
111929 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
111930 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
111931
111932
111933 XLA_AE_LINES_PKG.ValidateCurrentLine;
111934 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
111935
111936 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
111937 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
111938 ,p_balance_type_code => l_balance_type_code);
111939
111940 END IF;
111941
111942 -----------------------------------------------------------------------------------------
111943 -- 4262811 Multiperiod Accounting
111944 -----------------------------------------------------------------------------------------
111945 -- No MPA option is assigned.
111946
111947
111948 END IF;
111949 END IF;
111950 --
111951
111952 --
111953 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
111954 trace
111955 (p_msg => 'END of AcctLineType_219'
111956 ,p_level => C_LEVEL_PROCEDURE
111957 ,p_module => l_log_module);
111958 END IF;
111959 --
111960 EXCEPTION
111961 WHEN xla_exceptions_pkg.application_exception THEN
111962 RAISE;
111963 WHEN OTHERS THEN
111964 xla_exceptions_pkg.raise_message
111965 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_219');
111966 END AcctLineType_219;
111967 --
111968
111969 ---------------------------------------
111970 --
111971 -- PRIVATE FUNCTION
111972 -- AcctLineType_220
111973 --
111974 ---------------------------------------
111975 PROCEDURE AcctLineType_220 (
111976 p_application_id IN NUMBER
111977 ,p_event_id IN NUMBER
111978 ,p_calculate_acctd_flag IN VARCHAR2
111979 ,p_calculate_g_l_flag IN VARCHAR2
111980 ,p_actual_flag IN OUT VARCHAR2
111981 ,p_balance_type_code OUT VARCHAR2
111982 ,p_gain_or_loss_ref OUT VARCHAR2
111983
111984 --TRANSACTION_ID
111985 , p_source_1 IN NUMBER
111986 --Item Concatenated Segments
111987 , p_source_2 IN VARCHAR2
111988 --Transaction Quantity
111989 , p_source_3 IN NUMBER
111990 --Transaction Unit of Measure Code
111991 , p_source_4 IN VARCHAR2
111992 --Inventory Transaction Type Description
111993 , p_source_5 IN VARCHAR2
111994 --Cost Management Default Account
111995 , p_source_11 IN NUMBER
111996 --Cost Element Name
111997 , p_source_15 IN NUMBER
111998 --Primary Cost Method
111999 , p_source_39 IN NUMBER
112000 , p_source_39_meaning IN VARCHAR2
112001 --Product Line Accounting Category Material Account
112002 , p_source_41 IN NUMBER
112003 --Product Line Accounting Category Material Overhead Account
112004 , p_source_42 IN NUMBER
112005 --Product Line Accounting Category Resource Account
112006 , p_source_43 IN NUMBER
112007 --Product Line Accounting Category Outside Processing Account
112008 , p_source_44 IN NUMBER
112009 --Product Line Accounting Category Overhead Account
112010 , p_source_45 IN NUMBER
112011 --DISTRIBUTION_IDENTIFIER
112012 , p_source_84 IN NUMBER
112013 --Distribution Type
112014 , p_source_85 IN VARCHAR2
112015 , p_source_85_meaning IN VARCHAR2
112016 --Entered Currency Code
112017 , p_source_88 IN VARCHAR2
112018 --Entered Amount
112019 , p_source_91 IN NUMBER
112020 --Currency Conversion Date
112021 , p_source_92 IN DATE
112022 --Currency Conversion Rate
112023 , p_source_93 IN NUMBER
112024 --Currency Conversion Type
112025 , p_source_94 IN VARCHAR2
112026 --Accounted Amount
112027 , p_source_95 IN NUMBER
112028 --Accounting Line Type
112029 , p_source_97 IN NUMBER
112030 )
112031 IS
112032
112033 l_component_type VARCHAR2(80);
112034 l_component_code VARCHAR2(30);
112035 l_component_type_code VARCHAR2(1);
112036 l_component_appl_id INTEGER;
112037 l_amb_context_code VARCHAR2(30);
112038 l_entity_code VARCHAR2(30);
112039 l_event_class_code VARCHAR2(30);
112040 l_ae_header_id NUMBER;
112041 l_event_type_code VARCHAR2(30);
112042 l_line_definition_code VARCHAR2(30);
112043 l_line_definition_owner_code VARCHAR2(1);
112044 --
112045 -- adr variables
112046 l_segment VARCHAR2(30);
112047 l_ccid NUMBER;
112048 l_adr_transaction_coa_id NUMBER;
112049 l_adr_accounting_coa_id NUMBER;
112050 l_adr_flexfield_segment_code VARCHAR2(30);
112051 l_adr_flex_value_set_id NUMBER;
112052 l_adr_value_type_code VARCHAR2(30);
112053 l_adr_value_combination_id NUMBER;
112054 l_adr_value_segment_code VARCHAR2(30);
112055
112056 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
112057 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
112058 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
112059 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
112060
112061 -- 4262811 Variables ------------------------------------------------------------------------------------------
112062 l_entered_amt_idx NUMBER;
112063 l_accted_amt_idx NUMBER;
112064 l_acc_rev_flag VARCHAR2(1);
112065 l_accrual_line_num NUMBER;
112066 l_tmp_amt NUMBER;
112067 l_acc_rev_natural_side_code VARCHAR2(1);
112068
112069 l_num_entries NUMBER;
112070 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
112071 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
112072 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
112073 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
112074 l_recog_line_1 NUMBER;
112075 l_recog_line_2 NUMBER;
112076
112077 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
112078 l_bflow_applied_to_amt NUMBER; -- 5132302
112079 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
112080
112081 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
112082
112083 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
112084 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
112085
112086 ---------------------------------------------------------------------------------------------------------------
112087
112088
112089 --
112090 -- bulk performance
112091 --
112092 l_balance_type_code VARCHAR2(1);
112093 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
112094 l_log_module VARCHAR2(240);
112095
112096 --
112097 -- Upgrade strategy
112098 --
112099 l_actual_upg_option VARCHAR2(1);
112100 l_enc_upg_option VARCHAR2(1);
112101
112102 --
112103 BEGIN
112104 --
112105 IF g_log_enabled THEN
112106 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_220';
112107 END IF;
112108 --
112109 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
112110
112111 trace
112112 (p_msg => 'BEGIN of AcctLineType_220'
112113 ,p_level => C_LEVEL_PROCEDURE
112114 ,p_module => l_log_module);
112115
112116 END IF;
112117 --
112118 l_component_type := 'AMB_JLT';
112119 l_component_code := 'INTRANSIT_VALUATION';
112120 l_component_type_code := 'S';
112121 l_component_appl_id := 707;
112122 l_amb_context_code := 'DEFAULT';
112123 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
112124 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
112125 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
112126 l_line_definition_owner_code := 'S';
112127 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
112128 --
112129 l_balance_type_code := 'A';
112130 l_segment := NULL;
112131 l_ccid := NULL;
112132 l_adr_transaction_coa_id := NULL;
112133 l_adr_accounting_coa_id := NULL;
112134 l_adr_flexfield_segment_code := NULL;
112135 l_adr_flex_value_set_id := NULL;
112136 l_adr_value_type_code := NULL;
112137 l_adr_value_combination_id := NULL;
112138 l_adr_value_segment_code := NULL;
112139
112140 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
112141 l_bflow_class_code := ''; -- 4219869 Business Flow
112142 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
112143 l_budgetary_control_flag := 'N';
112144
112145 l_bflow_applied_to_amt_idx := NULL; -- 5132302
112146 l_bflow_applied_to_amt := NULL; -- 5132302
112147 l_entered_amt_idx := NULL; -- 4262811
112148 l_accted_amt_idx := NULL; -- 4262811
112149 l_acc_rev_flag := NULL; -- 4262811
112150 l_accrual_line_num := NULL; -- 4262811
112151 l_tmp_amt := NULL; -- 4262811
112152 --
112153
112154 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
112155 l_balance_type_code <> 'B' THEN
112156 IF NVL(p_source_97,9E125) = 14
112157 THEN
112158
112159 --
112160 XLA_AE_LINES_PKG.SetNewLine;
112161
112162 p_balance_type_code := l_balance_type_code;
112163 -- set the flag so later we will know whether the gain loss line needs to be created
112164
112165 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
112166 p_actual_flag :='A';
112167 END IF;
112168
112169 --
112170 -- bulk performance
112171 --
112172 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
112173 p_header_num => 0); -- 4262811
112174 --
112175 -- set accounting line options
112176 --
112177 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
112178 p_natural_side_code => 'D'
112179 , p_gain_or_loss_flag => 'N'
112180 , p_gl_transfer_mode_code => 'S'
112181 , p_acct_entry_type_code => 'A'
112182 , p_switch_side_flag => 'Y'
112183 , p_merge_duplicate_code => 'N'
112184 );
112185 --
112186 l_acc_rev_natural_side_code := 'C'; -- 4262811
112187 --
112188 --
112189 -- set accounting line type info
112190 --
112191 xla_ae_lines_pkg.SetAcctLineType
112192 (p_component_type => l_component_type
112193 ,p_event_type_code => l_event_type_code
112194 ,p_line_definition_owner_code => l_line_definition_owner_code
112195 ,p_line_definition_code => l_line_definition_code
112196 ,p_accounting_line_code => l_component_code
112197 ,p_accounting_line_type_code => l_component_type_code
112198 ,p_accounting_line_appl_id => l_component_appl_id
112199 ,p_amb_context_code => l_amb_context_code
112200 ,p_entity_code => l_entity_code
112201 ,p_event_class_code => l_event_class_code);
112202 --
112203 -- set accounting class
112204 --
112205 xla_ae_lines_pkg.SetAcctClass(
112206 p_accounting_class_code => 'INTRANSIT_VALUATION'
112207 , p_ae_header_id => l_ae_header_id
112208 );
112209
112210 --
112211 -- set rounding class
112212 --
112213 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
112214 'INTRANSIT_VALUATION';
112215
112216 --
112217 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
112218 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
112219 --
112220 -- bulk performance
112221 --
112222 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
112223
112224 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
112225 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
112226
112227 -- 4955764
112228 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
112229 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
112230
112231 -- 4458381 Public Sector Enh
112232
112233 --
112234 -- set accounting attributes for the line type
112235 --
112236 l_entered_amt_idx := 3;
112237 l_accted_amt_idx := 8;
112238 l_bflow_applied_to_amt_idx := NULL; -- 5132302
112239 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
112240 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
112241 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
112242 l_rec_acct_attrs.array_char_value(2) := p_source_85;
112243 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
112244 l_rec_acct_attrs.array_num_value(3) := p_source_91;
112245 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
112246 l_rec_acct_attrs.array_char_value(4) := p_source_88;
112247 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
112248 l_rec_acct_attrs.array_date_value(5) := p_source_92;
112249 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
112250 l_rec_acct_attrs.array_num_value(6) := p_source_93;
112251 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
112252 l_rec_acct_attrs.array_char_value(7) := p_source_94;
112253 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
112254 l_rec_acct_attrs.array_num_value(8) := p_source_95;
112255
112256 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
112257 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
112258
112259 ---------------------------------------------------------------------------------------------------------------
112260 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
112261 ---------------------------------------------------------------------------------------------------------------
112262 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
112263
112264 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
112265 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
112266
112267 IF xla_accounting_cache_pkg.GetValueChar
112268 (p_source_code => 'LEDGER_CATEGORY_CODE'
112269 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
112270 AND l_bflow_method_code = 'PRIOR_ENTRY'
112271 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
112272 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
112273 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
112274 )
112275 THEN
112276 xla_ae_lines_pkg.BflowUpgEntry
112277 (p_business_method_code => l_bflow_method_code
112278 ,p_business_class_code => l_bflow_class_code
112279 ,p_balance_type => l_balance_type_code);
112280 ELSE
112281 NULL;
112282 -- No business flow processing for business flow method of NONE.
112283 END IF;
112284
112285 --
112286 -- call analytical criteria
112287 --
112288
112289 --
112290 -- call description
112291 --
112292
112293 xla_ae_lines_pkg.SetLineDescription(
112294 p_ae_header_id => l_ae_header_id
112295 ,p_description => Description_1 (
112296 p_application_id => p_application_id
112297 , p_ae_header_id => l_ae_header_id
112298 , p_source_1 => p_source_1
112299 , p_source_2 => p_source_2
112300 , p_source_3 => p_source_3
112301 , p_source_4 => p_source_4
112302 , p_source_5 => p_source_5
112303 )
112304 );
112305
112306
112307 --
112308 -- call ADRs
112309 -- Bug 4922099
112310 --
112311 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
112312 (NVL(l_actual_upg_option, 'N') = 'O') OR
112313 (NVL(l_enc_upg_option, 'N') = 'O')
112314 )
112315 THEN
112316 NULL;
112317 --
112318 --
112319
112320 l_ccid := AcctDerRule_25(
112321 p_application_id => p_application_id
112322 , p_ae_header_id => l_ae_header_id
112323 , p_source_11 => p_source_11
112324 , p_source_15 => p_source_15
112325 , p_source_39 => p_source_39
112326 , p_source_39_meaning => p_source_39_meaning
112327 , p_source_41 => p_source_41
112328 , p_source_42 => p_source_42
112329 , p_source_43 => p_source_43
112330 , p_source_44 => p_source_44
112331 , p_source_45 => p_source_45
112332 , x_transaction_coa_id => l_adr_transaction_coa_id
112333 , x_accounting_coa_id => l_adr_accounting_coa_id
112334 , x_value_type_code => l_adr_value_type_code
112335 , p_side => 'NA'
112336 );
112337
112338 xla_ae_lines_pkg.set_ccid(
112339 p_code_combination_id => l_ccid
112340 , p_value_type_code => l_adr_value_type_code
112341 , p_transaction_coa_id => l_adr_transaction_coa_id
112342 , p_accounting_coa_id => l_adr_accounting_coa_id
112343 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
112344 , p_adr_type_code => 'S'
112345 , p_component_type => l_component_type
112346 , p_component_code => l_component_code
112347 , p_component_type_code => l_component_type_code
112348 , p_component_appl_id => l_component_appl_id
112349 , p_amb_context_code => l_amb_context_code
112350 , p_side => 'NA'
112351 );
112352
112353
112354 --
112355 --
112356 END IF;
112357 --
112358 -- Bug 4922099
112359 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
112360 (NVL(l_enc_upg_option, 'N') = 'O')
112361 ) AND
112362 (l_bflow_method_code = 'PRIOR_ENTRY')
112363 )
112364 THEN
112365 IF
112366 --
112367 1 = 2
112368 --
112369 THEN
112370 xla_accounting_err_pkg.build_message
112371 (p_appli_s_name => 'XLA'
112372 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
112373 ,p_token_1 => 'LINE_NUMBER'
112374 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
112375 ,p_token_2 => 'LINE_TYPE_NAME'
112376 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
112377 l_component_type
112378 ,l_component_code
112379 ,l_component_type_code
112380 ,l_component_appl_id
112381 ,l_amb_context_code
112382 ,l_entity_code
112383 ,l_event_class_code
112384 )
112385 ,p_token_3 => 'OWNER'
112386 ,p_value_3 => xla_lookups_pkg.get_meaning(
112387 p_lookup_type => 'XLA_OWNER_TYPE'
112388 ,p_lookup_code => l_component_type_code
112389 )
112390 ,p_token_4 => 'PRODUCT_NAME'
112391 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
112392 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
112393 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
112394 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
112395 ,p_ae_header_id => NULL
112396 );
112397
112398 IF (C_LEVEL_ERROR>= g_log_level) THEN
112399 trace
112400 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
112401 ,p_level => C_LEVEL_ERROR
112402 ,p_module => l_log_module);
112403 END IF;
112404 END IF;
112405 END IF;
112406 --
112407 --
112408 ------------------------------------------------------------------------------------------------
112409 -- 4219869 Business Flow
112410 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
112411 -- Prior Entry. Currently, the following code is always generated.
112412 ------------------------------------------------------------------------------------------------
112413 XLA_AE_LINES_PKG.ValidateCurrentLine;
112414
112415 ------------------------------------------------------------------------------------
112416 -- 4219869 Business Flow
112417 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
112418 ------------------------------------------------------------------------------------
112419 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
112420
112421 ----------------------------------------------------------------------------------
112422 -- 4219869 Business Flow
112423 -- Update journal entry status -- Need to generate this within IF <condition>
112424 ----------------------------------------------------------------------------------
112425 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
112426 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
112427 ,p_balance_type_code => l_balance_type_code
112428 );
112429
112430 -------------------------------------------------------------------------------------------
112431 -- 4262811 - Generate the Accrual Reversal lines
112432 -------------------------------------------------------------------------------------------
112433 BEGIN
112434 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
112435 (g_array_event(p_event_id).array_value_num('header_index'));
112436 IF l_acc_rev_flag IS NULL THEN
112437 l_acc_rev_flag := 'N';
112438 END IF;
112439 EXCEPTION
112440 WHEN OTHERS THEN
112441 l_acc_rev_flag := 'N';
112442 END;
112443 --
112444 IF (l_acc_rev_flag = 'Y') THEN
112445
112446 -- 4645092 ------------------------------------------------------------------------------
112447 -- To allow MPA report to determine if it should generate report process
112448 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
112449 ------------------------------------------------------------------------------------------
112450
112451 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
112452 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
112453 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
112454 -- call ADRs
112455 -- Bug 4922099
112456 --
112457 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
112458 (NVL(l_actual_upg_option, 'N') = 'O') OR
112459 (NVL(l_enc_upg_option, 'N') = 'O')
112460 )
112461 THEN
112462 NULL;
112463 --
112464 --
112465
112466 l_ccid := AcctDerRule_25(
112467 p_application_id => p_application_id
112468 , p_ae_header_id => l_ae_header_id
112469 , p_source_11 => p_source_11
112470 , p_source_15 => p_source_15
112471 , p_source_39 => p_source_39
112472 , p_source_39_meaning => p_source_39_meaning
112473 , p_source_41 => p_source_41
112474 , p_source_42 => p_source_42
112475 , p_source_43 => p_source_43
112476 , p_source_44 => p_source_44
112477 , p_source_45 => p_source_45
112478 , x_transaction_coa_id => l_adr_transaction_coa_id
112479 , x_accounting_coa_id => l_adr_accounting_coa_id
112480 , x_value_type_code => l_adr_value_type_code
112481 , p_side => 'NA'
112482 );
112483
112484 xla_ae_lines_pkg.set_ccid(
112485 p_code_combination_id => l_ccid
112486 , p_value_type_code => l_adr_value_type_code
112487 , p_transaction_coa_id => l_adr_transaction_coa_id
112488 , p_accounting_coa_id => l_adr_accounting_coa_id
112489 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
112490 , p_adr_type_code => 'S'
112491 , p_component_type => l_component_type
112492 , p_component_code => l_component_code
112493 , p_component_type_code => l_component_type_code
112494 , p_component_appl_id => l_component_appl_id
112495 , p_amb_context_code => l_amb_context_code
112496 , p_side => 'NA'
112497 );
112498
112499
112500 --
112501 --
112502 END IF;
112503
112504 --
112505 -- Update the line information that should be overwritten
112506 --
112507 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
112508 p_header_num => 1);
112509 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
112510
112511 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
112512
112513 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
112514 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
112515 END IF;
112516
112517 --
112518 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
112519 --
112520 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
112521 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
112522 ELSE
112523 ---------------------------------------------------------------------------------------------------
112524 -- 4262811a Switch Sign
112525 ---------------------------------------------------------------------------------------------------
112526 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
112527 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
112528 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
112529 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
112530 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
112531 -- 5132302
112532 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
112533 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
112534
112535 END IF;
112536
112537 -- 4955764
112538 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
112539 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
112540
112541
112542 XLA_AE_LINES_PKG.ValidateCurrentLine;
112543 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
112544
112545 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
112546 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
112547 ,p_balance_type_code => l_balance_type_code);
112548
112549 END IF;
112550
112551 -----------------------------------------------------------------------------------------
112552 -- 4262811 Multiperiod Accounting
112553 -----------------------------------------------------------------------------------------
112554 -- No MPA option is assigned.
112555
112556
112557 END IF;
112558 END IF;
112559 --
112560
112561 --
112562 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
112563 trace
112564 (p_msg => 'END of AcctLineType_220'
112565 ,p_level => C_LEVEL_PROCEDURE
112566 ,p_module => l_log_module);
112567 END IF;
112568 --
112569 EXCEPTION
112570 WHEN xla_exceptions_pkg.application_exception THEN
112571 RAISE;
112572 WHEN OTHERS THEN
112573 xla_exceptions_pkg.raise_message
112574 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_220');
112575 END AcctLineType_220;
112576 --
112577
112578 ---------------------------------------
112579 --
112580 -- PRIVATE FUNCTION
112581 -- AcctLineType_221
112582 --
112583 ---------------------------------------
112584 PROCEDURE AcctLineType_221 (
112585 p_application_id IN NUMBER
112586 ,p_event_id IN NUMBER
112587 ,p_calculate_acctd_flag IN VARCHAR2
112588 ,p_calculate_g_l_flag IN VARCHAR2
112589 ,p_actual_flag IN OUT VARCHAR2
112590 ,p_balance_type_code OUT VARCHAR2
112591 ,p_gain_or_loss_ref OUT VARCHAR2
112592
112593 --TRANSACTION_ID
112594 , p_source_1 IN NUMBER
112595 --Item Concatenated Segments
112596 , p_source_2 IN VARCHAR2
112597 --Transaction Quantity
112598 , p_source_3 IN NUMBER
112599 --Transaction Unit of Measure Code
112600 , p_source_4 IN VARCHAR2
112601 --Inventory Transaction Type Description
112602 , p_source_5 IN VARCHAR2
112603 --Cost Management Default Account
112604 , p_source_11 IN NUMBER
112605 --Cost Element Name
112606 , p_source_15 IN NUMBER
112607 --Primary Cost Method
112608 , p_source_39 IN NUMBER
112609 , p_source_39_meaning IN VARCHAR2
112610 --Product Line Accounting Category Material Account
112611 , p_source_41 IN NUMBER
112612 --Product Line Accounting Category Material Overhead Account
112613 , p_source_42 IN NUMBER
112614 --Product Line Accounting Category Resource Account
112615 , p_source_43 IN NUMBER
112616 --Product Line Accounting Category Outside Processing Account
112617 , p_source_44 IN NUMBER
112618 --Product Line Accounting Category Overhead Account
112619 , p_source_45 IN NUMBER
112620 --DISTRIBUTION_IDENTIFIER
112621 , p_source_84 IN NUMBER
112622 --Distribution Type
112623 , p_source_85 IN VARCHAR2
112624 , p_source_85_meaning IN VARCHAR2
112625 --Entered Currency Code
112626 , p_source_88 IN VARCHAR2
112627 --Entered Amount
112628 , p_source_91 IN NUMBER
112629 --Currency Conversion Date
112630 , p_source_92 IN DATE
112631 --Currency Conversion Rate
112632 , p_source_93 IN NUMBER
112633 --Currency Conversion Type
112634 , p_source_94 IN VARCHAR2
112635 --Accounted Amount
112636 , p_source_95 IN NUMBER
112637 --Accounting Line Type
112638 , p_source_97 IN NUMBER
112639 )
112640 IS
112641
112642 l_component_type VARCHAR2(80);
112643 l_component_code VARCHAR2(30);
112644 l_component_type_code VARCHAR2(1);
112645 l_component_appl_id INTEGER;
112646 l_amb_context_code VARCHAR2(30);
112647 l_entity_code VARCHAR2(30);
112648 l_event_class_code VARCHAR2(30);
112649 l_ae_header_id NUMBER;
112650 l_event_type_code VARCHAR2(30);
112651 l_line_definition_code VARCHAR2(30);
112652 l_line_definition_owner_code VARCHAR2(1);
112653 --
112654 -- adr variables
112655 l_segment VARCHAR2(30);
112656 l_ccid NUMBER;
112657 l_adr_transaction_coa_id NUMBER;
112658 l_adr_accounting_coa_id NUMBER;
112659 l_adr_flexfield_segment_code VARCHAR2(30);
112660 l_adr_flex_value_set_id NUMBER;
112661 l_adr_value_type_code VARCHAR2(30);
112662 l_adr_value_combination_id NUMBER;
112663 l_adr_value_segment_code VARCHAR2(30);
112664
112665 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
112666 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
112667 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
112668 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
112669
112670 -- 4262811 Variables ------------------------------------------------------------------------------------------
112671 l_entered_amt_idx NUMBER;
112672 l_accted_amt_idx NUMBER;
112673 l_acc_rev_flag VARCHAR2(1);
112674 l_accrual_line_num NUMBER;
112675 l_tmp_amt NUMBER;
112676 l_acc_rev_natural_side_code VARCHAR2(1);
112677
112678 l_num_entries NUMBER;
112679 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
112680 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
112681 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
112682 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
112683 l_recog_line_1 NUMBER;
112684 l_recog_line_2 NUMBER;
112685
112686 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
112687 l_bflow_applied_to_amt NUMBER; -- 5132302
112688 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
112689
112690 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
112691
112692 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
112693 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
112694
112695 ---------------------------------------------------------------------------------------------------------------
112696
112697
112698 --
112699 -- bulk performance
112700 --
112701 l_balance_type_code VARCHAR2(1);
112702 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
112703 l_log_module VARCHAR2(240);
112704
112705 --
112706 -- Upgrade strategy
112707 --
112708 l_actual_upg_option VARCHAR2(1);
112709 l_enc_upg_option VARCHAR2(1);
112710
112711 --
112712 BEGIN
112713 --
112714 IF g_log_enabled THEN
112715 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_221';
112716 END IF;
112717 --
112718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
112719
112720 trace
112721 (p_msg => 'BEGIN of AcctLineType_221'
112722 ,p_level => C_LEVEL_PROCEDURE
112723 ,p_module => l_log_module);
112724
112725 END IF;
112726 --
112727 l_component_type := 'AMB_JLT';
112728 l_component_code := 'INTRANSIT_VALUATION';
112729 l_component_type_code := 'S';
112730 l_component_appl_id := 707;
112731 l_amb_context_code := 'DEFAULT';
112732 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
112733 l_event_class_code := 'MTL_COST_UPD';
112734 l_event_type_code := 'STD_COST_UPD';
112735 l_line_definition_owner_code := 'S';
112736 l_line_definition_code := 'PI_STD_COST_UPD';
112737 --
112738 l_balance_type_code := 'A';
112739 l_segment := NULL;
112740 l_ccid := NULL;
112741 l_adr_transaction_coa_id := NULL;
112742 l_adr_accounting_coa_id := NULL;
112743 l_adr_flexfield_segment_code := NULL;
112744 l_adr_flex_value_set_id := NULL;
112745 l_adr_value_type_code := NULL;
112746 l_adr_value_combination_id := NULL;
112747 l_adr_value_segment_code := NULL;
112748
112749 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
112750 l_bflow_class_code := ''; -- 4219869 Business Flow
112751 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
112752 l_budgetary_control_flag := 'N';
112753
112754 l_bflow_applied_to_amt_idx := NULL; -- 5132302
112755 l_bflow_applied_to_amt := NULL; -- 5132302
112756 l_entered_amt_idx := NULL; -- 4262811
112757 l_accted_amt_idx := NULL; -- 4262811
112758 l_acc_rev_flag := NULL; -- 4262811
112759 l_accrual_line_num := NULL; -- 4262811
112760 l_tmp_amt := NULL; -- 4262811
112761 --
112762
112763 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
112764 l_balance_type_code <> 'B' THEN
112765 IF NVL(p_source_97,9E125) = 14
112766 THEN
112767
112768 --
112769 XLA_AE_LINES_PKG.SetNewLine;
112770
112771 p_balance_type_code := l_balance_type_code;
112772 -- set the flag so later we will know whether the gain loss line needs to be created
112773
112774 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
112775 p_actual_flag :='A';
112776 END IF;
112777
112778 --
112779 -- bulk performance
112780 --
112781 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
112782 p_header_num => 0); -- 4262811
112783 --
112784 -- set accounting line options
112785 --
112786 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
112787 p_natural_side_code => 'D'
112788 , p_gain_or_loss_flag => 'N'
112789 , p_gl_transfer_mode_code => 'S'
112790 , p_acct_entry_type_code => 'A'
112791 , p_switch_side_flag => 'Y'
112792 , p_merge_duplicate_code => 'N'
112793 );
112794 --
112795 l_acc_rev_natural_side_code := 'C'; -- 4262811
112796 --
112797 --
112798 -- set accounting line type info
112799 --
112800 xla_ae_lines_pkg.SetAcctLineType
112801 (p_component_type => l_component_type
112802 ,p_event_type_code => l_event_type_code
112803 ,p_line_definition_owner_code => l_line_definition_owner_code
112804 ,p_line_definition_code => l_line_definition_code
112805 ,p_accounting_line_code => l_component_code
112806 ,p_accounting_line_type_code => l_component_type_code
112807 ,p_accounting_line_appl_id => l_component_appl_id
112808 ,p_amb_context_code => l_amb_context_code
112809 ,p_entity_code => l_entity_code
112810 ,p_event_class_code => l_event_class_code);
112811 --
112812 -- set accounting class
112813 --
112814 xla_ae_lines_pkg.SetAcctClass(
112815 p_accounting_class_code => 'INTRANSIT_VALUATION'
112816 , p_ae_header_id => l_ae_header_id
112817 );
112818
112819 --
112820 -- set rounding class
112821 --
112822 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
112823 'INTRANSIT_VALUATION';
112824
112825 --
112826 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
112827 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
112828 --
112829 -- bulk performance
112830 --
112831 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
112832
112833 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
112834 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
112835
112836 -- 4955764
112837 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
112838 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
112839
112840 -- 4458381 Public Sector Enh
112841
112842 --
112843 -- set accounting attributes for the line type
112844 --
112845 l_entered_amt_idx := 3;
112846 l_accted_amt_idx := 8;
112847 l_bflow_applied_to_amt_idx := NULL; -- 5132302
112848 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
112849 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
112850 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
112851 l_rec_acct_attrs.array_char_value(2) := p_source_85;
112852 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
112853 l_rec_acct_attrs.array_num_value(3) := p_source_91;
112854 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
112855 l_rec_acct_attrs.array_char_value(4) := p_source_88;
112856 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
112857 l_rec_acct_attrs.array_date_value(5) := p_source_92;
112858 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
112859 l_rec_acct_attrs.array_num_value(6) := p_source_93;
112860 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
112861 l_rec_acct_attrs.array_char_value(7) := p_source_94;
112862 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
112863 l_rec_acct_attrs.array_num_value(8) := p_source_95;
112864
112865 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
112866 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
112867
112868 ---------------------------------------------------------------------------------------------------------------
112869 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
112870 ---------------------------------------------------------------------------------------------------------------
112871 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
112872
112873 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
112874 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
112875
112876 IF xla_accounting_cache_pkg.GetValueChar
112877 (p_source_code => 'LEDGER_CATEGORY_CODE'
112878 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
112879 AND l_bflow_method_code = 'PRIOR_ENTRY'
112880 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
112881 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
112882 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
112883 )
112884 THEN
112885 xla_ae_lines_pkg.BflowUpgEntry
112886 (p_business_method_code => l_bflow_method_code
112887 ,p_business_class_code => l_bflow_class_code
112888 ,p_balance_type => l_balance_type_code);
112889 ELSE
112890 NULL;
112891 -- No business flow processing for business flow method of NONE.
112892 END IF;
112893
112894 --
112895 -- call analytical criteria
112896 --
112897
112898 --
112899 -- call description
112900 --
112901
112902 xla_ae_lines_pkg.SetLineDescription(
112903 p_ae_header_id => l_ae_header_id
112904 ,p_description => Description_1 (
112905 p_application_id => p_application_id
112906 , p_ae_header_id => l_ae_header_id
112907 , p_source_1 => p_source_1
112908 , p_source_2 => p_source_2
112909 , p_source_3 => p_source_3
112910 , p_source_4 => p_source_4
112911 , p_source_5 => p_source_5
112912 )
112913 );
112914
112915
112916 --
112917 -- call ADRs
112918 -- Bug 4922099
112919 --
112920 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
112921 (NVL(l_actual_upg_option, 'N') = 'O') OR
112922 (NVL(l_enc_upg_option, 'N') = 'O')
112923 )
112924 THEN
112925 NULL;
112926 --
112927 --
112928
112929 l_ccid := AcctDerRule_25(
112930 p_application_id => p_application_id
112931 , p_ae_header_id => l_ae_header_id
112932 , p_source_11 => p_source_11
112933 , p_source_15 => p_source_15
112934 , p_source_39 => p_source_39
112935 , p_source_39_meaning => p_source_39_meaning
112936 , p_source_41 => p_source_41
112937 , p_source_42 => p_source_42
112938 , p_source_43 => p_source_43
112939 , p_source_44 => p_source_44
112940 , p_source_45 => p_source_45
112941 , x_transaction_coa_id => l_adr_transaction_coa_id
112942 , x_accounting_coa_id => l_adr_accounting_coa_id
112943 , x_value_type_code => l_adr_value_type_code
112944 , p_side => 'NA'
112945 );
112946
112947 xla_ae_lines_pkg.set_ccid(
112948 p_code_combination_id => l_ccid
112949 , p_value_type_code => l_adr_value_type_code
112950 , p_transaction_coa_id => l_adr_transaction_coa_id
112951 , p_accounting_coa_id => l_adr_accounting_coa_id
112952 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
112953 , p_adr_type_code => 'S'
112954 , p_component_type => l_component_type
112955 , p_component_code => l_component_code
112956 , p_component_type_code => l_component_type_code
112957 , p_component_appl_id => l_component_appl_id
112958 , p_amb_context_code => l_amb_context_code
112959 , p_side => 'NA'
112960 );
112961
112962
112963 --
112964 --
112965 END IF;
112966 --
112967 -- Bug 4922099
112968 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
112969 (NVL(l_enc_upg_option, 'N') = 'O')
112970 ) AND
112971 (l_bflow_method_code = 'PRIOR_ENTRY')
112972 )
112973 THEN
112974 IF
112975 --
112976 1 = 2
112977 --
112978 THEN
112979 xla_accounting_err_pkg.build_message
112980 (p_appli_s_name => 'XLA'
112981 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
112982 ,p_token_1 => 'LINE_NUMBER'
112983 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
112984 ,p_token_2 => 'LINE_TYPE_NAME'
112985 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
112986 l_component_type
112987 ,l_component_code
112988 ,l_component_type_code
112989 ,l_component_appl_id
112990 ,l_amb_context_code
112991 ,l_entity_code
112992 ,l_event_class_code
112993 )
112994 ,p_token_3 => 'OWNER'
112995 ,p_value_3 => xla_lookups_pkg.get_meaning(
112996 p_lookup_type => 'XLA_OWNER_TYPE'
112997 ,p_lookup_code => l_component_type_code
112998 )
112999 ,p_token_4 => 'PRODUCT_NAME'
113000 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
113001 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
113002 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
113003 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
113004 ,p_ae_header_id => NULL
113005 );
113006
113007 IF (C_LEVEL_ERROR>= g_log_level) THEN
113008 trace
113009 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
113010 ,p_level => C_LEVEL_ERROR
113011 ,p_module => l_log_module);
113012 END IF;
113013 END IF;
113014 END IF;
113015 --
113016 --
113017 ------------------------------------------------------------------------------------------------
113018 -- 4219869 Business Flow
113019 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
113020 -- Prior Entry. Currently, the following code is always generated.
113021 ------------------------------------------------------------------------------------------------
113022 XLA_AE_LINES_PKG.ValidateCurrentLine;
113023
113024 ------------------------------------------------------------------------------------
113025 -- 4219869 Business Flow
113026 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
113027 ------------------------------------------------------------------------------------
113028 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
113029
113030 ----------------------------------------------------------------------------------
113031 -- 4219869 Business Flow
113032 -- Update journal entry status -- Need to generate this within IF <condition>
113033 ----------------------------------------------------------------------------------
113034 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
113035 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
113036 ,p_balance_type_code => l_balance_type_code
113037 );
113038
113039 -------------------------------------------------------------------------------------------
113040 -- 4262811 - Generate the Accrual Reversal lines
113041 -------------------------------------------------------------------------------------------
113042 BEGIN
113043 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
113044 (g_array_event(p_event_id).array_value_num('header_index'));
113045 IF l_acc_rev_flag IS NULL THEN
113046 l_acc_rev_flag := 'N';
113047 END IF;
113048 EXCEPTION
113049 WHEN OTHERS THEN
113050 l_acc_rev_flag := 'N';
113051 END;
113052 --
113053 IF (l_acc_rev_flag = 'Y') THEN
113054
113055 -- 4645092 ------------------------------------------------------------------------------
113056 -- To allow MPA report to determine if it should generate report process
113057 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
113058 ------------------------------------------------------------------------------------------
113059
113060 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
113061 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
113062 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
113063 -- call ADRs
113064 -- Bug 4922099
113065 --
113066 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
113067 (NVL(l_actual_upg_option, 'N') = 'O') OR
113068 (NVL(l_enc_upg_option, 'N') = 'O')
113069 )
113070 THEN
113071 NULL;
113072 --
113073 --
113074
113075 l_ccid := AcctDerRule_25(
113076 p_application_id => p_application_id
113077 , p_ae_header_id => l_ae_header_id
113078 , p_source_11 => p_source_11
113079 , p_source_15 => p_source_15
113080 , p_source_39 => p_source_39
113081 , p_source_39_meaning => p_source_39_meaning
113082 , p_source_41 => p_source_41
113083 , p_source_42 => p_source_42
113084 , p_source_43 => p_source_43
113085 , p_source_44 => p_source_44
113086 , p_source_45 => p_source_45
113087 , x_transaction_coa_id => l_adr_transaction_coa_id
113088 , x_accounting_coa_id => l_adr_accounting_coa_id
113089 , x_value_type_code => l_adr_value_type_code
113090 , p_side => 'NA'
113091 );
113092
113093 xla_ae_lines_pkg.set_ccid(
113094 p_code_combination_id => l_ccid
113095 , p_value_type_code => l_adr_value_type_code
113096 , p_transaction_coa_id => l_adr_transaction_coa_id
113097 , p_accounting_coa_id => l_adr_accounting_coa_id
113098 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
113099 , p_adr_type_code => 'S'
113100 , p_component_type => l_component_type
113101 , p_component_code => l_component_code
113102 , p_component_type_code => l_component_type_code
113103 , p_component_appl_id => l_component_appl_id
113104 , p_amb_context_code => l_amb_context_code
113105 , p_side => 'NA'
113106 );
113107
113108
113109 --
113110 --
113111 END IF;
113112
113113 --
113114 -- Update the line information that should be overwritten
113115 --
113116 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
113117 p_header_num => 1);
113118 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
113119
113120 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
113121
113122 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
113123 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
113124 END IF;
113125
113126 --
113127 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
113128 --
113129 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
113130 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
113131 ELSE
113132 ---------------------------------------------------------------------------------------------------
113133 -- 4262811a Switch Sign
113134 ---------------------------------------------------------------------------------------------------
113135 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
113136 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
113137 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113138 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
113139 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113140 -- 5132302
113141 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
113142 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113143
113144 END IF;
113145
113146 -- 4955764
113147 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
113148 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
113149
113150
113151 XLA_AE_LINES_PKG.ValidateCurrentLine;
113152 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
113153
113154 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
113155 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
113156 ,p_balance_type_code => l_balance_type_code);
113157
113158 END IF;
113159
113160 -----------------------------------------------------------------------------------------
113161 -- 4262811 Multiperiod Accounting
113162 -----------------------------------------------------------------------------------------
113163 -- No MPA option is assigned.
113164
113165
113166 END IF;
113167 END IF;
113168 --
113169
113170 --
113171 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
113172 trace
113173 (p_msg => 'END of AcctLineType_221'
113174 ,p_level => C_LEVEL_PROCEDURE
113175 ,p_module => l_log_module);
113176 END IF;
113177 --
113178 EXCEPTION
113179 WHEN xla_exceptions_pkg.application_exception THEN
113180 RAISE;
113181 WHEN OTHERS THEN
113182 xla_exceptions_pkg.raise_message
113183 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_221');
113184 END AcctLineType_221;
113185 --
113186
113187 ---------------------------------------
113188 --
113189 -- PRIVATE FUNCTION
113190 -- AcctLineType_222
113191 --
113192 ---------------------------------------
113193 PROCEDURE AcctLineType_222 (
113194 p_application_id IN NUMBER
113195 ,p_event_id IN NUMBER
113196 ,p_calculate_acctd_flag IN VARCHAR2
113197 ,p_calculate_g_l_flag IN VARCHAR2
113198 ,p_actual_flag IN OUT VARCHAR2
113199 ,p_balance_type_code OUT VARCHAR2
113200 ,p_gain_or_loss_ref OUT VARCHAR2
113201
113202 --TRANSACTION_ID
113203 , p_source_1 IN NUMBER
113204 --Item Concatenated Segments
113205 , p_source_2 IN VARCHAR2
113206 --Transaction Quantity
113207 , p_source_3 IN NUMBER
113208 --Transaction Unit of Measure Code
113209 , p_source_4 IN VARCHAR2
113210 --Inventory Transaction Type Description
113211 , p_source_5 IN VARCHAR2
113212 --Cost Management Default Account
113213 , p_source_11 IN NUMBER
113214 --Cost Element Name
113215 , p_source_15 IN NUMBER
113216 --Primary Cost Method
113217 , p_source_39 IN NUMBER
113218 , p_source_39_meaning IN VARCHAR2
113219 --Product Line Accounting Category Material Account
113220 , p_source_41 IN NUMBER
113221 --Product Line Accounting Category Material Overhead Account
113222 , p_source_42 IN NUMBER
113223 --Product Line Accounting Category Resource Account
113224 , p_source_43 IN NUMBER
113225 --Product Line Accounting Category Outside Processing Account
113226 , p_source_44 IN NUMBER
113227 --Product Line Accounting Category Overhead Account
113228 , p_source_45 IN NUMBER
113229 --DISTRIBUTION_IDENTIFIER
113230 , p_source_84 IN NUMBER
113231 --Distribution Type
113232 , p_source_85 IN VARCHAR2
113233 , p_source_85_meaning IN VARCHAR2
113234 --Entered Currency Code
113235 , p_source_88 IN VARCHAR2
113236 --Entered Amount
113237 , p_source_91 IN NUMBER
113238 --Currency Conversion Date
113239 , p_source_92 IN DATE
113240 --Currency Conversion Rate
113241 , p_source_93 IN NUMBER
113242 --Currency Conversion Type
113243 , p_source_94 IN VARCHAR2
113244 --Accounted Amount
113245 , p_source_95 IN NUMBER
113246 --Accounting Line Type
113247 , p_source_97 IN NUMBER
113248 )
113249 IS
113250
113251 l_component_type VARCHAR2(80);
113252 l_component_code VARCHAR2(30);
113253 l_component_type_code VARCHAR2(1);
113254 l_component_appl_id INTEGER;
113255 l_amb_context_code VARCHAR2(30);
113256 l_entity_code VARCHAR2(30);
113257 l_event_class_code VARCHAR2(30);
113258 l_ae_header_id NUMBER;
113259 l_event_type_code VARCHAR2(30);
113260 l_line_definition_code VARCHAR2(30);
113261 l_line_definition_owner_code VARCHAR2(1);
113262 --
113263 -- adr variables
113264 l_segment VARCHAR2(30);
113265 l_ccid NUMBER;
113266 l_adr_transaction_coa_id NUMBER;
113267 l_adr_accounting_coa_id NUMBER;
113268 l_adr_flexfield_segment_code VARCHAR2(30);
113269 l_adr_flex_value_set_id NUMBER;
113270 l_adr_value_type_code VARCHAR2(30);
113271 l_adr_value_combination_id NUMBER;
113272 l_adr_value_segment_code VARCHAR2(30);
113273
113274 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
113275 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
113276 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
113277 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
113278
113279 -- 4262811 Variables ------------------------------------------------------------------------------------------
113280 l_entered_amt_idx NUMBER;
113281 l_accted_amt_idx NUMBER;
113282 l_acc_rev_flag VARCHAR2(1);
113283 l_accrual_line_num NUMBER;
113284 l_tmp_amt NUMBER;
113285 l_acc_rev_natural_side_code VARCHAR2(1);
113286
113287 l_num_entries NUMBER;
113288 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
113289 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
113290 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
113291 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
113292 l_recog_line_1 NUMBER;
113293 l_recog_line_2 NUMBER;
113294
113295 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
113296 l_bflow_applied_to_amt NUMBER; -- 5132302
113297 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
113298
113299 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
113300
113301 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
113302 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
113303
113304 ---------------------------------------------------------------------------------------------------------------
113305
113306
113307 --
113308 -- bulk performance
113309 --
113310 l_balance_type_code VARCHAR2(1);
113311 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
113312 l_log_module VARCHAR2(240);
113313
113314 --
113315 -- Upgrade strategy
113316 --
113317 l_actual_upg_option VARCHAR2(1);
113318 l_enc_upg_option VARCHAR2(1);
113319
113320 --
113321 BEGIN
113322 --
113323 IF g_log_enabled THEN
113324 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_222';
113325 END IF;
113326 --
113327 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
113328
113329 trace
113330 (p_msg => 'BEGIN of AcctLineType_222'
113331 ,p_level => C_LEVEL_PROCEDURE
113332 ,p_module => l_log_module);
113333
113334 END IF;
113335 --
113336 l_component_type := 'AMB_JLT';
113337 l_component_code := 'INTRANSIT_VALUATION';
113338 l_component_type_code := 'S';
113339 l_component_appl_id := 707;
113340 l_amb_context_code := 'DEFAULT';
113341 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
113342 l_event_class_code := 'FOB_RCPT_SENDER_SHIP';
113343 l_event_type_code := 'FOB_RCPT_SENDER_SHIP';
113344 l_line_definition_owner_code := 'S';
113345 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
113346 --
113347 l_balance_type_code := 'A';
113348 l_segment := NULL;
113349 l_ccid := NULL;
113350 l_adr_transaction_coa_id := NULL;
113351 l_adr_accounting_coa_id := NULL;
113352 l_adr_flexfield_segment_code := NULL;
113353 l_adr_flex_value_set_id := NULL;
113354 l_adr_value_type_code := NULL;
113355 l_adr_value_combination_id := NULL;
113356 l_adr_value_segment_code := NULL;
113357
113358 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
113359 l_bflow_class_code := ''; -- 4219869 Business Flow
113360 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
113361 l_budgetary_control_flag := 'N';
113362
113363 l_bflow_applied_to_amt_idx := NULL; -- 5132302
113364 l_bflow_applied_to_amt := NULL; -- 5132302
113365 l_entered_amt_idx := NULL; -- 4262811
113366 l_accted_amt_idx := NULL; -- 4262811
113367 l_acc_rev_flag := NULL; -- 4262811
113368 l_accrual_line_num := NULL; -- 4262811
113369 l_tmp_amt := NULL; -- 4262811
113370 --
113371
113372 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
113373 l_balance_type_code <> 'B' THEN
113374 IF NVL(p_source_97,9E125) = 14
113375 THEN
113376
113377 --
113378 XLA_AE_LINES_PKG.SetNewLine;
113379
113380 p_balance_type_code := l_balance_type_code;
113381 -- set the flag so later we will know whether the gain loss line needs to be created
113382
113383 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
113384 p_actual_flag :='A';
113385 END IF;
113386
113387 --
113388 -- bulk performance
113389 --
113390 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
113391 p_header_num => 0); -- 4262811
113392 --
113393 -- set accounting line options
113394 --
113395 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
113396 p_natural_side_code => 'D'
113397 , p_gain_or_loss_flag => 'N'
113398 , p_gl_transfer_mode_code => 'S'
113399 , p_acct_entry_type_code => 'A'
113400 , p_switch_side_flag => 'Y'
113401 , p_merge_duplicate_code => 'N'
113402 );
113403 --
113404 l_acc_rev_natural_side_code := 'C'; -- 4262811
113405 --
113406 --
113407 -- set accounting line type info
113408 --
113409 xla_ae_lines_pkg.SetAcctLineType
113410 (p_component_type => l_component_type
113411 ,p_event_type_code => l_event_type_code
113412 ,p_line_definition_owner_code => l_line_definition_owner_code
113413 ,p_line_definition_code => l_line_definition_code
113414 ,p_accounting_line_code => l_component_code
113415 ,p_accounting_line_type_code => l_component_type_code
113416 ,p_accounting_line_appl_id => l_component_appl_id
113417 ,p_amb_context_code => l_amb_context_code
113418 ,p_entity_code => l_entity_code
113419 ,p_event_class_code => l_event_class_code);
113420 --
113421 -- set accounting class
113422 --
113423 xla_ae_lines_pkg.SetAcctClass(
113424 p_accounting_class_code => 'INTRANSIT_VALUATION'
113425 , p_ae_header_id => l_ae_header_id
113426 );
113427
113428 --
113429 -- set rounding class
113430 --
113431 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
113432 'INTRANSIT_VALUATION';
113433
113434 --
113435 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
113436 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
113437 --
113438 -- bulk performance
113439 --
113440 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
113441
113442 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
113443 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
113444
113445 -- 4955764
113446 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
113447 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
113448
113449 -- 4458381 Public Sector Enh
113450
113451 --
113452 -- set accounting attributes for the line type
113453 --
113454 l_entered_amt_idx := 3;
113455 l_accted_amt_idx := 8;
113456 l_bflow_applied_to_amt_idx := NULL; -- 5132302
113457 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
113458 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
113459 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
113460 l_rec_acct_attrs.array_char_value(2) := p_source_85;
113461 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
113462 l_rec_acct_attrs.array_num_value(3) := p_source_91;
113463 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
113464 l_rec_acct_attrs.array_char_value(4) := p_source_88;
113465 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
113466 l_rec_acct_attrs.array_date_value(5) := p_source_92;
113467 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
113468 l_rec_acct_attrs.array_num_value(6) := p_source_93;
113469 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
113470 l_rec_acct_attrs.array_char_value(7) := p_source_94;
113471 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
113472 l_rec_acct_attrs.array_num_value(8) := p_source_95;
113473
113474 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
113475 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
113476
113477 ---------------------------------------------------------------------------------------------------------------
113478 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
113479 ---------------------------------------------------------------------------------------------------------------
113480 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
113481
113482 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
113483 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
113484
113485 IF xla_accounting_cache_pkg.GetValueChar
113486 (p_source_code => 'LEDGER_CATEGORY_CODE'
113487 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
113488 AND l_bflow_method_code = 'PRIOR_ENTRY'
113489 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
113490 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
113491 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
113492 )
113493 THEN
113494 xla_ae_lines_pkg.BflowUpgEntry
113495 (p_business_method_code => l_bflow_method_code
113496 ,p_business_class_code => l_bflow_class_code
113497 ,p_balance_type => l_balance_type_code);
113498 ELSE
113499 NULL;
113500 -- No business flow processing for business flow method of NONE.
113501 END IF;
113502
113503 --
113504 -- call analytical criteria
113505 --
113506
113507 --
113508 -- call description
113509 --
113510
113511 xla_ae_lines_pkg.SetLineDescription(
113512 p_ae_header_id => l_ae_header_id
113513 ,p_description => Description_1 (
113514 p_application_id => p_application_id
113515 , p_ae_header_id => l_ae_header_id
113516 , p_source_1 => p_source_1
113517 , p_source_2 => p_source_2
113518 , p_source_3 => p_source_3
113519 , p_source_4 => p_source_4
113520 , p_source_5 => p_source_5
113521 )
113522 );
113523
113524
113525 --
113526 -- call ADRs
113527 -- Bug 4922099
113528 --
113529 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
113530 (NVL(l_actual_upg_option, 'N') = 'O') OR
113531 (NVL(l_enc_upg_option, 'N') = 'O')
113532 )
113533 THEN
113534 NULL;
113535 --
113536 --
113537
113538 l_ccid := AcctDerRule_25(
113539 p_application_id => p_application_id
113540 , p_ae_header_id => l_ae_header_id
113541 , p_source_11 => p_source_11
113542 , p_source_15 => p_source_15
113543 , p_source_39 => p_source_39
113544 , p_source_39_meaning => p_source_39_meaning
113545 , p_source_41 => p_source_41
113546 , p_source_42 => p_source_42
113547 , p_source_43 => p_source_43
113548 , p_source_44 => p_source_44
113549 , p_source_45 => p_source_45
113550 , x_transaction_coa_id => l_adr_transaction_coa_id
113551 , x_accounting_coa_id => l_adr_accounting_coa_id
113552 , x_value_type_code => l_adr_value_type_code
113553 , p_side => 'NA'
113554 );
113555
113556 xla_ae_lines_pkg.set_ccid(
113557 p_code_combination_id => l_ccid
113558 , p_value_type_code => l_adr_value_type_code
113559 , p_transaction_coa_id => l_adr_transaction_coa_id
113560 , p_accounting_coa_id => l_adr_accounting_coa_id
113561 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
113562 , p_adr_type_code => 'S'
113563 , p_component_type => l_component_type
113564 , p_component_code => l_component_code
113565 , p_component_type_code => l_component_type_code
113566 , p_component_appl_id => l_component_appl_id
113567 , p_amb_context_code => l_amb_context_code
113568 , p_side => 'NA'
113569 );
113570
113571
113572 --
113573 --
113574 END IF;
113575 --
113576 -- Bug 4922099
113577 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
113578 (NVL(l_enc_upg_option, 'N') = 'O')
113579 ) AND
113580 (l_bflow_method_code = 'PRIOR_ENTRY')
113581 )
113582 THEN
113583 IF
113584 --
113585 1 = 2
113586 --
113587 THEN
113588 xla_accounting_err_pkg.build_message
113589 (p_appli_s_name => 'XLA'
113590 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
113591 ,p_token_1 => 'LINE_NUMBER'
113592 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
113593 ,p_token_2 => 'LINE_TYPE_NAME'
113594 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
113595 l_component_type
113596 ,l_component_code
113597 ,l_component_type_code
113598 ,l_component_appl_id
113599 ,l_amb_context_code
113600 ,l_entity_code
113601 ,l_event_class_code
113602 )
113603 ,p_token_3 => 'OWNER'
113604 ,p_value_3 => xla_lookups_pkg.get_meaning(
113605 p_lookup_type => 'XLA_OWNER_TYPE'
113606 ,p_lookup_code => l_component_type_code
113607 )
113608 ,p_token_4 => 'PRODUCT_NAME'
113609 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
113610 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
113611 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
113612 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
113613 ,p_ae_header_id => NULL
113614 );
113615
113616 IF (C_LEVEL_ERROR>= g_log_level) THEN
113617 trace
113618 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
113619 ,p_level => C_LEVEL_ERROR
113620 ,p_module => l_log_module);
113621 END IF;
113622 END IF;
113623 END IF;
113624 --
113625 --
113626 ------------------------------------------------------------------------------------------------
113627 -- 4219869 Business Flow
113628 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
113629 -- Prior Entry. Currently, the following code is always generated.
113630 ------------------------------------------------------------------------------------------------
113631 XLA_AE_LINES_PKG.ValidateCurrentLine;
113632
113633 ------------------------------------------------------------------------------------
113634 -- 4219869 Business Flow
113635 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
113636 ------------------------------------------------------------------------------------
113637 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
113638
113639 ----------------------------------------------------------------------------------
113640 -- 4219869 Business Flow
113641 -- Update journal entry status -- Need to generate this within IF <condition>
113642 ----------------------------------------------------------------------------------
113643 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
113644 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
113645 ,p_balance_type_code => l_balance_type_code
113646 );
113647
113648 -------------------------------------------------------------------------------------------
113649 -- 4262811 - Generate the Accrual Reversal lines
113650 -------------------------------------------------------------------------------------------
113651 BEGIN
113652 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
113653 (g_array_event(p_event_id).array_value_num('header_index'));
113654 IF l_acc_rev_flag IS NULL THEN
113655 l_acc_rev_flag := 'N';
113656 END IF;
113657 EXCEPTION
113658 WHEN OTHERS THEN
113659 l_acc_rev_flag := 'N';
113660 END;
113661 --
113662 IF (l_acc_rev_flag = 'Y') THEN
113663
113664 -- 4645092 ------------------------------------------------------------------------------
113665 -- To allow MPA report to determine if it should generate report process
113666 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
113667 ------------------------------------------------------------------------------------------
113668
113669 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
113670 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
113671 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
113672 -- call ADRs
113673 -- Bug 4922099
113674 --
113675 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
113676 (NVL(l_actual_upg_option, 'N') = 'O') OR
113677 (NVL(l_enc_upg_option, 'N') = 'O')
113678 )
113679 THEN
113680 NULL;
113681 --
113682 --
113683
113684 l_ccid := AcctDerRule_25(
113685 p_application_id => p_application_id
113686 , p_ae_header_id => l_ae_header_id
113687 , p_source_11 => p_source_11
113688 , p_source_15 => p_source_15
113689 , p_source_39 => p_source_39
113690 , p_source_39_meaning => p_source_39_meaning
113691 , p_source_41 => p_source_41
113692 , p_source_42 => p_source_42
113693 , p_source_43 => p_source_43
113694 , p_source_44 => p_source_44
113695 , p_source_45 => p_source_45
113696 , x_transaction_coa_id => l_adr_transaction_coa_id
113697 , x_accounting_coa_id => l_adr_accounting_coa_id
113698 , x_value_type_code => l_adr_value_type_code
113699 , p_side => 'NA'
113700 );
113701
113702 xla_ae_lines_pkg.set_ccid(
113703 p_code_combination_id => l_ccid
113704 , p_value_type_code => l_adr_value_type_code
113705 , p_transaction_coa_id => l_adr_transaction_coa_id
113706 , p_accounting_coa_id => l_adr_accounting_coa_id
113707 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
113708 , p_adr_type_code => 'S'
113709 , p_component_type => l_component_type
113710 , p_component_code => l_component_code
113711 , p_component_type_code => l_component_type_code
113712 , p_component_appl_id => l_component_appl_id
113713 , p_amb_context_code => l_amb_context_code
113714 , p_side => 'NA'
113715 );
113716
113717
113718 --
113719 --
113720 END IF;
113721
113722 --
113723 -- Update the line information that should be overwritten
113724 --
113725 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
113726 p_header_num => 1);
113727 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
113728
113729 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
113730
113731 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
113732 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
113733 END IF;
113734
113735 --
113736 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
113737 --
113738 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
113739 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
113740 ELSE
113741 ---------------------------------------------------------------------------------------------------
113742 -- 4262811a Switch Sign
113743 ---------------------------------------------------------------------------------------------------
113744 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
113745 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
113746 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113747 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
113748 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113749 -- 5132302
113750 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
113751 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
113752
113753 END IF;
113754
113755 -- 4955764
113756 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
113757 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
113758
113759
113760 XLA_AE_LINES_PKG.ValidateCurrentLine;
113761 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
113762
113763 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
113764 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
113765 ,p_balance_type_code => l_balance_type_code);
113766
113767 END IF;
113768
113769 -----------------------------------------------------------------------------------------
113770 -- 4262811 Multiperiod Accounting
113771 -----------------------------------------------------------------------------------------
113772 -- No MPA option is assigned.
113773
113774
113775 END IF;
113776 END IF;
113777 --
113778
113779 --
113780 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
113781 trace
113782 (p_msg => 'END of AcctLineType_222'
113783 ,p_level => C_LEVEL_PROCEDURE
113784 ,p_module => l_log_module);
113785 END IF;
113786 --
113787 EXCEPTION
113788 WHEN xla_exceptions_pkg.application_exception THEN
113789 RAISE;
113790 WHEN OTHERS THEN
113791 xla_exceptions_pkg.raise_message
113792 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_222');
113793 END AcctLineType_222;
113794 --
113795
113796 ---------------------------------------
113797 --
113798 -- PRIVATE FUNCTION
113799 -- AcctLineType_223
113800 --
113801 ---------------------------------------
113802 PROCEDURE AcctLineType_223 (
113803 p_application_id IN NUMBER
113804 ,p_event_id IN NUMBER
113805 ,p_calculate_acctd_flag IN VARCHAR2
113806 ,p_calculate_g_l_flag IN VARCHAR2
113807 ,p_actual_flag IN OUT VARCHAR2
113808 ,p_balance_type_code OUT VARCHAR2
113809 ,p_gain_or_loss_ref OUT VARCHAR2
113810
113811 --TRANSACTION_ID
113812 , p_source_1 IN NUMBER
113813 --Item Concatenated Segments
113814 , p_source_2 IN VARCHAR2
113815 --Transaction Quantity
113816 , p_source_3 IN NUMBER
113817 --Transaction Unit of Measure Code
113818 , p_source_4 IN VARCHAR2
113819 --Inventory Transaction Type Description
113820 , p_source_5 IN VARCHAR2
113821 --Cost Element Name
113822 , p_source_15 IN NUMBER
113823 --Cost Group Identifier
113824 , p_source_26 IN NUMBER
113825 --INV Header Transfer Cost Group ID
113826 , p_source_27 IN NUMBER
113827 --INV Header Cost Group ID
113828 , p_source_28 IN NUMBER
113829 --Subinventory Name
113830 , p_source_29 IN VARCHAR2
113831 --INV Header Transfer Subinventory
113832 , p_source_31 IN VARCHAR2
113833 --Product Line Accounting Category Material Account
113834 , p_source_41 IN NUMBER
113835 --Product Line Accounting Category Material Overhead Account
113836 , p_source_42 IN NUMBER
113837 --Product Line Accounting Category Resource Account
113838 , p_source_43 IN NUMBER
113839 --Product Line Accounting Category Outside Processing Account
113840 , p_source_44 IN NUMBER
113841 --Product Line Accounting Category Overhead Account
113842 , p_source_45 IN NUMBER
113843 --Transfer to Subinventory or Cost Group category material account
113844 , p_source_48 IN NUMBER
113845 --Transfer to Subinventory or Cost Group category material overhead account
113846 , p_source_49 IN NUMBER
113847 --Transfer to Subinventory or Cost Group category resource account
113848 , p_source_50 IN NUMBER
113849 --Transfer to Subinventory or Cost Group category outside processing account
113850 , p_source_51 IN NUMBER
113851 --Transfer to Subinventory or Cost Group category overhead account
113852 , p_source_52 IN NUMBER
113853 --DISTRIBUTION_IDENTIFIER
113854 , p_source_84 IN NUMBER
113855 --Distribution Type
113856 , p_source_85 IN VARCHAR2
113857 , p_source_85_meaning IN VARCHAR2
113858 --Entered Currency Code
113859 , p_source_88 IN VARCHAR2
113860 --Entered Amount
113861 , p_source_91 IN NUMBER
113862 --Currency Conversion Date
113863 , p_source_92 IN DATE
113864 --Currency Conversion Rate
113865 , p_source_93 IN NUMBER
113866 --Currency Conversion Type
113867 , p_source_94 IN VARCHAR2
113868 --Accounted Amount
113869 , p_source_95 IN NUMBER
113870 --Accounting Line Type
113871 , p_source_97 IN NUMBER
113872 )
113873 IS
113874
113875 l_component_type VARCHAR2(80);
113876 l_component_code VARCHAR2(30);
113877 l_component_type_code VARCHAR2(1);
113878 l_component_appl_id INTEGER;
113879 l_amb_context_code VARCHAR2(30);
113880 l_entity_code VARCHAR2(30);
113881 l_event_class_code VARCHAR2(30);
113882 l_ae_header_id NUMBER;
113883 l_event_type_code VARCHAR2(30);
113884 l_line_definition_code VARCHAR2(30);
113885 l_line_definition_owner_code VARCHAR2(1);
113886 --
113887 -- adr variables
113888 l_segment VARCHAR2(30);
113889 l_ccid NUMBER;
113890 l_adr_transaction_coa_id NUMBER;
113891 l_adr_accounting_coa_id NUMBER;
113892 l_adr_flexfield_segment_code VARCHAR2(30);
113893 l_adr_flex_value_set_id NUMBER;
113894 l_adr_value_type_code VARCHAR2(30);
113895 l_adr_value_combination_id NUMBER;
113896 l_adr_value_segment_code VARCHAR2(30);
113897
113898 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
113899 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
113900 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
113901 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
113902
113903 -- 4262811 Variables ------------------------------------------------------------------------------------------
113904 l_entered_amt_idx NUMBER;
113905 l_accted_amt_idx NUMBER;
113906 l_acc_rev_flag VARCHAR2(1);
113907 l_accrual_line_num NUMBER;
113908 l_tmp_amt NUMBER;
113909 l_acc_rev_natural_side_code VARCHAR2(1);
113910
113911 l_num_entries NUMBER;
113912 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
113913 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
113914 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
113915 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
113916 l_recog_line_1 NUMBER;
113917 l_recog_line_2 NUMBER;
113918
113919 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
113920 l_bflow_applied_to_amt NUMBER; -- 5132302
113921 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
113922
113923 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
113924
113925 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
113926 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
113927
113928 ---------------------------------------------------------------------------------------------------------------
113929
113930
113931 --
113932 -- bulk performance
113933 --
113934 l_balance_type_code VARCHAR2(1);
113935 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
113936 l_log_module VARCHAR2(240);
113937
113938 --
113939 -- Upgrade strategy
113940 --
113941 l_actual_upg_option VARCHAR2(1);
113942 l_enc_upg_option VARCHAR2(1);
113943
113944 --
113945 BEGIN
113946 --
113947 IF g_log_enabled THEN
113948 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_223';
113949 END IF;
113950 --
113951 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
113952
113953 trace
113954 (p_msg => 'BEGIN of AcctLineType_223'
113955 ,p_level => C_LEVEL_PROCEDURE
113956 ,p_module => l_log_module);
113957
113958 END IF;
113959 --
113960 l_component_type := 'AMB_JLT';
113961 l_component_code := 'INTRANSIT_VALUATION';
113962 l_component_type_code := 'S';
113963 l_component_appl_id := 707;
113964 l_amb_context_code := 'DEFAULT';
113965 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
113966 l_event_class_code := 'USER_DEFINE';
113967 l_event_type_code := 'UIPV_TXFR';
113968 l_line_definition_owner_code := 'S';
113969 l_line_definition_code := 'PI_IPV_TXFR';
113970 --
113971 l_balance_type_code := 'A';
113972 l_segment := NULL;
113973 l_ccid := NULL;
113974 l_adr_transaction_coa_id := NULL;
113975 l_adr_accounting_coa_id := NULL;
113976 l_adr_flexfield_segment_code := NULL;
113977 l_adr_flex_value_set_id := NULL;
113978 l_adr_value_type_code := NULL;
113979 l_adr_value_combination_id := NULL;
113980 l_adr_value_segment_code := NULL;
113981
113982 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
113983 l_bflow_class_code := ''; -- 4219869 Business Flow
113984 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
113985 l_budgetary_control_flag := 'N';
113986
113987 l_bflow_applied_to_amt_idx := NULL; -- 5132302
113988 l_bflow_applied_to_amt := NULL; -- 5132302
113989 l_entered_amt_idx := NULL; -- 4262811
113990 l_accted_amt_idx := NULL; -- 4262811
113991 l_acc_rev_flag := NULL; -- 4262811
113992 l_accrual_line_num := NULL; -- 4262811
113993 l_tmp_amt := NULL; -- 4262811
113994 --
113995
113996 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
113997 l_balance_type_code <> 'B' THEN
113998 IF NVL(p_source_97,9E125) = 14
113999 THEN
114000
114001 --
114002 XLA_AE_LINES_PKG.SetNewLine;
114003
114004 p_balance_type_code := l_balance_type_code;
114005 -- set the flag so later we will know whether the gain loss line needs to be created
114006
114007 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
114008 p_actual_flag :='A';
114009 END IF;
114010
114011 --
114012 -- bulk performance
114013 --
114014 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
114015 p_header_num => 0); -- 4262811
114016 --
114017 -- set accounting line options
114018 --
114019 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
114020 p_natural_side_code => 'D'
114021 , p_gain_or_loss_flag => 'N'
114022 , p_gl_transfer_mode_code => 'S'
114023 , p_acct_entry_type_code => 'A'
114024 , p_switch_side_flag => 'Y'
114025 , p_merge_duplicate_code => 'N'
114026 );
114027 --
114028 l_acc_rev_natural_side_code := 'C'; -- 4262811
114029 --
114030 --
114031 -- set accounting line type info
114032 --
114033 xla_ae_lines_pkg.SetAcctLineType
114034 (p_component_type => l_component_type
114035 ,p_event_type_code => l_event_type_code
114036 ,p_line_definition_owner_code => l_line_definition_owner_code
114037 ,p_line_definition_code => l_line_definition_code
114038 ,p_accounting_line_code => l_component_code
114039 ,p_accounting_line_type_code => l_component_type_code
114040 ,p_accounting_line_appl_id => l_component_appl_id
114041 ,p_amb_context_code => l_amb_context_code
114042 ,p_entity_code => l_entity_code
114043 ,p_event_class_code => l_event_class_code);
114044 --
114045 -- set accounting class
114046 --
114047 xla_ae_lines_pkg.SetAcctClass(
114048 p_accounting_class_code => 'INTRANSIT_VALUATION'
114049 , p_ae_header_id => l_ae_header_id
114050 );
114051
114052 --
114053 -- set rounding class
114054 --
114055 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
114056 'INTRANSIT_VALUATION';
114057
114058 --
114059 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
114060 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
114061 --
114062 -- bulk performance
114063 --
114064 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
114065
114066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
114067 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
114068
114069 -- 4955764
114070 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
114071 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
114072
114073 -- 4458381 Public Sector Enh
114074
114075 --
114076 -- set accounting attributes for the line type
114077 --
114078 l_entered_amt_idx := 3;
114079 l_accted_amt_idx := 8;
114080 l_bflow_applied_to_amt_idx := NULL; -- 5132302
114081 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
114082 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
114083 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
114084 l_rec_acct_attrs.array_char_value(2) := p_source_85;
114085 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
114086 l_rec_acct_attrs.array_num_value(3) := p_source_91;
114087 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
114088 l_rec_acct_attrs.array_char_value(4) := p_source_88;
114089 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
114090 l_rec_acct_attrs.array_date_value(5) := p_source_92;
114091 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
114092 l_rec_acct_attrs.array_num_value(6) := p_source_93;
114093 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
114094 l_rec_acct_attrs.array_char_value(7) := p_source_94;
114095 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
114096 l_rec_acct_attrs.array_num_value(8) := p_source_95;
114097
114098 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
114099 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
114100
114101 ---------------------------------------------------------------------------------------------------------------
114102 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
114103 ---------------------------------------------------------------------------------------------------------------
114104 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
114105
114106 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
114107 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
114108
114109 IF xla_accounting_cache_pkg.GetValueChar
114110 (p_source_code => 'LEDGER_CATEGORY_CODE'
114111 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
114112 AND l_bflow_method_code = 'PRIOR_ENTRY'
114113 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
114114 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
114115 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
114116 )
114117 THEN
114118 xla_ae_lines_pkg.BflowUpgEntry
114119 (p_business_method_code => l_bflow_method_code
114120 ,p_business_class_code => l_bflow_class_code
114121 ,p_balance_type => l_balance_type_code);
114122 ELSE
114123 NULL;
114124 -- No business flow processing for business flow method of NONE.
114125 END IF;
114126
114127 --
114128 -- call analytical criteria
114129 --
114130
114131 --
114132 -- call description
114133 --
114134
114135 xla_ae_lines_pkg.SetLineDescription(
114136 p_ae_header_id => l_ae_header_id
114137 ,p_description => Description_1 (
114138 p_application_id => p_application_id
114139 , p_ae_header_id => l_ae_header_id
114140 , p_source_1 => p_source_1
114141 , p_source_2 => p_source_2
114142 , p_source_3 => p_source_3
114143 , p_source_4 => p_source_4
114144 , p_source_5 => p_source_5
114145 )
114146 );
114147
114148
114149 --
114150 -- call ADRs
114151 -- Bug 4922099
114152 --
114153 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
114154 (NVL(l_actual_upg_option, 'N') = 'O') OR
114155 (NVL(l_enc_upg_option, 'N') = 'O')
114156 )
114157 THEN
114158 NULL;
114159 --
114160 --
114161
114162 l_ccid := AcctDerRule_29(
114163 p_application_id => p_application_id
114164 , p_ae_header_id => l_ae_header_id
114165 , p_source_15 => p_source_15
114166 , p_source_26 => p_source_26
114167 , p_source_27 => p_source_27
114168 , p_source_28 => p_source_28
114169 , p_source_29 => p_source_29
114170 , p_source_31 => p_source_31
114171 , p_source_41 => p_source_41
114172 , p_source_42 => p_source_42
114173 , p_source_43 => p_source_43
114174 , p_source_44 => p_source_44
114175 , p_source_45 => p_source_45
114176 , p_source_48 => p_source_48
114177 , p_source_49 => p_source_49
114178 , p_source_50 => p_source_50
114179 , p_source_51 => p_source_51
114180 , p_source_52 => p_source_52
114181 , x_transaction_coa_id => l_adr_transaction_coa_id
114182 , x_accounting_coa_id => l_adr_accounting_coa_id
114183 , x_value_type_code => l_adr_value_type_code
114184 , p_side => 'NA'
114185 );
114186
114187 xla_ae_lines_pkg.set_ccid(
114188 p_code_combination_id => l_ccid
114189 , p_value_type_code => l_adr_value_type_code
114190 , p_transaction_coa_id => l_adr_transaction_coa_id
114191 , p_accounting_coa_id => l_adr_accounting_coa_id
114192 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
114193 , p_adr_type_code => 'S'
114194 , p_component_type => l_component_type
114195 , p_component_code => l_component_code
114196 , p_component_type_code => l_component_type_code
114197 , p_component_appl_id => l_component_appl_id
114198 , p_amb_context_code => l_amb_context_code
114199 , p_side => 'NA'
114200 );
114201
114202
114203 --
114204 --
114205 END IF;
114206 --
114207 -- Bug 4922099
114208 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
114209 (NVL(l_enc_upg_option, 'N') = 'O')
114210 ) AND
114211 (l_bflow_method_code = 'PRIOR_ENTRY')
114212 )
114213 THEN
114214 IF
114215 --
114216 1 = 2
114217 --
114218 THEN
114219 xla_accounting_err_pkg.build_message
114220 (p_appli_s_name => 'XLA'
114221 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
114222 ,p_token_1 => 'LINE_NUMBER'
114223 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
114224 ,p_token_2 => 'LINE_TYPE_NAME'
114225 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
114226 l_component_type
114227 ,l_component_code
114228 ,l_component_type_code
114229 ,l_component_appl_id
114230 ,l_amb_context_code
114231 ,l_entity_code
114232 ,l_event_class_code
114233 )
114234 ,p_token_3 => 'OWNER'
114235 ,p_value_3 => xla_lookups_pkg.get_meaning(
114236 p_lookup_type => 'XLA_OWNER_TYPE'
114237 ,p_lookup_code => l_component_type_code
114238 )
114239 ,p_token_4 => 'PRODUCT_NAME'
114240 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
114241 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
114242 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
114243 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
114244 ,p_ae_header_id => NULL
114245 );
114246
114247 IF (C_LEVEL_ERROR>= g_log_level) THEN
114248 trace
114249 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
114250 ,p_level => C_LEVEL_ERROR
114251 ,p_module => l_log_module);
114252 END IF;
114253 END IF;
114254 END IF;
114255 --
114256 --
114257 ------------------------------------------------------------------------------------------------
114258 -- 4219869 Business Flow
114259 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
114260 -- Prior Entry. Currently, the following code is always generated.
114261 ------------------------------------------------------------------------------------------------
114262 XLA_AE_LINES_PKG.ValidateCurrentLine;
114263
114264 ------------------------------------------------------------------------------------
114265 -- 4219869 Business Flow
114266 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
114267 ------------------------------------------------------------------------------------
114268 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
114269
114270 ----------------------------------------------------------------------------------
114271 -- 4219869 Business Flow
114272 -- Update journal entry status -- Need to generate this within IF <condition>
114273 ----------------------------------------------------------------------------------
114274 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
114275 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
114276 ,p_balance_type_code => l_balance_type_code
114277 );
114278
114279 -------------------------------------------------------------------------------------------
114280 -- 4262811 - Generate the Accrual Reversal lines
114281 -------------------------------------------------------------------------------------------
114282 BEGIN
114283 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
114284 (g_array_event(p_event_id).array_value_num('header_index'));
114285 IF l_acc_rev_flag IS NULL THEN
114286 l_acc_rev_flag := 'N';
114287 END IF;
114288 EXCEPTION
114289 WHEN OTHERS THEN
114290 l_acc_rev_flag := 'N';
114291 END;
114292 --
114293 IF (l_acc_rev_flag = 'Y') THEN
114294
114295 -- 4645092 ------------------------------------------------------------------------------
114296 -- To allow MPA report to determine if it should generate report process
114297 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
114298 ------------------------------------------------------------------------------------------
114299
114300 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
114301 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
114302 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
114303 -- call ADRs
114304 -- Bug 4922099
114305 --
114306 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
114307 (NVL(l_actual_upg_option, 'N') = 'O') OR
114308 (NVL(l_enc_upg_option, 'N') = 'O')
114309 )
114310 THEN
114311 NULL;
114312 --
114313 --
114314
114315 l_ccid := AcctDerRule_29(
114316 p_application_id => p_application_id
114317 , p_ae_header_id => l_ae_header_id
114318 , p_source_15 => p_source_15
114319 , p_source_26 => p_source_26
114320 , p_source_27 => p_source_27
114321 , p_source_28 => p_source_28
114322 , p_source_29 => p_source_29
114323 , p_source_31 => p_source_31
114324 , p_source_41 => p_source_41
114325 , p_source_42 => p_source_42
114326 , p_source_43 => p_source_43
114327 , p_source_44 => p_source_44
114328 , p_source_45 => p_source_45
114329 , p_source_48 => p_source_48
114330 , p_source_49 => p_source_49
114331 , p_source_50 => p_source_50
114332 , p_source_51 => p_source_51
114333 , p_source_52 => p_source_52
114334 , x_transaction_coa_id => l_adr_transaction_coa_id
114335 , x_accounting_coa_id => l_adr_accounting_coa_id
114336 , x_value_type_code => l_adr_value_type_code
114337 , p_side => 'NA'
114338 );
114339
114340 xla_ae_lines_pkg.set_ccid(
114341 p_code_combination_id => l_ccid
114342 , p_value_type_code => l_adr_value_type_code
114343 , p_transaction_coa_id => l_adr_transaction_coa_id
114344 , p_accounting_coa_id => l_adr_accounting_coa_id
114345 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
114346 , p_adr_type_code => 'S'
114347 , p_component_type => l_component_type
114348 , p_component_code => l_component_code
114349 , p_component_type_code => l_component_type_code
114350 , p_component_appl_id => l_component_appl_id
114351 , p_amb_context_code => l_amb_context_code
114352 , p_side => 'NA'
114353 );
114354
114355
114356 --
114357 --
114358 END IF;
114359
114360 --
114361 -- Update the line information that should be overwritten
114362 --
114363 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
114364 p_header_num => 1);
114365 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
114366
114367 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
114368
114369 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
114370 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
114371 END IF;
114372
114373 --
114374 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
114375 --
114376 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
114377 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
114378 ELSE
114379 ---------------------------------------------------------------------------------------------------
114380 -- 4262811a Switch Sign
114381 ---------------------------------------------------------------------------------------------------
114382 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
114383 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
114384 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114385 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
114386 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114387 -- 5132302
114388 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
114389 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114390
114391 END IF;
114392
114393 -- 4955764
114394 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
114395 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
114396
114397
114398 XLA_AE_LINES_PKG.ValidateCurrentLine;
114399 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
114400
114401 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
114402 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
114403 ,p_balance_type_code => l_balance_type_code);
114404
114405 END IF;
114406
114407 -----------------------------------------------------------------------------------------
114408 -- 4262811 Multiperiod Accounting
114409 -----------------------------------------------------------------------------------------
114410 -- No MPA option is assigned.
114411
114412
114413 END IF;
114414 END IF;
114415 --
114416
114417 --
114418 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
114419 trace
114420 (p_msg => 'END of AcctLineType_223'
114421 ,p_level => C_LEVEL_PROCEDURE
114422 ,p_module => l_log_module);
114423 END IF;
114424 --
114425 EXCEPTION
114426 WHEN xla_exceptions_pkg.application_exception THEN
114427 RAISE;
114428 WHEN OTHERS THEN
114429 xla_exceptions_pkg.raise_message
114430 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_223');
114431 END AcctLineType_223;
114432 --
114433
114434 ---------------------------------------
114435 --
114436 -- PRIVATE FUNCTION
114437 -- AcctLineType_224
114438 --
114439 ---------------------------------------
114440 PROCEDURE AcctLineType_224 (
114441 p_application_id IN NUMBER
114442 ,p_event_id IN NUMBER
114443 ,p_calculate_acctd_flag IN VARCHAR2
114444 ,p_calculate_g_l_flag IN VARCHAR2
114445 ,p_actual_flag IN OUT VARCHAR2
114446 ,p_balance_type_code OUT VARCHAR2
114447 ,p_gain_or_loss_ref OUT VARCHAR2
114448
114449 --TRANSACTION_ID
114450 , p_source_1 IN NUMBER
114451 --Item Concatenated Segments
114452 , p_source_2 IN VARCHAR2
114453 --Transaction Quantity
114454 , p_source_3 IN NUMBER
114455 --Transaction Unit of Measure Code
114456 , p_source_4 IN VARCHAR2
114457 --Inventory Transaction Type Description
114458 , p_source_5 IN VARCHAR2
114459 --Cost Management Default Account
114460 , p_source_11 IN NUMBER
114461 --Cost Element Name
114462 , p_source_15 IN NUMBER
114463 --Primary Cost Method
114464 , p_source_39 IN NUMBER
114465 , p_source_39_meaning IN VARCHAR2
114466 --Product Line Accounting Category Material Account
114467 , p_source_41 IN NUMBER
114468 --Product Line Accounting Category Material Overhead Account
114469 , p_source_42 IN NUMBER
114470 --Product Line Accounting Category Resource Account
114471 , p_source_43 IN NUMBER
114472 --Product Line Accounting Category Outside Processing Account
114473 , p_source_44 IN NUMBER
114474 --Product Line Accounting Category Overhead Account
114475 , p_source_45 IN NUMBER
114476 --DISTRIBUTION_IDENTIFIER
114477 , p_source_84 IN NUMBER
114478 --Distribution Type
114479 , p_source_85 IN VARCHAR2
114480 , p_source_85_meaning IN VARCHAR2
114481 --Entered Currency Code
114482 , p_source_88 IN VARCHAR2
114483 --Entered Amount
114484 , p_source_91 IN NUMBER
114485 --Currency Conversion Date
114486 , p_source_92 IN DATE
114487 --Currency Conversion Rate
114488 , p_source_93 IN NUMBER
114489 --Currency Conversion Type
114490 , p_source_94 IN VARCHAR2
114491 --Accounted Amount
114492 , p_source_95 IN NUMBER
114493 --Accounting Line Type
114494 , p_source_97 IN NUMBER
114495 )
114496 IS
114497
114498 l_component_type VARCHAR2(80);
114499 l_component_code VARCHAR2(30);
114500 l_component_type_code VARCHAR2(1);
114501 l_component_appl_id INTEGER;
114502 l_amb_context_code VARCHAR2(30);
114503 l_entity_code VARCHAR2(30);
114504 l_event_class_code VARCHAR2(30);
114505 l_ae_header_id NUMBER;
114506 l_event_type_code VARCHAR2(30);
114507 l_line_definition_code VARCHAR2(30);
114508 l_line_definition_owner_code VARCHAR2(1);
114509 --
114510 -- adr variables
114511 l_segment VARCHAR2(30);
114512 l_ccid NUMBER;
114513 l_adr_transaction_coa_id NUMBER;
114514 l_adr_accounting_coa_id NUMBER;
114515 l_adr_flexfield_segment_code VARCHAR2(30);
114516 l_adr_flex_value_set_id NUMBER;
114517 l_adr_value_type_code VARCHAR2(30);
114518 l_adr_value_combination_id NUMBER;
114519 l_adr_value_segment_code VARCHAR2(30);
114520
114521 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
114522 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
114523 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
114524 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
114525
114526 -- 4262811 Variables ------------------------------------------------------------------------------------------
114527 l_entered_amt_idx NUMBER;
114528 l_accted_amt_idx NUMBER;
114529 l_acc_rev_flag VARCHAR2(1);
114530 l_accrual_line_num NUMBER;
114531 l_tmp_amt NUMBER;
114532 l_acc_rev_natural_side_code VARCHAR2(1);
114533
114534 l_num_entries NUMBER;
114535 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
114536 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
114537 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
114538 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
114539 l_recog_line_1 NUMBER;
114540 l_recog_line_2 NUMBER;
114541
114542 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
114543 l_bflow_applied_to_amt NUMBER; -- 5132302
114544 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
114545
114546 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
114547
114548 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
114549 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
114550
114551 ---------------------------------------------------------------------------------------------------------------
114552
114553
114554 --
114555 -- bulk performance
114556 --
114557 l_balance_type_code VARCHAR2(1);
114558 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
114559 l_log_module VARCHAR2(240);
114560
114561 --
114562 -- Upgrade strategy
114563 --
114564 l_actual_upg_option VARCHAR2(1);
114565 l_enc_upg_option VARCHAR2(1);
114566
114567 --
114568 BEGIN
114569 --
114570 IF g_log_enabled THEN
114571 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_224';
114572 END IF;
114573 --
114574 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
114575
114576 trace
114577 (p_msg => 'BEGIN of AcctLineType_224'
114578 ,p_level => C_LEVEL_PROCEDURE
114579 ,p_module => l_log_module);
114580
114581 END IF;
114582 --
114583 l_component_type := 'AMB_JLT';
114584 l_component_code := 'INTRANSIT_VALUATION';
114585 l_component_type_code := 'S';
114586 l_component_appl_id := 707;
114587 l_amb_context_code := 'DEFAULT';
114588 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
114589 l_event_class_code := 'MTL_COST_UPD';
114590 l_event_type_code := 'LAYER_COST_UPD';
114591 l_line_definition_owner_code := 'S';
114592 l_line_definition_code := 'PI_LAYER_COST_UPDATE';
114593 --
114594 l_balance_type_code := 'A';
114595 l_segment := NULL;
114596 l_ccid := NULL;
114597 l_adr_transaction_coa_id := NULL;
114598 l_adr_accounting_coa_id := NULL;
114599 l_adr_flexfield_segment_code := NULL;
114600 l_adr_flex_value_set_id := NULL;
114601 l_adr_value_type_code := NULL;
114602 l_adr_value_combination_id := NULL;
114603 l_adr_value_segment_code := NULL;
114604
114605 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
114606 l_bflow_class_code := ''; -- 4219869 Business Flow
114607 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
114608 l_budgetary_control_flag := 'N';
114609
114610 l_bflow_applied_to_amt_idx := NULL; -- 5132302
114611 l_bflow_applied_to_amt := NULL; -- 5132302
114612 l_entered_amt_idx := NULL; -- 4262811
114613 l_accted_amt_idx := NULL; -- 4262811
114614 l_acc_rev_flag := NULL; -- 4262811
114615 l_accrual_line_num := NULL; -- 4262811
114616 l_tmp_amt := NULL; -- 4262811
114617 --
114618
114619 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
114620 l_balance_type_code <> 'B' THEN
114621 IF NVL(p_source_97,9E125) = 14
114622 THEN
114623
114624 --
114625 XLA_AE_LINES_PKG.SetNewLine;
114626
114627 p_balance_type_code := l_balance_type_code;
114628 -- set the flag so later we will know whether the gain loss line needs to be created
114629
114630 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
114631 p_actual_flag :='A';
114632 END IF;
114633
114634 --
114635 -- bulk performance
114636 --
114637 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
114638 p_header_num => 0); -- 4262811
114639 --
114640 -- set accounting line options
114641 --
114642 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
114643 p_natural_side_code => 'D'
114644 , p_gain_or_loss_flag => 'N'
114645 , p_gl_transfer_mode_code => 'S'
114646 , p_acct_entry_type_code => 'A'
114647 , p_switch_side_flag => 'Y'
114648 , p_merge_duplicate_code => 'N'
114649 );
114650 --
114651 l_acc_rev_natural_side_code := 'C'; -- 4262811
114652 --
114653 --
114654 -- set accounting line type info
114655 --
114656 xla_ae_lines_pkg.SetAcctLineType
114657 (p_component_type => l_component_type
114658 ,p_event_type_code => l_event_type_code
114659 ,p_line_definition_owner_code => l_line_definition_owner_code
114660 ,p_line_definition_code => l_line_definition_code
114661 ,p_accounting_line_code => l_component_code
114662 ,p_accounting_line_type_code => l_component_type_code
114663 ,p_accounting_line_appl_id => l_component_appl_id
114664 ,p_amb_context_code => l_amb_context_code
114665 ,p_entity_code => l_entity_code
114666 ,p_event_class_code => l_event_class_code);
114667 --
114668 -- set accounting class
114669 --
114670 xla_ae_lines_pkg.SetAcctClass(
114671 p_accounting_class_code => 'INTRANSIT_VALUATION'
114672 , p_ae_header_id => l_ae_header_id
114673 );
114674
114675 --
114676 -- set rounding class
114677 --
114678 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
114679 'INTRANSIT_VALUATION';
114680
114681 --
114682 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
114683 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
114684 --
114685 -- bulk performance
114686 --
114687 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
114688
114689 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
114690 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
114691
114692 -- 4955764
114693 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
114694 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
114695
114696 -- 4458381 Public Sector Enh
114697
114698 --
114699 -- set accounting attributes for the line type
114700 --
114701 l_entered_amt_idx := 3;
114702 l_accted_amt_idx := 8;
114703 l_bflow_applied_to_amt_idx := NULL; -- 5132302
114704 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
114705 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
114706 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
114707 l_rec_acct_attrs.array_char_value(2) := p_source_85;
114708 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
114709 l_rec_acct_attrs.array_num_value(3) := p_source_91;
114710 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
114711 l_rec_acct_attrs.array_char_value(4) := p_source_88;
114712 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
114713 l_rec_acct_attrs.array_date_value(5) := p_source_92;
114714 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
114715 l_rec_acct_attrs.array_num_value(6) := p_source_93;
114716 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
114717 l_rec_acct_attrs.array_char_value(7) := p_source_94;
114718 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
114719 l_rec_acct_attrs.array_num_value(8) := p_source_95;
114720
114721 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
114722 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
114723
114724 ---------------------------------------------------------------------------------------------------------------
114725 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
114726 ---------------------------------------------------------------------------------------------------------------
114727 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
114728
114729 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
114730 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
114731
114732 IF xla_accounting_cache_pkg.GetValueChar
114733 (p_source_code => 'LEDGER_CATEGORY_CODE'
114734 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
114735 AND l_bflow_method_code = 'PRIOR_ENTRY'
114736 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
114737 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
114738 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
114739 )
114740 THEN
114741 xla_ae_lines_pkg.BflowUpgEntry
114742 (p_business_method_code => l_bflow_method_code
114743 ,p_business_class_code => l_bflow_class_code
114744 ,p_balance_type => l_balance_type_code);
114745 ELSE
114746 NULL;
114747 -- No business flow processing for business flow method of NONE.
114748 END IF;
114749
114750 --
114751 -- call analytical criteria
114752 --
114753
114754 --
114755 -- call description
114756 --
114757
114758 xla_ae_lines_pkg.SetLineDescription(
114759 p_ae_header_id => l_ae_header_id
114760 ,p_description => Description_1 (
114761 p_application_id => p_application_id
114762 , p_ae_header_id => l_ae_header_id
114763 , p_source_1 => p_source_1
114764 , p_source_2 => p_source_2
114765 , p_source_3 => p_source_3
114766 , p_source_4 => p_source_4
114767 , p_source_5 => p_source_5
114768 )
114769 );
114770
114771
114772 --
114773 -- call ADRs
114774 -- Bug 4922099
114775 --
114776 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
114777 (NVL(l_actual_upg_option, 'N') = 'O') OR
114778 (NVL(l_enc_upg_option, 'N') = 'O')
114779 )
114780 THEN
114781 NULL;
114782 --
114783 --
114784
114785 l_ccid := AcctDerRule_25(
114786 p_application_id => p_application_id
114787 , p_ae_header_id => l_ae_header_id
114788 , p_source_11 => p_source_11
114789 , p_source_15 => p_source_15
114790 , p_source_39 => p_source_39
114791 , p_source_39_meaning => p_source_39_meaning
114792 , p_source_41 => p_source_41
114793 , p_source_42 => p_source_42
114794 , p_source_43 => p_source_43
114795 , p_source_44 => p_source_44
114796 , p_source_45 => p_source_45
114797 , x_transaction_coa_id => l_adr_transaction_coa_id
114798 , x_accounting_coa_id => l_adr_accounting_coa_id
114799 , x_value_type_code => l_adr_value_type_code
114800 , p_side => 'NA'
114801 );
114802
114803 xla_ae_lines_pkg.set_ccid(
114804 p_code_combination_id => l_ccid
114805 , p_value_type_code => l_adr_value_type_code
114806 , p_transaction_coa_id => l_adr_transaction_coa_id
114807 , p_accounting_coa_id => l_adr_accounting_coa_id
114808 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
114809 , p_adr_type_code => 'S'
114810 , p_component_type => l_component_type
114811 , p_component_code => l_component_code
114812 , p_component_type_code => l_component_type_code
114813 , p_component_appl_id => l_component_appl_id
114814 , p_amb_context_code => l_amb_context_code
114815 , p_side => 'NA'
114816 );
114817
114818
114819 --
114820 --
114821 END IF;
114822 --
114823 -- Bug 4922099
114824 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
114825 (NVL(l_enc_upg_option, 'N') = 'O')
114826 ) AND
114827 (l_bflow_method_code = 'PRIOR_ENTRY')
114828 )
114829 THEN
114830 IF
114831 --
114832 1 = 2
114833 --
114834 THEN
114835 xla_accounting_err_pkg.build_message
114836 (p_appli_s_name => 'XLA'
114837 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
114838 ,p_token_1 => 'LINE_NUMBER'
114839 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
114840 ,p_token_2 => 'LINE_TYPE_NAME'
114841 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
114842 l_component_type
114843 ,l_component_code
114844 ,l_component_type_code
114845 ,l_component_appl_id
114846 ,l_amb_context_code
114847 ,l_entity_code
114848 ,l_event_class_code
114849 )
114850 ,p_token_3 => 'OWNER'
114851 ,p_value_3 => xla_lookups_pkg.get_meaning(
114852 p_lookup_type => 'XLA_OWNER_TYPE'
114853 ,p_lookup_code => l_component_type_code
114854 )
114855 ,p_token_4 => 'PRODUCT_NAME'
114856 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
114857 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
114858 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
114859 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
114860 ,p_ae_header_id => NULL
114861 );
114862
114863 IF (C_LEVEL_ERROR>= g_log_level) THEN
114864 trace
114865 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
114866 ,p_level => C_LEVEL_ERROR
114867 ,p_module => l_log_module);
114868 END IF;
114869 END IF;
114870 END IF;
114871 --
114872 --
114873 ------------------------------------------------------------------------------------------------
114874 -- 4219869 Business Flow
114875 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
114876 -- Prior Entry. Currently, the following code is always generated.
114877 ------------------------------------------------------------------------------------------------
114878 XLA_AE_LINES_PKG.ValidateCurrentLine;
114879
114880 ------------------------------------------------------------------------------------
114881 -- 4219869 Business Flow
114882 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
114883 ------------------------------------------------------------------------------------
114884 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
114885
114886 ----------------------------------------------------------------------------------
114887 -- 4219869 Business Flow
114888 -- Update journal entry status -- Need to generate this within IF <condition>
114889 ----------------------------------------------------------------------------------
114890 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
114891 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
114892 ,p_balance_type_code => l_balance_type_code
114893 );
114894
114895 -------------------------------------------------------------------------------------------
114896 -- 4262811 - Generate the Accrual Reversal lines
114897 -------------------------------------------------------------------------------------------
114898 BEGIN
114899 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
114900 (g_array_event(p_event_id).array_value_num('header_index'));
114901 IF l_acc_rev_flag IS NULL THEN
114902 l_acc_rev_flag := 'N';
114903 END IF;
114904 EXCEPTION
114905 WHEN OTHERS THEN
114906 l_acc_rev_flag := 'N';
114907 END;
114908 --
114909 IF (l_acc_rev_flag = 'Y') THEN
114910
114911 -- 4645092 ------------------------------------------------------------------------------
114912 -- To allow MPA report to determine if it should generate report process
114913 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
114914 ------------------------------------------------------------------------------------------
114915
114916 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
114917 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
114918 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
114919 -- call ADRs
114920 -- Bug 4922099
114921 --
114922 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
114923 (NVL(l_actual_upg_option, 'N') = 'O') OR
114924 (NVL(l_enc_upg_option, 'N') = 'O')
114925 )
114926 THEN
114927 NULL;
114928 --
114929 --
114930
114931 l_ccid := AcctDerRule_25(
114932 p_application_id => p_application_id
114933 , p_ae_header_id => l_ae_header_id
114934 , p_source_11 => p_source_11
114935 , p_source_15 => p_source_15
114936 , p_source_39 => p_source_39
114937 , p_source_39_meaning => p_source_39_meaning
114938 , p_source_41 => p_source_41
114939 , p_source_42 => p_source_42
114940 , p_source_43 => p_source_43
114941 , p_source_44 => p_source_44
114942 , p_source_45 => p_source_45
114943 , x_transaction_coa_id => l_adr_transaction_coa_id
114944 , x_accounting_coa_id => l_adr_accounting_coa_id
114945 , x_value_type_code => l_adr_value_type_code
114946 , p_side => 'NA'
114947 );
114948
114949 xla_ae_lines_pkg.set_ccid(
114950 p_code_combination_id => l_ccid
114951 , p_value_type_code => l_adr_value_type_code
114952 , p_transaction_coa_id => l_adr_transaction_coa_id
114953 , p_accounting_coa_id => l_adr_accounting_coa_id
114954 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
114955 , p_adr_type_code => 'S'
114956 , p_component_type => l_component_type
114957 , p_component_code => l_component_code
114958 , p_component_type_code => l_component_type_code
114959 , p_component_appl_id => l_component_appl_id
114960 , p_amb_context_code => l_amb_context_code
114961 , p_side => 'NA'
114962 );
114963
114964
114965 --
114966 --
114967 END IF;
114968
114969 --
114970 -- Update the line information that should be overwritten
114971 --
114972 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
114973 p_header_num => 1);
114974 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
114975
114976 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
114977
114978 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
114979 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
114980 END IF;
114981
114982 --
114983 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
114984 --
114985 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
114986 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
114987 ELSE
114988 ---------------------------------------------------------------------------------------------------
114989 -- 4262811a Switch Sign
114990 ---------------------------------------------------------------------------------------------------
114991 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
114992 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
114993 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114994 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
114995 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114996 -- 5132302
114997 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
114998 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
114999
115000 END IF;
115001
115002 -- 4955764
115003 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
115004 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
115005
115006
115007 XLA_AE_LINES_PKG.ValidateCurrentLine;
115008 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
115009
115010 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
115011 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
115012 ,p_balance_type_code => l_balance_type_code);
115013
115014 END IF;
115015
115016 -----------------------------------------------------------------------------------------
115017 -- 4262811 Multiperiod Accounting
115018 -----------------------------------------------------------------------------------------
115019 -- No MPA option is assigned.
115020
115021
115022 END IF;
115023 END IF;
115024 --
115025
115026 --
115027 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
115028 trace
115029 (p_msg => 'END of AcctLineType_224'
115030 ,p_level => C_LEVEL_PROCEDURE
115031 ,p_module => l_log_module);
115032 END IF;
115033 --
115034 EXCEPTION
115035 WHEN xla_exceptions_pkg.application_exception THEN
115036 RAISE;
115037 WHEN OTHERS THEN
115038 xla_exceptions_pkg.raise_message
115039 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_224');
115040 END AcctLineType_224;
115041 --
115042
115043 ---------------------------------------
115044 --
115045 -- PRIVATE FUNCTION
115046 -- AcctLineType_225
115047 --
115048 ---------------------------------------
115049 PROCEDURE AcctLineType_225 (
115050 p_application_id IN NUMBER
115051 ,p_event_id IN NUMBER
115052 ,p_calculate_acctd_flag IN VARCHAR2
115053 ,p_calculate_g_l_flag IN VARCHAR2
115054 ,p_actual_flag IN OUT VARCHAR2
115055 ,p_balance_type_code OUT VARCHAR2
115056 ,p_gain_or_loss_ref OUT VARCHAR2
115057
115058 --TRANSACTION_ID
115059 , p_source_1 IN NUMBER
115060 --Item Concatenated Segments
115061 , p_source_2 IN VARCHAR2
115062 --Transaction Quantity
115063 , p_source_3 IN NUMBER
115064 --Transaction Unit of Measure Code
115065 , p_source_4 IN VARCHAR2
115066 --Inventory Transaction Type Description
115067 , p_source_5 IN VARCHAR2
115068 --Cost Management Default Account
115069 , p_source_11 IN NUMBER
115070 --Cost Element Name
115071 , p_source_15 IN NUMBER
115072 --Primary Cost Method
115073 , p_source_39 IN NUMBER
115074 , p_source_39_meaning IN VARCHAR2
115075 --Product Line Accounting Category Material Account
115076 , p_source_41 IN NUMBER
115077 --Product Line Accounting Category Material Overhead Account
115078 , p_source_42 IN NUMBER
115079 --Product Line Accounting Category Resource Account
115080 , p_source_43 IN NUMBER
115081 --Product Line Accounting Category Outside Processing Account
115082 , p_source_44 IN NUMBER
115083 --Product Line Accounting Category Overhead Account
115084 , p_source_45 IN NUMBER
115085 --DISTRIBUTION_IDENTIFIER
115086 , p_source_84 IN NUMBER
115087 --Distribution Type
115088 , p_source_85 IN VARCHAR2
115089 , p_source_85_meaning IN VARCHAR2
115090 --Entered Currency Code
115091 , p_source_88 IN VARCHAR2
115092 --Entered Amount
115093 , p_source_91 IN NUMBER
115094 --Currency Conversion Date
115095 , p_source_92 IN DATE
115096 --Currency Conversion Rate
115097 , p_source_93 IN NUMBER
115098 --Currency Conversion Type
115099 , p_source_94 IN VARCHAR2
115100 --Accounted Amount
115101 , p_source_95 IN NUMBER
115102 --Accounting Line Type
115103 , p_source_97 IN NUMBER
115104 )
115105 IS
115106
115107 l_component_type VARCHAR2(80);
115108 l_component_code VARCHAR2(30);
115109 l_component_type_code VARCHAR2(1);
115110 l_component_appl_id INTEGER;
115111 l_amb_context_code VARCHAR2(30);
115112 l_entity_code VARCHAR2(30);
115113 l_event_class_code VARCHAR2(30);
115114 l_ae_header_id NUMBER;
115115 l_event_type_code VARCHAR2(30);
115116 l_line_definition_code VARCHAR2(30);
115117 l_line_definition_owner_code VARCHAR2(1);
115118 --
115119 -- adr variables
115120 l_segment VARCHAR2(30);
115121 l_ccid NUMBER;
115122 l_adr_transaction_coa_id NUMBER;
115123 l_adr_accounting_coa_id NUMBER;
115124 l_adr_flexfield_segment_code VARCHAR2(30);
115125 l_adr_flex_value_set_id NUMBER;
115126 l_adr_value_type_code VARCHAR2(30);
115127 l_adr_value_combination_id NUMBER;
115128 l_adr_value_segment_code VARCHAR2(30);
115129
115130 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
115131 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
115132 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
115133 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
115134
115135 -- 4262811 Variables ------------------------------------------------------------------------------------------
115136 l_entered_amt_idx NUMBER;
115137 l_accted_amt_idx NUMBER;
115138 l_acc_rev_flag VARCHAR2(1);
115139 l_accrual_line_num NUMBER;
115140 l_tmp_amt NUMBER;
115141 l_acc_rev_natural_side_code VARCHAR2(1);
115142
115143 l_num_entries NUMBER;
115144 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
115145 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
115146 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
115147 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
115148 l_recog_line_1 NUMBER;
115149 l_recog_line_2 NUMBER;
115150
115151 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
115152 l_bflow_applied_to_amt NUMBER; -- 5132302
115153 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
115154
115155 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
115156
115157 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
115158 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
115159
115160 ---------------------------------------------------------------------------------------------------------------
115161
115162
115163 --
115164 -- bulk performance
115165 --
115166 l_balance_type_code VARCHAR2(1);
115167 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
115168 l_log_module VARCHAR2(240);
115169
115170 --
115171 -- Upgrade strategy
115172 --
115173 l_actual_upg_option VARCHAR2(1);
115174 l_enc_upg_option VARCHAR2(1);
115175
115176 --
115177 BEGIN
115178 --
115179 IF g_log_enabled THEN
115180 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_225';
115181 END IF;
115182 --
115183 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
115184
115185 trace
115186 (p_msg => 'BEGIN of AcctLineType_225'
115187 ,p_level => C_LEVEL_PROCEDURE
115188 ,p_module => l_log_module);
115189
115190 END IF;
115191 --
115192 l_component_type := 'AMB_JLT';
115193 l_component_code := 'INTRANSIT_VALUATION';
115194 l_component_type_code := 'S';
115195 l_component_appl_id := 707;
115196 l_amb_context_code := 'DEFAULT';
115197 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
115198 l_event_class_code := 'USER_DEFINE';
115199 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
115200 l_line_definition_owner_code := 'S';
115201 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
115202 --
115203 l_balance_type_code := 'A';
115204 l_segment := NULL;
115205 l_ccid := NULL;
115206 l_adr_transaction_coa_id := NULL;
115207 l_adr_accounting_coa_id := NULL;
115208 l_adr_flexfield_segment_code := NULL;
115209 l_adr_flex_value_set_id := NULL;
115210 l_adr_value_type_code := NULL;
115211 l_adr_value_combination_id := NULL;
115212 l_adr_value_segment_code := NULL;
115213
115214 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
115215 l_bflow_class_code := ''; -- 4219869 Business Flow
115216 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
115217 l_budgetary_control_flag := 'N';
115218
115219 l_bflow_applied_to_amt_idx := NULL; -- 5132302
115220 l_bflow_applied_to_amt := NULL; -- 5132302
115221 l_entered_amt_idx := NULL; -- 4262811
115222 l_accted_amt_idx := NULL; -- 4262811
115223 l_acc_rev_flag := NULL; -- 4262811
115224 l_accrual_line_num := NULL; -- 4262811
115225 l_tmp_amt := NULL; -- 4262811
115226 --
115227
115228 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
115229 l_balance_type_code <> 'B' THEN
115230 IF NVL(p_source_97,9E125) = 14
115231 THEN
115232
115233 --
115234 XLA_AE_LINES_PKG.SetNewLine;
115235
115236 p_balance_type_code := l_balance_type_code;
115237 -- set the flag so later we will know whether the gain loss line needs to be created
115238
115239 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
115240 p_actual_flag :='A';
115241 END IF;
115242
115243 --
115244 -- bulk performance
115245 --
115246 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
115247 p_header_num => 0); -- 4262811
115248 --
115249 -- set accounting line options
115250 --
115251 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
115252 p_natural_side_code => 'D'
115253 , p_gain_or_loss_flag => 'N'
115254 , p_gl_transfer_mode_code => 'S'
115255 , p_acct_entry_type_code => 'A'
115256 , p_switch_side_flag => 'Y'
115257 , p_merge_duplicate_code => 'N'
115258 );
115259 --
115260 l_acc_rev_natural_side_code := 'C'; -- 4262811
115261 --
115262 --
115263 -- set accounting line type info
115264 --
115265 xla_ae_lines_pkg.SetAcctLineType
115266 (p_component_type => l_component_type
115267 ,p_event_type_code => l_event_type_code
115268 ,p_line_definition_owner_code => l_line_definition_owner_code
115269 ,p_line_definition_code => l_line_definition_code
115270 ,p_accounting_line_code => l_component_code
115271 ,p_accounting_line_type_code => l_component_type_code
115272 ,p_accounting_line_appl_id => l_component_appl_id
115273 ,p_amb_context_code => l_amb_context_code
115274 ,p_entity_code => l_entity_code
115275 ,p_event_class_code => l_event_class_code);
115276 --
115277 -- set accounting class
115278 --
115279 xla_ae_lines_pkg.SetAcctClass(
115280 p_accounting_class_code => 'INTRANSIT_VALUATION'
115281 , p_ae_header_id => l_ae_header_id
115282 );
115283
115284 --
115285 -- set rounding class
115286 --
115287 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
115288 'INTRANSIT_VALUATION';
115289
115290 --
115291 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
115292 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
115293 --
115294 -- bulk performance
115295 --
115296 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
115297
115298 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
115299 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
115300
115301 -- 4955764
115302 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
115303 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
115304
115305 -- 4458381 Public Sector Enh
115306
115307 --
115308 -- set accounting attributes for the line type
115309 --
115310 l_entered_amt_idx := 3;
115311 l_accted_amt_idx := 8;
115312 l_bflow_applied_to_amt_idx := NULL; -- 5132302
115313 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
115314 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
115315 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
115316 l_rec_acct_attrs.array_char_value(2) := p_source_85;
115317 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
115318 l_rec_acct_attrs.array_num_value(3) := p_source_91;
115319 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
115320 l_rec_acct_attrs.array_char_value(4) := p_source_88;
115321 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
115322 l_rec_acct_attrs.array_date_value(5) := p_source_92;
115323 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
115324 l_rec_acct_attrs.array_num_value(6) := p_source_93;
115325 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
115326 l_rec_acct_attrs.array_char_value(7) := p_source_94;
115327 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
115328 l_rec_acct_attrs.array_num_value(8) := p_source_95;
115329
115330 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
115331 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
115332
115333 ---------------------------------------------------------------------------------------------------------------
115334 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
115335 ---------------------------------------------------------------------------------------------------------------
115336 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
115337
115338 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
115339 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
115340
115341 IF xla_accounting_cache_pkg.GetValueChar
115342 (p_source_code => 'LEDGER_CATEGORY_CODE'
115343 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
115344 AND l_bflow_method_code = 'PRIOR_ENTRY'
115345 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
115346 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
115347 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
115348 )
115349 THEN
115350 xla_ae_lines_pkg.BflowUpgEntry
115351 (p_business_method_code => l_bflow_method_code
115352 ,p_business_class_code => l_bflow_class_code
115353 ,p_balance_type => l_balance_type_code);
115354 ELSE
115355 NULL;
115356 -- No business flow processing for business flow method of NONE.
115357 END IF;
115358
115359 --
115360 -- call analytical criteria
115361 --
115362
115363 --
115364 -- call description
115365 --
115366
115367 xla_ae_lines_pkg.SetLineDescription(
115368 p_ae_header_id => l_ae_header_id
115369 ,p_description => Description_1 (
115370 p_application_id => p_application_id
115371 , p_ae_header_id => l_ae_header_id
115372 , p_source_1 => p_source_1
115373 , p_source_2 => p_source_2
115374 , p_source_3 => p_source_3
115375 , p_source_4 => p_source_4
115376 , p_source_5 => p_source_5
115377 )
115378 );
115379
115380
115381 --
115382 -- call ADRs
115383 -- Bug 4922099
115384 --
115385 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
115386 (NVL(l_actual_upg_option, 'N') = 'O') OR
115387 (NVL(l_enc_upg_option, 'N') = 'O')
115388 )
115389 THEN
115390 NULL;
115391 --
115392 --
115393
115394 l_ccid := AcctDerRule_25(
115395 p_application_id => p_application_id
115396 , p_ae_header_id => l_ae_header_id
115397 , p_source_11 => p_source_11
115398 , p_source_15 => p_source_15
115399 , p_source_39 => p_source_39
115400 , p_source_39_meaning => p_source_39_meaning
115401 , p_source_41 => p_source_41
115402 , p_source_42 => p_source_42
115403 , p_source_43 => p_source_43
115404 , p_source_44 => p_source_44
115405 , p_source_45 => p_source_45
115406 , x_transaction_coa_id => l_adr_transaction_coa_id
115407 , x_accounting_coa_id => l_adr_accounting_coa_id
115408 , x_value_type_code => l_adr_value_type_code
115409 , p_side => 'NA'
115410 );
115411
115412 xla_ae_lines_pkg.set_ccid(
115413 p_code_combination_id => l_ccid
115414 , p_value_type_code => l_adr_value_type_code
115415 , p_transaction_coa_id => l_adr_transaction_coa_id
115416 , p_accounting_coa_id => l_adr_accounting_coa_id
115417 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
115418 , p_adr_type_code => 'S'
115419 , p_component_type => l_component_type
115420 , p_component_code => l_component_code
115421 , p_component_type_code => l_component_type_code
115422 , p_component_appl_id => l_component_appl_id
115423 , p_amb_context_code => l_amb_context_code
115424 , p_side => 'NA'
115425 );
115426
115427
115428 --
115429 --
115430 END IF;
115431 --
115432 -- Bug 4922099
115433 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
115434 (NVL(l_enc_upg_option, 'N') = 'O')
115435 ) AND
115436 (l_bflow_method_code = 'PRIOR_ENTRY')
115437 )
115438 THEN
115439 IF
115440 --
115441 1 = 2
115442 --
115443 THEN
115444 xla_accounting_err_pkg.build_message
115445 (p_appli_s_name => 'XLA'
115446 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
115447 ,p_token_1 => 'LINE_NUMBER'
115448 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
115449 ,p_token_2 => 'LINE_TYPE_NAME'
115450 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
115451 l_component_type
115452 ,l_component_code
115453 ,l_component_type_code
115454 ,l_component_appl_id
115455 ,l_amb_context_code
115456 ,l_entity_code
115457 ,l_event_class_code
115458 )
115459 ,p_token_3 => 'OWNER'
115460 ,p_value_3 => xla_lookups_pkg.get_meaning(
115461 p_lookup_type => 'XLA_OWNER_TYPE'
115462 ,p_lookup_code => l_component_type_code
115463 )
115464 ,p_token_4 => 'PRODUCT_NAME'
115465 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
115466 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
115467 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
115468 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
115469 ,p_ae_header_id => NULL
115470 );
115471
115472 IF (C_LEVEL_ERROR>= g_log_level) THEN
115473 trace
115474 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
115475 ,p_level => C_LEVEL_ERROR
115476 ,p_module => l_log_module);
115477 END IF;
115478 END IF;
115479 END IF;
115480 --
115481 --
115482 ------------------------------------------------------------------------------------------------
115483 -- 4219869 Business Flow
115484 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
115485 -- Prior Entry. Currently, the following code is always generated.
115486 ------------------------------------------------------------------------------------------------
115487 XLA_AE_LINES_PKG.ValidateCurrentLine;
115488
115489 ------------------------------------------------------------------------------------
115490 -- 4219869 Business Flow
115491 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
115492 ------------------------------------------------------------------------------------
115493 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
115494
115495 ----------------------------------------------------------------------------------
115496 -- 4219869 Business Flow
115497 -- Update journal entry status -- Need to generate this within IF <condition>
115498 ----------------------------------------------------------------------------------
115499 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
115500 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
115501 ,p_balance_type_code => l_balance_type_code
115502 );
115503
115504 -------------------------------------------------------------------------------------------
115505 -- 4262811 - Generate the Accrual Reversal lines
115506 -------------------------------------------------------------------------------------------
115507 BEGIN
115508 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
115509 (g_array_event(p_event_id).array_value_num('header_index'));
115510 IF l_acc_rev_flag IS NULL THEN
115511 l_acc_rev_flag := 'N';
115512 END IF;
115513 EXCEPTION
115514 WHEN OTHERS THEN
115515 l_acc_rev_flag := 'N';
115516 END;
115517 --
115518 IF (l_acc_rev_flag = 'Y') THEN
115519
115520 -- 4645092 ------------------------------------------------------------------------------
115521 -- To allow MPA report to determine if it should generate report process
115522 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
115523 ------------------------------------------------------------------------------------------
115524
115525 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
115526 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
115527 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
115528 -- call ADRs
115529 -- Bug 4922099
115530 --
115531 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
115532 (NVL(l_actual_upg_option, 'N') = 'O') OR
115533 (NVL(l_enc_upg_option, 'N') = 'O')
115534 )
115535 THEN
115536 NULL;
115537 --
115538 --
115539
115540 l_ccid := AcctDerRule_25(
115541 p_application_id => p_application_id
115542 , p_ae_header_id => l_ae_header_id
115543 , p_source_11 => p_source_11
115544 , p_source_15 => p_source_15
115545 , p_source_39 => p_source_39
115546 , p_source_39_meaning => p_source_39_meaning
115547 , p_source_41 => p_source_41
115548 , p_source_42 => p_source_42
115549 , p_source_43 => p_source_43
115550 , p_source_44 => p_source_44
115551 , p_source_45 => p_source_45
115552 , x_transaction_coa_id => l_adr_transaction_coa_id
115553 , x_accounting_coa_id => l_adr_accounting_coa_id
115554 , x_value_type_code => l_adr_value_type_code
115555 , p_side => 'NA'
115556 );
115557
115558 xla_ae_lines_pkg.set_ccid(
115559 p_code_combination_id => l_ccid
115560 , p_value_type_code => l_adr_value_type_code
115561 , p_transaction_coa_id => l_adr_transaction_coa_id
115562 , p_accounting_coa_id => l_adr_accounting_coa_id
115563 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
115564 , p_adr_type_code => 'S'
115565 , p_component_type => l_component_type
115566 , p_component_code => l_component_code
115567 , p_component_type_code => l_component_type_code
115568 , p_component_appl_id => l_component_appl_id
115569 , p_amb_context_code => l_amb_context_code
115570 , p_side => 'NA'
115571 );
115572
115573
115574 --
115575 --
115576 END IF;
115577
115578 --
115579 -- Update the line information that should be overwritten
115580 --
115581 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
115582 p_header_num => 1);
115583 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
115584
115585 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
115586
115587 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
115588 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
115589 END IF;
115590
115591 --
115592 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
115593 --
115594 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
115595 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
115596 ELSE
115597 ---------------------------------------------------------------------------------------------------
115598 -- 4262811a Switch Sign
115599 ---------------------------------------------------------------------------------------------------
115600 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
115601 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
115602 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
115603 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
115604 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
115605 -- 5132302
115606 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
115607 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
115608
115609 END IF;
115610
115611 -- 4955764
115612 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
115613 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
115614
115615
115616 XLA_AE_LINES_PKG.ValidateCurrentLine;
115617 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
115618
115619 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
115620 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
115621 ,p_balance_type_code => l_balance_type_code);
115622
115623 END IF;
115624
115625 -----------------------------------------------------------------------------------------
115626 -- 4262811 Multiperiod Accounting
115627 -----------------------------------------------------------------------------------------
115628 -- No MPA option is assigned.
115629
115630
115631 END IF;
115632 END IF;
115633 --
115634
115635 --
115636 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
115637 trace
115638 (p_msg => 'END of AcctLineType_225'
115639 ,p_level => C_LEVEL_PROCEDURE
115640 ,p_module => l_log_module);
115641 END IF;
115642 --
115643 EXCEPTION
115644 WHEN xla_exceptions_pkg.application_exception THEN
115645 RAISE;
115646 WHEN OTHERS THEN
115647 xla_exceptions_pkg.raise_message
115648 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_225');
115649 END AcctLineType_225;
115650 --
115651
115652 ---------------------------------------
115653 --
115654 -- PRIVATE FUNCTION
115655 -- AcctLineType_226
115656 --
115657 ---------------------------------------
115658 PROCEDURE AcctLineType_226 (
115659 p_application_id IN NUMBER
115660 ,p_event_id IN NUMBER
115661 ,p_calculate_acctd_flag IN VARCHAR2
115662 ,p_calculate_g_l_flag IN VARCHAR2
115663 ,p_actual_flag IN OUT VARCHAR2
115664 ,p_balance_type_code OUT VARCHAR2
115665 ,p_gain_or_loss_ref OUT VARCHAR2
115666
115667 --TRANSACTION_ID
115668 , p_source_1 IN NUMBER
115669 --Item Concatenated Segments
115670 , p_source_2 IN VARCHAR2
115671 --Transaction Quantity
115672 , p_source_3 IN NUMBER
115673 --Transaction Unit of Measure Code
115674 , p_source_4 IN VARCHAR2
115675 --Inventory Transaction Type Description
115676 , p_source_5 IN VARCHAR2
115677 --Cost Management Default Account
115678 , p_source_11 IN NUMBER
115679 --Cost Element Name
115680 , p_source_15 IN NUMBER
115681 --Primary Cost Method
115682 , p_source_39 IN NUMBER
115683 , p_source_39_meaning IN VARCHAR2
115684 --Product Line Accounting Category Material Account
115685 , p_source_41 IN NUMBER
115686 --Product Line Accounting Category Material Overhead Account
115687 , p_source_42 IN NUMBER
115688 --Product Line Accounting Category Resource Account
115689 , p_source_43 IN NUMBER
115690 --Product Line Accounting Category Outside Processing Account
115691 , p_source_44 IN NUMBER
115692 --Product Line Accounting Category Overhead Account
115693 , p_source_45 IN NUMBER
115694 --DISTRIBUTION_IDENTIFIER
115695 , p_source_84 IN NUMBER
115696 --Distribution Type
115697 , p_source_85 IN VARCHAR2
115698 , p_source_85_meaning IN VARCHAR2
115699 --Entered Currency Code
115700 , p_source_88 IN VARCHAR2
115701 --Entered Amount
115702 , p_source_91 IN NUMBER
115703 --Currency Conversion Date
115704 , p_source_92 IN DATE
115705 --Currency Conversion Rate
115706 , p_source_93 IN NUMBER
115707 --Currency Conversion Type
115708 , p_source_94 IN VARCHAR2
115709 --Accounted Amount
115710 , p_source_95 IN NUMBER
115711 --Accounting Line Type
115712 , p_source_97 IN NUMBER
115713 )
115714 IS
115715
115716 l_component_type VARCHAR2(80);
115717 l_component_code VARCHAR2(30);
115718 l_component_type_code VARCHAR2(1);
115719 l_component_appl_id INTEGER;
115720 l_amb_context_code VARCHAR2(30);
115721 l_entity_code VARCHAR2(30);
115722 l_event_class_code VARCHAR2(30);
115723 l_ae_header_id NUMBER;
115724 l_event_type_code VARCHAR2(30);
115725 l_line_definition_code VARCHAR2(30);
115726 l_line_definition_owner_code VARCHAR2(1);
115727 --
115728 -- adr variables
115729 l_segment VARCHAR2(30);
115730 l_ccid NUMBER;
115731 l_adr_transaction_coa_id NUMBER;
115732 l_adr_accounting_coa_id NUMBER;
115733 l_adr_flexfield_segment_code VARCHAR2(30);
115734 l_adr_flex_value_set_id NUMBER;
115735 l_adr_value_type_code VARCHAR2(30);
115736 l_adr_value_combination_id NUMBER;
115737 l_adr_value_segment_code VARCHAR2(30);
115738
115739 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
115740 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
115741 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
115742 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
115743
115744 -- 4262811 Variables ------------------------------------------------------------------------------------------
115745 l_entered_amt_idx NUMBER;
115746 l_accted_amt_idx NUMBER;
115747 l_acc_rev_flag VARCHAR2(1);
115748 l_accrual_line_num NUMBER;
115749 l_tmp_amt NUMBER;
115750 l_acc_rev_natural_side_code VARCHAR2(1);
115751
115752 l_num_entries NUMBER;
115753 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
115754 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
115755 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
115756 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
115757 l_recog_line_1 NUMBER;
115758 l_recog_line_2 NUMBER;
115759
115760 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
115761 l_bflow_applied_to_amt NUMBER; -- 5132302
115762 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
115763
115764 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
115765
115766 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
115767 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
115768
115769 ---------------------------------------------------------------------------------------------------------------
115770
115771
115772 --
115773 -- bulk performance
115774 --
115775 l_balance_type_code VARCHAR2(1);
115776 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
115777 l_log_module VARCHAR2(240);
115778
115779 --
115780 -- Upgrade strategy
115781 --
115782 l_actual_upg_option VARCHAR2(1);
115783 l_enc_upg_option VARCHAR2(1);
115784
115785 --
115786 BEGIN
115787 --
115788 IF g_log_enabled THEN
115789 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_226';
115790 END IF;
115791 --
115792 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
115793
115794 trace
115795 (p_msg => 'BEGIN of AcctLineType_226'
115796 ,p_level => C_LEVEL_PROCEDURE
115797 ,p_module => l_log_module);
115798
115799 END IF;
115800 --
115801 l_component_type := 'AMB_JLT';
115802 l_component_code := 'INTRANSIT_VALUATION';
115803 l_component_type_code := 'S';
115804 l_component_appl_id := 707;
115805 l_amb_context_code := 'DEFAULT';
115806 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
115807 l_event_class_code := 'USER_DEFINE';
115808 l_event_type_code := 'UFOB_RCPT_SENDER_SHIP';
115809 l_line_definition_owner_code := 'S';
115810 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
115811 --
115812 l_balance_type_code := 'A';
115813 l_segment := NULL;
115814 l_ccid := NULL;
115815 l_adr_transaction_coa_id := NULL;
115816 l_adr_accounting_coa_id := NULL;
115817 l_adr_flexfield_segment_code := NULL;
115818 l_adr_flex_value_set_id := NULL;
115819 l_adr_value_type_code := NULL;
115820 l_adr_value_combination_id := NULL;
115821 l_adr_value_segment_code := NULL;
115822
115823 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
115824 l_bflow_class_code := ''; -- 4219869 Business Flow
115825 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
115826 l_budgetary_control_flag := 'N';
115827
115828 l_bflow_applied_to_amt_idx := NULL; -- 5132302
115829 l_bflow_applied_to_amt := NULL; -- 5132302
115830 l_entered_amt_idx := NULL; -- 4262811
115831 l_accted_amt_idx := NULL; -- 4262811
115832 l_acc_rev_flag := NULL; -- 4262811
115833 l_accrual_line_num := NULL; -- 4262811
115834 l_tmp_amt := NULL; -- 4262811
115835 --
115836
115837 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
115838 l_balance_type_code <> 'B' THEN
115839 IF NVL(p_source_97,9E125) = 14
115840 THEN
115841
115842 --
115843 XLA_AE_LINES_PKG.SetNewLine;
115844
115845 p_balance_type_code := l_balance_type_code;
115846 -- set the flag so later we will know whether the gain loss line needs to be created
115847
115848 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
115849 p_actual_flag :='A';
115850 END IF;
115851
115852 --
115853 -- bulk performance
115854 --
115855 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
115856 p_header_num => 0); -- 4262811
115857 --
115858 -- set accounting line options
115859 --
115860 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
115861 p_natural_side_code => 'D'
115862 , p_gain_or_loss_flag => 'N'
115863 , p_gl_transfer_mode_code => 'S'
115864 , p_acct_entry_type_code => 'A'
115865 , p_switch_side_flag => 'Y'
115866 , p_merge_duplicate_code => 'N'
115867 );
115868 --
115869 l_acc_rev_natural_side_code := 'C'; -- 4262811
115870 --
115871 --
115872 -- set accounting line type info
115873 --
115874 xla_ae_lines_pkg.SetAcctLineType
115875 (p_component_type => l_component_type
115876 ,p_event_type_code => l_event_type_code
115877 ,p_line_definition_owner_code => l_line_definition_owner_code
115878 ,p_line_definition_code => l_line_definition_code
115879 ,p_accounting_line_code => l_component_code
115880 ,p_accounting_line_type_code => l_component_type_code
115881 ,p_accounting_line_appl_id => l_component_appl_id
115882 ,p_amb_context_code => l_amb_context_code
115883 ,p_entity_code => l_entity_code
115884 ,p_event_class_code => l_event_class_code);
115885 --
115886 -- set accounting class
115887 --
115888 xla_ae_lines_pkg.SetAcctClass(
115889 p_accounting_class_code => 'INTRANSIT_VALUATION'
115890 , p_ae_header_id => l_ae_header_id
115891 );
115892
115893 --
115894 -- set rounding class
115895 --
115896 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
115897 'INTRANSIT_VALUATION';
115898
115899 --
115900 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
115901 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
115902 --
115903 -- bulk performance
115904 --
115905 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
115906
115907 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
115908 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
115909
115910 -- 4955764
115911 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
115912 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
115913
115914 -- 4458381 Public Sector Enh
115915
115916 --
115917 -- set accounting attributes for the line type
115918 --
115919 l_entered_amt_idx := 3;
115920 l_accted_amt_idx := 8;
115921 l_bflow_applied_to_amt_idx := NULL; -- 5132302
115922 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
115923 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
115924 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
115925 l_rec_acct_attrs.array_char_value(2) := p_source_85;
115926 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
115927 l_rec_acct_attrs.array_num_value(3) := p_source_91;
115928 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
115929 l_rec_acct_attrs.array_char_value(4) := p_source_88;
115930 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
115931 l_rec_acct_attrs.array_date_value(5) := p_source_92;
115932 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
115933 l_rec_acct_attrs.array_num_value(6) := p_source_93;
115934 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
115935 l_rec_acct_attrs.array_char_value(7) := p_source_94;
115936 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
115937 l_rec_acct_attrs.array_num_value(8) := p_source_95;
115938
115939 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
115940 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
115941
115942 ---------------------------------------------------------------------------------------------------------------
115943 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
115944 ---------------------------------------------------------------------------------------------------------------
115945 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
115946
115947 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
115948 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
115949
115950 IF xla_accounting_cache_pkg.GetValueChar
115951 (p_source_code => 'LEDGER_CATEGORY_CODE'
115952 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
115953 AND l_bflow_method_code = 'PRIOR_ENTRY'
115954 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
115955 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
115956 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
115957 )
115958 THEN
115959 xla_ae_lines_pkg.BflowUpgEntry
115960 (p_business_method_code => l_bflow_method_code
115961 ,p_business_class_code => l_bflow_class_code
115962 ,p_balance_type => l_balance_type_code);
115963 ELSE
115964 NULL;
115965 -- No business flow processing for business flow method of NONE.
115966 END IF;
115967
115968 --
115969 -- call analytical criteria
115970 --
115971
115972 --
115973 -- call description
115974 --
115975
115976 xla_ae_lines_pkg.SetLineDescription(
115977 p_ae_header_id => l_ae_header_id
115978 ,p_description => Description_1 (
115979 p_application_id => p_application_id
115980 , p_ae_header_id => l_ae_header_id
115981 , p_source_1 => p_source_1
115982 , p_source_2 => p_source_2
115983 , p_source_3 => p_source_3
115984 , p_source_4 => p_source_4
115985 , p_source_5 => p_source_5
115986 )
115987 );
115988
115989
115990 --
115991 -- call ADRs
115992 -- Bug 4922099
115993 --
115994 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
115995 (NVL(l_actual_upg_option, 'N') = 'O') OR
115996 (NVL(l_enc_upg_option, 'N') = 'O')
115997 )
115998 THEN
115999 NULL;
116000 --
116001 --
116002
116003 l_ccid := AcctDerRule_25(
116004 p_application_id => p_application_id
116005 , p_ae_header_id => l_ae_header_id
116006 , p_source_11 => p_source_11
116007 , p_source_15 => p_source_15
116008 , p_source_39 => p_source_39
116009 , p_source_39_meaning => p_source_39_meaning
116010 , p_source_41 => p_source_41
116011 , p_source_42 => p_source_42
116012 , p_source_43 => p_source_43
116013 , p_source_44 => p_source_44
116014 , p_source_45 => p_source_45
116015 , x_transaction_coa_id => l_adr_transaction_coa_id
116016 , x_accounting_coa_id => l_adr_accounting_coa_id
116017 , x_value_type_code => l_adr_value_type_code
116018 , p_side => 'NA'
116019 );
116020
116021 xla_ae_lines_pkg.set_ccid(
116022 p_code_combination_id => l_ccid
116023 , p_value_type_code => l_adr_value_type_code
116024 , p_transaction_coa_id => l_adr_transaction_coa_id
116025 , p_accounting_coa_id => l_adr_accounting_coa_id
116026 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
116027 , p_adr_type_code => 'S'
116028 , p_component_type => l_component_type
116029 , p_component_code => l_component_code
116030 , p_component_type_code => l_component_type_code
116031 , p_component_appl_id => l_component_appl_id
116032 , p_amb_context_code => l_amb_context_code
116033 , p_side => 'NA'
116034 );
116035
116036
116037 --
116038 --
116039 END IF;
116040 --
116041 -- Bug 4922099
116042 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
116043 (NVL(l_enc_upg_option, 'N') = 'O')
116044 ) AND
116045 (l_bflow_method_code = 'PRIOR_ENTRY')
116046 )
116047 THEN
116048 IF
116049 --
116050 1 = 2
116051 --
116052 THEN
116053 xla_accounting_err_pkg.build_message
116054 (p_appli_s_name => 'XLA'
116055 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
116056 ,p_token_1 => 'LINE_NUMBER'
116057 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
116058 ,p_token_2 => 'LINE_TYPE_NAME'
116059 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
116060 l_component_type
116061 ,l_component_code
116062 ,l_component_type_code
116063 ,l_component_appl_id
116064 ,l_amb_context_code
116065 ,l_entity_code
116066 ,l_event_class_code
116067 )
116068 ,p_token_3 => 'OWNER'
116069 ,p_value_3 => xla_lookups_pkg.get_meaning(
116070 p_lookup_type => 'XLA_OWNER_TYPE'
116071 ,p_lookup_code => l_component_type_code
116072 )
116073 ,p_token_4 => 'PRODUCT_NAME'
116074 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
116075 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
116076 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
116077 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
116078 ,p_ae_header_id => NULL
116079 );
116080
116081 IF (C_LEVEL_ERROR>= g_log_level) THEN
116082 trace
116083 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
116084 ,p_level => C_LEVEL_ERROR
116085 ,p_module => l_log_module);
116086 END IF;
116087 END IF;
116088 END IF;
116089 --
116090 --
116091 ------------------------------------------------------------------------------------------------
116092 -- 4219869 Business Flow
116093 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
116094 -- Prior Entry. Currently, the following code is always generated.
116095 ------------------------------------------------------------------------------------------------
116096 XLA_AE_LINES_PKG.ValidateCurrentLine;
116097
116098 ------------------------------------------------------------------------------------
116099 -- 4219869 Business Flow
116100 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
116101 ------------------------------------------------------------------------------------
116102 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
116103
116104 ----------------------------------------------------------------------------------
116105 -- 4219869 Business Flow
116106 -- Update journal entry status -- Need to generate this within IF <condition>
116107 ----------------------------------------------------------------------------------
116108 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
116109 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
116110 ,p_balance_type_code => l_balance_type_code
116111 );
116112
116113 -------------------------------------------------------------------------------------------
116114 -- 4262811 - Generate the Accrual Reversal lines
116115 -------------------------------------------------------------------------------------------
116116 BEGIN
116117 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
116118 (g_array_event(p_event_id).array_value_num('header_index'));
116119 IF l_acc_rev_flag IS NULL THEN
116120 l_acc_rev_flag := 'N';
116121 END IF;
116122 EXCEPTION
116123 WHEN OTHERS THEN
116124 l_acc_rev_flag := 'N';
116125 END;
116126 --
116127 IF (l_acc_rev_flag = 'Y') THEN
116128
116129 -- 4645092 ------------------------------------------------------------------------------
116130 -- To allow MPA report to determine if it should generate report process
116131 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
116132 ------------------------------------------------------------------------------------------
116133
116134 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
116135 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
116136 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
116137 -- call ADRs
116138 -- Bug 4922099
116139 --
116140 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
116141 (NVL(l_actual_upg_option, 'N') = 'O') OR
116142 (NVL(l_enc_upg_option, 'N') = 'O')
116143 )
116144 THEN
116145 NULL;
116146 --
116147 --
116148
116149 l_ccid := AcctDerRule_25(
116150 p_application_id => p_application_id
116151 , p_ae_header_id => l_ae_header_id
116152 , p_source_11 => p_source_11
116153 , p_source_15 => p_source_15
116154 , p_source_39 => p_source_39
116155 , p_source_39_meaning => p_source_39_meaning
116156 , p_source_41 => p_source_41
116157 , p_source_42 => p_source_42
116158 , p_source_43 => p_source_43
116159 , p_source_44 => p_source_44
116160 , p_source_45 => p_source_45
116161 , x_transaction_coa_id => l_adr_transaction_coa_id
116162 , x_accounting_coa_id => l_adr_accounting_coa_id
116163 , x_value_type_code => l_adr_value_type_code
116164 , p_side => 'NA'
116165 );
116166
116167 xla_ae_lines_pkg.set_ccid(
116168 p_code_combination_id => l_ccid
116169 , p_value_type_code => l_adr_value_type_code
116170 , p_transaction_coa_id => l_adr_transaction_coa_id
116171 , p_accounting_coa_id => l_adr_accounting_coa_id
116172 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
116173 , p_adr_type_code => 'S'
116174 , p_component_type => l_component_type
116175 , p_component_code => l_component_code
116176 , p_component_type_code => l_component_type_code
116177 , p_component_appl_id => l_component_appl_id
116178 , p_amb_context_code => l_amb_context_code
116179 , p_side => 'NA'
116180 );
116181
116182
116183 --
116184 --
116185 END IF;
116186
116187 --
116188 -- Update the line information that should be overwritten
116189 --
116190 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
116191 p_header_num => 1);
116192 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
116193
116194 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
116195
116196 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
116197 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
116198 END IF;
116199
116200 --
116201 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
116202 --
116203 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
116204 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
116205 ELSE
116206 ---------------------------------------------------------------------------------------------------
116207 -- 4262811a Switch Sign
116208 ---------------------------------------------------------------------------------------------------
116209 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
116210 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
116211 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116212 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
116213 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116214 -- 5132302
116215 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
116216 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116217
116218 END IF;
116219
116220 -- 4955764
116221 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
116222 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
116223
116224
116225 XLA_AE_LINES_PKG.ValidateCurrentLine;
116226 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
116227
116228 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
116229 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
116230 ,p_balance_type_code => l_balance_type_code);
116231
116232 END IF;
116233
116234 -----------------------------------------------------------------------------------------
116235 -- 4262811 Multiperiod Accounting
116236 -----------------------------------------------------------------------------------------
116237 -- No MPA option is assigned.
116238
116239
116240 END IF;
116241 END IF;
116242 --
116243
116244 --
116245 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
116246 trace
116247 (p_msg => 'END of AcctLineType_226'
116248 ,p_level => C_LEVEL_PROCEDURE
116249 ,p_module => l_log_module);
116250 END IF;
116251 --
116252 EXCEPTION
116253 WHEN xla_exceptions_pkg.application_exception THEN
116254 RAISE;
116255 WHEN OTHERS THEN
116256 xla_exceptions_pkg.raise_message
116257 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_226');
116258 END AcctLineType_226;
116259 --
116260
116261 ---------------------------------------
116262 --
116263 -- PRIVATE FUNCTION
116264 -- AcctLineType_227
116265 --
116266 ---------------------------------------
116267 PROCEDURE AcctLineType_227 (
116268 p_application_id IN NUMBER
116269 ,p_event_id IN NUMBER
116270 ,p_calculate_acctd_flag IN VARCHAR2
116271 ,p_calculate_g_l_flag IN VARCHAR2
116272 ,p_actual_flag IN OUT VARCHAR2
116273 ,p_balance_type_code OUT VARCHAR2
116274 ,p_gain_or_loss_ref OUT VARCHAR2
116275
116276 --TRANSACTION_ID
116277 , p_source_1 IN NUMBER
116278 --Item Concatenated Segments
116279 , p_source_2 IN VARCHAR2
116280 --Transaction Quantity
116281 , p_source_3 IN NUMBER
116282 --Transaction Unit of Measure Code
116283 , p_source_4 IN VARCHAR2
116284 --Inventory Transaction Type Description
116285 , p_source_5 IN VARCHAR2
116286 --Cost Management Default Account
116287 , p_source_11 IN NUMBER
116288 --DISTRIBUTION_IDENTIFIER
116289 , p_source_84 IN NUMBER
116290 --Distribution Type
116291 , p_source_85 IN VARCHAR2
116292 , p_source_85_meaning IN VARCHAR2
116293 --Entered Currency Code
116294 , p_source_88 IN VARCHAR2
116295 --Entered Amount
116296 , p_source_91 IN NUMBER
116297 --Currency Conversion Date
116298 , p_source_92 IN DATE
116299 --Currency Conversion Rate
116300 , p_source_93 IN NUMBER
116301 --Currency Conversion Type
116302 , p_source_94 IN VARCHAR2
116303 --Accounted Amount
116304 , p_source_95 IN NUMBER
116305 --Accounting Line Type
116306 , p_source_97 IN NUMBER
116307 )
116308 IS
116309
116310 l_component_type VARCHAR2(80);
116311 l_component_code VARCHAR2(30);
116312 l_component_type_code VARCHAR2(1);
116313 l_component_appl_id INTEGER;
116314 l_amb_context_code VARCHAR2(30);
116315 l_entity_code VARCHAR2(30);
116316 l_event_class_code VARCHAR2(30);
116317 l_ae_header_id NUMBER;
116318 l_event_type_code VARCHAR2(30);
116319 l_line_definition_code VARCHAR2(30);
116320 l_line_definition_owner_code VARCHAR2(1);
116321 --
116322 -- adr variables
116323 l_segment VARCHAR2(30);
116324 l_ccid NUMBER;
116325 l_adr_transaction_coa_id NUMBER;
116326 l_adr_accounting_coa_id NUMBER;
116327 l_adr_flexfield_segment_code VARCHAR2(30);
116328 l_adr_flex_value_set_id NUMBER;
116329 l_adr_value_type_code VARCHAR2(30);
116330 l_adr_value_combination_id NUMBER;
116331 l_adr_value_segment_code VARCHAR2(30);
116332
116333 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
116334 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
116335 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
116336 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
116337
116338 -- 4262811 Variables ------------------------------------------------------------------------------------------
116339 l_entered_amt_idx NUMBER;
116340 l_accted_amt_idx NUMBER;
116341 l_acc_rev_flag VARCHAR2(1);
116342 l_accrual_line_num NUMBER;
116343 l_tmp_amt NUMBER;
116344 l_acc_rev_natural_side_code VARCHAR2(1);
116345
116346 l_num_entries NUMBER;
116347 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
116348 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
116349 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
116350 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
116351 l_recog_line_1 NUMBER;
116352 l_recog_line_2 NUMBER;
116353
116354 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
116355 l_bflow_applied_to_amt NUMBER; -- 5132302
116356 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
116357
116358 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
116359
116360 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
116361 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
116362
116363 ---------------------------------------------------------------------------------------------------------------
116364
116365
116366 --
116367 -- bulk performance
116368 --
116369 l_balance_type_code VARCHAR2(1);
116370 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
116371 l_log_module VARCHAR2(240);
116372
116373 --
116374 -- Upgrade strategy
116375 --
116376 l_actual_upg_option VARCHAR2(1);
116377 l_enc_upg_option VARCHAR2(1);
116378
116379 --
116380 BEGIN
116381 --
116382 IF g_log_enabled THEN
116383 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_227';
116384 END IF;
116385 --
116386 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
116387
116388 trace
116389 (p_msg => 'BEGIN of AcctLineType_227'
116390 ,p_level => C_LEVEL_PROCEDURE
116391 ,p_module => l_log_module);
116392
116393 END IF;
116394 --
116395 l_component_type := 'AMB_JLT';
116396 l_component_code := 'INTRANSIT_VALUATION';
116397 l_component_type_code := 'S';
116398 l_component_appl_id := 707;
116399 l_amb_context_code := 'DEFAULT';
116400 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
116401 l_event_class_code := 'USER_DEFINE';
116402 l_event_type_code := 'UAVG_COST_UPD';
116403 l_line_definition_owner_code := 'S';
116404 l_line_definition_code := 'PI_COST_UPD';
116405 --
116406 l_balance_type_code := 'A';
116407 l_segment := NULL;
116408 l_ccid := NULL;
116409 l_adr_transaction_coa_id := NULL;
116410 l_adr_accounting_coa_id := NULL;
116411 l_adr_flexfield_segment_code := NULL;
116412 l_adr_flex_value_set_id := NULL;
116413 l_adr_value_type_code := NULL;
116414 l_adr_value_combination_id := NULL;
116415 l_adr_value_segment_code := NULL;
116416
116417 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
116418 l_bflow_class_code := ''; -- 4219869 Business Flow
116419 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
116420 l_budgetary_control_flag := 'N';
116421
116422 l_bflow_applied_to_amt_idx := NULL; -- 5132302
116423 l_bflow_applied_to_amt := NULL; -- 5132302
116424 l_entered_amt_idx := NULL; -- 4262811
116425 l_accted_amt_idx := NULL; -- 4262811
116426 l_acc_rev_flag := NULL; -- 4262811
116427 l_accrual_line_num := NULL; -- 4262811
116428 l_tmp_amt := NULL; -- 4262811
116429 --
116430
116431 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
116432 l_balance_type_code <> 'B' THEN
116433 IF NVL(p_source_97,9E125) = 14
116434 THEN
116435
116436 --
116437 XLA_AE_LINES_PKG.SetNewLine;
116438
116439 p_balance_type_code := l_balance_type_code;
116440 -- set the flag so later we will know whether the gain loss line needs to be created
116441
116442 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
116443 p_actual_flag :='A';
116444 END IF;
116445
116446 --
116447 -- bulk performance
116448 --
116449 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
116450 p_header_num => 0); -- 4262811
116451 --
116452 -- set accounting line options
116453 --
116454 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
116455 p_natural_side_code => 'D'
116456 , p_gain_or_loss_flag => 'N'
116457 , p_gl_transfer_mode_code => 'S'
116458 , p_acct_entry_type_code => 'A'
116459 , p_switch_side_flag => 'Y'
116460 , p_merge_duplicate_code => 'N'
116461 );
116462 --
116463 l_acc_rev_natural_side_code := 'C'; -- 4262811
116464 --
116465 --
116466 -- set accounting line type info
116467 --
116468 xla_ae_lines_pkg.SetAcctLineType
116469 (p_component_type => l_component_type
116470 ,p_event_type_code => l_event_type_code
116471 ,p_line_definition_owner_code => l_line_definition_owner_code
116472 ,p_line_definition_code => l_line_definition_code
116473 ,p_accounting_line_code => l_component_code
116474 ,p_accounting_line_type_code => l_component_type_code
116475 ,p_accounting_line_appl_id => l_component_appl_id
116476 ,p_amb_context_code => l_amb_context_code
116477 ,p_entity_code => l_entity_code
116478 ,p_event_class_code => l_event_class_code);
116479 --
116480 -- set accounting class
116481 --
116482 xla_ae_lines_pkg.SetAcctClass(
116483 p_accounting_class_code => 'INTRANSIT_VALUATION'
116484 , p_ae_header_id => l_ae_header_id
116485 );
116486
116487 --
116488 -- set rounding class
116489 --
116490 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
116491 'INTRANSIT_VALUATION';
116492
116493 --
116494 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
116495 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
116496 --
116497 -- bulk performance
116498 --
116499 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
116500
116501 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
116502 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
116503
116504 -- 4955764
116505 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
116506 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
116507
116508 -- 4458381 Public Sector Enh
116509
116510 --
116511 -- set accounting attributes for the line type
116512 --
116513 l_entered_amt_idx := 3;
116514 l_accted_amt_idx := 8;
116515 l_bflow_applied_to_amt_idx := NULL; -- 5132302
116516 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
116517 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
116518 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
116519 l_rec_acct_attrs.array_char_value(2) := p_source_85;
116520 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
116521 l_rec_acct_attrs.array_num_value(3) := p_source_91;
116522 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
116523 l_rec_acct_attrs.array_char_value(4) := p_source_88;
116524 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
116525 l_rec_acct_attrs.array_date_value(5) := p_source_92;
116526 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
116527 l_rec_acct_attrs.array_num_value(6) := p_source_93;
116528 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
116529 l_rec_acct_attrs.array_char_value(7) := p_source_94;
116530 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
116531 l_rec_acct_attrs.array_num_value(8) := p_source_95;
116532
116533 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
116534 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
116535
116536 ---------------------------------------------------------------------------------------------------------------
116537 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
116538 ---------------------------------------------------------------------------------------------------------------
116539 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
116540
116541 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
116542 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
116543
116544 IF xla_accounting_cache_pkg.GetValueChar
116545 (p_source_code => 'LEDGER_CATEGORY_CODE'
116546 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
116547 AND l_bflow_method_code = 'PRIOR_ENTRY'
116548 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
116549 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
116550 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
116551 )
116552 THEN
116553 xla_ae_lines_pkg.BflowUpgEntry
116554 (p_business_method_code => l_bflow_method_code
116555 ,p_business_class_code => l_bflow_class_code
116556 ,p_balance_type => l_balance_type_code);
116557 ELSE
116558 NULL;
116559 -- No business flow processing for business flow method of NONE.
116560 END IF;
116561
116562 --
116563 -- call analytical criteria
116564 --
116565
116566 --
116567 -- call description
116568 --
116569
116570 xla_ae_lines_pkg.SetLineDescription(
116571 p_ae_header_id => l_ae_header_id
116572 ,p_description => Description_1 (
116573 p_application_id => p_application_id
116574 , p_ae_header_id => l_ae_header_id
116575 , p_source_1 => p_source_1
116576 , p_source_2 => p_source_2
116577 , p_source_3 => p_source_3
116578 , p_source_4 => p_source_4
116579 , p_source_5 => p_source_5
116580 )
116581 );
116582
116583
116584 --
116585 -- call ADRs
116586 -- Bug 4922099
116587 --
116588 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
116589 (NVL(l_actual_upg_option, 'N') = 'O') OR
116590 (NVL(l_enc_upg_option, 'N') = 'O')
116591 )
116592 THEN
116593 NULL;
116594 --
116595 --
116596
116597 l_ccid := AcctDerRule_6(
116598 p_application_id => p_application_id
116599 , p_ae_header_id => l_ae_header_id
116600 , p_source_11 => p_source_11
116601 , x_transaction_coa_id => l_adr_transaction_coa_id
116602 , x_accounting_coa_id => l_adr_accounting_coa_id
116603 , x_value_type_code => l_adr_value_type_code
116604 , p_side => 'NA'
116605 );
116606
116607 xla_ae_lines_pkg.set_ccid(
116608 p_code_combination_id => l_ccid
116609 , p_value_type_code => l_adr_value_type_code
116610 , p_transaction_coa_id => l_adr_transaction_coa_id
116611 , p_accounting_coa_id => l_adr_accounting_coa_id
116612 , p_adr_code => 'CST_DEFAULT'
116613 , p_adr_type_code => 'S'
116614 , p_component_type => l_component_type
116615 , p_component_code => l_component_code
116616 , p_component_type_code => l_component_type_code
116617 , p_component_appl_id => l_component_appl_id
116618 , p_amb_context_code => l_amb_context_code
116619 , p_side => 'NA'
116620 );
116621
116622
116623 --
116624 --
116625 END IF;
116626 --
116627 -- Bug 4922099
116628 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
116629 (NVL(l_enc_upg_option, 'N') = 'O')
116630 ) AND
116631 (l_bflow_method_code = 'PRIOR_ENTRY')
116632 )
116633 THEN
116634 IF
116635 --
116636 1 = 2
116637 --
116638 THEN
116639 xla_accounting_err_pkg.build_message
116640 (p_appli_s_name => 'XLA'
116641 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
116642 ,p_token_1 => 'LINE_NUMBER'
116643 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
116644 ,p_token_2 => 'LINE_TYPE_NAME'
116645 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
116646 l_component_type
116647 ,l_component_code
116648 ,l_component_type_code
116649 ,l_component_appl_id
116650 ,l_amb_context_code
116651 ,l_entity_code
116652 ,l_event_class_code
116653 )
116654 ,p_token_3 => 'OWNER'
116655 ,p_value_3 => xla_lookups_pkg.get_meaning(
116656 p_lookup_type => 'XLA_OWNER_TYPE'
116657 ,p_lookup_code => l_component_type_code
116658 )
116659 ,p_token_4 => 'PRODUCT_NAME'
116660 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
116661 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
116662 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
116663 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
116664 ,p_ae_header_id => NULL
116665 );
116666
116667 IF (C_LEVEL_ERROR>= g_log_level) THEN
116668 trace
116669 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
116670 ,p_level => C_LEVEL_ERROR
116671 ,p_module => l_log_module);
116672 END IF;
116673 END IF;
116674 END IF;
116675 --
116676 --
116677 ------------------------------------------------------------------------------------------------
116678 -- 4219869 Business Flow
116679 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
116680 -- Prior Entry. Currently, the following code is always generated.
116681 ------------------------------------------------------------------------------------------------
116682 XLA_AE_LINES_PKG.ValidateCurrentLine;
116683
116684 ------------------------------------------------------------------------------------
116685 -- 4219869 Business Flow
116686 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
116687 ------------------------------------------------------------------------------------
116688 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
116689
116690 ----------------------------------------------------------------------------------
116691 -- 4219869 Business Flow
116692 -- Update journal entry status -- Need to generate this within IF <condition>
116693 ----------------------------------------------------------------------------------
116694 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
116695 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
116696 ,p_balance_type_code => l_balance_type_code
116697 );
116698
116699 -------------------------------------------------------------------------------------------
116700 -- 4262811 - Generate the Accrual Reversal lines
116701 -------------------------------------------------------------------------------------------
116702 BEGIN
116703 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
116704 (g_array_event(p_event_id).array_value_num('header_index'));
116705 IF l_acc_rev_flag IS NULL THEN
116706 l_acc_rev_flag := 'N';
116707 END IF;
116708 EXCEPTION
116709 WHEN OTHERS THEN
116710 l_acc_rev_flag := 'N';
116711 END;
116712 --
116713 IF (l_acc_rev_flag = 'Y') THEN
116714
116715 -- 4645092 ------------------------------------------------------------------------------
116716 -- To allow MPA report to determine if it should generate report process
116717 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
116718 ------------------------------------------------------------------------------------------
116719
116720 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
116721 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
116722 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
116723 -- call ADRs
116724 -- Bug 4922099
116725 --
116726 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
116727 (NVL(l_actual_upg_option, 'N') = 'O') OR
116728 (NVL(l_enc_upg_option, 'N') = 'O')
116729 )
116730 THEN
116731 NULL;
116732 --
116733 --
116734
116735 l_ccid := AcctDerRule_6(
116736 p_application_id => p_application_id
116737 , p_ae_header_id => l_ae_header_id
116738 , p_source_11 => p_source_11
116739 , x_transaction_coa_id => l_adr_transaction_coa_id
116740 , x_accounting_coa_id => l_adr_accounting_coa_id
116741 , x_value_type_code => l_adr_value_type_code
116742 , p_side => 'NA'
116743 );
116744
116745 xla_ae_lines_pkg.set_ccid(
116746 p_code_combination_id => l_ccid
116747 , p_value_type_code => l_adr_value_type_code
116748 , p_transaction_coa_id => l_adr_transaction_coa_id
116749 , p_accounting_coa_id => l_adr_accounting_coa_id
116750 , p_adr_code => 'CST_DEFAULT'
116751 , p_adr_type_code => 'S'
116752 , p_component_type => l_component_type
116753 , p_component_code => l_component_code
116754 , p_component_type_code => l_component_type_code
116755 , p_component_appl_id => l_component_appl_id
116756 , p_amb_context_code => l_amb_context_code
116757 , p_side => 'NA'
116758 );
116759
116760
116761 --
116762 --
116763 END IF;
116764
116765 --
116766 -- Update the line information that should be overwritten
116767 --
116768 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
116769 p_header_num => 1);
116770 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
116771
116772 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
116773
116774 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
116775 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
116776 END IF;
116777
116778 --
116779 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
116780 --
116781 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
116782 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
116783 ELSE
116784 ---------------------------------------------------------------------------------------------------
116785 -- 4262811a Switch Sign
116786 ---------------------------------------------------------------------------------------------------
116787 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
116788 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
116789 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116790 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
116791 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116792 -- 5132302
116793 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
116794 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
116795
116796 END IF;
116797
116798 -- 4955764
116799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
116800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
116801
116802
116803 XLA_AE_LINES_PKG.ValidateCurrentLine;
116804 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
116805
116806 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
116807 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
116808 ,p_balance_type_code => l_balance_type_code);
116809
116810 END IF;
116811
116812 -----------------------------------------------------------------------------------------
116813 -- 4262811 Multiperiod Accounting
116814 -----------------------------------------------------------------------------------------
116815 -- No MPA option is assigned.
116816
116817
116818 END IF;
116819 END IF;
116820 --
116821
116822 --
116823 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
116824 trace
116825 (p_msg => 'END of AcctLineType_227'
116826 ,p_level => C_LEVEL_PROCEDURE
116827 ,p_module => l_log_module);
116828 END IF;
116829 --
116830 EXCEPTION
116831 WHEN xla_exceptions_pkg.application_exception THEN
116832 RAISE;
116833 WHEN OTHERS THEN
116834 xla_exceptions_pkg.raise_message
116835 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_227');
116836 END AcctLineType_227;
116837 --
116838
116839 ---------------------------------------
116840 --
116841 -- PRIVATE FUNCTION
116842 -- AcctLineType_228
116843 --
116844 ---------------------------------------
116845 PROCEDURE AcctLineType_228 (
116846 p_application_id IN NUMBER
116847 ,p_event_id IN NUMBER
116848 ,p_calculate_acctd_flag IN VARCHAR2
116849 ,p_calculate_g_l_flag IN VARCHAR2
116850 ,p_actual_flag IN OUT VARCHAR2
116851 ,p_balance_type_code OUT VARCHAR2
116852 ,p_gain_or_loss_ref OUT VARCHAR2
116853
116854 --TRANSACTION_ID
116855 , p_source_1 IN NUMBER
116856 --Item Concatenated Segments
116857 , p_source_2 IN VARCHAR2
116858 --Transaction Quantity
116859 , p_source_3 IN NUMBER
116860 --Transaction Unit of Measure Code
116861 , p_source_4 IN VARCHAR2
116862 --Inventory Transaction Type Description
116863 , p_source_5 IN VARCHAR2
116864 --Cost Management Default Account
116865 , p_source_11 IN NUMBER
116866 --Cost Element Name
116867 , p_source_15 IN NUMBER
116868 --Primary Cost Method
116869 , p_source_39 IN NUMBER
116870 , p_source_39_meaning IN VARCHAR2
116871 --Product Line Accounting Category Material Account
116872 , p_source_41 IN NUMBER
116873 --Product Line Accounting Category Material Overhead Account
116874 , p_source_42 IN NUMBER
116875 --Product Line Accounting Category Resource Account
116876 , p_source_43 IN NUMBER
116877 --Product Line Accounting Category Outside Processing Account
116878 , p_source_44 IN NUMBER
116879 --Product Line Accounting Category Overhead Account
116880 , p_source_45 IN NUMBER
116881 --DISTRIBUTION_IDENTIFIER
116882 , p_source_84 IN NUMBER
116883 --Distribution Type
116884 , p_source_85 IN VARCHAR2
116885 , p_source_85_meaning IN VARCHAR2
116886 --Entered Currency Code
116887 , p_source_88 IN VARCHAR2
116888 --Entered Amount
116889 , p_source_91 IN NUMBER
116890 --Currency Conversion Date
116891 , p_source_92 IN DATE
116892 --Currency Conversion Rate
116893 , p_source_93 IN NUMBER
116894 --Currency Conversion Type
116895 , p_source_94 IN VARCHAR2
116896 --Accounted Amount
116897 , p_source_95 IN NUMBER
116898 --Accounting Line Type
116899 , p_source_97 IN NUMBER
116900 )
116901 IS
116902
116903 l_component_type VARCHAR2(80);
116904 l_component_code VARCHAR2(30);
116905 l_component_type_code VARCHAR2(1);
116906 l_component_appl_id INTEGER;
116907 l_amb_context_code VARCHAR2(30);
116908 l_entity_code VARCHAR2(30);
116909 l_event_class_code VARCHAR2(30);
116910 l_ae_header_id NUMBER;
116911 l_event_type_code VARCHAR2(30);
116912 l_line_definition_code VARCHAR2(30);
116913 l_line_definition_owner_code VARCHAR2(1);
116914 --
116915 -- adr variables
116916 l_segment VARCHAR2(30);
116917 l_ccid NUMBER;
116918 l_adr_transaction_coa_id NUMBER;
116919 l_adr_accounting_coa_id NUMBER;
116920 l_adr_flexfield_segment_code VARCHAR2(30);
116921 l_adr_flex_value_set_id NUMBER;
116922 l_adr_value_type_code VARCHAR2(30);
116923 l_adr_value_combination_id NUMBER;
116924 l_adr_value_segment_code VARCHAR2(30);
116925
116926 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
116927 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
116928 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
116929 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
116930
116931 -- 4262811 Variables ------------------------------------------------------------------------------------------
116932 l_entered_amt_idx NUMBER;
116933 l_accted_amt_idx NUMBER;
116934 l_acc_rev_flag VARCHAR2(1);
116935 l_accrual_line_num NUMBER;
116936 l_tmp_amt NUMBER;
116937 l_acc_rev_natural_side_code VARCHAR2(1);
116938
116939 l_num_entries NUMBER;
116940 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
116941 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
116942 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
116943 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
116944 l_recog_line_1 NUMBER;
116945 l_recog_line_2 NUMBER;
116946
116947 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
116948 l_bflow_applied_to_amt NUMBER; -- 5132302
116949 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
116950
116951 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
116952
116953 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
116954 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
116955
116956 ---------------------------------------------------------------------------------------------------------------
116957
116958
116959 --
116960 -- bulk performance
116961 --
116962 l_balance_type_code VARCHAR2(1);
116963 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
116964 l_log_module VARCHAR2(240);
116965
116966 --
116967 -- Upgrade strategy
116968 --
116969 l_actual_upg_option VARCHAR2(1);
116970 l_enc_upg_option VARCHAR2(1);
116971
116972 --
116973 BEGIN
116974 --
116975 IF g_log_enabled THEN
116976 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_228';
116977 END IF;
116978 --
116979 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
116980
116981 trace
116982 (p_msg => 'BEGIN of AcctLineType_228'
116983 ,p_level => C_LEVEL_PROCEDURE
116984 ,p_module => l_log_module);
116985
116986 END IF;
116987 --
116988 l_component_type := 'AMB_JLT';
116989 l_component_code := 'INTRANSIT_VALUATION';
116990 l_component_type_code := 'S';
116991 l_component_appl_id := 707;
116992 l_amb_context_code := 'DEFAULT';
116993 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
116994 l_event_class_code := 'USER_DEFINE';
116995 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
116996 l_line_definition_owner_code := 'S';
116997 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
116998 --
116999 l_balance_type_code := 'A';
117000 l_segment := NULL;
117001 l_ccid := NULL;
117002 l_adr_transaction_coa_id := NULL;
117003 l_adr_accounting_coa_id := NULL;
117004 l_adr_flexfield_segment_code := NULL;
117005 l_adr_flex_value_set_id := NULL;
117006 l_adr_value_type_code := NULL;
117007 l_adr_value_combination_id := NULL;
117008 l_adr_value_segment_code := NULL;
117009
117010 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
117011 l_bflow_class_code := ''; -- 4219869 Business Flow
117012 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
117013 l_budgetary_control_flag := 'N';
117014
117015 l_bflow_applied_to_amt_idx := NULL; -- 5132302
117016 l_bflow_applied_to_amt := NULL; -- 5132302
117017 l_entered_amt_idx := NULL; -- 4262811
117018 l_accted_amt_idx := NULL; -- 4262811
117019 l_acc_rev_flag := NULL; -- 4262811
117020 l_accrual_line_num := NULL; -- 4262811
117021 l_tmp_amt := NULL; -- 4262811
117022 --
117023
117024 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
117025 l_balance_type_code <> 'B' THEN
117026 IF NVL(p_source_97,9E125) = 14
117027 THEN
117028
117029 --
117030 XLA_AE_LINES_PKG.SetNewLine;
117031
117032 p_balance_type_code := l_balance_type_code;
117033 -- set the flag so later we will know whether the gain loss line needs to be created
117034
117035 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
117036 p_actual_flag :='A';
117037 END IF;
117038
117039 --
117040 -- bulk performance
117041 --
117042 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
117043 p_header_num => 0); -- 4262811
117044 --
117045 -- set accounting line options
117046 --
117047 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
117048 p_natural_side_code => 'D'
117049 , p_gain_or_loss_flag => 'N'
117050 , p_gl_transfer_mode_code => 'S'
117051 , p_acct_entry_type_code => 'A'
117052 , p_switch_side_flag => 'Y'
117053 , p_merge_duplicate_code => 'N'
117054 );
117055 --
117056 l_acc_rev_natural_side_code := 'C'; -- 4262811
117057 --
117058 --
117059 -- set accounting line type info
117060 --
117061 xla_ae_lines_pkg.SetAcctLineType
117062 (p_component_type => l_component_type
117063 ,p_event_type_code => l_event_type_code
117064 ,p_line_definition_owner_code => l_line_definition_owner_code
117065 ,p_line_definition_code => l_line_definition_code
117066 ,p_accounting_line_code => l_component_code
117067 ,p_accounting_line_type_code => l_component_type_code
117068 ,p_accounting_line_appl_id => l_component_appl_id
117069 ,p_amb_context_code => l_amb_context_code
117070 ,p_entity_code => l_entity_code
117071 ,p_event_class_code => l_event_class_code);
117072 --
117073 -- set accounting class
117074 --
117075 xla_ae_lines_pkg.SetAcctClass(
117076 p_accounting_class_code => 'INTRANSIT_VALUATION'
117077 , p_ae_header_id => l_ae_header_id
117078 );
117079
117080 --
117081 -- set rounding class
117082 --
117083 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
117084 'INTRANSIT_VALUATION';
117085
117086 --
117087 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
117088 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
117089 --
117090 -- bulk performance
117091 --
117092 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
117093
117094 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
117095 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
117096
117097 -- 4955764
117098 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
117099 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
117100
117101 -- 4458381 Public Sector Enh
117102
117103 --
117104 -- set accounting attributes for the line type
117105 --
117106 l_entered_amt_idx := 3;
117107 l_accted_amt_idx := 8;
117108 l_bflow_applied_to_amt_idx := NULL; -- 5132302
117109 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
117110 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
117111 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
117112 l_rec_acct_attrs.array_char_value(2) := p_source_85;
117113 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
117114 l_rec_acct_attrs.array_num_value(3) := p_source_91;
117115 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
117116 l_rec_acct_attrs.array_char_value(4) := p_source_88;
117117 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
117118 l_rec_acct_attrs.array_date_value(5) := p_source_92;
117119 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
117120 l_rec_acct_attrs.array_num_value(6) := p_source_93;
117121 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
117122 l_rec_acct_attrs.array_char_value(7) := p_source_94;
117123 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
117124 l_rec_acct_attrs.array_num_value(8) := p_source_95;
117125
117126 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
117127 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
117128
117129 ---------------------------------------------------------------------------------------------------------------
117130 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
117131 ---------------------------------------------------------------------------------------------------------------
117132 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
117133
117134 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
117135 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
117136
117137 IF xla_accounting_cache_pkg.GetValueChar
117138 (p_source_code => 'LEDGER_CATEGORY_CODE'
117139 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
117140 AND l_bflow_method_code = 'PRIOR_ENTRY'
117141 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
117142 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
117143 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
117144 )
117145 THEN
117146 xla_ae_lines_pkg.BflowUpgEntry
117147 (p_business_method_code => l_bflow_method_code
117148 ,p_business_class_code => l_bflow_class_code
117149 ,p_balance_type => l_balance_type_code);
117150 ELSE
117151 NULL;
117152 -- No business flow processing for business flow method of NONE.
117153 END IF;
117154
117155 --
117156 -- call analytical criteria
117157 --
117158
117159 --
117160 -- call description
117161 --
117162
117163 xla_ae_lines_pkg.SetLineDescription(
117164 p_ae_header_id => l_ae_header_id
117165 ,p_description => Description_1 (
117166 p_application_id => p_application_id
117167 , p_ae_header_id => l_ae_header_id
117168 , p_source_1 => p_source_1
117169 , p_source_2 => p_source_2
117170 , p_source_3 => p_source_3
117171 , p_source_4 => p_source_4
117172 , p_source_5 => p_source_5
117173 )
117174 );
117175
117176
117177 --
117178 -- call ADRs
117179 -- Bug 4922099
117180 --
117181 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
117182 (NVL(l_actual_upg_option, 'N') = 'O') OR
117183 (NVL(l_enc_upg_option, 'N') = 'O')
117184 )
117185 THEN
117186 NULL;
117187 --
117188 --
117189
117190 l_ccid := AcctDerRule_25(
117191 p_application_id => p_application_id
117192 , p_ae_header_id => l_ae_header_id
117193 , p_source_11 => p_source_11
117194 , p_source_15 => p_source_15
117195 , p_source_39 => p_source_39
117196 , p_source_39_meaning => p_source_39_meaning
117197 , p_source_41 => p_source_41
117198 , p_source_42 => p_source_42
117199 , p_source_43 => p_source_43
117200 , p_source_44 => p_source_44
117201 , p_source_45 => p_source_45
117202 , x_transaction_coa_id => l_adr_transaction_coa_id
117203 , x_accounting_coa_id => l_adr_accounting_coa_id
117204 , x_value_type_code => l_adr_value_type_code
117205 , p_side => 'NA'
117206 );
117207
117208 xla_ae_lines_pkg.set_ccid(
117209 p_code_combination_id => l_ccid
117210 , p_value_type_code => l_adr_value_type_code
117211 , p_transaction_coa_id => l_adr_transaction_coa_id
117212 , p_accounting_coa_id => l_adr_accounting_coa_id
117213 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
117214 , p_adr_type_code => 'S'
117215 , p_component_type => l_component_type
117216 , p_component_code => l_component_code
117217 , p_component_type_code => l_component_type_code
117218 , p_component_appl_id => l_component_appl_id
117219 , p_amb_context_code => l_amb_context_code
117220 , p_side => 'NA'
117221 );
117222
117223
117224 --
117225 --
117226 END IF;
117227 --
117228 -- Bug 4922099
117229 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
117230 (NVL(l_enc_upg_option, 'N') = 'O')
117231 ) AND
117232 (l_bflow_method_code = 'PRIOR_ENTRY')
117233 )
117234 THEN
117235 IF
117236 --
117237 1 = 2
117238 --
117239 THEN
117240 xla_accounting_err_pkg.build_message
117241 (p_appli_s_name => 'XLA'
117242 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
117243 ,p_token_1 => 'LINE_NUMBER'
117244 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
117245 ,p_token_2 => 'LINE_TYPE_NAME'
117246 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
117247 l_component_type
117248 ,l_component_code
117249 ,l_component_type_code
117250 ,l_component_appl_id
117251 ,l_amb_context_code
117252 ,l_entity_code
117253 ,l_event_class_code
117254 )
117255 ,p_token_3 => 'OWNER'
117256 ,p_value_3 => xla_lookups_pkg.get_meaning(
117257 p_lookup_type => 'XLA_OWNER_TYPE'
117258 ,p_lookup_code => l_component_type_code
117259 )
117260 ,p_token_4 => 'PRODUCT_NAME'
117261 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
117262 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
117263 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
117264 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
117265 ,p_ae_header_id => NULL
117266 );
117267
117268 IF (C_LEVEL_ERROR>= g_log_level) THEN
117269 trace
117270 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
117271 ,p_level => C_LEVEL_ERROR
117272 ,p_module => l_log_module);
117273 END IF;
117274 END IF;
117275 END IF;
117276 --
117277 --
117278 ------------------------------------------------------------------------------------------------
117279 -- 4219869 Business Flow
117280 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
117281 -- Prior Entry. Currently, the following code is always generated.
117282 ------------------------------------------------------------------------------------------------
117283 XLA_AE_LINES_PKG.ValidateCurrentLine;
117284
117285 ------------------------------------------------------------------------------------
117286 -- 4219869 Business Flow
117287 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
117288 ------------------------------------------------------------------------------------
117289 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
117290
117291 ----------------------------------------------------------------------------------
117292 -- 4219869 Business Flow
117293 -- Update journal entry status -- Need to generate this within IF <condition>
117294 ----------------------------------------------------------------------------------
117295 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
117296 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
117297 ,p_balance_type_code => l_balance_type_code
117298 );
117299
117300 -------------------------------------------------------------------------------------------
117301 -- 4262811 - Generate the Accrual Reversal lines
117302 -------------------------------------------------------------------------------------------
117303 BEGIN
117304 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
117305 (g_array_event(p_event_id).array_value_num('header_index'));
117306 IF l_acc_rev_flag IS NULL THEN
117307 l_acc_rev_flag := 'N';
117308 END IF;
117309 EXCEPTION
117310 WHEN OTHERS THEN
117311 l_acc_rev_flag := 'N';
117312 END;
117313 --
117314 IF (l_acc_rev_flag = 'Y') THEN
117315
117316 -- 4645092 ------------------------------------------------------------------------------
117317 -- To allow MPA report to determine if it should generate report process
117318 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
117319 ------------------------------------------------------------------------------------------
117320
117321 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
117322 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
117323 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
117324 -- call ADRs
117325 -- Bug 4922099
117326 --
117327 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
117328 (NVL(l_actual_upg_option, 'N') = 'O') OR
117329 (NVL(l_enc_upg_option, 'N') = 'O')
117330 )
117331 THEN
117332 NULL;
117333 --
117334 --
117335
117336 l_ccid := AcctDerRule_25(
117337 p_application_id => p_application_id
117338 , p_ae_header_id => l_ae_header_id
117339 , p_source_11 => p_source_11
117340 , p_source_15 => p_source_15
117341 , p_source_39 => p_source_39
117342 , p_source_39_meaning => p_source_39_meaning
117343 , p_source_41 => p_source_41
117344 , p_source_42 => p_source_42
117345 , p_source_43 => p_source_43
117346 , p_source_44 => p_source_44
117347 , p_source_45 => p_source_45
117348 , x_transaction_coa_id => l_adr_transaction_coa_id
117349 , x_accounting_coa_id => l_adr_accounting_coa_id
117350 , x_value_type_code => l_adr_value_type_code
117351 , p_side => 'NA'
117352 );
117353
117354 xla_ae_lines_pkg.set_ccid(
117355 p_code_combination_id => l_ccid
117356 , p_value_type_code => l_adr_value_type_code
117357 , p_transaction_coa_id => l_adr_transaction_coa_id
117358 , p_accounting_coa_id => l_adr_accounting_coa_id
117359 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
117360 , p_adr_type_code => 'S'
117361 , p_component_type => l_component_type
117362 , p_component_code => l_component_code
117363 , p_component_type_code => l_component_type_code
117364 , p_component_appl_id => l_component_appl_id
117365 , p_amb_context_code => l_amb_context_code
117366 , p_side => 'NA'
117367 );
117368
117369
117370 --
117371 --
117372 END IF;
117373
117374 --
117375 -- Update the line information that should be overwritten
117376 --
117377 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
117378 p_header_num => 1);
117379 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
117380
117381 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
117382
117383 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
117384 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
117385 END IF;
117386
117387 --
117388 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
117389 --
117390 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
117391 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
117392 ELSE
117393 ---------------------------------------------------------------------------------------------------
117394 -- 4262811a Switch Sign
117395 ---------------------------------------------------------------------------------------------------
117396 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
117397 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
117398 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
117399 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
117400 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
117401 -- 5132302
117402 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
117403 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
117404
117405 END IF;
117406
117407 -- 4955764
117408 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
117409 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
117410
117411
117412 XLA_AE_LINES_PKG.ValidateCurrentLine;
117413 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
117414
117415 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
117416 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
117417 ,p_balance_type_code => l_balance_type_code);
117418
117419 END IF;
117420
117421 -----------------------------------------------------------------------------------------
117422 -- 4262811 Multiperiod Accounting
117423 -----------------------------------------------------------------------------------------
117424 -- No MPA option is assigned.
117425
117426
117427 END IF;
117428 END IF;
117429 --
117430
117431 --
117432 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
117433 trace
117434 (p_msg => 'END of AcctLineType_228'
117435 ,p_level => C_LEVEL_PROCEDURE
117436 ,p_module => l_log_module);
117437 END IF;
117438 --
117439 EXCEPTION
117440 WHEN xla_exceptions_pkg.application_exception THEN
117441 RAISE;
117442 WHEN OTHERS THEN
117443 xla_exceptions_pkg.raise_message
117444 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_228');
117445 END AcctLineType_228;
117446 --
117447
117448 ---------------------------------------
117449 --
117450 -- PRIVATE FUNCTION
117451 -- AcctLineType_229
117452 --
117453 ---------------------------------------
117454 PROCEDURE AcctLineType_229 (
117455 p_application_id IN NUMBER
117456 ,p_event_id IN NUMBER
117457 ,p_calculate_acctd_flag IN VARCHAR2
117458 ,p_calculate_g_l_flag IN VARCHAR2
117459 ,p_actual_flag IN OUT VARCHAR2
117460 ,p_balance_type_code OUT VARCHAR2
117461 ,p_gain_or_loss_ref OUT VARCHAR2
117462
117463 --TRANSACTION_ID
117464 , p_source_1 IN NUMBER
117465 --Item Concatenated Segments
117466 , p_source_2 IN VARCHAR2
117467 --Transaction Quantity
117468 , p_source_3 IN NUMBER
117469 --Transaction Unit of Measure Code
117470 , p_source_4 IN VARCHAR2
117471 --Inventory Transaction Type Description
117472 , p_source_5 IN VARCHAR2
117473 --Cost Management Default Account
117474 , p_source_11 IN NUMBER
117475 --Cost Element Name
117476 , p_source_15 IN NUMBER
117477 --Primary Cost Method
117478 , p_source_39 IN NUMBER
117479 , p_source_39_meaning IN VARCHAR2
117480 --Product Line Accounting Category Material Account
117481 , p_source_41 IN NUMBER
117482 --Product Line Accounting Category Material Overhead Account
117483 , p_source_42 IN NUMBER
117484 --Product Line Accounting Category Resource Account
117485 , p_source_43 IN NUMBER
117486 --Product Line Accounting Category Outside Processing Account
117487 , p_source_44 IN NUMBER
117488 --Product Line Accounting Category Overhead Account
117489 , p_source_45 IN NUMBER
117490 --DISTRIBUTION_IDENTIFIER
117491 , p_source_84 IN NUMBER
117492 --Distribution Type
117493 , p_source_85 IN VARCHAR2
117494 , p_source_85_meaning IN VARCHAR2
117495 --Entered Currency Code
117496 , p_source_88 IN VARCHAR2
117497 --Entered Amount
117498 , p_source_91 IN NUMBER
117499 --Currency Conversion Date
117500 , p_source_92 IN DATE
117501 --Currency Conversion Rate
117502 , p_source_93 IN NUMBER
117503 --Currency Conversion Type
117504 , p_source_94 IN VARCHAR2
117505 --Accounted Amount
117506 , p_source_95 IN NUMBER
117507 --Accounting Line Type
117508 , p_source_97 IN NUMBER
117509 )
117510 IS
117511
117512 l_component_type VARCHAR2(80);
117513 l_component_code VARCHAR2(30);
117514 l_component_type_code VARCHAR2(1);
117515 l_component_appl_id INTEGER;
117516 l_amb_context_code VARCHAR2(30);
117517 l_entity_code VARCHAR2(30);
117518 l_event_class_code VARCHAR2(30);
117519 l_ae_header_id NUMBER;
117520 l_event_type_code VARCHAR2(30);
117521 l_line_definition_code VARCHAR2(30);
117522 l_line_definition_owner_code VARCHAR2(1);
117523 --
117524 -- adr variables
117525 l_segment VARCHAR2(30);
117526 l_ccid NUMBER;
117527 l_adr_transaction_coa_id NUMBER;
117528 l_adr_accounting_coa_id NUMBER;
117529 l_adr_flexfield_segment_code VARCHAR2(30);
117530 l_adr_flex_value_set_id NUMBER;
117531 l_adr_value_type_code VARCHAR2(30);
117532 l_adr_value_combination_id NUMBER;
117533 l_adr_value_segment_code VARCHAR2(30);
117534
117535 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
117536 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
117537 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
117538 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
117539
117540 -- 4262811 Variables ------------------------------------------------------------------------------------------
117541 l_entered_amt_idx NUMBER;
117542 l_accted_amt_idx NUMBER;
117543 l_acc_rev_flag VARCHAR2(1);
117544 l_accrual_line_num NUMBER;
117545 l_tmp_amt NUMBER;
117546 l_acc_rev_natural_side_code VARCHAR2(1);
117547
117548 l_num_entries NUMBER;
117549 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
117550 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
117551 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
117552 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
117553 l_recog_line_1 NUMBER;
117554 l_recog_line_2 NUMBER;
117555
117556 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
117557 l_bflow_applied_to_amt NUMBER; -- 5132302
117558 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
117559
117560 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
117561
117562 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
117563 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
117564
117565 ---------------------------------------------------------------------------------------------------------------
117566
117567
117568 --
117569 -- bulk performance
117570 --
117571 l_balance_type_code VARCHAR2(1);
117572 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
117573 l_log_module VARCHAR2(240);
117574
117575 --
117576 -- Upgrade strategy
117577 --
117578 l_actual_upg_option VARCHAR2(1);
117579 l_enc_upg_option VARCHAR2(1);
117580
117581 --
117582 BEGIN
117583 --
117584 IF g_log_enabled THEN
117585 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_229';
117586 END IF;
117587 --
117588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
117589
117590 trace
117591 (p_msg => 'BEGIN of AcctLineType_229'
117592 ,p_level => C_LEVEL_PROCEDURE
117593 ,p_module => l_log_module);
117594
117595 END IF;
117596 --
117597 l_component_type := 'AMB_JLT';
117598 l_component_code := 'INTRANSIT_VALUATION';
117599 l_component_type_code := 'S';
117600 l_component_appl_id := 707;
117601 l_amb_context_code := 'DEFAULT';
117602 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
117603 l_event_class_code := 'MTL_COST_UPD';
117604 l_event_type_code := 'AVG_COST_UPD';
117605 l_line_definition_owner_code := 'S';
117606 l_line_definition_code := 'PI_AVG_COST_UPD';
117607 --
117608 l_balance_type_code := 'A';
117609 l_segment := NULL;
117610 l_ccid := NULL;
117611 l_adr_transaction_coa_id := NULL;
117612 l_adr_accounting_coa_id := NULL;
117613 l_adr_flexfield_segment_code := NULL;
117614 l_adr_flex_value_set_id := NULL;
117615 l_adr_value_type_code := NULL;
117616 l_adr_value_combination_id := NULL;
117617 l_adr_value_segment_code := NULL;
117618
117619 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
117620 l_bflow_class_code := ''; -- 4219869 Business Flow
117621 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
117622 l_budgetary_control_flag := 'N';
117623
117624 l_bflow_applied_to_amt_idx := NULL; -- 5132302
117625 l_bflow_applied_to_amt := NULL; -- 5132302
117626 l_entered_amt_idx := NULL; -- 4262811
117627 l_accted_amt_idx := NULL; -- 4262811
117628 l_acc_rev_flag := NULL; -- 4262811
117629 l_accrual_line_num := NULL; -- 4262811
117630 l_tmp_amt := NULL; -- 4262811
117631 --
117632
117633 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
117634 l_balance_type_code <> 'B' THEN
117635 IF NVL(p_source_97,9E125) = 14
117636 THEN
117637
117638 --
117639 XLA_AE_LINES_PKG.SetNewLine;
117640
117641 p_balance_type_code := l_balance_type_code;
117642 -- set the flag so later we will know whether the gain loss line needs to be created
117643
117644 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
117645 p_actual_flag :='A';
117646 END IF;
117647
117648 --
117649 -- bulk performance
117650 --
117651 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
117652 p_header_num => 0); -- 4262811
117653 --
117654 -- set accounting line options
117655 --
117656 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
117657 p_natural_side_code => 'D'
117658 , p_gain_or_loss_flag => 'N'
117659 , p_gl_transfer_mode_code => 'S'
117660 , p_acct_entry_type_code => 'A'
117661 , p_switch_side_flag => 'Y'
117662 , p_merge_duplicate_code => 'N'
117663 );
117664 --
117665 l_acc_rev_natural_side_code := 'C'; -- 4262811
117666 --
117667 --
117668 -- set accounting line type info
117669 --
117670 xla_ae_lines_pkg.SetAcctLineType
117671 (p_component_type => l_component_type
117672 ,p_event_type_code => l_event_type_code
117673 ,p_line_definition_owner_code => l_line_definition_owner_code
117674 ,p_line_definition_code => l_line_definition_code
117675 ,p_accounting_line_code => l_component_code
117676 ,p_accounting_line_type_code => l_component_type_code
117677 ,p_accounting_line_appl_id => l_component_appl_id
117678 ,p_amb_context_code => l_amb_context_code
117679 ,p_entity_code => l_entity_code
117680 ,p_event_class_code => l_event_class_code);
117681 --
117682 -- set accounting class
117683 --
117684 xla_ae_lines_pkg.SetAcctClass(
117685 p_accounting_class_code => 'INTRANSIT_VALUATION'
117686 , p_ae_header_id => l_ae_header_id
117687 );
117688
117689 --
117690 -- set rounding class
117691 --
117692 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
117693 'INTRANSIT_VALUATION';
117694
117695 --
117696 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
117697 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
117698 --
117699 -- bulk performance
117700 --
117701 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
117702
117703 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
117704 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
117705
117706 -- 4955764
117707 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
117708 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
117709
117710 -- 4458381 Public Sector Enh
117711
117712 --
117713 -- set accounting attributes for the line type
117714 --
117715 l_entered_amt_idx := 3;
117716 l_accted_amt_idx := 8;
117717 l_bflow_applied_to_amt_idx := NULL; -- 5132302
117718 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
117719 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
117720 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
117721 l_rec_acct_attrs.array_char_value(2) := p_source_85;
117722 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
117723 l_rec_acct_attrs.array_num_value(3) := p_source_91;
117724 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
117725 l_rec_acct_attrs.array_char_value(4) := p_source_88;
117726 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
117727 l_rec_acct_attrs.array_date_value(5) := p_source_92;
117728 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
117729 l_rec_acct_attrs.array_num_value(6) := p_source_93;
117730 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
117731 l_rec_acct_attrs.array_char_value(7) := p_source_94;
117732 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
117733 l_rec_acct_attrs.array_num_value(8) := p_source_95;
117734
117735 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
117736 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
117737
117738 ---------------------------------------------------------------------------------------------------------------
117739 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
117740 ---------------------------------------------------------------------------------------------------------------
117741 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
117742
117743 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
117744 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
117745
117746 IF xla_accounting_cache_pkg.GetValueChar
117747 (p_source_code => 'LEDGER_CATEGORY_CODE'
117748 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
117749 AND l_bflow_method_code = 'PRIOR_ENTRY'
117750 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
117751 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
117752 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
117753 )
117754 THEN
117755 xla_ae_lines_pkg.BflowUpgEntry
117756 (p_business_method_code => l_bflow_method_code
117757 ,p_business_class_code => l_bflow_class_code
117758 ,p_balance_type => l_balance_type_code);
117759 ELSE
117760 NULL;
117761 -- No business flow processing for business flow method of NONE.
117762 END IF;
117763
117764 --
117765 -- call analytical criteria
117766 --
117767
117768 --
117769 -- call description
117770 --
117771
117772 xla_ae_lines_pkg.SetLineDescription(
117773 p_ae_header_id => l_ae_header_id
117774 ,p_description => Description_1 (
117775 p_application_id => p_application_id
117776 , p_ae_header_id => l_ae_header_id
117777 , p_source_1 => p_source_1
117778 , p_source_2 => p_source_2
117779 , p_source_3 => p_source_3
117780 , p_source_4 => p_source_4
117781 , p_source_5 => p_source_5
117782 )
117783 );
117784
117785
117786 --
117787 -- call ADRs
117788 -- Bug 4922099
117789 --
117790 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
117791 (NVL(l_actual_upg_option, 'N') = 'O') OR
117792 (NVL(l_enc_upg_option, 'N') = 'O')
117793 )
117794 THEN
117795 NULL;
117796 --
117797 --
117798
117799 l_ccid := AcctDerRule_25(
117800 p_application_id => p_application_id
117801 , p_ae_header_id => l_ae_header_id
117802 , p_source_11 => p_source_11
117803 , p_source_15 => p_source_15
117804 , p_source_39 => p_source_39
117805 , p_source_39_meaning => p_source_39_meaning
117806 , p_source_41 => p_source_41
117807 , p_source_42 => p_source_42
117808 , p_source_43 => p_source_43
117809 , p_source_44 => p_source_44
117810 , p_source_45 => p_source_45
117811 , x_transaction_coa_id => l_adr_transaction_coa_id
117812 , x_accounting_coa_id => l_adr_accounting_coa_id
117813 , x_value_type_code => l_adr_value_type_code
117814 , p_side => 'NA'
117815 );
117816
117817 xla_ae_lines_pkg.set_ccid(
117818 p_code_combination_id => l_ccid
117819 , p_value_type_code => l_adr_value_type_code
117820 , p_transaction_coa_id => l_adr_transaction_coa_id
117821 , p_accounting_coa_id => l_adr_accounting_coa_id
117822 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
117823 , p_adr_type_code => 'S'
117824 , p_component_type => l_component_type
117825 , p_component_code => l_component_code
117826 , p_component_type_code => l_component_type_code
117827 , p_component_appl_id => l_component_appl_id
117828 , p_amb_context_code => l_amb_context_code
117829 , p_side => 'NA'
117830 );
117831
117832
117833 --
117834 --
117835 END IF;
117836 --
117837 -- Bug 4922099
117838 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
117839 (NVL(l_enc_upg_option, 'N') = 'O')
117840 ) AND
117841 (l_bflow_method_code = 'PRIOR_ENTRY')
117842 )
117843 THEN
117844 IF
117845 --
117846 1 = 2
117847 --
117848 THEN
117849 xla_accounting_err_pkg.build_message
117850 (p_appli_s_name => 'XLA'
117851 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
117852 ,p_token_1 => 'LINE_NUMBER'
117853 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
117854 ,p_token_2 => 'LINE_TYPE_NAME'
117855 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
117856 l_component_type
117857 ,l_component_code
117858 ,l_component_type_code
117859 ,l_component_appl_id
117860 ,l_amb_context_code
117861 ,l_entity_code
117862 ,l_event_class_code
117863 )
117864 ,p_token_3 => 'OWNER'
117865 ,p_value_3 => xla_lookups_pkg.get_meaning(
117866 p_lookup_type => 'XLA_OWNER_TYPE'
117867 ,p_lookup_code => l_component_type_code
117868 )
117869 ,p_token_4 => 'PRODUCT_NAME'
117870 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
117871 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
117872 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
117873 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
117874 ,p_ae_header_id => NULL
117875 );
117876
117877 IF (C_LEVEL_ERROR>= g_log_level) THEN
117878 trace
117879 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
117880 ,p_level => C_LEVEL_ERROR
117881 ,p_module => l_log_module);
117882 END IF;
117883 END IF;
117884 END IF;
117885 --
117886 --
117887 ------------------------------------------------------------------------------------------------
117888 -- 4219869 Business Flow
117889 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
117890 -- Prior Entry. Currently, the following code is always generated.
117891 ------------------------------------------------------------------------------------------------
117892 XLA_AE_LINES_PKG.ValidateCurrentLine;
117893
117894 ------------------------------------------------------------------------------------
117895 -- 4219869 Business Flow
117896 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
117897 ------------------------------------------------------------------------------------
117898 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
117899
117900 ----------------------------------------------------------------------------------
117901 -- 4219869 Business Flow
117902 -- Update journal entry status -- Need to generate this within IF <condition>
117903 ----------------------------------------------------------------------------------
117904 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
117905 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
117906 ,p_balance_type_code => l_balance_type_code
117907 );
117908
117909 -------------------------------------------------------------------------------------------
117910 -- 4262811 - Generate the Accrual Reversal lines
117911 -------------------------------------------------------------------------------------------
117912 BEGIN
117913 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
117914 (g_array_event(p_event_id).array_value_num('header_index'));
117915 IF l_acc_rev_flag IS NULL THEN
117916 l_acc_rev_flag := 'N';
117917 END IF;
117918 EXCEPTION
117919 WHEN OTHERS THEN
117920 l_acc_rev_flag := 'N';
117921 END;
117922 --
117923 IF (l_acc_rev_flag = 'Y') THEN
117924
117925 -- 4645092 ------------------------------------------------------------------------------
117926 -- To allow MPA report to determine if it should generate report process
117927 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
117928 ------------------------------------------------------------------------------------------
117929
117930 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
117931 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
117932 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
117933 -- call ADRs
117934 -- Bug 4922099
117935 --
117936 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
117937 (NVL(l_actual_upg_option, 'N') = 'O') OR
117938 (NVL(l_enc_upg_option, 'N') = 'O')
117939 )
117940 THEN
117941 NULL;
117942 --
117943 --
117944
117945 l_ccid := AcctDerRule_25(
117946 p_application_id => p_application_id
117947 , p_ae_header_id => l_ae_header_id
117948 , p_source_11 => p_source_11
117949 , p_source_15 => p_source_15
117950 , p_source_39 => p_source_39
117951 , p_source_39_meaning => p_source_39_meaning
117952 , p_source_41 => p_source_41
117953 , p_source_42 => p_source_42
117954 , p_source_43 => p_source_43
117955 , p_source_44 => p_source_44
117956 , p_source_45 => p_source_45
117957 , x_transaction_coa_id => l_adr_transaction_coa_id
117958 , x_accounting_coa_id => l_adr_accounting_coa_id
117959 , x_value_type_code => l_adr_value_type_code
117960 , p_side => 'NA'
117961 );
117962
117963 xla_ae_lines_pkg.set_ccid(
117964 p_code_combination_id => l_ccid
117965 , p_value_type_code => l_adr_value_type_code
117966 , p_transaction_coa_id => l_adr_transaction_coa_id
117967 , p_accounting_coa_id => l_adr_accounting_coa_id
117968 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
117969 , p_adr_type_code => 'S'
117970 , p_component_type => l_component_type
117971 , p_component_code => l_component_code
117972 , p_component_type_code => l_component_type_code
117973 , p_component_appl_id => l_component_appl_id
117974 , p_amb_context_code => l_amb_context_code
117975 , p_side => 'NA'
117976 );
117977
117978
117979 --
117980 --
117981 END IF;
117982
117983 --
117984 -- Update the line information that should be overwritten
117985 --
117986 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
117987 p_header_num => 1);
117988 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
117989
117990 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
117991
117992 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
117993 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
117994 END IF;
117995
117996 --
117997 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
117998 --
117999 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
118000 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
118001 ELSE
118002 ---------------------------------------------------------------------------------------------------
118003 -- 4262811a Switch Sign
118004 ---------------------------------------------------------------------------------------------------
118005 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
118006 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
118007 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118008 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
118009 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118010 -- 5132302
118011 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
118012 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118013
118014 END IF;
118015
118016 -- 4955764
118017 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
118018 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
118019
118020
118021 XLA_AE_LINES_PKG.ValidateCurrentLine;
118022 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
118023
118024 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
118025 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
118026 ,p_balance_type_code => l_balance_type_code);
118027
118028 END IF;
118029
118030 -----------------------------------------------------------------------------------------
118031 -- 4262811 Multiperiod Accounting
118032 -----------------------------------------------------------------------------------------
118033 -- No MPA option is assigned.
118034
118035
118036 END IF;
118037 END IF;
118038 --
118039
118040 --
118041 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
118042 trace
118043 (p_msg => 'END of AcctLineType_229'
118044 ,p_level => C_LEVEL_PROCEDURE
118045 ,p_module => l_log_module);
118046 END IF;
118047 --
118048 EXCEPTION
118049 WHEN xla_exceptions_pkg.application_exception THEN
118050 RAISE;
118051 WHEN OTHERS THEN
118052 xla_exceptions_pkg.raise_message
118053 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_229');
118054 END AcctLineType_229;
118055 --
118056
118057 ---------------------------------------
118058 --
118059 -- PRIVATE FUNCTION
118060 -- AcctLineType_230
118061 --
118062 ---------------------------------------
118063 PROCEDURE AcctLineType_230 (
118064 p_application_id IN NUMBER
118065 ,p_event_id IN NUMBER
118066 ,p_calculate_acctd_flag IN VARCHAR2
118067 ,p_calculate_g_l_flag IN VARCHAR2
118068 ,p_actual_flag IN OUT VARCHAR2
118069 ,p_balance_type_code OUT VARCHAR2
118070 ,p_gain_or_loss_ref OUT VARCHAR2
118071
118072 --TRANSACTION_ID
118073 , p_source_1 IN NUMBER
118074 --Item Concatenated Segments
118075 , p_source_2 IN VARCHAR2
118076 --Transaction Quantity
118077 , p_source_3 IN NUMBER
118078 --Transaction Unit of Measure Code
118079 , p_source_4 IN VARCHAR2
118080 --Inventory Transaction Type Description
118081 , p_source_5 IN VARCHAR2
118082 --Cost Management Default Account
118083 , p_source_11 IN NUMBER
118084 --Cost Element Name
118085 , p_source_15 IN NUMBER
118086 --Primary Cost Method
118087 , p_source_39 IN NUMBER
118088 , p_source_39_meaning IN VARCHAR2
118089 --Product Line Accounting Category Material Account
118090 , p_source_41 IN NUMBER
118091 --Product Line Accounting Category Material Overhead Account
118092 , p_source_42 IN NUMBER
118093 --Product Line Accounting Category Resource Account
118094 , p_source_43 IN NUMBER
118095 --Product Line Accounting Category Outside Processing Account
118096 , p_source_44 IN NUMBER
118097 --Product Line Accounting Category Overhead Account
118098 , p_source_45 IN NUMBER
118099 --DISTRIBUTION_IDENTIFIER
118100 , p_source_84 IN NUMBER
118101 --Distribution Type
118102 , p_source_85 IN VARCHAR2
118103 , p_source_85_meaning IN VARCHAR2
118104 --Entered Currency Code
118105 , p_source_88 IN VARCHAR2
118106 --Entered Amount
118107 , p_source_91 IN NUMBER
118108 --Currency Conversion Date
118109 , p_source_92 IN DATE
118110 --Currency Conversion Rate
118111 , p_source_93 IN NUMBER
118112 --Currency Conversion Type
118113 , p_source_94 IN VARCHAR2
118114 --Accounted Amount
118115 , p_source_95 IN NUMBER
118116 --Accounting Line Type
118117 , p_source_97 IN NUMBER
118118 )
118119 IS
118120
118121 l_component_type VARCHAR2(80);
118122 l_component_code VARCHAR2(30);
118123 l_component_type_code VARCHAR2(1);
118124 l_component_appl_id INTEGER;
118125 l_amb_context_code VARCHAR2(30);
118126 l_entity_code VARCHAR2(30);
118127 l_event_class_code VARCHAR2(30);
118128 l_ae_header_id NUMBER;
118129 l_event_type_code VARCHAR2(30);
118130 l_line_definition_code VARCHAR2(30);
118131 l_line_definition_owner_code VARCHAR2(1);
118132 --
118133 -- adr variables
118134 l_segment VARCHAR2(30);
118135 l_ccid NUMBER;
118136 l_adr_transaction_coa_id NUMBER;
118137 l_adr_accounting_coa_id NUMBER;
118138 l_adr_flexfield_segment_code VARCHAR2(30);
118139 l_adr_flex_value_set_id NUMBER;
118140 l_adr_value_type_code VARCHAR2(30);
118141 l_adr_value_combination_id NUMBER;
118142 l_adr_value_segment_code VARCHAR2(30);
118143
118144 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
118145 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
118146 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
118147 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
118148
118149 -- 4262811 Variables ------------------------------------------------------------------------------------------
118150 l_entered_amt_idx NUMBER;
118151 l_accted_amt_idx NUMBER;
118152 l_acc_rev_flag VARCHAR2(1);
118153 l_accrual_line_num NUMBER;
118154 l_tmp_amt NUMBER;
118155 l_acc_rev_natural_side_code VARCHAR2(1);
118156
118157 l_num_entries NUMBER;
118158 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
118159 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
118160 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
118161 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
118162 l_recog_line_1 NUMBER;
118163 l_recog_line_2 NUMBER;
118164
118165 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
118166 l_bflow_applied_to_amt NUMBER; -- 5132302
118167 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
118168
118169 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
118170
118171 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
118172 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
118173
118174 ---------------------------------------------------------------------------------------------------------------
118175
118176
118177 --
118178 -- bulk performance
118179 --
118180 l_balance_type_code VARCHAR2(1);
118181 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
118182 l_log_module VARCHAR2(240);
118183
118184 --
118185 -- Upgrade strategy
118186 --
118187 l_actual_upg_option VARCHAR2(1);
118188 l_enc_upg_option VARCHAR2(1);
118189
118190 --
118191 BEGIN
118192 --
118193 IF g_log_enabled THEN
118194 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_230';
118195 END IF;
118196 --
118197 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
118198
118199 trace
118200 (p_msg => 'BEGIN of AcctLineType_230'
118201 ,p_level => C_LEVEL_PROCEDURE
118202 ,p_module => l_log_module);
118203
118204 END IF;
118205 --
118206 l_component_type := 'AMB_JLT';
118207 l_component_code := 'INTRANSIT_VALUATION';
118208 l_component_type_code := 'S';
118209 l_component_appl_id := 707;
118210 l_amb_context_code := 'DEFAULT';
118211 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
118212 l_event_class_code := 'MTL_COST_UPD';
118213 l_event_type_code := 'IPV_TXFR';
118214 l_line_definition_owner_code := 'S';
118215 l_line_definition_code := 'PI_IPV_TXFR';
118216 --
118217 l_balance_type_code := 'A';
118218 l_segment := NULL;
118219 l_ccid := NULL;
118220 l_adr_transaction_coa_id := NULL;
118221 l_adr_accounting_coa_id := NULL;
118222 l_adr_flexfield_segment_code := NULL;
118223 l_adr_flex_value_set_id := NULL;
118224 l_adr_value_type_code := NULL;
118225 l_adr_value_combination_id := NULL;
118226 l_adr_value_segment_code := NULL;
118227
118228 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
118229 l_bflow_class_code := ''; -- 4219869 Business Flow
118230 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
118231 l_budgetary_control_flag := 'N';
118232
118233 l_bflow_applied_to_amt_idx := NULL; -- 5132302
118234 l_bflow_applied_to_amt := NULL; -- 5132302
118235 l_entered_amt_idx := NULL; -- 4262811
118236 l_accted_amt_idx := NULL; -- 4262811
118237 l_acc_rev_flag := NULL; -- 4262811
118238 l_accrual_line_num := NULL; -- 4262811
118239 l_tmp_amt := NULL; -- 4262811
118240 --
118241
118242 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
118243 l_balance_type_code <> 'B' THEN
118244 IF NVL(p_source_97,9E125) = 14
118245 THEN
118246
118247 --
118248 XLA_AE_LINES_PKG.SetNewLine;
118249
118250 p_balance_type_code := l_balance_type_code;
118251 -- set the flag so later we will know whether the gain loss line needs to be created
118252
118253 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
118254 p_actual_flag :='A';
118255 END IF;
118256
118257 --
118258 -- bulk performance
118259 --
118260 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
118261 p_header_num => 0); -- 4262811
118262 --
118263 -- set accounting line options
118264 --
118265 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
118266 p_natural_side_code => 'D'
118267 , p_gain_or_loss_flag => 'N'
118268 , p_gl_transfer_mode_code => 'S'
118269 , p_acct_entry_type_code => 'A'
118270 , p_switch_side_flag => 'Y'
118271 , p_merge_duplicate_code => 'N'
118272 );
118273 --
118274 l_acc_rev_natural_side_code := 'C'; -- 4262811
118275 --
118276 --
118277 -- set accounting line type info
118278 --
118279 xla_ae_lines_pkg.SetAcctLineType
118280 (p_component_type => l_component_type
118281 ,p_event_type_code => l_event_type_code
118282 ,p_line_definition_owner_code => l_line_definition_owner_code
118283 ,p_line_definition_code => l_line_definition_code
118284 ,p_accounting_line_code => l_component_code
118285 ,p_accounting_line_type_code => l_component_type_code
118286 ,p_accounting_line_appl_id => l_component_appl_id
118287 ,p_amb_context_code => l_amb_context_code
118288 ,p_entity_code => l_entity_code
118289 ,p_event_class_code => l_event_class_code);
118290 --
118291 -- set accounting class
118292 --
118293 xla_ae_lines_pkg.SetAcctClass(
118294 p_accounting_class_code => 'INTRANSIT_VALUATION'
118295 , p_ae_header_id => l_ae_header_id
118296 );
118297
118298 --
118299 -- set rounding class
118300 --
118301 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
118302 'INTRANSIT_VALUATION';
118303
118304 --
118305 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
118306 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
118307 --
118308 -- bulk performance
118309 --
118310 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
118311
118312 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
118313 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
118314
118315 -- 4955764
118316 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
118317 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
118318
118319 -- 4458381 Public Sector Enh
118320
118321 --
118322 -- set accounting attributes for the line type
118323 --
118324 l_entered_amt_idx := 3;
118325 l_accted_amt_idx := 8;
118326 l_bflow_applied_to_amt_idx := NULL; -- 5132302
118327 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
118328 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
118329 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
118330 l_rec_acct_attrs.array_char_value(2) := p_source_85;
118331 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
118332 l_rec_acct_attrs.array_num_value(3) := p_source_91;
118333 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
118334 l_rec_acct_attrs.array_char_value(4) := p_source_88;
118335 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
118336 l_rec_acct_attrs.array_date_value(5) := p_source_92;
118337 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
118338 l_rec_acct_attrs.array_num_value(6) := p_source_93;
118339 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
118340 l_rec_acct_attrs.array_char_value(7) := p_source_94;
118341 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
118342 l_rec_acct_attrs.array_num_value(8) := p_source_95;
118343
118344 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
118345 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
118346
118347 ---------------------------------------------------------------------------------------------------------------
118348 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
118349 ---------------------------------------------------------------------------------------------------------------
118350 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
118351
118352 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
118353 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
118354
118355 IF xla_accounting_cache_pkg.GetValueChar
118356 (p_source_code => 'LEDGER_CATEGORY_CODE'
118357 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
118358 AND l_bflow_method_code = 'PRIOR_ENTRY'
118359 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
118360 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
118361 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
118362 )
118363 THEN
118364 xla_ae_lines_pkg.BflowUpgEntry
118365 (p_business_method_code => l_bflow_method_code
118366 ,p_business_class_code => l_bflow_class_code
118367 ,p_balance_type => l_balance_type_code);
118368 ELSE
118369 NULL;
118370 -- No business flow processing for business flow method of NONE.
118371 END IF;
118372
118373 --
118374 -- call analytical criteria
118375 --
118376
118377 --
118378 -- call description
118379 --
118380
118381 xla_ae_lines_pkg.SetLineDescription(
118382 p_ae_header_id => l_ae_header_id
118383 ,p_description => Description_1 (
118384 p_application_id => p_application_id
118385 , p_ae_header_id => l_ae_header_id
118386 , p_source_1 => p_source_1
118387 , p_source_2 => p_source_2
118388 , p_source_3 => p_source_3
118389 , p_source_4 => p_source_4
118390 , p_source_5 => p_source_5
118391 )
118392 );
118393
118394
118395 --
118396 -- call ADRs
118397 -- Bug 4922099
118398 --
118399 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
118400 (NVL(l_actual_upg_option, 'N') = 'O') OR
118401 (NVL(l_enc_upg_option, 'N') = 'O')
118402 )
118403 THEN
118404 NULL;
118405 --
118406 --
118407
118408 l_ccid := AcctDerRule_25(
118409 p_application_id => p_application_id
118410 , p_ae_header_id => l_ae_header_id
118411 , p_source_11 => p_source_11
118412 , p_source_15 => p_source_15
118413 , p_source_39 => p_source_39
118414 , p_source_39_meaning => p_source_39_meaning
118415 , p_source_41 => p_source_41
118416 , p_source_42 => p_source_42
118417 , p_source_43 => p_source_43
118418 , p_source_44 => p_source_44
118419 , p_source_45 => p_source_45
118420 , x_transaction_coa_id => l_adr_transaction_coa_id
118421 , x_accounting_coa_id => l_adr_accounting_coa_id
118422 , x_value_type_code => l_adr_value_type_code
118423 , p_side => 'NA'
118424 );
118425
118426 xla_ae_lines_pkg.set_ccid(
118427 p_code_combination_id => l_ccid
118428 , p_value_type_code => l_adr_value_type_code
118429 , p_transaction_coa_id => l_adr_transaction_coa_id
118430 , p_accounting_coa_id => l_adr_accounting_coa_id
118431 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
118432 , p_adr_type_code => 'S'
118433 , p_component_type => l_component_type
118434 , p_component_code => l_component_code
118435 , p_component_type_code => l_component_type_code
118436 , p_component_appl_id => l_component_appl_id
118437 , p_amb_context_code => l_amb_context_code
118438 , p_side => 'NA'
118439 );
118440
118441
118442 --
118443 --
118444 END IF;
118445 --
118446 -- Bug 4922099
118447 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
118448 (NVL(l_enc_upg_option, 'N') = 'O')
118449 ) AND
118450 (l_bflow_method_code = 'PRIOR_ENTRY')
118451 )
118452 THEN
118453 IF
118454 --
118455 1 = 2
118456 --
118457 THEN
118458 xla_accounting_err_pkg.build_message
118459 (p_appli_s_name => 'XLA'
118460 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
118461 ,p_token_1 => 'LINE_NUMBER'
118462 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
118463 ,p_token_2 => 'LINE_TYPE_NAME'
118464 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
118465 l_component_type
118466 ,l_component_code
118467 ,l_component_type_code
118468 ,l_component_appl_id
118469 ,l_amb_context_code
118470 ,l_entity_code
118471 ,l_event_class_code
118472 )
118473 ,p_token_3 => 'OWNER'
118474 ,p_value_3 => xla_lookups_pkg.get_meaning(
118475 p_lookup_type => 'XLA_OWNER_TYPE'
118476 ,p_lookup_code => l_component_type_code
118477 )
118478 ,p_token_4 => 'PRODUCT_NAME'
118479 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
118480 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
118481 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
118482 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
118483 ,p_ae_header_id => NULL
118484 );
118485
118486 IF (C_LEVEL_ERROR>= g_log_level) THEN
118487 trace
118488 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
118489 ,p_level => C_LEVEL_ERROR
118490 ,p_module => l_log_module);
118491 END IF;
118492 END IF;
118493 END IF;
118494 --
118495 --
118496 ------------------------------------------------------------------------------------------------
118497 -- 4219869 Business Flow
118498 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
118499 -- Prior Entry. Currently, the following code is always generated.
118500 ------------------------------------------------------------------------------------------------
118501 XLA_AE_LINES_PKG.ValidateCurrentLine;
118502
118503 ------------------------------------------------------------------------------------
118504 -- 4219869 Business Flow
118505 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
118506 ------------------------------------------------------------------------------------
118507 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
118508
118509 ----------------------------------------------------------------------------------
118510 -- 4219869 Business Flow
118511 -- Update journal entry status -- Need to generate this within IF <condition>
118512 ----------------------------------------------------------------------------------
118513 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
118514 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
118515 ,p_balance_type_code => l_balance_type_code
118516 );
118517
118518 -------------------------------------------------------------------------------------------
118519 -- 4262811 - Generate the Accrual Reversal lines
118520 -------------------------------------------------------------------------------------------
118521 BEGIN
118522 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
118523 (g_array_event(p_event_id).array_value_num('header_index'));
118524 IF l_acc_rev_flag IS NULL THEN
118525 l_acc_rev_flag := 'N';
118526 END IF;
118527 EXCEPTION
118528 WHEN OTHERS THEN
118529 l_acc_rev_flag := 'N';
118530 END;
118531 --
118532 IF (l_acc_rev_flag = 'Y') THEN
118533
118534 -- 4645092 ------------------------------------------------------------------------------
118535 -- To allow MPA report to determine if it should generate report process
118536 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
118537 ------------------------------------------------------------------------------------------
118538
118539 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
118540 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
118541 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
118542 -- call ADRs
118543 -- Bug 4922099
118544 --
118545 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
118546 (NVL(l_actual_upg_option, 'N') = 'O') OR
118547 (NVL(l_enc_upg_option, 'N') = 'O')
118548 )
118549 THEN
118550 NULL;
118551 --
118552 --
118553
118554 l_ccid := AcctDerRule_25(
118555 p_application_id => p_application_id
118556 , p_ae_header_id => l_ae_header_id
118557 , p_source_11 => p_source_11
118558 , p_source_15 => p_source_15
118559 , p_source_39 => p_source_39
118560 , p_source_39_meaning => p_source_39_meaning
118561 , p_source_41 => p_source_41
118562 , p_source_42 => p_source_42
118563 , p_source_43 => p_source_43
118564 , p_source_44 => p_source_44
118565 , p_source_45 => p_source_45
118566 , x_transaction_coa_id => l_adr_transaction_coa_id
118567 , x_accounting_coa_id => l_adr_accounting_coa_id
118568 , x_value_type_code => l_adr_value_type_code
118569 , p_side => 'NA'
118570 );
118571
118572 xla_ae_lines_pkg.set_ccid(
118573 p_code_combination_id => l_ccid
118574 , p_value_type_code => l_adr_value_type_code
118575 , p_transaction_coa_id => l_adr_transaction_coa_id
118576 , p_accounting_coa_id => l_adr_accounting_coa_id
118577 , p_adr_code => 'PI_INTRANSIT_ACCOUNT'
118578 , p_adr_type_code => 'S'
118579 , p_component_type => l_component_type
118580 , p_component_code => l_component_code
118581 , p_component_type_code => l_component_type_code
118582 , p_component_appl_id => l_component_appl_id
118583 , p_amb_context_code => l_amb_context_code
118584 , p_side => 'NA'
118585 );
118586
118587
118588 --
118589 --
118590 END IF;
118591
118592 --
118593 -- Update the line information that should be overwritten
118594 --
118595 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
118596 p_header_num => 1);
118597 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
118598
118599 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
118600
118601 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
118602 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
118603 END IF;
118604
118605 --
118606 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
118607 --
118608 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
118609 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
118610 ELSE
118611 ---------------------------------------------------------------------------------------------------
118612 -- 4262811a Switch Sign
118613 ---------------------------------------------------------------------------------------------------
118614 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
118615 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
118616 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118617 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
118618 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118619 -- 5132302
118620 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
118621 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
118622
118623 END IF;
118624
118625 -- 4955764
118626 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
118627 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
118628
118629
118630 XLA_AE_LINES_PKG.ValidateCurrentLine;
118631 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
118632
118633 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
118634 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
118635 ,p_balance_type_code => l_balance_type_code);
118636
118637 END IF;
118638
118639 -----------------------------------------------------------------------------------------
118640 -- 4262811 Multiperiod Accounting
118641 -----------------------------------------------------------------------------------------
118642 -- No MPA option is assigned.
118643
118644
118645 END IF;
118646 END IF;
118647 --
118648
118649 --
118650 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
118651 trace
118652 (p_msg => 'END of AcctLineType_230'
118653 ,p_level => C_LEVEL_PROCEDURE
118654 ,p_module => l_log_module);
118655 END IF;
118656 --
118657 EXCEPTION
118658 WHEN xla_exceptions_pkg.application_exception THEN
118659 RAISE;
118660 WHEN OTHERS THEN
118661 xla_exceptions_pkg.raise_message
118662 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_230');
118663 END AcctLineType_230;
118664 --
118665
118666 ---------------------------------------
118667 --
118668 -- PRIVATE FUNCTION
118669 -- AcctLineType_231
118670 --
118671 ---------------------------------------
118672 PROCEDURE AcctLineType_231 (
118673 p_application_id IN NUMBER
118674 ,p_event_id IN NUMBER
118675 ,p_calculate_acctd_flag IN VARCHAR2
118676 ,p_calculate_g_l_flag IN VARCHAR2
118677 ,p_actual_flag IN OUT VARCHAR2
118678 ,p_balance_type_code OUT VARCHAR2
118679 ,p_gain_or_loss_ref OUT VARCHAR2
118680
118681 --TRANSACTION_ID
118682 , p_source_1 IN NUMBER
118683 --Item Concatenated Segments
118684 , p_source_2 IN VARCHAR2
118685 --Transaction Quantity
118686 , p_source_3 IN NUMBER
118687 --Transaction Unit of Measure Code
118688 , p_source_4 IN VARCHAR2
118689 --Inventory Transaction Type Description
118690 , p_source_5 IN VARCHAR2
118691 --Cost Element Name
118692 , p_source_15 IN NUMBER
118693 --Product Line Accounting Category Material Account
118694 , p_source_41 IN NUMBER
118695 --Product Line Accounting Category Material Overhead Account
118696 , p_source_42 IN NUMBER
118697 --Product Line Accounting Category Resource Account
118698 , p_source_43 IN NUMBER
118699 --Product Line Accounting Category Outside Processing Account
118700 , p_source_44 IN NUMBER
118701 --Product Line Accounting Category Overhead Account
118702 , p_source_45 IN NUMBER
118703 --DISTRIBUTION_IDENTIFIER
118704 , p_source_84 IN NUMBER
118705 --Distribution Type
118706 , p_source_85 IN VARCHAR2
118707 , p_source_85_meaning IN VARCHAR2
118708 --Entered Currency Code
118709 , p_source_88 IN VARCHAR2
118710 --Entered Amount
118711 , p_source_91 IN NUMBER
118712 --Currency Conversion Date
118713 , p_source_92 IN DATE
118714 --Currency Conversion Rate
118715 , p_source_93 IN NUMBER
118716 --Currency Conversion Type
118717 , p_source_94 IN VARCHAR2
118718 --Accounted Amount
118719 , p_source_95 IN NUMBER
118720 --Accounting Line Type
118721 , p_source_97 IN NUMBER
118722 --Organization Code
118723 , p_source_108 IN VARCHAR2
118724 )
118725 IS
118726
118727 l_component_type VARCHAR2(80);
118728 l_component_code VARCHAR2(30);
118729 l_component_type_code VARCHAR2(1);
118730 l_component_appl_id INTEGER;
118731 l_amb_context_code VARCHAR2(30);
118732 l_entity_code VARCHAR2(30);
118733 l_event_class_code VARCHAR2(30);
118734 l_ae_header_id NUMBER;
118735 l_event_type_code VARCHAR2(30);
118736 l_line_definition_code VARCHAR2(30);
118737 l_line_definition_owner_code VARCHAR2(1);
118738 --
118739 -- adr variables
118740 l_segment VARCHAR2(30);
118741 l_ccid NUMBER;
118742 l_adr_transaction_coa_id NUMBER;
118743 l_adr_accounting_coa_id NUMBER;
118744 l_adr_flexfield_segment_code VARCHAR2(30);
118745 l_adr_flex_value_set_id NUMBER;
118746 l_adr_value_type_code VARCHAR2(30);
118747 l_adr_value_combination_id NUMBER;
118748 l_adr_value_segment_code VARCHAR2(30);
118749
118750 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
118751 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
118752 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
118753 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
118754
118755 -- 4262811 Variables ------------------------------------------------------------------------------------------
118756 l_entered_amt_idx NUMBER;
118757 l_accted_amt_idx NUMBER;
118758 l_acc_rev_flag VARCHAR2(1);
118759 l_accrual_line_num NUMBER;
118760 l_tmp_amt NUMBER;
118761 l_acc_rev_natural_side_code VARCHAR2(1);
118762
118763 l_num_entries NUMBER;
118764 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
118765 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
118766 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
118767 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
118768 l_recog_line_1 NUMBER;
118769 l_recog_line_2 NUMBER;
118770
118771 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
118772 l_bflow_applied_to_amt NUMBER; -- 5132302
118773 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
118774
118775 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
118776
118777 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
118778 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
118779
118780 ---------------------------------------------------------------------------------------------------------------
118781
118782
118783 --
118784 -- bulk performance
118785 --
118786 l_balance_type_code VARCHAR2(1);
118787 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
118788 l_log_module VARCHAR2(240);
118789
118790 --
118791 -- Upgrade strategy
118792 --
118793 l_actual_upg_option VARCHAR2(1);
118794 l_enc_upg_option VARCHAR2(1);
118795
118796 --
118797 BEGIN
118798 --
118799 IF g_log_enabled THEN
118800 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_231';
118801 END IF;
118802 --
118803 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
118804
118805 trace
118806 (p_msg => 'BEGIN of AcctLineType_231'
118807 ,p_level => C_LEVEL_PROCEDURE
118808 ,p_module => l_log_module);
118809
118810 END IF;
118811 --
118812 l_component_type := 'AMB_JLT';
118813 l_component_code := 'INVENTORY_VALUATION';
118814 l_component_type_code := 'S';
118815 l_component_appl_id := 707;
118816 l_amb_context_code := 'DEFAULT';
118817 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
118818 l_event_class_code := 'CON_INV_OWNR_TXFR';
118819 l_event_type_code := 'CON_INV_OWNR_TXFR_ALL';
118820 l_line_definition_owner_code := 'S';
118821 l_line_definition_code := 'PI_CON_INV_OWNR_TRFR';
118822 --
118823 l_balance_type_code := 'A';
118824 l_segment := NULL;
118825 l_ccid := NULL;
118826 l_adr_transaction_coa_id := NULL;
118827 l_adr_accounting_coa_id := NULL;
118828 l_adr_flexfield_segment_code := NULL;
118829 l_adr_flex_value_set_id := NULL;
118830 l_adr_value_type_code := NULL;
118831 l_adr_value_combination_id := NULL;
118832 l_adr_value_segment_code := NULL;
118833
118834 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
118835 l_bflow_class_code := ''; -- 4219869 Business Flow
118836 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
118837 l_budgetary_control_flag := 'N';
118838
118839 l_bflow_applied_to_amt_idx := NULL; -- 5132302
118840 l_bflow_applied_to_amt := NULL; -- 5132302
118841 l_entered_amt_idx := NULL; -- 4262811
118842 l_accted_amt_idx := NULL; -- 4262811
118843 l_acc_rev_flag := NULL; -- 4262811
118844 l_accrual_line_num := NULL; -- 4262811
118845 l_tmp_amt := NULL; -- 4262811
118846 --
118847
118848 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
118849 l_balance_type_code <> 'B' THEN
118850 IF NVL(p_source_97,9E125) = 1
118851 THEN
118852
118853 --
118854 XLA_AE_LINES_PKG.SetNewLine;
118855
118856 p_balance_type_code := l_balance_type_code;
118857 -- set the flag so later we will know whether the gain loss line needs to be created
118858
118859 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
118860 p_actual_flag :='A';
118861 END IF;
118862
118863 --
118864 -- bulk performance
118865 --
118866 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
118867 p_header_num => 0); -- 4262811
118868 --
118869 -- set accounting line options
118870 --
118871 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
118872 p_natural_side_code => 'D'
118873 , p_gain_or_loss_flag => 'N'
118874 , p_gl_transfer_mode_code => 'S'
118875 , p_acct_entry_type_code => 'A'
118876 , p_switch_side_flag => 'Y'
118877 , p_merge_duplicate_code => 'N'
118878 );
118879 --
118880 l_acc_rev_natural_side_code := 'C'; -- 4262811
118881 --
118882 --
118883 -- set accounting line type info
118884 --
118885 xla_ae_lines_pkg.SetAcctLineType
118886 (p_component_type => l_component_type
118887 ,p_event_type_code => l_event_type_code
118888 ,p_line_definition_owner_code => l_line_definition_owner_code
118889 ,p_line_definition_code => l_line_definition_code
118890 ,p_accounting_line_code => l_component_code
118891 ,p_accounting_line_type_code => l_component_type_code
118892 ,p_accounting_line_appl_id => l_component_appl_id
118893 ,p_amb_context_code => l_amb_context_code
118894 ,p_entity_code => l_entity_code
118895 ,p_event_class_code => l_event_class_code);
118896 --
118897 -- set accounting class
118898 --
118899 xla_ae_lines_pkg.SetAcctClass(
118900 p_accounting_class_code => 'INVENTORY_VALUATION'
118901 , p_ae_header_id => l_ae_header_id
118902 );
118903
118904 --
118905 -- set rounding class
118906 --
118907 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
118908 'INVENTORY_VALUATION';
118909
118910 --
118911 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
118912 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
118913 --
118914 -- bulk performance
118915 --
118916 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
118917
118918 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
118919 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
118920
118921 -- 4955764
118922 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
118923 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
118924
118925 -- 4458381 Public Sector Enh
118926
118927 --
118928 -- set accounting attributes for the line type
118929 --
118930 l_entered_amt_idx := 3;
118931 l_accted_amt_idx := 8;
118932 l_bflow_applied_to_amt_idx := NULL; -- 5132302
118933 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
118934 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
118935 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
118936 l_rec_acct_attrs.array_char_value(2) := p_source_85;
118937 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
118938 l_rec_acct_attrs.array_num_value(3) := p_source_91;
118939 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
118940 l_rec_acct_attrs.array_char_value(4) := p_source_88;
118941 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
118942 l_rec_acct_attrs.array_date_value(5) := p_source_92;
118943 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
118944 l_rec_acct_attrs.array_num_value(6) := p_source_93;
118945 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
118946 l_rec_acct_attrs.array_char_value(7) := p_source_94;
118947 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
118948 l_rec_acct_attrs.array_num_value(8) := p_source_95;
118949
118950 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
118951 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
118952
118953 ---------------------------------------------------------------------------------------------------------------
118954 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
118955 ---------------------------------------------------------------------------------------------------------------
118956 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
118957
118958 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
118959 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
118960
118961 IF xla_accounting_cache_pkg.GetValueChar
118962 (p_source_code => 'LEDGER_CATEGORY_CODE'
118963 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
118964 AND l_bflow_method_code = 'PRIOR_ENTRY'
118965 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
118966 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
118967 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
118968 )
118969 THEN
118970 xla_ae_lines_pkg.BflowUpgEntry
118971 (p_business_method_code => l_bflow_method_code
118972 ,p_business_class_code => l_bflow_class_code
118973 ,p_balance_type => l_balance_type_code);
118974 ELSE
118975 NULL;
118976 -- No business flow processing for business flow method of NONE.
118977 END IF;
118978
118979 --
118980 -- call analytical criteria
118981 --
118982
118983
118984 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
118985 xla_ae_lines_pkg.SetAnalyticalCriteria(
118986 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
118987 , p_analytical_criterion_owner => 'S'
118988 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
118989 , p_amb_context_code => 'DEFAULT'
118990 , p_balancing_flag => 'Y'
118991
118992 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
118993 , p_analytical_detail_num_1 => NULL
118994 , p_analytical_detail_date_1 => NULL
118995
118996 , p_ae_header_id => l_ae_header_id
118997 )
118998 ;
118999 --
119000
119001 --
119002 -- call description
119003 --
119004
119005 xla_ae_lines_pkg.SetLineDescription(
119006 p_ae_header_id => l_ae_header_id
119007 ,p_description => Description_1 (
119008 p_application_id => p_application_id
119009 , p_ae_header_id => l_ae_header_id
119010 , p_source_1 => p_source_1
119011 , p_source_2 => p_source_2
119012 , p_source_3 => p_source_3
119013 , p_source_4 => p_source_4
119014 , p_source_5 => p_source_5
119015 )
119016 );
119017
119018
119019 --
119020 -- call ADRs
119021 -- Bug 4922099
119022 --
119023 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
119024 (NVL(l_actual_upg_option, 'N') = 'O') OR
119025 (NVL(l_enc_upg_option, 'N') = 'O')
119026 )
119027 THEN
119028 NULL;
119029 --
119030 --
119031
119032 l_ccid := AcctDerRule_28(
119033 p_application_id => p_application_id
119034 , p_ae_header_id => l_ae_header_id
119035 , p_source_15 => p_source_15
119036 , p_source_41 => p_source_41
119037 , p_source_42 => p_source_42
119038 , p_source_43 => p_source_43
119039 , p_source_44 => p_source_44
119040 , p_source_45 => p_source_45
119041 , x_transaction_coa_id => l_adr_transaction_coa_id
119042 , x_accounting_coa_id => l_adr_accounting_coa_id
119043 , x_value_type_code => l_adr_value_type_code
119044 , p_side => 'NA'
119045 );
119046
119047 xla_ae_lines_pkg.set_ccid(
119048 p_code_combination_id => l_ccid
119049 , p_value_type_code => l_adr_value_type_code
119050 , p_transaction_coa_id => l_adr_transaction_coa_id
119051 , p_accounting_coa_id => l_adr_accounting_coa_id
119052 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
119053 , p_adr_type_code => 'S'
119054 , p_component_type => l_component_type
119055 , p_component_code => l_component_code
119056 , p_component_type_code => l_component_type_code
119057 , p_component_appl_id => l_component_appl_id
119058 , p_amb_context_code => l_amb_context_code
119059 , p_side => 'NA'
119060 );
119061
119062
119063 --
119064 --
119065 END IF;
119066 --
119067 -- Bug 4922099
119068 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
119069 (NVL(l_enc_upg_option, 'N') = 'O')
119070 ) AND
119071 (l_bflow_method_code = 'PRIOR_ENTRY')
119072 )
119073 THEN
119074 IF
119075 --
119076 1 = 2
119077 --
119078 THEN
119079 xla_accounting_err_pkg.build_message
119080 (p_appli_s_name => 'XLA'
119081 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
119082 ,p_token_1 => 'LINE_NUMBER'
119083 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
119084 ,p_token_2 => 'LINE_TYPE_NAME'
119085 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
119086 l_component_type
119087 ,l_component_code
119088 ,l_component_type_code
119089 ,l_component_appl_id
119090 ,l_amb_context_code
119091 ,l_entity_code
119092 ,l_event_class_code
119093 )
119094 ,p_token_3 => 'OWNER'
119095 ,p_value_3 => xla_lookups_pkg.get_meaning(
119096 p_lookup_type => 'XLA_OWNER_TYPE'
119097 ,p_lookup_code => l_component_type_code
119098 )
119099 ,p_token_4 => 'PRODUCT_NAME'
119100 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
119101 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
119102 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
119103 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
119104 ,p_ae_header_id => NULL
119105 );
119106
119107 IF (C_LEVEL_ERROR>= g_log_level) THEN
119108 trace
119109 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
119110 ,p_level => C_LEVEL_ERROR
119111 ,p_module => l_log_module);
119112 END IF;
119113 END IF;
119114 END IF;
119115 --
119116 --
119117 ------------------------------------------------------------------------------------------------
119118 -- 4219869 Business Flow
119119 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
119120 -- Prior Entry. Currently, the following code is always generated.
119121 ------------------------------------------------------------------------------------------------
119122 XLA_AE_LINES_PKG.ValidateCurrentLine;
119123
119124 ------------------------------------------------------------------------------------
119125 -- 4219869 Business Flow
119126 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
119127 ------------------------------------------------------------------------------------
119128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
119129
119130 ----------------------------------------------------------------------------------
119131 -- 4219869 Business Flow
119132 -- Update journal entry status -- Need to generate this within IF <condition>
119133 ----------------------------------------------------------------------------------
119134 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
119135 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
119136 ,p_balance_type_code => l_balance_type_code
119137 );
119138
119139 -------------------------------------------------------------------------------------------
119140 -- 4262811 - Generate the Accrual Reversal lines
119141 -------------------------------------------------------------------------------------------
119142 BEGIN
119143 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
119144 (g_array_event(p_event_id).array_value_num('header_index'));
119145 IF l_acc_rev_flag IS NULL THEN
119146 l_acc_rev_flag := 'N';
119147 END IF;
119148 EXCEPTION
119149 WHEN OTHERS THEN
119150 l_acc_rev_flag := 'N';
119151 END;
119152 --
119153 IF (l_acc_rev_flag = 'Y') THEN
119154
119155 -- 4645092 ------------------------------------------------------------------------------
119156 -- To allow MPA report to determine if it should generate report process
119157 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
119158 ------------------------------------------------------------------------------------------
119159
119160 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
119161 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
119162 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
119163 -- call ADRs
119164 -- Bug 4922099
119165 --
119166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
119167 (NVL(l_actual_upg_option, 'N') = 'O') OR
119168 (NVL(l_enc_upg_option, 'N') = 'O')
119169 )
119170 THEN
119171 NULL;
119172 --
119173 --
119174
119175 l_ccid := AcctDerRule_28(
119176 p_application_id => p_application_id
119177 , p_ae_header_id => l_ae_header_id
119178 , p_source_15 => p_source_15
119179 , p_source_41 => p_source_41
119180 , p_source_42 => p_source_42
119181 , p_source_43 => p_source_43
119182 , p_source_44 => p_source_44
119183 , p_source_45 => p_source_45
119184 , x_transaction_coa_id => l_adr_transaction_coa_id
119185 , x_accounting_coa_id => l_adr_accounting_coa_id
119186 , x_value_type_code => l_adr_value_type_code
119187 , p_side => 'NA'
119188 );
119189
119190 xla_ae_lines_pkg.set_ccid(
119191 p_code_combination_id => l_ccid
119192 , p_value_type_code => l_adr_value_type_code
119193 , p_transaction_coa_id => l_adr_transaction_coa_id
119194 , p_accounting_coa_id => l_adr_accounting_coa_id
119195 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
119196 , p_adr_type_code => 'S'
119197 , p_component_type => l_component_type
119198 , p_component_code => l_component_code
119199 , p_component_type_code => l_component_type_code
119200 , p_component_appl_id => l_component_appl_id
119201 , p_amb_context_code => l_amb_context_code
119202 , p_side => 'NA'
119203 );
119204
119205
119206 --
119207 --
119208 END IF;
119209
119210 --
119211 -- Update the line information that should be overwritten
119212 --
119213 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
119214 p_header_num => 1);
119215 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
119216
119217 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
119218
119219 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
119220 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
119221 END IF;
119222
119223 --
119224 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
119225 --
119226 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
119227 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
119228 ELSE
119229 ---------------------------------------------------------------------------------------------------
119230 -- 4262811a Switch Sign
119231 ---------------------------------------------------------------------------------------------------
119232 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
119233 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
119234 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119235 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
119236 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119237 -- 5132302
119238 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
119239 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119240
119241 END IF;
119242
119243 -- 4955764
119244 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
119245 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
119246
119247
119248 XLA_AE_LINES_PKG.ValidateCurrentLine;
119249 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
119250
119251 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
119252 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
119253 ,p_balance_type_code => l_balance_type_code);
119254
119255 END IF;
119256
119257 -----------------------------------------------------------------------------------------
119258 -- 4262811 Multiperiod Accounting
119259 -----------------------------------------------------------------------------------------
119260 -- No MPA option is assigned.
119261
119262
119263 END IF;
119264 END IF;
119265 --
119266
119267 --
119268 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
119269 trace
119270 (p_msg => 'END of AcctLineType_231'
119271 ,p_level => C_LEVEL_PROCEDURE
119272 ,p_module => l_log_module);
119273 END IF;
119274 --
119275 EXCEPTION
119276 WHEN xla_exceptions_pkg.application_exception THEN
119277 RAISE;
119278 WHEN OTHERS THEN
119279 xla_exceptions_pkg.raise_message
119280 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_231');
119281 END AcctLineType_231;
119282 --
119283
119284 ---------------------------------------
119285 --
119286 -- PRIVATE FUNCTION
119287 -- AcctLineType_232
119288 --
119289 ---------------------------------------
119290 PROCEDURE AcctLineType_232 (
119291 p_application_id IN NUMBER
119292 ,p_event_id IN NUMBER
119293 ,p_calculate_acctd_flag IN VARCHAR2
119294 ,p_calculate_g_l_flag IN VARCHAR2
119295 ,p_actual_flag IN OUT VARCHAR2
119296 ,p_balance_type_code OUT VARCHAR2
119297 ,p_gain_or_loss_ref OUT VARCHAR2
119298
119299 --TRANSACTION_ID
119300 , p_source_1 IN NUMBER
119301 --Item Concatenated Segments
119302 , p_source_2 IN VARCHAR2
119303 --Transaction Quantity
119304 , p_source_3 IN NUMBER
119305 --Transaction Unit of Measure Code
119306 , p_source_4 IN VARCHAR2
119307 --Inventory Transaction Type Description
119308 , p_source_5 IN VARCHAR2
119309 --Cost Element Name
119310 , p_source_15 IN NUMBER
119311 --Product Line Accounting Category Material Account
119312 , p_source_41 IN NUMBER
119313 --Product Line Accounting Category Material Overhead Account
119314 , p_source_42 IN NUMBER
119315 --Product Line Accounting Category Resource Account
119316 , p_source_43 IN NUMBER
119317 --Product Line Accounting Category Outside Processing Account
119318 , p_source_44 IN NUMBER
119319 --Product Line Accounting Category Overhead Account
119320 , p_source_45 IN NUMBER
119321 --DISTRIBUTION_IDENTIFIER
119322 , p_source_84 IN NUMBER
119323 --Distribution Type
119324 , p_source_85 IN VARCHAR2
119325 , p_source_85_meaning IN VARCHAR2
119326 --Entered Currency Code
119327 , p_source_88 IN VARCHAR2
119328 --Entered Amount
119329 , p_source_91 IN NUMBER
119330 --Currency Conversion Date
119331 , p_source_92 IN DATE
119332 --Currency Conversion Rate
119333 , p_source_93 IN NUMBER
119334 --Currency Conversion Type
119335 , p_source_94 IN VARCHAR2
119336 --Accounted Amount
119337 , p_source_95 IN NUMBER
119338 --Accounting Line Type
119339 , p_source_97 IN NUMBER
119340 --Organization Code
119341 , p_source_108 IN VARCHAR2
119342 )
119343 IS
119344
119345 l_component_type VARCHAR2(80);
119346 l_component_code VARCHAR2(30);
119347 l_component_type_code VARCHAR2(1);
119348 l_component_appl_id INTEGER;
119349 l_amb_context_code VARCHAR2(30);
119350 l_entity_code VARCHAR2(30);
119351 l_event_class_code VARCHAR2(30);
119352 l_ae_header_id NUMBER;
119353 l_event_type_code VARCHAR2(30);
119354 l_line_definition_code VARCHAR2(30);
119355 l_line_definition_owner_code VARCHAR2(1);
119356 --
119357 -- adr variables
119358 l_segment VARCHAR2(30);
119359 l_ccid NUMBER;
119360 l_adr_transaction_coa_id NUMBER;
119361 l_adr_accounting_coa_id NUMBER;
119362 l_adr_flexfield_segment_code VARCHAR2(30);
119363 l_adr_flex_value_set_id NUMBER;
119364 l_adr_value_type_code VARCHAR2(30);
119365 l_adr_value_combination_id NUMBER;
119366 l_adr_value_segment_code VARCHAR2(30);
119367
119368 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
119369 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
119370 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
119371 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
119372
119373 -- 4262811 Variables ------------------------------------------------------------------------------------------
119374 l_entered_amt_idx NUMBER;
119375 l_accted_amt_idx NUMBER;
119376 l_acc_rev_flag VARCHAR2(1);
119377 l_accrual_line_num NUMBER;
119378 l_tmp_amt NUMBER;
119379 l_acc_rev_natural_side_code VARCHAR2(1);
119380
119381 l_num_entries NUMBER;
119382 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
119383 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
119384 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
119385 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
119386 l_recog_line_1 NUMBER;
119387 l_recog_line_2 NUMBER;
119388
119389 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
119390 l_bflow_applied_to_amt NUMBER; -- 5132302
119391 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
119392
119393 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
119394
119395 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
119396 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
119397
119398 ---------------------------------------------------------------------------------------------------------------
119399
119400
119401 --
119402 -- bulk performance
119403 --
119404 l_balance_type_code VARCHAR2(1);
119405 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
119406 l_log_module VARCHAR2(240);
119407
119408 --
119409 -- Upgrade strategy
119410 --
119411 l_actual_upg_option VARCHAR2(1);
119412 l_enc_upg_option VARCHAR2(1);
119413
119414 --
119415 BEGIN
119416 --
119417 IF g_log_enabled THEN
119418 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_232';
119419 END IF;
119420 --
119421 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
119422
119423 trace
119424 (p_msg => 'BEGIN of AcctLineType_232'
119425 ,p_level => C_LEVEL_PROCEDURE
119426 ,p_module => l_log_module);
119427
119428 END IF;
119429 --
119430 l_component_type := 'AMB_JLT';
119431 l_component_code := 'INVENTORY_VALUATION';
119432 l_component_type_code := 'S';
119433 l_component_appl_id := 707;
119434 l_amb_context_code := 'DEFAULT';
119435 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
119436 l_event_class_code := 'FOB_RCPT_SENDER_SHIP';
119437 l_event_type_code := 'FOB_RCPT_SENDER_SHIP';
119438 l_line_definition_owner_code := 'S';
119439 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
119440 --
119441 l_balance_type_code := 'A';
119442 l_segment := NULL;
119443 l_ccid := NULL;
119444 l_adr_transaction_coa_id := NULL;
119445 l_adr_accounting_coa_id := NULL;
119446 l_adr_flexfield_segment_code := NULL;
119447 l_adr_flex_value_set_id := NULL;
119448 l_adr_value_type_code := NULL;
119449 l_adr_value_combination_id := NULL;
119450 l_adr_value_segment_code := NULL;
119451
119452 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
119453 l_bflow_class_code := ''; -- 4219869 Business Flow
119454 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
119455 l_budgetary_control_flag := 'N';
119456
119457 l_bflow_applied_to_amt_idx := NULL; -- 5132302
119458 l_bflow_applied_to_amt := NULL; -- 5132302
119459 l_entered_amt_idx := NULL; -- 4262811
119460 l_accted_amt_idx := NULL; -- 4262811
119461 l_acc_rev_flag := NULL; -- 4262811
119462 l_accrual_line_num := NULL; -- 4262811
119463 l_tmp_amt := NULL; -- 4262811
119464 --
119465
119466 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
119467 l_balance_type_code <> 'B' THEN
119468 IF NVL(p_source_97,9E125) = 1
119469 THEN
119470
119471 --
119472 XLA_AE_LINES_PKG.SetNewLine;
119473
119474 p_balance_type_code := l_balance_type_code;
119475 -- set the flag so later we will know whether the gain loss line needs to be created
119476
119477 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
119478 p_actual_flag :='A';
119479 END IF;
119480
119481 --
119482 -- bulk performance
119483 --
119484 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
119485 p_header_num => 0); -- 4262811
119486 --
119487 -- set accounting line options
119488 --
119489 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
119490 p_natural_side_code => 'D'
119491 , p_gain_or_loss_flag => 'N'
119492 , p_gl_transfer_mode_code => 'S'
119493 , p_acct_entry_type_code => 'A'
119494 , p_switch_side_flag => 'Y'
119495 , p_merge_duplicate_code => 'N'
119496 );
119497 --
119498 l_acc_rev_natural_side_code := 'C'; -- 4262811
119499 --
119500 --
119501 -- set accounting line type info
119502 --
119503 xla_ae_lines_pkg.SetAcctLineType
119504 (p_component_type => l_component_type
119505 ,p_event_type_code => l_event_type_code
119506 ,p_line_definition_owner_code => l_line_definition_owner_code
119507 ,p_line_definition_code => l_line_definition_code
119508 ,p_accounting_line_code => l_component_code
119509 ,p_accounting_line_type_code => l_component_type_code
119510 ,p_accounting_line_appl_id => l_component_appl_id
119511 ,p_amb_context_code => l_amb_context_code
119512 ,p_entity_code => l_entity_code
119513 ,p_event_class_code => l_event_class_code);
119514 --
119515 -- set accounting class
119516 --
119517 xla_ae_lines_pkg.SetAcctClass(
119518 p_accounting_class_code => 'INVENTORY_VALUATION'
119519 , p_ae_header_id => l_ae_header_id
119520 );
119521
119522 --
119523 -- set rounding class
119524 --
119525 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
119526 'INVENTORY_VALUATION';
119527
119528 --
119529 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
119530 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
119531 --
119532 -- bulk performance
119533 --
119534 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
119535
119536 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
119537 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
119538
119539 -- 4955764
119540 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
119541 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
119542
119543 -- 4458381 Public Sector Enh
119544
119545 --
119546 -- set accounting attributes for the line type
119547 --
119548 l_entered_amt_idx := 3;
119549 l_accted_amt_idx := 8;
119550 l_bflow_applied_to_amt_idx := NULL; -- 5132302
119551 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
119552 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
119553 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
119554 l_rec_acct_attrs.array_char_value(2) := p_source_85;
119555 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
119556 l_rec_acct_attrs.array_num_value(3) := p_source_91;
119557 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
119558 l_rec_acct_attrs.array_char_value(4) := p_source_88;
119559 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
119560 l_rec_acct_attrs.array_date_value(5) := p_source_92;
119561 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
119562 l_rec_acct_attrs.array_num_value(6) := p_source_93;
119563 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
119564 l_rec_acct_attrs.array_char_value(7) := p_source_94;
119565 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
119566 l_rec_acct_attrs.array_num_value(8) := p_source_95;
119567
119568 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
119569 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
119570
119571 ---------------------------------------------------------------------------------------------------------------
119572 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
119573 ---------------------------------------------------------------------------------------------------------------
119574 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
119575
119576 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
119577 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
119578
119579 IF xla_accounting_cache_pkg.GetValueChar
119580 (p_source_code => 'LEDGER_CATEGORY_CODE'
119581 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
119582 AND l_bflow_method_code = 'PRIOR_ENTRY'
119583 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
119584 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
119585 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
119586 )
119587 THEN
119588 xla_ae_lines_pkg.BflowUpgEntry
119589 (p_business_method_code => l_bflow_method_code
119590 ,p_business_class_code => l_bflow_class_code
119591 ,p_balance_type => l_balance_type_code);
119592 ELSE
119593 NULL;
119594 -- No business flow processing for business flow method of NONE.
119595 END IF;
119596
119597 --
119598 -- call analytical criteria
119599 --
119600
119601
119602 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
119603 xla_ae_lines_pkg.SetAnalyticalCriteria(
119604 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
119605 , p_analytical_criterion_owner => 'S'
119606 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
119607 , p_amb_context_code => 'DEFAULT'
119608 , p_balancing_flag => 'Y'
119609
119610 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
119611 , p_analytical_detail_num_1 => NULL
119612 , p_analytical_detail_date_1 => NULL
119613
119614 , p_ae_header_id => l_ae_header_id
119615 )
119616 ;
119617 --
119618
119619 --
119620 -- call description
119621 --
119622
119623 xla_ae_lines_pkg.SetLineDescription(
119624 p_ae_header_id => l_ae_header_id
119625 ,p_description => Description_1 (
119626 p_application_id => p_application_id
119627 , p_ae_header_id => l_ae_header_id
119628 , p_source_1 => p_source_1
119629 , p_source_2 => p_source_2
119630 , p_source_3 => p_source_3
119631 , p_source_4 => p_source_4
119632 , p_source_5 => p_source_5
119633 )
119634 );
119635
119636
119637 --
119638 -- call ADRs
119639 -- Bug 4922099
119640 --
119641 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
119642 (NVL(l_actual_upg_option, 'N') = 'O') OR
119643 (NVL(l_enc_upg_option, 'N') = 'O')
119644 )
119645 THEN
119646 NULL;
119647 --
119648 --
119649
119650 l_ccid := AcctDerRule_28(
119651 p_application_id => p_application_id
119652 , p_ae_header_id => l_ae_header_id
119653 , p_source_15 => p_source_15
119654 , p_source_41 => p_source_41
119655 , p_source_42 => p_source_42
119656 , p_source_43 => p_source_43
119657 , p_source_44 => p_source_44
119658 , p_source_45 => p_source_45
119659 , x_transaction_coa_id => l_adr_transaction_coa_id
119660 , x_accounting_coa_id => l_adr_accounting_coa_id
119661 , x_value_type_code => l_adr_value_type_code
119662 , p_side => 'NA'
119663 );
119664
119665 xla_ae_lines_pkg.set_ccid(
119666 p_code_combination_id => l_ccid
119667 , p_value_type_code => l_adr_value_type_code
119668 , p_transaction_coa_id => l_adr_transaction_coa_id
119669 , p_accounting_coa_id => l_adr_accounting_coa_id
119670 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
119671 , p_adr_type_code => 'S'
119672 , p_component_type => l_component_type
119673 , p_component_code => l_component_code
119674 , p_component_type_code => l_component_type_code
119675 , p_component_appl_id => l_component_appl_id
119676 , p_amb_context_code => l_amb_context_code
119677 , p_side => 'NA'
119678 );
119679
119680
119681 --
119682 --
119683 END IF;
119684 --
119685 -- Bug 4922099
119686 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
119687 (NVL(l_enc_upg_option, 'N') = 'O')
119688 ) AND
119689 (l_bflow_method_code = 'PRIOR_ENTRY')
119690 )
119691 THEN
119692 IF
119693 --
119694 1 = 2
119695 --
119696 THEN
119697 xla_accounting_err_pkg.build_message
119698 (p_appli_s_name => 'XLA'
119699 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
119700 ,p_token_1 => 'LINE_NUMBER'
119701 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
119702 ,p_token_2 => 'LINE_TYPE_NAME'
119703 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
119704 l_component_type
119705 ,l_component_code
119706 ,l_component_type_code
119707 ,l_component_appl_id
119708 ,l_amb_context_code
119709 ,l_entity_code
119710 ,l_event_class_code
119711 )
119712 ,p_token_3 => 'OWNER'
119713 ,p_value_3 => xla_lookups_pkg.get_meaning(
119714 p_lookup_type => 'XLA_OWNER_TYPE'
119715 ,p_lookup_code => l_component_type_code
119716 )
119717 ,p_token_4 => 'PRODUCT_NAME'
119718 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
119719 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
119720 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
119721 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
119722 ,p_ae_header_id => NULL
119723 );
119724
119725 IF (C_LEVEL_ERROR>= g_log_level) THEN
119726 trace
119727 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
119728 ,p_level => C_LEVEL_ERROR
119729 ,p_module => l_log_module);
119730 END IF;
119731 END IF;
119732 END IF;
119733 --
119734 --
119735 ------------------------------------------------------------------------------------------------
119736 -- 4219869 Business Flow
119737 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
119738 -- Prior Entry. Currently, the following code is always generated.
119739 ------------------------------------------------------------------------------------------------
119740 XLA_AE_LINES_PKG.ValidateCurrentLine;
119741
119742 ------------------------------------------------------------------------------------
119743 -- 4219869 Business Flow
119744 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
119745 ------------------------------------------------------------------------------------
119746 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
119747
119748 ----------------------------------------------------------------------------------
119749 -- 4219869 Business Flow
119750 -- Update journal entry status -- Need to generate this within IF <condition>
119751 ----------------------------------------------------------------------------------
119752 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
119753 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
119754 ,p_balance_type_code => l_balance_type_code
119755 );
119756
119757 -------------------------------------------------------------------------------------------
119758 -- 4262811 - Generate the Accrual Reversal lines
119759 -------------------------------------------------------------------------------------------
119760 BEGIN
119761 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
119762 (g_array_event(p_event_id).array_value_num('header_index'));
119763 IF l_acc_rev_flag IS NULL THEN
119764 l_acc_rev_flag := 'N';
119765 END IF;
119766 EXCEPTION
119767 WHEN OTHERS THEN
119768 l_acc_rev_flag := 'N';
119769 END;
119770 --
119771 IF (l_acc_rev_flag = 'Y') THEN
119772
119773 -- 4645092 ------------------------------------------------------------------------------
119774 -- To allow MPA report to determine if it should generate report process
119775 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
119776 ------------------------------------------------------------------------------------------
119777
119778 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
119779 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
119780 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
119781 -- call ADRs
119782 -- Bug 4922099
119783 --
119784 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
119785 (NVL(l_actual_upg_option, 'N') = 'O') OR
119786 (NVL(l_enc_upg_option, 'N') = 'O')
119787 )
119788 THEN
119789 NULL;
119790 --
119791 --
119792
119793 l_ccid := AcctDerRule_28(
119794 p_application_id => p_application_id
119795 , p_ae_header_id => l_ae_header_id
119796 , p_source_15 => p_source_15
119797 , p_source_41 => p_source_41
119798 , p_source_42 => p_source_42
119799 , p_source_43 => p_source_43
119800 , p_source_44 => p_source_44
119801 , p_source_45 => p_source_45
119802 , x_transaction_coa_id => l_adr_transaction_coa_id
119803 , x_accounting_coa_id => l_adr_accounting_coa_id
119804 , x_value_type_code => l_adr_value_type_code
119805 , p_side => 'NA'
119806 );
119807
119808 xla_ae_lines_pkg.set_ccid(
119809 p_code_combination_id => l_ccid
119810 , p_value_type_code => l_adr_value_type_code
119811 , p_transaction_coa_id => l_adr_transaction_coa_id
119812 , p_accounting_coa_id => l_adr_accounting_coa_id
119813 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
119814 , p_adr_type_code => 'S'
119815 , p_component_type => l_component_type
119816 , p_component_code => l_component_code
119817 , p_component_type_code => l_component_type_code
119818 , p_component_appl_id => l_component_appl_id
119819 , p_amb_context_code => l_amb_context_code
119820 , p_side => 'NA'
119821 );
119822
119823
119824 --
119825 --
119826 END IF;
119827
119828 --
119829 -- Update the line information that should be overwritten
119830 --
119831 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
119832 p_header_num => 1);
119833 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
119834
119835 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
119836
119837 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
119838 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
119839 END IF;
119840
119841 --
119842 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
119843 --
119844 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
119845 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
119846 ELSE
119847 ---------------------------------------------------------------------------------------------------
119848 -- 4262811a Switch Sign
119849 ---------------------------------------------------------------------------------------------------
119850 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
119851 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
119852 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119853 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
119854 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119855 -- 5132302
119856 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
119857 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
119858
119859 END IF;
119860
119861 -- 4955764
119862 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
119863 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
119864
119865
119866 XLA_AE_LINES_PKG.ValidateCurrentLine;
119867 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
119868
119869 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
119870 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
119871 ,p_balance_type_code => l_balance_type_code);
119872
119873 END IF;
119874
119875 -----------------------------------------------------------------------------------------
119876 -- 4262811 Multiperiod Accounting
119877 -----------------------------------------------------------------------------------------
119878 -- No MPA option is assigned.
119879
119880
119881 END IF;
119882 END IF;
119883 --
119884
119885 --
119886 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
119887 trace
119888 (p_msg => 'END of AcctLineType_232'
119889 ,p_level => C_LEVEL_PROCEDURE
119890 ,p_module => l_log_module);
119891 END IF;
119892 --
119893 EXCEPTION
119894 WHEN xla_exceptions_pkg.application_exception THEN
119895 RAISE;
119896 WHEN OTHERS THEN
119897 xla_exceptions_pkg.raise_message
119898 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_232');
119899 END AcctLineType_232;
119900 --
119901
119902 ---------------------------------------
119903 --
119904 -- PRIVATE FUNCTION
119905 -- AcctLineType_233
119906 --
119907 ---------------------------------------
119908 PROCEDURE AcctLineType_233 (
119909 p_application_id IN NUMBER
119910 ,p_event_id IN NUMBER
119911 ,p_calculate_acctd_flag IN VARCHAR2
119912 ,p_calculate_g_l_flag IN VARCHAR2
119913 ,p_actual_flag IN OUT VARCHAR2
119914 ,p_balance_type_code OUT VARCHAR2
119915 ,p_gain_or_loss_ref OUT VARCHAR2
119916
119917 --TRANSACTION_ID
119918 , p_source_1 IN NUMBER
119919 --Item Concatenated Segments
119920 , p_source_2 IN VARCHAR2
119921 --Transaction Quantity
119922 , p_source_3 IN NUMBER
119923 --Transaction Unit of Measure Code
119924 , p_source_4 IN VARCHAR2
119925 --Inventory Transaction Type Description
119926 , p_source_5 IN VARCHAR2
119927 --Cost Element Name
119928 , p_source_15 IN NUMBER
119929 --Product Line Accounting Category Material Account
119930 , p_source_41 IN NUMBER
119931 --Product Line Accounting Category Material Overhead Account
119932 , p_source_42 IN NUMBER
119933 --Product Line Accounting Category Resource Account
119934 , p_source_43 IN NUMBER
119935 --Product Line Accounting Category Outside Processing Account
119936 , p_source_44 IN NUMBER
119937 --Product Line Accounting Category Overhead Account
119938 , p_source_45 IN NUMBER
119939 --DISTRIBUTION_IDENTIFIER
119940 , p_source_84 IN NUMBER
119941 --Distribution Type
119942 , p_source_85 IN VARCHAR2
119943 , p_source_85_meaning IN VARCHAR2
119944 --Entered Currency Code
119945 , p_source_88 IN VARCHAR2
119946 --Entered Amount
119947 , p_source_91 IN NUMBER
119948 --Currency Conversion Date
119949 , p_source_92 IN DATE
119950 --Currency Conversion Rate
119951 , p_source_93 IN NUMBER
119952 --Currency Conversion Type
119953 , p_source_94 IN VARCHAR2
119954 --Accounted Amount
119955 , p_source_95 IN NUMBER
119956 --Accounting Line Type
119957 , p_source_97 IN NUMBER
119958 --Organization Code
119959 , p_source_108 IN VARCHAR2
119960 )
119961 IS
119962
119963 l_component_type VARCHAR2(80);
119964 l_component_code VARCHAR2(30);
119965 l_component_type_code VARCHAR2(1);
119966 l_component_appl_id INTEGER;
119967 l_amb_context_code VARCHAR2(30);
119968 l_entity_code VARCHAR2(30);
119969 l_event_class_code VARCHAR2(30);
119970 l_ae_header_id NUMBER;
119971 l_event_type_code VARCHAR2(30);
119972 l_line_definition_code VARCHAR2(30);
119973 l_line_definition_owner_code VARCHAR2(1);
119974 --
119975 -- adr variables
119976 l_segment VARCHAR2(30);
119977 l_ccid NUMBER;
119978 l_adr_transaction_coa_id NUMBER;
119979 l_adr_accounting_coa_id NUMBER;
119980 l_adr_flexfield_segment_code VARCHAR2(30);
119981 l_adr_flex_value_set_id NUMBER;
119982 l_adr_value_type_code VARCHAR2(30);
119983 l_adr_value_combination_id NUMBER;
119984 l_adr_value_segment_code VARCHAR2(30);
119985
119986 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
119987 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
119988 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
119989 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
119990
119991 -- 4262811 Variables ------------------------------------------------------------------------------------------
119992 l_entered_amt_idx NUMBER;
119993 l_accted_amt_idx NUMBER;
119994 l_acc_rev_flag VARCHAR2(1);
119995 l_accrual_line_num NUMBER;
119996 l_tmp_amt NUMBER;
119997 l_acc_rev_natural_side_code VARCHAR2(1);
119998
119999 l_num_entries NUMBER;
120000 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
120001 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
120002 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
120003 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
120004 l_recog_line_1 NUMBER;
120005 l_recog_line_2 NUMBER;
120006
120007 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
120008 l_bflow_applied_to_amt NUMBER; -- 5132302
120009 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
120010
120011 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
120012
120013 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
120014 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
120015
120016 ---------------------------------------------------------------------------------------------------------------
120017
120018
120019 --
120020 -- bulk performance
120021 --
120022 l_balance_type_code VARCHAR2(1);
120023 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
120024 l_log_module VARCHAR2(240);
120025
120026 --
120027 -- Upgrade strategy
120028 --
120029 l_actual_upg_option VARCHAR2(1);
120030 l_enc_upg_option VARCHAR2(1);
120031
120032 --
120033 BEGIN
120034 --
120035 IF g_log_enabled THEN
120036 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_233';
120037 END IF;
120038 --
120039 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
120040
120041 trace
120042 (p_msg => 'BEGIN of AcctLineType_233'
120043 ,p_level => C_LEVEL_PROCEDURE
120044 ,p_module => l_log_module);
120045
120046 END IF;
120047 --
120048 l_component_type := 'AMB_JLT';
120049 l_component_code := 'INVENTORY_VALUATION';
120050 l_component_type_code := 'S';
120051 l_component_appl_id := 707;
120052 l_amb_context_code := 'DEFAULT';
120053 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
120054 l_event_class_code := 'LOG_INTERCOMPANY';
120055 l_event_type_code := 'LOG_IC_SHIPMENT_RCPT';
120056 l_line_definition_owner_code := 'S';
120057 l_line_definition_code := 'PI_LOG_IC_SHIPMENT_RCPT';
120058 --
120059 l_balance_type_code := 'A';
120060 l_segment := NULL;
120061 l_ccid := NULL;
120062 l_adr_transaction_coa_id := NULL;
120063 l_adr_accounting_coa_id := NULL;
120064 l_adr_flexfield_segment_code := NULL;
120065 l_adr_flex_value_set_id := NULL;
120066 l_adr_value_type_code := NULL;
120067 l_adr_value_combination_id := NULL;
120068 l_adr_value_segment_code := NULL;
120069
120070 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
120071 l_bflow_class_code := ''; -- 4219869 Business Flow
120072 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
120073 l_budgetary_control_flag := 'N';
120074
120075 l_bflow_applied_to_amt_idx := NULL; -- 5132302
120076 l_bflow_applied_to_amt := NULL; -- 5132302
120077 l_entered_amt_idx := NULL; -- 4262811
120078 l_accted_amt_idx := NULL; -- 4262811
120079 l_acc_rev_flag := NULL; -- 4262811
120080 l_accrual_line_num := NULL; -- 4262811
120081 l_tmp_amt := NULL; -- 4262811
120082 --
120083
120084 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
120085 l_balance_type_code <> 'B' THEN
120086 IF NVL(p_source_97,9E125) = 1
120087 THEN
120088
120089 --
120090 XLA_AE_LINES_PKG.SetNewLine;
120091
120092 p_balance_type_code := l_balance_type_code;
120093 -- set the flag so later we will know whether the gain loss line needs to be created
120094
120095 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
120096 p_actual_flag :='A';
120097 END IF;
120098
120099 --
120100 -- bulk performance
120101 --
120102 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
120103 p_header_num => 0); -- 4262811
120104 --
120105 -- set accounting line options
120106 --
120107 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
120108 p_natural_side_code => 'D'
120109 , p_gain_or_loss_flag => 'N'
120110 , p_gl_transfer_mode_code => 'S'
120111 , p_acct_entry_type_code => 'A'
120112 , p_switch_side_flag => 'Y'
120113 , p_merge_duplicate_code => 'N'
120114 );
120115 --
120116 l_acc_rev_natural_side_code := 'C'; -- 4262811
120117 --
120118 --
120119 -- set accounting line type info
120120 --
120121 xla_ae_lines_pkg.SetAcctLineType
120122 (p_component_type => l_component_type
120123 ,p_event_type_code => l_event_type_code
120124 ,p_line_definition_owner_code => l_line_definition_owner_code
120125 ,p_line_definition_code => l_line_definition_code
120126 ,p_accounting_line_code => l_component_code
120127 ,p_accounting_line_type_code => l_component_type_code
120128 ,p_accounting_line_appl_id => l_component_appl_id
120129 ,p_amb_context_code => l_amb_context_code
120130 ,p_entity_code => l_entity_code
120131 ,p_event_class_code => l_event_class_code);
120132 --
120133 -- set accounting class
120134 --
120135 xla_ae_lines_pkg.SetAcctClass(
120136 p_accounting_class_code => 'INVENTORY_VALUATION'
120137 , p_ae_header_id => l_ae_header_id
120138 );
120139
120140 --
120141 -- set rounding class
120142 --
120143 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
120144 'INVENTORY_VALUATION';
120145
120146 --
120147 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
120148 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
120149 --
120150 -- bulk performance
120151 --
120152 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
120153
120154 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
120155 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
120156
120157 -- 4955764
120158 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
120159 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
120160
120161 -- 4458381 Public Sector Enh
120162
120163 --
120164 -- set accounting attributes for the line type
120165 --
120166 l_entered_amt_idx := 3;
120167 l_accted_amt_idx := 8;
120168 l_bflow_applied_to_amt_idx := NULL; -- 5132302
120169 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
120170 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
120171 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
120172 l_rec_acct_attrs.array_char_value(2) := p_source_85;
120173 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
120174 l_rec_acct_attrs.array_num_value(3) := p_source_91;
120175 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
120176 l_rec_acct_attrs.array_char_value(4) := p_source_88;
120177 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
120178 l_rec_acct_attrs.array_date_value(5) := p_source_92;
120179 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
120180 l_rec_acct_attrs.array_num_value(6) := p_source_93;
120181 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
120182 l_rec_acct_attrs.array_char_value(7) := p_source_94;
120183 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
120184 l_rec_acct_attrs.array_num_value(8) := p_source_95;
120185
120186 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
120187 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
120188
120189 ---------------------------------------------------------------------------------------------------------------
120190 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
120191 ---------------------------------------------------------------------------------------------------------------
120192 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
120193
120194 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
120195 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
120196
120197 IF xla_accounting_cache_pkg.GetValueChar
120198 (p_source_code => 'LEDGER_CATEGORY_CODE'
120199 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
120200 AND l_bflow_method_code = 'PRIOR_ENTRY'
120201 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
120202 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
120203 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
120204 )
120205 THEN
120206 xla_ae_lines_pkg.BflowUpgEntry
120207 (p_business_method_code => l_bflow_method_code
120208 ,p_business_class_code => l_bflow_class_code
120209 ,p_balance_type => l_balance_type_code);
120210 ELSE
120211 NULL;
120212 -- No business flow processing for business flow method of NONE.
120213 END IF;
120214
120215 --
120216 -- call analytical criteria
120217 --
120218
120219
120220 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
120221 xla_ae_lines_pkg.SetAnalyticalCriteria(
120222 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
120223 , p_analytical_criterion_owner => 'S'
120224 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
120225 , p_amb_context_code => 'DEFAULT'
120226 , p_balancing_flag => 'Y'
120227
120228 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
120229 , p_analytical_detail_num_1 => NULL
120230 , p_analytical_detail_date_1 => NULL
120231
120232 , p_ae_header_id => l_ae_header_id
120233 )
120234 ;
120235 --
120236
120237 --
120238 -- call description
120239 --
120240
120241 xla_ae_lines_pkg.SetLineDescription(
120242 p_ae_header_id => l_ae_header_id
120243 ,p_description => Description_1 (
120244 p_application_id => p_application_id
120245 , p_ae_header_id => l_ae_header_id
120246 , p_source_1 => p_source_1
120247 , p_source_2 => p_source_2
120248 , p_source_3 => p_source_3
120249 , p_source_4 => p_source_4
120250 , p_source_5 => p_source_5
120251 )
120252 );
120253
120254
120255 --
120256 -- call ADRs
120257 -- Bug 4922099
120258 --
120259 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
120260 (NVL(l_actual_upg_option, 'N') = 'O') OR
120261 (NVL(l_enc_upg_option, 'N') = 'O')
120262 )
120263 THEN
120264 NULL;
120265 --
120266 --
120267
120268 l_ccid := AcctDerRule_28(
120269 p_application_id => p_application_id
120270 , p_ae_header_id => l_ae_header_id
120271 , p_source_15 => p_source_15
120272 , p_source_41 => p_source_41
120273 , p_source_42 => p_source_42
120274 , p_source_43 => p_source_43
120275 , p_source_44 => p_source_44
120276 , p_source_45 => p_source_45
120277 , x_transaction_coa_id => l_adr_transaction_coa_id
120278 , x_accounting_coa_id => l_adr_accounting_coa_id
120279 , x_value_type_code => l_adr_value_type_code
120280 , p_side => 'NA'
120281 );
120282
120283 xla_ae_lines_pkg.set_ccid(
120284 p_code_combination_id => l_ccid
120285 , p_value_type_code => l_adr_value_type_code
120286 , p_transaction_coa_id => l_adr_transaction_coa_id
120287 , p_accounting_coa_id => l_adr_accounting_coa_id
120288 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
120289 , p_adr_type_code => 'S'
120290 , p_component_type => l_component_type
120291 , p_component_code => l_component_code
120292 , p_component_type_code => l_component_type_code
120293 , p_component_appl_id => l_component_appl_id
120294 , p_amb_context_code => l_amb_context_code
120295 , p_side => 'NA'
120296 );
120297
120298
120299 --
120300 --
120301 END IF;
120302 --
120303 -- Bug 4922099
120304 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
120305 (NVL(l_enc_upg_option, 'N') = 'O')
120306 ) AND
120307 (l_bflow_method_code = 'PRIOR_ENTRY')
120308 )
120309 THEN
120310 IF
120311 --
120312 1 = 2
120313 --
120314 THEN
120315 xla_accounting_err_pkg.build_message
120316 (p_appli_s_name => 'XLA'
120317 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
120318 ,p_token_1 => 'LINE_NUMBER'
120319 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
120320 ,p_token_2 => 'LINE_TYPE_NAME'
120321 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
120322 l_component_type
120323 ,l_component_code
120324 ,l_component_type_code
120325 ,l_component_appl_id
120326 ,l_amb_context_code
120327 ,l_entity_code
120328 ,l_event_class_code
120329 )
120330 ,p_token_3 => 'OWNER'
120331 ,p_value_3 => xla_lookups_pkg.get_meaning(
120332 p_lookup_type => 'XLA_OWNER_TYPE'
120333 ,p_lookup_code => l_component_type_code
120334 )
120335 ,p_token_4 => 'PRODUCT_NAME'
120336 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
120337 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
120338 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
120339 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
120340 ,p_ae_header_id => NULL
120341 );
120342
120343 IF (C_LEVEL_ERROR>= g_log_level) THEN
120344 trace
120345 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
120346 ,p_level => C_LEVEL_ERROR
120347 ,p_module => l_log_module);
120348 END IF;
120349 END IF;
120350 END IF;
120351 --
120352 --
120353 ------------------------------------------------------------------------------------------------
120354 -- 4219869 Business Flow
120355 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
120356 -- Prior Entry. Currently, the following code is always generated.
120357 ------------------------------------------------------------------------------------------------
120358 XLA_AE_LINES_PKG.ValidateCurrentLine;
120359
120360 ------------------------------------------------------------------------------------
120361 -- 4219869 Business Flow
120362 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
120363 ------------------------------------------------------------------------------------
120364 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
120365
120366 ----------------------------------------------------------------------------------
120367 -- 4219869 Business Flow
120368 -- Update journal entry status -- Need to generate this within IF <condition>
120369 ----------------------------------------------------------------------------------
120370 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
120371 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
120372 ,p_balance_type_code => l_balance_type_code
120373 );
120374
120375 -------------------------------------------------------------------------------------------
120376 -- 4262811 - Generate the Accrual Reversal lines
120377 -------------------------------------------------------------------------------------------
120378 BEGIN
120379 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
120380 (g_array_event(p_event_id).array_value_num('header_index'));
120381 IF l_acc_rev_flag IS NULL THEN
120382 l_acc_rev_flag := 'N';
120383 END IF;
120384 EXCEPTION
120385 WHEN OTHERS THEN
120386 l_acc_rev_flag := 'N';
120387 END;
120388 --
120389 IF (l_acc_rev_flag = 'Y') THEN
120390
120391 -- 4645092 ------------------------------------------------------------------------------
120392 -- To allow MPA report to determine if it should generate report process
120393 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
120394 ------------------------------------------------------------------------------------------
120395
120396 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
120397 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
120398 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
120399 -- call ADRs
120400 -- Bug 4922099
120401 --
120402 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
120403 (NVL(l_actual_upg_option, 'N') = 'O') OR
120404 (NVL(l_enc_upg_option, 'N') = 'O')
120405 )
120406 THEN
120407 NULL;
120408 --
120409 --
120410
120411 l_ccid := AcctDerRule_28(
120412 p_application_id => p_application_id
120413 , p_ae_header_id => l_ae_header_id
120414 , p_source_15 => p_source_15
120415 , p_source_41 => p_source_41
120416 , p_source_42 => p_source_42
120417 , p_source_43 => p_source_43
120418 , p_source_44 => p_source_44
120419 , p_source_45 => p_source_45
120420 , x_transaction_coa_id => l_adr_transaction_coa_id
120421 , x_accounting_coa_id => l_adr_accounting_coa_id
120422 , x_value_type_code => l_adr_value_type_code
120423 , p_side => 'NA'
120424 );
120425
120426 xla_ae_lines_pkg.set_ccid(
120427 p_code_combination_id => l_ccid
120428 , p_value_type_code => l_adr_value_type_code
120429 , p_transaction_coa_id => l_adr_transaction_coa_id
120430 , p_accounting_coa_id => l_adr_accounting_coa_id
120431 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
120432 , p_adr_type_code => 'S'
120433 , p_component_type => l_component_type
120434 , p_component_code => l_component_code
120435 , p_component_type_code => l_component_type_code
120436 , p_component_appl_id => l_component_appl_id
120437 , p_amb_context_code => l_amb_context_code
120438 , p_side => 'NA'
120439 );
120440
120441
120442 --
120443 --
120444 END IF;
120445
120446 --
120447 -- Update the line information that should be overwritten
120448 --
120449 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
120450 p_header_num => 1);
120451 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
120452
120453 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
120454
120455 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
120456 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
120457 END IF;
120458
120459 --
120460 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
120461 --
120462 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
120463 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
120464 ELSE
120465 ---------------------------------------------------------------------------------------------------
120466 -- 4262811a Switch Sign
120467 ---------------------------------------------------------------------------------------------------
120468 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
120469 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
120470 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
120471 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
120472 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
120473 -- 5132302
120474 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
120475 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
120476
120477 END IF;
120478
120479 -- 4955764
120480 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
120481 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
120482
120483
120484 XLA_AE_LINES_PKG.ValidateCurrentLine;
120485 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
120486
120487 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
120488 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
120489 ,p_balance_type_code => l_balance_type_code);
120490
120491 END IF;
120492
120493 -----------------------------------------------------------------------------------------
120494 -- 4262811 Multiperiod Accounting
120495 -----------------------------------------------------------------------------------------
120496 -- No MPA option is assigned.
120497
120498
120499 END IF;
120500 END IF;
120501 --
120502
120503 --
120504 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
120505 trace
120506 (p_msg => 'END of AcctLineType_233'
120507 ,p_level => C_LEVEL_PROCEDURE
120508 ,p_module => l_log_module);
120509 END IF;
120510 --
120511 EXCEPTION
120512 WHEN xla_exceptions_pkg.application_exception THEN
120513 RAISE;
120514 WHEN OTHERS THEN
120515 xla_exceptions_pkg.raise_message
120516 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_233');
120517 END AcctLineType_233;
120518 --
120519
120520 ---------------------------------------
120521 --
120522 -- PRIVATE FUNCTION
120523 -- AcctLineType_234
120524 --
120525 ---------------------------------------
120526 PROCEDURE AcctLineType_234 (
120527 p_application_id IN NUMBER
120528 ,p_event_id IN NUMBER
120529 ,p_calculate_acctd_flag IN VARCHAR2
120530 ,p_calculate_g_l_flag IN VARCHAR2
120531 ,p_actual_flag IN OUT VARCHAR2
120532 ,p_balance_type_code OUT VARCHAR2
120533 ,p_gain_or_loss_ref OUT VARCHAR2
120534
120535 --Cost Management Default Account
120536 , p_source_11 IN NUMBER
120537 --DISTRIBUTION_IDENTIFIER
120538 , p_source_84 IN NUMBER
120539 --Distribution Type
120540 , p_source_85 IN VARCHAR2
120541 , p_source_85_meaning IN VARCHAR2
120542 --Entered Currency Code
120543 , p_source_88 IN VARCHAR2
120544 --Entered Amount
120545 , p_source_91 IN NUMBER
120546 --Currency Conversion Date
120547 , p_source_92 IN DATE
120548 --Currency Conversion Rate
120549 , p_source_93 IN NUMBER
120550 --Currency Conversion Type
120551 , p_source_94 IN VARCHAR2
120552 --Accounted Amount
120553 , p_source_95 IN NUMBER
120554 --Accounting Line Type
120555 , p_source_97 IN NUMBER
120556 --Organization Code
120557 , p_source_108 IN VARCHAR2
120558 )
120559 IS
120560
120561 l_component_type VARCHAR2(80);
120562 l_component_code VARCHAR2(30);
120563 l_component_type_code VARCHAR2(1);
120564 l_component_appl_id INTEGER;
120565 l_amb_context_code VARCHAR2(30);
120566 l_entity_code VARCHAR2(30);
120567 l_event_class_code VARCHAR2(30);
120568 l_ae_header_id NUMBER;
120569 l_event_type_code VARCHAR2(30);
120570 l_line_definition_code VARCHAR2(30);
120571 l_line_definition_owner_code VARCHAR2(1);
120572 --
120573 -- adr variables
120574 l_segment VARCHAR2(30);
120575 l_ccid NUMBER;
120576 l_adr_transaction_coa_id NUMBER;
120577 l_adr_accounting_coa_id NUMBER;
120578 l_adr_flexfield_segment_code VARCHAR2(30);
120579 l_adr_flex_value_set_id NUMBER;
120580 l_adr_value_type_code VARCHAR2(30);
120581 l_adr_value_combination_id NUMBER;
120582 l_adr_value_segment_code VARCHAR2(30);
120583
120584 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
120585 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
120586 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
120587 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
120588
120589 -- 4262811 Variables ------------------------------------------------------------------------------------------
120590 l_entered_amt_idx NUMBER;
120591 l_accted_amt_idx NUMBER;
120592 l_acc_rev_flag VARCHAR2(1);
120593 l_accrual_line_num NUMBER;
120594 l_tmp_amt NUMBER;
120595 l_acc_rev_natural_side_code VARCHAR2(1);
120596
120597 l_num_entries NUMBER;
120598 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
120599 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
120600 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
120601 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
120602 l_recog_line_1 NUMBER;
120603 l_recog_line_2 NUMBER;
120604
120605 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
120606 l_bflow_applied_to_amt NUMBER; -- 5132302
120607 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
120608
120609 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
120610
120611 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
120612 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
120613
120614 ---------------------------------------------------------------------------------------------------------------
120615
120616
120617 --
120618 -- bulk performance
120619 --
120620 l_balance_type_code VARCHAR2(1);
120621 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
120622 l_log_module VARCHAR2(240);
120623
120624 --
120625 -- Upgrade strategy
120626 --
120627 l_actual_upg_option VARCHAR2(1);
120628 l_enc_upg_option VARCHAR2(1);
120629
120630 --
120631 BEGIN
120632 --
120633 IF g_log_enabled THEN
120634 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_234';
120635 END IF;
120636 --
120637 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
120638
120639 trace
120640 (p_msg => 'BEGIN of AcctLineType_234'
120641 ,p_level => C_LEVEL_PROCEDURE
120642 ,p_module => l_log_module);
120643
120644 END IF;
120645 --
120646 l_component_type := 'AMB_JLT';
120647 l_component_code := 'INVENTORY_VALUATION';
120648 l_component_type_code := 'S';
120649 l_component_appl_id := 707;
120650 l_amb_context_code := 'DEFAULT';
120651 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
120652 l_event_class_code := 'SALES_ORDER';
120653 l_event_type_code := 'COGS_RECOGNITION_ADJ';
120654 l_line_definition_owner_code := 'S';
120655 l_line_definition_code := 'PI_COGS_RECOGNITION_ADJ';
120656 --
120657 l_balance_type_code := 'A';
120658 l_segment := NULL;
120659 l_ccid := NULL;
120660 l_adr_transaction_coa_id := NULL;
120661 l_adr_accounting_coa_id := NULL;
120662 l_adr_flexfield_segment_code := NULL;
120663 l_adr_flex_value_set_id := NULL;
120664 l_adr_value_type_code := NULL;
120665 l_adr_value_combination_id := NULL;
120666 l_adr_value_segment_code := NULL;
120667
120668 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
120669 l_bflow_class_code := ''; -- 4219869 Business Flow
120670 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
120671 l_budgetary_control_flag := 'N';
120672
120673 l_bflow_applied_to_amt_idx := NULL; -- 5132302
120674 l_bflow_applied_to_amt := NULL; -- 5132302
120675 l_entered_amt_idx := NULL; -- 4262811
120676 l_accted_amt_idx := NULL; -- 4262811
120677 l_acc_rev_flag := NULL; -- 4262811
120678 l_accrual_line_num := NULL; -- 4262811
120679 l_tmp_amt := NULL; -- 4262811
120680 --
120681
120682 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
120683 l_balance_type_code <> 'B' THEN
120684 IF NVL(p_source_97,9E125) = 1
120685 THEN
120686
120687 --
120688 XLA_AE_LINES_PKG.SetNewLine;
120689
120690 p_balance_type_code := l_balance_type_code;
120691 -- set the flag so later we will know whether the gain loss line needs to be created
120692
120693 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
120694 p_actual_flag :='A';
120695 END IF;
120696
120697 --
120698 -- bulk performance
120699 --
120700 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
120701 p_header_num => 0); -- 4262811
120702 --
120703 -- set accounting line options
120704 --
120705 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
120706 p_natural_side_code => 'D'
120707 , p_gain_or_loss_flag => 'N'
120708 , p_gl_transfer_mode_code => 'S'
120709 , p_acct_entry_type_code => 'A'
120710 , p_switch_side_flag => 'Y'
120711 , p_merge_duplicate_code => 'N'
120712 );
120713 --
120714 l_acc_rev_natural_side_code := 'C'; -- 4262811
120715 --
120716 --
120717 -- set accounting line type info
120718 --
120719 xla_ae_lines_pkg.SetAcctLineType
120720 (p_component_type => l_component_type
120721 ,p_event_type_code => l_event_type_code
120722 ,p_line_definition_owner_code => l_line_definition_owner_code
120723 ,p_line_definition_code => l_line_definition_code
120724 ,p_accounting_line_code => l_component_code
120725 ,p_accounting_line_type_code => l_component_type_code
120726 ,p_accounting_line_appl_id => l_component_appl_id
120727 ,p_amb_context_code => l_amb_context_code
120728 ,p_entity_code => l_entity_code
120729 ,p_event_class_code => l_event_class_code);
120730 --
120731 -- set accounting class
120732 --
120733 xla_ae_lines_pkg.SetAcctClass(
120734 p_accounting_class_code => 'INVENTORY_VALUATION'
120735 , p_ae_header_id => l_ae_header_id
120736 );
120737
120738 --
120739 -- set rounding class
120740 --
120741 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
120742 'INVENTORY_VALUATION';
120743
120744 --
120745 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
120746 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
120747 --
120748 -- bulk performance
120749 --
120750 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
120751
120752 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
120753 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
120754
120755 -- 4955764
120756 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
120757 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
120758
120759 -- 4458381 Public Sector Enh
120760
120761 --
120762 -- set accounting attributes for the line type
120763 --
120764 l_entered_amt_idx := 3;
120765 l_accted_amt_idx := 8;
120766 l_bflow_applied_to_amt_idx := NULL; -- 5132302
120767 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
120768 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
120769 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
120770 l_rec_acct_attrs.array_char_value(2) := p_source_85;
120771 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
120772 l_rec_acct_attrs.array_num_value(3) := p_source_91;
120773 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
120774 l_rec_acct_attrs.array_char_value(4) := p_source_88;
120775 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
120776 l_rec_acct_attrs.array_date_value(5) := p_source_92;
120777 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
120778 l_rec_acct_attrs.array_num_value(6) := p_source_93;
120779 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
120780 l_rec_acct_attrs.array_char_value(7) := p_source_94;
120781 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
120782 l_rec_acct_attrs.array_num_value(8) := p_source_95;
120783
120784 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
120785 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
120786
120787 ---------------------------------------------------------------------------------------------------------------
120788 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
120789 ---------------------------------------------------------------------------------------------------------------
120790 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
120791
120792 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
120793 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
120794
120795 IF xla_accounting_cache_pkg.GetValueChar
120796 (p_source_code => 'LEDGER_CATEGORY_CODE'
120797 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
120798 AND l_bflow_method_code = 'PRIOR_ENTRY'
120799 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
120800 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
120801 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
120802 )
120803 THEN
120804 xla_ae_lines_pkg.BflowUpgEntry
120805 (p_business_method_code => l_bflow_method_code
120806 ,p_business_class_code => l_bflow_class_code
120807 ,p_balance_type => l_balance_type_code);
120808 ELSE
120809 NULL;
120810 -- No business flow processing for business flow method of NONE.
120811 END IF;
120812
120813 --
120814 -- call analytical criteria
120815 --
120816
120817
120818 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
120819 xla_ae_lines_pkg.SetAnalyticalCriteria(
120820 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
120821 , p_analytical_criterion_owner => 'S'
120822 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
120823 , p_amb_context_code => 'DEFAULT'
120824 , p_balancing_flag => 'Y'
120825
120826 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
120827 , p_analytical_detail_num_1 => NULL
120828 , p_analytical_detail_date_1 => NULL
120829
120830 , p_ae_header_id => l_ae_header_id
120831 )
120832 ;
120833 --
120834
120835 --
120836 -- call description
120837 --
120838 -- No description or it is inherited.
120839 --
120840 -- call ADRs
120841 -- Bug 4922099
120842 --
120843 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
120844 (NVL(l_actual_upg_option, 'N') = 'O') OR
120845 (NVL(l_enc_upg_option, 'N') = 'O')
120846 )
120847 THEN
120848 NULL;
120849 --
120850 --
120851
120852 l_ccid := AcctDerRule_6(
120853 p_application_id => p_application_id
120854 , p_ae_header_id => l_ae_header_id
120855 , p_source_11 => p_source_11
120856 , x_transaction_coa_id => l_adr_transaction_coa_id
120857 , x_accounting_coa_id => l_adr_accounting_coa_id
120858 , x_value_type_code => l_adr_value_type_code
120859 , p_side => 'NA'
120860 );
120861
120862 xla_ae_lines_pkg.set_ccid(
120863 p_code_combination_id => l_ccid
120864 , p_value_type_code => l_adr_value_type_code
120865 , p_transaction_coa_id => l_adr_transaction_coa_id
120866 , p_accounting_coa_id => l_adr_accounting_coa_id
120867 , p_adr_code => 'CST_DEFAULT'
120868 , p_adr_type_code => 'S'
120869 , p_component_type => l_component_type
120870 , p_component_code => l_component_code
120871 , p_component_type_code => l_component_type_code
120872 , p_component_appl_id => l_component_appl_id
120873 , p_amb_context_code => l_amb_context_code
120874 , p_side => 'NA'
120875 );
120876
120877
120878 --
120879 --
120880 END IF;
120881 --
120882 -- Bug 4922099
120883 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
120884 (NVL(l_enc_upg_option, 'N') = 'O')
120885 ) AND
120886 (l_bflow_method_code = 'PRIOR_ENTRY')
120887 )
120888 THEN
120889 IF
120890 --
120891 1 = 2
120892 --
120893 THEN
120894 xla_accounting_err_pkg.build_message
120895 (p_appli_s_name => 'XLA'
120896 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
120897 ,p_token_1 => 'LINE_NUMBER'
120898 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
120899 ,p_token_2 => 'LINE_TYPE_NAME'
120900 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
120901 l_component_type
120902 ,l_component_code
120903 ,l_component_type_code
120904 ,l_component_appl_id
120905 ,l_amb_context_code
120906 ,l_entity_code
120907 ,l_event_class_code
120908 )
120909 ,p_token_3 => 'OWNER'
120910 ,p_value_3 => xla_lookups_pkg.get_meaning(
120911 p_lookup_type => 'XLA_OWNER_TYPE'
120912 ,p_lookup_code => l_component_type_code
120913 )
120914 ,p_token_4 => 'PRODUCT_NAME'
120915 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
120916 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
120917 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
120918 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
120919 ,p_ae_header_id => NULL
120920 );
120921
120922 IF (C_LEVEL_ERROR>= g_log_level) THEN
120923 trace
120924 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
120925 ,p_level => C_LEVEL_ERROR
120926 ,p_module => l_log_module);
120927 END IF;
120928 END IF;
120929 END IF;
120930 --
120931 --
120932 ------------------------------------------------------------------------------------------------
120933 -- 4219869 Business Flow
120934 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
120935 -- Prior Entry. Currently, the following code is always generated.
120936 ------------------------------------------------------------------------------------------------
120937 XLA_AE_LINES_PKG.ValidateCurrentLine;
120938
120939 ------------------------------------------------------------------------------------
120940 -- 4219869 Business Flow
120941 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
120942 ------------------------------------------------------------------------------------
120943 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
120944
120945 ----------------------------------------------------------------------------------
120946 -- 4219869 Business Flow
120947 -- Update journal entry status -- Need to generate this within IF <condition>
120948 ----------------------------------------------------------------------------------
120949 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
120950 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
120951 ,p_balance_type_code => l_balance_type_code
120952 );
120953
120954 -------------------------------------------------------------------------------------------
120955 -- 4262811 - Generate the Accrual Reversal lines
120956 -------------------------------------------------------------------------------------------
120957 BEGIN
120958 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
120959 (g_array_event(p_event_id).array_value_num('header_index'));
120960 IF l_acc_rev_flag IS NULL THEN
120961 l_acc_rev_flag := 'N';
120962 END IF;
120963 EXCEPTION
120964 WHEN OTHERS THEN
120965 l_acc_rev_flag := 'N';
120966 END;
120967 --
120968 IF (l_acc_rev_flag = 'Y') THEN
120969
120970 -- 4645092 ------------------------------------------------------------------------------
120971 -- To allow MPA report to determine if it should generate report process
120972 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
120973 ------------------------------------------------------------------------------------------
120974
120975 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
120976 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
120977 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
120978 -- call ADRs
120979 -- Bug 4922099
120980 --
120981 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
120982 (NVL(l_actual_upg_option, 'N') = 'O') OR
120983 (NVL(l_enc_upg_option, 'N') = 'O')
120984 )
120985 THEN
120986 NULL;
120987 --
120988 --
120989
120990 l_ccid := AcctDerRule_6(
120991 p_application_id => p_application_id
120992 , p_ae_header_id => l_ae_header_id
120993 , p_source_11 => p_source_11
120994 , x_transaction_coa_id => l_adr_transaction_coa_id
120995 , x_accounting_coa_id => l_adr_accounting_coa_id
120996 , x_value_type_code => l_adr_value_type_code
120997 , p_side => 'NA'
120998 );
120999
121000 xla_ae_lines_pkg.set_ccid(
121001 p_code_combination_id => l_ccid
121002 , p_value_type_code => l_adr_value_type_code
121003 , p_transaction_coa_id => l_adr_transaction_coa_id
121004 , p_accounting_coa_id => l_adr_accounting_coa_id
121005 , p_adr_code => 'CST_DEFAULT'
121006 , p_adr_type_code => 'S'
121007 , p_component_type => l_component_type
121008 , p_component_code => l_component_code
121009 , p_component_type_code => l_component_type_code
121010 , p_component_appl_id => l_component_appl_id
121011 , p_amb_context_code => l_amb_context_code
121012 , p_side => 'NA'
121013 );
121014
121015
121016 --
121017 --
121018 END IF;
121019
121020 --
121021 -- Update the line information that should be overwritten
121022 --
121023 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
121024 p_header_num => 1);
121025 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
121026
121027 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
121028
121029 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
121030 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
121031 END IF;
121032
121033 --
121034 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
121035 --
121036 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
121037 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
121038 ELSE
121039 ---------------------------------------------------------------------------------------------------
121040 -- 4262811a Switch Sign
121041 ---------------------------------------------------------------------------------------------------
121042 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
121043 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
121044 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121045 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
121046 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121047 -- 5132302
121048 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
121049 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121050
121051 END IF;
121052
121053 -- 4955764
121054 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
121055 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
121056
121057
121058 XLA_AE_LINES_PKG.ValidateCurrentLine;
121059 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
121060
121061 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
121062 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
121063 ,p_balance_type_code => l_balance_type_code);
121064
121065 END IF;
121066
121067 -----------------------------------------------------------------------------------------
121068 -- 4262811 Multiperiod Accounting
121069 -----------------------------------------------------------------------------------------
121070 -- No MPA option is assigned.
121071
121072
121073 END IF;
121074 END IF;
121075 --
121076
121077 --
121078 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
121079 trace
121080 (p_msg => 'END of AcctLineType_234'
121081 ,p_level => C_LEVEL_PROCEDURE
121082 ,p_module => l_log_module);
121083 END IF;
121084 --
121085 EXCEPTION
121086 WHEN xla_exceptions_pkg.application_exception THEN
121087 RAISE;
121088 WHEN OTHERS THEN
121089 xla_exceptions_pkg.raise_message
121090 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_234');
121091 END AcctLineType_234;
121092 --
121093
121094 ---------------------------------------
121095 --
121096 -- PRIVATE FUNCTION
121097 -- AcctLineType_235
121098 --
121099 ---------------------------------------
121100 PROCEDURE AcctLineType_235 (
121101 p_application_id IN NUMBER
121102 ,p_event_id IN NUMBER
121103 ,p_calculate_acctd_flag IN VARCHAR2
121104 ,p_calculate_g_l_flag IN VARCHAR2
121105 ,p_actual_flag IN OUT VARCHAR2
121106 ,p_balance_type_code OUT VARCHAR2
121107 ,p_gain_or_loss_ref OUT VARCHAR2
121108
121109 --TRANSACTION_ID
121110 , p_source_1 IN NUMBER
121111 --Item Concatenated Segments
121112 , p_source_2 IN VARCHAR2
121113 --Transaction Quantity
121114 , p_source_3 IN NUMBER
121115 --Transaction Unit of Measure Code
121116 , p_source_4 IN VARCHAR2
121117 --Inventory Transaction Type Description
121118 , p_source_5 IN VARCHAR2
121119 --Cost Element Name
121120 , p_source_15 IN NUMBER
121121 --Product Line Accounting Category Material Account
121122 , p_source_41 IN NUMBER
121123 --Product Line Accounting Category Material Overhead Account
121124 , p_source_42 IN NUMBER
121125 --Product Line Accounting Category Resource Account
121126 , p_source_43 IN NUMBER
121127 --Product Line Accounting Category Outside Processing Account
121128 , p_source_44 IN NUMBER
121129 --Product Line Accounting Category Overhead Account
121130 , p_source_45 IN NUMBER
121131 --DISTRIBUTION_IDENTIFIER
121132 , p_source_84 IN NUMBER
121133 --Distribution Type
121134 , p_source_85 IN VARCHAR2
121135 , p_source_85_meaning IN VARCHAR2
121136 --Entered Currency Code
121137 , p_source_88 IN VARCHAR2
121138 --Entered Amount
121139 , p_source_91 IN NUMBER
121140 --Currency Conversion Date
121141 , p_source_92 IN DATE
121142 --Currency Conversion Rate
121143 , p_source_93 IN NUMBER
121144 --Currency Conversion Type
121145 , p_source_94 IN VARCHAR2
121146 --Accounted Amount
121147 , p_source_95 IN NUMBER
121148 --Accounting Line Type
121149 , p_source_97 IN NUMBER
121150 --Organization Code
121151 , p_source_108 IN VARCHAR2
121152 )
121153 IS
121154
121155 l_component_type VARCHAR2(80);
121156 l_component_code VARCHAR2(30);
121157 l_component_type_code VARCHAR2(1);
121158 l_component_appl_id INTEGER;
121159 l_amb_context_code VARCHAR2(30);
121160 l_entity_code VARCHAR2(30);
121161 l_event_class_code VARCHAR2(30);
121162 l_ae_header_id NUMBER;
121163 l_event_type_code VARCHAR2(30);
121164 l_line_definition_code VARCHAR2(30);
121165 l_line_definition_owner_code VARCHAR2(1);
121166 --
121167 -- adr variables
121168 l_segment VARCHAR2(30);
121169 l_ccid NUMBER;
121170 l_adr_transaction_coa_id NUMBER;
121171 l_adr_accounting_coa_id NUMBER;
121172 l_adr_flexfield_segment_code VARCHAR2(30);
121173 l_adr_flex_value_set_id NUMBER;
121174 l_adr_value_type_code VARCHAR2(30);
121175 l_adr_value_combination_id NUMBER;
121176 l_adr_value_segment_code VARCHAR2(30);
121177
121178 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
121179 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
121180 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
121181 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
121182
121183 -- 4262811 Variables ------------------------------------------------------------------------------------------
121184 l_entered_amt_idx NUMBER;
121185 l_accted_amt_idx NUMBER;
121186 l_acc_rev_flag VARCHAR2(1);
121187 l_accrual_line_num NUMBER;
121188 l_tmp_amt NUMBER;
121189 l_acc_rev_natural_side_code VARCHAR2(1);
121190
121191 l_num_entries NUMBER;
121192 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
121193 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
121194 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
121195 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
121196 l_recog_line_1 NUMBER;
121197 l_recog_line_2 NUMBER;
121198
121199 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
121200 l_bflow_applied_to_amt NUMBER; -- 5132302
121201 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
121202
121203 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
121204
121205 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
121206 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
121207
121208 ---------------------------------------------------------------------------------------------------------------
121209
121210
121211 --
121212 -- bulk performance
121213 --
121214 l_balance_type_code VARCHAR2(1);
121215 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
121216 l_log_module VARCHAR2(240);
121217
121218 --
121219 -- Upgrade strategy
121220 --
121221 l_actual_upg_option VARCHAR2(1);
121222 l_enc_upg_option VARCHAR2(1);
121223
121224 --
121225 BEGIN
121226 --
121227 IF g_log_enabled THEN
121228 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_235';
121229 END IF;
121230 --
121231 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
121232
121233 trace
121234 (p_msg => 'BEGIN of AcctLineType_235'
121235 ,p_level => C_LEVEL_PROCEDURE
121236 ,p_module => l_log_module);
121237
121238 END IF;
121239 --
121240 l_component_type := 'AMB_JLT';
121241 l_component_code := 'INVENTORY_VALUATION';
121242 l_component_type_code := 'S';
121243 l_component_appl_id := 707;
121244 l_amb_context_code := 'DEFAULT';
121245 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
121246 l_event_class_code := 'USER_DEFINE';
121247 l_event_type_code := 'UFOB_RCPT_SENDER_SHIP';
121248 l_line_definition_owner_code := 'S';
121249 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
121250 --
121251 l_balance_type_code := 'A';
121252 l_segment := NULL;
121253 l_ccid := NULL;
121254 l_adr_transaction_coa_id := NULL;
121255 l_adr_accounting_coa_id := NULL;
121256 l_adr_flexfield_segment_code := NULL;
121257 l_adr_flex_value_set_id := NULL;
121258 l_adr_value_type_code := NULL;
121259 l_adr_value_combination_id := NULL;
121260 l_adr_value_segment_code := NULL;
121261
121262 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
121263 l_bflow_class_code := ''; -- 4219869 Business Flow
121264 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
121265 l_budgetary_control_flag := 'N';
121266
121267 l_bflow_applied_to_amt_idx := NULL; -- 5132302
121268 l_bflow_applied_to_amt := NULL; -- 5132302
121269 l_entered_amt_idx := NULL; -- 4262811
121270 l_accted_amt_idx := NULL; -- 4262811
121271 l_acc_rev_flag := NULL; -- 4262811
121272 l_accrual_line_num := NULL; -- 4262811
121273 l_tmp_amt := NULL; -- 4262811
121274 --
121275
121276 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
121277 l_balance_type_code <> 'B' THEN
121278 IF NVL(p_source_97,9E125) = 1
121279 THEN
121280
121281 --
121282 XLA_AE_LINES_PKG.SetNewLine;
121283
121284 p_balance_type_code := l_balance_type_code;
121285 -- set the flag so later we will know whether the gain loss line needs to be created
121286
121287 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
121288 p_actual_flag :='A';
121289 END IF;
121290
121291 --
121292 -- bulk performance
121293 --
121294 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
121295 p_header_num => 0); -- 4262811
121296 --
121297 -- set accounting line options
121298 --
121299 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
121300 p_natural_side_code => 'D'
121301 , p_gain_or_loss_flag => 'N'
121302 , p_gl_transfer_mode_code => 'S'
121303 , p_acct_entry_type_code => 'A'
121304 , p_switch_side_flag => 'Y'
121305 , p_merge_duplicate_code => 'N'
121306 );
121307 --
121308 l_acc_rev_natural_side_code := 'C'; -- 4262811
121309 --
121310 --
121311 -- set accounting line type info
121312 --
121313 xla_ae_lines_pkg.SetAcctLineType
121314 (p_component_type => l_component_type
121315 ,p_event_type_code => l_event_type_code
121316 ,p_line_definition_owner_code => l_line_definition_owner_code
121317 ,p_line_definition_code => l_line_definition_code
121318 ,p_accounting_line_code => l_component_code
121319 ,p_accounting_line_type_code => l_component_type_code
121320 ,p_accounting_line_appl_id => l_component_appl_id
121321 ,p_amb_context_code => l_amb_context_code
121322 ,p_entity_code => l_entity_code
121323 ,p_event_class_code => l_event_class_code);
121324 --
121325 -- set accounting class
121326 --
121327 xla_ae_lines_pkg.SetAcctClass(
121328 p_accounting_class_code => 'INVENTORY_VALUATION'
121329 , p_ae_header_id => l_ae_header_id
121330 );
121331
121332 --
121333 -- set rounding class
121334 --
121335 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
121336 'INVENTORY_VALUATION';
121337
121338 --
121339 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
121340 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
121341 --
121342 -- bulk performance
121343 --
121344 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
121345
121346 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
121347 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
121348
121349 -- 4955764
121350 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
121351 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
121352
121353 -- 4458381 Public Sector Enh
121354
121355 --
121356 -- set accounting attributes for the line type
121357 --
121358 l_entered_amt_idx := 3;
121359 l_accted_amt_idx := 8;
121360 l_bflow_applied_to_amt_idx := NULL; -- 5132302
121361 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
121362 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
121363 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
121364 l_rec_acct_attrs.array_char_value(2) := p_source_85;
121365 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
121366 l_rec_acct_attrs.array_num_value(3) := p_source_91;
121367 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
121368 l_rec_acct_attrs.array_char_value(4) := p_source_88;
121369 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
121370 l_rec_acct_attrs.array_date_value(5) := p_source_92;
121371 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
121372 l_rec_acct_attrs.array_num_value(6) := p_source_93;
121373 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
121374 l_rec_acct_attrs.array_char_value(7) := p_source_94;
121375 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
121376 l_rec_acct_attrs.array_num_value(8) := p_source_95;
121377
121378 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
121379 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
121380
121381 ---------------------------------------------------------------------------------------------------------------
121382 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
121383 ---------------------------------------------------------------------------------------------------------------
121384 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
121385
121386 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
121387 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
121388
121389 IF xla_accounting_cache_pkg.GetValueChar
121390 (p_source_code => 'LEDGER_CATEGORY_CODE'
121391 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
121392 AND l_bflow_method_code = 'PRIOR_ENTRY'
121393 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
121394 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
121395 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
121396 )
121397 THEN
121398 xla_ae_lines_pkg.BflowUpgEntry
121399 (p_business_method_code => l_bflow_method_code
121400 ,p_business_class_code => l_bflow_class_code
121401 ,p_balance_type => l_balance_type_code);
121402 ELSE
121403 NULL;
121404 -- No business flow processing for business flow method of NONE.
121405 END IF;
121406
121407 --
121408 -- call analytical criteria
121409 --
121410
121411
121412 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
121413 xla_ae_lines_pkg.SetAnalyticalCriteria(
121414 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
121415 , p_analytical_criterion_owner => 'S'
121416 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
121417 , p_amb_context_code => 'DEFAULT'
121418 , p_balancing_flag => 'Y'
121419
121420 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
121421 , p_analytical_detail_num_1 => NULL
121422 , p_analytical_detail_date_1 => NULL
121423
121424 , p_ae_header_id => l_ae_header_id
121425 )
121426 ;
121427 --
121428
121429 --
121430 -- call description
121431 --
121432
121433 xla_ae_lines_pkg.SetLineDescription(
121434 p_ae_header_id => l_ae_header_id
121435 ,p_description => Description_1 (
121436 p_application_id => p_application_id
121437 , p_ae_header_id => l_ae_header_id
121438 , p_source_1 => p_source_1
121439 , p_source_2 => p_source_2
121440 , p_source_3 => p_source_3
121441 , p_source_4 => p_source_4
121442 , p_source_5 => p_source_5
121443 )
121444 );
121445
121446
121447 --
121448 -- call ADRs
121449 -- Bug 4922099
121450 --
121451 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
121452 (NVL(l_actual_upg_option, 'N') = 'O') OR
121453 (NVL(l_enc_upg_option, 'N') = 'O')
121454 )
121455 THEN
121456 NULL;
121457 --
121458 --
121459
121460 l_ccid := AcctDerRule_28(
121461 p_application_id => p_application_id
121462 , p_ae_header_id => l_ae_header_id
121463 , p_source_15 => p_source_15
121464 , p_source_41 => p_source_41
121465 , p_source_42 => p_source_42
121466 , p_source_43 => p_source_43
121467 , p_source_44 => p_source_44
121468 , p_source_45 => p_source_45
121469 , x_transaction_coa_id => l_adr_transaction_coa_id
121470 , x_accounting_coa_id => l_adr_accounting_coa_id
121471 , x_value_type_code => l_adr_value_type_code
121472 , p_side => 'NA'
121473 );
121474
121475 xla_ae_lines_pkg.set_ccid(
121476 p_code_combination_id => l_ccid
121477 , p_value_type_code => l_adr_value_type_code
121478 , p_transaction_coa_id => l_adr_transaction_coa_id
121479 , p_accounting_coa_id => l_adr_accounting_coa_id
121480 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
121481 , p_adr_type_code => 'S'
121482 , p_component_type => l_component_type
121483 , p_component_code => l_component_code
121484 , p_component_type_code => l_component_type_code
121485 , p_component_appl_id => l_component_appl_id
121486 , p_amb_context_code => l_amb_context_code
121487 , p_side => 'NA'
121488 );
121489
121490
121491 --
121492 --
121493 END IF;
121494 --
121495 -- Bug 4922099
121496 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
121497 (NVL(l_enc_upg_option, 'N') = 'O')
121498 ) AND
121499 (l_bflow_method_code = 'PRIOR_ENTRY')
121500 )
121501 THEN
121502 IF
121503 --
121504 1 = 2
121505 --
121506 THEN
121507 xla_accounting_err_pkg.build_message
121508 (p_appli_s_name => 'XLA'
121509 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
121510 ,p_token_1 => 'LINE_NUMBER'
121511 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
121512 ,p_token_2 => 'LINE_TYPE_NAME'
121513 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
121514 l_component_type
121515 ,l_component_code
121516 ,l_component_type_code
121517 ,l_component_appl_id
121518 ,l_amb_context_code
121519 ,l_entity_code
121520 ,l_event_class_code
121521 )
121522 ,p_token_3 => 'OWNER'
121523 ,p_value_3 => xla_lookups_pkg.get_meaning(
121524 p_lookup_type => 'XLA_OWNER_TYPE'
121525 ,p_lookup_code => l_component_type_code
121526 )
121527 ,p_token_4 => 'PRODUCT_NAME'
121528 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
121529 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
121530 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
121531 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
121532 ,p_ae_header_id => NULL
121533 );
121534
121535 IF (C_LEVEL_ERROR>= g_log_level) THEN
121536 trace
121537 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
121538 ,p_level => C_LEVEL_ERROR
121539 ,p_module => l_log_module);
121540 END IF;
121541 END IF;
121542 END IF;
121543 --
121544 --
121545 ------------------------------------------------------------------------------------------------
121546 -- 4219869 Business Flow
121547 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
121548 -- Prior Entry. Currently, the following code is always generated.
121549 ------------------------------------------------------------------------------------------------
121550 XLA_AE_LINES_PKG.ValidateCurrentLine;
121551
121552 ------------------------------------------------------------------------------------
121553 -- 4219869 Business Flow
121554 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
121555 ------------------------------------------------------------------------------------
121556 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
121557
121558 ----------------------------------------------------------------------------------
121559 -- 4219869 Business Flow
121560 -- Update journal entry status -- Need to generate this within IF <condition>
121561 ----------------------------------------------------------------------------------
121562 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
121563 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
121564 ,p_balance_type_code => l_balance_type_code
121565 );
121566
121567 -------------------------------------------------------------------------------------------
121568 -- 4262811 - Generate the Accrual Reversal lines
121569 -------------------------------------------------------------------------------------------
121570 BEGIN
121571 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
121572 (g_array_event(p_event_id).array_value_num('header_index'));
121573 IF l_acc_rev_flag IS NULL THEN
121574 l_acc_rev_flag := 'N';
121575 END IF;
121576 EXCEPTION
121577 WHEN OTHERS THEN
121578 l_acc_rev_flag := 'N';
121579 END;
121580 --
121581 IF (l_acc_rev_flag = 'Y') THEN
121582
121583 -- 4645092 ------------------------------------------------------------------------------
121584 -- To allow MPA report to determine if it should generate report process
121585 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
121586 ------------------------------------------------------------------------------------------
121587
121588 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
121589 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
121590 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
121591 -- call ADRs
121592 -- Bug 4922099
121593 --
121594 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
121595 (NVL(l_actual_upg_option, 'N') = 'O') OR
121596 (NVL(l_enc_upg_option, 'N') = 'O')
121597 )
121598 THEN
121599 NULL;
121600 --
121601 --
121602
121603 l_ccid := AcctDerRule_28(
121604 p_application_id => p_application_id
121605 , p_ae_header_id => l_ae_header_id
121606 , p_source_15 => p_source_15
121607 , p_source_41 => p_source_41
121608 , p_source_42 => p_source_42
121609 , p_source_43 => p_source_43
121610 , p_source_44 => p_source_44
121611 , p_source_45 => p_source_45
121612 , x_transaction_coa_id => l_adr_transaction_coa_id
121613 , x_accounting_coa_id => l_adr_accounting_coa_id
121614 , x_value_type_code => l_adr_value_type_code
121615 , p_side => 'NA'
121616 );
121617
121618 xla_ae_lines_pkg.set_ccid(
121619 p_code_combination_id => l_ccid
121620 , p_value_type_code => l_adr_value_type_code
121621 , p_transaction_coa_id => l_adr_transaction_coa_id
121622 , p_accounting_coa_id => l_adr_accounting_coa_id
121623 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
121624 , p_adr_type_code => 'S'
121625 , p_component_type => l_component_type
121626 , p_component_code => l_component_code
121627 , p_component_type_code => l_component_type_code
121628 , p_component_appl_id => l_component_appl_id
121629 , p_amb_context_code => l_amb_context_code
121630 , p_side => 'NA'
121631 );
121632
121633
121634 --
121635 --
121636 END IF;
121637
121638 --
121639 -- Update the line information that should be overwritten
121640 --
121641 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
121642 p_header_num => 1);
121643 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
121644
121645 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
121646
121647 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
121648 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
121649 END IF;
121650
121651 --
121652 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
121653 --
121654 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
121655 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
121656 ELSE
121657 ---------------------------------------------------------------------------------------------------
121658 -- 4262811a Switch Sign
121659 ---------------------------------------------------------------------------------------------------
121660 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
121661 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
121662 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121663 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
121664 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121665 -- 5132302
121666 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
121667 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
121668
121669 END IF;
121670
121671 -- 4955764
121672 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
121673 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
121674
121675
121676 XLA_AE_LINES_PKG.ValidateCurrentLine;
121677 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
121678
121679 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
121680 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
121681 ,p_balance_type_code => l_balance_type_code);
121682
121683 END IF;
121684
121685 -----------------------------------------------------------------------------------------
121686 -- 4262811 Multiperiod Accounting
121687 -----------------------------------------------------------------------------------------
121688 -- No MPA option is assigned.
121689
121690
121691 END IF;
121692 END IF;
121693 --
121694
121695 --
121696 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
121697 trace
121698 (p_msg => 'END of AcctLineType_235'
121699 ,p_level => C_LEVEL_PROCEDURE
121700 ,p_module => l_log_module);
121701 END IF;
121702 --
121703 EXCEPTION
121704 WHEN xla_exceptions_pkg.application_exception THEN
121705 RAISE;
121706 WHEN OTHERS THEN
121707 xla_exceptions_pkg.raise_message
121708 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_235');
121709 END AcctLineType_235;
121710 --
121711
121712 ---------------------------------------
121713 --
121714 -- PRIVATE FUNCTION
121715 -- AcctLineType_236
121716 --
121717 ---------------------------------------
121718 PROCEDURE AcctLineType_236 (
121719 p_application_id IN NUMBER
121720 ,p_event_id IN NUMBER
121721 ,p_calculate_acctd_flag IN VARCHAR2
121722 ,p_calculate_g_l_flag IN VARCHAR2
121723 ,p_actual_flag IN OUT VARCHAR2
121724 ,p_balance_type_code OUT VARCHAR2
121725 ,p_gain_or_loss_ref OUT VARCHAR2
121726
121727 --Cost Element Name
121728 , p_source_15 IN NUMBER
121729 --Product Line Accounting Category Material Account
121730 , p_source_41 IN NUMBER
121731 --Product Line Accounting Category Material Overhead Account
121732 , p_source_42 IN NUMBER
121733 --Product Line Accounting Category Resource Account
121734 , p_source_43 IN NUMBER
121735 --Product Line Accounting Category Outside Processing Account
121736 , p_source_44 IN NUMBER
121737 --Product Line Accounting Category Overhead Account
121738 , p_source_45 IN NUMBER
121739 --DISTRIBUTION_IDENTIFIER
121740 , p_source_84 IN NUMBER
121741 --Distribution Type
121742 , p_source_85 IN VARCHAR2
121743 , p_source_85_meaning IN VARCHAR2
121744 --Entered Currency Code
121745 , p_source_88 IN VARCHAR2
121746 --Entered Amount
121747 , p_source_91 IN NUMBER
121748 --Currency Conversion Date
121749 , p_source_92 IN DATE
121750 --Currency Conversion Rate
121751 , p_source_93 IN NUMBER
121752 --Currency Conversion Type
121753 , p_source_94 IN VARCHAR2
121754 --Accounted Amount
121755 , p_source_95 IN NUMBER
121756 --Accounting Line Type
121757 , p_source_97 IN NUMBER
121758 --Organization Code
121759 , p_source_108 IN VARCHAR2
121760 )
121761 IS
121762
121763 l_component_type VARCHAR2(80);
121764 l_component_code VARCHAR2(30);
121765 l_component_type_code VARCHAR2(1);
121766 l_component_appl_id INTEGER;
121767 l_amb_context_code VARCHAR2(30);
121768 l_entity_code VARCHAR2(30);
121769 l_event_class_code VARCHAR2(30);
121770 l_ae_header_id NUMBER;
121771 l_event_type_code VARCHAR2(30);
121772 l_line_definition_code VARCHAR2(30);
121773 l_line_definition_owner_code VARCHAR2(1);
121774 --
121775 -- adr variables
121776 l_segment VARCHAR2(30);
121777 l_ccid NUMBER;
121778 l_adr_transaction_coa_id NUMBER;
121779 l_adr_accounting_coa_id NUMBER;
121780 l_adr_flexfield_segment_code VARCHAR2(30);
121781 l_adr_flex_value_set_id NUMBER;
121782 l_adr_value_type_code VARCHAR2(30);
121783 l_adr_value_combination_id NUMBER;
121784 l_adr_value_segment_code VARCHAR2(30);
121785
121786 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
121787 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
121788 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
121789 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
121790
121791 -- 4262811 Variables ------------------------------------------------------------------------------------------
121792 l_entered_amt_idx NUMBER;
121793 l_accted_amt_idx NUMBER;
121794 l_acc_rev_flag VARCHAR2(1);
121795 l_accrual_line_num NUMBER;
121796 l_tmp_amt NUMBER;
121797 l_acc_rev_natural_side_code VARCHAR2(1);
121798
121799 l_num_entries NUMBER;
121800 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
121801 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
121802 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
121803 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
121804 l_recog_line_1 NUMBER;
121805 l_recog_line_2 NUMBER;
121806
121807 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
121808 l_bflow_applied_to_amt NUMBER; -- 5132302
121809 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
121810
121811 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
121812
121813 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
121814 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
121815
121816 ---------------------------------------------------------------------------------------------------------------
121817
121818
121819 --
121820 -- bulk performance
121821 --
121822 l_balance_type_code VARCHAR2(1);
121823 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
121824 l_log_module VARCHAR2(240);
121825
121826 --
121827 -- Upgrade strategy
121828 --
121829 l_actual_upg_option VARCHAR2(1);
121830 l_enc_upg_option VARCHAR2(1);
121831
121832 --
121833 BEGIN
121834 --
121835 IF g_log_enabled THEN
121836 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_236';
121837 END IF;
121838 --
121839 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
121840
121841 trace
121842 (p_msg => 'BEGIN of AcctLineType_236'
121843 ,p_level => C_LEVEL_PROCEDURE
121844 ,p_module => l_log_module);
121845
121846 END IF;
121847 --
121848 l_component_type := 'AMB_JLT';
121849 l_component_code := 'INVENTORY_VALUATION';
121850 l_component_type_code := 'S';
121851 l_component_appl_id := 707;
121852 l_amb_context_code := 'DEFAULT';
121853 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
121854 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
121855 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
121856 l_line_definition_owner_code := 'S';
121857 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
121858 --
121859 l_balance_type_code := 'A';
121860 l_segment := NULL;
121861 l_ccid := NULL;
121862 l_adr_transaction_coa_id := NULL;
121863 l_adr_accounting_coa_id := NULL;
121864 l_adr_flexfield_segment_code := NULL;
121865 l_adr_flex_value_set_id := NULL;
121866 l_adr_value_type_code := NULL;
121867 l_adr_value_combination_id := NULL;
121868 l_adr_value_segment_code := NULL;
121869
121870 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
121871 l_bflow_class_code := ''; -- 4219869 Business Flow
121872 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
121873 l_budgetary_control_flag := 'N';
121874
121875 l_bflow_applied_to_amt_idx := NULL; -- 5132302
121876 l_bflow_applied_to_amt := NULL; -- 5132302
121877 l_entered_amt_idx := NULL; -- 4262811
121878 l_accted_amt_idx := NULL; -- 4262811
121879 l_acc_rev_flag := NULL; -- 4262811
121880 l_accrual_line_num := NULL; -- 4262811
121881 l_tmp_amt := NULL; -- 4262811
121882 --
121883
121884 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
121885 l_balance_type_code <> 'B' THEN
121886 IF NVL(p_source_97,9E125) = 1
121887 THEN
121888
121889 --
121890 XLA_AE_LINES_PKG.SetNewLine;
121891
121892 p_balance_type_code := l_balance_type_code;
121893 -- set the flag so later we will know whether the gain loss line needs to be created
121894
121895 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
121896 p_actual_flag :='A';
121897 END IF;
121898
121899 --
121900 -- bulk performance
121901 --
121902 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
121903 p_header_num => 0); -- 4262811
121904 --
121905 -- set accounting line options
121906 --
121907 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
121908 p_natural_side_code => 'D'
121909 , p_gain_or_loss_flag => 'N'
121910 , p_gl_transfer_mode_code => 'S'
121911 , p_acct_entry_type_code => 'A'
121912 , p_switch_side_flag => 'Y'
121913 , p_merge_duplicate_code => 'N'
121914 );
121915 --
121916 l_acc_rev_natural_side_code := 'C'; -- 4262811
121917 --
121918 --
121919 -- set accounting line type info
121920 --
121921 xla_ae_lines_pkg.SetAcctLineType
121922 (p_component_type => l_component_type
121923 ,p_event_type_code => l_event_type_code
121924 ,p_line_definition_owner_code => l_line_definition_owner_code
121925 ,p_line_definition_code => l_line_definition_code
121926 ,p_accounting_line_code => l_component_code
121927 ,p_accounting_line_type_code => l_component_type_code
121928 ,p_accounting_line_appl_id => l_component_appl_id
121929 ,p_amb_context_code => l_amb_context_code
121930 ,p_entity_code => l_entity_code
121931 ,p_event_class_code => l_event_class_code);
121932 --
121933 -- set accounting class
121934 --
121935 xla_ae_lines_pkg.SetAcctClass(
121936 p_accounting_class_code => 'INVENTORY_VALUATION'
121937 , p_ae_header_id => l_ae_header_id
121938 );
121939
121940 --
121941 -- set rounding class
121942 --
121943 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
121944 'INVENTORY_VALUATION';
121945
121946 --
121947 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
121948 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
121949 --
121950 -- bulk performance
121951 --
121952 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
121953
121954 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
121955 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
121956
121957 -- 4955764
121958 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
121959 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
121960
121961 -- 4458381 Public Sector Enh
121962
121963 --
121964 -- set accounting attributes for the line type
121965 --
121966 l_entered_amt_idx := 3;
121967 l_accted_amt_idx := 8;
121968 l_bflow_applied_to_amt_idx := NULL; -- 5132302
121969 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
121970 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
121971 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
121972 l_rec_acct_attrs.array_char_value(2) := p_source_85;
121973 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
121974 l_rec_acct_attrs.array_num_value(3) := p_source_91;
121975 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
121976 l_rec_acct_attrs.array_char_value(4) := p_source_88;
121977 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
121978 l_rec_acct_attrs.array_date_value(5) := p_source_92;
121979 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
121980 l_rec_acct_attrs.array_num_value(6) := p_source_93;
121981 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
121982 l_rec_acct_attrs.array_char_value(7) := p_source_94;
121983 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
121984 l_rec_acct_attrs.array_num_value(8) := p_source_95;
121985
121986 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
121987 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
121988
121989 ---------------------------------------------------------------------------------------------------------------
121990 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
121991 ---------------------------------------------------------------------------------------------------------------
121992 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
121993
121994 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
121995 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
121996
121997 IF xla_accounting_cache_pkg.GetValueChar
121998 (p_source_code => 'LEDGER_CATEGORY_CODE'
121999 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
122000 AND l_bflow_method_code = 'PRIOR_ENTRY'
122001 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
122002 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
122003 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
122004 )
122005 THEN
122006 xla_ae_lines_pkg.BflowUpgEntry
122007 (p_business_method_code => l_bflow_method_code
122008 ,p_business_class_code => l_bflow_class_code
122009 ,p_balance_type => l_balance_type_code);
122010 ELSE
122011 NULL;
122012 -- No business flow processing for business flow method of NONE.
122013 END IF;
122014
122015 --
122016 -- call analytical criteria
122017 --
122018
122019
122020 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
122021 xla_ae_lines_pkg.SetAnalyticalCriteria(
122022 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
122023 , p_analytical_criterion_owner => 'S'
122024 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
122025 , p_amb_context_code => 'DEFAULT'
122026 , p_balancing_flag => 'Y'
122027
122028 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
122029 , p_analytical_detail_num_1 => NULL
122030 , p_analytical_detail_date_1 => NULL
122031
122032 , p_ae_header_id => l_ae_header_id
122033 )
122034 ;
122035 --
122036
122037 --
122038 -- call description
122039 --
122040 -- No description or it is inherited.
122041 --
122042 -- call ADRs
122043 -- Bug 4922099
122044 --
122045 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
122046 (NVL(l_actual_upg_option, 'N') = 'O') OR
122047 (NVL(l_enc_upg_option, 'N') = 'O')
122048 )
122049 THEN
122050 NULL;
122051 --
122052 --
122053
122054 l_ccid := AcctDerRule_28(
122055 p_application_id => p_application_id
122056 , p_ae_header_id => l_ae_header_id
122057 , p_source_15 => p_source_15
122058 , p_source_41 => p_source_41
122059 , p_source_42 => p_source_42
122060 , p_source_43 => p_source_43
122061 , p_source_44 => p_source_44
122062 , p_source_45 => p_source_45
122063 , x_transaction_coa_id => l_adr_transaction_coa_id
122064 , x_accounting_coa_id => l_adr_accounting_coa_id
122065 , x_value_type_code => l_adr_value_type_code
122066 , p_side => 'NA'
122067 );
122068
122069 xla_ae_lines_pkg.set_ccid(
122070 p_code_combination_id => l_ccid
122071 , p_value_type_code => l_adr_value_type_code
122072 , p_transaction_coa_id => l_adr_transaction_coa_id
122073 , p_accounting_coa_id => l_adr_accounting_coa_id
122074 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
122075 , p_adr_type_code => 'S'
122076 , p_component_type => l_component_type
122077 , p_component_code => l_component_code
122078 , p_component_type_code => l_component_type_code
122079 , p_component_appl_id => l_component_appl_id
122080 , p_amb_context_code => l_amb_context_code
122081 , p_side => 'NA'
122082 );
122083
122084
122085 --
122086 --
122087 END IF;
122088 --
122089 -- Bug 4922099
122090 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
122091 (NVL(l_enc_upg_option, 'N') = 'O')
122092 ) AND
122093 (l_bflow_method_code = 'PRIOR_ENTRY')
122094 )
122095 THEN
122096 IF
122097 --
122098 1 = 2
122099 --
122100 THEN
122101 xla_accounting_err_pkg.build_message
122102 (p_appli_s_name => 'XLA'
122103 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
122104 ,p_token_1 => 'LINE_NUMBER'
122105 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
122106 ,p_token_2 => 'LINE_TYPE_NAME'
122107 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
122108 l_component_type
122109 ,l_component_code
122110 ,l_component_type_code
122111 ,l_component_appl_id
122112 ,l_amb_context_code
122113 ,l_entity_code
122114 ,l_event_class_code
122115 )
122116 ,p_token_3 => 'OWNER'
122117 ,p_value_3 => xla_lookups_pkg.get_meaning(
122118 p_lookup_type => 'XLA_OWNER_TYPE'
122119 ,p_lookup_code => l_component_type_code
122120 )
122121 ,p_token_4 => 'PRODUCT_NAME'
122122 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
122123 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
122124 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
122125 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
122126 ,p_ae_header_id => NULL
122127 );
122128
122129 IF (C_LEVEL_ERROR>= g_log_level) THEN
122130 trace
122131 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
122132 ,p_level => C_LEVEL_ERROR
122133 ,p_module => l_log_module);
122134 END IF;
122135 END IF;
122136 END IF;
122137 --
122138 --
122139 ------------------------------------------------------------------------------------------------
122140 -- 4219869 Business Flow
122141 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
122142 -- Prior Entry. Currently, the following code is always generated.
122143 ------------------------------------------------------------------------------------------------
122144 XLA_AE_LINES_PKG.ValidateCurrentLine;
122145
122146 ------------------------------------------------------------------------------------
122147 -- 4219869 Business Flow
122148 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
122149 ------------------------------------------------------------------------------------
122150 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
122151
122152 ----------------------------------------------------------------------------------
122153 -- 4219869 Business Flow
122154 -- Update journal entry status -- Need to generate this within IF <condition>
122155 ----------------------------------------------------------------------------------
122156 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
122157 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
122158 ,p_balance_type_code => l_balance_type_code
122159 );
122160
122161 -------------------------------------------------------------------------------------------
122162 -- 4262811 - Generate the Accrual Reversal lines
122163 -------------------------------------------------------------------------------------------
122164 BEGIN
122165 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
122166 (g_array_event(p_event_id).array_value_num('header_index'));
122167 IF l_acc_rev_flag IS NULL THEN
122168 l_acc_rev_flag := 'N';
122169 END IF;
122170 EXCEPTION
122171 WHEN OTHERS THEN
122172 l_acc_rev_flag := 'N';
122173 END;
122174 --
122175 IF (l_acc_rev_flag = 'Y') THEN
122176
122177 -- 4645092 ------------------------------------------------------------------------------
122178 -- To allow MPA report to determine if it should generate report process
122179 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
122180 ------------------------------------------------------------------------------------------
122181
122182 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
122183 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
122184 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
122185 -- call ADRs
122186 -- Bug 4922099
122187 --
122188 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
122189 (NVL(l_actual_upg_option, 'N') = 'O') OR
122190 (NVL(l_enc_upg_option, 'N') = 'O')
122191 )
122192 THEN
122193 NULL;
122194 --
122195 --
122196
122197 l_ccid := AcctDerRule_28(
122198 p_application_id => p_application_id
122199 , p_ae_header_id => l_ae_header_id
122200 , p_source_15 => p_source_15
122201 , p_source_41 => p_source_41
122202 , p_source_42 => p_source_42
122203 , p_source_43 => p_source_43
122204 , p_source_44 => p_source_44
122205 , p_source_45 => p_source_45
122206 , x_transaction_coa_id => l_adr_transaction_coa_id
122207 , x_accounting_coa_id => l_adr_accounting_coa_id
122208 , x_value_type_code => l_adr_value_type_code
122209 , p_side => 'NA'
122210 );
122211
122212 xla_ae_lines_pkg.set_ccid(
122213 p_code_combination_id => l_ccid
122214 , p_value_type_code => l_adr_value_type_code
122215 , p_transaction_coa_id => l_adr_transaction_coa_id
122216 , p_accounting_coa_id => l_adr_accounting_coa_id
122217 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
122218 , p_adr_type_code => 'S'
122219 , p_component_type => l_component_type
122220 , p_component_code => l_component_code
122221 , p_component_type_code => l_component_type_code
122222 , p_component_appl_id => l_component_appl_id
122223 , p_amb_context_code => l_amb_context_code
122224 , p_side => 'NA'
122225 );
122226
122227
122228 --
122229 --
122230 END IF;
122231
122232 --
122233 -- Update the line information that should be overwritten
122234 --
122235 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
122236 p_header_num => 1);
122237 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
122238
122239 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
122240
122241 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
122242 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
122243 END IF;
122244
122245 --
122246 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
122247 --
122248 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
122249 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
122250 ELSE
122251 ---------------------------------------------------------------------------------------------------
122252 -- 4262811a Switch Sign
122253 ---------------------------------------------------------------------------------------------------
122254 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
122255 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
122256 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122257 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
122258 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122259 -- 5132302
122260 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
122261 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122262
122263 END IF;
122264
122265 -- 4955764
122266 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
122267 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
122268
122269
122270 XLA_AE_LINES_PKG.ValidateCurrentLine;
122271 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
122272
122273 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
122274 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
122275 ,p_balance_type_code => l_balance_type_code);
122276
122277 END IF;
122278
122279 -----------------------------------------------------------------------------------------
122280 -- 4262811 Multiperiod Accounting
122281 -----------------------------------------------------------------------------------------
122282 -- No MPA option is assigned.
122283
122284
122285 END IF;
122286 END IF;
122287 --
122288
122289 --
122290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
122291 trace
122292 (p_msg => 'END of AcctLineType_236'
122293 ,p_level => C_LEVEL_PROCEDURE
122294 ,p_module => l_log_module);
122295 END IF;
122296 --
122297 EXCEPTION
122298 WHEN xla_exceptions_pkg.application_exception THEN
122299 RAISE;
122300 WHEN OTHERS THEN
122301 xla_exceptions_pkg.raise_message
122302 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_236');
122303 END AcctLineType_236;
122304 --
122305
122306 ---------------------------------------
122307 --
122308 -- PRIVATE FUNCTION
122309 -- AcctLineType_237
122310 --
122311 ---------------------------------------
122312 PROCEDURE AcctLineType_237 (
122313 p_application_id IN NUMBER
122314 ,p_event_id IN NUMBER
122315 ,p_calculate_acctd_flag IN VARCHAR2
122316 ,p_calculate_g_l_flag IN VARCHAR2
122317 ,p_actual_flag IN OUT VARCHAR2
122318 ,p_balance_type_code OUT VARCHAR2
122319 ,p_gain_or_loss_ref OUT VARCHAR2
122320
122321 --TRANSACTION_ID
122322 , p_source_1 IN NUMBER
122323 --Item Concatenated Segments
122324 , p_source_2 IN VARCHAR2
122325 --Transaction Quantity
122326 , p_source_3 IN NUMBER
122327 --Transaction Unit of Measure Code
122328 , p_source_4 IN VARCHAR2
122329 --Inventory Transaction Type Description
122330 , p_source_5 IN VARCHAR2
122331 --Cost Element Name
122332 , p_source_15 IN NUMBER
122333 --Product Line Accounting Category Material Account
122334 , p_source_41 IN NUMBER
122335 --Product Line Accounting Category Material Overhead Account
122336 , p_source_42 IN NUMBER
122337 --Product Line Accounting Category Resource Account
122338 , p_source_43 IN NUMBER
122339 --Product Line Accounting Category Outside Processing Account
122340 , p_source_44 IN NUMBER
122341 --Product Line Accounting Category Overhead Account
122342 , p_source_45 IN NUMBER
122343 --DISTRIBUTION_IDENTIFIER
122344 , p_source_84 IN NUMBER
122345 --Distribution Type
122346 , p_source_85 IN VARCHAR2
122347 , p_source_85_meaning IN VARCHAR2
122348 --Entered Currency Code
122349 , p_source_88 IN VARCHAR2
122350 --Entered Amount
122351 , p_source_91 IN NUMBER
122352 --Currency Conversion Date
122353 , p_source_92 IN DATE
122354 --Currency Conversion Rate
122355 , p_source_93 IN NUMBER
122356 --Currency Conversion Type
122357 , p_source_94 IN VARCHAR2
122358 --Accounted Amount
122359 , p_source_95 IN NUMBER
122360 --Accounting Line Type
122361 , p_source_97 IN NUMBER
122362 --Organization Code
122363 , p_source_108 IN VARCHAR2
122364 )
122365 IS
122366
122367 l_component_type VARCHAR2(80);
122368 l_component_code VARCHAR2(30);
122369 l_component_type_code VARCHAR2(1);
122370 l_component_appl_id INTEGER;
122371 l_amb_context_code VARCHAR2(30);
122372 l_entity_code VARCHAR2(30);
122373 l_event_class_code VARCHAR2(30);
122374 l_ae_header_id NUMBER;
122375 l_event_type_code VARCHAR2(30);
122376 l_line_definition_code VARCHAR2(30);
122377 l_line_definition_owner_code VARCHAR2(1);
122378 --
122379 -- adr variables
122380 l_segment VARCHAR2(30);
122381 l_ccid NUMBER;
122382 l_adr_transaction_coa_id NUMBER;
122383 l_adr_accounting_coa_id NUMBER;
122384 l_adr_flexfield_segment_code VARCHAR2(30);
122385 l_adr_flex_value_set_id NUMBER;
122386 l_adr_value_type_code VARCHAR2(30);
122387 l_adr_value_combination_id NUMBER;
122388 l_adr_value_segment_code VARCHAR2(30);
122389
122390 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
122391 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
122392 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
122393 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
122394
122395 -- 4262811 Variables ------------------------------------------------------------------------------------------
122396 l_entered_amt_idx NUMBER;
122397 l_accted_amt_idx NUMBER;
122398 l_acc_rev_flag VARCHAR2(1);
122399 l_accrual_line_num NUMBER;
122400 l_tmp_amt NUMBER;
122401 l_acc_rev_natural_side_code VARCHAR2(1);
122402
122403 l_num_entries NUMBER;
122404 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
122405 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
122406 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
122407 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
122408 l_recog_line_1 NUMBER;
122409 l_recog_line_2 NUMBER;
122410
122411 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
122412 l_bflow_applied_to_amt NUMBER; -- 5132302
122413 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
122414
122415 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
122416
122417 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
122418 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
122419
122420 ---------------------------------------------------------------------------------------------------------------
122421
122422
122423 --
122424 -- bulk performance
122425 --
122426 l_balance_type_code VARCHAR2(1);
122427 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
122428 l_log_module VARCHAR2(240);
122429
122430 --
122431 -- Upgrade strategy
122432 --
122433 l_actual_upg_option VARCHAR2(1);
122434 l_enc_upg_option VARCHAR2(1);
122435
122436 --
122437 BEGIN
122438 --
122439 IF g_log_enabled THEN
122440 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_237';
122441 END IF;
122442 --
122443 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
122444
122445 trace
122446 (p_msg => 'BEGIN of AcctLineType_237'
122447 ,p_level => C_LEVEL_PROCEDURE
122448 ,p_module => l_log_module);
122449
122450 END IF;
122451 --
122452 l_component_type := 'AMB_JLT';
122453 l_component_code := 'INVENTORY_VALUATION';
122454 l_component_type_code := 'S';
122455 l_component_appl_id := 707;
122456 l_amb_context_code := 'DEFAULT';
122457 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
122458 l_event_class_code := 'INT_ORDER_TO_EXP';
122459 l_event_type_code := 'INT_ORDER_ISSUE_NO_TP';
122460 l_line_definition_owner_code := 'S';
122461 l_line_definition_code := 'PI_INT_ORDER_ISSUE_NO_TP';
122462 --
122463 l_balance_type_code := 'A';
122464 l_segment := NULL;
122465 l_ccid := NULL;
122466 l_adr_transaction_coa_id := NULL;
122467 l_adr_accounting_coa_id := NULL;
122468 l_adr_flexfield_segment_code := NULL;
122469 l_adr_flex_value_set_id := NULL;
122470 l_adr_value_type_code := NULL;
122471 l_adr_value_combination_id := NULL;
122472 l_adr_value_segment_code := NULL;
122473
122474 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
122475 l_bflow_class_code := ''; -- 4219869 Business Flow
122476 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
122477 l_budgetary_control_flag := 'N';
122478
122479 l_bflow_applied_to_amt_idx := NULL; -- 5132302
122480 l_bflow_applied_to_amt := NULL; -- 5132302
122481 l_entered_amt_idx := NULL; -- 4262811
122482 l_accted_amt_idx := NULL; -- 4262811
122483 l_acc_rev_flag := NULL; -- 4262811
122484 l_accrual_line_num := NULL; -- 4262811
122485 l_tmp_amt := NULL; -- 4262811
122486 --
122487
122488 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
122489 l_balance_type_code <> 'B' THEN
122490 IF NVL(p_source_97,9E125) = 1
122491 THEN
122492
122493 --
122494 XLA_AE_LINES_PKG.SetNewLine;
122495
122496 p_balance_type_code := l_balance_type_code;
122497 -- set the flag so later we will know whether the gain loss line needs to be created
122498
122499 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
122500 p_actual_flag :='A';
122501 END IF;
122502
122503 --
122504 -- bulk performance
122505 --
122506 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
122507 p_header_num => 0); -- 4262811
122508 --
122509 -- set accounting line options
122510 --
122511 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
122512 p_natural_side_code => 'D'
122513 , p_gain_or_loss_flag => 'N'
122514 , p_gl_transfer_mode_code => 'S'
122515 , p_acct_entry_type_code => 'A'
122516 , p_switch_side_flag => 'Y'
122517 , p_merge_duplicate_code => 'N'
122518 );
122519 --
122520 l_acc_rev_natural_side_code := 'C'; -- 4262811
122521 --
122522 --
122523 -- set accounting line type info
122524 --
122525 xla_ae_lines_pkg.SetAcctLineType
122526 (p_component_type => l_component_type
122527 ,p_event_type_code => l_event_type_code
122528 ,p_line_definition_owner_code => l_line_definition_owner_code
122529 ,p_line_definition_code => l_line_definition_code
122530 ,p_accounting_line_code => l_component_code
122531 ,p_accounting_line_type_code => l_component_type_code
122532 ,p_accounting_line_appl_id => l_component_appl_id
122533 ,p_amb_context_code => l_amb_context_code
122534 ,p_entity_code => l_entity_code
122535 ,p_event_class_code => l_event_class_code);
122536 --
122537 -- set accounting class
122538 --
122539 xla_ae_lines_pkg.SetAcctClass(
122540 p_accounting_class_code => 'INVENTORY_VALUATION'
122541 , p_ae_header_id => l_ae_header_id
122542 );
122543
122544 --
122545 -- set rounding class
122546 --
122547 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
122548 'INVENTORY_VALUATION';
122549
122550 --
122551 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
122552 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
122553 --
122554 -- bulk performance
122555 --
122556 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
122557
122558 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
122559 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
122560
122561 -- 4955764
122562 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
122563 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
122564
122565 -- 4458381 Public Sector Enh
122566
122567 --
122568 -- set accounting attributes for the line type
122569 --
122570 l_entered_amt_idx := 3;
122571 l_accted_amt_idx := 8;
122572 l_bflow_applied_to_amt_idx := NULL; -- 5132302
122573 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
122574 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
122575 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
122576 l_rec_acct_attrs.array_char_value(2) := p_source_85;
122577 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
122578 l_rec_acct_attrs.array_num_value(3) := p_source_91;
122579 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
122580 l_rec_acct_attrs.array_char_value(4) := p_source_88;
122581 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
122582 l_rec_acct_attrs.array_date_value(5) := p_source_92;
122583 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
122584 l_rec_acct_attrs.array_num_value(6) := p_source_93;
122585 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
122586 l_rec_acct_attrs.array_char_value(7) := p_source_94;
122587 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
122588 l_rec_acct_attrs.array_num_value(8) := p_source_95;
122589
122590 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
122591 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
122592
122593 ---------------------------------------------------------------------------------------------------------------
122594 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
122595 ---------------------------------------------------------------------------------------------------------------
122596 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
122597
122598 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
122599 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
122600
122601 IF xla_accounting_cache_pkg.GetValueChar
122602 (p_source_code => 'LEDGER_CATEGORY_CODE'
122603 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
122604 AND l_bflow_method_code = 'PRIOR_ENTRY'
122605 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
122606 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
122607 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
122608 )
122609 THEN
122610 xla_ae_lines_pkg.BflowUpgEntry
122611 (p_business_method_code => l_bflow_method_code
122612 ,p_business_class_code => l_bflow_class_code
122613 ,p_balance_type => l_balance_type_code);
122614 ELSE
122615 NULL;
122616 -- No business flow processing for business flow method of NONE.
122617 END IF;
122618
122619 --
122620 -- call analytical criteria
122621 --
122622
122623
122624 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
122625 xla_ae_lines_pkg.SetAnalyticalCriteria(
122626 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
122627 , p_analytical_criterion_owner => 'S'
122628 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
122629 , p_amb_context_code => 'DEFAULT'
122630 , p_balancing_flag => 'Y'
122631
122632 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
122633 , p_analytical_detail_num_1 => NULL
122634 , p_analytical_detail_date_1 => NULL
122635
122636 , p_ae_header_id => l_ae_header_id
122637 )
122638 ;
122639 --
122640
122641 --
122642 -- call description
122643 --
122644
122645 xla_ae_lines_pkg.SetLineDescription(
122646 p_ae_header_id => l_ae_header_id
122647 ,p_description => Description_1 (
122648 p_application_id => p_application_id
122649 , p_ae_header_id => l_ae_header_id
122650 , p_source_1 => p_source_1
122651 , p_source_2 => p_source_2
122652 , p_source_3 => p_source_3
122653 , p_source_4 => p_source_4
122654 , p_source_5 => p_source_5
122655 )
122656 );
122657
122658
122659 --
122660 -- call ADRs
122661 -- Bug 4922099
122662 --
122663 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
122664 (NVL(l_actual_upg_option, 'N') = 'O') OR
122665 (NVL(l_enc_upg_option, 'N') = 'O')
122666 )
122667 THEN
122668 NULL;
122669 --
122670 --
122671
122672 l_ccid := AcctDerRule_28(
122673 p_application_id => p_application_id
122674 , p_ae_header_id => l_ae_header_id
122675 , p_source_15 => p_source_15
122676 , p_source_41 => p_source_41
122677 , p_source_42 => p_source_42
122678 , p_source_43 => p_source_43
122679 , p_source_44 => p_source_44
122680 , p_source_45 => p_source_45
122681 , x_transaction_coa_id => l_adr_transaction_coa_id
122682 , x_accounting_coa_id => l_adr_accounting_coa_id
122683 , x_value_type_code => l_adr_value_type_code
122684 , p_side => 'NA'
122685 );
122686
122687 xla_ae_lines_pkg.set_ccid(
122688 p_code_combination_id => l_ccid
122689 , p_value_type_code => l_adr_value_type_code
122690 , p_transaction_coa_id => l_adr_transaction_coa_id
122691 , p_accounting_coa_id => l_adr_accounting_coa_id
122692 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
122693 , p_adr_type_code => 'S'
122694 , p_component_type => l_component_type
122695 , p_component_code => l_component_code
122696 , p_component_type_code => l_component_type_code
122697 , p_component_appl_id => l_component_appl_id
122698 , p_amb_context_code => l_amb_context_code
122699 , p_side => 'NA'
122700 );
122701
122702
122703 --
122704 --
122705 END IF;
122706 --
122707 -- Bug 4922099
122708 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
122709 (NVL(l_enc_upg_option, 'N') = 'O')
122710 ) AND
122711 (l_bflow_method_code = 'PRIOR_ENTRY')
122712 )
122713 THEN
122714 IF
122715 --
122716 1 = 2
122717 --
122718 THEN
122719 xla_accounting_err_pkg.build_message
122720 (p_appli_s_name => 'XLA'
122721 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
122722 ,p_token_1 => 'LINE_NUMBER'
122723 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
122724 ,p_token_2 => 'LINE_TYPE_NAME'
122725 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
122726 l_component_type
122727 ,l_component_code
122728 ,l_component_type_code
122729 ,l_component_appl_id
122730 ,l_amb_context_code
122731 ,l_entity_code
122732 ,l_event_class_code
122733 )
122734 ,p_token_3 => 'OWNER'
122735 ,p_value_3 => xla_lookups_pkg.get_meaning(
122736 p_lookup_type => 'XLA_OWNER_TYPE'
122737 ,p_lookup_code => l_component_type_code
122738 )
122739 ,p_token_4 => 'PRODUCT_NAME'
122740 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
122741 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
122742 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
122743 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
122744 ,p_ae_header_id => NULL
122745 );
122746
122747 IF (C_LEVEL_ERROR>= g_log_level) THEN
122748 trace
122749 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
122750 ,p_level => C_LEVEL_ERROR
122751 ,p_module => l_log_module);
122752 END IF;
122753 END IF;
122754 END IF;
122755 --
122756 --
122757 ------------------------------------------------------------------------------------------------
122758 -- 4219869 Business Flow
122759 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
122760 -- Prior Entry. Currently, the following code is always generated.
122761 ------------------------------------------------------------------------------------------------
122762 XLA_AE_LINES_PKG.ValidateCurrentLine;
122763
122764 ------------------------------------------------------------------------------------
122765 -- 4219869 Business Flow
122766 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
122767 ------------------------------------------------------------------------------------
122768 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
122769
122770 ----------------------------------------------------------------------------------
122771 -- 4219869 Business Flow
122772 -- Update journal entry status -- Need to generate this within IF <condition>
122773 ----------------------------------------------------------------------------------
122774 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
122775 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
122776 ,p_balance_type_code => l_balance_type_code
122777 );
122778
122779 -------------------------------------------------------------------------------------------
122780 -- 4262811 - Generate the Accrual Reversal lines
122781 -------------------------------------------------------------------------------------------
122782 BEGIN
122783 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
122784 (g_array_event(p_event_id).array_value_num('header_index'));
122785 IF l_acc_rev_flag IS NULL THEN
122786 l_acc_rev_flag := 'N';
122787 END IF;
122788 EXCEPTION
122789 WHEN OTHERS THEN
122790 l_acc_rev_flag := 'N';
122791 END;
122792 --
122793 IF (l_acc_rev_flag = 'Y') THEN
122794
122795 -- 4645092 ------------------------------------------------------------------------------
122796 -- To allow MPA report to determine if it should generate report process
122797 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
122798 ------------------------------------------------------------------------------------------
122799
122800 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
122801 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
122802 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
122803 -- call ADRs
122804 -- Bug 4922099
122805 --
122806 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
122807 (NVL(l_actual_upg_option, 'N') = 'O') OR
122808 (NVL(l_enc_upg_option, 'N') = 'O')
122809 )
122810 THEN
122811 NULL;
122812 --
122813 --
122814
122815 l_ccid := AcctDerRule_28(
122816 p_application_id => p_application_id
122817 , p_ae_header_id => l_ae_header_id
122818 , p_source_15 => p_source_15
122819 , p_source_41 => p_source_41
122820 , p_source_42 => p_source_42
122821 , p_source_43 => p_source_43
122822 , p_source_44 => p_source_44
122823 , p_source_45 => p_source_45
122824 , x_transaction_coa_id => l_adr_transaction_coa_id
122825 , x_accounting_coa_id => l_adr_accounting_coa_id
122826 , x_value_type_code => l_adr_value_type_code
122827 , p_side => 'NA'
122828 );
122829
122830 xla_ae_lines_pkg.set_ccid(
122831 p_code_combination_id => l_ccid
122832 , p_value_type_code => l_adr_value_type_code
122833 , p_transaction_coa_id => l_adr_transaction_coa_id
122834 , p_accounting_coa_id => l_adr_accounting_coa_id
122835 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
122836 , p_adr_type_code => 'S'
122837 , p_component_type => l_component_type
122838 , p_component_code => l_component_code
122839 , p_component_type_code => l_component_type_code
122840 , p_component_appl_id => l_component_appl_id
122841 , p_amb_context_code => l_amb_context_code
122842 , p_side => 'NA'
122843 );
122844
122845
122846 --
122847 --
122848 END IF;
122849
122850 --
122851 -- Update the line information that should be overwritten
122852 --
122853 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
122854 p_header_num => 1);
122855 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
122856
122857 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
122858
122859 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
122860 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
122861 END IF;
122862
122863 --
122864 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
122865 --
122866 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
122867 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
122868 ELSE
122869 ---------------------------------------------------------------------------------------------------
122870 -- 4262811a Switch Sign
122871 ---------------------------------------------------------------------------------------------------
122872 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
122873 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
122874 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122875 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
122876 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122877 -- 5132302
122878 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
122879 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
122880
122881 END IF;
122882
122883 -- 4955764
122884 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
122885 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
122886
122887
122888 XLA_AE_LINES_PKG.ValidateCurrentLine;
122889 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
122890
122891 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
122892 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
122893 ,p_balance_type_code => l_balance_type_code);
122894
122895 END IF;
122896
122897 -----------------------------------------------------------------------------------------
122898 -- 4262811 Multiperiod Accounting
122899 -----------------------------------------------------------------------------------------
122900 -- No MPA option is assigned.
122901
122902
122903 END IF;
122904 END IF;
122905 --
122906
122907 --
122908 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
122909 trace
122910 (p_msg => 'END of AcctLineType_237'
122911 ,p_level => C_LEVEL_PROCEDURE
122912 ,p_module => l_log_module);
122913 END IF;
122914 --
122915 EXCEPTION
122916 WHEN xla_exceptions_pkg.application_exception THEN
122917 RAISE;
122918 WHEN OTHERS THEN
122919 xla_exceptions_pkg.raise_message
122920 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_237');
122921 END AcctLineType_237;
122922 --
122923
122924 ---------------------------------------
122925 --
122926 -- PRIVATE FUNCTION
122927 -- AcctLineType_238
122928 --
122929 ---------------------------------------
122930 PROCEDURE AcctLineType_238 (
122931 p_application_id IN NUMBER
122932 ,p_event_id IN NUMBER
122933 ,p_calculate_acctd_flag IN VARCHAR2
122934 ,p_calculate_g_l_flag IN VARCHAR2
122935 ,p_actual_flag IN OUT VARCHAR2
122936 ,p_balance_type_code OUT VARCHAR2
122937 ,p_gain_or_loss_ref OUT VARCHAR2
122938
122939 --TRANSACTION_ID
122940 , p_source_1 IN NUMBER
122941 --Item Concatenated Segments
122942 , p_source_2 IN VARCHAR2
122943 --Transaction Quantity
122944 , p_source_3 IN NUMBER
122945 --Transaction Unit of Measure Code
122946 , p_source_4 IN VARCHAR2
122947 --Inventory Transaction Type Description
122948 , p_source_5 IN VARCHAR2
122949 --Cost Element Name
122950 , p_source_15 IN NUMBER
122951 --Product Line Accounting Category Material Account
122952 , p_source_41 IN NUMBER
122953 --Product Line Accounting Category Material Overhead Account
122954 , p_source_42 IN NUMBER
122955 --Product Line Accounting Category Resource Account
122956 , p_source_43 IN NUMBER
122957 --Product Line Accounting Category Outside Processing Account
122958 , p_source_44 IN NUMBER
122959 --Product Line Accounting Category Overhead Account
122960 , p_source_45 IN NUMBER
122961 --DISTRIBUTION_IDENTIFIER
122962 , p_source_84 IN NUMBER
122963 --Distribution Type
122964 , p_source_85 IN VARCHAR2
122965 , p_source_85_meaning IN VARCHAR2
122966 --Entered Currency Code
122967 , p_source_88 IN VARCHAR2
122968 --Entered Amount
122969 , p_source_91 IN NUMBER
122970 --Currency Conversion Date
122971 , p_source_92 IN DATE
122972 --Currency Conversion Rate
122973 , p_source_93 IN NUMBER
122974 --Currency Conversion Type
122975 , p_source_94 IN VARCHAR2
122976 --Accounted Amount
122977 , p_source_95 IN NUMBER
122978 --Accounting Line Type
122979 , p_source_97 IN NUMBER
122980 --Organization Code
122981 , p_source_108 IN VARCHAR2
122982 )
122983 IS
122984
122985 l_component_type VARCHAR2(80);
122986 l_component_code VARCHAR2(30);
122987 l_component_type_code VARCHAR2(1);
122988 l_component_appl_id INTEGER;
122989 l_amb_context_code VARCHAR2(30);
122990 l_entity_code VARCHAR2(30);
122991 l_event_class_code VARCHAR2(30);
122992 l_ae_header_id NUMBER;
122993 l_event_type_code VARCHAR2(30);
122994 l_line_definition_code VARCHAR2(30);
122995 l_line_definition_owner_code VARCHAR2(1);
122996 --
122997 -- adr variables
122998 l_segment VARCHAR2(30);
122999 l_ccid NUMBER;
123000 l_adr_transaction_coa_id NUMBER;
123001 l_adr_accounting_coa_id NUMBER;
123002 l_adr_flexfield_segment_code VARCHAR2(30);
123003 l_adr_flex_value_set_id NUMBER;
123004 l_adr_value_type_code VARCHAR2(30);
123005 l_adr_value_combination_id NUMBER;
123006 l_adr_value_segment_code VARCHAR2(30);
123007
123008 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
123009 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
123010 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
123011 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
123012
123013 -- 4262811 Variables ------------------------------------------------------------------------------------------
123014 l_entered_amt_idx NUMBER;
123015 l_accted_amt_idx NUMBER;
123016 l_acc_rev_flag VARCHAR2(1);
123017 l_accrual_line_num NUMBER;
123018 l_tmp_amt NUMBER;
123019 l_acc_rev_natural_side_code VARCHAR2(1);
123020
123021 l_num_entries NUMBER;
123022 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
123023 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
123024 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
123025 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
123026 l_recog_line_1 NUMBER;
123027 l_recog_line_2 NUMBER;
123028
123029 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
123030 l_bflow_applied_to_amt NUMBER; -- 5132302
123031 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
123032
123033 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
123034
123035 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
123036 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
123037
123038 ---------------------------------------------------------------------------------------------------------------
123039
123040
123041 --
123042 -- bulk performance
123043 --
123044 l_balance_type_code VARCHAR2(1);
123045 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
123046 l_log_module VARCHAR2(240);
123047
123048 --
123049 -- Upgrade strategy
123050 --
123051 l_actual_upg_option VARCHAR2(1);
123052 l_enc_upg_option VARCHAR2(1);
123053
123054 --
123055 BEGIN
123056 --
123057 IF g_log_enabled THEN
123058 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_238';
123059 END IF;
123060 --
123061 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
123062
123063 trace
123064 (p_msg => 'BEGIN of AcctLineType_238'
123065 ,p_level => C_LEVEL_PROCEDURE
123066 ,p_module => l_log_module);
123067
123068 END IF;
123069 --
123070 l_component_type := 'AMB_JLT';
123071 l_component_code := 'INVENTORY_VALUATION';
123072 l_component_type_code := 'S';
123073 l_component_appl_id := 707;
123074 l_amb_context_code := 'DEFAULT';
123075 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
123076 l_event_class_code := 'MTL_COST_UPD';
123077 l_event_type_code := 'LAYER_COST_UPD';
123078 l_line_definition_owner_code := 'S';
123079 l_line_definition_code := 'PI_LAYER_COST_UPDATE';
123080 --
123081 l_balance_type_code := 'A';
123082 l_segment := NULL;
123083 l_ccid := NULL;
123084 l_adr_transaction_coa_id := NULL;
123085 l_adr_accounting_coa_id := NULL;
123086 l_adr_flexfield_segment_code := NULL;
123087 l_adr_flex_value_set_id := NULL;
123088 l_adr_value_type_code := NULL;
123089 l_adr_value_combination_id := NULL;
123090 l_adr_value_segment_code := NULL;
123091
123092 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
123093 l_bflow_class_code := ''; -- 4219869 Business Flow
123094 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
123095 l_budgetary_control_flag := 'N';
123096
123097 l_bflow_applied_to_amt_idx := NULL; -- 5132302
123098 l_bflow_applied_to_amt := NULL; -- 5132302
123099 l_entered_amt_idx := NULL; -- 4262811
123100 l_accted_amt_idx := NULL; -- 4262811
123101 l_acc_rev_flag := NULL; -- 4262811
123102 l_accrual_line_num := NULL; -- 4262811
123103 l_tmp_amt := NULL; -- 4262811
123104 --
123105
123106 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
123107 l_balance_type_code <> 'B' THEN
123108 IF NVL(p_source_97,9E125) = 1
123109 THEN
123110
123111 --
123112 XLA_AE_LINES_PKG.SetNewLine;
123113
123114 p_balance_type_code := l_balance_type_code;
123115 -- set the flag so later we will know whether the gain loss line needs to be created
123116
123117 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
123118 p_actual_flag :='A';
123119 END IF;
123120
123121 --
123122 -- bulk performance
123123 --
123124 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
123125 p_header_num => 0); -- 4262811
123126 --
123127 -- set accounting line options
123128 --
123129 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
123130 p_natural_side_code => 'D'
123131 , p_gain_or_loss_flag => 'N'
123132 , p_gl_transfer_mode_code => 'S'
123133 , p_acct_entry_type_code => 'A'
123134 , p_switch_side_flag => 'Y'
123135 , p_merge_duplicate_code => 'N'
123136 );
123137 --
123138 l_acc_rev_natural_side_code := 'C'; -- 4262811
123139 --
123140 --
123141 -- set accounting line type info
123142 --
123143 xla_ae_lines_pkg.SetAcctLineType
123144 (p_component_type => l_component_type
123145 ,p_event_type_code => l_event_type_code
123146 ,p_line_definition_owner_code => l_line_definition_owner_code
123147 ,p_line_definition_code => l_line_definition_code
123148 ,p_accounting_line_code => l_component_code
123149 ,p_accounting_line_type_code => l_component_type_code
123150 ,p_accounting_line_appl_id => l_component_appl_id
123151 ,p_amb_context_code => l_amb_context_code
123152 ,p_entity_code => l_entity_code
123153 ,p_event_class_code => l_event_class_code);
123154 --
123155 -- set accounting class
123156 --
123157 xla_ae_lines_pkg.SetAcctClass(
123158 p_accounting_class_code => 'INVENTORY_VALUATION'
123159 , p_ae_header_id => l_ae_header_id
123160 );
123161
123162 --
123163 -- set rounding class
123164 --
123165 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
123166 'INVENTORY_VALUATION';
123167
123168 --
123169 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
123170 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
123171 --
123172 -- bulk performance
123173 --
123174 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
123175
123176 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
123177 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
123178
123179 -- 4955764
123180 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
123181 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
123182
123183 -- 4458381 Public Sector Enh
123184
123185 --
123186 -- set accounting attributes for the line type
123187 --
123188 l_entered_amt_idx := 3;
123189 l_accted_amt_idx := 8;
123190 l_bflow_applied_to_amt_idx := NULL; -- 5132302
123191 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
123192 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
123193 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
123194 l_rec_acct_attrs.array_char_value(2) := p_source_85;
123195 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
123196 l_rec_acct_attrs.array_num_value(3) := p_source_91;
123197 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
123198 l_rec_acct_attrs.array_char_value(4) := p_source_88;
123199 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
123200 l_rec_acct_attrs.array_date_value(5) := p_source_92;
123201 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
123202 l_rec_acct_attrs.array_num_value(6) := p_source_93;
123203 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
123204 l_rec_acct_attrs.array_char_value(7) := p_source_94;
123205 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
123206 l_rec_acct_attrs.array_num_value(8) := p_source_95;
123207
123208 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
123209 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
123210
123211 ---------------------------------------------------------------------------------------------------------------
123212 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
123213 ---------------------------------------------------------------------------------------------------------------
123214 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
123215
123216 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
123217 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
123218
123219 IF xla_accounting_cache_pkg.GetValueChar
123220 (p_source_code => 'LEDGER_CATEGORY_CODE'
123221 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
123222 AND l_bflow_method_code = 'PRIOR_ENTRY'
123223 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
123224 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
123225 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
123226 )
123227 THEN
123228 xla_ae_lines_pkg.BflowUpgEntry
123229 (p_business_method_code => l_bflow_method_code
123230 ,p_business_class_code => l_bflow_class_code
123231 ,p_balance_type => l_balance_type_code);
123232 ELSE
123233 NULL;
123234 -- No business flow processing for business flow method of NONE.
123235 END IF;
123236
123237 --
123238 -- call analytical criteria
123239 --
123240
123241
123242 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
123243 xla_ae_lines_pkg.SetAnalyticalCriteria(
123244 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
123245 , p_analytical_criterion_owner => 'S'
123246 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
123247 , p_amb_context_code => 'DEFAULT'
123248 , p_balancing_flag => 'Y'
123249
123250 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
123251 , p_analytical_detail_num_1 => NULL
123252 , p_analytical_detail_date_1 => NULL
123253
123254 , p_ae_header_id => l_ae_header_id
123255 )
123256 ;
123257 --
123258
123259 --
123260 -- call description
123261 --
123262
123263 xla_ae_lines_pkg.SetLineDescription(
123264 p_ae_header_id => l_ae_header_id
123265 ,p_description => Description_1 (
123266 p_application_id => p_application_id
123267 , p_ae_header_id => l_ae_header_id
123268 , p_source_1 => p_source_1
123269 , p_source_2 => p_source_2
123270 , p_source_3 => p_source_3
123271 , p_source_4 => p_source_4
123272 , p_source_5 => p_source_5
123273 )
123274 );
123275
123276
123277 --
123278 -- call ADRs
123279 -- Bug 4922099
123280 --
123281 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
123282 (NVL(l_actual_upg_option, 'N') = 'O') OR
123283 (NVL(l_enc_upg_option, 'N') = 'O')
123284 )
123285 THEN
123286 NULL;
123287 --
123288 --
123289
123290 l_ccid := AcctDerRule_28(
123291 p_application_id => p_application_id
123292 , p_ae_header_id => l_ae_header_id
123293 , p_source_15 => p_source_15
123294 , p_source_41 => p_source_41
123295 , p_source_42 => p_source_42
123296 , p_source_43 => p_source_43
123297 , p_source_44 => p_source_44
123298 , p_source_45 => p_source_45
123299 , x_transaction_coa_id => l_adr_transaction_coa_id
123300 , x_accounting_coa_id => l_adr_accounting_coa_id
123301 , x_value_type_code => l_adr_value_type_code
123302 , p_side => 'NA'
123303 );
123304
123305 xla_ae_lines_pkg.set_ccid(
123306 p_code_combination_id => l_ccid
123307 , p_value_type_code => l_adr_value_type_code
123308 , p_transaction_coa_id => l_adr_transaction_coa_id
123309 , p_accounting_coa_id => l_adr_accounting_coa_id
123310 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
123311 , p_adr_type_code => 'S'
123312 , p_component_type => l_component_type
123313 , p_component_code => l_component_code
123314 , p_component_type_code => l_component_type_code
123315 , p_component_appl_id => l_component_appl_id
123316 , p_amb_context_code => l_amb_context_code
123317 , p_side => 'NA'
123318 );
123319
123320
123321 --
123322 --
123323 END IF;
123324 --
123325 -- Bug 4922099
123326 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
123327 (NVL(l_enc_upg_option, 'N') = 'O')
123328 ) AND
123329 (l_bflow_method_code = 'PRIOR_ENTRY')
123330 )
123331 THEN
123332 IF
123333 --
123334 1 = 2
123335 --
123336 THEN
123337 xla_accounting_err_pkg.build_message
123338 (p_appli_s_name => 'XLA'
123339 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
123340 ,p_token_1 => 'LINE_NUMBER'
123341 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
123342 ,p_token_2 => 'LINE_TYPE_NAME'
123343 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
123344 l_component_type
123345 ,l_component_code
123346 ,l_component_type_code
123347 ,l_component_appl_id
123348 ,l_amb_context_code
123349 ,l_entity_code
123350 ,l_event_class_code
123351 )
123352 ,p_token_3 => 'OWNER'
123353 ,p_value_3 => xla_lookups_pkg.get_meaning(
123354 p_lookup_type => 'XLA_OWNER_TYPE'
123355 ,p_lookup_code => l_component_type_code
123356 )
123357 ,p_token_4 => 'PRODUCT_NAME'
123358 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
123359 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
123360 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
123361 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
123362 ,p_ae_header_id => NULL
123363 );
123364
123365 IF (C_LEVEL_ERROR>= g_log_level) THEN
123366 trace
123367 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
123368 ,p_level => C_LEVEL_ERROR
123369 ,p_module => l_log_module);
123370 END IF;
123371 END IF;
123372 END IF;
123373 --
123374 --
123375 ------------------------------------------------------------------------------------------------
123376 -- 4219869 Business Flow
123377 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
123378 -- Prior Entry. Currently, the following code is always generated.
123379 ------------------------------------------------------------------------------------------------
123380 XLA_AE_LINES_PKG.ValidateCurrentLine;
123381
123382 ------------------------------------------------------------------------------------
123383 -- 4219869 Business Flow
123384 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
123385 ------------------------------------------------------------------------------------
123386 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
123387
123388 ----------------------------------------------------------------------------------
123389 -- 4219869 Business Flow
123390 -- Update journal entry status -- Need to generate this within IF <condition>
123391 ----------------------------------------------------------------------------------
123392 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
123393 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
123394 ,p_balance_type_code => l_balance_type_code
123395 );
123396
123397 -------------------------------------------------------------------------------------------
123398 -- 4262811 - Generate the Accrual Reversal lines
123399 -------------------------------------------------------------------------------------------
123400 BEGIN
123401 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
123402 (g_array_event(p_event_id).array_value_num('header_index'));
123403 IF l_acc_rev_flag IS NULL THEN
123404 l_acc_rev_flag := 'N';
123405 END IF;
123406 EXCEPTION
123407 WHEN OTHERS THEN
123408 l_acc_rev_flag := 'N';
123409 END;
123410 --
123411 IF (l_acc_rev_flag = 'Y') THEN
123412
123413 -- 4645092 ------------------------------------------------------------------------------
123414 -- To allow MPA report to determine if it should generate report process
123415 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
123416 ------------------------------------------------------------------------------------------
123417
123418 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
123419 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
123420 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
123421 -- call ADRs
123422 -- Bug 4922099
123423 --
123424 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
123425 (NVL(l_actual_upg_option, 'N') = 'O') OR
123426 (NVL(l_enc_upg_option, 'N') = 'O')
123427 )
123428 THEN
123429 NULL;
123430 --
123431 --
123432
123433 l_ccid := AcctDerRule_28(
123434 p_application_id => p_application_id
123435 , p_ae_header_id => l_ae_header_id
123436 , p_source_15 => p_source_15
123437 , p_source_41 => p_source_41
123438 , p_source_42 => p_source_42
123439 , p_source_43 => p_source_43
123440 , p_source_44 => p_source_44
123441 , p_source_45 => p_source_45
123442 , x_transaction_coa_id => l_adr_transaction_coa_id
123443 , x_accounting_coa_id => l_adr_accounting_coa_id
123444 , x_value_type_code => l_adr_value_type_code
123445 , p_side => 'NA'
123446 );
123447
123448 xla_ae_lines_pkg.set_ccid(
123449 p_code_combination_id => l_ccid
123450 , p_value_type_code => l_adr_value_type_code
123451 , p_transaction_coa_id => l_adr_transaction_coa_id
123452 , p_accounting_coa_id => l_adr_accounting_coa_id
123453 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
123454 , p_adr_type_code => 'S'
123455 , p_component_type => l_component_type
123456 , p_component_code => l_component_code
123457 , p_component_type_code => l_component_type_code
123458 , p_component_appl_id => l_component_appl_id
123459 , p_amb_context_code => l_amb_context_code
123460 , p_side => 'NA'
123461 );
123462
123463
123464 --
123465 --
123466 END IF;
123467
123468 --
123469 -- Update the line information that should be overwritten
123470 --
123471 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
123472 p_header_num => 1);
123473 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
123474
123475 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
123476
123477 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
123478 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
123479 END IF;
123480
123481 --
123482 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
123483 --
123484 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
123485 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
123486 ELSE
123487 ---------------------------------------------------------------------------------------------------
123488 -- 4262811a Switch Sign
123489 ---------------------------------------------------------------------------------------------------
123490 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
123491 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
123492 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
123493 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
123494 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
123495 -- 5132302
123496 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
123497 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
123498
123499 END IF;
123500
123501 -- 4955764
123502 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
123503 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
123504
123505
123506 XLA_AE_LINES_PKG.ValidateCurrentLine;
123507 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
123508
123509 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
123510 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
123511 ,p_balance_type_code => l_balance_type_code);
123512
123513 END IF;
123514
123515 -----------------------------------------------------------------------------------------
123516 -- 4262811 Multiperiod Accounting
123517 -----------------------------------------------------------------------------------------
123518 -- No MPA option is assigned.
123519
123520
123521 END IF;
123522 END IF;
123523 --
123524
123525 --
123526 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
123527 trace
123528 (p_msg => 'END of AcctLineType_238'
123529 ,p_level => C_LEVEL_PROCEDURE
123530 ,p_module => l_log_module);
123531 END IF;
123532 --
123533 EXCEPTION
123534 WHEN xla_exceptions_pkg.application_exception THEN
123535 RAISE;
123536 WHEN OTHERS THEN
123537 xla_exceptions_pkg.raise_message
123538 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_238');
123539 END AcctLineType_238;
123540 --
123541
123542 ---------------------------------------
123543 --
123544 -- PRIVATE FUNCTION
123545 -- AcctLineType_239
123546 --
123547 ---------------------------------------
123548 PROCEDURE AcctLineType_239 (
123549 p_application_id IN NUMBER
123550 ,p_event_id IN NUMBER
123551 ,p_calculate_acctd_flag IN VARCHAR2
123552 ,p_calculate_g_l_flag IN VARCHAR2
123553 ,p_actual_flag IN OUT VARCHAR2
123554 ,p_balance_type_code OUT VARCHAR2
123555 ,p_gain_or_loss_ref OUT VARCHAR2
123556
123557 --TRANSACTION_ID
123558 , p_source_1 IN NUMBER
123559 --Item Concatenated Segments
123560 , p_source_2 IN VARCHAR2
123561 --Transaction Quantity
123562 , p_source_3 IN NUMBER
123563 --Transaction Unit of Measure Code
123564 , p_source_4 IN VARCHAR2
123565 --Inventory Transaction Type Description
123566 , p_source_5 IN VARCHAR2
123567 --Cost Element Name
123568 , p_source_15 IN NUMBER
123569 --Product Line Accounting Category Material Account
123570 , p_source_41 IN NUMBER
123571 --Product Line Accounting Category Material Overhead Account
123572 , p_source_42 IN NUMBER
123573 --Product Line Accounting Category Resource Account
123574 , p_source_43 IN NUMBER
123575 --Product Line Accounting Category Outside Processing Account
123576 , p_source_44 IN NUMBER
123577 --Product Line Accounting Category Overhead Account
123578 , p_source_45 IN NUMBER
123579 --Applied to Application ID
123580 , p_source_79 IN NUMBER
123581 --Applied to Distribution Link Type
123582 , p_source_80 IN VARCHAR2
123583 --Applied to Entity Code
123584 , p_source_81 IN VARCHAR2
123585 --Applied To Purchase Document Identifier
123586 , p_source_83 IN NUMBER
123587 --DISTRIBUTION_IDENTIFIER
123588 , p_source_84 IN NUMBER
123589 --Distribution Type
123590 , p_source_85 IN VARCHAR2
123591 , p_source_85_meaning IN VARCHAR2
123592 --PO Budget Account
123593 , p_source_86 IN NUMBER
123594 --Encumbrance Reversal Amount Entered
123595 , p_source_87 IN NUMBER
123596 --Entered Currency Code
123597 , p_source_88 IN VARCHAR2
123598 --Transaction Encumbrance Reversal Amount
123599 , p_source_89 IN NUMBER
123600 --Entered Amount
123601 , p_source_91 IN NUMBER
123602 --Currency Conversion Date
123603 , p_source_92 IN DATE
123604 --Currency Conversion Rate
123605 , p_source_93 IN NUMBER
123606 --Currency Conversion Type
123607 , p_source_94 IN VARCHAR2
123608 --Accounted Amount
123609 , p_source_95 IN NUMBER
123610 --Purchasing Encumbrance Type Identifier
123611 , p_source_96 IN NUMBER
123612 --Accounting Line Type
123613 , p_source_97 IN NUMBER
123614 --Costing Encumbrance Upgrade Option
123615 , p_source_100 IN VARCHAR2
123616 --TXN_PO_DISTRIBUTION_ID
123617 , p_source_101 IN NUMBER
123618 --Organization Code
123619 , p_source_108 IN VARCHAR2
123620 )
123621 IS
123622
123623 l_component_type VARCHAR2(80);
123624 l_component_code VARCHAR2(30);
123625 l_component_type_code VARCHAR2(1);
123626 l_component_appl_id INTEGER;
123627 l_amb_context_code VARCHAR2(30);
123628 l_entity_code VARCHAR2(30);
123629 l_event_class_code VARCHAR2(30);
123630 l_ae_header_id NUMBER;
123631 l_event_type_code VARCHAR2(30);
123632 l_line_definition_code VARCHAR2(30);
123633 l_line_definition_owner_code VARCHAR2(1);
123634 --
123635 -- adr variables
123636 l_segment VARCHAR2(30);
123637 l_ccid NUMBER;
123638 l_adr_transaction_coa_id NUMBER;
123639 l_adr_accounting_coa_id NUMBER;
123640 l_adr_flexfield_segment_code VARCHAR2(30);
123641 l_adr_flex_value_set_id NUMBER;
123642 l_adr_value_type_code VARCHAR2(30);
123643 l_adr_value_combination_id NUMBER;
123644 l_adr_value_segment_code VARCHAR2(30);
123645
123646 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
123647 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
123648 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
123649 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
123650
123651 -- 4262811 Variables ------------------------------------------------------------------------------------------
123652 l_entered_amt_idx NUMBER;
123653 l_accted_amt_idx NUMBER;
123654 l_acc_rev_flag VARCHAR2(1);
123655 l_accrual_line_num NUMBER;
123656 l_tmp_amt NUMBER;
123657 l_acc_rev_natural_side_code VARCHAR2(1);
123658
123659 l_num_entries NUMBER;
123660 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
123661 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
123662 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
123663 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
123664 l_recog_line_1 NUMBER;
123665 l_recog_line_2 NUMBER;
123666
123667 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
123668 l_bflow_applied_to_amt NUMBER; -- 5132302
123669 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
123670
123671 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
123672
123673 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
123674 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
123675
123676 ---------------------------------------------------------------------------------------------------------------
123677
123678
123679 --
123680 -- bulk performance
123681 --
123682 l_balance_type_code VARCHAR2(1);
123683 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
123684 l_log_module VARCHAR2(240);
123685
123686 --
123687 -- Upgrade strategy
123688 --
123689 l_actual_upg_option VARCHAR2(1);
123690 l_enc_upg_option VARCHAR2(1);
123691
123692 --
123693 BEGIN
123694 --
123695 IF g_log_enabled THEN
123696 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_239';
123697 END IF;
123698 --
123699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
123700
123701 trace
123702 (p_msg => 'BEGIN of AcctLineType_239'
123703 ,p_level => C_LEVEL_PROCEDURE
123704 ,p_module => l_log_module);
123705
123706 END IF;
123707 --
123708 l_component_type := 'AMB_JLT';
123709 l_component_code := 'INVENTORY_VALUATION';
123710 l_component_type_code := 'S';
123711 l_component_appl_id := 707;
123712 l_amb_context_code := 'DEFAULT';
123713 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
123714 l_event_class_code := 'PURCHASE_ORDER';
123715 l_event_type_code := 'PO_DEL_ADJ';
123716 l_line_definition_owner_code := 'S';
123717 l_line_definition_code := 'PI_PO_DEL_ADJ';
123718 --
123719 l_balance_type_code := 'A';
123720 l_segment := NULL;
123721 l_ccid := NULL;
123722 l_adr_transaction_coa_id := NULL;
123723 l_adr_accounting_coa_id := NULL;
123724 l_adr_flexfield_segment_code := NULL;
123725 l_adr_flex_value_set_id := NULL;
123726 l_adr_value_type_code := NULL;
123727 l_adr_value_combination_id := NULL;
123728 l_adr_value_segment_code := NULL;
123729
123730 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
123731 l_bflow_class_code := ''; -- 4219869 Business Flow
123732 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
123733 l_budgetary_control_flag := 'N';
123734
123735 l_bflow_applied_to_amt_idx := NULL; -- 5132302
123736 l_bflow_applied_to_amt := NULL; -- 5132302
123737 l_entered_amt_idx := NULL; -- 4262811
123738 l_accted_amt_idx := NULL; -- 4262811
123739 l_acc_rev_flag := NULL; -- 4262811
123740 l_accrual_line_num := NULL; -- 4262811
123741 l_tmp_amt := NULL; -- 4262811
123742 --
123743
123744 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
123745 l_balance_type_code <> 'B' THEN
123746 IF NVL(p_source_97,9E125) = 1
123747 THEN
123748
123749 --
123750 XLA_AE_LINES_PKG.SetNewLine;
123751
123752 p_balance_type_code := l_balance_type_code;
123753 -- set the flag so later we will know whether the gain loss line needs to be created
123754
123755 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
123756 p_actual_flag :='A';
123757 END IF;
123758
123759 --
123760 -- bulk performance
123761 --
123762 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
123763 p_header_num => 0); -- 4262811
123764 --
123765 -- set accounting line options
123766 --
123767 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
123768 p_natural_side_code => 'D'
123769 , p_gain_or_loss_flag => 'N'
123770 , p_gl_transfer_mode_code => 'S'
123771 , p_acct_entry_type_code => 'A'
123772 , p_switch_side_flag => 'Y'
123773 , p_merge_duplicate_code => 'N'
123774 );
123775 --
123776 l_acc_rev_natural_side_code := 'C'; -- 4262811
123777 --
123778 --
123779 -- set accounting line type info
123780 --
123781 xla_ae_lines_pkg.SetAcctLineType
123782 (p_component_type => l_component_type
123783 ,p_event_type_code => l_event_type_code
123784 ,p_line_definition_owner_code => l_line_definition_owner_code
123785 ,p_line_definition_code => l_line_definition_code
123786 ,p_accounting_line_code => l_component_code
123787 ,p_accounting_line_type_code => l_component_type_code
123788 ,p_accounting_line_appl_id => l_component_appl_id
123789 ,p_amb_context_code => l_amb_context_code
123790 ,p_entity_code => l_entity_code
123791 ,p_event_class_code => l_event_class_code);
123792 --
123793 -- set accounting class
123794 --
123795 xla_ae_lines_pkg.SetAcctClass(
123796 p_accounting_class_code => 'INVENTORY_VALUATION'
123797 , p_ae_header_id => l_ae_header_id
123798 );
123799
123800 --
123801 -- set rounding class
123802 --
123803 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
123804 'INVENTORY_VALUATION';
123805
123806 --
123807 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
123808 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
123809 --
123810 -- bulk performance
123811 --
123812 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
123813
123814 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
123815 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
123816
123817 -- 4955764
123818 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
123819 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
123820
123821 -- 4458381 Public Sector Enh
123822
123823 --
123824 -- set accounting attributes for the line type
123825 --
123826 l_entered_amt_idx := 17;
123827 l_accted_amt_idx := 22;
123828 l_bflow_applied_to_amt_idx := NULL; -- 5132302
123829 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
123830 l_rec_acct_attrs.array_num_value(1) := p_source_79;
123831 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
123832 l_rec_acct_attrs.array_char_value(2) := p_source_80;
123833 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
123834 l_rec_acct_attrs.array_char_value(3) := p_source_81;
123835 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
123836 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
123837 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
123838 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
123839 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
123840 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
123841 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
123842 l_rec_acct_attrs.array_char_value(7) := p_source_85;
123843 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
123844 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
123845 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
123846 l_rec_acct_attrs.array_num_value(9) := p_source_87;
123847 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
123848 l_rec_acct_attrs.array_char_value(10) := p_source_88;
123849 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
123850 l_rec_acct_attrs.array_num_value(11) := p_source_89;
123851 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
123852 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
123853 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
123854 l_rec_acct_attrs.array_num_value(13) := p_source_87;
123855 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
123856 l_rec_acct_attrs.array_char_value(14) := p_source_88;
123857 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
123858 l_rec_acct_attrs.array_num_value(15) := p_source_89;
123859 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
123860 l_rec_acct_attrs.array_char_value(16) := p_source_100;
123861 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
123862 l_rec_acct_attrs.array_num_value(17) := p_source_91;
123863 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
123864 l_rec_acct_attrs.array_char_value(18) := p_source_88;
123865 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
123866 l_rec_acct_attrs.array_date_value(19) := p_source_92;
123867 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
123868 l_rec_acct_attrs.array_num_value(20) := p_source_93;
123869 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
123870 l_rec_acct_attrs.array_char_value(21) := p_source_94;
123871 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
123872 l_rec_acct_attrs.array_num_value(22) := p_source_95;
123873 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
123874 l_rec_acct_attrs.array_num_value(23) := p_source_96;
123875 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
123876 l_rec_acct_attrs.array_num_value(24) := p_source_96;
123877
123878 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
123879 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
123880
123881 ---------------------------------------------------------------------------------------------------------------
123882 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
123883 ---------------------------------------------------------------------------------------------------------------
123884 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
123885
123886 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
123887 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
123888
123889 IF xla_accounting_cache_pkg.GetValueChar
123890 (p_source_code => 'LEDGER_CATEGORY_CODE'
123891 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
123892 AND l_bflow_method_code = 'PRIOR_ENTRY'
123893 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
123894 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
123895 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
123896 )
123897 THEN
123898 xla_ae_lines_pkg.BflowUpgEntry
123899 (p_business_method_code => l_bflow_method_code
123900 ,p_business_class_code => l_bflow_class_code
123901 ,p_balance_type => l_balance_type_code);
123902 ELSE
123903 NULL;
123904 -- No business flow processing for business flow method of NONE.
123905 END IF;
123906
123907 --
123908 -- call analytical criteria
123909 --
123910
123911
123912 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
123913 xla_ae_lines_pkg.SetAnalyticalCriteria(
123914 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
123915 , p_analytical_criterion_owner => 'S'
123916 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
123917 , p_amb_context_code => 'DEFAULT'
123918 , p_balancing_flag => 'Y'
123919
123920 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
123921 , p_analytical_detail_num_1 => NULL
123922 , p_analytical_detail_date_1 => NULL
123923
123924 , p_ae_header_id => l_ae_header_id
123925 )
123926 ;
123927 --
123928
123929 --
123930 -- call description
123931 --
123932
123933 xla_ae_lines_pkg.SetLineDescription(
123934 p_ae_header_id => l_ae_header_id
123935 ,p_description => Description_1 (
123936 p_application_id => p_application_id
123937 , p_ae_header_id => l_ae_header_id
123938 , p_source_1 => p_source_1
123939 , p_source_2 => p_source_2
123940 , p_source_3 => p_source_3
123941 , p_source_4 => p_source_4
123942 , p_source_5 => p_source_5
123943 )
123944 );
123945
123946
123947 --
123948 -- call ADRs
123949 -- Bug 4922099
123950 --
123951 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
123952 (NVL(l_actual_upg_option, 'N') = 'O') OR
123953 (NVL(l_enc_upg_option, 'N') = 'O')
123954 )
123955 THEN
123956 NULL;
123957 --
123958 --
123959
123960 l_ccid := AcctDerRule_28(
123961 p_application_id => p_application_id
123962 , p_ae_header_id => l_ae_header_id
123963 , p_source_15 => p_source_15
123964 , p_source_41 => p_source_41
123965 , p_source_42 => p_source_42
123966 , p_source_43 => p_source_43
123967 , p_source_44 => p_source_44
123968 , p_source_45 => p_source_45
123969 , x_transaction_coa_id => l_adr_transaction_coa_id
123970 , x_accounting_coa_id => l_adr_accounting_coa_id
123971 , x_value_type_code => l_adr_value_type_code
123972 , p_side => 'NA'
123973 );
123974
123975 xla_ae_lines_pkg.set_ccid(
123976 p_code_combination_id => l_ccid
123977 , p_value_type_code => l_adr_value_type_code
123978 , p_transaction_coa_id => l_adr_transaction_coa_id
123979 , p_accounting_coa_id => l_adr_accounting_coa_id
123980 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
123981 , p_adr_type_code => 'S'
123982 , p_component_type => l_component_type
123983 , p_component_code => l_component_code
123984 , p_component_type_code => l_component_type_code
123985 , p_component_appl_id => l_component_appl_id
123986 , p_amb_context_code => l_amb_context_code
123987 , p_side => 'NA'
123988 );
123989
123990
123991 --
123992 --
123993 END IF;
123994 --
123995 -- Bug 4922099
123996 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
123997 (NVL(l_enc_upg_option, 'N') = 'O')
123998 ) AND
123999 (l_bflow_method_code = 'PRIOR_ENTRY')
124000 )
124001 THEN
124002 IF
124003 --
124004 1 = 2
124005 --
124006 THEN
124007 xla_accounting_err_pkg.build_message
124008 (p_appli_s_name => 'XLA'
124009 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
124010 ,p_token_1 => 'LINE_NUMBER'
124011 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
124012 ,p_token_2 => 'LINE_TYPE_NAME'
124013 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
124014 l_component_type
124015 ,l_component_code
124016 ,l_component_type_code
124017 ,l_component_appl_id
124018 ,l_amb_context_code
124019 ,l_entity_code
124020 ,l_event_class_code
124021 )
124022 ,p_token_3 => 'OWNER'
124023 ,p_value_3 => xla_lookups_pkg.get_meaning(
124024 p_lookup_type => 'XLA_OWNER_TYPE'
124025 ,p_lookup_code => l_component_type_code
124026 )
124027 ,p_token_4 => 'PRODUCT_NAME'
124028 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
124029 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
124030 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
124031 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
124032 ,p_ae_header_id => NULL
124033 );
124034
124035 IF (C_LEVEL_ERROR>= g_log_level) THEN
124036 trace
124037 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
124038 ,p_level => C_LEVEL_ERROR
124039 ,p_module => l_log_module);
124040 END IF;
124041 END IF;
124042 END IF;
124043 --
124044 --
124045 ------------------------------------------------------------------------------------------------
124046 -- 4219869 Business Flow
124047 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
124048 -- Prior Entry. Currently, the following code is always generated.
124049 ------------------------------------------------------------------------------------------------
124050 XLA_AE_LINES_PKG.ValidateCurrentLine;
124051
124052 ------------------------------------------------------------------------------------
124053 -- 4219869 Business Flow
124054 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
124055 ------------------------------------------------------------------------------------
124056 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
124057
124058 ----------------------------------------------------------------------------------
124059 -- 4219869 Business Flow
124060 -- Update journal entry status -- Need to generate this within IF <condition>
124061 ----------------------------------------------------------------------------------
124062 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
124063 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
124064 ,p_balance_type_code => l_balance_type_code
124065 );
124066
124067 -------------------------------------------------------------------------------------------
124068 -- 4262811 - Generate the Accrual Reversal lines
124069 -------------------------------------------------------------------------------------------
124070 BEGIN
124071 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
124072 (g_array_event(p_event_id).array_value_num('header_index'));
124073 IF l_acc_rev_flag IS NULL THEN
124074 l_acc_rev_flag := 'N';
124075 END IF;
124076 EXCEPTION
124077 WHEN OTHERS THEN
124078 l_acc_rev_flag := 'N';
124079 END;
124080 --
124081 IF (l_acc_rev_flag = 'Y') THEN
124082
124083 -- 4645092 ------------------------------------------------------------------------------
124084 -- To allow MPA report to determine if it should generate report process
124085 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
124086 ------------------------------------------------------------------------------------------
124087
124088 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
124089 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
124090 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
124091 -- call ADRs
124092 -- Bug 4922099
124093 --
124094 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
124095 (NVL(l_actual_upg_option, 'N') = 'O') OR
124096 (NVL(l_enc_upg_option, 'N') = 'O')
124097 )
124098 THEN
124099 NULL;
124100 --
124101 --
124102
124103 l_ccid := AcctDerRule_28(
124104 p_application_id => p_application_id
124105 , p_ae_header_id => l_ae_header_id
124106 , p_source_15 => p_source_15
124107 , p_source_41 => p_source_41
124108 , p_source_42 => p_source_42
124109 , p_source_43 => p_source_43
124110 , p_source_44 => p_source_44
124111 , p_source_45 => p_source_45
124112 , x_transaction_coa_id => l_adr_transaction_coa_id
124113 , x_accounting_coa_id => l_adr_accounting_coa_id
124114 , x_value_type_code => l_adr_value_type_code
124115 , p_side => 'NA'
124116 );
124117
124118 xla_ae_lines_pkg.set_ccid(
124119 p_code_combination_id => l_ccid
124120 , p_value_type_code => l_adr_value_type_code
124121 , p_transaction_coa_id => l_adr_transaction_coa_id
124122 , p_accounting_coa_id => l_adr_accounting_coa_id
124123 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
124124 , p_adr_type_code => 'S'
124125 , p_component_type => l_component_type
124126 , p_component_code => l_component_code
124127 , p_component_type_code => l_component_type_code
124128 , p_component_appl_id => l_component_appl_id
124129 , p_amb_context_code => l_amb_context_code
124130 , p_side => 'NA'
124131 );
124132
124133
124134 --
124135 --
124136 END IF;
124137
124138 --
124139 -- Update the line information that should be overwritten
124140 --
124141 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
124142 p_header_num => 1);
124143 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
124144
124145 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
124146
124147 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
124148 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
124149 END IF;
124150
124151 --
124152 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
124153 --
124154 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
124155 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
124156 ELSE
124157 ---------------------------------------------------------------------------------------------------
124158 -- 4262811a Switch Sign
124159 ---------------------------------------------------------------------------------------------------
124160 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
124161 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
124162 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124163 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
124164 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124165 -- 5132302
124166 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
124167 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124168
124169 END IF;
124170
124171 -- 4955764
124172 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
124173 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
124174
124175
124176 XLA_AE_LINES_PKG.ValidateCurrentLine;
124177 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
124178
124179 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
124180 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
124181 ,p_balance_type_code => l_balance_type_code);
124182
124183 END IF;
124184
124185 -----------------------------------------------------------------------------------------
124186 -- 4262811 Multiperiod Accounting
124187 -----------------------------------------------------------------------------------------
124188 -- No MPA option is assigned.
124189
124190
124191 END IF;
124192 END IF;
124193 --
124194
124195 --
124196 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
124197 trace
124198 (p_msg => 'END of AcctLineType_239'
124199 ,p_level => C_LEVEL_PROCEDURE
124200 ,p_module => l_log_module);
124201 END IF;
124202 --
124203 EXCEPTION
124204 WHEN xla_exceptions_pkg.application_exception THEN
124205 RAISE;
124206 WHEN OTHERS THEN
124207 xla_exceptions_pkg.raise_message
124208 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_239');
124209 END AcctLineType_239;
124210 --
124211
124212 ---------------------------------------
124213 --
124214 -- PRIVATE FUNCTION
124215 -- AcctLineType_240
124216 --
124217 ---------------------------------------
124218 PROCEDURE AcctLineType_240 (
124219 p_application_id IN NUMBER
124220 ,p_event_id IN NUMBER
124221 ,p_calculate_acctd_flag IN VARCHAR2
124222 ,p_calculate_g_l_flag IN VARCHAR2
124223 ,p_actual_flag IN OUT VARCHAR2
124224 ,p_balance_type_code OUT VARCHAR2
124225 ,p_gain_or_loss_ref OUT VARCHAR2
124226
124227 --TRANSACTION_ID
124228 , p_source_1 IN NUMBER
124229 --Item Concatenated Segments
124230 , p_source_2 IN VARCHAR2
124231 --Transaction Quantity
124232 , p_source_3 IN NUMBER
124233 --Transaction Unit of Measure Code
124234 , p_source_4 IN VARCHAR2
124235 --Inventory Transaction Type Description
124236 , p_source_5 IN VARCHAR2
124237 --Cost Element Name
124238 , p_source_15 IN NUMBER
124239 --Product Line Accounting Category Material Account
124240 , p_source_41 IN NUMBER
124241 --Product Line Accounting Category Material Overhead Account
124242 , p_source_42 IN NUMBER
124243 --Product Line Accounting Category Resource Account
124244 , p_source_43 IN NUMBER
124245 --Product Line Accounting Category Outside Processing Account
124246 , p_source_44 IN NUMBER
124247 --Product Line Accounting Category Overhead Account
124248 , p_source_45 IN NUMBER
124249 --Applied to Application ID
124250 , p_source_79 IN NUMBER
124251 --Applied to Distribution Link Type
124252 , p_source_80 IN VARCHAR2
124253 --Applied to Entity Code
124254 , p_source_81 IN VARCHAR2
124255 --Applied To Purchase Document Identifier
124256 , p_source_83 IN NUMBER
124257 --DISTRIBUTION_IDENTIFIER
124258 , p_source_84 IN NUMBER
124259 --Distribution Type
124260 , p_source_85 IN VARCHAR2
124261 , p_source_85_meaning IN VARCHAR2
124262 --PO Budget Account
124263 , p_source_86 IN NUMBER
124264 --Encumbrance Reversal Amount Entered
124265 , p_source_87 IN NUMBER
124266 --Entered Currency Code
124267 , p_source_88 IN VARCHAR2
124268 --Transaction Encumbrance Reversal Amount
124269 , p_source_89 IN NUMBER
124270 --Entered Amount
124271 , p_source_91 IN NUMBER
124272 --Currency Conversion Date
124273 , p_source_92 IN DATE
124274 --Currency Conversion Rate
124275 , p_source_93 IN NUMBER
124276 --Currency Conversion Type
124277 , p_source_94 IN VARCHAR2
124278 --Accounted Amount
124279 , p_source_95 IN NUMBER
124280 --Purchasing Encumbrance Type Identifier
124281 , p_source_96 IN NUMBER
124282 --Accounting Line Type
124283 , p_source_97 IN NUMBER
124284 --Costing Encumbrance Upgrade Option
124285 , p_source_100 IN VARCHAR2
124286 --TXN_PO_DISTRIBUTION_ID
124287 , p_source_101 IN NUMBER
124288 --Organization Code
124289 , p_source_108 IN VARCHAR2
124290 )
124291 IS
124292
124293 l_component_type VARCHAR2(80);
124294 l_component_code VARCHAR2(30);
124295 l_component_type_code VARCHAR2(1);
124296 l_component_appl_id INTEGER;
124297 l_amb_context_code VARCHAR2(30);
124298 l_entity_code VARCHAR2(30);
124299 l_event_class_code VARCHAR2(30);
124300 l_ae_header_id NUMBER;
124301 l_event_type_code VARCHAR2(30);
124302 l_line_definition_code VARCHAR2(30);
124303 l_line_definition_owner_code VARCHAR2(1);
124304 --
124305 -- adr variables
124306 l_segment VARCHAR2(30);
124307 l_ccid NUMBER;
124308 l_adr_transaction_coa_id NUMBER;
124309 l_adr_accounting_coa_id NUMBER;
124310 l_adr_flexfield_segment_code VARCHAR2(30);
124311 l_adr_flex_value_set_id NUMBER;
124312 l_adr_value_type_code VARCHAR2(30);
124313 l_adr_value_combination_id NUMBER;
124314 l_adr_value_segment_code VARCHAR2(30);
124315
124316 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
124317 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
124318 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
124319 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
124320
124321 -- 4262811 Variables ------------------------------------------------------------------------------------------
124322 l_entered_amt_idx NUMBER;
124323 l_accted_amt_idx NUMBER;
124324 l_acc_rev_flag VARCHAR2(1);
124325 l_accrual_line_num NUMBER;
124326 l_tmp_amt NUMBER;
124327 l_acc_rev_natural_side_code VARCHAR2(1);
124328
124329 l_num_entries NUMBER;
124330 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
124331 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
124332 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
124333 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
124334 l_recog_line_1 NUMBER;
124335 l_recog_line_2 NUMBER;
124336
124337 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
124338 l_bflow_applied_to_amt NUMBER; -- 5132302
124339 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
124340
124341 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
124342
124343 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
124344 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
124345
124346 ---------------------------------------------------------------------------------------------------------------
124347
124348
124349 --
124350 -- bulk performance
124351 --
124352 l_balance_type_code VARCHAR2(1);
124353 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
124354 l_log_module VARCHAR2(240);
124355
124356 --
124357 -- Upgrade strategy
124358 --
124359 l_actual_upg_option VARCHAR2(1);
124360 l_enc_upg_option VARCHAR2(1);
124361
124362 --
124363 BEGIN
124364 --
124365 IF g_log_enabled THEN
124366 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_240';
124367 END IF;
124368 --
124369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
124370
124371 trace
124372 (p_msg => 'BEGIN of AcctLineType_240'
124373 ,p_level => C_LEVEL_PROCEDURE
124374 ,p_module => l_log_module);
124375
124376 END IF;
124377 --
124378 l_component_type := 'AMB_JLT';
124379 l_component_code := 'INVENTORY_VALUATION';
124380 l_component_type_code := 'S';
124381 l_component_appl_id := 707;
124382 l_amb_context_code := 'DEFAULT';
124383 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
124384 l_event_class_code := 'PURCHASE_ORDER';
124385 l_event_type_code := 'PO_DEL_INV';
124386 l_line_definition_owner_code := 'S';
124387 l_line_definition_code := 'PI_PO_DEL_INV';
124388 --
124389 l_balance_type_code := 'A';
124390 l_segment := NULL;
124391 l_ccid := NULL;
124392 l_adr_transaction_coa_id := NULL;
124393 l_adr_accounting_coa_id := NULL;
124394 l_adr_flexfield_segment_code := NULL;
124395 l_adr_flex_value_set_id := NULL;
124396 l_adr_value_type_code := NULL;
124397 l_adr_value_combination_id := NULL;
124398 l_adr_value_segment_code := NULL;
124399
124400 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
124401 l_bflow_class_code := ''; -- 4219869 Business Flow
124402 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
124403 l_budgetary_control_flag := 'N';
124404
124405 l_bflow_applied_to_amt_idx := NULL; -- 5132302
124406 l_bflow_applied_to_amt := NULL; -- 5132302
124407 l_entered_amt_idx := NULL; -- 4262811
124408 l_accted_amt_idx := NULL; -- 4262811
124409 l_acc_rev_flag := NULL; -- 4262811
124410 l_accrual_line_num := NULL; -- 4262811
124411 l_tmp_amt := NULL; -- 4262811
124412 --
124413
124414 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
124415 l_balance_type_code <> 'B' THEN
124416 IF NVL(p_source_97,9E125) = 1
124417 THEN
124418
124419 --
124420 XLA_AE_LINES_PKG.SetNewLine;
124421
124422 p_balance_type_code := l_balance_type_code;
124423 -- set the flag so later we will know whether the gain loss line needs to be created
124424
124425 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
124426 p_actual_flag :='A';
124427 END IF;
124428
124429 --
124430 -- bulk performance
124431 --
124432 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
124433 p_header_num => 0); -- 4262811
124434 --
124435 -- set accounting line options
124436 --
124437 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
124438 p_natural_side_code => 'D'
124439 , p_gain_or_loss_flag => 'N'
124440 , p_gl_transfer_mode_code => 'S'
124441 , p_acct_entry_type_code => 'A'
124442 , p_switch_side_flag => 'Y'
124443 , p_merge_duplicate_code => 'N'
124444 );
124445 --
124446 l_acc_rev_natural_side_code := 'C'; -- 4262811
124447 --
124448 --
124449 -- set accounting line type info
124450 --
124451 xla_ae_lines_pkg.SetAcctLineType
124452 (p_component_type => l_component_type
124453 ,p_event_type_code => l_event_type_code
124454 ,p_line_definition_owner_code => l_line_definition_owner_code
124455 ,p_line_definition_code => l_line_definition_code
124456 ,p_accounting_line_code => l_component_code
124457 ,p_accounting_line_type_code => l_component_type_code
124458 ,p_accounting_line_appl_id => l_component_appl_id
124459 ,p_amb_context_code => l_amb_context_code
124460 ,p_entity_code => l_entity_code
124461 ,p_event_class_code => l_event_class_code);
124462 --
124463 -- set accounting class
124464 --
124465 xla_ae_lines_pkg.SetAcctClass(
124466 p_accounting_class_code => 'INVENTORY_VALUATION'
124467 , p_ae_header_id => l_ae_header_id
124468 );
124469
124470 --
124471 -- set rounding class
124472 --
124473 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
124474 'INVENTORY_VALUATION';
124475
124476 --
124477 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
124478 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
124479 --
124480 -- bulk performance
124481 --
124482 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
124483
124484 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
124485 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
124486
124487 -- 4955764
124488 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
124489 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
124490
124491 -- 4458381 Public Sector Enh
124492
124493 --
124494 -- set accounting attributes for the line type
124495 --
124496 l_entered_amt_idx := 17;
124497 l_accted_amt_idx := 22;
124498 l_bflow_applied_to_amt_idx := NULL; -- 5132302
124499 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
124500 l_rec_acct_attrs.array_num_value(1) := p_source_79;
124501 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
124502 l_rec_acct_attrs.array_char_value(2) := p_source_80;
124503 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
124504 l_rec_acct_attrs.array_char_value(3) := p_source_81;
124505 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
124506 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
124507 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
124508 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
124509 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
124510 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
124511 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
124512 l_rec_acct_attrs.array_char_value(7) := p_source_85;
124513 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
124514 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
124515 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
124516 l_rec_acct_attrs.array_num_value(9) := p_source_87;
124517 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
124518 l_rec_acct_attrs.array_char_value(10) := p_source_88;
124519 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
124520 l_rec_acct_attrs.array_num_value(11) := p_source_89;
124521 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
124522 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
124523 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
124524 l_rec_acct_attrs.array_num_value(13) := p_source_87;
124525 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
124526 l_rec_acct_attrs.array_char_value(14) := p_source_88;
124527 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
124528 l_rec_acct_attrs.array_num_value(15) := p_source_89;
124529 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
124530 l_rec_acct_attrs.array_char_value(16) := p_source_100;
124531 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
124532 l_rec_acct_attrs.array_num_value(17) := p_source_91;
124533 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
124534 l_rec_acct_attrs.array_char_value(18) := p_source_88;
124535 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
124536 l_rec_acct_attrs.array_date_value(19) := p_source_92;
124537 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
124538 l_rec_acct_attrs.array_num_value(20) := p_source_93;
124539 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
124540 l_rec_acct_attrs.array_char_value(21) := p_source_94;
124541 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
124542 l_rec_acct_attrs.array_num_value(22) := p_source_95;
124543 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
124544 l_rec_acct_attrs.array_num_value(23) := p_source_96;
124545 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
124546 l_rec_acct_attrs.array_num_value(24) := p_source_96;
124547
124548 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
124549 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
124550
124551 ---------------------------------------------------------------------------------------------------------------
124552 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
124553 ---------------------------------------------------------------------------------------------------------------
124554 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
124555
124556 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
124557 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
124558
124559 IF xla_accounting_cache_pkg.GetValueChar
124560 (p_source_code => 'LEDGER_CATEGORY_CODE'
124561 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
124562 AND l_bflow_method_code = 'PRIOR_ENTRY'
124563 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
124564 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
124565 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
124566 )
124567 THEN
124568 xla_ae_lines_pkg.BflowUpgEntry
124569 (p_business_method_code => l_bflow_method_code
124570 ,p_business_class_code => l_bflow_class_code
124571 ,p_balance_type => l_balance_type_code);
124572 ELSE
124573 NULL;
124574 -- No business flow processing for business flow method of NONE.
124575 END IF;
124576
124577 --
124578 -- call analytical criteria
124579 --
124580
124581
124582 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
124583 xla_ae_lines_pkg.SetAnalyticalCriteria(
124584 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
124585 , p_analytical_criterion_owner => 'S'
124586 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
124587 , p_amb_context_code => 'DEFAULT'
124588 , p_balancing_flag => 'Y'
124589
124590 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
124591 , p_analytical_detail_num_1 => NULL
124592 , p_analytical_detail_date_1 => NULL
124593
124594 , p_ae_header_id => l_ae_header_id
124595 )
124596 ;
124597 --
124598
124599 --
124600 -- call description
124601 --
124602
124603 xla_ae_lines_pkg.SetLineDescription(
124604 p_ae_header_id => l_ae_header_id
124605 ,p_description => Description_1 (
124606 p_application_id => p_application_id
124607 , p_ae_header_id => l_ae_header_id
124608 , p_source_1 => p_source_1
124609 , p_source_2 => p_source_2
124610 , p_source_3 => p_source_3
124611 , p_source_4 => p_source_4
124612 , p_source_5 => p_source_5
124613 )
124614 );
124615
124616
124617 --
124618 -- call ADRs
124619 -- Bug 4922099
124620 --
124621 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
124622 (NVL(l_actual_upg_option, 'N') = 'O') OR
124623 (NVL(l_enc_upg_option, 'N') = 'O')
124624 )
124625 THEN
124626 NULL;
124627 --
124628 --
124629
124630 l_ccid := AcctDerRule_28(
124631 p_application_id => p_application_id
124632 , p_ae_header_id => l_ae_header_id
124633 , p_source_15 => p_source_15
124634 , p_source_41 => p_source_41
124635 , p_source_42 => p_source_42
124636 , p_source_43 => p_source_43
124637 , p_source_44 => p_source_44
124638 , p_source_45 => p_source_45
124639 , x_transaction_coa_id => l_adr_transaction_coa_id
124640 , x_accounting_coa_id => l_adr_accounting_coa_id
124641 , x_value_type_code => l_adr_value_type_code
124642 , p_side => 'NA'
124643 );
124644
124645 xla_ae_lines_pkg.set_ccid(
124646 p_code_combination_id => l_ccid
124647 , p_value_type_code => l_adr_value_type_code
124648 , p_transaction_coa_id => l_adr_transaction_coa_id
124649 , p_accounting_coa_id => l_adr_accounting_coa_id
124650 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
124651 , p_adr_type_code => 'S'
124652 , p_component_type => l_component_type
124653 , p_component_code => l_component_code
124654 , p_component_type_code => l_component_type_code
124655 , p_component_appl_id => l_component_appl_id
124656 , p_amb_context_code => l_amb_context_code
124657 , p_side => 'NA'
124658 );
124659
124660
124661 --
124662 --
124663 END IF;
124664 --
124665 -- Bug 4922099
124666 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
124667 (NVL(l_enc_upg_option, 'N') = 'O')
124668 ) AND
124669 (l_bflow_method_code = 'PRIOR_ENTRY')
124670 )
124671 THEN
124672 IF
124673 --
124674 1 = 2
124675 --
124676 THEN
124677 xla_accounting_err_pkg.build_message
124678 (p_appli_s_name => 'XLA'
124679 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
124680 ,p_token_1 => 'LINE_NUMBER'
124681 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
124682 ,p_token_2 => 'LINE_TYPE_NAME'
124683 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
124684 l_component_type
124685 ,l_component_code
124686 ,l_component_type_code
124687 ,l_component_appl_id
124688 ,l_amb_context_code
124689 ,l_entity_code
124690 ,l_event_class_code
124691 )
124692 ,p_token_3 => 'OWNER'
124693 ,p_value_3 => xla_lookups_pkg.get_meaning(
124694 p_lookup_type => 'XLA_OWNER_TYPE'
124695 ,p_lookup_code => l_component_type_code
124696 )
124697 ,p_token_4 => 'PRODUCT_NAME'
124698 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
124699 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
124700 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
124701 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
124702 ,p_ae_header_id => NULL
124703 );
124704
124705 IF (C_LEVEL_ERROR>= g_log_level) THEN
124706 trace
124707 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
124708 ,p_level => C_LEVEL_ERROR
124709 ,p_module => l_log_module);
124710 END IF;
124711 END IF;
124712 END IF;
124713 --
124714 --
124715 ------------------------------------------------------------------------------------------------
124716 -- 4219869 Business Flow
124717 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
124718 -- Prior Entry. Currently, the following code is always generated.
124719 ------------------------------------------------------------------------------------------------
124720 XLA_AE_LINES_PKG.ValidateCurrentLine;
124721
124722 ------------------------------------------------------------------------------------
124723 -- 4219869 Business Flow
124724 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
124725 ------------------------------------------------------------------------------------
124726 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
124727
124728 ----------------------------------------------------------------------------------
124729 -- 4219869 Business Flow
124730 -- Update journal entry status -- Need to generate this within IF <condition>
124731 ----------------------------------------------------------------------------------
124732 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
124733 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
124734 ,p_balance_type_code => l_balance_type_code
124735 );
124736
124737 -------------------------------------------------------------------------------------------
124738 -- 4262811 - Generate the Accrual Reversal lines
124739 -------------------------------------------------------------------------------------------
124740 BEGIN
124741 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
124742 (g_array_event(p_event_id).array_value_num('header_index'));
124743 IF l_acc_rev_flag IS NULL THEN
124744 l_acc_rev_flag := 'N';
124745 END IF;
124746 EXCEPTION
124747 WHEN OTHERS THEN
124748 l_acc_rev_flag := 'N';
124749 END;
124750 --
124751 IF (l_acc_rev_flag = 'Y') THEN
124752
124753 -- 4645092 ------------------------------------------------------------------------------
124754 -- To allow MPA report to determine if it should generate report process
124755 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
124756 ------------------------------------------------------------------------------------------
124757
124758 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
124759 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
124760 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
124761 -- call ADRs
124762 -- Bug 4922099
124763 --
124764 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
124765 (NVL(l_actual_upg_option, 'N') = 'O') OR
124766 (NVL(l_enc_upg_option, 'N') = 'O')
124767 )
124768 THEN
124769 NULL;
124770 --
124771 --
124772
124773 l_ccid := AcctDerRule_28(
124774 p_application_id => p_application_id
124775 , p_ae_header_id => l_ae_header_id
124776 , p_source_15 => p_source_15
124777 , p_source_41 => p_source_41
124778 , p_source_42 => p_source_42
124779 , p_source_43 => p_source_43
124780 , p_source_44 => p_source_44
124781 , p_source_45 => p_source_45
124782 , x_transaction_coa_id => l_adr_transaction_coa_id
124783 , x_accounting_coa_id => l_adr_accounting_coa_id
124784 , x_value_type_code => l_adr_value_type_code
124785 , p_side => 'NA'
124786 );
124787
124788 xla_ae_lines_pkg.set_ccid(
124789 p_code_combination_id => l_ccid
124790 , p_value_type_code => l_adr_value_type_code
124791 , p_transaction_coa_id => l_adr_transaction_coa_id
124792 , p_accounting_coa_id => l_adr_accounting_coa_id
124793 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
124794 , p_adr_type_code => 'S'
124795 , p_component_type => l_component_type
124796 , p_component_code => l_component_code
124797 , p_component_type_code => l_component_type_code
124798 , p_component_appl_id => l_component_appl_id
124799 , p_amb_context_code => l_amb_context_code
124800 , p_side => 'NA'
124801 );
124802
124803
124804 --
124805 --
124806 END IF;
124807
124808 --
124809 -- Update the line information that should be overwritten
124810 --
124811 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
124812 p_header_num => 1);
124813 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
124814
124815 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
124816
124817 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
124818 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
124819 END IF;
124820
124821 --
124822 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
124823 --
124824 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
124825 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
124826 ELSE
124827 ---------------------------------------------------------------------------------------------------
124828 -- 4262811a Switch Sign
124829 ---------------------------------------------------------------------------------------------------
124830 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
124831 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
124832 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124833 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
124834 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124835 -- 5132302
124836 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
124837 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
124838
124839 END IF;
124840
124841 -- 4955764
124842 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
124843 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
124844
124845
124846 XLA_AE_LINES_PKG.ValidateCurrentLine;
124847 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
124848
124849 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
124850 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
124851 ,p_balance_type_code => l_balance_type_code);
124852
124853 END IF;
124854
124855 -----------------------------------------------------------------------------------------
124856 -- 4262811 Multiperiod Accounting
124857 -----------------------------------------------------------------------------------------
124858 -- No MPA option is assigned.
124859
124860
124861 END IF;
124862 END IF;
124863 --
124864
124865 --
124866 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
124867 trace
124868 (p_msg => 'END of AcctLineType_240'
124869 ,p_level => C_LEVEL_PROCEDURE
124870 ,p_module => l_log_module);
124871 END IF;
124872 --
124873 EXCEPTION
124874 WHEN xla_exceptions_pkg.application_exception THEN
124875 RAISE;
124876 WHEN OTHERS THEN
124877 xla_exceptions_pkg.raise_message
124878 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_240');
124879 END AcctLineType_240;
124880 --
124881
124882 ---------------------------------------
124883 --
124884 -- PRIVATE FUNCTION
124885 -- AcctLineType_241
124886 --
124887 ---------------------------------------
124888 PROCEDURE AcctLineType_241 (
124889 p_application_id IN NUMBER
124890 ,p_event_id IN NUMBER
124891 ,p_calculate_acctd_flag IN VARCHAR2
124892 ,p_calculate_g_l_flag IN VARCHAR2
124893 ,p_actual_flag IN OUT VARCHAR2
124894 ,p_balance_type_code OUT VARCHAR2
124895 ,p_gain_or_loss_ref OUT VARCHAR2
124896
124897 --TRANSACTION_ID
124898 , p_source_1 IN NUMBER
124899 --Item Concatenated Segments
124900 , p_source_2 IN VARCHAR2
124901 --Transaction Quantity
124902 , p_source_3 IN NUMBER
124903 --Transaction Unit of Measure Code
124904 , p_source_4 IN VARCHAR2
124905 --Inventory Transaction Type Description
124906 , p_source_5 IN VARCHAR2
124907 --Cost Element Name
124908 , p_source_15 IN NUMBER
124909 --Product Line Accounting Category Material Account
124910 , p_source_41 IN NUMBER
124911 --Product Line Accounting Category Material Overhead Account
124912 , p_source_42 IN NUMBER
124913 --Product Line Accounting Category Resource Account
124914 , p_source_43 IN NUMBER
124915 --Product Line Accounting Category Outside Processing Account
124916 , p_source_44 IN NUMBER
124917 --Product Line Accounting Category Overhead Account
124918 , p_source_45 IN NUMBER
124919 --DISTRIBUTION_IDENTIFIER
124920 , p_source_84 IN NUMBER
124921 --Distribution Type
124922 , p_source_85 IN VARCHAR2
124923 , p_source_85_meaning IN VARCHAR2
124924 --Entered Currency Code
124925 , p_source_88 IN VARCHAR2
124926 --Entered Amount
124927 , p_source_91 IN NUMBER
124928 --Currency Conversion Date
124929 , p_source_92 IN DATE
124930 --Currency Conversion Rate
124931 , p_source_93 IN NUMBER
124932 --Currency Conversion Type
124933 , p_source_94 IN VARCHAR2
124934 --Accounted Amount
124935 , p_source_95 IN NUMBER
124936 --Accounting Line Type
124937 , p_source_97 IN NUMBER
124938 --Organization Code
124939 , p_source_108 IN VARCHAR2
124940 )
124941 IS
124942
124943 l_component_type VARCHAR2(80);
124944 l_component_code VARCHAR2(30);
124945 l_component_type_code VARCHAR2(1);
124946 l_component_appl_id INTEGER;
124947 l_amb_context_code VARCHAR2(30);
124948 l_entity_code VARCHAR2(30);
124949 l_event_class_code VARCHAR2(30);
124950 l_ae_header_id NUMBER;
124951 l_event_type_code VARCHAR2(30);
124952 l_line_definition_code VARCHAR2(30);
124953 l_line_definition_owner_code VARCHAR2(1);
124954 --
124955 -- adr variables
124956 l_segment VARCHAR2(30);
124957 l_ccid NUMBER;
124958 l_adr_transaction_coa_id NUMBER;
124959 l_adr_accounting_coa_id NUMBER;
124960 l_adr_flexfield_segment_code VARCHAR2(30);
124961 l_adr_flex_value_set_id NUMBER;
124962 l_adr_value_type_code VARCHAR2(30);
124963 l_adr_value_combination_id NUMBER;
124964 l_adr_value_segment_code VARCHAR2(30);
124965
124966 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
124967 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
124968 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
124969 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
124970
124971 -- 4262811 Variables ------------------------------------------------------------------------------------------
124972 l_entered_amt_idx NUMBER;
124973 l_accted_amt_idx NUMBER;
124974 l_acc_rev_flag VARCHAR2(1);
124975 l_accrual_line_num NUMBER;
124976 l_tmp_amt NUMBER;
124977 l_acc_rev_natural_side_code VARCHAR2(1);
124978
124979 l_num_entries NUMBER;
124980 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
124981 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
124982 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
124983 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
124984 l_recog_line_1 NUMBER;
124985 l_recog_line_2 NUMBER;
124986
124987 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
124988 l_bflow_applied_to_amt NUMBER; -- 5132302
124989 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
124990
124991 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
124992
124993 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
124994 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
124995
124996 ---------------------------------------------------------------------------------------------------------------
124997
124998
124999 --
125000 -- bulk performance
125001 --
125002 l_balance_type_code VARCHAR2(1);
125003 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
125004 l_log_module VARCHAR2(240);
125005
125006 --
125007 -- Upgrade strategy
125008 --
125009 l_actual_upg_option VARCHAR2(1);
125010 l_enc_upg_option VARCHAR2(1);
125011
125012 --
125013 BEGIN
125014 --
125015 IF g_log_enabled THEN
125016 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_241';
125017 END IF;
125018 --
125019 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
125020
125021 trace
125022 (p_msg => 'BEGIN of AcctLineType_241'
125023 ,p_level => C_LEVEL_PROCEDURE
125024 ,p_module => l_log_module);
125025
125026 END IF;
125027 --
125028 l_component_type := 'AMB_JLT';
125029 l_component_code := 'INVENTORY_VALUATION';
125030 l_component_type_code := 'S';
125031 l_component_appl_id := 707;
125032 l_amb_context_code := 'DEFAULT';
125033 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
125034 l_event_class_code := 'SALES_ORDER';
125035 l_event_type_code := 'RMA_RETURN';
125036 l_line_definition_owner_code := 'S';
125037 l_line_definition_code := 'PI_RMA_RETURN';
125038 --
125039 l_balance_type_code := 'A';
125040 l_segment := NULL;
125041 l_ccid := NULL;
125042 l_adr_transaction_coa_id := NULL;
125043 l_adr_accounting_coa_id := NULL;
125044 l_adr_flexfield_segment_code := NULL;
125045 l_adr_flex_value_set_id := NULL;
125046 l_adr_value_type_code := NULL;
125047 l_adr_value_combination_id := NULL;
125048 l_adr_value_segment_code := NULL;
125049
125050 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
125051 l_bflow_class_code := ''; -- 4219869 Business Flow
125052 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
125053 l_budgetary_control_flag := 'N';
125054
125055 l_bflow_applied_to_amt_idx := NULL; -- 5132302
125056 l_bflow_applied_to_amt := NULL; -- 5132302
125057 l_entered_amt_idx := NULL; -- 4262811
125058 l_accted_amt_idx := NULL; -- 4262811
125059 l_acc_rev_flag := NULL; -- 4262811
125060 l_accrual_line_num := NULL; -- 4262811
125061 l_tmp_amt := NULL; -- 4262811
125062 --
125063
125064 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
125065 l_balance_type_code <> 'B' THEN
125066 IF NVL(p_source_97,9E125) = 1
125067 THEN
125068
125069 --
125070 XLA_AE_LINES_PKG.SetNewLine;
125071
125072 p_balance_type_code := l_balance_type_code;
125073 -- set the flag so later we will know whether the gain loss line needs to be created
125074
125075 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
125076 p_actual_flag :='A';
125077 END IF;
125078
125079 --
125080 -- bulk performance
125081 --
125082 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
125083 p_header_num => 0); -- 4262811
125084 --
125085 -- set accounting line options
125086 --
125087 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
125088 p_natural_side_code => 'D'
125089 , p_gain_or_loss_flag => 'N'
125090 , p_gl_transfer_mode_code => 'S'
125091 , p_acct_entry_type_code => 'A'
125092 , p_switch_side_flag => 'Y'
125093 , p_merge_duplicate_code => 'N'
125094 );
125095 --
125096 l_acc_rev_natural_side_code := 'C'; -- 4262811
125097 --
125098 --
125099 -- set accounting line type info
125100 --
125101 xla_ae_lines_pkg.SetAcctLineType
125102 (p_component_type => l_component_type
125103 ,p_event_type_code => l_event_type_code
125104 ,p_line_definition_owner_code => l_line_definition_owner_code
125105 ,p_line_definition_code => l_line_definition_code
125106 ,p_accounting_line_code => l_component_code
125107 ,p_accounting_line_type_code => l_component_type_code
125108 ,p_accounting_line_appl_id => l_component_appl_id
125109 ,p_amb_context_code => l_amb_context_code
125110 ,p_entity_code => l_entity_code
125111 ,p_event_class_code => l_event_class_code);
125112 --
125113 -- set accounting class
125114 --
125115 xla_ae_lines_pkg.SetAcctClass(
125116 p_accounting_class_code => 'INVENTORY_VALUATION'
125117 , p_ae_header_id => l_ae_header_id
125118 );
125119
125120 --
125121 -- set rounding class
125122 --
125123 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
125124 'INVENTORY_VALUATION';
125125
125126 --
125127 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
125128 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
125129 --
125130 -- bulk performance
125131 --
125132 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
125133
125134 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
125135 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
125136
125137 -- 4955764
125138 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
125139 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
125140
125141 -- 4458381 Public Sector Enh
125142
125143 --
125144 -- set accounting attributes for the line type
125145 --
125146 l_entered_amt_idx := 3;
125147 l_accted_amt_idx := 8;
125148 l_bflow_applied_to_amt_idx := NULL; -- 5132302
125149 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
125150 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
125151 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
125152 l_rec_acct_attrs.array_char_value(2) := p_source_85;
125153 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
125154 l_rec_acct_attrs.array_num_value(3) := p_source_91;
125155 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
125156 l_rec_acct_attrs.array_char_value(4) := p_source_88;
125157 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
125158 l_rec_acct_attrs.array_date_value(5) := p_source_92;
125159 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
125160 l_rec_acct_attrs.array_num_value(6) := p_source_93;
125161 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
125162 l_rec_acct_attrs.array_char_value(7) := p_source_94;
125163 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
125164 l_rec_acct_attrs.array_num_value(8) := p_source_95;
125165
125166 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
125167 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
125168
125169 ---------------------------------------------------------------------------------------------------------------
125170 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
125171 ---------------------------------------------------------------------------------------------------------------
125172 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
125173
125174 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
125175 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
125176
125177 IF xla_accounting_cache_pkg.GetValueChar
125178 (p_source_code => 'LEDGER_CATEGORY_CODE'
125179 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
125180 AND l_bflow_method_code = 'PRIOR_ENTRY'
125181 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
125182 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
125183 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
125184 )
125185 THEN
125186 xla_ae_lines_pkg.BflowUpgEntry
125187 (p_business_method_code => l_bflow_method_code
125188 ,p_business_class_code => l_bflow_class_code
125189 ,p_balance_type => l_balance_type_code);
125190 ELSE
125191 NULL;
125192 -- No business flow processing for business flow method of NONE.
125193 END IF;
125194
125195 --
125196 -- call analytical criteria
125197 --
125198
125199
125200 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
125201 xla_ae_lines_pkg.SetAnalyticalCriteria(
125202 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
125203 , p_analytical_criterion_owner => 'S'
125204 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
125205 , p_amb_context_code => 'DEFAULT'
125206 , p_balancing_flag => 'Y'
125207
125208 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
125209 , p_analytical_detail_num_1 => NULL
125210 , p_analytical_detail_date_1 => NULL
125211
125212 , p_ae_header_id => l_ae_header_id
125213 )
125214 ;
125215 --
125216
125217 --
125218 -- call description
125219 --
125220
125221 xla_ae_lines_pkg.SetLineDescription(
125222 p_ae_header_id => l_ae_header_id
125223 ,p_description => Description_1 (
125224 p_application_id => p_application_id
125225 , p_ae_header_id => l_ae_header_id
125226 , p_source_1 => p_source_1
125227 , p_source_2 => p_source_2
125228 , p_source_3 => p_source_3
125229 , p_source_4 => p_source_4
125230 , p_source_5 => p_source_5
125231 )
125232 );
125233
125234
125235 --
125236 -- call ADRs
125237 -- Bug 4922099
125238 --
125239 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
125240 (NVL(l_actual_upg_option, 'N') = 'O') OR
125241 (NVL(l_enc_upg_option, 'N') = 'O')
125242 )
125243 THEN
125244 NULL;
125245 --
125246 --
125247
125248 l_ccid := AcctDerRule_28(
125249 p_application_id => p_application_id
125250 , p_ae_header_id => l_ae_header_id
125251 , p_source_15 => p_source_15
125252 , p_source_41 => p_source_41
125253 , p_source_42 => p_source_42
125254 , p_source_43 => p_source_43
125255 , p_source_44 => p_source_44
125256 , p_source_45 => p_source_45
125257 , x_transaction_coa_id => l_adr_transaction_coa_id
125258 , x_accounting_coa_id => l_adr_accounting_coa_id
125259 , x_value_type_code => l_adr_value_type_code
125260 , p_side => 'NA'
125261 );
125262
125263 xla_ae_lines_pkg.set_ccid(
125264 p_code_combination_id => l_ccid
125265 , p_value_type_code => l_adr_value_type_code
125266 , p_transaction_coa_id => l_adr_transaction_coa_id
125267 , p_accounting_coa_id => l_adr_accounting_coa_id
125268 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
125269 , p_adr_type_code => 'S'
125270 , p_component_type => l_component_type
125271 , p_component_code => l_component_code
125272 , p_component_type_code => l_component_type_code
125273 , p_component_appl_id => l_component_appl_id
125274 , p_amb_context_code => l_amb_context_code
125275 , p_side => 'NA'
125276 );
125277
125278
125279 --
125280 --
125281 END IF;
125282 --
125283 -- Bug 4922099
125284 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
125285 (NVL(l_enc_upg_option, 'N') = 'O')
125286 ) AND
125287 (l_bflow_method_code = 'PRIOR_ENTRY')
125288 )
125289 THEN
125290 IF
125291 --
125292 1 = 2
125293 --
125294 THEN
125295 xla_accounting_err_pkg.build_message
125296 (p_appli_s_name => 'XLA'
125297 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
125298 ,p_token_1 => 'LINE_NUMBER'
125299 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
125300 ,p_token_2 => 'LINE_TYPE_NAME'
125301 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
125302 l_component_type
125303 ,l_component_code
125304 ,l_component_type_code
125305 ,l_component_appl_id
125306 ,l_amb_context_code
125307 ,l_entity_code
125308 ,l_event_class_code
125309 )
125310 ,p_token_3 => 'OWNER'
125311 ,p_value_3 => xla_lookups_pkg.get_meaning(
125312 p_lookup_type => 'XLA_OWNER_TYPE'
125313 ,p_lookup_code => l_component_type_code
125314 )
125315 ,p_token_4 => 'PRODUCT_NAME'
125316 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
125317 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
125318 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
125319 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
125320 ,p_ae_header_id => NULL
125321 );
125322
125323 IF (C_LEVEL_ERROR>= g_log_level) THEN
125324 trace
125325 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
125326 ,p_level => C_LEVEL_ERROR
125327 ,p_module => l_log_module);
125328 END IF;
125329 END IF;
125330 END IF;
125331 --
125332 --
125333 ------------------------------------------------------------------------------------------------
125334 -- 4219869 Business Flow
125335 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
125336 -- Prior Entry. Currently, the following code is always generated.
125337 ------------------------------------------------------------------------------------------------
125338 XLA_AE_LINES_PKG.ValidateCurrentLine;
125339
125340 ------------------------------------------------------------------------------------
125341 -- 4219869 Business Flow
125342 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
125343 ------------------------------------------------------------------------------------
125344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
125345
125346 ----------------------------------------------------------------------------------
125347 -- 4219869 Business Flow
125348 -- Update journal entry status -- Need to generate this within IF <condition>
125349 ----------------------------------------------------------------------------------
125350 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
125351 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
125352 ,p_balance_type_code => l_balance_type_code
125353 );
125354
125355 -------------------------------------------------------------------------------------------
125356 -- 4262811 - Generate the Accrual Reversal lines
125357 -------------------------------------------------------------------------------------------
125358 BEGIN
125359 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
125360 (g_array_event(p_event_id).array_value_num('header_index'));
125361 IF l_acc_rev_flag IS NULL THEN
125362 l_acc_rev_flag := 'N';
125363 END IF;
125364 EXCEPTION
125365 WHEN OTHERS THEN
125366 l_acc_rev_flag := 'N';
125367 END;
125368 --
125369 IF (l_acc_rev_flag = 'Y') THEN
125370
125371 -- 4645092 ------------------------------------------------------------------------------
125372 -- To allow MPA report to determine if it should generate report process
125373 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
125374 ------------------------------------------------------------------------------------------
125375
125376 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
125377 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
125378 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
125379 -- call ADRs
125380 -- Bug 4922099
125381 --
125382 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
125383 (NVL(l_actual_upg_option, 'N') = 'O') OR
125384 (NVL(l_enc_upg_option, 'N') = 'O')
125385 )
125386 THEN
125387 NULL;
125388 --
125389 --
125390
125391 l_ccid := AcctDerRule_28(
125392 p_application_id => p_application_id
125393 , p_ae_header_id => l_ae_header_id
125394 , p_source_15 => p_source_15
125395 , p_source_41 => p_source_41
125396 , p_source_42 => p_source_42
125397 , p_source_43 => p_source_43
125398 , p_source_44 => p_source_44
125399 , p_source_45 => p_source_45
125400 , x_transaction_coa_id => l_adr_transaction_coa_id
125401 , x_accounting_coa_id => l_adr_accounting_coa_id
125402 , x_value_type_code => l_adr_value_type_code
125403 , p_side => 'NA'
125404 );
125405
125406 xla_ae_lines_pkg.set_ccid(
125407 p_code_combination_id => l_ccid
125408 , p_value_type_code => l_adr_value_type_code
125409 , p_transaction_coa_id => l_adr_transaction_coa_id
125410 , p_accounting_coa_id => l_adr_accounting_coa_id
125411 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
125412 , p_adr_type_code => 'S'
125413 , p_component_type => l_component_type
125414 , p_component_code => l_component_code
125415 , p_component_type_code => l_component_type_code
125416 , p_component_appl_id => l_component_appl_id
125417 , p_amb_context_code => l_amb_context_code
125418 , p_side => 'NA'
125419 );
125420
125421
125422 --
125423 --
125424 END IF;
125425
125426 --
125427 -- Update the line information that should be overwritten
125428 --
125429 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
125430 p_header_num => 1);
125431 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
125432
125433 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
125434
125435 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
125436 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
125437 END IF;
125438
125439 --
125440 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
125441 --
125442 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
125443 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
125444 ELSE
125445 ---------------------------------------------------------------------------------------------------
125446 -- 4262811a Switch Sign
125447 ---------------------------------------------------------------------------------------------------
125448 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
125449 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
125450 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
125451 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
125452 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
125453 -- 5132302
125454 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
125455 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
125456
125457 END IF;
125458
125459 -- 4955764
125460 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
125461 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
125462
125463
125464 XLA_AE_LINES_PKG.ValidateCurrentLine;
125465 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
125466
125467 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
125468 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
125469 ,p_balance_type_code => l_balance_type_code);
125470
125471 END IF;
125472
125473 -----------------------------------------------------------------------------------------
125474 -- 4262811 Multiperiod Accounting
125475 -----------------------------------------------------------------------------------------
125476 -- No MPA option is assigned.
125477
125478
125479 END IF;
125480 END IF;
125481 --
125482
125483 --
125484 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
125485 trace
125486 (p_msg => 'END of AcctLineType_241'
125487 ,p_level => C_LEVEL_PROCEDURE
125488 ,p_module => l_log_module);
125489 END IF;
125490 --
125491 EXCEPTION
125492 WHEN xla_exceptions_pkg.application_exception THEN
125493 RAISE;
125494 WHEN OTHERS THEN
125495 xla_exceptions_pkg.raise_message
125496 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_241');
125497 END AcctLineType_241;
125498 --
125499
125500 ---------------------------------------
125501 --
125502 -- PRIVATE FUNCTION
125503 -- AcctLineType_242
125504 --
125505 ---------------------------------------
125506 PROCEDURE AcctLineType_242 (
125507 p_application_id IN NUMBER
125508 ,p_event_id IN NUMBER
125509 ,p_calculate_acctd_flag IN VARCHAR2
125510 ,p_calculate_g_l_flag IN VARCHAR2
125511 ,p_actual_flag IN OUT VARCHAR2
125512 ,p_balance_type_code OUT VARCHAR2
125513 ,p_gain_or_loss_ref OUT VARCHAR2
125514
125515 --TRANSACTION_ID
125516 , p_source_1 IN NUMBER
125517 --Item Concatenated Segments
125518 , p_source_2 IN VARCHAR2
125519 --Transaction Quantity
125520 , p_source_3 IN NUMBER
125521 --Transaction Unit of Measure Code
125522 , p_source_4 IN VARCHAR2
125523 --Inventory Transaction Type Description
125524 , p_source_5 IN VARCHAR2
125525 --Cost Element Name
125526 , p_source_15 IN NUMBER
125527 --Product Line Accounting Category Material Account
125528 , p_source_41 IN NUMBER
125529 --Product Line Accounting Category Material Overhead Account
125530 , p_source_42 IN NUMBER
125531 --Product Line Accounting Category Resource Account
125532 , p_source_43 IN NUMBER
125533 --Product Line Accounting Category Outside Processing Account
125534 , p_source_44 IN NUMBER
125535 --Product Line Accounting Category Overhead Account
125536 , p_source_45 IN NUMBER
125537 --DISTRIBUTION_IDENTIFIER
125538 , p_source_84 IN NUMBER
125539 --Distribution Type
125540 , p_source_85 IN VARCHAR2
125541 , p_source_85_meaning IN VARCHAR2
125542 --Entered Currency Code
125543 , p_source_88 IN VARCHAR2
125544 --Entered Amount
125545 , p_source_91 IN NUMBER
125546 --Currency Conversion Date
125547 , p_source_92 IN DATE
125548 --Currency Conversion Rate
125549 , p_source_93 IN NUMBER
125550 --Currency Conversion Type
125551 , p_source_94 IN VARCHAR2
125552 --Accounted Amount
125553 , p_source_95 IN NUMBER
125554 --Accounting Line Type
125555 , p_source_97 IN NUMBER
125556 --Organization Code
125557 , p_source_108 IN VARCHAR2
125558 )
125559 IS
125560
125561 l_component_type VARCHAR2(80);
125562 l_component_code VARCHAR2(30);
125563 l_component_type_code VARCHAR2(1);
125564 l_component_appl_id INTEGER;
125565 l_amb_context_code VARCHAR2(30);
125566 l_entity_code VARCHAR2(30);
125567 l_event_class_code VARCHAR2(30);
125568 l_ae_header_id NUMBER;
125569 l_event_type_code VARCHAR2(30);
125570 l_line_definition_code VARCHAR2(30);
125571 l_line_definition_owner_code VARCHAR2(1);
125572 --
125573 -- adr variables
125574 l_segment VARCHAR2(30);
125575 l_ccid NUMBER;
125576 l_adr_transaction_coa_id NUMBER;
125577 l_adr_accounting_coa_id NUMBER;
125578 l_adr_flexfield_segment_code VARCHAR2(30);
125579 l_adr_flex_value_set_id NUMBER;
125580 l_adr_value_type_code VARCHAR2(30);
125581 l_adr_value_combination_id NUMBER;
125582 l_adr_value_segment_code VARCHAR2(30);
125583
125584 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
125585 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
125586 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
125587 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
125588
125589 -- 4262811 Variables ------------------------------------------------------------------------------------------
125590 l_entered_amt_idx NUMBER;
125591 l_accted_amt_idx NUMBER;
125592 l_acc_rev_flag VARCHAR2(1);
125593 l_accrual_line_num NUMBER;
125594 l_tmp_amt NUMBER;
125595 l_acc_rev_natural_side_code VARCHAR2(1);
125596
125597 l_num_entries NUMBER;
125598 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
125599 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
125600 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
125601 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
125602 l_recog_line_1 NUMBER;
125603 l_recog_line_2 NUMBER;
125604
125605 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
125606 l_bflow_applied_to_amt NUMBER; -- 5132302
125607 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
125608
125609 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
125610
125611 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
125612 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
125613
125614 ---------------------------------------------------------------------------------------------------------------
125615
125616
125617 --
125618 -- bulk performance
125619 --
125620 l_balance_type_code VARCHAR2(1);
125621 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
125622 l_log_module VARCHAR2(240);
125623
125624 --
125625 -- Upgrade strategy
125626 --
125627 l_actual_upg_option VARCHAR2(1);
125628 l_enc_upg_option VARCHAR2(1);
125629
125630 --
125631 BEGIN
125632 --
125633 IF g_log_enabled THEN
125634 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_242';
125635 END IF;
125636 --
125637 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
125638
125639 trace
125640 (p_msg => 'BEGIN of AcctLineType_242'
125641 ,p_level => C_LEVEL_PROCEDURE
125642 ,p_module => l_log_module);
125643
125644 END IF;
125645 --
125646 l_component_type := 'AMB_JLT';
125647 l_component_code := 'INVENTORY_VALUATION';
125648 l_component_type_code := 'S';
125649 l_component_appl_id := 707;
125650 l_amb_context_code := 'DEFAULT';
125651 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
125652 l_event_class_code := 'SALES_ORDER';
125653 l_event_type_code := 'SO_ISSUE';
125654 l_line_definition_owner_code := 'S';
125655 l_line_definition_code := 'PI_SO_ISSUE';
125656 --
125657 l_balance_type_code := 'A';
125658 l_segment := NULL;
125659 l_ccid := NULL;
125660 l_adr_transaction_coa_id := NULL;
125661 l_adr_accounting_coa_id := NULL;
125662 l_adr_flexfield_segment_code := NULL;
125663 l_adr_flex_value_set_id := NULL;
125664 l_adr_value_type_code := NULL;
125665 l_adr_value_combination_id := NULL;
125666 l_adr_value_segment_code := NULL;
125667
125668 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
125669 l_bflow_class_code := ''; -- 4219869 Business Flow
125670 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
125671 l_budgetary_control_flag := 'N';
125672
125673 l_bflow_applied_to_amt_idx := NULL; -- 5132302
125674 l_bflow_applied_to_amt := NULL; -- 5132302
125675 l_entered_amt_idx := NULL; -- 4262811
125676 l_accted_amt_idx := NULL; -- 4262811
125677 l_acc_rev_flag := NULL; -- 4262811
125678 l_accrual_line_num := NULL; -- 4262811
125679 l_tmp_amt := NULL; -- 4262811
125680 --
125681
125682 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
125683 l_balance_type_code <> 'B' THEN
125684 IF NVL(p_source_97,9E125) = 1
125685 THEN
125686
125687 --
125688 XLA_AE_LINES_PKG.SetNewLine;
125689
125690 p_balance_type_code := l_balance_type_code;
125691 -- set the flag so later we will know whether the gain loss line needs to be created
125692
125693 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
125694 p_actual_flag :='A';
125695 END IF;
125696
125697 --
125698 -- bulk performance
125699 --
125700 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
125701 p_header_num => 0); -- 4262811
125702 --
125703 -- set accounting line options
125704 --
125705 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
125706 p_natural_side_code => 'D'
125707 , p_gain_or_loss_flag => 'N'
125708 , p_gl_transfer_mode_code => 'S'
125709 , p_acct_entry_type_code => 'A'
125710 , p_switch_side_flag => 'Y'
125711 , p_merge_duplicate_code => 'N'
125712 );
125713 --
125714 l_acc_rev_natural_side_code := 'C'; -- 4262811
125715 --
125716 --
125717 -- set accounting line type info
125718 --
125719 xla_ae_lines_pkg.SetAcctLineType
125720 (p_component_type => l_component_type
125721 ,p_event_type_code => l_event_type_code
125722 ,p_line_definition_owner_code => l_line_definition_owner_code
125723 ,p_line_definition_code => l_line_definition_code
125724 ,p_accounting_line_code => l_component_code
125725 ,p_accounting_line_type_code => l_component_type_code
125726 ,p_accounting_line_appl_id => l_component_appl_id
125727 ,p_amb_context_code => l_amb_context_code
125728 ,p_entity_code => l_entity_code
125729 ,p_event_class_code => l_event_class_code);
125730 --
125731 -- set accounting class
125732 --
125733 xla_ae_lines_pkg.SetAcctClass(
125734 p_accounting_class_code => 'INVENTORY_VALUATION'
125735 , p_ae_header_id => l_ae_header_id
125736 );
125737
125738 --
125739 -- set rounding class
125740 --
125741 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
125742 'INVENTORY_VALUATION';
125743
125744 --
125745 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
125746 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
125747 --
125748 -- bulk performance
125749 --
125750 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
125751
125752 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
125753 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
125754
125755 -- 4955764
125756 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
125757 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
125758
125759 -- 4458381 Public Sector Enh
125760
125761 --
125762 -- set accounting attributes for the line type
125763 --
125764 l_entered_amt_idx := 3;
125765 l_accted_amt_idx := 8;
125766 l_bflow_applied_to_amt_idx := NULL; -- 5132302
125767 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
125768 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
125769 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
125770 l_rec_acct_attrs.array_char_value(2) := p_source_85;
125771 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
125772 l_rec_acct_attrs.array_num_value(3) := p_source_91;
125773 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
125774 l_rec_acct_attrs.array_char_value(4) := p_source_88;
125775 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
125776 l_rec_acct_attrs.array_date_value(5) := p_source_92;
125777 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
125778 l_rec_acct_attrs.array_num_value(6) := p_source_93;
125779 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
125780 l_rec_acct_attrs.array_char_value(7) := p_source_94;
125781 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
125782 l_rec_acct_attrs.array_num_value(8) := p_source_95;
125783
125784 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
125785 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
125786
125787 ---------------------------------------------------------------------------------------------------------------
125788 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
125789 ---------------------------------------------------------------------------------------------------------------
125790 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
125791
125792 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
125793 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
125794
125795 IF xla_accounting_cache_pkg.GetValueChar
125796 (p_source_code => 'LEDGER_CATEGORY_CODE'
125797 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
125798 AND l_bflow_method_code = 'PRIOR_ENTRY'
125799 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
125800 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
125801 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
125802 )
125803 THEN
125804 xla_ae_lines_pkg.BflowUpgEntry
125805 (p_business_method_code => l_bflow_method_code
125806 ,p_business_class_code => l_bflow_class_code
125807 ,p_balance_type => l_balance_type_code);
125808 ELSE
125809 NULL;
125810 -- No business flow processing for business flow method of NONE.
125811 END IF;
125812
125813 --
125814 -- call analytical criteria
125815 --
125816
125817
125818 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
125819 xla_ae_lines_pkg.SetAnalyticalCriteria(
125820 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
125821 , p_analytical_criterion_owner => 'S'
125822 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
125823 , p_amb_context_code => 'DEFAULT'
125824 , p_balancing_flag => 'Y'
125825
125826 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
125827 , p_analytical_detail_num_1 => NULL
125828 , p_analytical_detail_date_1 => NULL
125829
125830 , p_ae_header_id => l_ae_header_id
125831 )
125832 ;
125833 --
125834
125835 --
125836 -- call description
125837 --
125838
125839 xla_ae_lines_pkg.SetLineDescription(
125840 p_ae_header_id => l_ae_header_id
125841 ,p_description => Description_1 (
125842 p_application_id => p_application_id
125843 , p_ae_header_id => l_ae_header_id
125844 , p_source_1 => p_source_1
125845 , p_source_2 => p_source_2
125846 , p_source_3 => p_source_3
125847 , p_source_4 => p_source_4
125848 , p_source_5 => p_source_5
125849 )
125850 );
125851
125852
125853 --
125854 -- call ADRs
125855 -- Bug 4922099
125856 --
125857 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
125858 (NVL(l_actual_upg_option, 'N') = 'O') OR
125859 (NVL(l_enc_upg_option, 'N') = 'O')
125860 )
125861 THEN
125862 NULL;
125863 --
125864 --
125865
125866 l_ccid := AcctDerRule_28(
125867 p_application_id => p_application_id
125868 , p_ae_header_id => l_ae_header_id
125869 , p_source_15 => p_source_15
125870 , p_source_41 => p_source_41
125871 , p_source_42 => p_source_42
125872 , p_source_43 => p_source_43
125873 , p_source_44 => p_source_44
125874 , p_source_45 => p_source_45
125875 , x_transaction_coa_id => l_adr_transaction_coa_id
125876 , x_accounting_coa_id => l_adr_accounting_coa_id
125877 , x_value_type_code => l_adr_value_type_code
125878 , p_side => 'NA'
125879 );
125880
125881 xla_ae_lines_pkg.set_ccid(
125882 p_code_combination_id => l_ccid
125883 , p_value_type_code => l_adr_value_type_code
125884 , p_transaction_coa_id => l_adr_transaction_coa_id
125885 , p_accounting_coa_id => l_adr_accounting_coa_id
125886 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
125887 , p_adr_type_code => 'S'
125888 , p_component_type => l_component_type
125889 , p_component_code => l_component_code
125890 , p_component_type_code => l_component_type_code
125891 , p_component_appl_id => l_component_appl_id
125892 , p_amb_context_code => l_amb_context_code
125893 , p_side => 'NA'
125894 );
125895
125896
125897 --
125898 --
125899 END IF;
125900 --
125901 -- Bug 4922099
125902 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
125903 (NVL(l_enc_upg_option, 'N') = 'O')
125904 ) AND
125905 (l_bflow_method_code = 'PRIOR_ENTRY')
125906 )
125907 THEN
125908 IF
125909 --
125910 1 = 2
125911 --
125912 THEN
125913 xla_accounting_err_pkg.build_message
125914 (p_appli_s_name => 'XLA'
125915 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
125916 ,p_token_1 => 'LINE_NUMBER'
125917 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
125918 ,p_token_2 => 'LINE_TYPE_NAME'
125919 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
125920 l_component_type
125921 ,l_component_code
125922 ,l_component_type_code
125923 ,l_component_appl_id
125924 ,l_amb_context_code
125925 ,l_entity_code
125926 ,l_event_class_code
125927 )
125928 ,p_token_3 => 'OWNER'
125929 ,p_value_3 => xla_lookups_pkg.get_meaning(
125930 p_lookup_type => 'XLA_OWNER_TYPE'
125931 ,p_lookup_code => l_component_type_code
125932 )
125933 ,p_token_4 => 'PRODUCT_NAME'
125934 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
125935 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
125936 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
125937 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
125938 ,p_ae_header_id => NULL
125939 );
125940
125941 IF (C_LEVEL_ERROR>= g_log_level) THEN
125942 trace
125943 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
125944 ,p_level => C_LEVEL_ERROR
125945 ,p_module => l_log_module);
125946 END IF;
125947 END IF;
125948 END IF;
125949 --
125950 --
125951 ------------------------------------------------------------------------------------------------
125952 -- 4219869 Business Flow
125953 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
125954 -- Prior Entry. Currently, the following code is always generated.
125955 ------------------------------------------------------------------------------------------------
125956 XLA_AE_LINES_PKG.ValidateCurrentLine;
125957
125958 ------------------------------------------------------------------------------------
125959 -- 4219869 Business Flow
125960 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
125961 ------------------------------------------------------------------------------------
125962 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
125963
125964 ----------------------------------------------------------------------------------
125965 -- 4219869 Business Flow
125966 -- Update journal entry status -- Need to generate this within IF <condition>
125967 ----------------------------------------------------------------------------------
125968 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
125969 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
125970 ,p_balance_type_code => l_balance_type_code
125971 );
125972
125973 -------------------------------------------------------------------------------------------
125974 -- 4262811 - Generate the Accrual Reversal lines
125975 -------------------------------------------------------------------------------------------
125976 BEGIN
125977 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
125978 (g_array_event(p_event_id).array_value_num('header_index'));
125979 IF l_acc_rev_flag IS NULL THEN
125980 l_acc_rev_flag := 'N';
125981 END IF;
125982 EXCEPTION
125983 WHEN OTHERS THEN
125984 l_acc_rev_flag := 'N';
125985 END;
125986 --
125987 IF (l_acc_rev_flag = 'Y') THEN
125988
125989 -- 4645092 ------------------------------------------------------------------------------
125990 -- To allow MPA report to determine if it should generate report process
125991 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
125992 ------------------------------------------------------------------------------------------
125993
125994 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
125995 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
125996 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
125997 -- call ADRs
125998 -- Bug 4922099
125999 --
126000 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
126001 (NVL(l_actual_upg_option, 'N') = 'O') OR
126002 (NVL(l_enc_upg_option, 'N') = 'O')
126003 )
126004 THEN
126005 NULL;
126006 --
126007 --
126008
126009 l_ccid := AcctDerRule_28(
126010 p_application_id => p_application_id
126011 , p_ae_header_id => l_ae_header_id
126012 , p_source_15 => p_source_15
126013 , p_source_41 => p_source_41
126014 , p_source_42 => p_source_42
126015 , p_source_43 => p_source_43
126016 , p_source_44 => p_source_44
126017 , p_source_45 => p_source_45
126018 , x_transaction_coa_id => l_adr_transaction_coa_id
126019 , x_accounting_coa_id => l_adr_accounting_coa_id
126020 , x_value_type_code => l_adr_value_type_code
126021 , p_side => 'NA'
126022 );
126023
126024 xla_ae_lines_pkg.set_ccid(
126025 p_code_combination_id => l_ccid
126026 , p_value_type_code => l_adr_value_type_code
126027 , p_transaction_coa_id => l_adr_transaction_coa_id
126028 , p_accounting_coa_id => l_adr_accounting_coa_id
126029 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
126030 , p_adr_type_code => 'S'
126031 , p_component_type => l_component_type
126032 , p_component_code => l_component_code
126033 , p_component_type_code => l_component_type_code
126034 , p_component_appl_id => l_component_appl_id
126035 , p_amb_context_code => l_amb_context_code
126036 , p_side => 'NA'
126037 );
126038
126039
126040 --
126041 --
126042 END IF;
126043
126044 --
126045 -- Update the line information that should be overwritten
126046 --
126047 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
126048 p_header_num => 1);
126049 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
126050
126051 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
126052
126053 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
126054 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
126055 END IF;
126056
126057 --
126058 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
126059 --
126060 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
126061 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
126062 ELSE
126063 ---------------------------------------------------------------------------------------------------
126064 -- 4262811a Switch Sign
126065 ---------------------------------------------------------------------------------------------------
126066 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
126067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
126068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
126070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126071 -- 5132302
126072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
126073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126074
126075 END IF;
126076
126077 -- 4955764
126078 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
126079 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
126080
126081
126082 XLA_AE_LINES_PKG.ValidateCurrentLine;
126083 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
126084
126085 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
126086 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
126087 ,p_balance_type_code => l_balance_type_code);
126088
126089 END IF;
126090
126091 -----------------------------------------------------------------------------------------
126092 -- 4262811 Multiperiod Accounting
126093 -----------------------------------------------------------------------------------------
126094 -- No MPA option is assigned.
126095
126096
126097 END IF;
126098 END IF;
126099 --
126100
126101 --
126102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
126103 trace
126104 (p_msg => 'END of AcctLineType_242'
126105 ,p_level => C_LEVEL_PROCEDURE
126106 ,p_module => l_log_module);
126107 END IF;
126108 --
126109 EXCEPTION
126110 WHEN xla_exceptions_pkg.application_exception THEN
126111 RAISE;
126112 WHEN OTHERS THEN
126113 xla_exceptions_pkg.raise_message
126114 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_242');
126115 END AcctLineType_242;
126116 --
126117
126118 ---------------------------------------
126119 --
126120 -- PRIVATE FUNCTION
126121 -- AcctLineType_243
126122 --
126123 ---------------------------------------
126124 PROCEDURE AcctLineType_243 (
126125 p_application_id IN NUMBER
126126 ,p_event_id IN NUMBER
126127 ,p_calculate_acctd_flag IN VARCHAR2
126128 ,p_calculate_g_l_flag IN VARCHAR2
126129 ,p_actual_flag IN OUT VARCHAR2
126130 ,p_balance_type_code OUT VARCHAR2
126131 ,p_gain_or_loss_ref OUT VARCHAR2
126132
126133 --TRANSACTION_ID
126134 , p_source_1 IN NUMBER
126135 --Item Concatenated Segments
126136 , p_source_2 IN VARCHAR2
126137 --Transaction Quantity
126138 , p_source_3 IN NUMBER
126139 --Transaction Unit of Measure Code
126140 , p_source_4 IN VARCHAR2
126141 --Inventory Transaction Type Description
126142 , p_source_5 IN VARCHAR2
126143 --Cost Element Name
126144 , p_source_15 IN NUMBER
126145 --Product Line Accounting Category Material Account
126146 , p_source_41 IN NUMBER
126147 --Product Line Accounting Category Material Overhead Account
126148 , p_source_42 IN NUMBER
126149 --Product Line Accounting Category Resource Account
126150 , p_source_43 IN NUMBER
126151 --Product Line Accounting Category Outside Processing Account
126152 , p_source_44 IN NUMBER
126153 --Product Line Accounting Category Overhead Account
126154 , p_source_45 IN NUMBER
126155 --DISTRIBUTION_IDENTIFIER
126156 , p_source_84 IN NUMBER
126157 --Distribution Type
126158 , p_source_85 IN VARCHAR2
126159 , p_source_85_meaning IN VARCHAR2
126160 --Entered Currency Code
126161 , p_source_88 IN VARCHAR2
126162 --Entered Amount
126163 , p_source_91 IN NUMBER
126164 --Currency Conversion Date
126165 , p_source_92 IN DATE
126166 --Currency Conversion Rate
126167 , p_source_93 IN NUMBER
126168 --Currency Conversion Type
126169 , p_source_94 IN VARCHAR2
126170 --Accounted Amount
126171 , p_source_95 IN NUMBER
126172 --Accounting Line Type
126173 , p_source_97 IN NUMBER
126174 --Organization Code
126175 , p_source_108 IN VARCHAR2
126176 )
126177 IS
126178
126179 l_component_type VARCHAR2(80);
126180 l_component_code VARCHAR2(30);
126181 l_component_type_code VARCHAR2(1);
126182 l_component_appl_id INTEGER;
126183 l_amb_context_code VARCHAR2(30);
126184 l_entity_code VARCHAR2(30);
126185 l_event_class_code VARCHAR2(30);
126186 l_ae_header_id NUMBER;
126187 l_event_type_code VARCHAR2(30);
126188 l_line_definition_code VARCHAR2(30);
126189 l_line_definition_owner_code VARCHAR2(1);
126190 --
126191 -- adr variables
126192 l_segment VARCHAR2(30);
126193 l_ccid NUMBER;
126194 l_adr_transaction_coa_id NUMBER;
126195 l_adr_accounting_coa_id NUMBER;
126196 l_adr_flexfield_segment_code VARCHAR2(30);
126197 l_adr_flex_value_set_id NUMBER;
126198 l_adr_value_type_code VARCHAR2(30);
126199 l_adr_value_combination_id NUMBER;
126200 l_adr_value_segment_code VARCHAR2(30);
126201
126202 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
126203 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
126204 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
126205 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
126206
126207 -- 4262811 Variables ------------------------------------------------------------------------------------------
126208 l_entered_amt_idx NUMBER;
126209 l_accted_amt_idx NUMBER;
126210 l_acc_rev_flag VARCHAR2(1);
126211 l_accrual_line_num NUMBER;
126212 l_tmp_amt NUMBER;
126213 l_acc_rev_natural_side_code VARCHAR2(1);
126214
126215 l_num_entries NUMBER;
126216 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
126217 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
126218 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
126219 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
126220 l_recog_line_1 NUMBER;
126221 l_recog_line_2 NUMBER;
126222
126223 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
126224 l_bflow_applied_to_amt NUMBER; -- 5132302
126225 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
126226
126227 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
126228
126229 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
126230 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
126231
126232 ---------------------------------------------------------------------------------------------------------------
126233
126234
126235 --
126236 -- bulk performance
126237 --
126238 l_balance_type_code VARCHAR2(1);
126239 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
126240 l_log_module VARCHAR2(240);
126241
126242 --
126243 -- Upgrade strategy
126244 --
126245 l_actual_upg_option VARCHAR2(1);
126246 l_enc_upg_option VARCHAR2(1);
126247
126248 --
126249 BEGIN
126250 --
126251 IF g_log_enabled THEN
126252 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_243';
126253 END IF;
126254 --
126255 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
126256
126257 trace
126258 (p_msg => 'BEGIN of AcctLineType_243'
126259 ,p_level => C_LEVEL_PROCEDURE
126260 ,p_module => l_log_module);
126261
126262 END IF;
126263 --
126264 l_component_type := 'AMB_JLT';
126265 l_component_code := 'INVENTORY_VALUATION';
126266 l_component_type_code := 'S';
126267 l_component_appl_id := 707;
126268 l_amb_context_code := 'DEFAULT';
126269 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
126270 l_event_class_code := 'USER_DEFINE';
126271 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
126272 l_line_definition_owner_code := 'S';
126273 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
126274 --
126275 l_balance_type_code := 'A';
126276 l_segment := NULL;
126277 l_ccid := NULL;
126278 l_adr_transaction_coa_id := NULL;
126279 l_adr_accounting_coa_id := NULL;
126280 l_adr_flexfield_segment_code := NULL;
126281 l_adr_flex_value_set_id := NULL;
126282 l_adr_value_type_code := NULL;
126283 l_adr_value_combination_id := NULL;
126284 l_adr_value_segment_code := NULL;
126285
126286 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
126287 l_bflow_class_code := ''; -- 4219869 Business Flow
126288 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
126289 l_budgetary_control_flag := 'N';
126290
126291 l_bflow_applied_to_amt_idx := NULL; -- 5132302
126292 l_bflow_applied_to_amt := NULL; -- 5132302
126293 l_entered_amt_idx := NULL; -- 4262811
126294 l_accted_amt_idx := NULL; -- 4262811
126295 l_acc_rev_flag := NULL; -- 4262811
126296 l_accrual_line_num := NULL; -- 4262811
126297 l_tmp_amt := NULL; -- 4262811
126298 --
126299
126300 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
126301 l_balance_type_code <> 'B' THEN
126302 IF NVL(p_source_97,9E125) = 1
126303 THEN
126304
126305 --
126306 XLA_AE_LINES_PKG.SetNewLine;
126307
126308 p_balance_type_code := l_balance_type_code;
126309 -- set the flag so later we will know whether the gain loss line needs to be created
126310
126311 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
126312 p_actual_flag :='A';
126313 END IF;
126314
126315 --
126316 -- bulk performance
126317 --
126318 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
126319 p_header_num => 0); -- 4262811
126320 --
126321 -- set accounting line options
126322 --
126323 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
126324 p_natural_side_code => 'D'
126325 , p_gain_or_loss_flag => 'N'
126326 , p_gl_transfer_mode_code => 'S'
126327 , p_acct_entry_type_code => 'A'
126328 , p_switch_side_flag => 'Y'
126329 , p_merge_duplicate_code => 'N'
126330 );
126331 --
126332 l_acc_rev_natural_side_code := 'C'; -- 4262811
126333 --
126334 --
126335 -- set accounting line type info
126336 --
126337 xla_ae_lines_pkg.SetAcctLineType
126338 (p_component_type => l_component_type
126339 ,p_event_type_code => l_event_type_code
126340 ,p_line_definition_owner_code => l_line_definition_owner_code
126341 ,p_line_definition_code => l_line_definition_code
126342 ,p_accounting_line_code => l_component_code
126343 ,p_accounting_line_type_code => l_component_type_code
126344 ,p_accounting_line_appl_id => l_component_appl_id
126345 ,p_amb_context_code => l_amb_context_code
126346 ,p_entity_code => l_entity_code
126347 ,p_event_class_code => l_event_class_code);
126348 --
126349 -- set accounting class
126350 --
126351 xla_ae_lines_pkg.SetAcctClass(
126352 p_accounting_class_code => 'INVENTORY_VALUATION'
126353 , p_ae_header_id => l_ae_header_id
126354 );
126355
126356 --
126357 -- set rounding class
126358 --
126359 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
126360 'INVENTORY_VALUATION';
126361
126362 --
126363 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
126364 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
126365 --
126366 -- bulk performance
126367 --
126368 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
126369
126370 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
126371 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
126372
126373 -- 4955764
126374 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
126375 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
126376
126377 -- 4458381 Public Sector Enh
126378
126379 --
126380 -- set accounting attributes for the line type
126381 --
126382 l_entered_amt_idx := 3;
126383 l_accted_amt_idx := 8;
126384 l_bflow_applied_to_amt_idx := NULL; -- 5132302
126385 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
126386 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
126387 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
126388 l_rec_acct_attrs.array_char_value(2) := p_source_85;
126389 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
126390 l_rec_acct_attrs.array_num_value(3) := p_source_91;
126391 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
126392 l_rec_acct_attrs.array_char_value(4) := p_source_88;
126393 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
126394 l_rec_acct_attrs.array_date_value(5) := p_source_92;
126395 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
126396 l_rec_acct_attrs.array_num_value(6) := p_source_93;
126397 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
126398 l_rec_acct_attrs.array_char_value(7) := p_source_94;
126399 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
126400 l_rec_acct_attrs.array_num_value(8) := p_source_95;
126401
126402 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
126403 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
126404
126405 ---------------------------------------------------------------------------------------------------------------
126406 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
126407 ---------------------------------------------------------------------------------------------------------------
126408 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
126409
126410 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
126411 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
126412
126413 IF xla_accounting_cache_pkg.GetValueChar
126414 (p_source_code => 'LEDGER_CATEGORY_CODE'
126415 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
126416 AND l_bflow_method_code = 'PRIOR_ENTRY'
126417 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
126418 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
126419 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
126420 )
126421 THEN
126422 xla_ae_lines_pkg.BflowUpgEntry
126423 (p_business_method_code => l_bflow_method_code
126424 ,p_business_class_code => l_bflow_class_code
126425 ,p_balance_type => l_balance_type_code);
126426 ELSE
126427 NULL;
126428 -- No business flow processing for business flow method of NONE.
126429 END IF;
126430
126431 --
126432 -- call analytical criteria
126433 --
126434
126435
126436 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
126437 xla_ae_lines_pkg.SetAnalyticalCriteria(
126438 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
126439 , p_analytical_criterion_owner => 'S'
126440 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
126441 , p_amb_context_code => 'DEFAULT'
126442 , p_balancing_flag => 'Y'
126443
126444 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
126445 , p_analytical_detail_num_1 => NULL
126446 , p_analytical_detail_date_1 => NULL
126447
126448 , p_ae_header_id => l_ae_header_id
126449 )
126450 ;
126451 --
126452
126453 --
126454 -- call description
126455 --
126456
126457 xla_ae_lines_pkg.SetLineDescription(
126458 p_ae_header_id => l_ae_header_id
126459 ,p_description => Description_1 (
126460 p_application_id => p_application_id
126461 , p_ae_header_id => l_ae_header_id
126462 , p_source_1 => p_source_1
126463 , p_source_2 => p_source_2
126464 , p_source_3 => p_source_3
126465 , p_source_4 => p_source_4
126466 , p_source_5 => p_source_5
126467 )
126468 );
126469
126470
126471 --
126472 -- call ADRs
126473 -- Bug 4922099
126474 --
126475 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
126476 (NVL(l_actual_upg_option, 'N') = 'O') OR
126477 (NVL(l_enc_upg_option, 'N') = 'O')
126478 )
126479 THEN
126480 NULL;
126481 --
126482 --
126483
126484 l_ccid := AcctDerRule_28(
126485 p_application_id => p_application_id
126486 , p_ae_header_id => l_ae_header_id
126487 , p_source_15 => p_source_15
126488 , p_source_41 => p_source_41
126489 , p_source_42 => p_source_42
126490 , p_source_43 => p_source_43
126491 , p_source_44 => p_source_44
126492 , p_source_45 => p_source_45
126493 , x_transaction_coa_id => l_adr_transaction_coa_id
126494 , x_accounting_coa_id => l_adr_accounting_coa_id
126495 , x_value_type_code => l_adr_value_type_code
126496 , p_side => 'NA'
126497 );
126498
126499 xla_ae_lines_pkg.set_ccid(
126500 p_code_combination_id => l_ccid
126501 , p_value_type_code => l_adr_value_type_code
126502 , p_transaction_coa_id => l_adr_transaction_coa_id
126503 , p_accounting_coa_id => l_adr_accounting_coa_id
126504 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
126505 , p_adr_type_code => 'S'
126506 , p_component_type => l_component_type
126507 , p_component_code => l_component_code
126508 , p_component_type_code => l_component_type_code
126509 , p_component_appl_id => l_component_appl_id
126510 , p_amb_context_code => l_amb_context_code
126511 , p_side => 'NA'
126512 );
126513
126514
126515 --
126516 --
126517 END IF;
126518 --
126519 -- Bug 4922099
126520 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
126521 (NVL(l_enc_upg_option, 'N') = 'O')
126522 ) AND
126523 (l_bflow_method_code = 'PRIOR_ENTRY')
126524 )
126525 THEN
126526 IF
126527 --
126528 1 = 2
126529 --
126530 THEN
126531 xla_accounting_err_pkg.build_message
126532 (p_appli_s_name => 'XLA'
126533 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
126534 ,p_token_1 => 'LINE_NUMBER'
126535 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
126536 ,p_token_2 => 'LINE_TYPE_NAME'
126537 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
126538 l_component_type
126539 ,l_component_code
126540 ,l_component_type_code
126541 ,l_component_appl_id
126542 ,l_amb_context_code
126543 ,l_entity_code
126544 ,l_event_class_code
126545 )
126546 ,p_token_3 => 'OWNER'
126547 ,p_value_3 => xla_lookups_pkg.get_meaning(
126548 p_lookup_type => 'XLA_OWNER_TYPE'
126549 ,p_lookup_code => l_component_type_code
126550 )
126551 ,p_token_4 => 'PRODUCT_NAME'
126552 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
126553 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
126554 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
126555 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
126556 ,p_ae_header_id => NULL
126557 );
126558
126559 IF (C_LEVEL_ERROR>= g_log_level) THEN
126560 trace
126561 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
126562 ,p_level => C_LEVEL_ERROR
126563 ,p_module => l_log_module);
126564 END IF;
126565 END IF;
126566 END IF;
126567 --
126568 --
126569 ------------------------------------------------------------------------------------------------
126570 -- 4219869 Business Flow
126571 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
126572 -- Prior Entry. Currently, the following code is always generated.
126573 ------------------------------------------------------------------------------------------------
126574 XLA_AE_LINES_PKG.ValidateCurrentLine;
126575
126576 ------------------------------------------------------------------------------------
126577 -- 4219869 Business Flow
126578 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
126579 ------------------------------------------------------------------------------------
126580 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
126581
126582 ----------------------------------------------------------------------------------
126583 -- 4219869 Business Flow
126584 -- Update journal entry status -- Need to generate this within IF <condition>
126585 ----------------------------------------------------------------------------------
126586 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
126587 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
126588 ,p_balance_type_code => l_balance_type_code
126589 );
126590
126591 -------------------------------------------------------------------------------------------
126592 -- 4262811 - Generate the Accrual Reversal lines
126593 -------------------------------------------------------------------------------------------
126594 BEGIN
126595 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
126596 (g_array_event(p_event_id).array_value_num('header_index'));
126597 IF l_acc_rev_flag IS NULL THEN
126598 l_acc_rev_flag := 'N';
126599 END IF;
126600 EXCEPTION
126601 WHEN OTHERS THEN
126602 l_acc_rev_flag := 'N';
126603 END;
126604 --
126605 IF (l_acc_rev_flag = 'Y') THEN
126606
126607 -- 4645092 ------------------------------------------------------------------------------
126608 -- To allow MPA report to determine if it should generate report process
126609 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
126610 ------------------------------------------------------------------------------------------
126611
126612 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
126613 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
126614 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
126615 -- call ADRs
126616 -- Bug 4922099
126617 --
126618 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
126619 (NVL(l_actual_upg_option, 'N') = 'O') OR
126620 (NVL(l_enc_upg_option, 'N') = 'O')
126621 )
126622 THEN
126623 NULL;
126624 --
126625 --
126626
126627 l_ccid := AcctDerRule_28(
126628 p_application_id => p_application_id
126629 , p_ae_header_id => l_ae_header_id
126630 , p_source_15 => p_source_15
126631 , p_source_41 => p_source_41
126632 , p_source_42 => p_source_42
126633 , p_source_43 => p_source_43
126634 , p_source_44 => p_source_44
126635 , p_source_45 => p_source_45
126636 , x_transaction_coa_id => l_adr_transaction_coa_id
126637 , x_accounting_coa_id => l_adr_accounting_coa_id
126638 , x_value_type_code => l_adr_value_type_code
126639 , p_side => 'NA'
126640 );
126641
126642 xla_ae_lines_pkg.set_ccid(
126643 p_code_combination_id => l_ccid
126644 , p_value_type_code => l_adr_value_type_code
126645 , p_transaction_coa_id => l_adr_transaction_coa_id
126646 , p_accounting_coa_id => l_adr_accounting_coa_id
126647 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
126648 , p_adr_type_code => 'S'
126649 , p_component_type => l_component_type
126650 , p_component_code => l_component_code
126651 , p_component_type_code => l_component_type_code
126652 , p_component_appl_id => l_component_appl_id
126653 , p_amb_context_code => l_amb_context_code
126654 , p_side => 'NA'
126655 );
126656
126657
126658 --
126659 --
126660 END IF;
126661
126662 --
126663 -- Update the line information that should be overwritten
126664 --
126665 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
126666 p_header_num => 1);
126667 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
126668
126669 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
126670
126671 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
126672 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
126673 END IF;
126674
126675 --
126676 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
126677 --
126678 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
126679 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
126680 ELSE
126681 ---------------------------------------------------------------------------------------------------
126682 -- 4262811a Switch Sign
126683 ---------------------------------------------------------------------------------------------------
126684 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
126685 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
126686 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126687 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
126688 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126689 -- 5132302
126690 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
126691 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
126692
126693 END IF;
126694
126695 -- 4955764
126696 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
126697 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
126698
126699
126700 XLA_AE_LINES_PKG.ValidateCurrentLine;
126701 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
126702
126703 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
126704 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
126705 ,p_balance_type_code => l_balance_type_code);
126706
126707 END IF;
126708
126709 -----------------------------------------------------------------------------------------
126710 -- 4262811 Multiperiod Accounting
126711 -----------------------------------------------------------------------------------------
126712 -- No MPA option is assigned.
126713
126714
126715 END IF;
126716 END IF;
126717 --
126718
126719 --
126720 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
126721 trace
126722 (p_msg => 'END of AcctLineType_243'
126723 ,p_level => C_LEVEL_PROCEDURE
126724 ,p_module => l_log_module);
126725 END IF;
126726 --
126727 EXCEPTION
126728 WHEN xla_exceptions_pkg.application_exception THEN
126729 RAISE;
126730 WHEN OTHERS THEN
126731 xla_exceptions_pkg.raise_message
126732 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_243');
126733 END AcctLineType_243;
126734 --
126735
126736 ---------------------------------------
126737 --
126738 -- PRIVATE FUNCTION
126739 -- AcctLineType_244
126740 --
126741 ---------------------------------------
126742 PROCEDURE AcctLineType_244 (
126743 p_application_id IN NUMBER
126744 ,p_event_id IN NUMBER
126745 ,p_calculate_acctd_flag IN VARCHAR2
126746 ,p_calculate_g_l_flag IN VARCHAR2
126747 ,p_actual_flag IN OUT VARCHAR2
126748 ,p_balance_type_code OUT VARCHAR2
126749 ,p_gain_or_loss_ref OUT VARCHAR2
126750
126751 --TRANSACTION_ID
126752 , p_source_1 IN NUMBER
126753 --Item Concatenated Segments
126754 , p_source_2 IN VARCHAR2
126755 --Transaction Quantity
126756 , p_source_3 IN NUMBER
126757 --Transaction Unit of Measure Code
126758 , p_source_4 IN VARCHAR2
126759 --Inventory Transaction Type Description
126760 , p_source_5 IN VARCHAR2
126761 --Cost Management Default Account
126762 , p_source_11 IN NUMBER
126763 --DISTRIBUTION_IDENTIFIER
126764 , p_source_84 IN NUMBER
126765 --Distribution Type
126766 , p_source_85 IN VARCHAR2
126767 , p_source_85_meaning IN VARCHAR2
126768 --Entered Currency Code
126769 , p_source_88 IN VARCHAR2
126770 --Entered Amount
126771 , p_source_91 IN NUMBER
126772 --Currency Conversion Date
126773 , p_source_92 IN DATE
126774 --Currency Conversion Rate
126775 , p_source_93 IN NUMBER
126776 --Currency Conversion Type
126777 , p_source_94 IN VARCHAR2
126778 --Accounted Amount
126779 , p_source_95 IN NUMBER
126780 --Accounting Line Type
126781 , p_source_97 IN NUMBER
126782 --Organization Code
126783 , p_source_108 IN VARCHAR2
126784 )
126785 IS
126786
126787 l_component_type VARCHAR2(80);
126788 l_component_code VARCHAR2(30);
126789 l_component_type_code VARCHAR2(1);
126790 l_component_appl_id INTEGER;
126791 l_amb_context_code VARCHAR2(30);
126792 l_entity_code VARCHAR2(30);
126793 l_event_class_code VARCHAR2(30);
126794 l_ae_header_id NUMBER;
126795 l_event_type_code VARCHAR2(30);
126796 l_line_definition_code VARCHAR2(30);
126797 l_line_definition_owner_code VARCHAR2(1);
126798 --
126799 -- adr variables
126800 l_segment VARCHAR2(30);
126801 l_ccid NUMBER;
126802 l_adr_transaction_coa_id NUMBER;
126803 l_adr_accounting_coa_id NUMBER;
126804 l_adr_flexfield_segment_code VARCHAR2(30);
126805 l_adr_flex_value_set_id NUMBER;
126806 l_adr_value_type_code VARCHAR2(30);
126807 l_adr_value_combination_id NUMBER;
126808 l_adr_value_segment_code VARCHAR2(30);
126809
126810 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
126811 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
126812 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
126813 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
126814
126815 -- 4262811 Variables ------------------------------------------------------------------------------------------
126816 l_entered_amt_idx NUMBER;
126817 l_accted_amt_idx NUMBER;
126818 l_acc_rev_flag VARCHAR2(1);
126819 l_accrual_line_num NUMBER;
126820 l_tmp_amt NUMBER;
126821 l_acc_rev_natural_side_code VARCHAR2(1);
126822
126823 l_num_entries NUMBER;
126824 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
126825 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
126826 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
126827 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
126828 l_recog_line_1 NUMBER;
126829 l_recog_line_2 NUMBER;
126830
126831 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
126832 l_bflow_applied_to_amt NUMBER; -- 5132302
126833 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
126834
126835 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
126836
126837 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
126838 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
126839
126840 ---------------------------------------------------------------------------------------------------------------
126841
126842
126843 --
126844 -- bulk performance
126845 --
126846 l_balance_type_code VARCHAR2(1);
126847 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
126848 l_log_module VARCHAR2(240);
126849
126850 --
126851 -- Upgrade strategy
126852 --
126853 l_actual_upg_option VARCHAR2(1);
126854 l_enc_upg_option VARCHAR2(1);
126855
126856 --
126857 BEGIN
126858 --
126859 IF g_log_enabled THEN
126860 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_244';
126861 END IF;
126862 --
126863 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
126864
126865 trace
126866 (p_msg => 'BEGIN of AcctLineType_244'
126867 ,p_level => C_LEVEL_PROCEDURE
126868 ,p_module => l_log_module);
126869
126870 END IF;
126871 --
126872 l_component_type := 'AMB_JLT';
126873 l_component_code := 'INVENTORY_VALUATION';
126874 l_component_type_code := 'S';
126875 l_component_appl_id := 707;
126876 l_amb_context_code := 'DEFAULT';
126877 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
126878 l_event_class_code := 'INT_ORDER_TO_EXP';
126879 l_event_type_code := 'EXP_REQ_RCPT_NO_TP';
126880 l_line_definition_owner_code := 'S';
126881 l_line_definition_code := 'PI_EXP_REQ_RCPT_NO_TP';
126882 --
126883 l_balance_type_code := 'A';
126884 l_segment := NULL;
126885 l_ccid := NULL;
126886 l_adr_transaction_coa_id := NULL;
126887 l_adr_accounting_coa_id := NULL;
126888 l_adr_flexfield_segment_code := NULL;
126889 l_adr_flex_value_set_id := NULL;
126890 l_adr_value_type_code := NULL;
126891 l_adr_value_combination_id := NULL;
126892 l_adr_value_segment_code := NULL;
126893
126894 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
126895 l_bflow_class_code := ''; -- 4219869 Business Flow
126896 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
126897 l_budgetary_control_flag := 'N';
126898
126899 l_bflow_applied_to_amt_idx := NULL; -- 5132302
126900 l_bflow_applied_to_amt := NULL; -- 5132302
126901 l_entered_amt_idx := NULL; -- 4262811
126902 l_accted_amt_idx := NULL; -- 4262811
126903 l_acc_rev_flag := NULL; -- 4262811
126904 l_accrual_line_num := NULL; -- 4262811
126905 l_tmp_amt := NULL; -- 4262811
126906 --
126907
126908 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
126909 l_balance_type_code <> 'B' THEN
126910 IF NVL(p_source_97,9E125) = 1
126911 THEN
126912
126913 --
126914 XLA_AE_LINES_PKG.SetNewLine;
126915
126916 p_balance_type_code := l_balance_type_code;
126917 -- set the flag so later we will know whether the gain loss line needs to be created
126918
126919 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
126920 p_actual_flag :='A';
126921 END IF;
126922
126923 --
126924 -- bulk performance
126925 --
126926 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
126927 p_header_num => 0); -- 4262811
126928 --
126929 -- set accounting line options
126930 --
126931 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
126932 p_natural_side_code => 'D'
126933 , p_gain_or_loss_flag => 'N'
126934 , p_gl_transfer_mode_code => 'S'
126935 , p_acct_entry_type_code => 'A'
126936 , p_switch_side_flag => 'Y'
126937 , p_merge_duplicate_code => 'N'
126938 );
126939 --
126940 l_acc_rev_natural_side_code := 'C'; -- 4262811
126941 --
126942 --
126943 -- set accounting line type info
126944 --
126945 xla_ae_lines_pkg.SetAcctLineType
126946 (p_component_type => l_component_type
126947 ,p_event_type_code => l_event_type_code
126948 ,p_line_definition_owner_code => l_line_definition_owner_code
126949 ,p_line_definition_code => l_line_definition_code
126950 ,p_accounting_line_code => l_component_code
126951 ,p_accounting_line_type_code => l_component_type_code
126952 ,p_accounting_line_appl_id => l_component_appl_id
126953 ,p_amb_context_code => l_amb_context_code
126954 ,p_entity_code => l_entity_code
126955 ,p_event_class_code => l_event_class_code);
126956 --
126957 -- set accounting class
126958 --
126959 xla_ae_lines_pkg.SetAcctClass(
126960 p_accounting_class_code => 'INVENTORY_VALUATION'
126961 , p_ae_header_id => l_ae_header_id
126962 );
126963
126964 --
126965 -- set rounding class
126966 --
126967 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
126968 'INVENTORY_VALUATION';
126969
126970 --
126971 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
126972 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
126973 --
126974 -- bulk performance
126975 --
126976 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
126977
126978 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
126979 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
126980
126981 -- 4955764
126982 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
126983 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
126984
126985 -- 4458381 Public Sector Enh
126986
126987 --
126988 -- set accounting attributes for the line type
126989 --
126990 l_entered_amt_idx := 3;
126991 l_accted_amt_idx := 8;
126992 l_bflow_applied_to_amt_idx := NULL; -- 5132302
126993 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
126994 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
126995 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
126996 l_rec_acct_attrs.array_char_value(2) := p_source_85;
126997 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
126998 l_rec_acct_attrs.array_num_value(3) := p_source_91;
126999 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
127000 l_rec_acct_attrs.array_char_value(4) := p_source_88;
127001 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
127002 l_rec_acct_attrs.array_date_value(5) := p_source_92;
127003 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
127004 l_rec_acct_attrs.array_num_value(6) := p_source_93;
127005 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
127006 l_rec_acct_attrs.array_char_value(7) := p_source_94;
127007 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
127008 l_rec_acct_attrs.array_num_value(8) := p_source_95;
127009
127010 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
127011 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
127012
127013 ---------------------------------------------------------------------------------------------------------------
127014 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
127015 ---------------------------------------------------------------------------------------------------------------
127016 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
127017
127018 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
127019 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
127020
127021 IF xla_accounting_cache_pkg.GetValueChar
127022 (p_source_code => 'LEDGER_CATEGORY_CODE'
127023 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
127024 AND l_bflow_method_code = 'PRIOR_ENTRY'
127025 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
127026 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
127027 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
127028 )
127029 THEN
127030 xla_ae_lines_pkg.BflowUpgEntry
127031 (p_business_method_code => l_bflow_method_code
127032 ,p_business_class_code => l_bflow_class_code
127033 ,p_balance_type => l_balance_type_code);
127034 ELSE
127035 NULL;
127036 -- No business flow processing for business flow method of NONE.
127037 END IF;
127038
127039 --
127040 -- call analytical criteria
127041 --
127042
127043
127044 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
127045 xla_ae_lines_pkg.SetAnalyticalCriteria(
127046 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
127047 , p_analytical_criterion_owner => 'S'
127048 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
127049 , p_amb_context_code => 'DEFAULT'
127050 , p_balancing_flag => 'Y'
127051
127052 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
127053 , p_analytical_detail_num_1 => NULL
127054 , p_analytical_detail_date_1 => NULL
127055
127056 , p_ae_header_id => l_ae_header_id
127057 )
127058 ;
127059 --
127060
127061 --
127062 -- call description
127063 --
127064
127065 xla_ae_lines_pkg.SetLineDescription(
127066 p_ae_header_id => l_ae_header_id
127067 ,p_description => Description_1 (
127068 p_application_id => p_application_id
127069 , p_ae_header_id => l_ae_header_id
127070 , p_source_1 => p_source_1
127071 , p_source_2 => p_source_2
127072 , p_source_3 => p_source_3
127073 , p_source_4 => p_source_4
127074 , p_source_5 => p_source_5
127075 )
127076 );
127077
127078
127079 --
127080 -- call ADRs
127081 -- Bug 4922099
127082 --
127083 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
127084 (NVL(l_actual_upg_option, 'N') = 'O') OR
127085 (NVL(l_enc_upg_option, 'N') = 'O')
127086 )
127087 THEN
127088 NULL;
127089 --
127090 --
127091
127092 l_ccid := AcctDerRule_6(
127093 p_application_id => p_application_id
127094 , p_ae_header_id => l_ae_header_id
127095 , p_source_11 => p_source_11
127096 , x_transaction_coa_id => l_adr_transaction_coa_id
127097 , x_accounting_coa_id => l_adr_accounting_coa_id
127098 , x_value_type_code => l_adr_value_type_code
127099 , p_side => 'NA'
127100 );
127101
127102 xla_ae_lines_pkg.set_ccid(
127103 p_code_combination_id => l_ccid
127104 , p_value_type_code => l_adr_value_type_code
127105 , p_transaction_coa_id => l_adr_transaction_coa_id
127106 , p_accounting_coa_id => l_adr_accounting_coa_id
127107 , p_adr_code => 'CST_DEFAULT'
127108 , p_adr_type_code => 'S'
127109 , p_component_type => l_component_type
127110 , p_component_code => l_component_code
127111 , p_component_type_code => l_component_type_code
127112 , p_component_appl_id => l_component_appl_id
127113 , p_amb_context_code => l_amb_context_code
127114 , p_side => 'NA'
127115 );
127116
127117
127118 --
127119 --
127120 END IF;
127121 --
127122 -- Bug 4922099
127123 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
127124 (NVL(l_enc_upg_option, 'N') = 'O')
127125 ) AND
127126 (l_bflow_method_code = 'PRIOR_ENTRY')
127127 )
127128 THEN
127129 IF
127130 --
127131 1 = 2
127132 --
127133 THEN
127134 xla_accounting_err_pkg.build_message
127135 (p_appli_s_name => 'XLA'
127136 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
127137 ,p_token_1 => 'LINE_NUMBER'
127138 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
127139 ,p_token_2 => 'LINE_TYPE_NAME'
127140 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
127141 l_component_type
127142 ,l_component_code
127143 ,l_component_type_code
127144 ,l_component_appl_id
127145 ,l_amb_context_code
127146 ,l_entity_code
127147 ,l_event_class_code
127148 )
127149 ,p_token_3 => 'OWNER'
127150 ,p_value_3 => xla_lookups_pkg.get_meaning(
127151 p_lookup_type => 'XLA_OWNER_TYPE'
127152 ,p_lookup_code => l_component_type_code
127153 )
127154 ,p_token_4 => 'PRODUCT_NAME'
127155 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
127156 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
127157 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
127158 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
127159 ,p_ae_header_id => NULL
127160 );
127161
127162 IF (C_LEVEL_ERROR>= g_log_level) THEN
127163 trace
127164 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
127165 ,p_level => C_LEVEL_ERROR
127166 ,p_module => l_log_module);
127167 END IF;
127168 END IF;
127169 END IF;
127170 --
127171 --
127172 ------------------------------------------------------------------------------------------------
127173 -- 4219869 Business Flow
127174 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
127175 -- Prior Entry. Currently, the following code is always generated.
127176 ------------------------------------------------------------------------------------------------
127177 XLA_AE_LINES_PKG.ValidateCurrentLine;
127178
127179 ------------------------------------------------------------------------------------
127180 -- 4219869 Business Flow
127181 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
127182 ------------------------------------------------------------------------------------
127183 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
127184
127185 ----------------------------------------------------------------------------------
127186 -- 4219869 Business Flow
127187 -- Update journal entry status -- Need to generate this within IF <condition>
127188 ----------------------------------------------------------------------------------
127189 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
127190 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
127191 ,p_balance_type_code => l_balance_type_code
127192 );
127193
127194 -------------------------------------------------------------------------------------------
127195 -- 4262811 - Generate the Accrual Reversal lines
127196 -------------------------------------------------------------------------------------------
127197 BEGIN
127198 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
127199 (g_array_event(p_event_id).array_value_num('header_index'));
127200 IF l_acc_rev_flag IS NULL THEN
127201 l_acc_rev_flag := 'N';
127202 END IF;
127203 EXCEPTION
127204 WHEN OTHERS THEN
127205 l_acc_rev_flag := 'N';
127206 END;
127207 --
127208 IF (l_acc_rev_flag = 'Y') THEN
127209
127210 -- 4645092 ------------------------------------------------------------------------------
127211 -- To allow MPA report to determine if it should generate report process
127212 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
127213 ------------------------------------------------------------------------------------------
127214
127215 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
127216 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
127217 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
127218 -- call ADRs
127219 -- Bug 4922099
127220 --
127221 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
127222 (NVL(l_actual_upg_option, 'N') = 'O') OR
127223 (NVL(l_enc_upg_option, 'N') = 'O')
127224 )
127225 THEN
127226 NULL;
127227 --
127228 --
127229
127230 l_ccid := AcctDerRule_6(
127231 p_application_id => p_application_id
127232 , p_ae_header_id => l_ae_header_id
127233 , p_source_11 => p_source_11
127234 , x_transaction_coa_id => l_adr_transaction_coa_id
127235 , x_accounting_coa_id => l_adr_accounting_coa_id
127236 , x_value_type_code => l_adr_value_type_code
127237 , p_side => 'NA'
127238 );
127239
127240 xla_ae_lines_pkg.set_ccid(
127241 p_code_combination_id => l_ccid
127242 , p_value_type_code => l_adr_value_type_code
127243 , p_transaction_coa_id => l_adr_transaction_coa_id
127244 , p_accounting_coa_id => l_adr_accounting_coa_id
127245 , p_adr_code => 'CST_DEFAULT'
127246 , p_adr_type_code => 'S'
127247 , p_component_type => l_component_type
127248 , p_component_code => l_component_code
127249 , p_component_type_code => l_component_type_code
127250 , p_component_appl_id => l_component_appl_id
127251 , p_amb_context_code => l_amb_context_code
127252 , p_side => 'NA'
127253 );
127254
127255
127256 --
127257 --
127258 END IF;
127259
127260 --
127261 -- Update the line information that should be overwritten
127262 --
127263 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
127264 p_header_num => 1);
127265 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
127266
127267 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
127268
127269 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
127270 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
127271 END IF;
127272
127273 --
127274 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
127275 --
127276 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
127277 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
127278 ELSE
127279 ---------------------------------------------------------------------------------------------------
127280 -- 4262811a Switch Sign
127281 ---------------------------------------------------------------------------------------------------
127282 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
127283 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
127284 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127285 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
127286 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127287 -- 5132302
127288 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
127289 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127290
127291 END IF;
127292
127293 -- 4955764
127294 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
127295 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
127296
127297
127298 XLA_AE_LINES_PKG.ValidateCurrentLine;
127299 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
127300
127301 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
127302 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
127303 ,p_balance_type_code => l_balance_type_code);
127304
127305 END IF;
127306
127307 -----------------------------------------------------------------------------------------
127308 -- 4262811 Multiperiod Accounting
127309 -----------------------------------------------------------------------------------------
127310 -- No MPA option is assigned.
127311
127312
127313 END IF;
127314 END IF;
127315 --
127316
127317 --
127318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
127319 trace
127320 (p_msg => 'END of AcctLineType_244'
127321 ,p_level => C_LEVEL_PROCEDURE
127322 ,p_module => l_log_module);
127323 END IF;
127324 --
127325 EXCEPTION
127326 WHEN xla_exceptions_pkg.application_exception THEN
127327 RAISE;
127328 WHEN OTHERS THEN
127329 xla_exceptions_pkg.raise_message
127330 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_244');
127331 END AcctLineType_244;
127332 --
127333
127334 ---------------------------------------
127335 --
127336 -- PRIVATE FUNCTION
127337 -- AcctLineType_245
127338 --
127339 ---------------------------------------
127340 PROCEDURE AcctLineType_245 (
127341 p_application_id IN NUMBER
127342 ,p_event_id IN NUMBER
127343 ,p_calculate_acctd_flag IN VARCHAR2
127344 ,p_calculate_g_l_flag IN VARCHAR2
127345 ,p_actual_flag IN OUT VARCHAR2
127346 ,p_balance_type_code OUT VARCHAR2
127347 ,p_gain_or_loss_ref OUT VARCHAR2
127348
127349 --TRANSACTION_ID
127350 , p_source_1 IN NUMBER
127351 --Item Concatenated Segments
127352 , p_source_2 IN VARCHAR2
127353 --Transaction Quantity
127354 , p_source_3 IN NUMBER
127355 --Transaction Unit of Measure Code
127356 , p_source_4 IN VARCHAR2
127357 --Inventory Transaction Type Description
127358 , p_source_5 IN VARCHAR2
127359 --Cost Element Name
127360 , p_source_15 IN NUMBER
127361 --Product Line Accounting Category Material Account
127362 , p_source_41 IN NUMBER
127363 --Product Line Accounting Category Material Overhead Account
127364 , p_source_42 IN NUMBER
127365 --Product Line Accounting Category Resource Account
127366 , p_source_43 IN NUMBER
127367 --Product Line Accounting Category Outside Processing Account
127368 , p_source_44 IN NUMBER
127369 --Product Line Accounting Category Overhead Account
127370 , p_source_45 IN NUMBER
127371 --DISTRIBUTION_IDENTIFIER
127372 , p_source_84 IN NUMBER
127373 --Distribution Type
127374 , p_source_85 IN VARCHAR2
127375 , p_source_85_meaning IN VARCHAR2
127376 --Entered Currency Code
127377 , p_source_88 IN VARCHAR2
127378 --Entered Amount
127379 , p_source_91 IN NUMBER
127380 --Currency Conversion Date
127381 , p_source_92 IN DATE
127382 --Currency Conversion Rate
127383 , p_source_93 IN NUMBER
127384 --Currency Conversion Type
127385 , p_source_94 IN VARCHAR2
127386 --Accounted Amount
127387 , p_source_95 IN NUMBER
127388 --Accounting Line Type
127389 , p_source_97 IN NUMBER
127390 --Organization Code
127391 , p_source_108 IN VARCHAR2
127392 )
127393 IS
127394
127395 l_component_type VARCHAR2(80);
127396 l_component_code VARCHAR2(30);
127397 l_component_type_code VARCHAR2(1);
127398 l_component_appl_id INTEGER;
127399 l_amb_context_code VARCHAR2(30);
127400 l_entity_code VARCHAR2(30);
127401 l_event_class_code VARCHAR2(30);
127402 l_ae_header_id NUMBER;
127403 l_event_type_code VARCHAR2(30);
127404 l_line_definition_code VARCHAR2(30);
127405 l_line_definition_owner_code VARCHAR2(1);
127406 --
127407 -- adr variables
127408 l_segment VARCHAR2(30);
127409 l_ccid NUMBER;
127410 l_adr_transaction_coa_id NUMBER;
127411 l_adr_accounting_coa_id NUMBER;
127412 l_adr_flexfield_segment_code VARCHAR2(30);
127413 l_adr_flex_value_set_id NUMBER;
127414 l_adr_value_type_code VARCHAR2(30);
127415 l_adr_value_combination_id NUMBER;
127416 l_adr_value_segment_code VARCHAR2(30);
127417
127418 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
127419 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
127420 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
127421 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
127422
127423 -- 4262811 Variables ------------------------------------------------------------------------------------------
127424 l_entered_amt_idx NUMBER;
127425 l_accted_amt_idx NUMBER;
127426 l_acc_rev_flag VARCHAR2(1);
127427 l_accrual_line_num NUMBER;
127428 l_tmp_amt NUMBER;
127429 l_acc_rev_natural_side_code VARCHAR2(1);
127430
127431 l_num_entries NUMBER;
127432 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
127433 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
127434 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
127435 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
127436 l_recog_line_1 NUMBER;
127437 l_recog_line_2 NUMBER;
127438
127439 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
127440 l_bflow_applied_to_amt NUMBER; -- 5132302
127441 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
127442
127443 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
127444
127445 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
127446 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
127447
127448 ---------------------------------------------------------------------------------------------------------------
127449
127450
127451 --
127452 -- bulk performance
127453 --
127454 l_balance_type_code VARCHAR2(1);
127455 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
127456 l_log_module VARCHAR2(240);
127457
127458 --
127459 -- Upgrade strategy
127460 --
127461 l_actual_upg_option VARCHAR2(1);
127462 l_enc_upg_option VARCHAR2(1);
127463
127464 --
127465 BEGIN
127466 --
127467 IF g_log_enabled THEN
127468 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_245';
127469 END IF;
127470 --
127471 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
127472
127473 trace
127474 (p_msg => 'BEGIN of AcctLineType_245'
127475 ,p_level => C_LEVEL_PROCEDURE
127476 ,p_module => l_log_module);
127477
127478 END IF;
127479 --
127480 l_component_type := 'AMB_JLT';
127481 l_component_code := 'INVENTORY_VALUATION';
127482 l_component_type_code := 'S';
127483 l_component_appl_id := 707;
127484 l_amb_context_code := 'DEFAULT';
127485 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
127486 l_event_class_code := 'MTL_COST_UPD';
127487 l_event_type_code := 'IPV_TXFR';
127488 l_line_definition_owner_code := 'S';
127489 l_line_definition_code := 'PI_IPV_TXFR';
127490 --
127491 l_balance_type_code := 'A';
127492 l_segment := NULL;
127493 l_ccid := NULL;
127494 l_adr_transaction_coa_id := NULL;
127495 l_adr_accounting_coa_id := NULL;
127496 l_adr_flexfield_segment_code := NULL;
127497 l_adr_flex_value_set_id := NULL;
127498 l_adr_value_type_code := NULL;
127499 l_adr_value_combination_id := NULL;
127500 l_adr_value_segment_code := NULL;
127501
127502 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
127503 l_bflow_class_code := ''; -- 4219869 Business Flow
127504 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
127505 l_budgetary_control_flag := 'N';
127506
127507 l_bflow_applied_to_amt_idx := NULL; -- 5132302
127508 l_bflow_applied_to_amt := NULL; -- 5132302
127509 l_entered_amt_idx := NULL; -- 4262811
127510 l_accted_amt_idx := NULL; -- 4262811
127511 l_acc_rev_flag := NULL; -- 4262811
127512 l_accrual_line_num := NULL; -- 4262811
127513 l_tmp_amt := NULL; -- 4262811
127514 --
127515
127516 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
127517 l_balance_type_code <> 'B' THEN
127518 IF NVL(p_source_97,9E125) = 1
127519 THEN
127520
127521 --
127522 XLA_AE_LINES_PKG.SetNewLine;
127523
127524 p_balance_type_code := l_balance_type_code;
127525 -- set the flag so later we will know whether the gain loss line needs to be created
127526
127527 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
127528 p_actual_flag :='A';
127529 END IF;
127530
127531 --
127532 -- bulk performance
127533 --
127534 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
127535 p_header_num => 0); -- 4262811
127536 --
127537 -- set accounting line options
127538 --
127539 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
127540 p_natural_side_code => 'D'
127541 , p_gain_or_loss_flag => 'N'
127542 , p_gl_transfer_mode_code => 'S'
127543 , p_acct_entry_type_code => 'A'
127544 , p_switch_side_flag => 'Y'
127545 , p_merge_duplicate_code => 'N'
127546 );
127547 --
127548 l_acc_rev_natural_side_code := 'C'; -- 4262811
127549 --
127550 --
127551 -- set accounting line type info
127552 --
127553 xla_ae_lines_pkg.SetAcctLineType
127554 (p_component_type => l_component_type
127555 ,p_event_type_code => l_event_type_code
127556 ,p_line_definition_owner_code => l_line_definition_owner_code
127557 ,p_line_definition_code => l_line_definition_code
127558 ,p_accounting_line_code => l_component_code
127559 ,p_accounting_line_type_code => l_component_type_code
127560 ,p_accounting_line_appl_id => l_component_appl_id
127561 ,p_amb_context_code => l_amb_context_code
127562 ,p_entity_code => l_entity_code
127563 ,p_event_class_code => l_event_class_code);
127564 --
127565 -- set accounting class
127566 --
127567 xla_ae_lines_pkg.SetAcctClass(
127568 p_accounting_class_code => 'INVENTORY_VALUATION'
127569 , p_ae_header_id => l_ae_header_id
127570 );
127571
127572 --
127573 -- set rounding class
127574 --
127575 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
127576 'INVENTORY_VALUATION';
127577
127578 --
127579 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
127580 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
127581 --
127582 -- bulk performance
127583 --
127584 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
127585
127586 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
127587 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
127588
127589 -- 4955764
127590 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
127591 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
127592
127593 -- 4458381 Public Sector Enh
127594
127595 --
127596 -- set accounting attributes for the line type
127597 --
127598 l_entered_amt_idx := 3;
127599 l_accted_amt_idx := 8;
127600 l_bflow_applied_to_amt_idx := NULL; -- 5132302
127601 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
127602 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
127603 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
127604 l_rec_acct_attrs.array_char_value(2) := p_source_85;
127605 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
127606 l_rec_acct_attrs.array_num_value(3) := p_source_91;
127607 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
127608 l_rec_acct_attrs.array_char_value(4) := p_source_88;
127609 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
127610 l_rec_acct_attrs.array_date_value(5) := p_source_92;
127611 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
127612 l_rec_acct_attrs.array_num_value(6) := p_source_93;
127613 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
127614 l_rec_acct_attrs.array_char_value(7) := p_source_94;
127615 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
127616 l_rec_acct_attrs.array_num_value(8) := p_source_95;
127617
127618 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
127619 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
127620
127621 ---------------------------------------------------------------------------------------------------------------
127622 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
127623 ---------------------------------------------------------------------------------------------------------------
127624 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
127625
127626 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
127627 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
127628
127629 IF xla_accounting_cache_pkg.GetValueChar
127630 (p_source_code => 'LEDGER_CATEGORY_CODE'
127631 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
127632 AND l_bflow_method_code = 'PRIOR_ENTRY'
127633 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
127634 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
127635 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
127636 )
127637 THEN
127638 xla_ae_lines_pkg.BflowUpgEntry
127639 (p_business_method_code => l_bflow_method_code
127640 ,p_business_class_code => l_bflow_class_code
127641 ,p_balance_type => l_balance_type_code);
127642 ELSE
127643 NULL;
127644 -- No business flow processing for business flow method of NONE.
127645 END IF;
127646
127647 --
127648 -- call analytical criteria
127649 --
127650
127651
127652 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
127653 xla_ae_lines_pkg.SetAnalyticalCriteria(
127654 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
127655 , p_analytical_criterion_owner => 'S'
127656 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
127657 , p_amb_context_code => 'DEFAULT'
127658 , p_balancing_flag => 'Y'
127659
127660 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
127661 , p_analytical_detail_num_1 => NULL
127662 , p_analytical_detail_date_1 => NULL
127663
127664 , p_ae_header_id => l_ae_header_id
127665 )
127666 ;
127667 --
127668
127669 --
127670 -- call description
127671 --
127672
127673 xla_ae_lines_pkg.SetLineDescription(
127674 p_ae_header_id => l_ae_header_id
127675 ,p_description => Description_1 (
127676 p_application_id => p_application_id
127677 , p_ae_header_id => l_ae_header_id
127678 , p_source_1 => p_source_1
127679 , p_source_2 => p_source_2
127680 , p_source_3 => p_source_3
127681 , p_source_4 => p_source_4
127682 , p_source_5 => p_source_5
127683 )
127684 );
127685
127686
127687 --
127688 -- call ADRs
127689 -- Bug 4922099
127690 --
127691 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
127692 (NVL(l_actual_upg_option, 'N') = 'O') OR
127693 (NVL(l_enc_upg_option, 'N') = 'O')
127694 )
127695 THEN
127696 NULL;
127697 --
127698 --
127699
127700 l_ccid := AcctDerRule_28(
127701 p_application_id => p_application_id
127702 , p_ae_header_id => l_ae_header_id
127703 , p_source_15 => p_source_15
127704 , p_source_41 => p_source_41
127705 , p_source_42 => p_source_42
127706 , p_source_43 => p_source_43
127707 , p_source_44 => p_source_44
127708 , p_source_45 => p_source_45
127709 , x_transaction_coa_id => l_adr_transaction_coa_id
127710 , x_accounting_coa_id => l_adr_accounting_coa_id
127711 , x_value_type_code => l_adr_value_type_code
127712 , p_side => 'NA'
127713 );
127714
127715 xla_ae_lines_pkg.set_ccid(
127716 p_code_combination_id => l_ccid
127717 , p_value_type_code => l_adr_value_type_code
127718 , p_transaction_coa_id => l_adr_transaction_coa_id
127719 , p_accounting_coa_id => l_adr_accounting_coa_id
127720 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
127721 , p_adr_type_code => 'S'
127722 , p_component_type => l_component_type
127723 , p_component_code => l_component_code
127724 , p_component_type_code => l_component_type_code
127725 , p_component_appl_id => l_component_appl_id
127726 , p_amb_context_code => l_amb_context_code
127727 , p_side => 'NA'
127728 );
127729
127730
127731 --
127732 --
127733 END IF;
127734 --
127735 -- Bug 4922099
127736 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
127737 (NVL(l_enc_upg_option, 'N') = 'O')
127738 ) AND
127739 (l_bflow_method_code = 'PRIOR_ENTRY')
127740 )
127741 THEN
127742 IF
127743 --
127744 1 = 2
127745 --
127746 THEN
127747 xla_accounting_err_pkg.build_message
127748 (p_appli_s_name => 'XLA'
127749 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
127750 ,p_token_1 => 'LINE_NUMBER'
127751 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
127752 ,p_token_2 => 'LINE_TYPE_NAME'
127753 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
127754 l_component_type
127755 ,l_component_code
127756 ,l_component_type_code
127757 ,l_component_appl_id
127758 ,l_amb_context_code
127759 ,l_entity_code
127760 ,l_event_class_code
127761 )
127762 ,p_token_3 => 'OWNER'
127763 ,p_value_3 => xla_lookups_pkg.get_meaning(
127764 p_lookup_type => 'XLA_OWNER_TYPE'
127765 ,p_lookup_code => l_component_type_code
127766 )
127767 ,p_token_4 => 'PRODUCT_NAME'
127768 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
127769 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
127770 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
127771 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
127772 ,p_ae_header_id => NULL
127773 );
127774
127775 IF (C_LEVEL_ERROR>= g_log_level) THEN
127776 trace
127777 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
127778 ,p_level => C_LEVEL_ERROR
127779 ,p_module => l_log_module);
127780 END IF;
127781 END IF;
127782 END IF;
127783 --
127784 --
127785 ------------------------------------------------------------------------------------------------
127786 -- 4219869 Business Flow
127787 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
127788 -- Prior Entry. Currently, the following code is always generated.
127789 ------------------------------------------------------------------------------------------------
127790 XLA_AE_LINES_PKG.ValidateCurrentLine;
127791
127792 ------------------------------------------------------------------------------------
127793 -- 4219869 Business Flow
127794 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
127795 ------------------------------------------------------------------------------------
127796 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
127797
127798 ----------------------------------------------------------------------------------
127799 -- 4219869 Business Flow
127800 -- Update journal entry status -- Need to generate this within IF <condition>
127801 ----------------------------------------------------------------------------------
127802 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
127803 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
127804 ,p_balance_type_code => l_balance_type_code
127805 );
127806
127807 -------------------------------------------------------------------------------------------
127808 -- 4262811 - Generate the Accrual Reversal lines
127809 -------------------------------------------------------------------------------------------
127810 BEGIN
127811 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
127812 (g_array_event(p_event_id).array_value_num('header_index'));
127813 IF l_acc_rev_flag IS NULL THEN
127814 l_acc_rev_flag := 'N';
127815 END IF;
127816 EXCEPTION
127817 WHEN OTHERS THEN
127818 l_acc_rev_flag := 'N';
127819 END;
127820 --
127821 IF (l_acc_rev_flag = 'Y') THEN
127822
127823 -- 4645092 ------------------------------------------------------------------------------
127824 -- To allow MPA report to determine if it should generate report process
127825 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
127826 ------------------------------------------------------------------------------------------
127827
127828 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
127829 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
127830 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
127831 -- call ADRs
127832 -- Bug 4922099
127833 --
127834 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
127835 (NVL(l_actual_upg_option, 'N') = 'O') OR
127836 (NVL(l_enc_upg_option, 'N') = 'O')
127837 )
127838 THEN
127839 NULL;
127840 --
127841 --
127842
127843 l_ccid := AcctDerRule_28(
127844 p_application_id => p_application_id
127845 , p_ae_header_id => l_ae_header_id
127846 , p_source_15 => p_source_15
127847 , p_source_41 => p_source_41
127848 , p_source_42 => p_source_42
127849 , p_source_43 => p_source_43
127850 , p_source_44 => p_source_44
127851 , p_source_45 => p_source_45
127852 , x_transaction_coa_id => l_adr_transaction_coa_id
127853 , x_accounting_coa_id => l_adr_accounting_coa_id
127854 , x_value_type_code => l_adr_value_type_code
127855 , p_side => 'NA'
127856 );
127857
127858 xla_ae_lines_pkg.set_ccid(
127859 p_code_combination_id => l_ccid
127860 , p_value_type_code => l_adr_value_type_code
127861 , p_transaction_coa_id => l_adr_transaction_coa_id
127862 , p_accounting_coa_id => l_adr_accounting_coa_id
127863 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
127864 , p_adr_type_code => 'S'
127865 , p_component_type => l_component_type
127866 , p_component_code => l_component_code
127867 , p_component_type_code => l_component_type_code
127868 , p_component_appl_id => l_component_appl_id
127869 , p_amb_context_code => l_amb_context_code
127870 , p_side => 'NA'
127871 );
127872
127873
127874 --
127875 --
127876 END IF;
127877
127878 --
127879 -- Update the line information that should be overwritten
127880 --
127881 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
127882 p_header_num => 1);
127883 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
127884
127885 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
127886
127887 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
127888 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
127889 END IF;
127890
127891 --
127892 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
127893 --
127894 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
127895 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
127896 ELSE
127897 ---------------------------------------------------------------------------------------------------
127898 -- 4262811a Switch Sign
127899 ---------------------------------------------------------------------------------------------------
127900 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
127901 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
127902 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127903 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
127904 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127905 -- 5132302
127906 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
127907 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
127908
127909 END IF;
127910
127911 -- 4955764
127912 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
127913 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
127914
127915
127916 XLA_AE_LINES_PKG.ValidateCurrentLine;
127917 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
127918
127919 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
127920 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
127921 ,p_balance_type_code => l_balance_type_code);
127922
127923 END IF;
127924
127925 -----------------------------------------------------------------------------------------
127926 -- 4262811 Multiperiod Accounting
127927 -----------------------------------------------------------------------------------------
127928 -- No MPA option is assigned.
127929
127930
127931 END IF;
127932 END IF;
127933 --
127934
127935 --
127936 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
127937 trace
127938 (p_msg => 'END of AcctLineType_245'
127939 ,p_level => C_LEVEL_PROCEDURE
127940 ,p_module => l_log_module);
127941 END IF;
127942 --
127943 EXCEPTION
127944 WHEN xla_exceptions_pkg.application_exception THEN
127945 RAISE;
127946 WHEN OTHERS THEN
127947 xla_exceptions_pkg.raise_message
127948 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_245');
127949 END AcctLineType_245;
127950 --
127951
127952 ---------------------------------------
127953 --
127954 -- PRIVATE FUNCTION
127955 -- AcctLineType_246
127956 --
127957 ---------------------------------------
127958 PROCEDURE AcctLineType_246 (
127959 p_application_id IN NUMBER
127960 ,p_event_id IN NUMBER
127961 ,p_calculate_acctd_flag IN VARCHAR2
127962 ,p_calculate_g_l_flag IN VARCHAR2
127963 ,p_actual_flag IN OUT VARCHAR2
127964 ,p_balance_type_code OUT VARCHAR2
127965 ,p_gain_or_loss_ref OUT VARCHAR2
127966
127967 --TRANSACTION_ID
127968 , p_source_1 IN NUMBER
127969 --Item Concatenated Segments
127970 , p_source_2 IN VARCHAR2
127971 --Transaction Quantity
127972 , p_source_3 IN NUMBER
127973 --Transaction Unit of Measure Code
127974 , p_source_4 IN VARCHAR2
127975 --Inventory Transaction Type Description
127976 , p_source_5 IN VARCHAR2
127977 --Cost Element Name
127978 , p_source_15 IN NUMBER
127979 --Product Line Accounting Category Material Account
127980 , p_source_41 IN NUMBER
127981 --Product Line Accounting Category Material Overhead Account
127982 , p_source_42 IN NUMBER
127983 --Product Line Accounting Category Resource Account
127984 , p_source_43 IN NUMBER
127985 --Product Line Accounting Category Outside Processing Account
127986 , p_source_44 IN NUMBER
127987 --Product Line Accounting Category Overhead Account
127988 , p_source_45 IN NUMBER
127989 --DISTRIBUTION_IDENTIFIER
127990 , p_source_84 IN NUMBER
127991 --Distribution Type
127992 , p_source_85 IN VARCHAR2
127993 , p_source_85_meaning IN VARCHAR2
127994 --Entered Currency Code
127995 , p_source_88 IN VARCHAR2
127996 --Entered Amount
127997 , p_source_91 IN NUMBER
127998 --Currency Conversion Date
127999 , p_source_92 IN DATE
128000 --Currency Conversion Rate
128001 , p_source_93 IN NUMBER
128002 --Currency Conversion Type
128003 , p_source_94 IN VARCHAR2
128004 --Accounted Amount
128005 , p_source_95 IN NUMBER
128006 --Accounting Line Type
128007 , p_source_97 IN NUMBER
128008 --Organization Code
128009 , p_source_108 IN VARCHAR2
128010 )
128011 IS
128012
128013 l_component_type VARCHAR2(80);
128014 l_component_code VARCHAR2(30);
128015 l_component_type_code VARCHAR2(1);
128016 l_component_appl_id INTEGER;
128017 l_amb_context_code VARCHAR2(30);
128018 l_entity_code VARCHAR2(30);
128019 l_event_class_code VARCHAR2(30);
128020 l_ae_header_id NUMBER;
128021 l_event_type_code VARCHAR2(30);
128022 l_line_definition_code VARCHAR2(30);
128023 l_line_definition_owner_code VARCHAR2(1);
128024 --
128025 -- adr variables
128026 l_segment VARCHAR2(30);
128027 l_ccid NUMBER;
128028 l_adr_transaction_coa_id NUMBER;
128029 l_adr_accounting_coa_id NUMBER;
128030 l_adr_flexfield_segment_code VARCHAR2(30);
128031 l_adr_flex_value_set_id NUMBER;
128032 l_adr_value_type_code VARCHAR2(30);
128033 l_adr_value_combination_id NUMBER;
128034 l_adr_value_segment_code VARCHAR2(30);
128035
128036 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
128037 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
128038 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
128039 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
128040
128041 -- 4262811 Variables ------------------------------------------------------------------------------------------
128042 l_entered_amt_idx NUMBER;
128043 l_accted_amt_idx NUMBER;
128044 l_acc_rev_flag VARCHAR2(1);
128045 l_accrual_line_num NUMBER;
128046 l_tmp_amt NUMBER;
128047 l_acc_rev_natural_side_code VARCHAR2(1);
128048
128049 l_num_entries NUMBER;
128050 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
128051 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
128052 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
128053 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
128054 l_recog_line_1 NUMBER;
128055 l_recog_line_2 NUMBER;
128056
128057 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
128058 l_bflow_applied_to_amt NUMBER; -- 5132302
128059 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
128060
128061 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
128062
128063 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
128064 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
128065
128066 ---------------------------------------------------------------------------------------------------------------
128067
128068
128069 --
128070 -- bulk performance
128071 --
128072 l_balance_type_code VARCHAR2(1);
128073 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
128074 l_log_module VARCHAR2(240);
128075
128076 --
128077 -- Upgrade strategy
128078 --
128079 l_actual_upg_option VARCHAR2(1);
128080 l_enc_upg_option VARCHAR2(1);
128081
128082 --
128083 BEGIN
128084 --
128085 IF g_log_enabled THEN
128086 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_246';
128087 END IF;
128088 --
128089 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
128090
128091 trace
128092 (p_msg => 'BEGIN of AcctLineType_246'
128093 ,p_level => C_LEVEL_PROCEDURE
128094 ,p_module => l_log_module);
128095
128096 END IF;
128097 --
128098 l_component_type := 'AMB_JLT';
128099 l_component_code := 'INVENTORY_VALUATION';
128100 l_component_type_code := 'S';
128101 l_component_appl_id := 707;
128102 l_amb_context_code := 'DEFAULT';
128103 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
128104 l_event_class_code := 'USER_DEFINE';
128105 l_event_type_code := 'UAVG_COST_UPD';
128106 l_line_definition_owner_code := 'S';
128107 l_line_definition_code := 'PI_COST_UPD';
128108 --
128109 l_balance_type_code := 'A';
128110 l_segment := NULL;
128111 l_ccid := NULL;
128112 l_adr_transaction_coa_id := NULL;
128113 l_adr_accounting_coa_id := NULL;
128114 l_adr_flexfield_segment_code := NULL;
128115 l_adr_flex_value_set_id := NULL;
128116 l_adr_value_type_code := NULL;
128117 l_adr_value_combination_id := NULL;
128118 l_adr_value_segment_code := NULL;
128119
128120 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
128121 l_bflow_class_code := ''; -- 4219869 Business Flow
128122 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
128123 l_budgetary_control_flag := 'N';
128124
128125 l_bflow_applied_to_amt_idx := NULL; -- 5132302
128126 l_bflow_applied_to_amt := NULL; -- 5132302
128127 l_entered_amt_idx := NULL; -- 4262811
128128 l_accted_amt_idx := NULL; -- 4262811
128129 l_acc_rev_flag := NULL; -- 4262811
128130 l_accrual_line_num := NULL; -- 4262811
128131 l_tmp_amt := NULL; -- 4262811
128132 --
128133
128134 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
128135 l_balance_type_code <> 'B' THEN
128136 IF NVL(p_source_97,9E125) = 1
128137 THEN
128138
128139 --
128140 XLA_AE_LINES_PKG.SetNewLine;
128141
128142 p_balance_type_code := l_balance_type_code;
128143 -- set the flag so later we will know whether the gain loss line needs to be created
128144
128145 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
128146 p_actual_flag :='A';
128147 END IF;
128148
128149 --
128150 -- bulk performance
128151 --
128152 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
128153 p_header_num => 0); -- 4262811
128154 --
128155 -- set accounting line options
128156 --
128157 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
128158 p_natural_side_code => 'D'
128159 , p_gain_or_loss_flag => 'N'
128160 , p_gl_transfer_mode_code => 'S'
128161 , p_acct_entry_type_code => 'A'
128162 , p_switch_side_flag => 'Y'
128163 , p_merge_duplicate_code => 'N'
128164 );
128165 --
128166 l_acc_rev_natural_side_code := 'C'; -- 4262811
128167 --
128168 --
128169 -- set accounting line type info
128170 --
128171 xla_ae_lines_pkg.SetAcctLineType
128172 (p_component_type => l_component_type
128173 ,p_event_type_code => l_event_type_code
128174 ,p_line_definition_owner_code => l_line_definition_owner_code
128175 ,p_line_definition_code => l_line_definition_code
128176 ,p_accounting_line_code => l_component_code
128177 ,p_accounting_line_type_code => l_component_type_code
128178 ,p_accounting_line_appl_id => l_component_appl_id
128179 ,p_amb_context_code => l_amb_context_code
128180 ,p_entity_code => l_entity_code
128181 ,p_event_class_code => l_event_class_code);
128182 --
128183 -- set accounting class
128184 --
128185 xla_ae_lines_pkg.SetAcctClass(
128186 p_accounting_class_code => 'INVENTORY_VALUATION'
128187 , p_ae_header_id => l_ae_header_id
128188 );
128189
128190 --
128191 -- set rounding class
128192 --
128193 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
128194 'INVENTORY_VALUATION';
128195
128196 --
128197 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
128198 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
128199 --
128200 -- bulk performance
128201 --
128202 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
128203
128204 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
128205 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
128206
128207 -- 4955764
128208 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
128209 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
128210
128211 -- 4458381 Public Sector Enh
128212
128213 --
128214 -- set accounting attributes for the line type
128215 --
128216 l_entered_amt_idx := 3;
128217 l_accted_amt_idx := 8;
128218 l_bflow_applied_to_amt_idx := NULL; -- 5132302
128219 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
128220 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
128221 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
128222 l_rec_acct_attrs.array_char_value(2) := p_source_85;
128223 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
128224 l_rec_acct_attrs.array_num_value(3) := p_source_91;
128225 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
128226 l_rec_acct_attrs.array_char_value(4) := p_source_88;
128227 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
128228 l_rec_acct_attrs.array_date_value(5) := p_source_92;
128229 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
128230 l_rec_acct_attrs.array_num_value(6) := p_source_93;
128231 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
128232 l_rec_acct_attrs.array_char_value(7) := p_source_94;
128233 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
128234 l_rec_acct_attrs.array_num_value(8) := p_source_95;
128235
128236 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
128237 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
128238
128239 ---------------------------------------------------------------------------------------------------------------
128240 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
128241 ---------------------------------------------------------------------------------------------------------------
128242 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
128243
128244 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
128245 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
128246
128247 IF xla_accounting_cache_pkg.GetValueChar
128248 (p_source_code => 'LEDGER_CATEGORY_CODE'
128249 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
128250 AND l_bflow_method_code = 'PRIOR_ENTRY'
128251 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
128252 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
128253 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
128254 )
128255 THEN
128256 xla_ae_lines_pkg.BflowUpgEntry
128257 (p_business_method_code => l_bflow_method_code
128258 ,p_business_class_code => l_bflow_class_code
128259 ,p_balance_type => l_balance_type_code);
128260 ELSE
128261 NULL;
128262 -- No business flow processing for business flow method of NONE.
128263 END IF;
128264
128265 --
128266 -- call analytical criteria
128267 --
128268
128269
128270 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
128271 xla_ae_lines_pkg.SetAnalyticalCriteria(
128272 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
128273 , p_analytical_criterion_owner => 'S'
128274 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
128275 , p_amb_context_code => 'DEFAULT'
128276 , p_balancing_flag => 'Y'
128277
128278 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
128279 , p_analytical_detail_num_1 => NULL
128280 , p_analytical_detail_date_1 => NULL
128281
128282 , p_ae_header_id => l_ae_header_id
128283 )
128284 ;
128285 --
128286
128287 --
128288 -- call description
128289 --
128290
128291 xla_ae_lines_pkg.SetLineDescription(
128292 p_ae_header_id => l_ae_header_id
128293 ,p_description => Description_1 (
128294 p_application_id => p_application_id
128295 , p_ae_header_id => l_ae_header_id
128296 , p_source_1 => p_source_1
128297 , p_source_2 => p_source_2
128298 , p_source_3 => p_source_3
128299 , p_source_4 => p_source_4
128300 , p_source_5 => p_source_5
128301 )
128302 );
128303
128304
128305 --
128306 -- call ADRs
128307 -- Bug 4922099
128308 --
128309 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
128310 (NVL(l_actual_upg_option, 'N') = 'O') OR
128311 (NVL(l_enc_upg_option, 'N') = 'O')
128312 )
128313 THEN
128314 NULL;
128315 --
128316 --
128317
128318 l_ccid := AcctDerRule_28(
128319 p_application_id => p_application_id
128320 , p_ae_header_id => l_ae_header_id
128321 , p_source_15 => p_source_15
128322 , p_source_41 => p_source_41
128323 , p_source_42 => p_source_42
128324 , p_source_43 => p_source_43
128325 , p_source_44 => p_source_44
128326 , p_source_45 => p_source_45
128327 , x_transaction_coa_id => l_adr_transaction_coa_id
128328 , x_accounting_coa_id => l_adr_accounting_coa_id
128329 , x_value_type_code => l_adr_value_type_code
128330 , p_side => 'NA'
128331 );
128332
128333 xla_ae_lines_pkg.set_ccid(
128334 p_code_combination_id => l_ccid
128335 , p_value_type_code => l_adr_value_type_code
128336 , p_transaction_coa_id => l_adr_transaction_coa_id
128337 , p_accounting_coa_id => l_adr_accounting_coa_id
128338 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
128339 , p_adr_type_code => 'S'
128340 , p_component_type => l_component_type
128341 , p_component_code => l_component_code
128342 , p_component_type_code => l_component_type_code
128343 , p_component_appl_id => l_component_appl_id
128344 , p_amb_context_code => l_amb_context_code
128345 , p_side => 'NA'
128346 );
128347
128348
128349 --
128350 --
128351 END IF;
128352 --
128353 -- Bug 4922099
128354 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
128355 (NVL(l_enc_upg_option, 'N') = 'O')
128356 ) AND
128357 (l_bflow_method_code = 'PRIOR_ENTRY')
128358 )
128359 THEN
128360 IF
128361 --
128362 1 = 2
128363 --
128364 THEN
128365 xla_accounting_err_pkg.build_message
128366 (p_appli_s_name => 'XLA'
128367 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
128368 ,p_token_1 => 'LINE_NUMBER'
128369 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
128370 ,p_token_2 => 'LINE_TYPE_NAME'
128371 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
128372 l_component_type
128373 ,l_component_code
128374 ,l_component_type_code
128375 ,l_component_appl_id
128376 ,l_amb_context_code
128377 ,l_entity_code
128378 ,l_event_class_code
128379 )
128380 ,p_token_3 => 'OWNER'
128381 ,p_value_3 => xla_lookups_pkg.get_meaning(
128382 p_lookup_type => 'XLA_OWNER_TYPE'
128383 ,p_lookup_code => l_component_type_code
128384 )
128385 ,p_token_4 => 'PRODUCT_NAME'
128386 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
128387 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
128388 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
128389 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
128390 ,p_ae_header_id => NULL
128391 );
128392
128393 IF (C_LEVEL_ERROR>= g_log_level) THEN
128394 trace
128395 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
128396 ,p_level => C_LEVEL_ERROR
128397 ,p_module => l_log_module);
128398 END IF;
128399 END IF;
128400 END IF;
128401 --
128402 --
128403 ------------------------------------------------------------------------------------------------
128404 -- 4219869 Business Flow
128405 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
128406 -- Prior Entry. Currently, the following code is always generated.
128407 ------------------------------------------------------------------------------------------------
128408 XLA_AE_LINES_PKG.ValidateCurrentLine;
128409
128410 ------------------------------------------------------------------------------------
128411 -- 4219869 Business Flow
128412 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
128413 ------------------------------------------------------------------------------------
128414 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
128415
128416 ----------------------------------------------------------------------------------
128417 -- 4219869 Business Flow
128418 -- Update journal entry status -- Need to generate this within IF <condition>
128419 ----------------------------------------------------------------------------------
128420 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
128421 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
128422 ,p_balance_type_code => l_balance_type_code
128423 );
128424
128425 -------------------------------------------------------------------------------------------
128426 -- 4262811 - Generate the Accrual Reversal lines
128427 -------------------------------------------------------------------------------------------
128428 BEGIN
128429 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
128430 (g_array_event(p_event_id).array_value_num('header_index'));
128431 IF l_acc_rev_flag IS NULL THEN
128432 l_acc_rev_flag := 'N';
128433 END IF;
128434 EXCEPTION
128435 WHEN OTHERS THEN
128436 l_acc_rev_flag := 'N';
128437 END;
128438 --
128439 IF (l_acc_rev_flag = 'Y') THEN
128440
128441 -- 4645092 ------------------------------------------------------------------------------
128442 -- To allow MPA report to determine if it should generate report process
128443 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
128444 ------------------------------------------------------------------------------------------
128445
128446 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
128447 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
128448 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
128449 -- call ADRs
128450 -- Bug 4922099
128451 --
128452 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
128453 (NVL(l_actual_upg_option, 'N') = 'O') OR
128454 (NVL(l_enc_upg_option, 'N') = 'O')
128455 )
128456 THEN
128457 NULL;
128458 --
128459 --
128460
128461 l_ccid := AcctDerRule_28(
128462 p_application_id => p_application_id
128463 , p_ae_header_id => l_ae_header_id
128464 , p_source_15 => p_source_15
128465 , p_source_41 => p_source_41
128466 , p_source_42 => p_source_42
128467 , p_source_43 => p_source_43
128468 , p_source_44 => p_source_44
128469 , p_source_45 => p_source_45
128470 , x_transaction_coa_id => l_adr_transaction_coa_id
128471 , x_accounting_coa_id => l_adr_accounting_coa_id
128472 , x_value_type_code => l_adr_value_type_code
128473 , p_side => 'NA'
128474 );
128475
128476 xla_ae_lines_pkg.set_ccid(
128477 p_code_combination_id => l_ccid
128478 , p_value_type_code => l_adr_value_type_code
128479 , p_transaction_coa_id => l_adr_transaction_coa_id
128480 , p_accounting_coa_id => l_adr_accounting_coa_id
128481 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
128482 , p_adr_type_code => 'S'
128483 , p_component_type => l_component_type
128484 , p_component_code => l_component_code
128485 , p_component_type_code => l_component_type_code
128486 , p_component_appl_id => l_component_appl_id
128487 , p_amb_context_code => l_amb_context_code
128488 , p_side => 'NA'
128489 );
128490
128491
128492 --
128493 --
128494 END IF;
128495
128496 --
128497 -- Update the line information that should be overwritten
128498 --
128499 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
128500 p_header_num => 1);
128501 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
128502
128503 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
128504
128505 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
128506 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
128507 END IF;
128508
128509 --
128510 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
128511 --
128512 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
128513 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
128514 ELSE
128515 ---------------------------------------------------------------------------------------------------
128516 -- 4262811a Switch Sign
128517 ---------------------------------------------------------------------------------------------------
128518 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
128519 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
128520 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
128521 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
128522 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
128523 -- 5132302
128524 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
128525 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
128526
128527 END IF;
128528
128529 -- 4955764
128530 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
128531 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
128532
128533
128534 XLA_AE_LINES_PKG.ValidateCurrentLine;
128535 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
128536
128537 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
128538 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
128539 ,p_balance_type_code => l_balance_type_code);
128540
128541 END IF;
128542
128543 -----------------------------------------------------------------------------------------
128544 -- 4262811 Multiperiod Accounting
128545 -----------------------------------------------------------------------------------------
128546 -- No MPA option is assigned.
128547
128548
128549 END IF;
128550 END IF;
128551 --
128552
128553 --
128554 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
128555 trace
128556 (p_msg => 'END of AcctLineType_246'
128557 ,p_level => C_LEVEL_PROCEDURE
128558 ,p_module => l_log_module);
128559 END IF;
128560 --
128561 EXCEPTION
128562 WHEN xla_exceptions_pkg.application_exception THEN
128563 RAISE;
128564 WHEN OTHERS THEN
128565 xla_exceptions_pkg.raise_message
128566 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_246');
128567 END AcctLineType_246;
128568 --
128569
128570 ---------------------------------------
128571 --
128572 -- PRIVATE FUNCTION
128573 -- AcctLineType_247
128574 --
128575 ---------------------------------------
128576 PROCEDURE AcctLineType_247 (
128577 p_application_id IN NUMBER
128578 ,p_event_id IN NUMBER
128579 ,p_calculate_acctd_flag IN VARCHAR2
128580 ,p_calculate_g_l_flag IN VARCHAR2
128581 ,p_actual_flag IN OUT VARCHAR2
128582 ,p_balance_type_code OUT VARCHAR2
128583 ,p_gain_or_loss_ref OUT VARCHAR2
128584
128585 --TRANSACTION_ID
128586 , p_source_1 IN NUMBER
128587 --Item Concatenated Segments
128588 , p_source_2 IN VARCHAR2
128589 --Transaction Quantity
128590 , p_source_3 IN NUMBER
128591 --Transaction Unit of Measure Code
128592 , p_source_4 IN VARCHAR2
128593 --Inventory Transaction Type Description
128594 , p_source_5 IN VARCHAR2
128595 --Cost Element Name
128596 , p_source_15 IN NUMBER
128597 --Product Line Accounting Category Material Account
128598 , p_source_41 IN NUMBER
128599 --Product Line Accounting Category Material Overhead Account
128600 , p_source_42 IN NUMBER
128601 --Product Line Accounting Category Resource Account
128602 , p_source_43 IN NUMBER
128603 --Product Line Accounting Category Outside Processing Account
128604 , p_source_44 IN NUMBER
128605 --Product Line Accounting Category Overhead Account
128606 , p_source_45 IN NUMBER
128607 --DISTRIBUTION_IDENTIFIER
128608 , p_source_84 IN NUMBER
128609 --Distribution Type
128610 , p_source_85 IN VARCHAR2
128611 , p_source_85_meaning IN VARCHAR2
128612 --Entered Currency Code
128613 , p_source_88 IN VARCHAR2
128614 --Entered Amount
128615 , p_source_91 IN NUMBER
128616 --Currency Conversion Date
128617 , p_source_92 IN DATE
128618 --Currency Conversion Rate
128619 , p_source_93 IN NUMBER
128620 --Currency Conversion Type
128621 , p_source_94 IN VARCHAR2
128622 --Accounted Amount
128623 , p_source_95 IN NUMBER
128624 --Accounting Line Type
128625 , p_source_97 IN NUMBER
128626 --Organization Code
128627 , p_source_108 IN VARCHAR2
128628 )
128629 IS
128630
128631 l_component_type VARCHAR2(80);
128632 l_component_code VARCHAR2(30);
128633 l_component_type_code VARCHAR2(1);
128634 l_component_appl_id INTEGER;
128635 l_amb_context_code VARCHAR2(30);
128636 l_entity_code VARCHAR2(30);
128637 l_event_class_code VARCHAR2(30);
128638 l_ae_header_id NUMBER;
128639 l_event_type_code VARCHAR2(30);
128640 l_line_definition_code VARCHAR2(30);
128641 l_line_definition_owner_code VARCHAR2(1);
128642 --
128643 -- adr variables
128644 l_segment VARCHAR2(30);
128645 l_ccid NUMBER;
128646 l_adr_transaction_coa_id NUMBER;
128647 l_adr_accounting_coa_id NUMBER;
128648 l_adr_flexfield_segment_code VARCHAR2(30);
128649 l_adr_flex_value_set_id NUMBER;
128650 l_adr_value_type_code VARCHAR2(30);
128651 l_adr_value_combination_id NUMBER;
128652 l_adr_value_segment_code VARCHAR2(30);
128653
128654 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
128655 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
128656 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
128657 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
128658
128659 -- 4262811 Variables ------------------------------------------------------------------------------------------
128660 l_entered_amt_idx NUMBER;
128661 l_accted_amt_idx NUMBER;
128662 l_acc_rev_flag VARCHAR2(1);
128663 l_accrual_line_num NUMBER;
128664 l_tmp_amt NUMBER;
128665 l_acc_rev_natural_side_code VARCHAR2(1);
128666
128667 l_num_entries NUMBER;
128668 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
128669 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
128670 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
128671 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
128672 l_recog_line_1 NUMBER;
128673 l_recog_line_2 NUMBER;
128674
128675 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
128676 l_bflow_applied_to_amt NUMBER; -- 5132302
128677 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
128678
128679 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
128680
128681 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
128682 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
128683
128684 ---------------------------------------------------------------------------------------------------------------
128685
128686
128687 --
128688 -- bulk performance
128689 --
128690 l_balance_type_code VARCHAR2(1);
128691 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
128692 l_log_module VARCHAR2(240);
128693
128694 --
128695 -- Upgrade strategy
128696 --
128697 l_actual_upg_option VARCHAR2(1);
128698 l_enc_upg_option VARCHAR2(1);
128699
128700 --
128701 BEGIN
128702 --
128703 IF g_log_enabled THEN
128704 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_247';
128705 END IF;
128706 --
128707 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
128708
128709 trace
128710 (p_msg => 'BEGIN of AcctLineType_247'
128711 ,p_level => C_LEVEL_PROCEDURE
128712 ,p_module => l_log_module);
128713
128714 END IF;
128715 --
128716 l_component_type := 'AMB_JLT';
128717 l_component_code := 'INVENTORY_VALUATION';
128718 l_component_type_code := 'S';
128719 l_component_appl_id := 707;
128720 l_amb_context_code := 'DEFAULT';
128721 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
128722 l_event_class_code := 'USER_DEFINE';
128723 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_TP';
128724 l_line_definition_owner_code := 'S';
128725 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_TP';
128726 --
128727 l_balance_type_code := 'A';
128728 l_segment := NULL;
128729 l_ccid := NULL;
128730 l_adr_transaction_coa_id := NULL;
128731 l_adr_accounting_coa_id := NULL;
128732 l_adr_flexfield_segment_code := NULL;
128733 l_adr_flex_value_set_id := NULL;
128734 l_adr_value_type_code := NULL;
128735 l_adr_value_combination_id := NULL;
128736 l_adr_value_segment_code := NULL;
128737
128738 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
128739 l_bflow_class_code := ''; -- 4219869 Business Flow
128740 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
128741 l_budgetary_control_flag := 'N';
128742
128743 l_bflow_applied_to_amt_idx := NULL; -- 5132302
128744 l_bflow_applied_to_amt := NULL; -- 5132302
128745 l_entered_amt_idx := NULL; -- 4262811
128746 l_accted_amt_idx := NULL; -- 4262811
128747 l_acc_rev_flag := NULL; -- 4262811
128748 l_accrual_line_num := NULL; -- 4262811
128749 l_tmp_amt := NULL; -- 4262811
128750 --
128751
128752 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
128753 l_balance_type_code <> 'B' THEN
128754 IF NVL(p_source_97,9E125) = 1
128755 THEN
128756
128757 --
128758 XLA_AE_LINES_PKG.SetNewLine;
128759
128760 p_balance_type_code := l_balance_type_code;
128761 -- set the flag so later we will know whether the gain loss line needs to be created
128762
128763 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
128764 p_actual_flag :='A';
128765 END IF;
128766
128767 --
128768 -- bulk performance
128769 --
128770 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
128771 p_header_num => 0); -- 4262811
128772 --
128773 -- set accounting line options
128774 --
128775 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
128776 p_natural_side_code => 'D'
128777 , p_gain_or_loss_flag => 'N'
128778 , p_gl_transfer_mode_code => 'S'
128779 , p_acct_entry_type_code => 'A'
128780 , p_switch_side_flag => 'Y'
128781 , p_merge_duplicate_code => 'N'
128782 );
128783 --
128784 l_acc_rev_natural_side_code := 'C'; -- 4262811
128785 --
128786 --
128787 -- set accounting line type info
128788 --
128789 xla_ae_lines_pkg.SetAcctLineType
128790 (p_component_type => l_component_type
128791 ,p_event_type_code => l_event_type_code
128792 ,p_line_definition_owner_code => l_line_definition_owner_code
128793 ,p_line_definition_code => l_line_definition_code
128794 ,p_accounting_line_code => l_component_code
128795 ,p_accounting_line_type_code => l_component_type_code
128796 ,p_accounting_line_appl_id => l_component_appl_id
128797 ,p_amb_context_code => l_amb_context_code
128798 ,p_entity_code => l_entity_code
128799 ,p_event_class_code => l_event_class_code);
128800 --
128801 -- set accounting class
128802 --
128803 xla_ae_lines_pkg.SetAcctClass(
128804 p_accounting_class_code => 'INVENTORY_VALUATION'
128805 , p_ae_header_id => l_ae_header_id
128806 );
128807
128808 --
128809 -- set rounding class
128810 --
128811 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
128812 'INVENTORY_VALUATION';
128813
128814 --
128815 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
128816 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
128817 --
128818 -- bulk performance
128819 --
128820 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
128821
128822 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
128823 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
128824
128825 -- 4955764
128826 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
128827 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
128828
128829 -- 4458381 Public Sector Enh
128830
128831 --
128832 -- set accounting attributes for the line type
128833 --
128834 l_entered_amt_idx := 3;
128835 l_accted_amt_idx := 8;
128836 l_bflow_applied_to_amt_idx := NULL; -- 5132302
128837 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
128838 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
128839 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
128840 l_rec_acct_attrs.array_char_value(2) := p_source_85;
128841 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
128842 l_rec_acct_attrs.array_num_value(3) := p_source_91;
128843 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
128844 l_rec_acct_attrs.array_char_value(4) := p_source_88;
128845 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
128846 l_rec_acct_attrs.array_date_value(5) := p_source_92;
128847 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
128848 l_rec_acct_attrs.array_num_value(6) := p_source_93;
128849 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
128850 l_rec_acct_attrs.array_char_value(7) := p_source_94;
128851 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
128852 l_rec_acct_attrs.array_num_value(8) := p_source_95;
128853
128854 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
128855 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
128856
128857 ---------------------------------------------------------------------------------------------------------------
128858 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
128859 ---------------------------------------------------------------------------------------------------------------
128860 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
128861
128862 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
128863 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
128864
128865 IF xla_accounting_cache_pkg.GetValueChar
128866 (p_source_code => 'LEDGER_CATEGORY_CODE'
128867 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
128868 AND l_bflow_method_code = 'PRIOR_ENTRY'
128869 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
128870 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
128871 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
128872 )
128873 THEN
128874 xla_ae_lines_pkg.BflowUpgEntry
128875 (p_business_method_code => l_bflow_method_code
128876 ,p_business_class_code => l_bflow_class_code
128877 ,p_balance_type => l_balance_type_code);
128878 ELSE
128879 NULL;
128880 -- No business flow processing for business flow method of NONE.
128881 END IF;
128882
128883 --
128884 -- call analytical criteria
128885 --
128886
128887
128888 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
128889 xla_ae_lines_pkg.SetAnalyticalCriteria(
128890 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
128891 , p_analytical_criterion_owner => 'S'
128892 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
128893 , p_amb_context_code => 'DEFAULT'
128894 , p_balancing_flag => 'Y'
128895
128896 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
128897 , p_analytical_detail_num_1 => NULL
128898 , p_analytical_detail_date_1 => NULL
128899
128900 , p_ae_header_id => l_ae_header_id
128901 )
128902 ;
128903 --
128904
128905 --
128906 -- call description
128907 --
128908
128909 xla_ae_lines_pkg.SetLineDescription(
128910 p_ae_header_id => l_ae_header_id
128911 ,p_description => Description_1 (
128912 p_application_id => p_application_id
128913 , p_ae_header_id => l_ae_header_id
128914 , p_source_1 => p_source_1
128915 , p_source_2 => p_source_2
128916 , p_source_3 => p_source_3
128917 , p_source_4 => p_source_4
128918 , p_source_5 => p_source_5
128919 )
128920 );
128921
128922
128923 --
128924 -- call ADRs
128925 -- Bug 4922099
128926 --
128927 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
128928 (NVL(l_actual_upg_option, 'N') = 'O') OR
128929 (NVL(l_enc_upg_option, 'N') = 'O')
128930 )
128931 THEN
128932 NULL;
128933 --
128934 --
128935
128936 l_ccid := AcctDerRule_28(
128937 p_application_id => p_application_id
128938 , p_ae_header_id => l_ae_header_id
128939 , p_source_15 => p_source_15
128940 , p_source_41 => p_source_41
128941 , p_source_42 => p_source_42
128942 , p_source_43 => p_source_43
128943 , p_source_44 => p_source_44
128944 , p_source_45 => p_source_45
128945 , x_transaction_coa_id => l_adr_transaction_coa_id
128946 , x_accounting_coa_id => l_adr_accounting_coa_id
128947 , x_value_type_code => l_adr_value_type_code
128948 , p_side => 'NA'
128949 );
128950
128951 xla_ae_lines_pkg.set_ccid(
128952 p_code_combination_id => l_ccid
128953 , p_value_type_code => l_adr_value_type_code
128954 , p_transaction_coa_id => l_adr_transaction_coa_id
128955 , p_accounting_coa_id => l_adr_accounting_coa_id
128956 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
128957 , p_adr_type_code => 'S'
128958 , p_component_type => l_component_type
128959 , p_component_code => l_component_code
128960 , p_component_type_code => l_component_type_code
128961 , p_component_appl_id => l_component_appl_id
128962 , p_amb_context_code => l_amb_context_code
128963 , p_side => 'NA'
128964 );
128965
128966
128967 --
128968 --
128969 END IF;
128970 --
128971 -- Bug 4922099
128972 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
128973 (NVL(l_enc_upg_option, 'N') = 'O')
128974 ) AND
128975 (l_bflow_method_code = 'PRIOR_ENTRY')
128976 )
128977 THEN
128978 IF
128979 --
128980 1 = 2
128981 --
128982 THEN
128983 xla_accounting_err_pkg.build_message
128984 (p_appli_s_name => 'XLA'
128985 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
128986 ,p_token_1 => 'LINE_NUMBER'
128987 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
128988 ,p_token_2 => 'LINE_TYPE_NAME'
128989 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
128990 l_component_type
128991 ,l_component_code
128992 ,l_component_type_code
128993 ,l_component_appl_id
128994 ,l_amb_context_code
128995 ,l_entity_code
128996 ,l_event_class_code
128997 )
128998 ,p_token_3 => 'OWNER'
128999 ,p_value_3 => xla_lookups_pkg.get_meaning(
129000 p_lookup_type => 'XLA_OWNER_TYPE'
129001 ,p_lookup_code => l_component_type_code
129002 )
129003 ,p_token_4 => 'PRODUCT_NAME'
129004 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
129005 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
129006 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
129007 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
129008 ,p_ae_header_id => NULL
129009 );
129010
129011 IF (C_LEVEL_ERROR>= g_log_level) THEN
129012 trace
129013 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
129014 ,p_level => C_LEVEL_ERROR
129015 ,p_module => l_log_module);
129016 END IF;
129017 END IF;
129018 END IF;
129019 --
129020 --
129021 ------------------------------------------------------------------------------------------------
129022 -- 4219869 Business Flow
129023 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
129024 -- Prior Entry. Currently, the following code is always generated.
129025 ------------------------------------------------------------------------------------------------
129026 XLA_AE_LINES_PKG.ValidateCurrentLine;
129027
129028 ------------------------------------------------------------------------------------
129029 -- 4219869 Business Flow
129030 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
129031 ------------------------------------------------------------------------------------
129032 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
129033
129034 ----------------------------------------------------------------------------------
129035 -- 4219869 Business Flow
129036 -- Update journal entry status -- Need to generate this within IF <condition>
129037 ----------------------------------------------------------------------------------
129038 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
129039 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
129040 ,p_balance_type_code => l_balance_type_code
129041 );
129042
129043 -------------------------------------------------------------------------------------------
129044 -- 4262811 - Generate the Accrual Reversal lines
129045 -------------------------------------------------------------------------------------------
129046 BEGIN
129047 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
129048 (g_array_event(p_event_id).array_value_num('header_index'));
129049 IF l_acc_rev_flag IS NULL THEN
129050 l_acc_rev_flag := 'N';
129051 END IF;
129052 EXCEPTION
129053 WHEN OTHERS THEN
129054 l_acc_rev_flag := 'N';
129055 END;
129056 --
129057 IF (l_acc_rev_flag = 'Y') THEN
129058
129059 -- 4645092 ------------------------------------------------------------------------------
129060 -- To allow MPA report to determine if it should generate report process
129061 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
129062 ------------------------------------------------------------------------------------------
129063
129064 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
129065 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
129066 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
129067 -- call ADRs
129068 -- Bug 4922099
129069 --
129070 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
129071 (NVL(l_actual_upg_option, 'N') = 'O') OR
129072 (NVL(l_enc_upg_option, 'N') = 'O')
129073 )
129074 THEN
129075 NULL;
129076 --
129077 --
129078
129079 l_ccid := AcctDerRule_28(
129080 p_application_id => p_application_id
129081 , p_ae_header_id => l_ae_header_id
129082 , p_source_15 => p_source_15
129083 , p_source_41 => p_source_41
129084 , p_source_42 => p_source_42
129085 , p_source_43 => p_source_43
129086 , p_source_44 => p_source_44
129087 , p_source_45 => p_source_45
129088 , x_transaction_coa_id => l_adr_transaction_coa_id
129089 , x_accounting_coa_id => l_adr_accounting_coa_id
129090 , x_value_type_code => l_adr_value_type_code
129091 , p_side => 'NA'
129092 );
129093
129094 xla_ae_lines_pkg.set_ccid(
129095 p_code_combination_id => l_ccid
129096 , p_value_type_code => l_adr_value_type_code
129097 , p_transaction_coa_id => l_adr_transaction_coa_id
129098 , p_accounting_coa_id => l_adr_accounting_coa_id
129099 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
129100 , p_adr_type_code => 'S'
129101 , p_component_type => l_component_type
129102 , p_component_code => l_component_code
129103 , p_component_type_code => l_component_type_code
129104 , p_component_appl_id => l_component_appl_id
129105 , p_amb_context_code => l_amb_context_code
129106 , p_side => 'NA'
129107 );
129108
129109
129110 --
129111 --
129112 END IF;
129113
129114 --
129115 -- Update the line information that should be overwritten
129116 --
129117 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
129118 p_header_num => 1);
129119 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
129120
129121 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
129122
129123 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
129124 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
129125 END IF;
129126
129127 --
129128 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
129129 --
129130 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
129131 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
129132 ELSE
129133 ---------------------------------------------------------------------------------------------------
129134 -- 4262811a Switch Sign
129135 ---------------------------------------------------------------------------------------------------
129136 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
129137 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
129138 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129139 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
129140 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129141 -- 5132302
129142 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
129143 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129144
129145 END IF;
129146
129147 -- 4955764
129148 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
129149 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
129150
129151
129152 XLA_AE_LINES_PKG.ValidateCurrentLine;
129153 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
129154
129155 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
129156 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
129157 ,p_balance_type_code => l_balance_type_code);
129158
129159 END IF;
129160
129161 -----------------------------------------------------------------------------------------
129162 -- 4262811 Multiperiod Accounting
129163 -----------------------------------------------------------------------------------------
129164 -- No MPA option is assigned.
129165
129166
129167 END IF;
129168 END IF;
129169 --
129170
129171 --
129172 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
129173 trace
129174 (p_msg => 'END of AcctLineType_247'
129175 ,p_level => C_LEVEL_PROCEDURE
129176 ,p_module => l_log_module);
129177 END IF;
129178 --
129179 EXCEPTION
129180 WHEN xla_exceptions_pkg.application_exception THEN
129181 RAISE;
129182 WHEN OTHERS THEN
129183 xla_exceptions_pkg.raise_message
129184 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_247');
129185 END AcctLineType_247;
129186 --
129187
129188 ---------------------------------------
129189 --
129190 -- PRIVATE FUNCTION
129191 -- AcctLineType_248
129192 --
129193 ---------------------------------------
129194 PROCEDURE AcctLineType_248 (
129195 p_application_id IN NUMBER
129196 ,p_event_id IN NUMBER
129197 ,p_calculate_acctd_flag IN VARCHAR2
129198 ,p_calculate_g_l_flag IN VARCHAR2
129199 ,p_actual_flag IN OUT VARCHAR2
129200 ,p_balance_type_code OUT VARCHAR2
129201 ,p_gain_or_loss_ref OUT VARCHAR2
129202
129203 --TRANSACTION_ID
129204 , p_source_1 IN NUMBER
129205 --Item Concatenated Segments
129206 , p_source_2 IN VARCHAR2
129207 --Transaction Quantity
129208 , p_source_3 IN NUMBER
129209 --Transaction Unit of Measure Code
129210 , p_source_4 IN VARCHAR2
129211 --Inventory Transaction Type Description
129212 , p_source_5 IN VARCHAR2
129213 --Cost Element Name
129214 , p_source_15 IN NUMBER
129215 --Product Line Accounting Category Material Account
129216 , p_source_41 IN NUMBER
129217 --Product Line Accounting Category Material Overhead Account
129218 , p_source_42 IN NUMBER
129219 --Product Line Accounting Category Resource Account
129220 , p_source_43 IN NUMBER
129221 --Product Line Accounting Category Outside Processing Account
129222 , p_source_44 IN NUMBER
129223 --Product Line Accounting Category Overhead Account
129224 , p_source_45 IN NUMBER
129225 --DISTRIBUTION_IDENTIFIER
129226 , p_source_84 IN NUMBER
129227 --Distribution Type
129228 , p_source_85 IN VARCHAR2
129229 , p_source_85_meaning IN VARCHAR2
129230 --Entered Currency Code
129231 , p_source_88 IN VARCHAR2
129232 --Entered Amount
129233 , p_source_91 IN NUMBER
129234 --Currency Conversion Date
129235 , p_source_92 IN DATE
129236 --Currency Conversion Rate
129237 , p_source_93 IN NUMBER
129238 --Currency Conversion Type
129239 , p_source_94 IN VARCHAR2
129240 --Accounted Amount
129241 , p_source_95 IN NUMBER
129242 --Accounting Line Type
129243 , p_source_97 IN NUMBER
129244 --Organization Code
129245 , p_source_108 IN VARCHAR2
129246 )
129247 IS
129248
129249 l_component_type VARCHAR2(80);
129250 l_component_code VARCHAR2(30);
129251 l_component_type_code VARCHAR2(1);
129252 l_component_appl_id INTEGER;
129253 l_amb_context_code VARCHAR2(30);
129254 l_entity_code VARCHAR2(30);
129255 l_event_class_code VARCHAR2(30);
129256 l_ae_header_id NUMBER;
129257 l_event_type_code VARCHAR2(30);
129258 l_line_definition_code VARCHAR2(30);
129259 l_line_definition_owner_code VARCHAR2(1);
129260 --
129261 -- adr variables
129262 l_segment VARCHAR2(30);
129263 l_ccid NUMBER;
129264 l_adr_transaction_coa_id NUMBER;
129265 l_adr_accounting_coa_id NUMBER;
129266 l_adr_flexfield_segment_code VARCHAR2(30);
129267 l_adr_flex_value_set_id NUMBER;
129268 l_adr_value_type_code VARCHAR2(30);
129269 l_adr_value_combination_id NUMBER;
129270 l_adr_value_segment_code VARCHAR2(30);
129271
129272 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
129273 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
129274 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
129275 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
129276
129277 -- 4262811 Variables ------------------------------------------------------------------------------------------
129278 l_entered_amt_idx NUMBER;
129279 l_accted_amt_idx NUMBER;
129280 l_acc_rev_flag VARCHAR2(1);
129281 l_accrual_line_num NUMBER;
129282 l_tmp_amt NUMBER;
129283 l_acc_rev_natural_side_code VARCHAR2(1);
129284
129285 l_num_entries NUMBER;
129286 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
129287 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
129288 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
129289 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
129290 l_recog_line_1 NUMBER;
129291 l_recog_line_2 NUMBER;
129292
129293 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
129294 l_bflow_applied_to_amt NUMBER; -- 5132302
129295 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
129296
129297 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
129298
129299 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
129300 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
129301
129302 ---------------------------------------------------------------------------------------------------------------
129303
129304
129305 --
129306 -- bulk performance
129307 --
129308 l_balance_type_code VARCHAR2(1);
129309 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
129310 l_log_module VARCHAR2(240);
129311
129312 --
129313 -- Upgrade strategy
129314 --
129315 l_actual_upg_option VARCHAR2(1);
129316 l_enc_upg_option VARCHAR2(1);
129317
129318 --
129319 BEGIN
129320 --
129321 IF g_log_enabled THEN
129322 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_248';
129323 END IF;
129324 --
129325 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
129326
129327 trace
129328 (p_msg => 'BEGIN of AcctLineType_248'
129329 ,p_level => C_LEVEL_PROCEDURE
129330 ,p_module => l_log_module);
129331
129332 END IF;
129333 --
129334 l_component_type := 'AMB_JLT';
129335 l_component_code := 'INVENTORY_VALUATION';
129336 l_component_type_code := 'S';
129337 l_component_appl_id := 707;
129338 l_amb_context_code := 'DEFAULT';
129339 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
129340 l_event_class_code := 'DIR_INTERORG_SHIP';
129341 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
129342 l_line_definition_owner_code := 'S';
129343 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
129344 --
129345 l_balance_type_code := 'A';
129346 l_segment := NULL;
129347 l_ccid := NULL;
129348 l_adr_transaction_coa_id := NULL;
129349 l_adr_accounting_coa_id := NULL;
129350 l_adr_flexfield_segment_code := NULL;
129351 l_adr_flex_value_set_id := NULL;
129352 l_adr_value_type_code := NULL;
129353 l_adr_value_combination_id := NULL;
129354 l_adr_value_segment_code := NULL;
129355
129356 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
129357 l_bflow_class_code := ''; -- 4219869 Business Flow
129358 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
129359 l_budgetary_control_flag := 'N';
129360
129361 l_bflow_applied_to_amt_idx := NULL; -- 5132302
129362 l_bflow_applied_to_amt := NULL; -- 5132302
129363 l_entered_amt_idx := NULL; -- 4262811
129364 l_accted_amt_idx := NULL; -- 4262811
129365 l_acc_rev_flag := NULL; -- 4262811
129366 l_accrual_line_num := NULL; -- 4262811
129367 l_tmp_amt := NULL; -- 4262811
129368 --
129369
129370 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
129371 l_balance_type_code <> 'B' THEN
129372 IF NVL(p_source_97,9E125) = 1
129373 THEN
129374
129375 --
129376 XLA_AE_LINES_PKG.SetNewLine;
129377
129378 p_balance_type_code := l_balance_type_code;
129379 -- set the flag so later we will know whether the gain loss line needs to be created
129380
129381 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
129382 p_actual_flag :='A';
129383 END IF;
129384
129385 --
129386 -- bulk performance
129387 --
129388 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
129389 p_header_num => 0); -- 4262811
129390 --
129391 -- set accounting line options
129392 --
129393 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
129394 p_natural_side_code => 'D'
129395 , p_gain_or_loss_flag => 'N'
129396 , p_gl_transfer_mode_code => 'S'
129397 , p_acct_entry_type_code => 'A'
129398 , p_switch_side_flag => 'Y'
129399 , p_merge_duplicate_code => 'N'
129400 );
129401 --
129402 l_acc_rev_natural_side_code := 'C'; -- 4262811
129403 --
129404 --
129405 -- set accounting line type info
129406 --
129407 xla_ae_lines_pkg.SetAcctLineType
129408 (p_component_type => l_component_type
129409 ,p_event_type_code => l_event_type_code
129410 ,p_line_definition_owner_code => l_line_definition_owner_code
129411 ,p_line_definition_code => l_line_definition_code
129412 ,p_accounting_line_code => l_component_code
129413 ,p_accounting_line_type_code => l_component_type_code
129414 ,p_accounting_line_appl_id => l_component_appl_id
129415 ,p_amb_context_code => l_amb_context_code
129416 ,p_entity_code => l_entity_code
129417 ,p_event_class_code => l_event_class_code);
129418 --
129419 -- set accounting class
129420 --
129421 xla_ae_lines_pkg.SetAcctClass(
129422 p_accounting_class_code => 'INVENTORY_VALUATION'
129423 , p_ae_header_id => l_ae_header_id
129424 );
129425
129426 --
129427 -- set rounding class
129428 --
129429 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
129430 'INVENTORY_VALUATION';
129431
129432 --
129433 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
129434 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
129435 --
129436 -- bulk performance
129437 --
129438 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
129439
129440 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
129441 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
129442
129443 -- 4955764
129444 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
129445 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
129446
129447 -- 4458381 Public Sector Enh
129448
129449 --
129450 -- set accounting attributes for the line type
129451 --
129452 l_entered_amt_idx := 3;
129453 l_accted_amt_idx := 8;
129454 l_bflow_applied_to_amt_idx := NULL; -- 5132302
129455 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
129456 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
129457 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
129458 l_rec_acct_attrs.array_char_value(2) := p_source_85;
129459 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
129460 l_rec_acct_attrs.array_num_value(3) := p_source_91;
129461 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
129462 l_rec_acct_attrs.array_char_value(4) := p_source_88;
129463 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
129464 l_rec_acct_attrs.array_date_value(5) := p_source_92;
129465 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
129466 l_rec_acct_attrs.array_num_value(6) := p_source_93;
129467 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
129468 l_rec_acct_attrs.array_char_value(7) := p_source_94;
129469 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
129470 l_rec_acct_attrs.array_num_value(8) := p_source_95;
129471
129472 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
129473 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
129474
129475 ---------------------------------------------------------------------------------------------------------------
129476 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
129477 ---------------------------------------------------------------------------------------------------------------
129478 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
129479
129480 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
129481 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
129482
129483 IF xla_accounting_cache_pkg.GetValueChar
129484 (p_source_code => 'LEDGER_CATEGORY_CODE'
129485 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
129486 AND l_bflow_method_code = 'PRIOR_ENTRY'
129487 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
129488 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
129489 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
129490 )
129491 THEN
129492 xla_ae_lines_pkg.BflowUpgEntry
129493 (p_business_method_code => l_bflow_method_code
129494 ,p_business_class_code => l_bflow_class_code
129495 ,p_balance_type => l_balance_type_code);
129496 ELSE
129497 NULL;
129498 -- No business flow processing for business flow method of NONE.
129499 END IF;
129500
129501 --
129502 -- call analytical criteria
129503 --
129504
129505
129506 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
129507 xla_ae_lines_pkg.SetAnalyticalCriteria(
129508 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
129509 , p_analytical_criterion_owner => 'S'
129510 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
129511 , p_amb_context_code => 'DEFAULT'
129512 , p_balancing_flag => 'Y'
129513
129514 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
129515 , p_analytical_detail_num_1 => NULL
129516 , p_analytical_detail_date_1 => NULL
129517
129518 , p_ae_header_id => l_ae_header_id
129519 )
129520 ;
129521 --
129522
129523 --
129524 -- call description
129525 --
129526
129527 xla_ae_lines_pkg.SetLineDescription(
129528 p_ae_header_id => l_ae_header_id
129529 ,p_description => Description_1 (
129530 p_application_id => p_application_id
129531 , p_ae_header_id => l_ae_header_id
129532 , p_source_1 => p_source_1
129533 , p_source_2 => p_source_2
129534 , p_source_3 => p_source_3
129535 , p_source_4 => p_source_4
129536 , p_source_5 => p_source_5
129537 )
129538 );
129539
129540
129541 --
129542 -- call ADRs
129543 -- Bug 4922099
129544 --
129545 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
129546 (NVL(l_actual_upg_option, 'N') = 'O') OR
129547 (NVL(l_enc_upg_option, 'N') = 'O')
129548 )
129549 THEN
129550 NULL;
129551 --
129552 --
129553
129554 l_ccid := AcctDerRule_28(
129555 p_application_id => p_application_id
129556 , p_ae_header_id => l_ae_header_id
129557 , p_source_15 => p_source_15
129558 , p_source_41 => p_source_41
129559 , p_source_42 => p_source_42
129560 , p_source_43 => p_source_43
129561 , p_source_44 => p_source_44
129562 , p_source_45 => p_source_45
129563 , x_transaction_coa_id => l_adr_transaction_coa_id
129564 , x_accounting_coa_id => l_adr_accounting_coa_id
129565 , x_value_type_code => l_adr_value_type_code
129566 , p_side => 'NA'
129567 );
129568
129569 xla_ae_lines_pkg.set_ccid(
129570 p_code_combination_id => l_ccid
129571 , p_value_type_code => l_adr_value_type_code
129572 , p_transaction_coa_id => l_adr_transaction_coa_id
129573 , p_accounting_coa_id => l_adr_accounting_coa_id
129574 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
129575 , p_adr_type_code => 'S'
129576 , p_component_type => l_component_type
129577 , p_component_code => l_component_code
129578 , p_component_type_code => l_component_type_code
129579 , p_component_appl_id => l_component_appl_id
129580 , p_amb_context_code => l_amb_context_code
129581 , p_side => 'NA'
129582 );
129583
129584
129585 --
129586 --
129587 END IF;
129588 --
129589 -- Bug 4922099
129590 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
129591 (NVL(l_enc_upg_option, 'N') = 'O')
129592 ) AND
129593 (l_bflow_method_code = 'PRIOR_ENTRY')
129594 )
129595 THEN
129596 IF
129597 --
129598 1 = 2
129599 --
129600 THEN
129601 xla_accounting_err_pkg.build_message
129602 (p_appli_s_name => 'XLA'
129603 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
129604 ,p_token_1 => 'LINE_NUMBER'
129605 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
129606 ,p_token_2 => 'LINE_TYPE_NAME'
129607 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
129608 l_component_type
129609 ,l_component_code
129610 ,l_component_type_code
129611 ,l_component_appl_id
129612 ,l_amb_context_code
129613 ,l_entity_code
129614 ,l_event_class_code
129615 )
129616 ,p_token_3 => 'OWNER'
129617 ,p_value_3 => xla_lookups_pkg.get_meaning(
129618 p_lookup_type => 'XLA_OWNER_TYPE'
129619 ,p_lookup_code => l_component_type_code
129620 )
129621 ,p_token_4 => 'PRODUCT_NAME'
129622 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
129623 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
129624 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
129625 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
129626 ,p_ae_header_id => NULL
129627 );
129628
129629 IF (C_LEVEL_ERROR>= g_log_level) THEN
129630 trace
129631 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
129632 ,p_level => C_LEVEL_ERROR
129633 ,p_module => l_log_module);
129634 END IF;
129635 END IF;
129636 END IF;
129637 --
129638 --
129639 ------------------------------------------------------------------------------------------------
129640 -- 4219869 Business Flow
129641 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
129642 -- Prior Entry. Currently, the following code is always generated.
129643 ------------------------------------------------------------------------------------------------
129644 XLA_AE_LINES_PKG.ValidateCurrentLine;
129645
129646 ------------------------------------------------------------------------------------
129647 -- 4219869 Business Flow
129648 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
129649 ------------------------------------------------------------------------------------
129650 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
129651
129652 ----------------------------------------------------------------------------------
129653 -- 4219869 Business Flow
129654 -- Update journal entry status -- Need to generate this within IF <condition>
129655 ----------------------------------------------------------------------------------
129656 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
129657 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
129658 ,p_balance_type_code => l_balance_type_code
129659 );
129660
129661 -------------------------------------------------------------------------------------------
129662 -- 4262811 - Generate the Accrual Reversal lines
129663 -------------------------------------------------------------------------------------------
129664 BEGIN
129665 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
129666 (g_array_event(p_event_id).array_value_num('header_index'));
129667 IF l_acc_rev_flag IS NULL THEN
129668 l_acc_rev_flag := 'N';
129669 END IF;
129670 EXCEPTION
129671 WHEN OTHERS THEN
129672 l_acc_rev_flag := 'N';
129673 END;
129674 --
129675 IF (l_acc_rev_flag = 'Y') THEN
129676
129677 -- 4645092 ------------------------------------------------------------------------------
129678 -- To allow MPA report to determine if it should generate report process
129679 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
129680 ------------------------------------------------------------------------------------------
129681
129682 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
129683 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
129684 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
129685 -- call ADRs
129686 -- Bug 4922099
129687 --
129688 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
129689 (NVL(l_actual_upg_option, 'N') = 'O') OR
129690 (NVL(l_enc_upg_option, 'N') = 'O')
129691 )
129692 THEN
129693 NULL;
129694 --
129695 --
129696
129697 l_ccid := AcctDerRule_28(
129698 p_application_id => p_application_id
129699 , p_ae_header_id => l_ae_header_id
129700 , p_source_15 => p_source_15
129701 , p_source_41 => p_source_41
129702 , p_source_42 => p_source_42
129703 , p_source_43 => p_source_43
129704 , p_source_44 => p_source_44
129705 , p_source_45 => p_source_45
129706 , x_transaction_coa_id => l_adr_transaction_coa_id
129707 , x_accounting_coa_id => l_adr_accounting_coa_id
129708 , x_value_type_code => l_adr_value_type_code
129709 , p_side => 'NA'
129710 );
129711
129712 xla_ae_lines_pkg.set_ccid(
129713 p_code_combination_id => l_ccid
129714 , p_value_type_code => l_adr_value_type_code
129715 , p_transaction_coa_id => l_adr_transaction_coa_id
129716 , p_accounting_coa_id => l_adr_accounting_coa_id
129717 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
129718 , p_adr_type_code => 'S'
129719 , p_component_type => l_component_type
129720 , p_component_code => l_component_code
129721 , p_component_type_code => l_component_type_code
129722 , p_component_appl_id => l_component_appl_id
129723 , p_amb_context_code => l_amb_context_code
129724 , p_side => 'NA'
129725 );
129726
129727
129728 --
129729 --
129730 END IF;
129731
129732 --
129733 -- Update the line information that should be overwritten
129734 --
129735 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
129736 p_header_num => 1);
129737 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
129738
129739 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
129740
129741 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
129742 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
129743 END IF;
129744
129745 --
129746 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
129747 --
129748 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
129749 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
129750 ELSE
129751 ---------------------------------------------------------------------------------------------------
129752 -- 4262811a Switch Sign
129753 ---------------------------------------------------------------------------------------------------
129754 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
129755 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
129756 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129757 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
129758 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129759 -- 5132302
129760 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
129761 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
129762
129763 END IF;
129764
129765 -- 4955764
129766 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
129767 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
129768
129769
129770 XLA_AE_LINES_PKG.ValidateCurrentLine;
129771 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
129772
129773 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
129774 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
129775 ,p_balance_type_code => l_balance_type_code);
129776
129777 END IF;
129778
129779 -----------------------------------------------------------------------------------------
129780 -- 4262811 Multiperiod Accounting
129781 -----------------------------------------------------------------------------------------
129782 -- No MPA option is assigned.
129783
129784
129785 END IF;
129786 END IF;
129787 --
129788
129789 --
129790 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
129791 trace
129792 (p_msg => 'END of AcctLineType_248'
129793 ,p_level => C_LEVEL_PROCEDURE
129794 ,p_module => l_log_module);
129795 END IF;
129796 --
129797 EXCEPTION
129798 WHEN xla_exceptions_pkg.application_exception THEN
129799 RAISE;
129800 WHEN OTHERS THEN
129801 xla_exceptions_pkg.raise_message
129802 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_248');
129803 END AcctLineType_248;
129804 --
129805
129806 ---------------------------------------
129807 --
129808 -- PRIVATE FUNCTION
129809 -- AcctLineType_249
129810 --
129811 ---------------------------------------
129812 PROCEDURE AcctLineType_249 (
129813 p_application_id IN NUMBER
129814 ,p_event_id IN NUMBER
129815 ,p_calculate_acctd_flag IN VARCHAR2
129816 ,p_calculate_g_l_flag IN VARCHAR2
129817 ,p_actual_flag IN OUT VARCHAR2
129818 ,p_balance_type_code OUT VARCHAR2
129819 ,p_gain_or_loss_ref OUT VARCHAR2
129820
129821 --TRANSACTION_ID
129822 , p_source_1 IN NUMBER
129823 --Item Concatenated Segments
129824 , p_source_2 IN VARCHAR2
129825 --Transaction Quantity
129826 , p_source_3 IN NUMBER
129827 --Transaction Unit of Measure Code
129828 , p_source_4 IN VARCHAR2
129829 --Inventory Transaction Type Description
129830 , p_source_5 IN VARCHAR2
129831 --Cost Element Name
129832 , p_source_15 IN NUMBER
129833 --Product Line Accounting Category Material Account
129834 , p_source_41 IN NUMBER
129835 --Product Line Accounting Category Material Overhead Account
129836 , p_source_42 IN NUMBER
129837 --Product Line Accounting Category Resource Account
129838 , p_source_43 IN NUMBER
129839 --Product Line Accounting Category Outside Processing Account
129840 , p_source_44 IN NUMBER
129841 --Product Line Accounting Category Overhead Account
129842 , p_source_45 IN NUMBER
129843 --DISTRIBUTION_IDENTIFIER
129844 , p_source_84 IN NUMBER
129845 --Distribution Type
129846 , p_source_85 IN VARCHAR2
129847 , p_source_85_meaning IN VARCHAR2
129848 --Entered Currency Code
129849 , p_source_88 IN VARCHAR2
129850 --Entered Amount
129851 , p_source_91 IN NUMBER
129852 --Currency Conversion Date
129853 , p_source_92 IN DATE
129854 --Currency Conversion Rate
129855 , p_source_93 IN NUMBER
129856 --Currency Conversion Type
129857 , p_source_94 IN VARCHAR2
129858 --Accounted Amount
129859 , p_source_95 IN NUMBER
129860 --Accounting Line Type
129861 , p_source_97 IN NUMBER
129862 --Organization Code
129863 , p_source_108 IN VARCHAR2
129864 )
129865 IS
129866
129867 l_component_type VARCHAR2(80);
129868 l_component_code VARCHAR2(30);
129869 l_component_type_code VARCHAR2(1);
129870 l_component_appl_id INTEGER;
129871 l_amb_context_code VARCHAR2(30);
129872 l_entity_code VARCHAR2(30);
129873 l_event_class_code VARCHAR2(30);
129874 l_ae_header_id NUMBER;
129875 l_event_type_code VARCHAR2(30);
129876 l_line_definition_code VARCHAR2(30);
129877 l_line_definition_owner_code VARCHAR2(1);
129878 --
129879 -- adr variables
129880 l_segment VARCHAR2(30);
129881 l_ccid NUMBER;
129882 l_adr_transaction_coa_id NUMBER;
129883 l_adr_accounting_coa_id NUMBER;
129884 l_adr_flexfield_segment_code VARCHAR2(30);
129885 l_adr_flex_value_set_id NUMBER;
129886 l_adr_value_type_code VARCHAR2(30);
129887 l_adr_value_combination_id NUMBER;
129888 l_adr_value_segment_code VARCHAR2(30);
129889
129890 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
129891 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
129892 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
129893 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
129894
129895 -- 4262811 Variables ------------------------------------------------------------------------------------------
129896 l_entered_amt_idx NUMBER;
129897 l_accted_amt_idx NUMBER;
129898 l_acc_rev_flag VARCHAR2(1);
129899 l_accrual_line_num NUMBER;
129900 l_tmp_amt NUMBER;
129901 l_acc_rev_natural_side_code VARCHAR2(1);
129902
129903 l_num_entries NUMBER;
129904 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
129905 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
129906 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
129907 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
129908 l_recog_line_1 NUMBER;
129909 l_recog_line_2 NUMBER;
129910
129911 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
129912 l_bflow_applied_to_amt NUMBER; -- 5132302
129913 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
129914
129915 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
129916
129917 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
129918 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
129919
129920 ---------------------------------------------------------------------------------------------------------------
129921
129922
129923 --
129924 -- bulk performance
129925 --
129926 l_balance_type_code VARCHAR2(1);
129927 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
129928 l_log_module VARCHAR2(240);
129929
129930 --
129931 -- Upgrade strategy
129932 --
129933 l_actual_upg_option VARCHAR2(1);
129934 l_enc_upg_option VARCHAR2(1);
129935
129936 --
129937 BEGIN
129938 --
129939 IF g_log_enabled THEN
129940 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_249';
129941 END IF;
129942 --
129943 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
129944
129945 trace
129946 (p_msg => 'BEGIN of AcctLineType_249'
129947 ,p_level => C_LEVEL_PROCEDURE
129948 ,p_module => l_log_module);
129949
129950 END IF;
129951 --
129952 l_component_type := 'AMB_JLT';
129953 l_component_code := 'INVENTORY_VALUATION';
129954 l_component_type_code := 'S';
129955 l_component_appl_id := 707;
129956 l_amb_context_code := 'DEFAULT';
129957 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
129958 l_event_class_code := 'MTL_COST_UPD';
129959 l_event_type_code := 'STD_COST_UPD';
129960 l_line_definition_owner_code := 'S';
129961 l_line_definition_code := 'PI_STD_COST_UPD';
129962 --
129963 l_balance_type_code := 'A';
129964 l_segment := NULL;
129965 l_ccid := NULL;
129966 l_adr_transaction_coa_id := NULL;
129967 l_adr_accounting_coa_id := NULL;
129968 l_adr_flexfield_segment_code := NULL;
129969 l_adr_flex_value_set_id := NULL;
129970 l_adr_value_type_code := NULL;
129971 l_adr_value_combination_id := NULL;
129972 l_adr_value_segment_code := NULL;
129973
129974 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
129975 l_bflow_class_code := ''; -- 4219869 Business Flow
129976 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
129977 l_budgetary_control_flag := 'N';
129978
129979 l_bflow_applied_to_amt_idx := NULL; -- 5132302
129980 l_bflow_applied_to_amt := NULL; -- 5132302
129981 l_entered_amt_idx := NULL; -- 4262811
129982 l_accted_amt_idx := NULL; -- 4262811
129983 l_acc_rev_flag := NULL; -- 4262811
129984 l_accrual_line_num := NULL; -- 4262811
129985 l_tmp_amt := NULL; -- 4262811
129986 --
129987
129988 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
129989 l_balance_type_code <> 'B' THEN
129990 IF NVL(p_source_97,9E125) = 1
129991 THEN
129992
129993 --
129994 XLA_AE_LINES_PKG.SetNewLine;
129995
129996 p_balance_type_code := l_balance_type_code;
129997 -- set the flag so later we will know whether the gain loss line needs to be created
129998
129999 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
130000 p_actual_flag :='A';
130001 END IF;
130002
130003 --
130004 -- bulk performance
130005 --
130006 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
130007 p_header_num => 0); -- 4262811
130008 --
130009 -- set accounting line options
130010 --
130011 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
130012 p_natural_side_code => 'D'
130013 , p_gain_or_loss_flag => 'N'
130014 , p_gl_transfer_mode_code => 'S'
130015 , p_acct_entry_type_code => 'A'
130016 , p_switch_side_flag => 'Y'
130017 , p_merge_duplicate_code => 'N'
130018 );
130019 --
130020 l_acc_rev_natural_side_code := 'C'; -- 4262811
130021 --
130022 --
130023 -- set accounting line type info
130024 --
130025 xla_ae_lines_pkg.SetAcctLineType
130026 (p_component_type => l_component_type
130027 ,p_event_type_code => l_event_type_code
130028 ,p_line_definition_owner_code => l_line_definition_owner_code
130029 ,p_line_definition_code => l_line_definition_code
130030 ,p_accounting_line_code => l_component_code
130031 ,p_accounting_line_type_code => l_component_type_code
130032 ,p_accounting_line_appl_id => l_component_appl_id
130033 ,p_amb_context_code => l_amb_context_code
130034 ,p_entity_code => l_entity_code
130035 ,p_event_class_code => l_event_class_code);
130036 --
130037 -- set accounting class
130038 --
130039 xla_ae_lines_pkg.SetAcctClass(
130040 p_accounting_class_code => 'INVENTORY_VALUATION'
130041 , p_ae_header_id => l_ae_header_id
130042 );
130043
130044 --
130045 -- set rounding class
130046 --
130047 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
130048 'INVENTORY_VALUATION';
130049
130050 --
130051 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
130052 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
130053 --
130054 -- bulk performance
130055 --
130056 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
130057
130058 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
130059 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
130060
130061 -- 4955764
130062 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
130063 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
130064
130065 -- 4458381 Public Sector Enh
130066
130067 --
130068 -- set accounting attributes for the line type
130069 --
130070 l_entered_amt_idx := 3;
130071 l_accted_amt_idx := 8;
130072 l_bflow_applied_to_amt_idx := NULL; -- 5132302
130073 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
130074 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
130075 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
130076 l_rec_acct_attrs.array_char_value(2) := p_source_85;
130077 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
130078 l_rec_acct_attrs.array_num_value(3) := p_source_91;
130079 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
130080 l_rec_acct_attrs.array_char_value(4) := p_source_88;
130081 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
130082 l_rec_acct_attrs.array_date_value(5) := p_source_92;
130083 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
130084 l_rec_acct_attrs.array_num_value(6) := p_source_93;
130085 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
130086 l_rec_acct_attrs.array_char_value(7) := p_source_94;
130087 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
130088 l_rec_acct_attrs.array_num_value(8) := p_source_95;
130089
130090 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
130091 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
130092
130093 ---------------------------------------------------------------------------------------------------------------
130094 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
130095 ---------------------------------------------------------------------------------------------------------------
130096 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
130097
130098 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
130099 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
130100
130101 IF xla_accounting_cache_pkg.GetValueChar
130102 (p_source_code => 'LEDGER_CATEGORY_CODE'
130103 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
130104 AND l_bflow_method_code = 'PRIOR_ENTRY'
130105 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
130106 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
130107 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
130108 )
130109 THEN
130110 xla_ae_lines_pkg.BflowUpgEntry
130111 (p_business_method_code => l_bflow_method_code
130112 ,p_business_class_code => l_bflow_class_code
130113 ,p_balance_type => l_balance_type_code);
130114 ELSE
130115 NULL;
130116 -- No business flow processing for business flow method of NONE.
130117 END IF;
130118
130119 --
130120 -- call analytical criteria
130121 --
130122
130123
130124 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
130125 xla_ae_lines_pkg.SetAnalyticalCriteria(
130126 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
130127 , p_analytical_criterion_owner => 'S'
130128 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
130129 , p_amb_context_code => 'DEFAULT'
130130 , p_balancing_flag => 'Y'
130131
130132 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
130133 , p_analytical_detail_num_1 => NULL
130134 , p_analytical_detail_date_1 => NULL
130135
130136 , p_ae_header_id => l_ae_header_id
130137 )
130138 ;
130139 --
130140
130141 --
130142 -- call description
130143 --
130144
130145 xla_ae_lines_pkg.SetLineDescription(
130146 p_ae_header_id => l_ae_header_id
130147 ,p_description => Description_1 (
130148 p_application_id => p_application_id
130149 , p_ae_header_id => l_ae_header_id
130150 , p_source_1 => p_source_1
130151 , p_source_2 => p_source_2
130152 , p_source_3 => p_source_3
130153 , p_source_4 => p_source_4
130154 , p_source_5 => p_source_5
130155 )
130156 );
130157
130158
130159 --
130160 -- call ADRs
130161 -- Bug 4922099
130162 --
130163 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
130164 (NVL(l_actual_upg_option, 'N') = 'O') OR
130165 (NVL(l_enc_upg_option, 'N') = 'O')
130166 )
130167 THEN
130168 NULL;
130169 --
130170 --
130171
130172 l_ccid := AcctDerRule_28(
130173 p_application_id => p_application_id
130174 , p_ae_header_id => l_ae_header_id
130175 , p_source_15 => p_source_15
130176 , p_source_41 => p_source_41
130177 , p_source_42 => p_source_42
130178 , p_source_43 => p_source_43
130179 , p_source_44 => p_source_44
130180 , p_source_45 => p_source_45
130181 , x_transaction_coa_id => l_adr_transaction_coa_id
130182 , x_accounting_coa_id => l_adr_accounting_coa_id
130183 , x_value_type_code => l_adr_value_type_code
130184 , p_side => 'NA'
130185 );
130186
130187 xla_ae_lines_pkg.set_ccid(
130188 p_code_combination_id => l_ccid
130189 , p_value_type_code => l_adr_value_type_code
130190 , p_transaction_coa_id => l_adr_transaction_coa_id
130191 , p_accounting_coa_id => l_adr_accounting_coa_id
130192 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
130193 , p_adr_type_code => 'S'
130194 , p_component_type => l_component_type
130195 , p_component_code => l_component_code
130196 , p_component_type_code => l_component_type_code
130197 , p_component_appl_id => l_component_appl_id
130198 , p_amb_context_code => l_amb_context_code
130199 , p_side => 'NA'
130200 );
130201
130202
130203 --
130204 --
130205 END IF;
130206 --
130207 -- Bug 4922099
130208 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
130209 (NVL(l_enc_upg_option, 'N') = 'O')
130210 ) AND
130211 (l_bflow_method_code = 'PRIOR_ENTRY')
130212 )
130213 THEN
130214 IF
130215 --
130216 1 = 2
130217 --
130218 THEN
130219 xla_accounting_err_pkg.build_message
130220 (p_appli_s_name => 'XLA'
130221 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
130222 ,p_token_1 => 'LINE_NUMBER'
130223 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
130224 ,p_token_2 => 'LINE_TYPE_NAME'
130225 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
130226 l_component_type
130227 ,l_component_code
130228 ,l_component_type_code
130229 ,l_component_appl_id
130230 ,l_amb_context_code
130231 ,l_entity_code
130232 ,l_event_class_code
130233 )
130234 ,p_token_3 => 'OWNER'
130235 ,p_value_3 => xla_lookups_pkg.get_meaning(
130236 p_lookup_type => 'XLA_OWNER_TYPE'
130237 ,p_lookup_code => l_component_type_code
130238 )
130239 ,p_token_4 => 'PRODUCT_NAME'
130240 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
130241 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
130242 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
130243 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
130244 ,p_ae_header_id => NULL
130245 );
130246
130247 IF (C_LEVEL_ERROR>= g_log_level) THEN
130248 trace
130249 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
130250 ,p_level => C_LEVEL_ERROR
130251 ,p_module => l_log_module);
130252 END IF;
130253 END IF;
130254 END IF;
130255 --
130256 --
130257 ------------------------------------------------------------------------------------------------
130258 -- 4219869 Business Flow
130259 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
130260 -- Prior Entry. Currently, the following code is always generated.
130261 ------------------------------------------------------------------------------------------------
130262 XLA_AE_LINES_PKG.ValidateCurrentLine;
130263
130264 ------------------------------------------------------------------------------------
130265 -- 4219869 Business Flow
130266 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
130267 ------------------------------------------------------------------------------------
130268 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
130269
130270 ----------------------------------------------------------------------------------
130271 -- 4219869 Business Flow
130272 -- Update journal entry status -- Need to generate this within IF <condition>
130273 ----------------------------------------------------------------------------------
130274 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
130275 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
130276 ,p_balance_type_code => l_balance_type_code
130277 );
130278
130279 -------------------------------------------------------------------------------------------
130280 -- 4262811 - Generate the Accrual Reversal lines
130281 -------------------------------------------------------------------------------------------
130282 BEGIN
130283 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
130284 (g_array_event(p_event_id).array_value_num('header_index'));
130285 IF l_acc_rev_flag IS NULL THEN
130286 l_acc_rev_flag := 'N';
130287 END IF;
130288 EXCEPTION
130289 WHEN OTHERS THEN
130290 l_acc_rev_flag := 'N';
130291 END;
130292 --
130293 IF (l_acc_rev_flag = 'Y') THEN
130294
130295 -- 4645092 ------------------------------------------------------------------------------
130296 -- To allow MPA report to determine if it should generate report process
130297 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
130298 ------------------------------------------------------------------------------------------
130299
130300 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
130301 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
130302 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
130303 -- call ADRs
130304 -- Bug 4922099
130305 --
130306 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
130307 (NVL(l_actual_upg_option, 'N') = 'O') OR
130308 (NVL(l_enc_upg_option, 'N') = 'O')
130309 )
130310 THEN
130311 NULL;
130312 --
130313 --
130314
130315 l_ccid := AcctDerRule_28(
130316 p_application_id => p_application_id
130317 , p_ae_header_id => l_ae_header_id
130318 , p_source_15 => p_source_15
130319 , p_source_41 => p_source_41
130320 , p_source_42 => p_source_42
130321 , p_source_43 => p_source_43
130322 , p_source_44 => p_source_44
130323 , p_source_45 => p_source_45
130324 , x_transaction_coa_id => l_adr_transaction_coa_id
130325 , x_accounting_coa_id => l_adr_accounting_coa_id
130326 , x_value_type_code => l_adr_value_type_code
130327 , p_side => 'NA'
130328 );
130329
130330 xla_ae_lines_pkg.set_ccid(
130331 p_code_combination_id => l_ccid
130332 , p_value_type_code => l_adr_value_type_code
130333 , p_transaction_coa_id => l_adr_transaction_coa_id
130334 , p_accounting_coa_id => l_adr_accounting_coa_id
130335 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
130336 , p_adr_type_code => 'S'
130337 , p_component_type => l_component_type
130338 , p_component_code => l_component_code
130339 , p_component_type_code => l_component_type_code
130340 , p_component_appl_id => l_component_appl_id
130341 , p_amb_context_code => l_amb_context_code
130342 , p_side => 'NA'
130343 );
130344
130345
130346 --
130347 --
130348 END IF;
130349
130350 --
130351 -- Update the line information that should be overwritten
130352 --
130353 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
130354 p_header_num => 1);
130355 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
130356
130357 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
130358
130359 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
130360 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
130361 END IF;
130362
130363 --
130364 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
130365 --
130366 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
130367 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
130368 ELSE
130369 ---------------------------------------------------------------------------------------------------
130370 -- 4262811a Switch Sign
130371 ---------------------------------------------------------------------------------------------------
130372 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
130373 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
130374 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130375 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
130376 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130377 -- 5132302
130378 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
130379 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130380
130381 END IF;
130382
130383 -- 4955764
130384 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
130385 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
130386
130387
130388 XLA_AE_LINES_PKG.ValidateCurrentLine;
130389 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
130390
130391 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
130392 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
130393 ,p_balance_type_code => l_balance_type_code);
130394
130395 END IF;
130396
130397 -----------------------------------------------------------------------------------------
130398 -- 4262811 Multiperiod Accounting
130399 -----------------------------------------------------------------------------------------
130400 -- No MPA option is assigned.
130401
130402
130403 END IF;
130404 END IF;
130405 --
130406
130407 --
130408 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
130409 trace
130410 (p_msg => 'END of AcctLineType_249'
130411 ,p_level => C_LEVEL_PROCEDURE
130412 ,p_module => l_log_module);
130413 END IF;
130414 --
130415 EXCEPTION
130416 WHEN xla_exceptions_pkg.application_exception THEN
130417 RAISE;
130418 WHEN OTHERS THEN
130419 xla_exceptions_pkg.raise_message
130420 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_249');
130421 END AcctLineType_249;
130422 --
130423
130424 ---------------------------------------
130425 --
130426 -- PRIVATE FUNCTION
130427 -- AcctLineType_250
130428 --
130429 ---------------------------------------
130430 PROCEDURE AcctLineType_250 (
130431 p_application_id IN NUMBER
130432 ,p_event_id IN NUMBER
130433 ,p_calculate_acctd_flag IN VARCHAR2
130434 ,p_calculate_g_l_flag IN VARCHAR2
130435 ,p_actual_flag IN OUT VARCHAR2
130436 ,p_balance_type_code OUT VARCHAR2
130437 ,p_gain_or_loss_ref OUT VARCHAR2
130438
130439 --Cost Management Default Account
130440 , p_source_11 IN NUMBER
130441 --DISTRIBUTION_IDENTIFIER
130442 , p_source_84 IN NUMBER
130443 --Distribution Type
130444 , p_source_85 IN VARCHAR2
130445 , p_source_85_meaning IN VARCHAR2
130446 --Entered Currency Code
130447 , p_source_88 IN VARCHAR2
130448 --Entered Amount
130449 , p_source_91 IN NUMBER
130450 --Currency Conversion Date
130451 , p_source_92 IN DATE
130452 --Currency Conversion Rate
130453 , p_source_93 IN NUMBER
130454 --Currency Conversion Type
130455 , p_source_94 IN VARCHAR2
130456 --Accounted Amount
130457 , p_source_95 IN NUMBER
130458 --Accounting Line Type
130459 , p_source_97 IN NUMBER
130460 --Organization Code
130461 , p_source_108 IN VARCHAR2
130462 )
130463 IS
130464
130465 l_component_type VARCHAR2(80);
130466 l_component_code VARCHAR2(30);
130467 l_component_type_code VARCHAR2(1);
130468 l_component_appl_id INTEGER;
130469 l_amb_context_code VARCHAR2(30);
130470 l_entity_code VARCHAR2(30);
130471 l_event_class_code VARCHAR2(30);
130472 l_ae_header_id NUMBER;
130473 l_event_type_code VARCHAR2(30);
130474 l_line_definition_code VARCHAR2(30);
130475 l_line_definition_owner_code VARCHAR2(1);
130476 --
130477 -- adr variables
130478 l_segment VARCHAR2(30);
130479 l_ccid NUMBER;
130480 l_adr_transaction_coa_id NUMBER;
130481 l_adr_accounting_coa_id NUMBER;
130482 l_adr_flexfield_segment_code VARCHAR2(30);
130483 l_adr_flex_value_set_id NUMBER;
130484 l_adr_value_type_code VARCHAR2(30);
130485 l_adr_value_combination_id NUMBER;
130486 l_adr_value_segment_code VARCHAR2(30);
130487
130488 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
130489 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
130490 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
130491 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
130492
130493 -- 4262811 Variables ------------------------------------------------------------------------------------------
130494 l_entered_amt_idx NUMBER;
130495 l_accted_amt_idx NUMBER;
130496 l_acc_rev_flag VARCHAR2(1);
130497 l_accrual_line_num NUMBER;
130498 l_tmp_amt NUMBER;
130499 l_acc_rev_natural_side_code VARCHAR2(1);
130500
130501 l_num_entries NUMBER;
130502 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
130503 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
130504 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
130505 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
130506 l_recog_line_1 NUMBER;
130507 l_recog_line_2 NUMBER;
130508
130509 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
130510 l_bflow_applied_to_amt NUMBER; -- 5132302
130511 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
130512
130513 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
130514
130515 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
130516 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
130517
130518 ---------------------------------------------------------------------------------------------------------------
130519
130520
130521 --
130522 -- bulk performance
130523 --
130524 l_balance_type_code VARCHAR2(1);
130525 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
130526 l_log_module VARCHAR2(240);
130527
130528 --
130529 -- Upgrade strategy
130530 --
130531 l_actual_upg_option VARCHAR2(1);
130532 l_enc_upg_option VARCHAR2(1);
130533
130534 --
130535 BEGIN
130536 --
130537 IF g_log_enabled THEN
130538 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_250';
130539 END IF;
130540 --
130541 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
130542
130543 trace
130544 (p_msg => 'BEGIN of AcctLineType_250'
130545 ,p_level => C_LEVEL_PROCEDURE
130546 ,p_module => l_log_module);
130547
130548 END IF;
130549 --
130550 l_component_type := 'AMB_JLT';
130551 l_component_code := 'INVENTORY_VALUATION';
130552 l_component_type_code := 'S';
130553 l_component_appl_id := 707;
130554 l_amb_context_code := 'DEFAULT';
130555 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
130556 l_event_class_code := 'SALES_ORDER';
130557 l_event_type_code := 'COGS_RECOGNITION';
130558 l_line_definition_owner_code := 'S';
130559 l_line_definition_code := 'PI_COGS_RECOGNITION';
130560 --
130561 l_balance_type_code := 'A';
130562 l_segment := NULL;
130563 l_ccid := NULL;
130564 l_adr_transaction_coa_id := NULL;
130565 l_adr_accounting_coa_id := NULL;
130566 l_adr_flexfield_segment_code := NULL;
130567 l_adr_flex_value_set_id := NULL;
130568 l_adr_value_type_code := NULL;
130569 l_adr_value_combination_id := NULL;
130570 l_adr_value_segment_code := NULL;
130571
130572 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
130573 l_bflow_class_code := ''; -- 4219869 Business Flow
130574 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
130575 l_budgetary_control_flag := 'N';
130576
130577 l_bflow_applied_to_amt_idx := NULL; -- 5132302
130578 l_bflow_applied_to_amt := NULL; -- 5132302
130579 l_entered_amt_idx := NULL; -- 4262811
130580 l_accted_amt_idx := NULL; -- 4262811
130581 l_acc_rev_flag := NULL; -- 4262811
130582 l_accrual_line_num := NULL; -- 4262811
130583 l_tmp_amt := NULL; -- 4262811
130584 --
130585
130586 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
130587 l_balance_type_code <> 'B' THEN
130588 IF NVL(p_source_97,9E125) = 1
130589 THEN
130590
130591 --
130592 XLA_AE_LINES_PKG.SetNewLine;
130593
130594 p_balance_type_code := l_balance_type_code;
130595 -- set the flag so later we will know whether the gain loss line needs to be created
130596
130597 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
130598 p_actual_flag :='A';
130599 END IF;
130600
130601 --
130602 -- bulk performance
130603 --
130604 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
130605 p_header_num => 0); -- 4262811
130606 --
130607 -- set accounting line options
130608 --
130609 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
130610 p_natural_side_code => 'D'
130611 , p_gain_or_loss_flag => 'N'
130612 , p_gl_transfer_mode_code => 'S'
130613 , p_acct_entry_type_code => 'A'
130614 , p_switch_side_flag => 'Y'
130615 , p_merge_duplicate_code => 'N'
130616 );
130617 --
130618 l_acc_rev_natural_side_code := 'C'; -- 4262811
130619 --
130620 --
130621 -- set accounting line type info
130622 --
130623 xla_ae_lines_pkg.SetAcctLineType
130624 (p_component_type => l_component_type
130625 ,p_event_type_code => l_event_type_code
130626 ,p_line_definition_owner_code => l_line_definition_owner_code
130627 ,p_line_definition_code => l_line_definition_code
130628 ,p_accounting_line_code => l_component_code
130629 ,p_accounting_line_type_code => l_component_type_code
130630 ,p_accounting_line_appl_id => l_component_appl_id
130631 ,p_amb_context_code => l_amb_context_code
130632 ,p_entity_code => l_entity_code
130633 ,p_event_class_code => l_event_class_code);
130634 --
130635 -- set accounting class
130636 --
130637 xla_ae_lines_pkg.SetAcctClass(
130638 p_accounting_class_code => 'INVENTORY_VALUATION'
130639 , p_ae_header_id => l_ae_header_id
130640 );
130641
130642 --
130643 -- set rounding class
130644 --
130645 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
130646 'INVENTORY_VALUATION';
130647
130648 --
130649 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
130650 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
130651 --
130652 -- bulk performance
130653 --
130654 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
130655
130656 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
130657 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
130658
130659 -- 4955764
130660 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
130661 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
130662
130663 -- 4458381 Public Sector Enh
130664
130665 --
130666 -- set accounting attributes for the line type
130667 --
130668 l_entered_amt_idx := 3;
130669 l_accted_amt_idx := 8;
130670 l_bflow_applied_to_amt_idx := NULL; -- 5132302
130671 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
130672 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
130673 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
130674 l_rec_acct_attrs.array_char_value(2) := p_source_85;
130675 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
130676 l_rec_acct_attrs.array_num_value(3) := p_source_91;
130677 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
130678 l_rec_acct_attrs.array_char_value(4) := p_source_88;
130679 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
130680 l_rec_acct_attrs.array_date_value(5) := p_source_92;
130681 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
130682 l_rec_acct_attrs.array_num_value(6) := p_source_93;
130683 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
130684 l_rec_acct_attrs.array_char_value(7) := p_source_94;
130685 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
130686 l_rec_acct_attrs.array_num_value(8) := p_source_95;
130687
130688 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
130689 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
130690
130691 ---------------------------------------------------------------------------------------------------------------
130692 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
130693 ---------------------------------------------------------------------------------------------------------------
130694 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
130695
130696 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
130697 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
130698
130699 IF xla_accounting_cache_pkg.GetValueChar
130700 (p_source_code => 'LEDGER_CATEGORY_CODE'
130701 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
130702 AND l_bflow_method_code = 'PRIOR_ENTRY'
130703 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
130704 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
130705 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
130706 )
130707 THEN
130708 xla_ae_lines_pkg.BflowUpgEntry
130709 (p_business_method_code => l_bflow_method_code
130710 ,p_business_class_code => l_bflow_class_code
130711 ,p_balance_type => l_balance_type_code);
130712 ELSE
130713 NULL;
130714 -- No business flow processing for business flow method of NONE.
130715 END IF;
130716
130717 --
130718 -- call analytical criteria
130719 --
130720
130721
130722 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
130723 xla_ae_lines_pkg.SetAnalyticalCriteria(
130724 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
130725 , p_analytical_criterion_owner => 'S'
130726 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
130727 , p_amb_context_code => 'DEFAULT'
130728 , p_balancing_flag => 'Y'
130729
130730 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
130731 , p_analytical_detail_num_1 => NULL
130732 , p_analytical_detail_date_1 => NULL
130733
130734 , p_ae_header_id => l_ae_header_id
130735 )
130736 ;
130737 --
130738
130739 --
130740 -- call description
130741 --
130742 -- No description or it is inherited.
130743 --
130744 -- call ADRs
130745 -- Bug 4922099
130746 --
130747 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
130748 (NVL(l_actual_upg_option, 'N') = 'O') OR
130749 (NVL(l_enc_upg_option, 'N') = 'O')
130750 )
130751 THEN
130752 NULL;
130753 --
130754 --
130755
130756 l_ccid := AcctDerRule_6(
130757 p_application_id => p_application_id
130758 , p_ae_header_id => l_ae_header_id
130759 , p_source_11 => p_source_11
130760 , x_transaction_coa_id => l_adr_transaction_coa_id
130761 , x_accounting_coa_id => l_adr_accounting_coa_id
130762 , x_value_type_code => l_adr_value_type_code
130763 , p_side => 'NA'
130764 );
130765
130766 xla_ae_lines_pkg.set_ccid(
130767 p_code_combination_id => l_ccid
130768 , p_value_type_code => l_adr_value_type_code
130769 , p_transaction_coa_id => l_adr_transaction_coa_id
130770 , p_accounting_coa_id => l_adr_accounting_coa_id
130771 , p_adr_code => 'CST_DEFAULT'
130772 , p_adr_type_code => 'S'
130773 , p_component_type => l_component_type
130774 , p_component_code => l_component_code
130775 , p_component_type_code => l_component_type_code
130776 , p_component_appl_id => l_component_appl_id
130777 , p_amb_context_code => l_amb_context_code
130778 , p_side => 'NA'
130779 );
130780
130781
130782 --
130783 --
130784 END IF;
130785 --
130786 -- Bug 4922099
130787 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
130788 (NVL(l_enc_upg_option, 'N') = 'O')
130789 ) AND
130790 (l_bflow_method_code = 'PRIOR_ENTRY')
130791 )
130792 THEN
130793 IF
130794 --
130795 1 = 2
130796 --
130797 THEN
130798 xla_accounting_err_pkg.build_message
130799 (p_appli_s_name => 'XLA'
130800 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
130801 ,p_token_1 => 'LINE_NUMBER'
130802 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
130803 ,p_token_2 => 'LINE_TYPE_NAME'
130804 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
130805 l_component_type
130806 ,l_component_code
130807 ,l_component_type_code
130808 ,l_component_appl_id
130809 ,l_amb_context_code
130810 ,l_entity_code
130811 ,l_event_class_code
130812 )
130813 ,p_token_3 => 'OWNER'
130814 ,p_value_3 => xla_lookups_pkg.get_meaning(
130815 p_lookup_type => 'XLA_OWNER_TYPE'
130816 ,p_lookup_code => l_component_type_code
130817 )
130818 ,p_token_4 => 'PRODUCT_NAME'
130819 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
130820 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
130821 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
130822 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
130823 ,p_ae_header_id => NULL
130824 );
130825
130826 IF (C_LEVEL_ERROR>= g_log_level) THEN
130827 trace
130828 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
130829 ,p_level => C_LEVEL_ERROR
130830 ,p_module => l_log_module);
130831 END IF;
130832 END IF;
130833 END IF;
130834 --
130835 --
130836 ------------------------------------------------------------------------------------------------
130837 -- 4219869 Business Flow
130838 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
130839 -- Prior Entry. Currently, the following code is always generated.
130840 ------------------------------------------------------------------------------------------------
130841 XLA_AE_LINES_PKG.ValidateCurrentLine;
130842
130843 ------------------------------------------------------------------------------------
130844 -- 4219869 Business Flow
130845 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
130846 ------------------------------------------------------------------------------------
130847 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
130848
130849 ----------------------------------------------------------------------------------
130850 -- 4219869 Business Flow
130851 -- Update journal entry status -- Need to generate this within IF <condition>
130852 ----------------------------------------------------------------------------------
130853 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
130854 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
130855 ,p_balance_type_code => l_balance_type_code
130856 );
130857
130858 -------------------------------------------------------------------------------------------
130859 -- 4262811 - Generate the Accrual Reversal lines
130860 -------------------------------------------------------------------------------------------
130861 BEGIN
130862 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
130863 (g_array_event(p_event_id).array_value_num('header_index'));
130864 IF l_acc_rev_flag IS NULL THEN
130865 l_acc_rev_flag := 'N';
130866 END IF;
130867 EXCEPTION
130868 WHEN OTHERS THEN
130869 l_acc_rev_flag := 'N';
130870 END;
130871 --
130872 IF (l_acc_rev_flag = 'Y') THEN
130873
130874 -- 4645092 ------------------------------------------------------------------------------
130875 -- To allow MPA report to determine if it should generate report process
130876 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
130877 ------------------------------------------------------------------------------------------
130878
130879 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
130880 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
130881 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
130882 -- call ADRs
130883 -- Bug 4922099
130884 --
130885 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
130886 (NVL(l_actual_upg_option, 'N') = 'O') OR
130887 (NVL(l_enc_upg_option, 'N') = 'O')
130888 )
130889 THEN
130890 NULL;
130891 --
130892 --
130893
130894 l_ccid := AcctDerRule_6(
130895 p_application_id => p_application_id
130896 , p_ae_header_id => l_ae_header_id
130897 , p_source_11 => p_source_11
130898 , x_transaction_coa_id => l_adr_transaction_coa_id
130899 , x_accounting_coa_id => l_adr_accounting_coa_id
130900 , x_value_type_code => l_adr_value_type_code
130901 , p_side => 'NA'
130902 );
130903
130904 xla_ae_lines_pkg.set_ccid(
130905 p_code_combination_id => l_ccid
130906 , p_value_type_code => l_adr_value_type_code
130907 , p_transaction_coa_id => l_adr_transaction_coa_id
130908 , p_accounting_coa_id => l_adr_accounting_coa_id
130909 , p_adr_code => 'CST_DEFAULT'
130910 , p_adr_type_code => 'S'
130911 , p_component_type => l_component_type
130912 , p_component_code => l_component_code
130913 , p_component_type_code => l_component_type_code
130914 , p_component_appl_id => l_component_appl_id
130915 , p_amb_context_code => l_amb_context_code
130916 , p_side => 'NA'
130917 );
130918
130919
130920 --
130921 --
130922 END IF;
130923
130924 --
130925 -- Update the line information that should be overwritten
130926 --
130927 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
130928 p_header_num => 1);
130929 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
130930
130931 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
130932
130933 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
130934 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
130935 END IF;
130936
130937 --
130938 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
130939 --
130940 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
130941 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
130942 ELSE
130943 ---------------------------------------------------------------------------------------------------
130944 -- 4262811a Switch Sign
130945 ---------------------------------------------------------------------------------------------------
130946 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
130947 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
130948 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130949 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
130950 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130951 -- 5132302
130952 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
130953 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
130954
130955 END IF;
130956
130957 -- 4955764
130958 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
130959 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
130960
130961
130962 XLA_AE_LINES_PKG.ValidateCurrentLine;
130963 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
130964
130965 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
130966 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
130967 ,p_balance_type_code => l_balance_type_code);
130968
130969 END IF;
130970
130971 -----------------------------------------------------------------------------------------
130972 -- 4262811 Multiperiod Accounting
130973 -----------------------------------------------------------------------------------------
130974 -- No MPA option is assigned.
130975
130976
130977 END IF;
130978 END IF;
130979 --
130980
130981 --
130982 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
130983 trace
130984 (p_msg => 'END of AcctLineType_250'
130985 ,p_level => C_LEVEL_PROCEDURE
130986 ,p_module => l_log_module);
130987 END IF;
130988 --
130989 EXCEPTION
130990 WHEN xla_exceptions_pkg.application_exception THEN
130991 RAISE;
130992 WHEN OTHERS THEN
130993 xla_exceptions_pkg.raise_message
130994 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_250');
130995 END AcctLineType_250;
130996 --
130997
130998 ---------------------------------------
130999 --
131000 -- PRIVATE FUNCTION
131001 -- AcctLineType_251
131002 --
131003 ---------------------------------------
131004 PROCEDURE AcctLineType_251 (
131005 p_application_id IN NUMBER
131006 ,p_event_id IN NUMBER
131007 ,p_calculate_acctd_flag IN VARCHAR2
131008 ,p_calculate_g_l_flag IN VARCHAR2
131009 ,p_actual_flag IN OUT VARCHAR2
131010 ,p_balance_type_code OUT VARCHAR2
131011 ,p_gain_or_loss_ref OUT VARCHAR2
131012
131013 --TRANSACTION_ID
131014 , p_source_1 IN NUMBER
131015 --Item Concatenated Segments
131016 , p_source_2 IN VARCHAR2
131017 --Transaction Quantity
131018 , p_source_3 IN NUMBER
131019 --Transaction Unit of Measure Code
131020 , p_source_4 IN VARCHAR2
131021 --Inventory Transaction Type Description
131022 , p_source_5 IN VARCHAR2
131023 --Cost Element Name
131024 , p_source_15 IN NUMBER
131025 --Product Line Accounting Category Material Account
131026 , p_source_41 IN NUMBER
131027 --Product Line Accounting Category Material Overhead Account
131028 , p_source_42 IN NUMBER
131029 --Product Line Accounting Category Resource Account
131030 , p_source_43 IN NUMBER
131031 --Product Line Accounting Category Outside Processing Account
131032 , p_source_44 IN NUMBER
131033 --Product Line Accounting Category Overhead Account
131034 , p_source_45 IN NUMBER
131035 --DISTRIBUTION_IDENTIFIER
131036 , p_source_84 IN NUMBER
131037 --Distribution Type
131038 , p_source_85 IN VARCHAR2
131039 , p_source_85_meaning IN VARCHAR2
131040 --Entered Currency Code
131041 , p_source_88 IN VARCHAR2
131042 --Entered Amount
131043 , p_source_91 IN NUMBER
131044 --Currency Conversion Date
131045 , p_source_92 IN DATE
131046 --Currency Conversion Rate
131047 , p_source_93 IN NUMBER
131048 --Currency Conversion Type
131049 , p_source_94 IN VARCHAR2
131050 --Accounted Amount
131051 , p_source_95 IN NUMBER
131052 --Accounting Line Type
131053 , p_source_97 IN NUMBER
131054 --Organization Code
131055 , p_source_108 IN VARCHAR2
131056 )
131057 IS
131058
131059 l_component_type VARCHAR2(80);
131060 l_component_code VARCHAR2(30);
131061 l_component_type_code VARCHAR2(1);
131062 l_component_appl_id INTEGER;
131063 l_amb_context_code VARCHAR2(30);
131064 l_entity_code VARCHAR2(30);
131065 l_event_class_code VARCHAR2(30);
131066 l_ae_header_id NUMBER;
131067 l_event_type_code VARCHAR2(30);
131068 l_line_definition_code VARCHAR2(30);
131069 l_line_definition_owner_code VARCHAR2(1);
131070 --
131071 -- adr variables
131072 l_segment VARCHAR2(30);
131073 l_ccid NUMBER;
131074 l_adr_transaction_coa_id NUMBER;
131075 l_adr_accounting_coa_id NUMBER;
131076 l_adr_flexfield_segment_code VARCHAR2(30);
131077 l_adr_flex_value_set_id NUMBER;
131078 l_adr_value_type_code VARCHAR2(30);
131079 l_adr_value_combination_id NUMBER;
131080 l_adr_value_segment_code VARCHAR2(30);
131081
131082 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
131083 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
131084 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
131085 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
131086
131087 -- 4262811 Variables ------------------------------------------------------------------------------------------
131088 l_entered_amt_idx NUMBER;
131089 l_accted_amt_idx NUMBER;
131090 l_acc_rev_flag VARCHAR2(1);
131091 l_accrual_line_num NUMBER;
131092 l_tmp_amt NUMBER;
131093 l_acc_rev_natural_side_code VARCHAR2(1);
131094
131095 l_num_entries NUMBER;
131096 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
131097 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
131098 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
131099 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
131100 l_recog_line_1 NUMBER;
131101 l_recog_line_2 NUMBER;
131102
131103 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
131104 l_bflow_applied_to_amt NUMBER; -- 5132302
131105 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
131106
131107 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
131108
131109 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
131110 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
131111
131112 ---------------------------------------------------------------------------------------------------------------
131113
131114
131115 --
131116 -- bulk performance
131117 --
131118 l_balance_type_code VARCHAR2(1);
131119 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
131120 l_log_module VARCHAR2(240);
131121
131122 --
131123 -- Upgrade strategy
131124 --
131125 l_actual_upg_option VARCHAR2(1);
131126 l_enc_upg_option VARCHAR2(1);
131127
131128 --
131129 BEGIN
131130 --
131131 IF g_log_enabled THEN
131132 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_251';
131133 END IF;
131134 --
131135 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
131136
131137 trace
131138 (p_msg => 'BEGIN of AcctLineType_251'
131139 ,p_level => C_LEVEL_PROCEDURE
131140 ,p_module => l_log_module);
131141
131142 END IF;
131143 --
131144 l_component_type := 'AMB_JLT';
131145 l_component_code := 'INVENTORY_VALUATION';
131146 l_component_type_code := 'S';
131147 l_component_appl_id := 707;
131148 l_amb_context_code := 'DEFAULT';
131149 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
131150 l_event_class_code := 'USER_DEFINE';
131151 l_event_type_code := 'UDIR_INTERORG_RCPT';
131152 l_line_definition_owner_code := 'S';
131153 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
131154 --
131155 l_balance_type_code := 'A';
131156 l_segment := NULL;
131157 l_ccid := NULL;
131158 l_adr_transaction_coa_id := NULL;
131159 l_adr_accounting_coa_id := NULL;
131160 l_adr_flexfield_segment_code := NULL;
131161 l_adr_flex_value_set_id := NULL;
131162 l_adr_value_type_code := NULL;
131163 l_adr_value_combination_id := NULL;
131164 l_adr_value_segment_code := NULL;
131165
131166 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
131167 l_bflow_class_code := ''; -- 4219869 Business Flow
131168 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
131169 l_budgetary_control_flag := 'N';
131170
131171 l_bflow_applied_to_amt_idx := NULL; -- 5132302
131172 l_bflow_applied_to_amt := NULL; -- 5132302
131173 l_entered_amt_idx := NULL; -- 4262811
131174 l_accted_amt_idx := NULL; -- 4262811
131175 l_acc_rev_flag := NULL; -- 4262811
131176 l_accrual_line_num := NULL; -- 4262811
131177 l_tmp_amt := NULL; -- 4262811
131178 --
131179
131180 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
131181 l_balance_type_code <> 'B' THEN
131182 IF NVL(p_source_97,9E125) = 1
131183 THEN
131184
131185 --
131186 XLA_AE_LINES_PKG.SetNewLine;
131187
131188 p_balance_type_code := l_balance_type_code;
131189 -- set the flag so later we will know whether the gain loss line needs to be created
131190
131191 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
131192 p_actual_flag :='A';
131193 END IF;
131194
131195 --
131196 -- bulk performance
131197 --
131198 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
131199 p_header_num => 0); -- 4262811
131200 --
131201 -- set accounting line options
131202 --
131203 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
131204 p_natural_side_code => 'D'
131205 , p_gain_or_loss_flag => 'N'
131206 , p_gl_transfer_mode_code => 'S'
131207 , p_acct_entry_type_code => 'A'
131208 , p_switch_side_flag => 'Y'
131209 , p_merge_duplicate_code => 'N'
131210 );
131211 --
131212 l_acc_rev_natural_side_code := 'C'; -- 4262811
131213 --
131214 --
131215 -- set accounting line type info
131216 --
131217 xla_ae_lines_pkg.SetAcctLineType
131218 (p_component_type => l_component_type
131219 ,p_event_type_code => l_event_type_code
131220 ,p_line_definition_owner_code => l_line_definition_owner_code
131221 ,p_line_definition_code => l_line_definition_code
131222 ,p_accounting_line_code => l_component_code
131223 ,p_accounting_line_type_code => l_component_type_code
131224 ,p_accounting_line_appl_id => l_component_appl_id
131225 ,p_amb_context_code => l_amb_context_code
131226 ,p_entity_code => l_entity_code
131227 ,p_event_class_code => l_event_class_code);
131228 --
131229 -- set accounting class
131230 --
131231 xla_ae_lines_pkg.SetAcctClass(
131232 p_accounting_class_code => 'INVENTORY_VALUATION'
131233 , p_ae_header_id => l_ae_header_id
131234 );
131235
131236 --
131237 -- set rounding class
131238 --
131239 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
131240 'INVENTORY_VALUATION';
131241
131242 --
131243 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
131244 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
131245 --
131246 -- bulk performance
131247 --
131248 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
131249
131250 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
131251 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
131252
131253 -- 4955764
131254 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
131255 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
131256
131257 -- 4458381 Public Sector Enh
131258
131259 --
131260 -- set accounting attributes for the line type
131261 --
131262 l_entered_amt_idx := 3;
131263 l_accted_amt_idx := 8;
131264 l_bflow_applied_to_amt_idx := NULL; -- 5132302
131265 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
131266 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
131267 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
131268 l_rec_acct_attrs.array_char_value(2) := p_source_85;
131269 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
131270 l_rec_acct_attrs.array_num_value(3) := p_source_91;
131271 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
131272 l_rec_acct_attrs.array_char_value(4) := p_source_88;
131273 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
131274 l_rec_acct_attrs.array_date_value(5) := p_source_92;
131275 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
131276 l_rec_acct_attrs.array_num_value(6) := p_source_93;
131277 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
131278 l_rec_acct_attrs.array_char_value(7) := p_source_94;
131279 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
131280 l_rec_acct_attrs.array_num_value(8) := p_source_95;
131281
131282 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
131283 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
131284
131285 ---------------------------------------------------------------------------------------------------------------
131286 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
131287 ---------------------------------------------------------------------------------------------------------------
131288 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
131289
131290 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
131291 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
131292
131293 IF xla_accounting_cache_pkg.GetValueChar
131294 (p_source_code => 'LEDGER_CATEGORY_CODE'
131295 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
131296 AND l_bflow_method_code = 'PRIOR_ENTRY'
131297 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
131298 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
131299 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
131300 )
131301 THEN
131302 xla_ae_lines_pkg.BflowUpgEntry
131303 (p_business_method_code => l_bflow_method_code
131304 ,p_business_class_code => l_bflow_class_code
131305 ,p_balance_type => l_balance_type_code);
131306 ELSE
131307 NULL;
131308 -- No business flow processing for business flow method of NONE.
131309 END IF;
131310
131311 --
131312 -- call analytical criteria
131313 --
131314
131315
131316 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
131317 xla_ae_lines_pkg.SetAnalyticalCriteria(
131318 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
131319 , p_analytical_criterion_owner => 'S'
131320 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
131321 , p_amb_context_code => 'DEFAULT'
131322 , p_balancing_flag => 'Y'
131323
131324 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
131325 , p_analytical_detail_num_1 => NULL
131326 , p_analytical_detail_date_1 => NULL
131327
131328 , p_ae_header_id => l_ae_header_id
131329 )
131330 ;
131331 --
131332
131333 --
131334 -- call description
131335 --
131336
131337 xla_ae_lines_pkg.SetLineDescription(
131338 p_ae_header_id => l_ae_header_id
131339 ,p_description => Description_1 (
131340 p_application_id => p_application_id
131341 , p_ae_header_id => l_ae_header_id
131342 , p_source_1 => p_source_1
131343 , p_source_2 => p_source_2
131344 , p_source_3 => p_source_3
131345 , p_source_4 => p_source_4
131346 , p_source_5 => p_source_5
131347 )
131348 );
131349
131350
131351 --
131352 -- call ADRs
131353 -- Bug 4922099
131354 --
131355 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
131356 (NVL(l_actual_upg_option, 'N') = 'O') OR
131357 (NVL(l_enc_upg_option, 'N') = 'O')
131358 )
131359 THEN
131360 NULL;
131361 --
131362 --
131363
131364 l_ccid := AcctDerRule_28(
131365 p_application_id => p_application_id
131366 , p_ae_header_id => l_ae_header_id
131367 , p_source_15 => p_source_15
131368 , p_source_41 => p_source_41
131369 , p_source_42 => p_source_42
131370 , p_source_43 => p_source_43
131371 , p_source_44 => p_source_44
131372 , p_source_45 => p_source_45
131373 , x_transaction_coa_id => l_adr_transaction_coa_id
131374 , x_accounting_coa_id => l_adr_accounting_coa_id
131375 , x_value_type_code => l_adr_value_type_code
131376 , p_side => 'NA'
131377 );
131378
131379 xla_ae_lines_pkg.set_ccid(
131380 p_code_combination_id => l_ccid
131381 , p_value_type_code => l_adr_value_type_code
131382 , p_transaction_coa_id => l_adr_transaction_coa_id
131383 , p_accounting_coa_id => l_adr_accounting_coa_id
131384 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
131385 , p_adr_type_code => 'S'
131386 , p_component_type => l_component_type
131387 , p_component_code => l_component_code
131388 , p_component_type_code => l_component_type_code
131389 , p_component_appl_id => l_component_appl_id
131390 , p_amb_context_code => l_amb_context_code
131391 , p_side => 'NA'
131392 );
131393
131394
131395 --
131396 --
131397 END IF;
131398 --
131399 -- Bug 4922099
131400 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
131401 (NVL(l_enc_upg_option, 'N') = 'O')
131402 ) AND
131403 (l_bflow_method_code = 'PRIOR_ENTRY')
131404 )
131405 THEN
131406 IF
131407 --
131408 1 = 2
131409 --
131410 THEN
131411 xla_accounting_err_pkg.build_message
131412 (p_appli_s_name => 'XLA'
131413 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
131414 ,p_token_1 => 'LINE_NUMBER'
131415 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
131416 ,p_token_2 => 'LINE_TYPE_NAME'
131417 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
131418 l_component_type
131419 ,l_component_code
131420 ,l_component_type_code
131421 ,l_component_appl_id
131422 ,l_amb_context_code
131423 ,l_entity_code
131424 ,l_event_class_code
131425 )
131426 ,p_token_3 => 'OWNER'
131427 ,p_value_3 => xla_lookups_pkg.get_meaning(
131428 p_lookup_type => 'XLA_OWNER_TYPE'
131429 ,p_lookup_code => l_component_type_code
131430 )
131431 ,p_token_4 => 'PRODUCT_NAME'
131432 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
131433 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
131434 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
131435 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
131436 ,p_ae_header_id => NULL
131437 );
131438
131439 IF (C_LEVEL_ERROR>= g_log_level) THEN
131440 trace
131441 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
131442 ,p_level => C_LEVEL_ERROR
131443 ,p_module => l_log_module);
131444 END IF;
131445 END IF;
131446 END IF;
131447 --
131448 --
131449 ------------------------------------------------------------------------------------------------
131450 -- 4219869 Business Flow
131451 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
131452 -- Prior Entry. Currently, the following code is always generated.
131453 ------------------------------------------------------------------------------------------------
131454 XLA_AE_LINES_PKG.ValidateCurrentLine;
131455
131456 ------------------------------------------------------------------------------------
131457 -- 4219869 Business Flow
131458 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
131459 ------------------------------------------------------------------------------------
131460 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
131461
131462 ----------------------------------------------------------------------------------
131463 -- 4219869 Business Flow
131464 -- Update journal entry status -- Need to generate this within IF <condition>
131465 ----------------------------------------------------------------------------------
131466 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
131467 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
131468 ,p_balance_type_code => l_balance_type_code
131469 );
131470
131471 -------------------------------------------------------------------------------------------
131472 -- 4262811 - Generate the Accrual Reversal lines
131473 -------------------------------------------------------------------------------------------
131474 BEGIN
131475 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
131476 (g_array_event(p_event_id).array_value_num('header_index'));
131477 IF l_acc_rev_flag IS NULL THEN
131478 l_acc_rev_flag := 'N';
131479 END IF;
131480 EXCEPTION
131481 WHEN OTHERS THEN
131482 l_acc_rev_flag := 'N';
131483 END;
131484 --
131485 IF (l_acc_rev_flag = 'Y') THEN
131486
131487 -- 4645092 ------------------------------------------------------------------------------
131488 -- To allow MPA report to determine if it should generate report process
131489 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
131490 ------------------------------------------------------------------------------------------
131491
131492 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
131493 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
131494 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
131495 -- call ADRs
131496 -- Bug 4922099
131497 --
131498 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
131499 (NVL(l_actual_upg_option, 'N') = 'O') OR
131500 (NVL(l_enc_upg_option, 'N') = 'O')
131501 )
131502 THEN
131503 NULL;
131504 --
131505 --
131506
131507 l_ccid := AcctDerRule_28(
131508 p_application_id => p_application_id
131509 , p_ae_header_id => l_ae_header_id
131510 , p_source_15 => p_source_15
131511 , p_source_41 => p_source_41
131512 , p_source_42 => p_source_42
131513 , p_source_43 => p_source_43
131514 , p_source_44 => p_source_44
131515 , p_source_45 => p_source_45
131516 , x_transaction_coa_id => l_adr_transaction_coa_id
131517 , x_accounting_coa_id => l_adr_accounting_coa_id
131518 , x_value_type_code => l_adr_value_type_code
131519 , p_side => 'NA'
131520 );
131521
131522 xla_ae_lines_pkg.set_ccid(
131523 p_code_combination_id => l_ccid
131524 , p_value_type_code => l_adr_value_type_code
131525 , p_transaction_coa_id => l_adr_transaction_coa_id
131526 , p_accounting_coa_id => l_adr_accounting_coa_id
131527 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
131528 , p_adr_type_code => 'S'
131529 , p_component_type => l_component_type
131530 , p_component_code => l_component_code
131531 , p_component_type_code => l_component_type_code
131532 , p_component_appl_id => l_component_appl_id
131533 , p_amb_context_code => l_amb_context_code
131534 , p_side => 'NA'
131535 );
131536
131537
131538 --
131539 --
131540 END IF;
131541
131542 --
131543 -- Update the line information that should be overwritten
131544 --
131545 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
131546 p_header_num => 1);
131547 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
131548
131549 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
131550
131551 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
131552 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
131553 END IF;
131554
131555 --
131556 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
131557 --
131558 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
131559 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
131560 ELSE
131561 ---------------------------------------------------------------------------------------------------
131562 -- 4262811a Switch Sign
131563 ---------------------------------------------------------------------------------------------------
131564 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
131565 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
131566 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
131567 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
131568 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
131569 -- 5132302
131570 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
131571 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
131572
131573 END IF;
131574
131575 -- 4955764
131576 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
131577 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
131578
131579
131580 XLA_AE_LINES_PKG.ValidateCurrentLine;
131581 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
131582
131583 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
131584 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
131585 ,p_balance_type_code => l_balance_type_code);
131586
131587 END IF;
131588
131589 -----------------------------------------------------------------------------------------
131590 -- 4262811 Multiperiod Accounting
131591 -----------------------------------------------------------------------------------------
131592 -- No MPA option is assigned.
131593
131594
131595 END IF;
131596 END IF;
131597 --
131598
131599 --
131600 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
131601 trace
131602 (p_msg => 'END of AcctLineType_251'
131603 ,p_level => C_LEVEL_PROCEDURE
131604 ,p_module => l_log_module);
131605 END IF;
131606 --
131607 EXCEPTION
131608 WHEN xla_exceptions_pkg.application_exception THEN
131609 RAISE;
131610 WHEN OTHERS THEN
131611 xla_exceptions_pkg.raise_message
131612 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_251');
131613 END AcctLineType_251;
131614 --
131615
131616 ---------------------------------------
131617 --
131618 -- PRIVATE FUNCTION
131619 -- AcctLineType_252
131620 --
131621 ---------------------------------------
131622 PROCEDURE AcctLineType_252 (
131623 p_application_id IN NUMBER
131624 ,p_event_id IN NUMBER
131625 ,p_calculate_acctd_flag IN VARCHAR2
131626 ,p_calculate_g_l_flag IN VARCHAR2
131627 ,p_actual_flag IN OUT VARCHAR2
131628 ,p_balance_type_code OUT VARCHAR2
131629 ,p_gain_or_loss_ref OUT VARCHAR2
131630
131631 --TRANSACTION_ID
131632 , p_source_1 IN NUMBER
131633 --Item Concatenated Segments
131634 , p_source_2 IN VARCHAR2
131635 --Transaction Quantity
131636 , p_source_3 IN NUMBER
131637 --Transaction Unit of Measure Code
131638 , p_source_4 IN VARCHAR2
131639 --Inventory Transaction Type Description
131640 , p_source_5 IN VARCHAR2
131641 --Cost Element Name
131642 , p_source_15 IN NUMBER
131643 --Product Line Accounting Category Material Account
131644 , p_source_41 IN NUMBER
131645 --Product Line Accounting Category Material Overhead Account
131646 , p_source_42 IN NUMBER
131647 --Product Line Accounting Category Resource Account
131648 , p_source_43 IN NUMBER
131649 --Product Line Accounting Category Outside Processing Account
131650 , p_source_44 IN NUMBER
131651 --Product Line Accounting Category Overhead Account
131652 , p_source_45 IN NUMBER
131653 --DISTRIBUTION_IDENTIFIER
131654 , p_source_84 IN NUMBER
131655 --Distribution Type
131656 , p_source_85 IN VARCHAR2
131657 , p_source_85_meaning IN VARCHAR2
131658 --Entered Currency Code
131659 , p_source_88 IN VARCHAR2
131660 --Entered Amount
131661 , p_source_91 IN NUMBER
131662 --Currency Conversion Date
131663 , p_source_92 IN DATE
131664 --Currency Conversion Rate
131665 , p_source_93 IN NUMBER
131666 --Currency Conversion Type
131667 , p_source_94 IN VARCHAR2
131668 --Accounted Amount
131669 , p_source_95 IN NUMBER
131670 --Accounting Line Type
131671 , p_source_97 IN NUMBER
131672 --Organization Code
131673 , p_source_108 IN VARCHAR2
131674 )
131675 IS
131676
131677 l_component_type VARCHAR2(80);
131678 l_component_code VARCHAR2(30);
131679 l_component_type_code VARCHAR2(1);
131680 l_component_appl_id INTEGER;
131681 l_amb_context_code VARCHAR2(30);
131682 l_entity_code VARCHAR2(30);
131683 l_event_class_code VARCHAR2(30);
131684 l_ae_header_id NUMBER;
131685 l_event_type_code VARCHAR2(30);
131686 l_line_definition_code VARCHAR2(30);
131687 l_line_definition_owner_code VARCHAR2(1);
131688 --
131689 -- adr variables
131690 l_segment VARCHAR2(30);
131691 l_ccid NUMBER;
131692 l_adr_transaction_coa_id NUMBER;
131693 l_adr_accounting_coa_id NUMBER;
131694 l_adr_flexfield_segment_code VARCHAR2(30);
131695 l_adr_flex_value_set_id NUMBER;
131696 l_adr_value_type_code VARCHAR2(30);
131697 l_adr_value_combination_id NUMBER;
131698 l_adr_value_segment_code VARCHAR2(30);
131699
131700 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
131701 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
131702 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
131703 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
131704
131705 -- 4262811 Variables ------------------------------------------------------------------------------------------
131706 l_entered_amt_idx NUMBER;
131707 l_accted_amt_idx NUMBER;
131708 l_acc_rev_flag VARCHAR2(1);
131709 l_accrual_line_num NUMBER;
131710 l_tmp_amt NUMBER;
131711 l_acc_rev_natural_side_code VARCHAR2(1);
131712
131713 l_num_entries NUMBER;
131714 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
131715 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
131716 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
131717 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
131718 l_recog_line_1 NUMBER;
131719 l_recog_line_2 NUMBER;
131720
131721 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
131722 l_bflow_applied_to_amt NUMBER; -- 5132302
131723 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
131724
131725 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
131726
131727 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
131728 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
131729
131730 ---------------------------------------------------------------------------------------------------------------
131731
131732
131733 --
131734 -- bulk performance
131735 --
131736 l_balance_type_code VARCHAR2(1);
131737 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
131738 l_log_module VARCHAR2(240);
131739
131740 --
131741 -- Upgrade strategy
131742 --
131743 l_actual_upg_option VARCHAR2(1);
131744 l_enc_upg_option VARCHAR2(1);
131745
131746 --
131747 BEGIN
131748 --
131749 IF g_log_enabled THEN
131750 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_252';
131751 END IF;
131752 --
131753 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
131754
131755 trace
131756 (p_msg => 'BEGIN of AcctLineType_252'
131757 ,p_level => C_LEVEL_PROCEDURE
131758 ,p_module => l_log_module);
131759
131760 END IF;
131761 --
131762 l_component_type := 'AMB_JLT';
131763 l_component_code := 'INVENTORY_VALUATION';
131764 l_component_type_code := 'S';
131765 l_component_appl_id := 707;
131766 l_amb_context_code := 'DEFAULT';
131767 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
131768 l_event_class_code := 'USER_DEFINE';
131769 l_event_type_code := 'UMISC_ISSUE';
131770 l_line_definition_owner_code := 'S';
131771 l_line_definition_code := 'PI_USER_ISSUE';
131772 --
131773 l_balance_type_code := 'A';
131774 l_segment := NULL;
131775 l_ccid := NULL;
131776 l_adr_transaction_coa_id := NULL;
131777 l_adr_accounting_coa_id := NULL;
131778 l_adr_flexfield_segment_code := NULL;
131779 l_adr_flex_value_set_id := NULL;
131780 l_adr_value_type_code := NULL;
131781 l_adr_value_combination_id := NULL;
131782 l_adr_value_segment_code := NULL;
131783
131784 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
131785 l_bflow_class_code := ''; -- 4219869 Business Flow
131786 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
131787 l_budgetary_control_flag := 'N';
131788
131789 l_bflow_applied_to_amt_idx := NULL; -- 5132302
131790 l_bflow_applied_to_amt := NULL; -- 5132302
131791 l_entered_amt_idx := NULL; -- 4262811
131792 l_accted_amt_idx := NULL; -- 4262811
131793 l_acc_rev_flag := NULL; -- 4262811
131794 l_accrual_line_num := NULL; -- 4262811
131795 l_tmp_amt := NULL; -- 4262811
131796 --
131797
131798 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
131799 l_balance_type_code <> 'B' THEN
131800 IF NVL(p_source_97,9E125) = 1
131801 THEN
131802
131803 --
131804 XLA_AE_LINES_PKG.SetNewLine;
131805
131806 p_balance_type_code := l_balance_type_code;
131807 -- set the flag so later we will know whether the gain loss line needs to be created
131808
131809 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
131810 p_actual_flag :='A';
131811 END IF;
131812
131813 --
131814 -- bulk performance
131815 --
131816 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
131817 p_header_num => 0); -- 4262811
131818 --
131819 -- set accounting line options
131820 --
131821 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
131822 p_natural_side_code => 'D'
131823 , p_gain_or_loss_flag => 'N'
131824 , p_gl_transfer_mode_code => 'S'
131825 , p_acct_entry_type_code => 'A'
131826 , p_switch_side_flag => 'Y'
131827 , p_merge_duplicate_code => 'N'
131828 );
131829 --
131830 l_acc_rev_natural_side_code := 'C'; -- 4262811
131831 --
131832 --
131833 -- set accounting line type info
131834 --
131835 xla_ae_lines_pkg.SetAcctLineType
131836 (p_component_type => l_component_type
131837 ,p_event_type_code => l_event_type_code
131838 ,p_line_definition_owner_code => l_line_definition_owner_code
131839 ,p_line_definition_code => l_line_definition_code
131840 ,p_accounting_line_code => l_component_code
131841 ,p_accounting_line_type_code => l_component_type_code
131842 ,p_accounting_line_appl_id => l_component_appl_id
131843 ,p_amb_context_code => l_amb_context_code
131844 ,p_entity_code => l_entity_code
131845 ,p_event_class_code => l_event_class_code);
131846 --
131847 -- set accounting class
131848 --
131849 xla_ae_lines_pkg.SetAcctClass(
131850 p_accounting_class_code => 'INVENTORY_VALUATION'
131851 , p_ae_header_id => l_ae_header_id
131852 );
131853
131854 --
131855 -- set rounding class
131856 --
131857 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
131858 'INVENTORY_VALUATION';
131859
131860 --
131861 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
131862 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
131863 --
131864 -- bulk performance
131865 --
131866 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
131867
131868 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
131869 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
131870
131871 -- 4955764
131872 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
131873 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
131874
131875 -- 4458381 Public Sector Enh
131876
131877 --
131878 -- set accounting attributes for the line type
131879 --
131880 l_entered_amt_idx := 3;
131881 l_accted_amt_idx := 8;
131882 l_bflow_applied_to_amt_idx := NULL; -- 5132302
131883 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
131884 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
131885 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
131886 l_rec_acct_attrs.array_char_value(2) := p_source_85;
131887 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
131888 l_rec_acct_attrs.array_num_value(3) := p_source_91;
131889 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
131890 l_rec_acct_attrs.array_char_value(4) := p_source_88;
131891 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
131892 l_rec_acct_attrs.array_date_value(5) := p_source_92;
131893 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
131894 l_rec_acct_attrs.array_num_value(6) := p_source_93;
131895 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
131896 l_rec_acct_attrs.array_char_value(7) := p_source_94;
131897 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
131898 l_rec_acct_attrs.array_num_value(8) := p_source_95;
131899
131900 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
131901 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
131902
131903 ---------------------------------------------------------------------------------------------------------------
131904 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
131905 ---------------------------------------------------------------------------------------------------------------
131906 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
131907
131908 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
131909 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
131910
131911 IF xla_accounting_cache_pkg.GetValueChar
131912 (p_source_code => 'LEDGER_CATEGORY_CODE'
131913 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
131914 AND l_bflow_method_code = 'PRIOR_ENTRY'
131915 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
131916 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
131917 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
131918 )
131919 THEN
131920 xla_ae_lines_pkg.BflowUpgEntry
131921 (p_business_method_code => l_bflow_method_code
131922 ,p_business_class_code => l_bflow_class_code
131923 ,p_balance_type => l_balance_type_code);
131924 ELSE
131925 NULL;
131926 -- No business flow processing for business flow method of NONE.
131927 END IF;
131928
131929 --
131930 -- call analytical criteria
131931 --
131932
131933
131934 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
131935 xla_ae_lines_pkg.SetAnalyticalCriteria(
131936 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
131937 , p_analytical_criterion_owner => 'S'
131938 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
131939 , p_amb_context_code => 'DEFAULT'
131940 , p_balancing_flag => 'Y'
131941
131942 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
131943 , p_analytical_detail_num_1 => NULL
131944 , p_analytical_detail_date_1 => NULL
131945
131946 , p_ae_header_id => l_ae_header_id
131947 )
131948 ;
131949 --
131950
131951 --
131952 -- call description
131953 --
131954
131955 xla_ae_lines_pkg.SetLineDescription(
131956 p_ae_header_id => l_ae_header_id
131957 ,p_description => Description_1 (
131958 p_application_id => p_application_id
131959 , p_ae_header_id => l_ae_header_id
131960 , p_source_1 => p_source_1
131961 , p_source_2 => p_source_2
131962 , p_source_3 => p_source_3
131963 , p_source_4 => p_source_4
131964 , p_source_5 => p_source_5
131965 )
131966 );
131967
131968
131969 --
131970 -- call ADRs
131971 -- Bug 4922099
131972 --
131973 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
131974 (NVL(l_actual_upg_option, 'N') = 'O') OR
131975 (NVL(l_enc_upg_option, 'N') = 'O')
131976 )
131977 THEN
131978 NULL;
131979 --
131980 --
131981
131982 l_ccid := AcctDerRule_28(
131983 p_application_id => p_application_id
131984 , p_ae_header_id => l_ae_header_id
131985 , p_source_15 => p_source_15
131986 , p_source_41 => p_source_41
131987 , p_source_42 => p_source_42
131988 , p_source_43 => p_source_43
131989 , p_source_44 => p_source_44
131990 , p_source_45 => p_source_45
131991 , x_transaction_coa_id => l_adr_transaction_coa_id
131992 , x_accounting_coa_id => l_adr_accounting_coa_id
131993 , x_value_type_code => l_adr_value_type_code
131994 , p_side => 'NA'
131995 );
131996
131997 xla_ae_lines_pkg.set_ccid(
131998 p_code_combination_id => l_ccid
131999 , p_value_type_code => l_adr_value_type_code
132000 , p_transaction_coa_id => l_adr_transaction_coa_id
132001 , p_accounting_coa_id => l_adr_accounting_coa_id
132002 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
132003 , p_adr_type_code => 'S'
132004 , p_component_type => l_component_type
132005 , p_component_code => l_component_code
132006 , p_component_type_code => l_component_type_code
132007 , p_component_appl_id => l_component_appl_id
132008 , p_amb_context_code => l_amb_context_code
132009 , p_side => 'NA'
132010 );
132011
132012
132013 --
132014 --
132015 END IF;
132016 --
132017 -- Bug 4922099
132018 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
132019 (NVL(l_enc_upg_option, 'N') = 'O')
132020 ) AND
132021 (l_bflow_method_code = 'PRIOR_ENTRY')
132022 )
132023 THEN
132024 IF
132025 --
132026 1 = 2
132027 --
132028 THEN
132029 xla_accounting_err_pkg.build_message
132030 (p_appli_s_name => 'XLA'
132031 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
132032 ,p_token_1 => 'LINE_NUMBER'
132033 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
132034 ,p_token_2 => 'LINE_TYPE_NAME'
132035 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
132036 l_component_type
132037 ,l_component_code
132038 ,l_component_type_code
132039 ,l_component_appl_id
132040 ,l_amb_context_code
132041 ,l_entity_code
132042 ,l_event_class_code
132043 )
132044 ,p_token_3 => 'OWNER'
132045 ,p_value_3 => xla_lookups_pkg.get_meaning(
132046 p_lookup_type => 'XLA_OWNER_TYPE'
132047 ,p_lookup_code => l_component_type_code
132048 )
132049 ,p_token_4 => 'PRODUCT_NAME'
132050 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
132051 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
132052 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
132053 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
132054 ,p_ae_header_id => NULL
132055 );
132056
132057 IF (C_LEVEL_ERROR>= g_log_level) THEN
132058 trace
132059 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
132060 ,p_level => C_LEVEL_ERROR
132061 ,p_module => l_log_module);
132062 END IF;
132063 END IF;
132064 END IF;
132065 --
132066 --
132067 ------------------------------------------------------------------------------------------------
132068 -- 4219869 Business Flow
132069 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
132070 -- Prior Entry. Currently, the following code is always generated.
132071 ------------------------------------------------------------------------------------------------
132072 XLA_AE_LINES_PKG.ValidateCurrentLine;
132073
132074 ------------------------------------------------------------------------------------
132075 -- 4219869 Business Flow
132076 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
132077 ------------------------------------------------------------------------------------
132078 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
132079
132080 ----------------------------------------------------------------------------------
132081 -- 4219869 Business Flow
132082 -- Update journal entry status -- Need to generate this within IF <condition>
132083 ----------------------------------------------------------------------------------
132084 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
132085 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
132086 ,p_balance_type_code => l_balance_type_code
132087 );
132088
132089 -------------------------------------------------------------------------------------------
132090 -- 4262811 - Generate the Accrual Reversal lines
132091 -------------------------------------------------------------------------------------------
132092 BEGIN
132093 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
132094 (g_array_event(p_event_id).array_value_num('header_index'));
132095 IF l_acc_rev_flag IS NULL THEN
132096 l_acc_rev_flag := 'N';
132097 END IF;
132098 EXCEPTION
132099 WHEN OTHERS THEN
132100 l_acc_rev_flag := 'N';
132101 END;
132102 --
132103 IF (l_acc_rev_flag = 'Y') THEN
132104
132105 -- 4645092 ------------------------------------------------------------------------------
132106 -- To allow MPA report to determine if it should generate report process
132107 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
132108 ------------------------------------------------------------------------------------------
132109
132110 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
132111 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
132112 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
132113 -- call ADRs
132114 -- Bug 4922099
132115 --
132116 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
132117 (NVL(l_actual_upg_option, 'N') = 'O') OR
132118 (NVL(l_enc_upg_option, 'N') = 'O')
132119 )
132120 THEN
132121 NULL;
132122 --
132123 --
132124
132125 l_ccid := AcctDerRule_28(
132126 p_application_id => p_application_id
132127 , p_ae_header_id => l_ae_header_id
132128 , p_source_15 => p_source_15
132129 , p_source_41 => p_source_41
132130 , p_source_42 => p_source_42
132131 , p_source_43 => p_source_43
132132 , p_source_44 => p_source_44
132133 , p_source_45 => p_source_45
132134 , x_transaction_coa_id => l_adr_transaction_coa_id
132135 , x_accounting_coa_id => l_adr_accounting_coa_id
132136 , x_value_type_code => l_adr_value_type_code
132137 , p_side => 'NA'
132138 );
132139
132140 xla_ae_lines_pkg.set_ccid(
132141 p_code_combination_id => l_ccid
132142 , p_value_type_code => l_adr_value_type_code
132143 , p_transaction_coa_id => l_adr_transaction_coa_id
132144 , p_accounting_coa_id => l_adr_accounting_coa_id
132145 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
132146 , p_adr_type_code => 'S'
132147 , p_component_type => l_component_type
132148 , p_component_code => l_component_code
132149 , p_component_type_code => l_component_type_code
132150 , p_component_appl_id => l_component_appl_id
132151 , p_amb_context_code => l_amb_context_code
132152 , p_side => 'NA'
132153 );
132154
132155
132156 --
132157 --
132158 END IF;
132159
132160 --
132161 -- Update the line information that should be overwritten
132162 --
132163 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
132164 p_header_num => 1);
132165 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
132166
132167 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
132168
132169 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
132170 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
132171 END IF;
132172
132173 --
132174 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
132175 --
132176 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
132177 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
132178 ELSE
132179 ---------------------------------------------------------------------------------------------------
132180 -- 4262811a Switch Sign
132181 ---------------------------------------------------------------------------------------------------
132182 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
132183 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
132184 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132185 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
132186 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132187 -- 5132302
132188 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
132189 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132190
132191 END IF;
132192
132193 -- 4955764
132194 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
132195 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
132196
132197
132198 XLA_AE_LINES_PKG.ValidateCurrentLine;
132199 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
132200
132201 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
132202 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
132203 ,p_balance_type_code => l_balance_type_code);
132204
132205 END IF;
132206
132207 -----------------------------------------------------------------------------------------
132208 -- 4262811 Multiperiod Accounting
132209 -----------------------------------------------------------------------------------------
132210 -- No MPA option is assigned.
132211
132212
132213 END IF;
132214 END IF;
132215 --
132216
132217 --
132218 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
132219 trace
132220 (p_msg => 'END of AcctLineType_252'
132221 ,p_level => C_LEVEL_PROCEDURE
132222 ,p_module => l_log_module);
132223 END IF;
132224 --
132225 EXCEPTION
132226 WHEN xla_exceptions_pkg.application_exception THEN
132227 RAISE;
132228 WHEN OTHERS THEN
132229 xla_exceptions_pkg.raise_message
132230 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_252');
132231 END AcctLineType_252;
132232 --
132233
132234 ---------------------------------------
132235 --
132236 -- PRIVATE FUNCTION
132237 -- AcctLineType_253
132238 --
132239 ---------------------------------------
132240 PROCEDURE AcctLineType_253 (
132241 p_application_id IN NUMBER
132242 ,p_event_id IN NUMBER
132243 ,p_calculate_acctd_flag IN VARCHAR2
132244 ,p_calculate_g_l_flag IN VARCHAR2
132245 ,p_actual_flag IN OUT VARCHAR2
132246 ,p_balance_type_code OUT VARCHAR2
132247 ,p_gain_or_loss_ref OUT VARCHAR2
132248
132249 --Cost Element Name
132250 , p_source_15 IN NUMBER
132251 --Product Line Accounting Category Material Account
132252 , p_source_41 IN NUMBER
132253 --Product Line Accounting Category Material Overhead Account
132254 , p_source_42 IN NUMBER
132255 --Product Line Accounting Category Resource Account
132256 , p_source_43 IN NUMBER
132257 --Product Line Accounting Category Outside Processing Account
132258 , p_source_44 IN NUMBER
132259 --Product Line Accounting Category Overhead Account
132260 , p_source_45 IN NUMBER
132261 --DISTRIBUTION_IDENTIFIER
132262 , p_source_84 IN NUMBER
132263 --Distribution Type
132264 , p_source_85 IN VARCHAR2
132265 , p_source_85_meaning IN VARCHAR2
132266 --Entered Currency Code
132267 , p_source_88 IN VARCHAR2
132268 --Entered Amount
132269 , p_source_91 IN NUMBER
132270 --Currency Conversion Date
132271 , p_source_92 IN DATE
132272 --Currency Conversion Rate
132273 , p_source_93 IN NUMBER
132274 --Currency Conversion Type
132275 , p_source_94 IN VARCHAR2
132276 --Accounted Amount
132277 , p_source_95 IN NUMBER
132278 --Accounting Line Type
132279 , p_source_97 IN NUMBER
132280 --Organization Code
132281 , p_source_108 IN VARCHAR2
132282 )
132283 IS
132284
132285 l_component_type VARCHAR2(80);
132286 l_component_code VARCHAR2(30);
132287 l_component_type_code VARCHAR2(1);
132288 l_component_appl_id INTEGER;
132289 l_amb_context_code VARCHAR2(30);
132290 l_entity_code VARCHAR2(30);
132291 l_event_class_code VARCHAR2(30);
132292 l_ae_header_id NUMBER;
132293 l_event_type_code VARCHAR2(30);
132294 l_line_definition_code VARCHAR2(30);
132295 l_line_definition_owner_code VARCHAR2(1);
132296 --
132297 -- adr variables
132298 l_segment VARCHAR2(30);
132299 l_ccid NUMBER;
132300 l_adr_transaction_coa_id NUMBER;
132301 l_adr_accounting_coa_id NUMBER;
132302 l_adr_flexfield_segment_code VARCHAR2(30);
132303 l_adr_flex_value_set_id NUMBER;
132304 l_adr_value_type_code VARCHAR2(30);
132305 l_adr_value_combination_id NUMBER;
132306 l_adr_value_segment_code VARCHAR2(30);
132307
132308 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
132309 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
132310 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
132311 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
132312
132313 -- 4262811 Variables ------------------------------------------------------------------------------------------
132314 l_entered_amt_idx NUMBER;
132315 l_accted_amt_idx NUMBER;
132316 l_acc_rev_flag VARCHAR2(1);
132317 l_accrual_line_num NUMBER;
132318 l_tmp_amt NUMBER;
132319 l_acc_rev_natural_side_code VARCHAR2(1);
132320
132321 l_num_entries NUMBER;
132322 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
132323 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
132324 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
132325 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
132326 l_recog_line_1 NUMBER;
132327 l_recog_line_2 NUMBER;
132328
132329 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
132330 l_bflow_applied_to_amt NUMBER; -- 5132302
132331 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
132332
132333 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
132334
132335 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
132336 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
132337
132338 ---------------------------------------------------------------------------------------------------------------
132339
132340
132341 --
132342 -- bulk performance
132343 --
132344 l_balance_type_code VARCHAR2(1);
132345 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
132346 l_log_module VARCHAR2(240);
132347
132348 --
132349 -- Upgrade strategy
132350 --
132351 l_actual_upg_option VARCHAR2(1);
132352 l_enc_upg_option VARCHAR2(1);
132353
132354 --
132355 BEGIN
132356 --
132357 IF g_log_enabled THEN
132358 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_253';
132359 END IF;
132360 --
132361 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
132362
132363 trace
132364 (p_msg => 'BEGIN of AcctLineType_253'
132365 ,p_level => C_LEVEL_PROCEDURE
132366 ,p_module => l_log_module);
132367
132368 END IF;
132369 --
132370 l_component_type := 'AMB_JLT';
132371 l_component_code := 'INVENTORY_VALUATION';
132372 l_component_type_code := 'S';
132373 l_component_appl_id := 707;
132374 l_amb_context_code := 'DEFAULT';
132375 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
132376 l_event_class_code := 'USER_DEFINE';
132377 l_event_type_code := 'UMISC_RCPT';
132378 l_line_definition_owner_code := 'S';
132379 l_line_definition_code := 'PI_USER_RCPT';
132380 --
132381 l_balance_type_code := 'A';
132382 l_segment := NULL;
132383 l_ccid := NULL;
132384 l_adr_transaction_coa_id := NULL;
132385 l_adr_accounting_coa_id := NULL;
132386 l_adr_flexfield_segment_code := NULL;
132387 l_adr_flex_value_set_id := NULL;
132388 l_adr_value_type_code := NULL;
132389 l_adr_value_combination_id := NULL;
132390 l_adr_value_segment_code := NULL;
132391
132392 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
132393 l_bflow_class_code := ''; -- 4219869 Business Flow
132394 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
132395 l_budgetary_control_flag := 'N';
132396
132397 l_bflow_applied_to_amt_idx := NULL; -- 5132302
132398 l_bflow_applied_to_amt := NULL; -- 5132302
132399 l_entered_amt_idx := NULL; -- 4262811
132400 l_accted_amt_idx := NULL; -- 4262811
132401 l_acc_rev_flag := NULL; -- 4262811
132402 l_accrual_line_num := NULL; -- 4262811
132403 l_tmp_amt := NULL; -- 4262811
132404 --
132405
132406 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
132407 l_balance_type_code <> 'B' THEN
132408 IF NVL(p_source_97,9E125) = 1
132409 THEN
132410
132411 --
132412 XLA_AE_LINES_PKG.SetNewLine;
132413
132414 p_balance_type_code := l_balance_type_code;
132415 -- set the flag so later we will know whether the gain loss line needs to be created
132416
132417 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
132418 p_actual_flag :='A';
132419 END IF;
132420
132421 --
132422 -- bulk performance
132423 --
132424 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
132425 p_header_num => 0); -- 4262811
132426 --
132427 -- set accounting line options
132428 --
132429 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
132430 p_natural_side_code => 'D'
132431 , p_gain_or_loss_flag => 'N'
132432 , p_gl_transfer_mode_code => 'S'
132433 , p_acct_entry_type_code => 'A'
132434 , p_switch_side_flag => 'Y'
132435 , p_merge_duplicate_code => 'N'
132436 );
132437 --
132438 l_acc_rev_natural_side_code := 'C'; -- 4262811
132439 --
132440 --
132441 -- set accounting line type info
132442 --
132443 xla_ae_lines_pkg.SetAcctLineType
132444 (p_component_type => l_component_type
132445 ,p_event_type_code => l_event_type_code
132446 ,p_line_definition_owner_code => l_line_definition_owner_code
132447 ,p_line_definition_code => l_line_definition_code
132448 ,p_accounting_line_code => l_component_code
132449 ,p_accounting_line_type_code => l_component_type_code
132450 ,p_accounting_line_appl_id => l_component_appl_id
132451 ,p_amb_context_code => l_amb_context_code
132452 ,p_entity_code => l_entity_code
132453 ,p_event_class_code => l_event_class_code);
132454 --
132455 -- set accounting class
132456 --
132457 xla_ae_lines_pkg.SetAcctClass(
132458 p_accounting_class_code => 'INVENTORY_VALUATION'
132459 , p_ae_header_id => l_ae_header_id
132460 );
132461
132462 --
132463 -- set rounding class
132464 --
132465 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
132466 'INVENTORY_VALUATION';
132467
132468 --
132469 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
132470 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
132471 --
132472 -- bulk performance
132473 --
132474 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
132475
132476 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
132477 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
132478
132479 -- 4955764
132480 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
132481 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
132482
132483 -- 4458381 Public Sector Enh
132484
132485 --
132486 -- set accounting attributes for the line type
132487 --
132488 l_entered_amt_idx := 3;
132489 l_accted_amt_idx := 8;
132490 l_bflow_applied_to_amt_idx := NULL; -- 5132302
132491 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
132492 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
132493 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
132494 l_rec_acct_attrs.array_char_value(2) := p_source_85;
132495 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
132496 l_rec_acct_attrs.array_num_value(3) := p_source_91;
132497 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
132498 l_rec_acct_attrs.array_char_value(4) := p_source_88;
132499 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
132500 l_rec_acct_attrs.array_date_value(5) := p_source_92;
132501 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
132502 l_rec_acct_attrs.array_num_value(6) := p_source_93;
132503 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
132504 l_rec_acct_attrs.array_char_value(7) := p_source_94;
132505 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
132506 l_rec_acct_attrs.array_num_value(8) := p_source_95;
132507
132508 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
132509 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
132510
132511 ---------------------------------------------------------------------------------------------------------------
132512 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
132513 ---------------------------------------------------------------------------------------------------------------
132514 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
132515
132516 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
132517 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
132518
132519 IF xla_accounting_cache_pkg.GetValueChar
132520 (p_source_code => 'LEDGER_CATEGORY_CODE'
132521 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
132522 AND l_bflow_method_code = 'PRIOR_ENTRY'
132523 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
132524 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
132525 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
132526 )
132527 THEN
132528 xla_ae_lines_pkg.BflowUpgEntry
132529 (p_business_method_code => l_bflow_method_code
132530 ,p_business_class_code => l_bflow_class_code
132531 ,p_balance_type => l_balance_type_code);
132532 ELSE
132533 NULL;
132534 -- No business flow processing for business flow method of NONE.
132535 END IF;
132536
132537 --
132538 -- call analytical criteria
132539 --
132540
132541
132542 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
132543 xla_ae_lines_pkg.SetAnalyticalCriteria(
132544 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
132545 , p_analytical_criterion_owner => 'S'
132546 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
132547 , p_amb_context_code => 'DEFAULT'
132548 , p_balancing_flag => 'Y'
132549
132550 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
132551 , p_analytical_detail_num_1 => NULL
132552 , p_analytical_detail_date_1 => NULL
132553
132554 , p_ae_header_id => l_ae_header_id
132555 )
132556 ;
132557 --
132558
132559 --
132560 -- call description
132561 --
132562 -- No description or it is inherited.
132563 --
132564 -- call ADRs
132565 -- Bug 4922099
132566 --
132567 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
132568 (NVL(l_actual_upg_option, 'N') = 'O') OR
132569 (NVL(l_enc_upg_option, 'N') = 'O')
132570 )
132571 THEN
132572 NULL;
132573 --
132574 --
132575
132576 l_ccid := AcctDerRule_28(
132577 p_application_id => p_application_id
132578 , p_ae_header_id => l_ae_header_id
132579 , p_source_15 => p_source_15
132580 , p_source_41 => p_source_41
132581 , p_source_42 => p_source_42
132582 , p_source_43 => p_source_43
132583 , p_source_44 => p_source_44
132584 , p_source_45 => p_source_45
132585 , x_transaction_coa_id => l_adr_transaction_coa_id
132586 , x_accounting_coa_id => l_adr_accounting_coa_id
132587 , x_value_type_code => l_adr_value_type_code
132588 , p_side => 'NA'
132589 );
132590
132591 xla_ae_lines_pkg.set_ccid(
132592 p_code_combination_id => l_ccid
132593 , p_value_type_code => l_adr_value_type_code
132594 , p_transaction_coa_id => l_adr_transaction_coa_id
132595 , p_accounting_coa_id => l_adr_accounting_coa_id
132596 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
132597 , p_adr_type_code => 'S'
132598 , p_component_type => l_component_type
132599 , p_component_code => l_component_code
132600 , p_component_type_code => l_component_type_code
132601 , p_component_appl_id => l_component_appl_id
132602 , p_amb_context_code => l_amb_context_code
132603 , p_side => 'NA'
132604 );
132605
132606
132607 --
132608 --
132609 END IF;
132610 --
132611 -- Bug 4922099
132612 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
132613 (NVL(l_enc_upg_option, 'N') = 'O')
132614 ) AND
132615 (l_bflow_method_code = 'PRIOR_ENTRY')
132616 )
132617 THEN
132618 IF
132619 --
132620 1 = 2
132621 --
132622 THEN
132623 xla_accounting_err_pkg.build_message
132624 (p_appli_s_name => 'XLA'
132625 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
132626 ,p_token_1 => 'LINE_NUMBER'
132627 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
132628 ,p_token_2 => 'LINE_TYPE_NAME'
132629 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
132630 l_component_type
132631 ,l_component_code
132632 ,l_component_type_code
132633 ,l_component_appl_id
132634 ,l_amb_context_code
132635 ,l_entity_code
132636 ,l_event_class_code
132637 )
132638 ,p_token_3 => 'OWNER'
132639 ,p_value_3 => xla_lookups_pkg.get_meaning(
132640 p_lookup_type => 'XLA_OWNER_TYPE'
132641 ,p_lookup_code => l_component_type_code
132642 )
132643 ,p_token_4 => 'PRODUCT_NAME'
132644 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
132645 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
132646 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
132647 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
132648 ,p_ae_header_id => NULL
132649 );
132650
132651 IF (C_LEVEL_ERROR>= g_log_level) THEN
132652 trace
132653 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
132654 ,p_level => C_LEVEL_ERROR
132655 ,p_module => l_log_module);
132656 END IF;
132657 END IF;
132658 END IF;
132659 --
132660 --
132661 ------------------------------------------------------------------------------------------------
132662 -- 4219869 Business Flow
132663 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
132664 -- Prior Entry. Currently, the following code is always generated.
132665 ------------------------------------------------------------------------------------------------
132666 XLA_AE_LINES_PKG.ValidateCurrentLine;
132667
132668 ------------------------------------------------------------------------------------
132669 -- 4219869 Business Flow
132670 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
132671 ------------------------------------------------------------------------------------
132672 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
132673
132674 ----------------------------------------------------------------------------------
132675 -- 4219869 Business Flow
132676 -- Update journal entry status -- Need to generate this within IF <condition>
132677 ----------------------------------------------------------------------------------
132678 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
132679 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
132680 ,p_balance_type_code => l_balance_type_code
132681 );
132682
132683 -------------------------------------------------------------------------------------------
132684 -- 4262811 - Generate the Accrual Reversal lines
132685 -------------------------------------------------------------------------------------------
132686 BEGIN
132687 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
132688 (g_array_event(p_event_id).array_value_num('header_index'));
132689 IF l_acc_rev_flag IS NULL THEN
132690 l_acc_rev_flag := 'N';
132691 END IF;
132692 EXCEPTION
132693 WHEN OTHERS THEN
132694 l_acc_rev_flag := 'N';
132695 END;
132696 --
132697 IF (l_acc_rev_flag = 'Y') THEN
132698
132699 -- 4645092 ------------------------------------------------------------------------------
132700 -- To allow MPA report to determine if it should generate report process
132701 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
132702 ------------------------------------------------------------------------------------------
132703
132704 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
132705 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
132706 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
132707 -- call ADRs
132708 -- Bug 4922099
132709 --
132710 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
132711 (NVL(l_actual_upg_option, 'N') = 'O') OR
132712 (NVL(l_enc_upg_option, 'N') = 'O')
132713 )
132714 THEN
132715 NULL;
132716 --
132717 --
132718
132719 l_ccid := AcctDerRule_28(
132720 p_application_id => p_application_id
132721 , p_ae_header_id => l_ae_header_id
132722 , p_source_15 => p_source_15
132723 , p_source_41 => p_source_41
132724 , p_source_42 => p_source_42
132725 , p_source_43 => p_source_43
132726 , p_source_44 => p_source_44
132727 , p_source_45 => p_source_45
132728 , x_transaction_coa_id => l_adr_transaction_coa_id
132729 , x_accounting_coa_id => l_adr_accounting_coa_id
132730 , x_value_type_code => l_adr_value_type_code
132731 , p_side => 'NA'
132732 );
132733
132734 xla_ae_lines_pkg.set_ccid(
132735 p_code_combination_id => l_ccid
132736 , p_value_type_code => l_adr_value_type_code
132737 , p_transaction_coa_id => l_adr_transaction_coa_id
132738 , p_accounting_coa_id => l_adr_accounting_coa_id
132739 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
132740 , p_adr_type_code => 'S'
132741 , p_component_type => l_component_type
132742 , p_component_code => l_component_code
132743 , p_component_type_code => l_component_type_code
132744 , p_component_appl_id => l_component_appl_id
132745 , p_amb_context_code => l_amb_context_code
132746 , p_side => 'NA'
132747 );
132748
132749
132750 --
132751 --
132752 END IF;
132753
132754 --
132755 -- Update the line information that should be overwritten
132756 --
132757 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
132758 p_header_num => 1);
132759 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
132760
132761 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
132762
132763 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
132764 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
132765 END IF;
132766
132767 --
132768 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
132769 --
132770 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
132771 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
132772 ELSE
132773 ---------------------------------------------------------------------------------------------------
132774 -- 4262811a Switch Sign
132775 ---------------------------------------------------------------------------------------------------
132776 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
132777 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
132778 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132779 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
132780 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132781 -- 5132302
132782 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
132783 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
132784
132785 END IF;
132786
132787 -- 4955764
132788 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
132789 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
132790
132791
132792 XLA_AE_LINES_PKG.ValidateCurrentLine;
132793 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
132794
132795 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
132796 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
132797 ,p_balance_type_code => l_balance_type_code);
132798
132799 END IF;
132800
132801 -----------------------------------------------------------------------------------------
132802 -- 4262811 Multiperiod Accounting
132803 -----------------------------------------------------------------------------------------
132804 -- No MPA option is assigned.
132805
132806
132807 END IF;
132808 END IF;
132809 --
132810
132811 --
132812 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
132813 trace
132814 (p_msg => 'END of AcctLineType_253'
132815 ,p_level => C_LEVEL_PROCEDURE
132816 ,p_module => l_log_module);
132817 END IF;
132818 --
132819 EXCEPTION
132820 WHEN xla_exceptions_pkg.application_exception THEN
132821 RAISE;
132822 WHEN OTHERS THEN
132823 xla_exceptions_pkg.raise_message
132824 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_253');
132825 END AcctLineType_253;
132826 --
132827
132828 ---------------------------------------
132829 --
132830 -- PRIVATE FUNCTION
132831 -- AcctLineType_254
132832 --
132833 ---------------------------------------
132834 PROCEDURE AcctLineType_254 (
132835 p_application_id IN NUMBER
132836 ,p_event_id IN NUMBER
132837 ,p_calculate_acctd_flag IN VARCHAR2
132838 ,p_calculate_g_l_flag IN VARCHAR2
132839 ,p_actual_flag IN OUT VARCHAR2
132840 ,p_balance_type_code OUT VARCHAR2
132841 ,p_gain_or_loss_ref OUT VARCHAR2
132842
132843 --TRANSACTION_ID
132844 , p_source_1 IN NUMBER
132845 --Item Concatenated Segments
132846 , p_source_2 IN VARCHAR2
132847 --Transaction Quantity
132848 , p_source_3 IN NUMBER
132849 --Transaction Unit of Measure Code
132850 , p_source_4 IN VARCHAR2
132851 --Inventory Transaction Type Description
132852 , p_source_5 IN VARCHAR2
132853 --Cost Element Name
132854 , p_source_15 IN NUMBER
132855 --Product Line Accounting Category Material Account
132856 , p_source_41 IN NUMBER
132857 --Product Line Accounting Category Material Overhead Account
132858 , p_source_42 IN NUMBER
132859 --Product Line Accounting Category Resource Account
132860 , p_source_43 IN NUMBER
132861 --Product Line Accounting Category Outside Processing Account
132862 , p_source_44 IN NUMBER
132863 --Product Line Accounting Category Overhead Account
132864 , p_source_45 IN NUMBER
132865 --DISTRIBUTION_IDENTIFIER
132866 , p_source_84 IN NUMBER
132867 --Distribution Type
132868 , p_source_85 IN VARCHAR2
132869 , p_source_85_meaning IN VARCHAR2
132870 --Entered Currency Code
132871 , p_source_88 IN VARCHAR2
132872 --Entered Amount
132873 , p_source_91 IN NUMBER
132874 --Currency Conversion Date
132875 , p_source_92 IN DATE
132876 --Currency Conversion Rate
132877 , p_source_93 IN NUMBER
132878 --Currency Conversion Type
132879 , p_source_94 IN VARCHAR2
132880 --Accounted Amount
132881 , p_source_95 IN NUMBER
132882 --Accounting Line Type
132883 , p_source_97 IN NUMBER
132884 --Organization Code
132885 , p_source_108 IN VARCHAR2
132886 )
132887 IS
132888
132889 l_component_type VARCHAR2(80);
132890 l_component_code VARCHAR2(30);
132891 l_component_type_code VARCHAR2(1);
132892 l_component_appl_id INTEGER;
132893 l_amb_context_code VARCHAR2(30);
132894 l_entity_code VARCHAR2(30);
132895 l_event_class_code VARCHAR2(30);
132896 l_ae_header_id NUMBER;
132897 l_event_type_code VARCHAR2(30);
132898 l_line_definition_code VARCHAR2(30);
132899 l_line_definition_owner_code VARCHAR2(1);
132900 --
132901 -- adr variables
132902 l_segment VARCHAR2(30);
132903 l_ccid NUMBER;
132904 l_adr_transaction_coa_id NUMBER;
132905 l_adr_accounting_coa_id NUMBER;
132906 l_adr_flexfield_segment_code VARCHAR2(30);
132907 l_adr_flex_value_set_id NUMBER;
132908 l_adr_value_type_code VARCHAR2(30);
132909 l_adr_value_combination_id NUMBER;
132910 l_adr_value_segment_code VARCHAR2(30);
132911
132912 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
132913 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
132914 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
132915 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
132916
132917 -- 4262811 Variables ------------------------------------------------------------------------------------------
132918 l_entered_amt_idx NUMBER;
132919 l_accted_amt_idx NUMBER;
132920 l_acc_rev_flag VARCHAR2(1);
132921 l_accrual_line_num NUMBER;
132922 l_tmp_amt NUMBER;
132923 l_acc_rev_natural_side_code VARCHAR2(1);
132924
132925 l_num_entries NUMBER;
132926 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
132927 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
132928 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
132929 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
132930 l_recog_line_1 NUMBER;
132931 l_recog_line_2 NUMBER;
132932
132933 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
132934 l_bflow_applied_to_amt NUMBER; -- 5132302
132935 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
132936
132937 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
132938
132939 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
132940 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
132941
132942 ---------------------------------------------------------------------------------------------------------------
132943
132944
132945 --
132946 -- bulk performance
132947 --
132948 l_balance_type_code VARCHAR2(1);
132949 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
132950 l_log_module VARCHAR2(240);
132951
132952 --
132953 -- Upgrade strategy
132954 --
132955 l_actual_upg_option VARCHAR2(1);
132956 l_enc_upg_option VARCHAR2(1);
132957
132958 --
132959 BEGIN
132960 --
132961 IF g_log_enabled THEN
132962 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_254';
132963 END IF;
132964 --
132965 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
132966
132967 trace
132968 (p_msg => 'BEGIN of AcctLineType_254'
132969 ,p_level => C_LEVEL_PROCEDURE
132970 ,p_module => l_log_module);
132971
132972 END IF;
132973 --
132974 l_component_type := 'AMB_JLT';
132975 l_component_code := 'INVENTORY_VALUATION';
132976 l_component_type_code := 'S';
132977 l_component_appl_id := 707;
132978 l_amb_context_code := 'DEFAULT';
132979 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
132980 l_event_class_code := 'WIP_MTL';
132981 l_event_type_code := 'WIP_NEG_COMP_RETURN';
132982 l_line_definition_owner_code := 'S';
132983 l_line_definition_code := 'PI_WIP_NEG_COMP_RETURN';
132984 --
132985 l_balance_type_code := 'A';
132986 l_segment := NULL;
132987 l_ccid := NULL;
132988 l_adr_transaction_coa_id := NULL;
132989 l_adr_accounting_coa_id := NULL;
132990 l_adr_flexfield_segment_code := NULL;
132991 l_adr_flex_value_set_id := NULL;
132992 l_adr_value_type_code := NULL;
132993 l_adr_value_combination_id := NULL;
132994 l_adr_value_segment_code := NULL;
132995
132996 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
132997 l_bflow_class_code := ''; -- 4219869 Business Flow
132998 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
132999 l_budgetary_control_flag := 'N';
133000
133001 l_bflow_applied_to_amt_idx := NULL; -- 5132302
133002 l_bflow_applied_to_amt := NULL; -- 5132302
133003 l_entered_amt_idx := NULL; -- 4262811
133004 l_accted_amt_idx := NULL; -- 4262811
133005 l_acc_rev_flag := NULL; -- 4262811
133006 l_accrual_line_num := NULL; -- 4262811
133007 l_tmp_amt := NULL; -- 4262811
133008 --
133009
133010 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
133011 l_balance_type_code <> 'B' THEN
133012 IF NVL(p_source_97,9E125) = 1
133013 THEN
133014
133015 --
133016 XLA_AE_LINES_PKG.SetNewLine;
133017
133018 p_balance_type_code := l_balance_type_code;
133019 -- set the flag so later we will know whether the gain loss line needs to be created
133020
133021 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
133022 p_actual_flag :='A';
133023 END IF;
133024
133025 --
133026 -- bulk performance
133027 --
133028 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
133029 p_header_num => 0); -- 4262811
133030 --
133031 -- set accounting line options
133032 --
133033 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
133034 p_natural_side_code => 'D'
133035 , p_gain_or_loss_flag => 'N'
133036 , p_gl_transfer_mode_code => 'S'
133037 , p_acct_entry_type_code => 'A'
133038 , p_switch_side_flag => 'Y'
133039 , p_merge_duplicate_code => 'N'
133040 );
133041 --
133042 l_acc_rev_natural_side_code := 'C'; -- 4262811
133043 --
133044 --
133045 -- set accounting line type info
133046 --
133047 xla_ae_lines_pkg.SetAcctLineType
133048 (p_component_type => l_component_type
133049 ,p_event_type_code => l_event_type_code
133050 ,p_line_definition_owner_code => l_line_definition_owner_code
133051 ,p_line_definition_code => l_line_definition_code
133052 ,p_accounting_line_code => l_component_code
133053 ,p_accounting_line_type_code => l_component_type_code
133054 ,p_accounting_line_appl_id => l_component_appl_id
133055 ,p_amb_context_code => l_amb_context_code
133056 ,p_entity_code => l_entity_code
133057 ,p_event_class_code => l_event_class_code);
133058 --
133059 -- set accounting class
133060 --
133061 xla_ae_lines_pkg.SetAcctClass(
133062 p_accounting_class_code => 'INVENTORY_VALUATION'
133063 , p_ae_header_id => l_ae_header_id
133064 );
133065
133066 --
133067 -- set rounding class
133068 --
133069 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
133070 'INVENTORY_VALUATION';
133071
133072 --
133073 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
133074 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
133075 --
133076 -- bulk performance
133077 --
133078 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
133079
133080 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
133081 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
133082
133083 -- 4955764
133084 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
133085 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
133086
133087 -- 4458381 Public Sector Enh
133088
133089 --
133090 -- set accounting attributes for the line type
133091 --
133092 l_entered_amt_idx := 3;
133093 l_accted_amt_idx := 8;
133094 l_bflow_applied_to_amt_idx := NULL; -- 5132302
133095 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
133096 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
133097 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
133098 l_rec_acct_attrs.array_char_value(2) := p_source_85;
133099 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
133100 l_rec_acct_attrs.array_num_value(3) := p_source_91;
133101 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
133102 l_rec_acct_attrs.array_char_value(4) := p_source_88;
133103 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
133104 l_rec_acct_attrs.array_date_value(5) := p_source_92;
133105 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
133106 l_rec_acct_attrs.array_num_value(6) := p_source_93;
133107 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
133108 l_rec_acct_attrs.array_char_value(7) := p_source_94;
133109 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
133110 l_rec_acct_attrs.array_num_value(8) := p_source_95;
133111
133112 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
133113 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
133114
133115 ---------------------------------------------------------------------------------------------------------------
133116 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
133117 ---------------------------------------------------------------------------------------------------------------
133118 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
133119
133120 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
133121 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
133122
133123 IF xla_accounting_cache_pkg.GetValueChar
133124 (p_source_code => 'LEDGER_CATEGORY_CODE'
133125 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
133126 AND l_bflow_method_code = 'PRIOR_ENTRY'
133127 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
133128 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
133129 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
133130 )
133131 THEN
133132 xla_ae_lines_pkg.BflowUpgEntry
133133 (p_business_method_code => l_bflow_method_code
133134 ,p_business_class_code => l_bflow_class_code
133135 ,p_balance_type => l_balance_type_code);
133136 ELSE
133137 NULL;
133138 -- No business flow processing for business flow method of NONE.
133139 END IF;
133140
133141 --
133142 -- call analytical criteria
133143 --
133144
133145
133146 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
133147 xla_ae_lines_pkg.SetAnalyticalCriteria(
133148 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
133149 , p_analytical_criterion_owner => 'S'
133150 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
133151 , p_amb_context_code => 'DEFAULT'
133152 , p_balancing_flag => 'Y'
133153
133154 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
133155 , p_analytical_detail_num_1 => NULL
133156 , p_analytical_detail_date_1 => NULL
133157
133158 , p_ae_header_id => l_ae_header_id
133159 )
133160 ;
133161 --
133162
133163 --
133164 -- call description
133165 --
133166
133167 xla_ae_lines_pkg.SetLineDescription(
133168 p_ae_header_id => l_ae_header_id
133169 ,p_description => Description_1 (
133170 p_application_id => p_application_id
133171 , p_ae_header_id => l_ae_header_id
133172 , p_source_1 => p_source_1
133173 , p_source_2 => p_source_2
133174 , p_source_3 => p_source_3
133175 , p_source_4 => p_source_4
133176 , p_source_5 => p_source_5
133177 )
133178 );
133179
133180
133181 --
133182 -- call ADRs
133183 -- Bug 4922099
133184 --
133185 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
133186 (NVL(l_actual_upg_option, 'N') = 'O') OR
133187 (NVL(l_enc_upg_option, 'N') = 'O')
133188 )
133189 THEN
133190 NULL;
133191 --
133192 --
133193
133194 l_ccid := AcctDerRule_28(
133195 p_application_id => p_application_id
133196 , p_ae_header_id => l_ae_header_id
133197 , p_source_15 => p_source_15
133198 , p_source_41 => p_source_41
133199 , p_source_42 => p_source_42
133200 , p_source_43 => p_source_43
133201 , p_source_44 => p_source_44
133202 , p_source_45 => p_source_45
133203 , x_transaction_coa_id => l_adr_transaction_coa_id
133204 , x_accounting_coa_id => l_adr_accounting_coa_id
133205 , x_value_type_code => l_adr_value_type_code
133206 , p_side => 'NA'
133207 );
133208
133209 xla_ae_lines_pkg.set_ccid(
133210 p_code_combination_id => l_ccid
133211 , p_value_type_code => l_adr_value_type_code
133212 , p_transaction_coa_id => l_adr_transaction_coa_id
133213 , p_accounting_coa_id => l_adr_accounting_coa_id
133214 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
133215 , p_adr_type_code => 'S'
133216 , p_component_type => l_component_type
133217 , p_component_code => l_component_code
133218 , p_component_type_code => l_component_type_code
133219 , p_component_appl_id => l_component_appl_id
133220 , p_amb_context_code => l_amb_context_code
133221 , p_side => 'NA'
133222 );
133223
133224
133225 --
133226 --
133227 END IF;
133228 --
133229 -- Bug 4922099
133230 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
133231 (NVL(l_enc_upg_option, 'N') = 'O')
133232 ) AND
133233 (l_bflow_method_code = 'PRIOR_ENTRY')
133234 )
133235 THEN
133236 IF
133237 --
133238 1 = 2
133239 --
133240 THEN
133241 xla_accounting_err_pkg.build_message
133242 (p_appli_s_name => 'XLA'
133243 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
133244 ,p_token_1 => 'LINE_NUMBER'
133245 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
133246 ,p_token_2 => 'LINE_TYPE_NAME'
133247 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
133248 l_component_type
133249 ,l_component_code
133250 ,l_component_type_code
133251 ,l_component_appl_id
133252 ,l_amb_context_code
133253 ,l_entity_code
133254 ,l_event_class_code
133255 )
133256 ,p_token_3 => 'OWNER'
133257 ,p_value_3 => xla_lookups_pkg.get_meaning(
133258 p_lookup_type => 'XLA_OWNER_TYPE'
133259 ,p_lookup_code => l_component_type_code
133260 )
133261 ,p_token_4 => 'PRODUCT_NAME'
133262 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
133263 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
133264 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
133265 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
133266 ,p_ae_header_id => NULL
133267 );
133268
133269 IF (C_LEVEL_ERROR>= g_log_level) THEN
133270 trace
133271 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
133272 ,p_level => C_LEVEL_ERROR
133273 ,p_module => l_log_module);
133274 END IF;
133275 END IF;
133276 END IF;
133277 --
133278 --
133279 ------------------------------------------------------------------------------------------------
133280 -- 4219869 Business Flow
133281 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
133282 -- Prior Entry. Currently, the following code is always generated.
133283 ------------------------------------------------------------------------------------------------
133284 XLA_AE_LINES_PKG.ValidateCurrentLine;
133285
133286 ------------------------------------------------------------------------------------
133287 -- 4219869 Business Flow
133288 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
133289 ------------------------------------------------------------------------------------
133290 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
133291
133292 ----------------------------------------------------------------------------------
133293 -- 4219869 Business Flow
133294 -- Update journal entry status -- Need to generate this within IF <condition>
133295 ----------------------------------------------------------------------------------
133296 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
133297 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
133298 ,p_balance_type_code => l_balance_type_code
133299 );
133300
133301 -------------------------------------------------------------------------------------------
133302 -- 4262811 - Generate the Accrual Reversal lines
133303 -------------------------------------------------------------------------------------------
133304 BEGIN
133305 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
133306 (g_array_event(p_event_id).array_value_num('header_index'));
133307 IF l_acc_rev_flag IS NULL THEN
133308 l_acc_rev_flag := 'N';
133309 END IF;
133310 EXCEPTION
133311 WHEN OTHERS THEN
133312 l_acc_rev_flag := 'N';
133313 END;
133314 --
133315 IF (l_acc_rev_flag = 'Y') THEN
133316
133317 -- 4645092 ------------------------------------------------------------------------------
133318 -- To allow MPA report to determine if it should generate report process
133319 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
133320 ------------------------------------------------------------------------------------------
133321
133322 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
133323 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
133324 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
133325 -- call ADRs
133326 -- Bug 4922099
133327 --
133328 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
133329 (NVL(l_actual_upg_option, 'N') = 'O') OR
133330 (NVL(l_enc_upg_option, 'N') = 'O')
133331 )
133332 THEN
133333 NULL;
133334 --
133335 --
133336
133337 l_ccid := AcctDerRule_28(
133338 p_application_id => p_application_id
133339 , p_ae_header_id => l_ae_header_id
133340 , p_source_15 => p_source_15
133341 , p_source_41 => p_source_41
133342 , p_source_42 => p_source_42
133343 , p_source_43 => p_source_43
133344 , p_source_44 => p_source_44
133345 , p_source_45 => p_source_45
133346 , x_transaction_coa_id => l_adr_transaction_coa_id
133347 , x_accounting_coa_id => l_adr_accounting_coa_id
133348 , x_value_type_code => l_adr_value_type_code
133349 , p_side => 'NA'
133350 );
133351
133352 xla_ae_lines_pkg.set_ccid(
133353 p_code_combination_id => l_ccid
133354 , p_value_type_code => l_adr_value_type_code
133355 , p_transaction_coa_id => l_adr_transaction_coa_id
133356 , p_accounting_coa_id => l_adr_accounting_coa_id
133357 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
133358 , p_adr_type_code => 'S'
133359 , p_component_type => l_component_type
133360 , p_component_code => l_component_code
133361 , p_component_type_code => l_component_type_code
133362 , p_component_appl_id => l_component_appl_id
133363 , p_amb_context_code => l_amb_context_code
133364 , p_side => 'NA'
133365 );
133366
133367
133368 --
133369 --
133370 END IF;
133371
133372 --
133373 -- Update the line information that should be overwritten
133374 --
133375 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
133376 p_header_num => 1);
133377 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
133378
133379 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
133380
133381 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
133382 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
133383 END IF;
133384
133385 --
133386 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
133387 --
133388 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
133389 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
133390 ELSE
133391 ---------------------------------------------------------------------------------------------------
133392 -- 4262811a Switch Sign
133393 ---------------------------------------------------------------------------------------------------
133394 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
133395 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
133396 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
133397 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
133398 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
133399 -- 5132302
133400 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
133401 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
133402
133403 END IF;
133404
133405 -- 4955764
133406 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
133407 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
133408
133409
133410 XLA_AE_LINES_PKG.ValidateCurrentLine;
133411 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
133412
133413 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
133414 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
133415 ,p_balance_type_code => l_balance_type_code);
133416
133417 END IF;
133418
133419 -----------------------------------------------------------------------------------------
133420 -- 4262811 Multiperiod Accounting
133421 -----------------------------------------------------------------------------------------
133422 -- No MPA option is assigned.
133423
133424
133425 END IF;
133426 END IF;
133427 --
133428
133429 --
133430 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
133431 trace
133432 (p_msg => 'END of AcctLineType_254'
133433 ,p_level => C_LEVEL_PROCEDURE
133434 ,p_module => l_log_module);
133435 END IF;
133436 --
133437 EXCEPTION
133438 WHEN xla_exceptions_pkg.application_exception THEN
133439 RAISE;
133440 WHEN OTHERS THEN
133441 xla_exceptions_pkg.raise_message
133442 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_254');
133443 END AcctLineType_254;
133444 --
133445
133446 ---------------------------------------
133447 --
133448 -- PRIVATE FUNCTION
133449 -- AcctLineType_255
133450 --
133451 ---------------------------------------
133452 PROCEDURE AcctLineType_255 (
133453 p_application_id IN NUMBER
133454 ,p_event_id IN NUMBER
133455 ,p_calculate_acctd_flag IN VARCHAR2
133456 ,p_calculate_g_l_flag IN VARCHAR2
133457 ,p_actual_flag IN OUT VARCHAR2
133458 ,p_balance_type_code OUT VARCHAR2
133459 ,p_gain_or_loss_ref OUT VARCHAR2
133460
133461 --TRANSACTION_ID
133462 , p_source_1 IN NUMBER
133463 --Item Concatenated Segments
133464 , p_source_2 IN VARCHAR2
133465 --Transaction Quantity
133466 , p_source_3 IN NUMBER
133467 --Transaction Unit of Measure Code
133468 , p_source_4 IN VARCHAR2
133469 --Inventory Transaction Type Description
133470 , p_source_5 IN VARCHAR2
133471 --Cost Element Name
133472 , p_source_15 IN NUMBER
133473 --Product Line Accounting Category Material Account
133474 , p_source_41 IN NUMBER
133475 --Product Line Accounting Category Material Overhead Account
133476 , p_source_42 IN NUMBER
133477 --Product Line Accounting Category Resource Account
133478 , p_source_43 IN NUMBER
133479 --Product Line Accounting Category Outside Processing Account
133480 , p_source_44 IN NUMBER
133481 --Product Line Accounting Category Overhead Account
133482 , p_source_45 IN NUMBER
133483 --DISTRIBUTION_IDENTIFIER
133484 , p_source_84 IN NUMBER
133485 --Distribution Type
133486 , p_source_85 IN VARCHAR2
133487 , p_source_85_meaning IN VARCHAR2
133488 --Entered Currency Code
133489 , p_source_88 IN VARCHAR2
133490 --Entered Amount
133491 , p_source_91 IN NUMBER
133492 --Currency Conversion Date
133493 , p_source_92 IN DATE
133494 --Currency Conversion Rate
133495 , p_source_93 IN NUMBER
133496 --Currency Conversion Type
133497 , p_source_94 IN VARCHAR2
133498 --Accounted Amount
133499 , p_source_95 IN NUMBER
133500 --Accounting Line Type
133501 , p_source_97 IN NUMBER
133502 --Organization Code
133503 , p_source_108 IN VARCHAR2
133504 )
133505 IS
133506
133507 l_component_type VARCHAR2(80);
133508 l_component_code VARCHAR2(30);
133509 l_component_type_code VARCHAR2(1);
133510 l_component_appl_id INTEGER;
133511 l_amb_context_code VARCHAR2(30);
133512 l_entity_code VARCHAR2(30);
133513 l_event_class_code VARCHAR2(30);
133514 l_ae_header_id NUMBER;
133515 l_event_type_code VARCHAR2(30);
133516 l_line_definition_code VARCHAR2(30);
133517 l_line_definition_owner_code VARCHAR2(1);
133518 --
133519 -- adr variables
133520 l_segment VARCHAR2(30);
133521 l_ccid NUMBER;
133522 l_adr_transaction_coa_id NUMBER;
133523 l_adr_accounting_coa_id NUMBER;
133524 l_adr_flexfield_segment_code VARCHAR2(30);
133525 l_adr_flex_value_set_id NUMBER;
133526 l_adr_value_type_code VARCHAR2(30);
133527 l_adr_value_combination_id NUMBER;
133528 l_adr_value_segment_code VARCHAR2(30);
133529
133530 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
133531 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
133532 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
133533 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
133534
133535 -- 4262811 Variables ------------------------------------------------------------------------------------------
133536 l_entered_amt_idx NUMBER;
133537 l_accted_amt_idx NUMBER;
133538 l_acc_rev_flag VARCHAR2(1);
133539 l_accrual_line_num NUMBER;
133540 l_tmp_amt NUMBER;
133541 l_acc_rev_natural_side_code VARCHAR2(1);
133542
133543 l_num_entries NUMBER;
133544 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
133545 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
133546 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
133547 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
133548 l_recog_line_1 NUMBER;
133549 l_recog_line_2 NUMBER;
133550
133551 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
133552 l_bflow_applied_to_amt NUMBER; -- 5132302
133553 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
133554
133555 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
133556
133557 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
133558 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
133559
133560 ---------------------------------------------------------------------------------------------------------------
133561
133562
133563 --
133564 -- bulk performance
133565 --
133566 l_balance_type_code VARCHAR2(1);
133567 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
133568 l_log_module VARCHAR2(240);
133569
133570 --
133571 -- Upgrade strategy
133572 --
133573 l_actual_upg_option VARCHAR2(1);
133574 l_enc_upg_option VARCHAR2(1);
133575
133576 --
133577 BEGIN
133578 --
133579 IF g_log_enabled THEN
133580 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_255';
133581 END IF;
133582 --
133583 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
133584
133585 trace
133586 (p_msg => 'BEGIN of AcctLineType_255'
133587 ,p_level => C_LEVEL_PROCEDURE
133588 ,p_module => l_log_module);
133589
133590 END IF;
133591 --
133592 l_component_type := 'AMB_JLT';
133593 l_component_code := 'INVENTORY_VALUATION';
133594 l_component_type_code := 'S';
133595 l_component_appl_id := 707;
133596 l_amb_context_code := 'DEFAULT';
133597 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
133598 l_event_class_code := 'INT_ORDER_TO_EXP';
133599 l_event_type_code := 'EXP_REQ_RCPT_TP';
133600 l_line_definition_owner_code := 'S';
133601 l_line_definition_code := 'PI_EXP_REQ_RCPT_TP';
133602 --
133603 l_balance_type_code := 'A';
133604 l_segment := NULL;
133605 l_ccid := NULL;
133606 l_adr_transaction_coa_id := NULL;
133607 l_adr_accounting_coa_id := NULL;
133608 l_adr_flexfield_segment_code := NULL;
133609 l_adr_flex_value_set_id := NULL;
133610 l_adr_value_type_code := NULL;
133611 l_adr_value_combination_id := NULL;
133612 l_adr_value_segment_code := NULL;
133613
133614 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
133615 l_bflow_class_code := ''; -- 4219869 Business Flow
133616 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
133617 l_budgetary_control_flag := 'N';
133618
133619 l_bflow_applied_to_amt_idx := NULL; -- 5132302
133620 l_bflow_applied_to_amt := NULL; -- 5132302
133621 l_entered_amt_idx := NULL; -- 4262811
133622 l_accted_amt_idx := NULL; -- 4262811
133623 l_acc_rev_flag := NULL; -- 4262811
133624 l_accrual_line_num := NULL; -- 4262811
133625 l_tmp_amt := NULL; -- 4262811
133626 --
133627
133628 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
133629 l_balance_type_code <> 'B' THEN
133630 IF NVL(p_source_97,9E125) = 1
133631 THEN
133632
133633 --
133634 XLA_AE_LINES_PKG.SetNewLine;
133635
133636 p_balance_type_code := l_balance_type_code;
133637 -- set the flag so later we will know whether the gain loss line needs to be created
133638
133639 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
133640 p_actual_flag :='A';
133641 END IF;
133642
133643 --
133644 -- bulk performance
133645 --
133646 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
133647 p_header_num => 0); -- 4262811
133648 --
133649 -- set accounting line options
133650 --
133651 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
133652 p_natural_side_code => 'D'
133653 , p_gain_or_loss_flag => 'N'
133654 , p_gl_transfer_mode_code => 'S'
133655 , p_acct_entry_type_code => 'A'
133656 , p_switch_side_flag => 'Y'
133657 , p_merge_duplicate_code => 'N'
133658 );
133659 --
133660 l_acc_rev_natural_side_code := 'C'; -- 4262811
133661 --
133662 --
133663 -- set accounting line type info
133664 --
133665 xla_ae_lines_pkg.SetAcctLineType
133666 (p_component_type => l_component_type
133667 ,p_event_type_code => l_event_type_code
133668 ,p_line_definition_owner_code => l_line_definition_owner_code
133669 ,p_line_definition_code => l_line_definition_code
133670 ,p_accounting_line_code => l_component_code
133671 ,p_accounting_line_type_code => l_component_type_code
133672 ,p_accounting_line_appl_id => l_component_appl_id
133673 ,p_amb_context_code => l_amb_context_code
133674 ,p_entity_code => l_entity_code
133675 ,p_event_class_code => l_event_class_code);
133676 --
133677 -- set accounting class
133678 --
133679 xla_ae_lines_pkg.SetAcctClass(
133680 p_accounting_class_code => 'INVENTORY_VALUATION'
133681 , p_ae_header_id => l_ae_header_id
133682 );
133683
133684 --
133685 -- set rounding class
133686 --
133687 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
133688 'INVENTORY_VALUATION';
133689
133690 --
133691 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
133692 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
133693 --
133694 -- bulk performance
133695 --
133696 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
133697
133698 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
133699 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
133700
133701 -- 4955764
133702 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
133703 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
133704
133705 -- 4458381 Public Sector Enh
133706
133707 --
133708 -- set accounting attributes for the line type
133709 --
133710 l_entered_amt_idx := 3;
133711 l_accted_amt_idx := 8;
133712 l_bflow_applied_to_amt_idx := NULL; -- 5132302
133713 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
133714 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
133715 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
133716 l_rec_acct_attrs.array_char_value(2) := p_source_85;
133717 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
133718 l_rec_acct_attrs.array_num_value(3) := p_source_91;
133719 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
133720 l_rec_acct_attrs.array_char_value(4) := p_source_88;
133721 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
133722 l_rec_acct_attrs.array_date_value(5) := p_source_92;
133723 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
133724 l_rec_acct_attrs.array_num_value(6) := p_source_93;
133725 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
133726 l_rec_acct_attrs.array_char_value(7) := p_source_94;
133727 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
133728 l_rec_acct_attrs.array_num_value(8) := p_source_95;
133729
133730 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
133731 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
133732
133733 ---------------------------------------------------------------------------------------------------------------
133734 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
133735 ---------------------------------------------------------------------------------------------------------------
133736 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
133737
133738 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
133739 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
133740
133741 IF xla_accounting_cache_pkg.GetValueChar
133742 (p_source_code => 'LEDGER_CATEGORY_CODE'
133743 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
133744 AND l_bflow_method_code = 'PRIOR_ENTRY'
133745 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
133746 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
133747 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
133748 )
133749 THEN
133750 xla_ae_lines_pkg.BflowUpgEntry
133751 (p_business_method_code => l_bflow_method_code
133752 ,p_business_class_code => l_bflow_class_code
133753 ,p_balance_type => l_balance_type_code);
133754 ELSE
133755 NULL;
133756 -- No business flow processing for business flow method of NONE.
133757 END IF;
133758
133759 --
133760 -- call analytical criteria
133761 --
133762
133763
133764 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
133765 xla_ae_lines_pkg.SetAnalyticalCriteria(
133766 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
133767 , p_analytical_criterion_owner => 'S'
133768 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
133769 , p_amb_context_code => 'DEFAULT'
133770 , p_balancing_flag => 'Y'
133771
133772 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
133773 , p_analytical_detail_num_1 => NULL
133774 , p_analytical_detail_date_1 => NULL
133775
133776 , p_ae_header_id => l_ae_header_id
133777 )
133778 ;
133779 --
133780
133781 --
133782 -- call description
133783 --
133784
133785 xla_ae_lines_pkg.SetLineDescription(
133786 p_ae_header_id => l_ae_header_id
133787 ,p_description => Description_1 (
133788 p_application_id => p_application_id
133789 , p_ae_header_id => l_ae_header_id
133790 , p_source_1 => p_source_1
133791 , p_source_2 => p_source_2
133792 , p_source_3 => p_source_3
133793 , p_source_4 => p_source_4
133794 , p_source_5 => p_source_5
133795 )
133796 );
133797
133798
133799 --
133800 -- call ADRs
133801 -- Bug 4922099
133802 --
133803 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
133804 (NVL(l_actual_upg_option, 'N') = 'O') OR
133805 (NVL(l_enc_upg_option, 'N') = 'O')
133806 )
133807 THEN
133808 NULL;
133809 --
133810 --
133811
133812 l_ccid := AcctDerRule_28(
133813 p_application_id => p_application_id
133814 , p_ae_header_id => l_ae_header_id
133815 , p_source_15 => p_source_15
133816 , p_source_41 => p_source_41
133817 , p_source_42 => p_source_42
133818 , p_source_43 => p_source_43
133819 , p_source_44 => p_source_44
133820 , p_source_45 => p_source_45
133821 , x_transaction_coa_id => l_adr_transaction_coa_id
133822 , x_accounting_coa_id => l_adr_accounting_coa_id
133823 , x_value_type_code => l_adr_value_type_code
133824 , p_side => 'NA'
133825 );
133826
133827 xla_ae_lines_pkg.set_ccid(
133828 p_code_combination_id => l_ccid
133829 , p_value_type_code => l_adr_value_type_code
133830 , p_transaction_coa_id => l_adr_transaction_coa_id
133831 , p_accounting_coa_id => l_adr_accounting_coa_id
133832 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
133833 , p_adr_type_code => 'S'
133834 , p_component_type => l_component_type
133835 , p_component_code => l_component_code
133836 , p_component_type_code => l_component_type_code
133837 , p_component_appl_id => l_component_appl_id
133838 , p_amb_context_code => l_amb_context_code
133839 , p_side => 'NA'
133840 );
133841
133842
133843 --
133844 --
133845 END IF;
133846 --
133847 -- Bug 4922099
133848 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
133849 (NVL(l_enc_upg_option, 'N') = 'O')
133850 ) AND
133851 (l_bflow_method_code = 'PRIOR_ENTRY')
133852 )
133853 THEN
133854 IF
133855 --
133856 1 = 2
133857 --
133858 THEN
133859 xla_accounting_err_pkg.build_message
133860 (p_appli_s_name => 'XLA'
133861 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
133862 ,p_token_1 => 'LINE_NUMBER'
133863 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
133864 ,p_token_2 => 'LINE_TYPE_NAME'
133865 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
133866 l_component_type
133867 ,l_component_code
133868 ,l_component_type_code
133869 ,l_component_appl_id
133870 ,l_amb_context_code
133871 ,l_entity_code
133872 ,l_event_class_code
133873 )
133874 ,p_token_3 => 'OWNER'
133875 ,p_value_3 => xla_lookups_pkg.get_meaning(
133876 p_lookup_type => 'XLA_OWNER_TYPE'
133877 ,p_lookup_code => l_component_type_code
133878 )
133879 ,p_token_4 => 'PRODUCT_NAME'
133880 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
133881 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
133882 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
133883 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
133884 ,p_ae_header_id => NULL
133885 );
133886
133887 IF (C_LEVEL_ERROR>= g_log_level) THEN
133888 trace
133889 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
133890 ,p_level => C_LEVEL_ERROR
133891 ,p_module => l_log_module);
133892 END IF;
133893 END IF;
133894 END IF;
133895 --
133896 --
133897 ------------------------------------------------------------------------------------------------
133898 -- 4219869 Business Flow
133899 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
133900 -- Prior Entry. Currently, the following code is always generated.
133901 ------------------------------------------------------------------------------------------------
133902 XLA_AE_LINES_PKG.ValidateCurrentLine;
133903
133904 ------------------------------------------------------------------------------------
133905 -- 4219869 Business Flow
133906 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
133907 ------------------------------------------------------------------------------------
133908 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
133909
133910 ----------------------------------------------------------------------------------
133911 -- 4219869 Business Flow
133912 -- Update journal entry status -- Need to generate this within IF <condition>
133913 ----------------------------------------------------------------------------------
133914 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
133915 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
133916 ,p_balance_type_code => l_balance_type_code
133917 );
133918
133919 -------------------------------------------------------------------------------------------
133920 -- 4262811 - Generate the Accrual Reversal lines
133921 -------------------------------------------------------------------------------------------
133922 BEGIN
133923 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
133924 (g_array_event(p_event_id).array_value_num('header_index'));
133925 IF l_acc_rev_flag IS NULL THEN
133926 l_acc_rev_flag := 'N';
133927 END IF;
133928 EXCEPTION
133929 WHEN OTHERS THEN
133930 l_acc_rev_flag := 'N';
133931 END;
133932 --
133933 IF (l_acc_rev_flag = 'Y') THEN
133934
133935 -- 4645092 ------------------------------------------------------------------------------
133936 -- To allow MPA report to determine if it should generate report process
133937 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
133938 ------------------------------------------------------------------------------------------
133939
133940 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
133941 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
133942 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
133943 -- call ADRs
133944 -- Bug 4922099
133945 --
133946 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
133947 (NVL(l_actual_upg_option, 'N') = 'O') OR
133948 (NVL(l_enc_upg_option, 'N') = 'O')
133949 )
133950 THEN
133951 NULL;
133952 --
133953 --
133954
133955 l_ccid := AcctDerRule_28(
133956 p_application_id => p_application_id
133957 , p_ae_header_id => l_ae_header_id
133958 , p_source_15 => p_source_15
133959 , p_source_41 => p_source_41
133960 , p_source_42 => p_source_42
133961 , p_source_43 => p_source_43
133962 , p_source_44 => p_source_44
133963 , p_source_45 => p_source_45
133964 , x_transaction_coa_id => l_adr_transaction_coa_id
133965 , x_accounting_coa_id => l_adr_accounting_coa_id
133966 , x_value_type_code => l_adr_value_type_code
133967 , p_side => 'NA'
133968 );
133969
133970 xla_ae_lines_pkg.set_ccid(
133971 p_code_combination_id => l_ccid
133972 , p_value_type_code => l_adr_value_type_code
133973 , p_transaction_coa_id => l_adr_transaction_coa_id
133974 , p_accounting_coa_id => l_adr_accounting_coa_id
133975 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
133976 , p_adr_type_code => 'S'
133977 , p_component_type => l_component_type
133978 , p_component_code => l_component_code
133979 , p_component_type_code => l_component_type_code
133980 , p_component_appl_id => l_component_appl_id
133981 , p_amb_context_code => l_amb_context_code
133982 , p_side => 'NA'
133983 );
133984
133985
133986 --
133987 --
133988 END IF;
133989
133990 --
133991 -- Update the line information that should be overwritten
133992 --
133993 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
133994 p_header_num => 1);
133995 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
133996
133997 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
133998
133999 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
134000 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
134001 END IF;
134002
134003 --
134004 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
134005 --
134006 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
134007 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
134008 ELSE
134009 ---------------------------------------------------------------------------------------------------
134010 -- 4262811a Switch Sign
134011 ---------------------------------------------------------------------------------------------------
134012 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
134013 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
134014 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134015 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
134016 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134017 -- 5132302
134018 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
134019 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134020
134021 END IF;
134022
134023 -- 4955764
134024 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
134025 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
134026
134027
134028 XLA_AE_LINES_PKG.ValidateCurrentLine;
134029 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
134030
134031 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
134032 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
134033 ,p_balance_type_code => l_balance_type_code);
134034
134035 END IF;
134036
134037 -----------------------------------------------------------------------------------------
134038 -- 4262811 Multiperiod Accounting
134039 -----------------------------------------------------------------------------------------
134040 -- No MPA option is assigned.
134041
134042
134043 END IF;
134044 END IF;
134045 --
134046
134047 --
134048 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
134049 trace
134050 (p_msg => 'END of AcctLineType_255'
134051 ,p_level => C_LEVEL_PROCEDURE
134052 ,p_module => l_log_module);
134053 END IF;
134054 --
134055 EXCEPTION
134056 WHEN xla_exceptions_pkg.application_exception THEN
134057 RAISE;
134058 WHEN OTHERS THEN
134059 xla_exceptions_pkg.raise_message
134060 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_255');
134061 END AcctLineType_255;
134062 --
134063
134064 ---------------------------------------
134065 --
134066 -- PRIVATE FUNCTION
134067 -- AcctLineType_256
134068 --
134069 ---------------------------------------
134070 PROCEDURE AcctLineType_256 (
134071 p_application_id IN NUMBER
134072 ,p_event_id IN NUMBER
134073 ,p_calculate_acctd_flag IN VARCHAR2
134074 ,p_calculate_g_l_flag IN VARCHAR2
134075 ,p_actual_flag IN OUT VARCHAR2
134076 ,p_balance_type_code OUT VARCHAR2
134077 ,p_gain_or_loss_ref OUT VARCHAR2
134078
134079 --TRANSACTION_ID
134080 , p_source_1 IN NUMBER
134081 --Item Concatenated Segments
134082 , p_source_2 IN VARCHAR2
134083 --Transaction Quantity
134084 , p_source_3 IN NUMBER
134085 --Transaction Unit of Measure Code
134086 , p_source_4 IN VARCHAR2
134087 --Inventory Transaction Type Description
134088 , p_source_5 IN VARCHAR2
134089 --Cost Element Name
134090 , p_source_15 IN NUMBER
134091 --Product Line Accounting Category Material Account
134092 , p_source_41 IN NUMBER
134093 --Product Line Accounting Category Material Overhead Account
134094 , p_source_42 IN NUMBER
134095 --Product Line Accounting Category Resource Account
134096 , p_source_43 IN NUMBER
134097 --Product Line Accounting Category Outside Processing Account
134098 , p_source_44 IN NUMBER
134099 --Product Line Accounting Category Overhead Account
134100 , p_source_45 IN NUMBER
134101 --Applied to Application ID
134102 , p_source_79 IN NUMBER
134103 --Applied to Distribution Link Type
134104 , p_source_80 IN VARCHAR2
134105 --Applied to Entity Code
134106 , p_source_81 IN VARCHAR2
134107 --Applied To Purchase Document Identifier
134108 , p_source_83 IN NUMBER
134109 --DISTRIBUTION_IDENTIFIER
134110 , p_source_84 IN NUMBER
134111 --Distribution Type
134112 , p_source_85 IN VARCHAR2
134113 , p_source_85_meaning IN VARCHAR2
134114 --PO Budget Account
134115 , p_source_86 IN NUMBER
134116 --Encumbrance Reversal Amount Entered
134117 , p_source_87 IN NUMBER
134118 --Entered Currency Code
134119 , p_source_88 IN VARCHAR2
134120 --Transaction Encumbrance Reversal Amount
134121 , p_source_89 IN NUMBER
134122 --Entered Amount
134123 , p_source_91 IN NUMBER
134124 --Currency Conversion Date
134125 , p_source_92 IN DATE
134126 --Currency Conversion Rate
134127 , p_source_93 IN NUMBER
134128 --Currency Conversion Type
134129 , p_source_94 IN VARCHAR2
134130 --Accounted Amount
134131 , p_source_95 IN NUMBER
134132 --Purchasing Encumbrance Type Identifier
134133 , p_source_96 IN NUMBER
134134 --Accounting Line Type
134135 , p_source_97 IN NUMBER
134136 --Costing Encumbrance Upgrade Option
134137 , p_source_100 IN VARCHAR2
134138 --TXN_PO_DISTRIBUTION_ID
134139 , p_source_101 IN NUMBER
134140 --Organization Code
134141 , p_source_108 IN VARCHAR2
134142 )
134143 IS
134144
134145 l_component_type VARCHAR2(80);
134146 l_component_code VARCHAR2(30);
134147 l_component_type_code VARCHAR2(1);
134148 l_component_appl_id INTEGER;
134149 l_amb_context_code VARCHAR2(30);
134150 l_entity_code VARCHAR2(30);
134151 l_event_class_code VARCHAR2(30);
134152 l_ae_header_id NUMBER;
134153 l_event_type_code VARCHAR2(30);
134154 l_line_definition_code VARCHAR2(30);
134155 l_line_definition_owner_code VARCHAR2(1);
134156 --
134157 -- adr variables
134158 l_segment VARCHAR2(30);
134159 l_ccid NUMBER;
134160 l_adr_transaction_coa_id NUMBER;
134161 l_adr_accounting_coa_id NUMBER;
134162 l_adr_flexfield_segment_code VARCHAR2(30);
134163 l_adr_flex_value_set_id NUMBER;
134164 l_adr_value_type_code VARCHAR2(30);
134165 l_adr_value_combination_id NUMBER;
134166 l_adr_value_segment_code VARCHAR2(30);
134167
134168 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
134169 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
134170 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
134171 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
134172
134173 -- 4262811 Variables ------------------------------------------------------------------------------------------
134174 l_entered_amt_idx NUMBER;
134175 l_accted_amt_idx NUMBER;
134176 l_acc_rev_flag VARCHAR2(1);
134177 l_accrual_line_num NUMBER;
134178 l_tmp_amt NUMBER;
134179 l_acc_rev_natural_side_code VARCHAR2(1);
134180
134181 l_num_entries NUMBER;
134182 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
134183 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
134184 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
134185 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
134186 l_recog_line_1 NUMBER;
134187 l_recog_line_2 NUMBER;
134188
134189 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
134190 l_bflow_applied_to_amt NUMBER; -- 5132302
134191 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
134192
134193 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
134194
134195 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
134196 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
134197
134198 ---------------------------------------------------------------------------------------------------------------
134199
134200
134201 --
134202 -- bulk performance
134203 --
134204 l_balance_type_code VARCHAR2(1);
134205 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
134206 l_log_module VARCHAR2(240);
134207
134208 --
134209 -- Upgrade strategy
134210 --
134211 l_actual_upg_option VARCHAR2(1);
134212 l_enc_upg_option VARCHAR2(1);
134213
134214 --
134215 BEGIN
134216 --
134217 IF g_log_enabled THEN
134218 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_256';
134219 END IF;
134220 --
134221 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
134222
134223 trace
134224 (p_msg => 'BEGIN of AcctLineType_256'
134225 ,p_level => C_LEVEL_PROCEDURE
134226 ,p_module => l_log_module);
134227
134228 END IF;
134229 --
134230 l_component_type := 'AMB_JLT';
134231 l_component_code := 'INVENTORY_VALUATION';
134232 l_component_type_code := 'S';
134233 l_component_appl_id := 707;
134234 l_amb_context_code := 'DEFAULT';
134235 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
134236 l_event_class_code := 'PURCHASE_ORDER';
134237 l_event_type_code := 'LOG_PO_DEL_INV';
134238 l_line_definition_owner_code := 'S';
134239 l_line_definition_code := 'PI_LOG_DEL_INV';
134240 --
134241 l_balance_type_code := 'A';
134242 l_segment := NULL;
134243 l_ccid := NULL;
134244 l_adr_transaction_coa_id := NULL;
134245 l_adr_accounting_coa_id := NULL;
134246 l_adr_flexfield_segment_code := NULL;
134247 l_adr_flex_value_set_id := NULL;
134248 l_adr_value_type_code := NULL;
134249 l_adr_value_combination_id := NULL;
134250 l_adr_value_segment_code := NULL;
134251
134252 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
134253 l_bflow_class_code := ''; -- 4219869 Business Flow
134254 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
134255 l_budgetary_control_flag := 'N';
134256
134257 l_bflow_applied_to_amt_idx := NULL; -- 5132302
134258 l_bflow_applied_to_amt := NULL; -- 5132302
134259 l_entered_amt_idx := NULL; -- 4262811
134260 l_accted_amt_idx := NULL; -- 4262811
134261 l_acc_rev_flag := NULL; -- 4262811
134262 l_accrual_line_num := NULL; -- 4262811
134263 l_tmp_amt := NULL; -- 4262811
134264 --
134265
134266 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
134267 l_balance_type_code <> 'B' THEN
134268 IF NVL(p_source_97,9E125) = 1
134269 THEN
134270
134271 --
134272 XLA_AE_LINES_PKG.SetNewLine;
134273
134274 p_balance_type_code := l_balance_type_code;
134275 -- set the flag so later we will know whether the gain loss line needs to be created
134276
134277 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
134278 p_actual_flag :='A';
134279 END IF;
134280
134281 --
134282 -- bulk performance
134283 --
134284 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
134285 p_header_num => 0); -- 4262811
134286 --
134287 -- set accounting line options
134288 --
134289 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
134290 p_natural_side_code => 'D'
134291 , p_gain_or_loss_flag => 'N'
134292 , p_gl_transfer_mode_code => 'S'
134293 , p_acct_entry_type_code => 'A'
134294 , p_switch_side_flag => 'Y'
134295 , p_merge_duplicate_code => 'N'
134296 );
134297 --
134298 l_acc_rev_natural_side_code := 'C'; -- 4262811
134299 --
134300 --
134301 -- set accounting line type info
134302 --
134303 xla_ae_lines_pkg.SetAcctLineType
134304 (p_component_type => l_component_type
134305 ,p_event_type_code => l_event_type_code
134306 ,p_line_definition_owner_code => l_line_definition_owner_code
134307 ,p_line_definition_code => l_line_definition_code
134308 ,p_accounting_line_code => l_component_code
134309 ,p_accounting_line_type_code => l_component_type_code
134310 ,p_accounting_line_appl_id => l_component_appl_id
134311 ,p_amb_context_code => l_amb_context_code
134312 ,p_entity_code => l_entity_code
134313 ,p_event_class_code => l_event_class_code);
134314 --
134315 -- set accounting class
134316 --
134317 xla_ae_lines_pkg.SetAcctClass(
134318 p_accounting_class_code => 'INVENTORY_VALUATION'
134319 , p_ae_header_id => l_ae_header_id
134320 );
134321
134322 --
134323 -- set rounding class
134324 --
134325 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
134326 'INVENTORY_VALUATION';
134327
134328 --
134329 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
134330 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
134331 --
134332 -- bulk performance
134333 --
134334 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
134335
134336 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
134337 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
134338
134339 -- 4955764
134340 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
134341 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
134342
134343 -- 4458381 Public Sector Enh
134344
134345 --
134346 -- set accounting attributes for the line type
134347 --
134348 l_entered_amt_idx := 17;
134349 l_accted_amt_idx := 22;
134350 l_bflow_applied_to_amt_idx := NULL; -- 5132302
134351 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
134352 l_rec_acct_attrs.array_num_value(1) := p_source_79;
134353 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
134354 l_rec_acct_attrs.array_char_value(2) := p_source_80;
134355 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
134356 l_rec_acct_attrs.array_char_value(3) := p_source_81;
134357 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
134358 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
134359 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
134360 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
134361 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
134362 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
134363 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
134364 l_rec_acct_attrs.array_char_value(7) := p_source_85;
134365 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
134366 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
134367 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
134368 l_rec_acct_attrs.array_num_value(9) := p_source_87;
134369 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
134370 l_rec_acct_attrs.array_char_value(10) := p_source_88;
134371 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
134372 l_rec_acct_attrs.array_num_value(11) := p_source_89;
134373 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
134374 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
134375 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
134376 l_rec_acct_attrs.array_num_value(13) := p_source_87;
134377 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
134378 l_rec_acct_attrs.array_char_value(14) := p_source_88;
134379 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
134380 l_rec_acct_attrs.array_num_value(15) := p_source_89;
134381 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
134382 l_rec_acct_attrs.array_char_value(16) := p_source_100;
134383 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
134384 l_rec_acct_attrs.array_num_value(17) := p_source_91;
134385 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
134386 l_rec_acct_attrs.array_char_value(18) := p_source_88;
134387 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
134388 l_rec_acct_attrs.array_date_value(19) := p_source_92;
134389 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
134390 l_rec_acct_attrs.array_num_value(20) := p_source_93;
134391 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
134392 l_rec_acct_attrs.array_char_value(21) := p_source_94;
134393 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
134394 l_rec_acct_attrs.array_num_value(22) := p_source_95;
134395 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
134396 l_rec_acct_attrs.array_num_value(23) := p_source_96;
134397 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
134398 l_rec_acct_attrs.array_num_value(24) := p_source_96;
134399
134400 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
134401 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
134402
134403 ---------------------------------------------------------------------------------------------------------------
134404 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
134405 ---------------------------------------------------------------------------------------------------------------
134406 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
134407
134408 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
134409 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
134410
134411 IF xla_accounting_cache_pkg.GetValueChar
134412 (p_source_code => 'LEDGER_CATEGORY_CODE'
134413 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
134414 AND l_bflow_method_code = 'PRIOR_ENTRY'
134415 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
134416 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
134417 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
134418 )
134419 THEN
134420 xla_ae_lines_pkg.BflowUpgEntry
134421 (p_business_method_code => l_bflow_method_code
134422 ,p_business_class_code => l_bflow_class_code
134423 ,p_balance_type => l_balance_type_code);
134424 ELSE
134425 NULL;
134426 -- No business flow processing for business flow method of NONE.
134427 END IF;
134428
134429 --
134430 -- call analytical criteria
134431 --
134432
134433
134434 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
134435 xla_ae_lines_pkg.SetAnalyticalCriteria(
134436 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
134437 , p_analytical_criterion_owner => 'S'
134438 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
134439 , p_amb_context_code => 'DEFAULT'
134440 , p_balancing_flag => 'Y'
134441
134442 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
134443 , p_analytical_detail_num_1 => NULL
134444 , p_analytical_detail_date_1 => NULL
134445
134446 , p_ae_header_id => l_ae_header_id
134447 )
134448 ;
134449 --
134450
134451 --
134452 -- call description
134453 --
134454
134455 xla_ae_lines_pkg.SetLineDescription(
134456 p_ae_header_id => l_ae_header_id
134457 ,p_description => Description_1 (
134458 p_application_id => p_application_id
134459 , p_ae_header_id => l_ae_header_id
134460 , p_source_1 => p_source_1
134461 , p_source_2 => p_source_2
134462 , p_source_3 => p_source_3
134463 , p_source_4 => p_source_4
134464 , p_source_5 => p_source_5
134465 )
134466 );
134467
134468
134469 --
134470 -- call ADRs
134471 -- Bug 4922099
134472 --
134473 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
134474 (NVL(l_actual_upg_option, 'N') = 'O') OR
134475 (NVL(l_enc_upg_option, 'N') = 'O')
134476 )
134477 THEN
134478 NULL;
134479 --
134480 --
134481
134482 l_ccid := AcctDerRule_28(
134483 p_application_id => p_application_id
134484 , p_ae_header_id => l_ae_header_id
134485 , p_source_15 => p_source_15
134486 , p_source_41 => p_source_41
134487 , p_source_42 => p_source_42
134488 , p_source_43 => p_source_43
134489 , p_source_44 => p_source_44
134490 , p_source_45 => p_source_45
134491 , x_transaction_coa_id => l_adr_transaction_coa_id
134492 , x_accounting_coa_id => l_adr_accounting_coa_id
134493 , x_value_type_code => l_adr_value_type_code
134494 , p_side => 'NA'
134495 );
134496
134497 xla_ae_lines_pkg.set_ccid(
134498 p_code_combination_id => l_ccid
134499 , p_value_type_code => l_adr_value_type_code
134500 , p_transaction_coa_id => l_adr_transaction_coa_id
134501 , p_accounting_coa_id => l_adr_accounting_coa_id
134502 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
134503 , p_adr_type_code => 'S'
134504 , p_component_type => l_component_type
134505 , p_component_code => l_component_code
134506 , p_component_type_code => l_component_type_code
134507 , p_component_appl_id => l_component_appl_id
134508 , p_amb_context_code => l_amb_context_code
134509 , p_side => 'NA'
134510 );
134511
134512
134513 --
134514 --
134515 END IF;
134516 --
134517 -- Bug 4922099
134518 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
134519 (NVL(l_enc_upg_option, 'N') = 'O')
134520 ) AND
134521 (l_bflow_method_code = 'PRIOR_ENTRY')
134522 )
134523 THEN
134524 IF
134525 --
134526 1 = 2
134527 --
134528 THEN
134529 xla_accounting_err_pkg.build_message
134530 (p_appli_s_name => 'XLA'
134531 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
134532 ,p_token_1 => 'LINE_NUMBER'
134533 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
134534 ,p_token_2 => 'LINE_TYPE_NAME'
134535 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
134536 l_component_type
134537 ,l_component_code
134538 ,l_component_type_code
134539 ,l_component_appl_id
134540 ,l_amb_context_code
134541 ,l_entity_code
134542 ,l_event_class_code
134543 )
134544 ,p_token_3 => 'OWNER'
134545 ,p_value_3 => xla_lookups_pkg.get_meaning(
134546 p_lookup_type => 'XLA_OWNER_TYPE'
134547 ,p_lookup_code => l_component_type_code
134548 )
134549 ,p_token_4 => 'PRODUCT_NAME'
134550 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
134551 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
134552 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
134553 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
134554 ,p_ae_header_id => NULL
134555 );
134556
134557 IF (C_LEVEL_ERROR>= g_log_level) THEN
134558 trace
134559 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
134560 ,p_level => C_LEVEL_ERROR
134561 ,p_module => l_log_module);
134562 END IF;
134563 END IF;
134564 END IF;
134565 --
134566 --
134567 ------------------------------------------------------------------------------------------------
134568 -- 4219869 Business Flow
134569 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
134570 -- Prior Entry. Currently, the following code is always generated.
134571 ------------------------------------------------------------------------------------------------
134572 XLA_AE_LINES_PKG.ValidateCurrentLine;
134573
134574 ------------------------------------------------------------------------------------
134575 -- 4219869 Business Flow
134576 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
134577 ------------------------------------------------------------------------------------
134578 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
134579
134580 ----------------------------------------------------------------------------------
134581 -- 4219869 Business Flow
134582 -- Update journal entry status -- Need to generate this within IF <condition>
134583 ----------------------------------------------------------------------------------
134584 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
134585 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
134586 ,p_balance_type_code => l_balance_type_code
134587 );
134588
134589 -------------------------------------------------------------------------------------------
134590 -- 4262811 - Generate the Accrual Reversal lines
134591 -------------------------------------------------------------------------------------------
134592 BEGIN
134593 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
134594 (g_array_event(p_event_id).array_value_num('header_index'));
134595 IF l_acc_rev_flag IS NULL THEN
134596 l_acc_rev_flag := 'N';
134597 END IF;
134598 EXCEPTION
134599 WHEN OTHERS THEN
134600 l_acc_rev_flag := 'N';
134601 END;
134602 --
134603 IF (l_acc_rev_flag = 'Y') THEN
134604
134605 -- 4645092 ------------------------------------------------------------------------------
134606 -- To allow MPA report to determine if it should generate report process
134607 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
134608 ------------------------------------------------------------------------------------------
134609
134610 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
134611 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
134612 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
134613 -- call ADRs
134614 -- Bug 4922099
134615 --
134616 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
134617 (NVL(l_actual_upg_option, 'N') = 'O') OR
134618 (NVL(l_enc_upg_option, 'N') = 'O')
134619 )
134620 THEN
134621 NULL;
134622 --
134623 --
134624
134625 l_ccid := AcctDerRule_28(
134626 p_application_id => p_application_id
134627 , p_ae_header_id => l_ae_header_id
134628 , p_source_15 => p_source_15
134629 , p_source_41 => p_source_41
134630 , p_source_42 => p_source_42
134631 , p_source_43 => p_source_43
134632 , p_source_44 => p_source_44
134633 , p_source_45 => p_source_45
134634 , x_transaction_coa_id => l_adr_transaction_coa_id
134635 , x_accounting_coa_id => l_adr_accounting_coa_id
134636 , x_value_type_code => l_adr_value_type_code
134637 , p_side => 'NA'
134638 );
134639
134640 xla_ae_lines_pkg.set_ccid(
134641 p_code_combination_id => l_ccid
134642 , p_value_type_code => l_adr_value_type_code
134643 , p_transaction_coa_id => l_adr_transaction_coa_id
134644 , p_accounting_coa_id => l_adr_accounting_coa_id
134645 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
134646 , p_adr_type_code => 'S'
134647 , p_component_type => l_component_type
134648 , p_component_code => l_component_code
134649 , p_component_type_code => l_component_type_code
134650 , p_component_appl_id => l_component_appl_id
134651 , p_amb_context_code => l_amb_context_code
134652 , p_side => 'NA'
134653 );
134654
134655
134656 --
134657 --
134658 END IF;
134659
134660 --
134661 -- Update the line information that should be overwritten
134662 --
134663 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
134664 p_header_num => 1);
134665 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
134666
134667 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
134668
134669 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
134670 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
134671 END IF;
134672
134673 --
134674 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
134675 --
134676 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
134677 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
134678 ELSE
134679 ---------------------------------------------------------------------------------------------------
134680 -- 4262811a Switch Sign
134681 ---------------------------------------------------------------------------------------------------
134682 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
134683 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
134684 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134685 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
134686 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134687 -- 5132302
134688 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
134689 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
134690
134691 END IF;
134692
134693 -- 4955764
134694 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
134695 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
134696
134697
134698 XLA_AE_LINES_PKG.ValidateCurrentLine;
134699 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
134700
134701 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
134702 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
134703 ,p_balance_type_code => l_balance_type_code);
134704
134705 END IF;
134706
134707 -----------------------------------------------------------------------------------------
134708 -- 4262811 Multiperiod Accounting
134709 -----------------------------------------------------------------------------------------
134710 -- No MPA option is assigned.
134711
134712
134713 END IF;
134714 END IF;
134715 --
134716
134717 --
134718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
134719 trace
134720 (p_msg => 'END of AcctLineType_256'
134721 ,p_level => C_LEVEL_PROCEDURE
134722 ,p_module => l_log_module);
134723 END IF;
134724 --
134725 EXCEPTION
134726 WHEN xla_exceptions_pkg.application_exception THEN
134727 RAISE;
134728 WHEN OTHERS THEN
134729 xla_exceptions_pkg.raise_message
134730 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_256');
134731 END AcctLineType_256;
134732 --
134733
134734 ---------------------------------------
134735 --
134736 -- PRIVATE FUNCTION
134737 -- AcctLineType_257
134738 --
134739 ---------------------------------------
134740 PROCEDURE AcctLineType_257 (
134741 p_application_id IN NUMBER
134742 ,p_event_id IN NUMBER
134743 ,p_calculate_acctd_flag IN VARCHAR2
134744 ,p_calculate_g_l_flag IN VARCHAR2
134745 ,p_actual_flag IN OUT VARCHAR2
134746 ,p_balance_type_code OUT VARCHAR2
134747 ,p_gain_or_loss_ref OUT VARCHAR2
134748
134749 --TRANSACTION_ID
134750 , p_source_1 IN NUMBER
134751 --Item Concatenated Segments
134752 , p_source_2 IN VARCHAR2
134753 --Transaction Quantity
134754 , p_source_3 IN NUMBER
134755 --Transaction Unit of Measure Code
134756 , p_source_4 IN VARCHAR2
134757 --Inventory Transaction Type Description
134758 , p_source_5 IN VARCHAR2
134759 --Cost Element Name
134760 , p_source_15 IN NUMBER
134761 --Product Line Accounting Category Material Account
134762 , p_source_41 IN NUMBER
134763 --Product Line Accounting Category Material Overhead Account
134764 , p_source_42 IN NUMBER
134765 --Product Line Accounting Category Resource Account
134766 , p_source_43 IN NUMBER
134767 --Product Line Accounting Category Outside Processing Account
134768 , p_source_44 IN NUMBER
134769 --Product Line Accounting Category Overhead Account
134770 , p_source_45 IN NUMBER
134771 --DISTRIBUTION_IDENTIFIER
134772 , p_source_84 IN NUMBER
134773 --Distribution Type
134774 , p_source_85 IN VARCHAR2
134775 , p_source_85_meaning IN VARCHAR2
134776 --Entered Currency Code
134777 , p_source_88 IN VARCHAR2
134778 --Entered Amount
134779 , p_source_91 IN NUMBER
134780 --Currency Conversion Date
134781 , p_source_92 IN DATE
134782 --Currency Conversion Rate
134783 , p_source_93 IN NUMBER
134784 --Currency Conversion Type
134785 , p_source_94 IN VARCHAR2
134786 --Accounted Amount
134787 , p_source_95 IN NUMBER
134788 --Accounting Line Type
134789 , p_source_97 IN NUMBER
134790 --Organization Code
134791 , p_source_108 IN VARCHAR2
134792 )
134793 IS
134794
134795 l_component_type VARCHAR2(80);
134796 l_component_code VARCHAR2(30);
134797 l_component_type_code VARCHAR2(1);
134798 l_component_appl_id INTEGER;
134799 l_amb_context_code VARCHAR2(30);
134800 l_entity_code VARCHAR2(30);
134801 l_event_class_code VARCHAR2(30);
134802 l_ae_header_id NUMBER;
134803 l_event_type_code VARCHAR2(30);
134804 l_line_definition_code VARCHAR2(30);
134805 l_line_definition_owner_code VARCHAR2(1);
134806 --
134807 -- adr variables
134808 l_segment VARCHAR2(30);
134809 l_ccid NUMBER;
134810 l_adr_transaction_coa_id NUMBER;
134811 l_adr_accounting_coa_id NUMBER;
134812 l_adr_flexfield_segment_code VARCHAR2(30);
134813 l_adr_flex_value_set_id NUMBER;
134814 l_adr_value_type_code VARCHAR2(30);
134815 l_adr_value_combination_id NUMBER;
134816 l_adr_value_segment_code VARCHAR2(30);
134817
134818 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
134819 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
134820 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
134821 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
134822
134823 -- 4262811 Variables ------------------------------------------------------------------------------------------
134824 l_entered_amt_idx NUMBER;
134825 l_accted_amt_idx NUMBER;
134826 l_acc_rev_flag VARCHAR2(1);
134827 l_accrual_line_num NUMBER;
134828 l_tmp_amt NUMBER;
134829 l_acc_rev_natural_side_code VARCHAR2(1);
134830
134831 l_num_entries NUMBER;
134832 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
134833 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
134834 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
134835 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
134836 l_recog_line_1 NUMBER;
134837 l_recog_line_2 NUMBER;
134838
134839 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
134840 l_bflow_applied_to_amt NUMBER; -- 5132302
134841 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
134842
134843 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
134844
134845 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
134846 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
134847
134848 ---------------------------------------------------------------------------------------------------------------
134849
134850
134851 --
134852 -- bulk performance
134853 --
134854 l_balance_type_code VARCHAR2(1);
134855 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
134856 l_log_module VARCHAR2(240);
134857
134858 --
134859 -- Upgrade strategy
134860 --
134861 l_actual_upg_option VARCHAR2(1);
134862 l_enc_upg_option VARCHAR2(1);
134863
134864 --
134865 BEGIN
134866 --
134867 IF g_log_enabled THEN
134868 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_257';
134869 END IF;
134870 --
134871 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
134872
134873 trace
134874 (p_msg => 'BEGIN of AcctLineType_257'
134875 ,p_level => C_LEVEL_PROCEDURE
134876 ,p_module => l_log_module);
134877
134878 END IF;
134879 --
134880 l_component_type := 'AMB_JLT';
134881 l_component_code := 'INVENTORY_VALUATION';
134882 l_component_type_code := 'S';
134883 l_component_appl_id := 707;
134884 l_amb_context_code := 'DEFAULT';
134885 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
134886 l_event_class_code := 'SALES_ORDER';
134887 l_event_type_code := 'LOG_SO_ISSUE';
134888 l_line_definition_owner_code := 'S';
134889 l_line_definition_code := 'PI_LOG_SO_ISSUE';
134890 --
134891 l_balance_type_code := 'A';
134892 l_segment := NULL;
134893 l_ccid := NULL;
134894 l_adr_transaction_coa_id := NULL;
134895 l_adr_accounting_coa_id := NULL;
134896 l_adr_flexfield_segment_code := NULL;
134897 l_adr_flex_value_set_id := NULL;
134898 l_adr_value_type_code := NULL;
134899 l_adr_value_combination_id := NULL;
134900 l_adr_value_segment_code := NULL;
134901
134902 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
134903 l_bflow_class_code := ''; -- 4219869 Business Flow
134904 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
134905 l_budgetary_control_flag := 'N';
134906
134907 l_bflow_applied_to_amt_idx := NULL; -- 5132302
134908 l_bflow_applied_to_amt := NULL; -- 5132302
134909 l_entered_amt_idx := NULL; -- 4262811
134910 l_accted_amt_idx := NULL; -- 4262811
134911 l_acc_rev_flag := NULL; -- 4262811
134912 l_accrual_line_num := NULL; -- 4262811
134913 l_tmp_amt := NULL; -- 4262811
134914 --
134915
134916 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
134917 l_balance_type_code <> 'B' THEN
134918 IF NVL(p_source_97,9E125) = 1
134919 THEN
134920
134921 --
134922 XLA_AE_LINES_PKG.SetNewLine;
134923
134924 p_balance_type_code := l_balance_type_code;
134925 -- set the flag so later we will know whether the gain loss line needs to be created
134926
134927 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
134928 p_actual_flag :='A';
134929 END IF;
134930
134931 --
134932 -- bulk performance
134933 --
134934 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
134935 p_header_num => 0); -- 4262811
134936 --
134937 -- set accounting line options
134938 --
134939 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
134940 p_natural_side_code => 'D'
134941 , p_gain_or_loss_flag => 'N'
134942 , p_gl_transfer_mode_code => 'S'
134943 , p_acct_entry_type_code => 'A'
134944 , p_switch_side_flag => 'Y'
134945 , p_merge_duplicate_code => 'N'
134946 );
134947 --
134948 l_acc_rev_natural_side_code := 'C'; -- 4262811
134949 --
134950 --
134951 -- set accounting line type info
134952 --
134953 xla_ae_lines_pkg.SetAcctLineType
134954 (p_component_type => l_component_type
134955 ,p_event_type_code => l_event_type_code
134956 ,p_line_definition_owner_code => l_line_definition_owner_code
134957 ,p_line_definition_code => l_line_definition_code
134958 ,p_accounting_line_code => l_component_code
134959 ,p_accounting_line_type_code => l_component_type_code
134960 ,p_accounting_line_appl_id => l_component_appl_id
134961 ,p_amb_context_code => l_amb_context_code
134962 ,p_entity_code => l_entity_code
134963 ,p_event_class_code => l_event_class_code);
134964 --
134965 -- set accounting class
134966 --
134967 xla_ae_lines_pkg.SetAcctClass(
134968 p_accounting_class_code => 'INVENTORY_VALUATION'
134969 , p_ae_header_id => l_ae_header_id
134970 );
134971
134972 --
134973 -- set rounding class
134974 --
134975 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
134976 'INVENTORY_VALUATION';
134977
134978 --
134979 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
134980 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
134981 --
134982 -- bulk performance
134983 --
134984 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
134985
134986 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
134987 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
134988
134989 -- 4955764
134990 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
134991 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
134992
134993 -- 4458381 Public Sector Enh
134994
134995 --
134996 -- set accounting attributes for the line type
134997 --
134998 l_entered_amt_idx := 3;
134999 l_accted_amt_idx := 8;
135000 l_bflow_applied_to_amt_idx := NULL; -- 5132302
135001 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
135002 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
135003 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
135004 l_rec_acct_attrs.array_char_value(2) := p_source_85;
135005 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
135006 l_rec_acct_attrs.array_num_value(3) := p_source_91;
135007 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
135008 l_rec_acct_attrs.array_char_value(4) := p_source_88;
135009 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
135010 l_rec_acct_attrs.array_date_value(5) := p_source_92;
135011 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
135012 l_rec_acct_attrs.array_num_value(6) := p_source_93;
135013 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
135014 l_rec_acct_attrs.array_char_value(7) := p_source_94;
135015 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
135016 l_rec_acct_attrs.array_num_value(8) := p_source_95;
135017
135018 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
135019 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
135020
135021 ---------------------------------------------------------------------------------------------------------------
135022 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
135023 ---------------------------------------------------------------------------------------------------------------
135024 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
135025
135026 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
135027 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
135028
135029 IF xla_accounting_cache_pkg.GetValueChar
135030 (p_source_code => 'LEDGER_CATEGORY_CODE'
135031 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
135032 AND l_bflow_method_code = 'PRIOR_ENTRY'
135033 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
135034 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
135035 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
135036 )
135037 THEN
135038 xla_ae_lines_pkg.BflowUpgEntry
135039 (p_business_method_code => l_bflow_method_code
135040 ,p_business_class_code => l_bflow_class_code
135041 ,p_balance_type => l_balance_type_code);
135042 ELSE
135043 NULL;
135044 -- No business flow processing for business flow method of NONE.
135045 END IF;
135046
135047 --
135048 -- call analytical criteria
135049 --
135050
135051
135052 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
135053 xla_ae_lines_pkg.SetAnalyticalCriteria(
135054 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
135055 , p_analytical_criterion_owner => 'S'
135056 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
135057 , p_amb_context_code => 'DEFAULT'
135058 , p_balancing_flag => 'Y'
135059
135060 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
135061 , p_analytical_detail_num_1 => NULL
135062 , p_analytical_detail_date_1 => NULL
135063
135064 , p_ae_header_id => l_ae_header_id
135065 )
135066 ;
135067 --
135068
135069 --
135070 -- call description
135071 --
135072
135073 xla_ae_lines_pkg.SetLineDescription(
135074 p_ae_header_id => l_ae_header_id
135075 ,p_description => Description_1 (
135076 p_application_id => p_application_id
135077 , p_ae_header_id => l_ae_header_id
135078 , p_source_1 => p_source_1
135079 , p_source_2 => p_source_2
135080 , p_source_3 => p_source_3
135081 , p_source_4 => p_source_4
135082 , p_source_5 => p_source_5
135083 )
135084 );
135085
135086
135087 --
135088 -- call ADRs
135089 -- Bug 4922099
135090 --
135091 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
135092 (NVL(l_actual_upg_option, 'N') = 'O') OR
135093 (NVL(l_enc_upg_option, 'N') = 'O')
135094 )
135095 THEN
135096 NULL;
135097 --
135098 --
135099
135100 l_ccid := AcctDerRule_28(
135101 p_application_id => p_application_id
135102 , p_ae_header_id => l_ae_header_id
135103 , p_source_15 => p_source_15
135104 , p_source_41 => p_source_41
135105 , p_source_42 => p_source_42
135106 , p_source_43 => p_source_43
135107 , p_source_44 => p_source_44
135108 , p_source_45 => p_source_45
135109 , x_transaction_coa_id => l_adr_transaction_coa_id
135110 , x_accounting_coa_id => l_adr_accounting_coa_id
135111 , x_value_type_code => l_adr_value_type_code
135112 , p_side => 'NA'
135113 );
135114
135115 xla_ae_lines_pkg.set_ccid(
135116 p_code_combination_id => l_ccid
135117 , p_value_type_code => l_adr_value_type_code
135118 , p_transaction_coa_id => l_adr_transaction_coa_id
135119 , p_accounting_coa_id => l_adr_accounting_coa_id
135120 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
135121 , p_adr_type_code => 'S'
135122 , p_component_type => l_component_type
135123 , p_component_code => l_component_code
135124 , p_component_type_code => l_component_type_code
135125 , p_component_appl_id => l_component_appl_id
135126 , p_amb_context_code => l_amb_context_code
135127 , p_side => 'NA'
135128 );
135129
135130
135131 --
135132 --
135133 END IF;
135134 --
135135 -- Bug 4922099
135136 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
135137 (NVL(l_enc_upg_option, 'N') = 'O')
135138 ) AND
135139 (l_bflow_method_code = 'PRIOR_ENTRY')
135140 )
135141 THEN
135142 IF
135143 --
135144 1 = 2
135145 --
135146 THEN
135147 xla_accounting_err_pkg.build_message
135148 (p_appli_s_name => 'XLA'
135149 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
135150 ,p_token_1 => 'LINE_NUMBER'
135151 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
135152 ,p_token_2 => 'LINE_TYPE_NAME'
135153 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
135154 l_component_type
135155 ,l_component_code
135156 ,l_component_type_code
135157 ,l_component_appl_id
135158 ,l_amb_context_code
135159 ,l_entity_code
135160 ,l_event_class_code
135161 )
135162 ,p_token_3 => 'OWNER'
135163 ,p_value_3 => xla_lookups_pkg.get_meaning(
135164 p_lookup_type => 'XLA_OWNER_TYPE'
135165 ,p_lookup_code => l_component_type_code
135166 )
135167 ,p_token_4 => 'PRODUCT_NAME'
135168 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
135169 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
135170 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
135171 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
135172 ,p_ae_header_id => NULL
135173 );
135174
135175 IF (C_LEVEL_ERROR>= g_log_level) THEN
135176 trace
135177 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
135178 ,p_level => C_LEVEL_ERROR
135179 ,p_module => l_log_module);
135180 END IF;
135181 END IF;
135182 END IF;
135183 --
135184 --
135185 ------------------------------------------------------------------------------------------------
135186 -- 4219869 Business Flow
135187 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
135188 -- Prior Entry. Currently, the following code is always generated.
135189 ------------------------------------------------------------------------------------------------
135190 XLA_AE_LINES_PKG.ValidateCurrentLine;
135191
135192 ------------------------------------------------------------------------------------
135193 -- 4219869 Business Flow
135194 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
135195 ------------------------------------------------------------------------------------
135196 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
135197
135198 ----------------------------------------------------------------------------------
135199 -- 4219869 Business Flow
135200 -- Update journal entry status -- Need to generate this within IF <condition>
135201 ----------------------------------------------------------------------------------
135202 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
135203 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
135204 ,p_balance_type_code => l_balance_type_code
135205 );
135206
135207 -------------------------------------------------------------------------------------------
135208 -- 4262811 - Generate the Accrual Reversal lines
135209 -------------------------------------------------------------------------------------------
135210 BEGIN
135211 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
135212 (g_array_event(p_event_id).array_value_num('header_index'));
135213 IF l_acc_rev_flag IS NULL THEN
135214 l_acc_rev_flag := 'N';
135215 END IF;
135216 EXCEPTION
135217 WHEN OTHERS THEN
135218 l_acc_rev_flag := 'N';
135219 END;
135220 --
135221 IF (l_acc_rev_flag = 'Y') THEN
135222
135223 -- 4645092 ------------------------------------------------------------------------------
135224 -- To allow MPA report to determine if it should generate report process
135225 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
135226 ------------------------------------------------------------------------------------------
135227
135228 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
135229 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
135230 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
135231 -- call ADRs
135232 -- Bug 4922099
135233 --
135234 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
135235 (NVL(l_actual_upg_option, 'N') = 'O') OR
135236 (NVL(l_enc_upg_option, 'N') = 'O')
135237 )
135238 THEN
135239 NULL;
135240 --
135241 --
135242
135243 l_ccid := AcctDerRule_28(
135244 p_application_id => p_application_id
135245 , p_ae_header_id => l_ae_header_id
135246 , p_source_15 => p_source_15
135247 , p_source_41 => p_source_41
135248 , p_source_42 => p_source_42
135249 , p_source_43 => p_source_43
135250 , p_source_44 => p_source_44
135251 , p_source_45 => p_source_45
135252 , x_transaction_coa_id => l_adr_transaction_coa_id
135253 , x_accounting_coa_id => l_adr_accounting_coa_id
135254 , x_value_type_code => l_adr_value_type_code
135255 , p_side => 'NA'
135256 );
135257
135258 xla_ae_lines_pkg.set_ccid(
135259 p_code_combination_id => l_ccid
135260 , p_value_type_code => l_adr_value_type_code
135261 , p_transaction_coa_id => l_adr_transaction_coa_id
135262 , p_accounting_coa_id => l_adr_accounting_coa_id
135263 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
135264 , p_adr_type_code => 'S'
135265 , p_component_type => l_component_type
135266 , p_component_code => l_component_code
135267 , p_component_type_code => l_component_type_code
135268 , p_component_appl_id => l_component_appl_id
135269 , p_amb_context_code => l_amb_context_code
135270 , p_side => 'NA'
135271 );
135272
135273
135274 --
135275 --
135276 END IF;
135277
135278 --
135279 -- Update the line information that should be overwritten
135280 --
135281 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
135282 p_header_num => 1);
135283 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
135284
135285 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
135286
135287 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
135288 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
135289 END IF;
135290
135291 --
135292 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
135293 --
135294 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
135295 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
135296 ELSE
135297 ---------------------------------------------------------------------------------------------------
135298 -- 4262811a Switch Sign
135299 ---------------------------------------------------------------------------------------------------
135300 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
135301 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
135302 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135303 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
135304 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135305 -- 5132302
135306 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
135307 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135308
135309 END IF;
135310
135311 -- 4955764
135312 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
135313 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
135314
135315
135316 XLA_AE_LINES_PKG.ValidateCurrentLine;
135317 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
135318
135319 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
135320 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
135321 ,p_balance_type_code => l_balance_type_code);
135322
135323 END IF;
135324
135325 -----------------------------------------------------------------------------------------
135326 -- 4262811 Multiperiod Accounting
135327 -----------------------------------------------------------------------------------------
135328 -- No MPA option is assigned.
135329
135330
135331 END IF;
135332 END IF;
135333 --
135334
135335 --
135336 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
135337 trace
135338 (p_msg => 'END of AcctLineType_257'
135339 ,p_level => C_LEVEL_PROCEDURE
135340 ,p_module => l_log_module);
135341 END IF;
135342 --
135343 EXCEPTION
135344 WHEN xla_exceptions_pkg.application_exception THEN
135345 RAISE;
135346 WHEN OTHERS THEN
135347 xla_exceptions_pkg.raise_message
135348 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_257');
135349 END AcctLineType_257;
135350 --
135351
135352 ---------------------------------------
135353 --
135354 -- PRIVATE FUNCTION
135355 -- AcctLineType_258
135356 --
135357 ---------------------------------------
135358 PROCEDURE AcctLineType_258 (
135359 p_application_id IN NUMBER
135360 ,p_event_id IN NUMBER
135361 ,p_calculate_acctd_flag IN VARCHAR2
135362 ,p_calculate_g_l_flag IN VARCHAR2
135363 ,p_actual_flag IN OUT VARCHAR2
135364 ,p_balance_type_code OUT VARCHAR2
135365 ,p_gain_or_loss_ref OUT VARCHAR2
135366
135367 --TRANSACTION_ID
135368 , p_source_1 IN NUMBER
135369 --Item Concatenated Segments
135370 , p_source_2 IN VARCHAR2
135371 --Transaction Quantity
135372 , p_source_3 IN NUMBER
135373 --Transaction Unit of Measure Code
135374 , p_source_4 IN VARCHAR2
135375 --Inventory Transaction Type Description
135376 , p_source_5 IN VARCHAR2
135377 --Cost Element Name
135378 , p_source_15 IN NUMBER
135379 --Product Line Accounting Category Material Account
135380 , p_source_41 IN NUMBER
135381 --Product Line Accounting Category Material Overhead Account
135382 , p_source_42 IN NUMBER
135383 --Product Line Accounting Category Resource Account
135384 , p_source_43 IN NUMBER
135385 --Product Line Accounting Category Outside Processing Account
135386 , p_source_44 IN NUMBER
135387 --Product Line Accounting Category Overhead Account
135388 , p_source_45 IN NUMBER
135389 --DISTRIBUTION_IDENTIFIER
135390 , p_source_84 IN NUMBER
135391 --Distribution Type
135392 , p_source_85 IN VARCHAR2
135393 , p_source_85_meaning IN VARCHAR2
135394 --Entered Currency Code
135395 , p_source_88 IN VARCHAR2
135396 --Entered Amount
135397 , p_source_91 IN NUMBER
135398 --Currency Conversion Date
135399 , p_source_92 IN DATE
135400 --Currency Conversion Rate
135401 , p_source_93 IN NUMBER
135402 --Currency Conversion Type
135403 , p_source_94 IN VARCHAR2
135404 --Accounted Amount
135405 , p_source_95 IN NUMBER
135406 --Accounting Line Type
135407 , p_source_97 IN NUMBER
135408 --Organization Code
135409 , p_source_108 IN VARCHAR2
135410 )
135411 IS
135412
135413 l_component_type VARCHAR2(80);
135414 l_component_code VARCHAR2(30);
135415 l_component_type_code VARCHAR2(1);
135416 l_component_appl_id INTEGER;
135417 l_amb_context_code VARCHAR2(30);
135418 l_entity_code VARCHAR2(30);
135419 l_event_class_code VARCHAR2(30);
135420 l_ae_header_id NUMBER;
135421 l_event_type_code VARCHAR2(30);
135422 l_line_definition_code VARCHAR2(30);
135423 l_line_definition_owner_code VARCHAR2(1);
135424 --
135425 -- adr variables
135426 l_segment VARCHAR2(30);
135427 l_ccid NUMBER;
135428 l_adr_transaction_coa_id NUMBER;
135429 l_adr_accounting_coa_id NUMBER;
135430 l_adr_flexfield_segment_code VARCHAR2(30);
135431 l_adr_flex_value_set_id NUMBER;
135432 l_adr_value_type_code VARCHAR2(30);
135433 l_adr_value_combination_id NUMBER;
135434 l_adr_value_segment_code VARCHAR2(30);
135435
135436 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
135437 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
135438 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
135439 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
135440
135441 -- 4262811 Variables ------------------------------------------------------------------------------------------
135442 l_entered_amt_idx NUMBER;
135443 l_accted_amt_idx NUMBER;
135444 l_acc_rev_flag VARCHAR2(1);
135445 l_accrual_line_num NUMBER;
135446 l_tmp_amt NUMBER;
135447 l_acc_rev_natural_side_code VARCHAR2(1);
135448
135449 l_num_entries NUMBER;
135450 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
135451 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
135452 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
135453 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
135454 l_recog_line_1 NUMBER;
135455 l_recog_line_2 NUMBER;
135456
135457 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
135458 l_bflow_applied_to_amt NUMBER; -- 5132302
135459 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
135460
135461 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
135462
135463 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
135464 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
135465
135466 ---------------------------------------------------------------------------------------------------------------
135467
135468
135469 --
135470 -- bulk performance
135471 --
135472 l_balance_type_code VARCHAR2(1);
135473 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
135474 l_log_module VARCHAR2(240);
135475
135476 --
135477 -- Upgrade strategy
135478 --
135479 l_actual_upg_option VARCHAR2(1);
135480 l_enc_upg_option VARCHAR2(1);
135481
135482 --
135483 BEGIN
135484 --
135485 IF g_log_enabled THEN
135486 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_258';
135487 END IF;
135488 --
135489 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
135490
135491 trace
135492 (p_msg => 'BEGIN of AcctLineType_258'
135493 ,p_level => C_LEVEL_PROCEDURE
135494 ,p_module => l_log_module);
135495
135496 END IF;
135497 --
135498 l_component_type := 'AMB_JLT';
135499 l_component_code := 'INVENTORY_VALUATION';
135500 l_component_type_code := 'S';
135501 l_component_appl_id := 707;
135502 l_amb_context_code := 'DEFAULT';
135503 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
135504 l_event_class_code := 'USER_DEFINE';
135505 l_event_type_code := 'UCG_TXFR';
135506 l_line_definition_owner_code := 'S';
135507 l_line_definition_code := 'PI_CG_TXFR';
135508 --
135509 l_balance_type_code := 'A';
135510 l_segment := NULL;
135511 l_ccid := NULL;
135512 l_adr_transaction_coa_id := NULL;
135513 l_adr_accounting_coa_id := NULL;
135514 l_adr_flexfield_segment_code := NULL;
135515 l_adr_flex_value_set_id := NULL;
135516 l_adr_value_type_code := NULL;
135517 l_adr_value_combination_id := NULL;
135518 l_adr_value_segment_code := NULL;
135519
135520 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
135521 l_bflow_class_code := ''; -- 4219869 Business Flow
135522 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
135523 l_budgetary_control_flag := 'N';
135524
135525 l_bflow_applied_to_amt_idx := NULL; -- 5132302
135526 l_bflow_applied_to_amt := NULL; -- 5132302
135527 l_entered_amt_idx := NULL; -- 4262811
135528 l_accted_amt_idx := NULL; -- 4262811
135529 l_acc_rev_flag := NULL; -- 4262811
135530 l_accrual_line_num := NULL; -- 4262811
135531 l_tmp_amt := NULL; -- 4262811
135532 --
135533
135534 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
135535 l_balance_type_code <> 'B' THEN
135536 IF NVL(p_source_97,9E125) = 1
135537 THEN
135538
135539 --
135540 XLA_AE_LINES_PKG.SetNewLine;
135541
135542 p_balance_type_code := l_balance_type_code;
135543 -- set the flag so later we will know whether the gain loss line needs to be created
135544
135545 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
135546 p_actual_flag :='A';
135547 END IF;
135548
135549 --
135550 -- bulk performance
135551 --
135552 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
135553 p_header_num => 0); -- 4262811
135554 --
135555 -- set accounting line options
135556 --
135557 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
135558 p_natural_side_code => 'D'
135559 , p_gain_or_loss_flag => 'N'
135560 , p_gl_transfer_mode_code => 'S'
135561 , p_acct_entry_type_code => 'A'
135562 , p_switch_side_flag => 'Y'
135563 , p_merge_duplicate_code => 'N'
135564 );
135565 --
135566 l_acc_rev_natural_side_code := 'C'; -- 4262811
135567 --
135568 --
135569 -- set accounting line type info
135570 --
135571 xla_ae_lines_pkg.SetAcctLineType
135572 (p_component_type => l_component_type
135573 ,p_event_type_code => l_event_type_code
135574 ,p_line_definition_owner_code => l_line_definition_owner_code
135575 ,p_line_definition_code => l_line_definition_code
135576 ,p_accounting_line_code => l_component_code
135577 ,p_accounting_line_type_code => l_component_type_code
135578 ,p_accounting_line_appl_id => l_component_appl_id
135579 ,p_amb_context_code => l_amb_context_code
135580 ,p_entity_code => l_entity_code
135581 ,p_event_class_code => l_event_class_code);
135582 --
135583 -- set accounting class
135584 --
135585 xla_ae_lines_pkg.SetAcctClass(
135586 p_accounting_class_code => 'INVENTORY_VALUATION'
135587 , p_ae_header_id => l_ae_header_id
135588 );
135589
135590 --
135591 -- set rounding class
135592 --
135593 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
135594 'INVENTORY_VALUATION';
135595
135596 --
135597 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
135598 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
135599 --
135600 -- bulk performance
135601 --
135602 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
135603
135604 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
135605 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
135606
135607 -- 4955764
135608 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
135609 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
135610
135611 -- 4458381 Public Sector Enh
135612
135613 --
135614 -- set accounting attributes for the line type
135615 --
135616 l_entered_amt_idx := 3;
135617 l_accted_amt_idx := 8;
135618 l_bflow_applied_to_amt_idx := NULL; -- 5132302
135619 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
135620 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
135621 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
135622 l_rec_acct_attrs.array_char_value(2) := p_source_85;
135623 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
135624 l_rec_acct_attrs.array_num_value(3) := p_source_91;
135625 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
135626 l_rec_acct_attrs.array_char_value(4) := p_source_88;
135627 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
135628 l_rec_acct_attrs.array_date_value(5) := p_source_92;
135629 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
135630 l_rec_acct_attrs.array_num_value(6) := p_source_93;
135631 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
135632 l_rec_acct_attrs.array_char_value(7) := p_source_94;
135633 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
135634 l_rec_acct_attrs.array_num_value(8) := p_source_95;
135635
135636 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
135637 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
135638
135639 ---------------------------------------------------------------------------------------------------------------
135640 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
135641 ---------------------------------------------------------------------------------------------------------------
135642 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
135643
135644 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
135645 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
135646
135647 IF xla_accounting_cache_pkg.GetValueChar
135648 (p_source_code => 'LEDGER_CATEGORY_CODE'
135649 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
135650 AND l_bflow_method_code = 'PRIOR_ENTRY'
135651 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
135652 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
135653 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
135654 )
135655 THEN
135656 xla_ae_lines_pkg.BflowUpgEntry
135657 (p_business_method_code => l_bflow_method_code
135658 ,p_business_class_code => l_bflow_class_code
135659 ,p_balance_type => l_balance_type_code);
135660 ELSE
135661 NULL;
135662 -- No business flow processing for business flow method of NONE.
135663 END IF;
135664
135665 --
135666 -- call analytical criteria
135667 --
135668
135669
135670 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
135671 xla_ae_lines_pkg.SetAnalyticalCriteria(
135672 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
135673 , p_analytical_criterion_owner => 'S'
135674 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
135675 , p_amb_context_code => 'DEFAULT'
135676 , p_balancing_flag => 'Y'
135677
135678 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
135679 , p_analytical_detail_num_1 => NULL
135680 , p_analytical_detail_date_1 => NULL
135681
135682 , p_ae_header_id => l_ae_header_id
135683 )
135684 ;
135685 --
135686
135687 --
135688 -- call description
135689 --
135690
135691 xla_ae_lines_pkg.SetLineDescription(
135692 p_ae_header_id => l_ae_header_id
135693 ,p_description => Description_1 (
135694 p_application_id => p_application_id
135695 , p_ae_header_id => l_ae_header_id
135696 , p_source_1 => p_source_1
135697 , p_source_2 => p_source_2
135698 , p_source_3 => p_source_3
135699 , p_source_4 => p_source_4
135700 , p_source_5 => p_source_5
135701 )
135702 );
135703
135704
135705 --
135706 -- call ADRs
135707 -- Bug 4922099
135708 --
135709 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
135710 (NVL(l_actual_upg_option, 'N') = 'O') OR
135711 (NVL(l_enc_upg_option, 'N') = 'O')
135712 )
135713 THEN
135714 NULL;
135715 --
135716 --
135717
135718 l_ccid := AcctDerRule_28(
135719 p_application_id => p_application_id
135720 , p_ae_header_id => l_ae_header_id
135721 , p_source_15 => p_source_15
135722 , p_source_41 => p_source_41
135723 , p_source_42 => p_source_42
135724 , p_source_43 => p_source_43
135725 , p_source_44 => p_source_44
135726 , p_source_45 => p_source_45
135727 , x_transaction_coa_id => l_adr_transaction_coa_id
135728 , x_accounting_coa_id => l_adr_accounting_coa_id
135729 , x_value_type_code => l_adr_value_type_code
135730 , p_side => 'NA'
135731 );
135732
135733 xla_ae_lines_pkg.set_ccid(
135734 p_code_combination_id => l_ccid
135735 , p_value_type_code => l_adr_value_type_code
135736 , p_transaction_coa_id => l_adr_transaction_coa_id
135737 , p_accounting_coa_id => l_adr_accounting_coa_id
135738 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
135739 , p_adr_type_code => 'S'
135740 , p_component_type => l_component_type
135741 , p_component_code => l_component_code
135742 , p_component_type_code => l_component_type_code
135743 , p_component_appl_id => l_component_appl_id
135744 , p_amb_context_code => l_amb_context_code
135745 , p_side => 'NA'
135746 );
135747
135748
135749 --
135750 --
135751 END IF;
135752 --
135753 -- Bug 4922099
135754 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
135755 (NVL(l_enc_upg_option, 'N') = 'O')
135756 ) AND
135757 (l_bflow_method_code = 'PRIOR_ENTRY')
135758 )
135759 THEN
135760 IF
135761 --
135762 1 = 2
135763 --
135764 THEN
135765 xla_accounting_err_pkg.build_message
135766 (p_appli_s_name => 'XLA'
135767 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
135768 ,p_token_1 => 'LINE_NUMBER'
135769 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
135770 ,p_token_2 => 'LINE_TYPE_NAME'
135771 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
135772 l_component_type
135773 ,l_component_code
135774 ,l_component_type_code
135775 ,l_component_appl_id
135776 ,l_amb_context_code
135777 ,l_entity_code
135778 ,l_event_class_code
135779 )
135780 ,p_token_3 => 'OWNER'
135781 ,p_value_3 => xla_lookups_pkg.get_meaning(
135782 p_lookup_type => 'XLA_OWNER_TYPE'
135783 ,p_lookup_code => l_component_type_code
135784 )
135785 ,p_token_4 => 'PRODUCT_NAME'
135786 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
135787 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
135788 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
135789 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
135790 ,p_ae_header_id => NULL
135791 );
135792
135793 IF (C_LEVEL_ERROR>= g_log_level) THEN
135794 trace
135795 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
135796 ,p_level => C_LEVEL_ERROR
135797 ,p_module => l_log_module);
135798 END IF;
135799 END IF;
135800 END IF;
135801 --
135802 --
135803 ------------------------------------------------------------------------------------------------
135804 -- 4219869 Business Flow
135805 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
135806 -- Prior Entry. Currently, the following code is always generated.
135807 ------------------------------------------------------------------------------------------------
135808 XLA_AE_LINES_PKG.ValidateCurrentLine;
135809
135810 ------------------------------------------------------------------------------------
135811 -- 4219869 Business Flow
135812 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
135813 ------------------------------------------------------------------------------------
135814 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
135815
135816 ----------------------------------------------------------------------------------
135817 -- 4219869 Business Flow
135818 -- Update journal entry status -- Need to generate this within IF <condition>
135819 ----------------------------------------------------------------------------------
135820 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
135821 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
135822 ,p_balance_type_code => l_balance_type_code
135823 );
135824
135825 -------------------------------------------------------------------------------------------
135826 -- 4262811 - Generate the Accrual Reversal lines
135827 -------------------------------------------------------------------------------------------
135828 BEGIN
135829 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
135830 (g_array_event(p_event_id).array_value_num('header_index'));
135831 IF l_acc_rev_flag IS NULL THEN
135832 l_acc_rev_flag := 'N';
135833 END IF;
135834 EXCEPTION
135835 WHEN OTHERS THEN
135836 l_acc_rev_flag := 'N';
135837 END;
135838 --
135839 IF (l_acc_rev_flag = 'Y') THEN
135840
135841 -- 4645092 ------------------------------------------------------------------------------
135842 -- To allow MPA report to determine if it should generate report process
135843 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
135844 ------------------------------------------------------------------------------------------
135845
135846 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
135847 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
135848 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
135849 -- call ADRs
135850 -- Bug 4922099
135851 --
135852 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
135853 (NVL(l_actual_upg_option, 'N') = 'O') OR
135854 (NVL(l_enc_upg_option, 'N') = 'O')
135855 )
135856 THEN
135857 NULL;
135858 --
135859 --
135860
135861 l_ccid := AcctDerRule_28(
135862 p_application_id => p_application_id
135863 , p_ae_header_id => l_ae_header_id
135864 , p_source_15 => p_source_15
135865 , p_source_41 => p_source_41
135866 , p_source_42 => p_source_42
135867 , p_source_43 => p_source_43
135868 , p_source_44 => p_source_44
135869 , p_source_45 => p_source_45
135870 , x_transaction_coa_id => l_adr_transaction_coa_id
135871 , x_accounting_coa_id => l_adr_accounting_coa_id
135872 , x_value_type_code => l_adr_value_type_code
135873 , p_side => 'NA'
135874 );
135875
135876 xla_ae_lines_pkg.set_ccid(
135877 p_code_combination_id => l_ccid
135878 , p_value_type_code => l_adr_value_type_code
135879 , p_transaction_coa_id => l_adr_transaction_coa_id
135880 , p_accounting_coa_id => l_adr_accounting_coa_id
135881 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
135882 , p_adr_type_code => 'S'
135883 , p_component_type => l_component_type
135884 , p_component_code => l_component_code
135885 , p_component_type_code => l_component_type_code
135886 , p_component_appl_id => l_component_appl_id
135887 , p_amb_context_code => l_amb_context_code
135888 , p_side => 'NA'
135889 );
135890
135891
135892 --
135893 --
135894 END IF;
135895
135896 --
135897 -- Update the line information that should be overwritten
135898 --
135899 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
135900 p_header_num => 1);
135901 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
135902
135903 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
135904
135905 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
135906 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
135907 END IF;
135908
135909 --
135910 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
135911 --
135912 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
135913 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
135914 ELSE
135915 ---------------------------------------------------------------------------------------------------
135916 -- 4262811a Switch Sign
135917 ---------------------------------------------------------------------------------------------------
135918 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
135919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
135920 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135921 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
135922 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135923 -- 5132302
135924 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
135925 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
135926
135927 END IF;
135928
135929 -- 4955764
135930 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
135931 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
135932
135933
135934 XLA_AE_LINES_PKG.ValidateCurrentLine;
135935 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
135936
135937 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
135938 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
135939 ,p_balance_type_code => l_balance_type_code);
135940
135941 END IF;
135942
135943 -----------------------------------------------------------------------------------------
135944 -- 4262811 Multiperiod Accounting
135945 -----------------------------------------------------------------------------------------
135946 -- No MPA option is assigned.
135947
135948
135949 END IF;
135950 END IF;
135951 --
135952
135953 --
135954 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
135955 trace
135956 (p_msg => 'END of AcctLineType_258'
135957 ,p_level => C_LEVEL_PROCEDURE
135958 ,p_module => l_log_module);
135959 END IF;
135960 --
135961 EXCEPTION
135962 WHEN xla_exceptions_pkg.application_exception THEN
135963 RAISE;
135964 WHEN OTHERS THEN
135965 xla_exceptions_pkg.raise_message
135966 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_258');
135967 END AcctLineType_258;
135968 --
135969
135970 ---------------------------------------
135971 --
135972 -- PRIVATE FUNCTION
135973 -- AcctLineType_259
135974 --
135975 ---------------------------------------
135976 PROCEDURE AcctLineType_259 (
135977 p_application_id IN NUMBER
135978 ,p_event_id IN NUMBER
135979 ,p_calculate_acctd_flag IN VARCHAR2
135980 ,p_calculate_g_l_flag IN VARCHAR2
135981 ,p_actual_flag IN OUT VARCHAR2
135982 ,p_balance_type_code OUT VARCHAR2
135983 ,p_gain_or_loss_ref OUT VARCHAR2
135984
135985 --Cost Element Name
135986 , p_source_15 IN NUMBER
135987 --Product Line Accounting Category Material Account
135988 , p_source_41 IN NUMBER
135989 --Product Line Accounting Category Material Overhead Account
135990 , p_source_42 IN NUMBER
135991 --Product Line Accounting Category Resource Account
135992 , p_source_43 IN NUMBER
135993 --Product Line Accounting Category Outside Processing Account
135994 , p_source_44 IN NUMBER
135995 --Product Line Accounting Category Overhead Account
135996 , p_source_45 IN NUMBER
135997 --DISTRIBUTION_IDENTIFIER
135998 , p_source_84 IN NUMBER
135999 --Distribution Type
136000 , p_source_85 IN VARCHAR2
136001 , p_source_85_meaning IN VARCHAR2
136002 --Entered Currency Code
136003 , p_source_88 IN VARCHAR2
136004 --Entered Amount
136005 , p_source_91 IN NUMBER
136006 --Currency Conversion Date
136007 , p_source_92 IN DATE
136008 --Currency Conversion Rate
136009 , p_source_93 IN NUMBER
136010 --Currency Conversion Type
136011 , p_source_94 IN VARCHAR2
136012 --Accounted Amount
136013 , p_source_95 IN NUMBER
136014 --Accounting Line Type
136015 , p_source_97 IN NUMBER
136016 --Organization Code
136017 , p_source_108 IN VARCHAR2
136018 )
136019 IS
136020
136021 l_component_type VARCHAR2(80);
136022 l_component_code VARCHAR2(30);
136023 l_component_type_code VARCHAR2(1);
136024 l_component_appl_id INTEGER;
136025 l_amb_context_code VARCHAR2(30);
136026 l_entity_code VARCHAR2(30);
136027 l_event_class_code VARCHAR2(30);
136028 l_ae_header_id NUMBER;
136029 l_event_type_code VARCHAR2(30);
136030 l_line_definition_code VARCHAR2(30);
136031 l_line_definition_owner_code VARCHAR2(1);
136032 --
136033 -- adr variables
136034 l_segment VARCHAR2(30);
136035 l_ccid NUMBER;
136036 l_adr_transaction_coa_id NUMBER;
136037 l_adr_accounting_coa_id NUMBER;
136038 l_adr_flexfield_segment_code VARCHAR2(30);
136039 l_adr_flex_value_set_id NUMBER;
136040 l_adr_value_type_code VARCHAR2(30);
136041 l_adr_value_combination_id NUMBER;
136042 l_adr_value_segment_code VARCHAR2(30);
136043
136044 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
136045 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
136046 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
136047 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
136048
136049 -- 4262811 Variables ------------------------------------------------------------------------------------------
136050 l_entered_amt_idx NUMBER;
136051 l_accted_amt_idx NUMBER;
136052 l_acc_rev_flag VARCHAR2(1);
136053 l_accrual_line_num NUMBER;
136054 l_tmp_amt NUMBER;
136055 l_acc_rev_natural_side_code VARCHAR2(1);
136056
136057 l_num_entries NUMBER;
136058 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
136059 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
136060 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
136061 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
136062 l_recog_line_1 NUMBER;
136063 l_recog_line_2 NUMBER;
136064
136065 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
136066 l_bflow_applied_to_amt NUMBER; -- 5132302
136067 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
136068
136069 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
136070
136071 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
136072 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
136073
136074 ---------------------------------------------------------------------------------------------------------------
136075
136076
136077 --
136078 -- bulk performance
136079 --
136080 l_balance_type_code VARCHAR2(1);
136081 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
136082 l_log_module VARCHAR2(240);
136083
136084 --
136085 -- Upgrade strategy
136086 --
136087 l_actual_upg_option VARCHAR2(1);
136088 l_enc_upg_option VARCHAR2(1);
136089
136090 --
136091 BEGIN
136092 --
136093 IF g_log_enabled THEN
136094 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_259';
136095 END IF;
136096 --
136097 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
136098
136099 trace
136100 (p_msg => 'BEGIN of AcctLineType_259'
136101 ,p_level => C_LEVEL_PROCEDURE
136102 ,p_module => l_log_module);
136103
136104 END IF;
136105 --
136106 l_component_type := 'AMB_JLT';
136107 l_component_code := 'INVENTORY_VALUATION';
136108 l_component_type_code := 'S';
136109 l_component_appl_id := 707;
136110 l_amb_context_code := 'DEFAULT';
136111 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
136112 l_event_class_code := 'USER_DEFINE';
136113 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
136114 l_line_definition_owner_code := 'S';
136115 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
136116 --
136117 l_balance_type_code := 'A';
136118 l_segment := NULL;
136119 l_ccid := NULL;
136120 l_adr_transaction_coa_id := NULL;
136121 l_adr_accounting_coa_id := NULL;
136122 l_adr_flexfield_segment_code := NULL;
136123 l_adr_flex_value_set_id := NULL;
136124 l_adr_value_type_code := NULL;
136125 l_adr_value_combination_id := NULL;
136126 l_adr_value_segment_code := NULL;
136127
136128 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
136129 l_bflow_class_code := ''; -- 4219869 Business Flow
136130 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
136131 l_budgetary_control_flag := 'N';
136132
136133 l_bflow_applied_to_amt_idx := NULL; -- 5132302
136134 l_bflow_applied_to_amt := NULL; -- 5132302
136135 l_entered_amt_idx := NULL; -- 4262811
136136 l_accted_amt_idx := NULL; -- 4262811
136137 l_acc_rev_flag := NULL; -- 4262811
136138 l_accrual_line_num := NULL; -- 4262811
136139 l_tmp_amt := NULL; -- 4262811
136140 --
136141
136142 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
136143 l_balance_type_code <> 'B' THEN
136144 IF NVL(p_source_97,9E125) = 1
136145 THEN
136146
136147 --
136148 XLA_AE_LINES_PKG.SetNewLine;
136149
136150 p_balance_type_code := l_balance_type_code;
136151 -- set the flag so later we will know whether the gain loss line needs to be created
136152
136153 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
136154 p_actual_flag :='A';
136155 END IF;
136156
136157 --
136158 -- bulk performance
136159 --
136160 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
136161 p_header_num => 0); -- 4262811
136162 --
136163 -- set accounting line options
136164 --
136165 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
136166 p_natural_side_code => 'D'
136167 , p_gain_or_loss_flag => 'N'
136168 , p_gl_transfer_mode_code => 'S'
136169 , p_acct_entry_type_code => 'A'
136170 , p_switch_side_flag => 'Y'
136171 , p_merge_duplicate_code => 'N'
136172 );
136173 --
136174 l_acc_rev_natural_side_code := 'C'; -- 4262811
136175 --
136176 --
136177 -- set accounting line type info
136178 --
136179 xla_ae_lines_pkg.SetAcctLineType
136180 (p_component_type => l_component_type
136181 ,p_event_type_code => l_event_type_code
136182 ,p_line_definition_owner_code => l_line_definition_owner_code
136183 ,p_line_definition_code => l_line_definition_code
136184 ,p_accounting_line_code => l_component_code
136185 ,p_accounting_line_type_code => l_component_type_code
136186 ,p_accounting_line_appl_id => l_component_appl_id
136187 ,p_amb_context_code => l_amb_context_code
136188 ,p_entity_code => l_entity_code
136189 ,p_event_class_code => l_event_class_code);
136190 --
136191 -- set accounting class
136192 --
136193 xla_ae_lines_pkg.SetAcctClass(
136194 p_accounting_class_code => 'INVENTORY_VALUATION'
136195 , p_ae_header_id => l_ae_header_id
136196 );
136197
136198 --
136199 -- set rounding class
136200 --
136201 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
136202 'INVENTORY_VALUATION';
136203
136204 --
136205 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
136206 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
136207 --
136208 -- bulk performance
136209 --
136210 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
136211
136212 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
136213 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
136214
136215 -- 4955764
136216 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
136217 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
136218
136219 -- 4458381 Public Sector Enh
136220
136221 --
136222 -- set accounting attributes for the line type
136223 --
136224 l_entered_amt_idx := 3;
136225 l_accted_amt_idx := 8;
136226 l_bflow_applied_to_amt_idx := NULL; -- 5132302
136227 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
136228 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
136229 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
136230 l_rec_acct_attrs.array_char_value(2) := p_source_85;
136231 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
136232 l_rec_acct_attrs.array_num_value(3) := p_source_91;
136233 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
136234 l_rec_acct_attrs.array_char_value(4) := p_source_88;
136235 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
136236 l_rec_acct_attrs.array_date_value(5) := p_source_92;
136237 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
136238 l_rec_acct_attrs.array_num_value(6) := p_source_93;
136239 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
136240 l_rec_acct_attrs.array_char_value(7) := p_source_94;
136241 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
136242 l_rec_acct_attrs.array_num_value(8) := p_source_95;
136243
136244 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
136245 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
136246
136247 ---------------------------------------------------------------------------------------------------------------
136248 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
136249 ---------------------------------------------------------------------------------------------------------------
136250 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
136251
136252 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
136253 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
136254
136255 IF xla_accounting_cache_pkg.GetValueChar
136256 (p_source_code => 'LEDGER_CATEGORY_CODE'
136257 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
136258 AND l_bflow_method_code = 'PRIOR_ENTRY'
136259 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
136260 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
136261 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
136262 )
136263 THEN
136264 xla_ae_lines_pkg.BflowUpgEntry
136265 (p_business_method_code => l_bflow_method_code
136266 ,p_business_class_code => l_bflow_class_code
136267 ,p_balance_type => l_balance_type_code);
136268 ELSE
136269 NULL;
136270 -- No business flow processing for business flow method of NONE.
136271 END IF;
136272
136273 --
136274 -- call analytical criteria
136275 --
136276
136277
136278 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
136279 xla_ae_lines_pkg.SetAnalyticalCriteria(
136280 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
136281 , p_analytical_criterion_owner => 'S'
136282 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
136283 , p_amb_context_code => 'DEFAULT'
136284 , p_balancing_flag => 'Y'
136285
136286 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
136287 , p_analytical_detail_num_1 => NULL
136288 , p_analytical_detail_date_1 => NULL
136289
136290 , p_ae_header_id => l_ae_header_id
136291 )
136292 ;
136293 --
136294
136295 --
136296 -- call description
136297 --
136298 -- No description or it is inherited.
136299 --
136300 -- call ADRs
136301 -- Bug 4922099
136302 --
136303 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
136304 (NVL(l_actual_upg_option, 'N') = 'O') OR
136305 (NVL(l_enc_upg_option, 'N') = 'O')
136306 )
136307 THEN
136308 NULL;
136309 --
136310 --
136311
136312 l_ccid := AcctDerRule_28(
136313 p_application_id => p_application_id
136314 , p_ae_header_id => l_ae_header_id
136315 , p_source_15 => p_source_15
136316 , p_source_41 => p_source_41
136317 , p_source_42 => p_source_42
136318 , p_source_43 => p_source_43
136319 , p_source_44 => p_source_44
136320 , p_source_45 => p_source_45
136321 , x_transaction_coa_id => l_adr_transaction_coa_id
136322 , x_accounting_coa_id => l_adr_accounting_coa_id
136323 , x_value_type_code => l_adr_value_type_code
136324 , p_side => 'NA'
136325 );
136326
136327 xla_ae_lines_pkg.set_ccid(
136328 p_code_combination_id => l_ccid
136329 , p_value_type_code => l_adr_value_type_code
136330 , p_transaction_coa_id => l_adr_transaction_coa_id
136331 , p_accounting_coa_id => l_adr_accounting_coa_id
136332 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
136333 , p_adr_type_code => 'S'
136334 , p_component_type => l_component_type
136335 , p_component_code => l_component_code
136336 , p_component_type_code => l_component_type_code
136337 , p_component_appl_id => l_component_appl_id
136338 , p_amb_context_code => l_amb_context_code
136339 , p_side => 'NA'
136340 );
136341
136342
136343 --
136344 --
136345 END IF;
136346 --
136347 -- Bug 4922099
136348 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
136349 (NVL(l_enc_upg_option, 'N') = 'O')
136350 ) AND
136351 (l_bflow_method_code = 'PRIOR_ENTRY')
136352 )
136353 THEN
136354 IF
136355 --
136356 1 = 2
136357 --
136358 THEN
136359 xla_accounting_err_pkg.build_message
136360 (p_appli_s_name => 'XLA'
136361 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
136362 ,p_token_1 => 'LINE_NUMBER'
136363 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
136364 ,p_token_2 => 'LINE_TYPE_NAME'
136365 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
136366 l_component_type
136367 ,l_component_code
136368 ,l_component_type_code
136369 ,l_component_appl_id
136370 ,l_amb_context_code
136371 ,l_entity_code
136372 ,l_event_class_code
136373 )
136374 ,p_token_3 => 'OWNER'
136375 ,p_value_3 => xla_lookups_pkg.get_meaning(
136376 p_lookup_type => 'XLA_OWNER_TYPE'
136377 ,p_lookup_code => l_component_type_code
136378 )
136379 ,p_token_4 => 'PRODUCT_NAME'
136380 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
136381 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
136382 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
136383 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
136384 ,p_ae_header_id => NULL
136385 );
136386
136387 IF (C_LEVEL_ERROR>= g_log_level) THEN
136388 trace
136389 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
136390 ,p_level => C_LEVEL_ERROR
136391 ,p_module => l_log_module);
136392 END IF;
136393 END IF;
136394 END IF;
136395 --
136396 --
136397 ------------------------------------------------------------------------------------------------
136398 -- 4219869 Business Flow
136399 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
136400 -- Prior Entry. Currently, the following code is always generated.
136401 ------------------------------------------------------------------------------------------------
136402 XLA_AE_LINES_PKG.ValidateCurrentLine;
136403
136404 ------------------------------------------------------------------------------------
136405 -- 4219869 Business Flow
136406 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
136407 ------------------------------------------------------------------------------------
136408 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
136409
136410 ----------------------------------------------------------------------------------
136411 -- 4219869 Business Flow
136412 -- Update journal entry status -- Need to generate this within IF <condition>
136413 ----------------------------------------------------------------------------------
136414 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
136415 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
136416 ,p_balance_type_code => l_balance_type_code
136417 );
136418
136419 -------------------------------------------------------------------------------------------
136420 -- 4262811 - Generate the Accrual Reversal lines
136421 -------------------------------------------------------------------------------------------
136422 BEGIN
136423 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
136424 (g_array_event(p_event_id).array_value_num('header_index'));
136425 IF l_acc_rev_flag IS NULL THEN
136426 l_acc_rev_flag := 'N';
136427 END IF;
136428 EXCEPTION
136429 WHEN OTHERS THEN
136430 l_acc_rev_flag := 'N';
136431 END;
136432 --
136433 IF (l_acc_rev_flag = 'Y') THEN
136434
136435 -- 4645092 ------------------------------------------------------------------------------
136436 -- To allow MPA report to determine if it should generate report process
136437 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
136438 ------------------------------------------------------------------------------------------
136439
136440 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
136441 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
136442 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
136443 -- call ADRs
136444 -- Bug 4922099
136445 --
136446 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
136447 (NVL(l_actual_upg_option, 'N') = 'O') OR
136448 (NVL(l_enc_upg_option, 'N') = 'O')
136449 )
136450 THEN
136451 NULL;
136452 --
136453 --
136454
136455 l_ccid := AcctDerRule_28(
136456 p_application_id => p_application_id
136457 , p_ae_header_id => l_ae_header_id
136458 , p_source_15 => p_source_15
136459 , p_source_41 => p_source_41
136460 , p_source_42 => p_source_42
136461 , p_source_43 => p_source_43
136462 , p_source_44 => p_source_44
136463 , p_source_45 => p_source_45
136464 , x_transaction_coa_id => l_adr_transaction_coa_id
136465 , x_accounting_coa_id => l_adr_accounting_coa_id
136466 , x_value_type_code => l_adr_value_type_code
136467 , p_side => 'NA'
136468 );
136469
136470 xla_ae_lines_pkg.set_ccid(
136471 p_code_combination_id => l_ccid
136472 , p_value_type_code => l_adr_value_type_code
136473 , p_transaction_coa_id => l_adr_transaction_coa_id
136474 , p_accounting_coa_id => l_adr_accounting_coa_id
136475 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
136476 , p_adr_type_code => 'S'
136477 , p_component_type => l_component_type
136478 , p_component_code => l_component_code
136479 , p_component_type_code => l_component_type_code
136480 , p_component_appl_id => l_component_appl_id
136481 , p_amb_context_code => l_amb_context_code
136482 , p_side => 'NA'
136483 );
136484
136485
136486 --
136487 --
136488 END IF;
136489
136490 --
136491 -- Update the line information that should be overwritten
136492 --
136493 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
136494 p_header_num => 1);
136495 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
136496
136497 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
136498
136499 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
136500 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
136501 END IF;
136502
136503 --
136504 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
136505 --
136506 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
136507 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
136508 ELSE
136509 ---------------------------------------------------------------------------------------------------
136510 -- 4262811a Switch Sign
136511 ---------------------------------------------------------------------------------------------------
136512 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
136513 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
136514 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
136515 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
136516 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
136517 -- 5132302
136518 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
136519 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
136520
136521 END IF;
136522
136523 -- 4955764
136524 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
136525 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
136526
136527
136528 XLA_AE_LINES_PKG.ValidateCurrentLine;
136529 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
136530
136531 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
136532 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
136533 ,p_balance_type_code => l_balance_type_code);
136534
136535 END IF;
136536
136537 -----------------------------------------------------------------------------------------
136538 -- 4262811 Multiperiod Accounting
136539 -----------------------------------------------------------------------------------------
136540 -- No MPA option is assigned.
136541
136542
136543 END IF;
136544 END IF;
136545 --
136546
136547 --
136548 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
136549 trace
136550 (p_msg => 'END of AcctLineType_259'
136551 ,p_level => C_LEVEL_PROCEDURE
136552 ,p_module => l_log_module);
136553 END IF;
136554 --
136555 EXCEPTION
136556 WHEN xla_exceptions_pkg.application_exception THEN
136557 RAISE;
136558 WHEN OTHERS THEN
136559 xla_exceptions_pkg.raise_message
136560 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_259');
136561 END AcctLineType_259;
136562 --
136563
136564 ---------------------------------------
136565 --
136566 -- PRIVATE FUNCTION
136567 -- AcctLineType_260
136568 --
136569 ---------------------------------------
136570 PROCEDURE AcctLineType_260 (
136571 p_application_id IN NUMBER
136572 ,p_event_id IN NUMBER
136573 ,p_calculate_acctd_flag IN VARCHAR2
136574 ,p_calculate_g_l_flag IN VARCHAR2
136575 ,p_actual_flag IN OUT VARCHAR2
136576 ,p_balance_type_code OUT VARCHAR2
136577 ,p_gain_or_loss_ref OUT VARCHAR2
136578
136579 --TRANSACTION_ID
136580 , p_source_1 IN NUMBER
136581 --Item Concatenated Segments
136582 , p_source_2 IN VARCHAR2
136583 --Transaction Quantity
136584 , p_source_3 IN NUMBER
136585 --Transaction Unit of Measure Code
136586 , p_source_4 IN VARCHAR2
136587 --Inventory Transaction Type Description
136588 , p_source_5 IN VARCHAR2
136589 --Cost Element Name
136590 , p_source_15 IN NUMBER
136591 --Product Line Accounting Category Material Account
136592 , p_source_41 IN NUMBER
136593 --Product Line Accounting Category Material Overhead Account
136594 , p_source_42 IN NUMBER
136595 --Product Line Accounting Category Resource Account
136596 , p_source_43 IN NUMBER
136597 --Product Line Accounting Category Outside Processing Account
136598 , p_source_44 IN NUMBER
136599 --Product Line Accounting Category Overhead Account
136600 , p_source_45 IN NUMBER
136601 --DISTRIBUTION_IDENTIFIER
136602 , p_source_84 IN NUMBER
136603 --Distribution Type
136604 , p_source_85 IN VARCHAR2
136605 , p_source_85_meaning IN VARCHAR2
136606 --Entered Currency Code
136607 , p_source_88 IN VARCHAR2
136608 --Entered Amount
136609 , p_source_91 IN NUMBER
136610 --Currency Conversion Date
136611 , p_source_92 IN DATE
136612 --Currency Conversion Rate
136613 , p_source_93 IN NUMBER
136614 --Currency Conversion Type
136615 , p_source_94 IN VARCHAR2
136616 --Accounted Amount
136617 , p_source_95 IN NUMBER
136618 --Accounting Line Type
136619 , p_source_97 IN NUMBER
136620 --Organization Code
136621 , p_source_108 IN VARCHAR2
136622 )
136623 IS
136624
136625 l_component_type VARCHAR2(80);
136626 l_component_code VARCHAR2(30);
136627 l_component_type_code VARCHAR2(1);
136628 l_component_appl_id INTEGER;
136629 l_amb_context_code VARCHAR2(30);
136630 l_entity_code VARCHAR2(30);
136631 l_event_class_code VARCHAR2(30);
136632 l_ae_header_id NUMBER;
136633 l_event_type_code VARCHAR2(30);
136634 l_line_definition_code VARCHAR2(30);
136635 l_line_definition_owner_code VARCHAR2(1);
136636 --
136637 -- adr variables
136638 l_segment VARCHAR2(30);
136639 l_ccid NUMBER;
136640 l_adr_transaction_coa_id NUMBER;
136641 l_adr_accounting_coa_id NUMBER;
136642 l_adr_flexfield_segment_code VARCHAR2(30);
136643 l_adr_flex_value_set_id NUMBER;
136644 l_adr_value_type_code VARCHAR2(30);
136645 l_adr_value_combination_id NUMBER;
136646 l_adr_value_segment_code VARCHAR2(30);
136647
136648 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
136649 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
136650 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
136651 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
136652
136653 -- 4262811 Variables ------------------------------------------------------------------------------------------
136654 l_entered_amt_idx NUMBER;
136655 l_accted_amt_idx NUMBER;
136656 l_acc_rev_flag VARCHAR2(1);
136657 l_accrual_line_num NUMBER;
136658 l_tmp_amt NUMBER;
136659 l_acc_rev_natural_side_code VARCHAR2(1);
136660
136661 l_num_entries NUMBER;
136662 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
136663 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
136664 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
136665 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
136666 l_recog_line_1 NUMBER;
136667 l_recog_line_2 NUMBER;
136668
136669 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
136670 l_bflow_applied_to_amt NUMBER; -- 5132302
136671 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
136672
136673 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
136674
136675 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
136676 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
136677
136678 ---------------------------------------------------------------------------------------------------------------
136679
136680
136681 --
136682 -- bulk performance
136683 --
136684 l_balance_type_code VARCHAR2(1);
136685 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
136686 l_log_module VARCHAR2(240);
136687
136688 --
136689 -- Upgrade strategy
136690 --
136691 l_actual_upg_option VARCHAR2(1);
136692 l_enc_upg_option VARCHAR2(1);
136693
136694 --
136695 BEGIN
136696 --
136697 IF g_log_enabled THEN
136698 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_260';
136699 END IF;
136700 --
136701 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
136702
136703 trace
136704 (p_msg => 'BEGIN of AcctLineType_260'
136705 ,p_level => C_LEVEL_PROCEDURE
136706 ,p_module => l_log_module);
136707
136708 END IF;
136709 --
136710 l_component_type := 'AMB_JLT';
136711 l_component_code := 'INVENTORY_VALUATION';
136712 l_component_type_code := 'S';
136713 l_component_appl_id := 707;
136714 l_amb_context_code := 'DEFAULT';
136715 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
136716 l_event_class_code := 'USER_DEFINE';
136717 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
136718 l_line_definition_owner_code := 'S';
136719 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
136720 --
136721 l_balance_type_code := 'A';
136722 l_segment := NULL;
136723 l_ccid := NULL;
136724 l_adr_transaction_coa_id := NULL;
136725 l_adr_accounting_coa_id := NULL;
136726 l_adr_flexfield_segment_code := NULL;
136727 l_adr_flex_value_set_id := NULL;
136728 l_adr_value_type_code := NULL;
136729 l_adr_value_combination_id := NULL;
136730 l_adr_value_segment_code := NULL;
136731
136732 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
136733 l_bflow_class_code := ''; -- 4219869 Business Flow
136734 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
136735 l_budgetary_control_flag := 'N';
136736
136737 l_bflow_applied_to_amt_idx := NULL; -- 5132302
136738 l_bflow_applied_to_amt := NULL; -- 5132302
136739 l_entered_amt_idx := NULL; -- 4262811
136740 l_accted_amt_idx := NULL; -- 4262811
136741 l_acc_rev_flag := NULL; -- 4262811
136742 l_accrual_line_num := NULL; -- 4262811
136743 l_tmp_amt := NULL; -- 4262811
136744 --
136745
136746 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
136747 l_balance_type_code <> 'B' THEN
136748 IF NVL(p_source_97,9E125) = 1
136749 THEN
136750
136751 --
136752 XLA_AE_LINES_PKG.SetNewLine;
136753
136754 p_balance_type_code := l_balance_type_code;
136755 -- set the flag so later we will know whether the gain loss line needs to be created
136756
136757 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
136758 p_actual_flag :='A';
136759 END IF;
136760
136761 --
136762 -- bulk performance
136763 --
136764 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
136765 p_header_num => 0); -- 4262811
136766 --
136767 -- set accounting line options
136768 --
136769 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
136770 p_natural_side_code => 'D'
136771 , p_gain_or_loss_flag => 'N'
136772 , p_gl_transfer_mode_code => 'S'
136773 , p_acct_entry_type_code => 'A'
136774 , p_switch_side_flag => 'Y'
136775 , p_merge_duplicate_code => 'N'
136776 );
136777 --
136778 l_acc_rev_natural_side_code := 'C'; -- 4262811
136779 --
136780 --
136781 -- set accounting line type info
136782 --
136783 xla_ae_lines_pkg.SetAcctLineType
136784 (p_component_type => l_component_type
136785 ,p_event_type_code => l_event_type_code
136786 ,p_line_definition_owner_code => l_line_definition_owner_code
136787 ,p_line_definition_code => l_line_definition_code
136788 ,p_accounting_line_code => l_component_code
136789 ,p_accounting_line_type_code => l_component_type_code
136790 ,p_accounting_line_appl_id => l_component_appl_id
136791 ,p_amb_context_code => l_amb_context_code
136792 ,p_entity_code => l_entity_code
136793 ,p_event_class_code => l_event_class_code);
136794 --
136795 -- set accounting class
136796 --
136797 xla_ae_lines_pkg.SetAcctClass(
136798 p_accounting_class_code => 'INVENTORY_VALUATION'
136799 , p_ae_header_id => l_ae_header_id
136800 );
136801
136802 --
136803 -- set rounding class
136804 --
136805 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
136806 'INVENTORY_VALUATION';
136807
136808 --
136809 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
136810 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
136811 --
136812 -- bulk performance
136813 --
136814 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
136815
136816 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
136817 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
136818
136819 -- 4955764
136820 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
136821 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
136822
136823 -- 4458381 Public Sector Enh
136824
136825 --
136826 -- set accounting attributes for the line type
136827 --
136828 l_entered_amt_idx := 3;
136829 l_accted_amt_idx := 8;
136830 l_bflow_applied_to_amt_idx := NULL; -- 5132302
136831 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
136832 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
136833 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
136834 l_rec_acct_attrs.array_char_value(2) := p_source_85;
136835 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
136836 l_rec_acct_attrs.array_num_value(3) := p_source_91;
136837 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
136838 l_rec_acct_attrs.array_char_value(4) := p_source_88;
136839 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
136840 l_rec_acct_attrs.array_date_value(5) := p_source_92;
136841 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
136842 l_rec_acct_attrs.array_num_value(6) := p_source_93;
136843 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
136844 l_rec_acct_attrs.array_char_value(7) := p_source_94;
136845 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
136846 l_rec_acct_attrs.array_num_value(8) := p_source_95;
136847
136848 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
136849 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
136850
136851 ---------------------------------------------------------------------------------------------------------------
136852 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
136853 ---------------------------------------------------------------------------------------------------------------
136854 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
136855
136856 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
136857 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
136858
136859 IF xla_accounting_cache_pkg.GetValueChar
136860 (p_source_code => 'LEDGER_CATEGORY_CODE'
136861 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
136862 AND l_bflow_method_code = 'PRIOR_ENTRY'
136863 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
136864 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
136865 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
136866 )
136867 THEN
136868 xla_ae_lines_pkg.BflowUpgEntry
136869 (p_business_method_code => l_bflow_method_code
136870 ,p_business_class_code => l_bflow_class_code
136871 ,p_balance_type => l_balance_type_code);
136872 ELSE
136873 NULL;
136874 -- No business flow processing for business flow method of NONE.
136875 END IF;
136876
136877 --
136878 -- call analytical criteria
136879 --
136880
136881
136882 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
136883 xla_ae_lines_pkg.SetAnalyticalCriteria(
136884 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
136885 , p_analytical_criterion_owner => 'S'
136886 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
136887 , p_amb_context_code => 'DEFAULT'
136888 , p_balancing_flag => 'Y'
136889
136890 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
136891 , p_analytical_detail_num_1 => NULL
136892 , p_analytical_detail_date_1 => NULL
136893
136894 , p_ae_header_id => l_ae_header_id
136895 )
136896 ;
136897 --
136898
136899 --
136900 -- call description
136901 --
136902
136903 xla_ae_lines_pkg.SetLineDescription(
136904 p_ae_header_id => l_ae_header_id
136905 ,p_description => Description_1 (
136906 p_application_id => p_application_id
136907 , p_ae_header_id => l_ae_header_id
136908 , p_source_1 => p_source_1
136909 , p_source_2 => p_source_2
136910 , p_source_3 => p_source_3
136911 , p_source_4 => p_source_4
136912 , p_source_5 => p_source_5
136913 )
136914 );
136915
136916
136917 --
136918 -- call ADRs
136919 -- Bug 4922099
136920 --
136921 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
136922 (NVL(l_actual_upg_option, 'N') = 'O') OR
136923 (NVL(l_enc_upg_option, 'N') = 'O')
136924 )
136925 THEN
136926 NULL;
136927 --
136928 --
136929
136930 l_ccid := AcctDerRule_28(
136931 p_application_id => p_application_id
136932 , p_ae_header_id => l_ae_header_id
136933 , p_source_15 => p_source_15
136934 , p_source_41 => p_source_41
136935 , p_source_42 => p_source_42
136936 , p_source_43 => p_source_43
136937 , p_source_44 => p_source_44
136938 , p_source_45 => p_source_45
136939 , x_transaction_coa_id => l_adr_transaction_coa_id
136940 , x_accounting_coa_id => l_adr_accounting_coa_id
136941 , x_value_type_code => l_adr_value_type_code
136942 , p_side => 'NA'
136943 );
136944
136945 xla_ae_lines_pkg.set_ccid(
136946 p_code_combination_id => l_ccid
136947 , p_value_type_code => l_adr_value_type_code
136948 , p_transaction_coa_id => l_adr_transaction_coa_id
136949 , p_accounting_coa_id => l_adr_accounting_coa_id
136950 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
136951 , p_adr_type_code => 'S'
136952 , p_component_type => l_component_type
136953 , p_component_code => l_component_code
136954 , p_component_type_code => l_component_type_code
136955 , p_component_appl_id => l_component_appl_id
136956 , p_amb_context_code => l_amb_context_code
136957 , p_side => 'NA'
136958 );
136959
136960
136961 --
136962 --
136963 END IF;
136964 --
136965 -- Bug 4922099
136966 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
136967 (NVL(l_enc_upg_option, 'N') = 'O')
136968 ) AND
136969 (l_bflow_method_code = 'PRIOR_ENTRY')
136970 )
136971 THEN
136972 IF
136973 --
136974 1 = 2
136975 --
136976 THEN
136977 xla_accounting_err_pkg.build_message
136978 (p_appli_s_name => 'XLA'
136979 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
136980 ,p_token_1 => 'LINE_NUMBER'
136981 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
136982 ,p_token_2 => 'LINE_TYPE_NAME'
136983 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
136984 l_component_type
136985 ,l_component_code
136986 ,l_component_type_code
136987 ,l_component_appl_id
136988 ,l_amb_context_code
136989 ,l_entity_code
136990 ,l_event_class_code
136991 )
136992 ,p_token_3 => 'OWNER'
136993 ,p_value_3 => xla_lookups_pkg.get_meaning(
136994 p_lookup_type => 'XLA_OWNER_TYPE'
136995 ,p_lookup_code => l_component_type_code
136996 )
136997 ,p_token_4 => 'PRODUCT_NAME'
136998 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
136999 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
137000 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
137001 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
137002 ,p_ae_header_id => NULL
137003 );
137004
137005 IF (C_LEVEL_ERROR>= g_log_level) THEN
137006 trace
137007 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
137008 ,p_level => C_LEVEL_ERROR
137009 ,p_module => l_log_module);
137010 END IF;
137011 END IF;
137012 END IF;
137013 --
137014 --
137015 ------------------------------------------------------------------------------------------------
137016 -- 4219869 Business Flow
137017 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
137018 -- Prior Entry. Currently, the following code is always generated.
137019 ------------------------------------------------------------------------------------------------
137020 XLA_AE_LINES_PKG.ValidateCurrentLine;
137021
137022 ------------------------------------------------------------------------------------
137023 -- 4219869 Business Flow
137024 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
137025 ------------------------------------------------------------------------------------
137026 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
137027
137028 ----------------------------------------------------------------------------------
137029 -- 4219869 Business Flow
137030 -- Update journal entry status -- Need to generate this within IF <condition>
137031 ----------------------------------------------------------------------------------
137032 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
137033 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
137034 ,p_balance_type_code => l_balance_type_code
137035 );
137036
137037 -------------------------------------------------------------------------------------------
137038 -- 4262811 - Generate the Accrual Reversal lines
137039 -------------------------------------------------------------------------------------------
137040 BEGIN
137041 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
137042 (g_array_event(p_event_id).array_value_num('header_index'));
137043 IF l_acc_rev_flag IS NULL THEN
137044 l_acc_rev_flag := 'N';
137045 END IF;
137046 EXCEPTION
137047 WHEN OTHERS THEN
137048 l_acc_rev_flag := 'N';
137049 END;
137050 --
137051 IF (l_acc_rev_flag = 'Y') THEN
137052
137053 -- 4645092 ------------------------------------------------------------------------------
137054 -- To allow MPA report to determine if it should generate report process
137055 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
137056 ------------------------------------------------------------------------------------------
137057
137058 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
137059 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
137060 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
137061 -- call ADRs
137062 -- Bug 4922099
137063 --
137064 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
137065 (NVL(l_actual_upg_option, 'N') = 'O') OR
137066 (NVL(l_enc_upg_option, 'N') = 'O')
137067 )
137068 THEN
137069 NULL;
137070 --
137071 --
137072
137073 l_ccid := AcctDerRule_28(
137074 p_application_id => p_application_id
137075 , p_ae_header_id => l_ae_header_id
137076 , p_source_15 => p_source_15
137077 , p_source_41 => p_source_41
137078 , p_source_42 => p_source_42
137079 , p_source_43 => p_source_43
137080 , p_source_44 => p_source_44
137081 , p_source_45 => p_source_45
137082 , x_transaction_coa_id => l_adr_transaction_coa_id
137083 , x_accounting_coa_id => l_adr_accounting_coa_id
137084 , x_value_type_code => l_adr_value_type_code
137085 , p_side => 'NA'
137086 );
137087
137088 xla_ae_lines_pkg.set_ccid(
137089 p_code_combination_id => l_ccid
137090 , p_value_type_code => l_adr_value_type_code
137091 , p_transaction_coa_id => l_adr_transaction_coa_id
137092 , p_accounting_coa_id => l_adr_accounting_coa_id
137093 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
137094 , p_adr_type_code => 'S'
137095 , p_component_type => l_component_type
137096 , p_component_code => l_component_code
137097 , p_component_type_code => l_component_type_code
137098 , p_component_appl_id => l_component_appl_id
137099 , p_amb_context_code => l_amb_context_code
137100 , p_side => 'NA'
137101 );
137102
137103
137104 --
137105 --
137106 END IF;
137107
137108 --
137109 -- Update the line information that should be overwritten
137110 --
137111 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
137112 p_header_num => 1);
137113 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
137114
137115 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
137116
137117 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
137118 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
137119 END IF;
137120
137121 --
137122 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
137123 --
137124 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
137125 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
137126 ELSE
137127 ---------------------------------------------------------------------------------------------------
137128 -- 4262811a Switch Sign
137129 ---------------------------------------------------------------------------------------------------
137130 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
137131 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
137132 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137133 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
137134 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137135 -- 5132302
137136 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
137137 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137138
137139 END IF;
137140
137141 -- 4955764
137142 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
137143 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
137144
137145
137146 XLA_AE_LINES_PKG.ValidateCurrentLine;
137147 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
137148
137149 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
137150 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
137151 ,p_balance_type_code => l_balance_type_code);
137152
137153 END IF;
137154
137155 -----------------------------------------------------------------------------------------
137156 -- 4262811 Multiperiod Accounting
137157 -----------------------------------------------------------------------------------------
137158 -- No MPA option is assigned.
137159
137160
137161 END IF;
137162 END IF;
137163 --
137164
137165 --
137166 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
137167 trace
137168 (p_msg => 'END of AcctLineType_260'
137169 ,p_level => C_LEVEL_PROCEDURE
137170 ,p_module => l_log_module);
137171 END IF;
137172 --
137173 EXCEPTION
137174 WHEN xla_exceptions_pkg.application_exception THEN
137175 RAISE;
137176 WHEN OTHERS THEN
137177 xla_exceptions_pkg.raise_message
137178 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_260');
137179 END AcctLineType_260;
137180 --
137181
137182 ---------------------------------------
137183 --
137184 -- PRIVATE FUNCTION
137185 -- AcctLineType_261
137186 --
137187 ---------------------------------------
137188 PROCEDURE AcctLineType_261 (
137189 p_application_id IN NUMBER
137190 ,p_event_id IN NUMBER
137191 ,p_calculate_acctd_flag IN VARCHAR2
137192 ,p_calculate_g_l_flag IN VARCHAR2
137193 ,p_actual_flag IN OUT VARCHAR2
137194 ,p_balance_type_code OUT VARCHAR2
137195 ,p_gain_or_loss_ref OUT VARCHAR2
137196
137197 --TRANSACTION_ID
137198 , p_source_1 IN NUMBER
137199 --Item Concatenated Segments
137200 , p_source_2 IN VARCHAR2
137201 --Transaction Quantity
137202 , p_source_3 IN NUMBER
137203 --Transaction Unit of Measure Code
137204 , p_source_4 IN VARCHAR2
137205 --Inventory Transaction Type Description
137206 , p_source_5 IN VARCHAR2
137207 --Cost Element Name
137208 , p_source_15 IN NUMBER
137209 --Cost Group Identifier
137210 , p_source_26 IN NUMBER
137211 --INV Header Transfer Cost Group ID
137212 , p_source_27 IN NUMBER
137213 --INV Header Cost Group ID
137214 , p_source_28 IN NUMBER
137215 --Subinventory Name
137216 , p_source_29 IN VARCHAR2
137217 --INV Header Transfer Subinventory
137218 , p_source_31 IN VARCHAR2
137219 --Product Line Accounting Category Material Account
137220 , p_source_41 IN NUMBER
137221 --Product Line Accounting Category Material Overhead Account
137222 , p_source_42 IN NUMBER
137223 --Product Line Accounting Category Resource Account
137224 , p_source_43 IN NUMBER
137225 --Product Line Accounting Category Outside Processing Account
137226 , p_source_44 IN NUMBER
137227 --Product Line Accounting Category Overhead Account
137228 , p_source_45 IN NUMBER
137229 --Transfer to Subinventory or Cost Group category material account
137230 , p_source_48 IN NUMBER
137231 --Transfer to Subinventory or Cost Group category material overhead account
137232 , p_source_49 IN NUMBER
137233 --Transfer to Subinventory or Cost Group category resource account
137234 , p_source_50 IN NUMBER
137235 --Transfer to Subinventory or Cost Group category outside processing account
137236 , p_source_51 IN NUMBER
137237 --Transfer to Subinventory or Cost Group category overhead account
137238 , p_source_52 IN NUMBER
137239 --DISTRIBUTION_IDENTIFIER
137240 , p_source_84 IN NUMBER
137241 --Distribution Type
137242 , p_source_85 IN VARCHAR2
137243 , p_source_85_meaning IN VARCHAR2
137244 --Entered Currency Code
137245 , p_source_88 IN VARCHAR2
137246 --Entered Amount
137247 , p_source_91 IN NUMBER
137248 --Currency Conversion Date
137249 , p_source_92 IN DATE
137250 --Currency Conversion Rate
137251 , p_source_93 IN NUMBER
137252 --Currency Conversion Type
137253 , p_source_94 IN VARCHAR2
137254 --Accounted Amount
137255 , p_source_95 IN NUMBER
137256 --Accounting Line Type
137257 , p_source_97 IN NUMBER
137258 --Organization Code
137259 , p_source_108 IN VARCHAR2
137260 )
137261 IS
137262
137263 l_component_type VARCHAR2(80);
137264 l_component_code VARCHAR2(30);
137265 l_component_type_code VARCHAR2(1);
137266 l_component_appl_id INTEGER;
137267 l_amb_context_code VARCHAR2(30);
137268 l_entity_code VARCHAR2(30);
137269 l_event_class_code VARCHAR2(30);
137270 l_ae_header_id NUMBER;
137271 l_event_type_code VARCHAR2(30);
137272 l_line_definition_code VARCHAR2(30);
137273 l_line_definition_owner_code VARCHAR2(1);
137274 --
137275 -- adr variables
137276 l_segment VARCHAR2(30);
137277 l_ccid NUMBER;
137278 l_adr_transaction_coa_id NUMBER;
137279 l_adr_accounting_coa_id NUMBER;
137280 l_adr_flexfield_segment_code VARCHAR2(30);
137281 l_adr_flex_value_set_id NUMBER;
137282 l_adr_value_type_code VARCHAR2(30);
137283 l_adr_value_combination_id NUMBER;
137284 l_adr_value_segment_code VARCHAR2(30);
137285
137286 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
137287 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
137288 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
137289 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
137290
137291 -- 4262811 Variables ------------------------------------------------------------------------------------------
137292 l_entered_amt_idx NUMBER;
137293 l_accted_amt_idx NUMBER;
137294 l_acc_rev_flag VARCHAR2(1);
137295 l_accrual_line_num NUMBER;
137296 l_tmp_amt NUMBER;
137297 l_acc_rev_natural_side_code VARCHAR2(1);
137298
137299 l_num_entries NUMBER;
137300 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
137301 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
137302 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
137303 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
137304 l_recog_line_1 NUMBER;
137305 l_recog_line_2 NUMBER;
137306
137307 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
137308 l_bflow_applied_to_amt NUMBER; -- 5132302
137309 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
137310
137311 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
137312
137313 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
137314 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
137315
137316 ---------------------------------------------------------------------------------------------------------------
137317
137318
137319 --
137320 -- bulk performance
137321 --
137322 l_balance_type_code VARCHAR2(1);
137323 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
137324 l_log_module VARCHAR2(240);
137325
137326 --
137327 -- Upgrade strategy
137328 --
137329 l_actual_upg_option VARCHAR2(1);
137330 l_enc_upg_option VARCHAR2(1);
137331
137332 --
137333 BEGIN
137334 --
137335 IF g_log_enabled THEN
137336 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_261';
137337 END IF;
137338 --
137339 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
137340
137341 trace
137342 (p_msg => 'BEGIN of AcctLineType_261'
137343 ,p_level => C_LEVEL_PROCEDURE
137344 ,p_module => l_log_module);
137345
137346 END IF;
137347 --
137348 l_component_type := 'AMB_JLT';
137349 l_component_code := 'INVENTORY_VALUATION';
137350 l_component_type_code := 'S';
137351 l_component_appl_id := 707;
137352 l_amb_context_code := 'DEFAULT';
137353 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
137354 l_event_class_code := 'USER_DEFINE';
137355 l_event_type_code := 'USUB_TXFR';
137356 l_line_definition_owner_code := 'S';
137357 l_line_definition_code := 'PI_INTRAORG_TXFR';
137358 --
137359 l_balance_type_code := 'A';
137360 l_segment := NULL;
137361 l_ccid := NULL;
137362 l_adr_transaction_coa_id := NULL;
137363 l_adr_accounting_coa_id := NULL;
137364 l_adr_flexfield_segment_code := NULL;
137365 l_adr_flex_value_set_id := NULL;
137366 l_adr_value_type_code := NULL;
137367 l_adr_value_combination_id := NULL;
137368 l_adr_value_segment_code := NULL;
137369
137370 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
137371 l_bflow_class_code := ''; -- 4219869 Business Flow
137372 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
137373 l_budgetary_control_flag := 'N';
137374
137375 l_bflow_applied_to_amt_idx := NULL; -- 5132302
137376 l_bflow_applied_to_amt := NULL; -- 5132302
137377 l_entered_amt_idx := NULL; -- 4262811
137378 l_accted_amt_idx := NULL; -- 4262811
137379 l_acc_rev_flag := NULL; -- 4262811
137380 l_accrual_line_num := NULL; -- 4262811
137381 l_tmp_amt := NULL; -- 4262811
137382 --
137383
137384 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
137385 l_balance_type_code <> 'B' THEN
137386 IF NVL(p_source_97,9E125) = 1
137387 THEN
137388
137389 --
137390 XLA_AE_LINES_PKG.SetNewLine;
137391
137392 p_balance_type_code := l_balance_type_code;
137393 -- set the flag so later we will know whether the gain loss line needs to be created
137394
137395 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
137396 p_actual_flag :='A';
137397 END IF;
137398
137399 --
137400 -- bulk performance
137401 --
137402 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
137403 p_header_num => 0); -- 4262811
137404 --
137405 -- set accounting line options
137406 --
137407 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
137408 p_natural_side_code => 'D'
137409 , p_gain_or_loss_flag => 'N'
137410 , p_gl_transfer_mode_code => 'S'
137411 , p_acct_entry_type_code => 'A'
137412 , p_switch_side_flag => 'Y'
137413 , p_merge_duplicate_code => 'N'
137414 );
137415 --
137416 l_acc_rev_natural_side_code := 'C'; -- 4262811
137417 --
137418 --
137419 -- set accounting line type info
137420 --
137421 xla_ae_lines_pkg.SetAcctLineType
137422 (p_component_type => l_component_type
137423 ,p_event_type_code => l_event_type_code
137424 ,p_line_definition_owner_code => l_line_definition_owner_code
137425 ,p_line_definition_code => l_line_definition_code
137426 ,p_accounting_line_code => l_component_code
137427 ,p_accounting_line_type_code => l_component_type_code
137428 ,p_accounting_line_appl_id => l_component_appl_id
137429 ,p_amb_context_code => l_amb_context_code
137430 ,p_entity_code => l_entity_code
137431 ,p_event_class_code => l_event_class_code);
137432 --
137433 -- set accounting class
137434 --
137435 xla_ae_lines_pkg.SetAcctClass(
137436 p_accounting_class_code => 'INVENTORY_VALUATION'
137437 , p_ae_header_id => l_ae_header_id
137438 );
137439
137440 --
137441 -- set rounding class
137442 --
137443 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
137444 'INVENTORY_VALUATION';
137445
137446 --
137447 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
137448 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
137449 --
137450 -- bulk performance
137451 --
137452 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
137453
137454 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
137455 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
137456
137457 -- 4955764
137458 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
137459 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
137460
137461 -- 4458381 Public Sector Enh
137462
137463 --
137464 -- set accounting attributes for the line type
137465 --
137466 l_entered_amt_idx := 3;
137467 l_accted_amt_idx := 8;
137468 l_bflow_applied_to_amt_idx := NULL; -- 5132302
137469 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
137470 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
137471 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
137472 l_rec_acct_attrs.array_char_value(2) := p_source_85;
137473 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
137474 l_rec_acct_attrs.array_num_value(3) := p_source_91;
137475 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
137476 l_rec_acct_attrs.array_char_value(4) := p_source_88;
137477 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
137478 l_rec_acct_attrs.array_date_value(5) := p_source_92;
137479 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
137480 l_rec_acct_attrs.array_num_value(6) := p_source_93;
137481 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
137482 l_rec_acct_attrs.array_char_value(7) := p_source_94;
137483 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
137484 l_rec_acct_attrs.array_num_value(8) := p_source_95;
137485
137486 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
137487 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
137488
137489 ---------------------------------------------------------------------------------------------------------------
137490 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
137491 ---------------------------------------------------------------------------------------------------------------
137492 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
137493
137494 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
137495 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
137496
137497 IF xla_accounting_cache_pkg.GetValueChar
137498 (p_source_code => 'LEDGER_CATEGORY_CODE'
137499 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
137500 AND l_bflow_method_code = 'PRIOR_ENTRY'
137501 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
137502 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
137503 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
137504 )
137505 THEN
137506 xla_ae_lines_pkg.BflowUpgEntry
137507 (p_business_method_code => l_bflow_method_code
137508 ,p_business_class_code => l_bflow_class_code
137509 ,p_balance_type => l_balance_type_code);
137510 ELSE
137511 NULL;
137512 -- No business flow processing for business flow method of NONE.
137513 END IF;
137514
137515 --
137516 -- call analytical criteria
137517 --
137518
137519
137520 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
137521 xla_ae_lines_pkg.SetAnalyticalCriteria(
137522 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
137523 , p_analytical_criterion_owner => 'S'
137524 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
137525 , p_amb_context_code => 'DEFAULT'
137526 , p_balancing_flag => 'Y'
137527
137528 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
137529 , p_analytical_detail_num_1 => NULL
137530 , p_analytical_detail_date_1 => NULL
137531
137532 , p_ae_header_id => l_ae_header_id
137533 )
137534 ;
137535 --
137536
137537 --
137538 -- call description
137539 --
137540
137541 xla_ae_lines_pkg.SetLineDescription(
137542 p_ae_header_id => l_ae_header_id
137543 ,p_description => Description_1 (
137544 p_application_id => p_application_id
137545 , p_ae_header_id => l_ae_header_id
137546 , p_source_1 => p_source_1
137547 , p_source_2 => p_source_2
137548 , p_source_3 => p_source_3
137549 , p_source_4 => p_source_4
137550 , p_source_5 => p_source_5
137551 )
137552 );
137553
137554
137555 --
137556 -- call ADRs
137557 -- Bug 4922099
137558 --
137559 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
137560 (NVL(l_actual_upg_option, 'N') = 'O') OR
137561 (NVL(l_enc_upg_option, 'N') = 'O')
137562 )
137563 THEN
137564 NULL;
137565 --
137566 --
137567
137568 l_ccid := AcctDerRule_29(
137569 p_application_id => p_application_id
137570 , p_ae_header_id => l_ae_header_id
137571 , p_source_15 => p_source_15
137572 , p_source_26 => p_source_26
137573 , p_source_27 => p_source_27
137574 , p_source_28 => p_source_28
137575 , p_source_29 => p_source_29
137576 , p_source_31 => p_source_31
137577 , p_source_41 => p_source_41
137578 , p_source_42 => p_source_42
137579 , p_source_43 => p_source_43
137580 , p_source_44 => p_source_44
137581 , p_source_45 => p_source_45
137582 , p_source_48 => p_source_48
137583 , p_source_49 => p_source_49
137584 , p_source_50 => p_source_50
137585 , p_source_51 => p_source_51
137586 , p_source_52 => p_source_52
137587 , x_transaction_coa_id => l_adr_transaction_coa_id
137588 , x_accounting_coa_id => l_adr_accounting_coa_id
137589 , x_value_type_code => l_adr_value_type_code
137590 , p_side => 'NA'
137591 );
137592
137593 xla_ae_lines_pkg.set_ccid(
137594 p_code_combination_id => l_ccid
137595 , p_value_type_code => l_adr_value_type_code
137596 , p_transaction_coa_id => l_adr_transaction_coa_id
137597 , p_accounting_coa_id => l_adr_accounting_coa_id
137598 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
137599 , p_adr_type_code => 'S'
137600 , p_component_type => l_component_type
137601 , p_component_code => l_component_code
137602 , p_component_type_code => l_component_type_code
137603 , p_component_appl_id => l_component_appl_id
137604 , p_amb_context_code => l_amb_context_code
137605 , p_side => 'NA'
137606 );
137607
137608
137609 --
137610 --
137611 END IF;
137612 --
137613 -- Bug 4922099
137614 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
137615 (NVL(l_enc_upg_option, 'N') = 'O')
137616 ) AND
137617 (l_bflow_method_code = 'PRIOR_ENTRY')
137618 )
137619 THEN
137620 IF
137621 --
137622 1 = 2
137623 --
137624 THEN
137625 xla_accounting_err_pkg.build_message
137626 (p_appli_s_name => 'XLA'
137627 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
137628 ,p_token_1 => 'LINE_NUMBER'
137629 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
137630 ,p_token_2 => 'LINE_TYPE_NAME'
137631 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
137632 l_component_type
137633 ,l_component_code
137634 ,l_component_type_code
137635 ,l_component_appl_id
137636 ,l_amb_context_code
137637 ,l_entity_code
137638 ,l_event_class_code
137639 )
137640 ,p_token_3 => 'OWNER'
137641 ,p_value_3 => xla_lookups_pkg.get_meaning(
137642 p_lookup_type => 'XLA_OWNER_TYPE'
137643 ,p_lookup_code => l_component_type_code
137644 )
137645 ,p_token_4 => 'PRODUCT_NAME'
137646 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
137647 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
137648 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
137649 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
137650 ,p_ae_header_id => NULL
137651 );
137652
137653 IF (C_LEVEL_ERROR>= g_log_level) THEN
137654 trace
137655 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
137656 ,p_level => C_LEVEL_ERROR
137657 ,p_module => l_log_module);
137658 END IF;
137659 END IF;
137660 END IF;
137661 --
137662 --
137663 ------------------------------------------------------------------------------------------------
137664 -- 4219869 Business Flow
137665 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
137666 -- Prior Entry. Currently, the following code is always generated.
137667 ------------------------------------------------------------------------------------------------
137668 XLA_AE_LINES_PKG.ValidateCurrentLine;
137669
137670 ------------------------------------------------------------------------------------
137671 -- 4219869 Business Flow
137672 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
137673 ------------------------------------------------------------------------------------
137674 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
137675
137676 ----------------------------------------------------------------------------------
137677 -- 4219869 Business Flow
137678 -- Update journal entry status -- Need to generate this within IF <condition>
137679 ----------------------------------------------------------------------------------
137680 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
137681 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
137682 ,p_balance_type_code => l_balance_type_code
137683 );
137684
137685 -------------------------------------------------------------------------------------------
137686 -- 4262811 - Generate the Accrual Reversal lines
137687 -------------------------------------------------------------------------------------------
137688 BEGIN
137689 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
137690 (g_array_event(p_event_id).array_value_num('header_index'));
137691 IF l_acc_rev_flag IS NULL THEN
137692 l_acc_rev_flag := 'N';
137693 END IF;
137694 EXCEPTION
137695 WHEN OTHERS THEN
137696 l_acc_rev_flag := 'N';
137697 END;
137698 --
137699 IF (l_acc_rev_flag = 'Y') THEN
137700
137701 -- 4645092 ------------------------------------------------------------------------------
137702 -- To allow MPA report to determine if it should generate report process
137703 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
137704 ------------------------------------------------------------------------------------------
137705
137706 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
137707 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
137708 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
137709 -- call ADRs
137710 -- Bug 4922099
137711 --
137712 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
137713 (NVL(l_actual_upg_option, 'N') = 'O') OR
137714 (NVL(l_enc_upg_option, 'N') = 'O')
137715 )
137716 THEN
137717 NULL;
137718 --
137719 --
137720
137721 l_ccid := AcctDerRule_29(
137722 p_application_id => p_application_id
137723 , p_ae_header_id => l_ae_header_id
137724 , p_source_15 => p_source_15
137725 , p_source_26 => p_source_26
137726 , p_source_27 => p_source_27
137727 , p_source_28 => p_source_28
137728 , p_source_29 => p_source_29
137729 , p_source_31 => p_source_31
137730 , p_source_41 => p_source_41
137731 , p_source_42 => p_source_42
137732 , p_source_43 => p_source_43
137733 , p_source_44 => p_source_44
137734 , p_source_45 => p_source_45
137735 , p_source_48 => p_source_48
137736 , p_source_49 => p_source_49
137737 , p_source_50 => p_source_50
137738 , p_source_51 => p_source_51
137739 , p_source_52 => p_source_52
137740 , x_transaction_coa_id => l_adr_transaction_coa_id
137741 , x_accounting_coa_id => l_adr_accounting_coa_id
137742 , x_value_type_code => l_adr_value_type_code
137743 , p_side => 'NA'
137744 );
137745
137746 xla_ae_lines_pkg.set_ccid(
137747 p_code_combination_id => l_ccid
137748 , p_value_type_code => l_adr_value_type_code
137749 , p_transaction_coa_id => l_adr_transaction_coa_id
137750 , p_accounting_coa_id => l_adr_accounting_coa_id
137751 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
137752 , p_adr_type_code => 'S'
137753 , p_component_type => l_component_type
137754 , p_component_code => l_component_code
137755 , p_component_type_code => l_component_type_code
137756 , p_component_appl_id => l_component_appl_id
137757 , p_amb_context_code => l_amb_context_code
137758 , p_side => 'NA'
137759 );
137760
137761
137762 --
137763 --
137764 END IF;
137765
137766 --
137767 -- Update the line information that should be overwritten
137768 --
137769 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
137770 p_header_num => 1);
137771 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
137772
137773 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
137774
137775 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
137776 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
137777 END IF;
137778
137779 --
137780 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
137781 --
137782 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
137783 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
137784 ELSE
137785 ---------------------------------------------------------------------------------------------------
137786 -- 4262811a Switch Sign
137787 ---------------------------------------------------------------------------------------------------
137788 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
137789 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
137790 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137791 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
137792 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137793 -- 5132302
137794 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
137795 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
137796
137797 END IF;
137798
137799 -- 4955764
137800 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
137801 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
137802
137803
137804 XLA_AE_LINES_PKG.ValidateCurrentLine;
137805 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
137806
137807 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
137808 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
137809 ,p_balance_type_code => l_balance_type_code);
137810
137811 END IF;
137812
137813 -----------------------------------------------------------------------------------------
137814 -- 4262811 Multiperiod Accounting
137815 -----------------------------------------------------------------------------------------
137816 -- No MPA option is assigned.
137817
137818
137819 END IF;
137820 END IF;
137821 --
137822
137823 --
137824 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
137825 trace
137826 (p_msg => 'END of AcctLineType_261'
137827 ,p_level => C_LEVEL_PROCEDURE
137828 ,p_module => l_log_module);
137829 END IF;
137830 --
137831 EXCEPTION
137832 WHEN xla_exceptions_pkg.application_exception THEN
137833 RAISE;
137834 WHEN OTHERS THEN
137835 xla_exceptions_pkg.raise_message
137836 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_261');
137837 END AcctLineType_261;
137838 --
137839
137840 ---------------------------------------
137841 --
137842 -- PRIVATE FUNCTION
137843 -- AcctLineType_262
137844 --
137845 ---------------------------------------
137846 PROCEDURE AcctLineType_262 (
137847 p_application_id IN NUMBER
137848 ,p_event_id IN NUMBER
137849 ,p_calculate_acctd_flag IN VARCHAR2
137850 ,p_calculate_g_l_flag IN VARCHAR2
137851 ,p_actual_flag IN OUT VARCHAR2
137852 ,p_balance_type_code OUT VARCHAR2
137853 ,p_gain_or_loss_ref OUT VARCHAR2
137854
137855 --TRANSACTION_ID
137856 , p_source_1 IN NUMBER
137857 --Item Concatenated Segments
137858 , p_source_2 IN VARCHAR2
137859 --Transaction Quantity
137860 , p_source_3 IN NUMBER
137861 --Transaction Unit of Measure Code
137862 , p_source_4 IN VARCHAR2
137863 --Inventory Transaction Type Description
137864 , p_source_5 IN VARCHAR2
137865 --Cost Element Name
137866 , p_source_15 IN NUMBER
137867 --Product Line Accounting Category Material Account
137868 , p_source_41 IN NUMBER
137869 --Product Line Accounting Category Material Overhead Account
137870 , p_source_42 IN NUMBER
137871 --Product Line Accounting Category Resource Account
137872 , p_source_43 IN NUMBER
137873 --Product Line Accounting Category Outside Processing Account
137874 , p_source_44 IN NUMBER
137875 --Product Line Accounting Category Overhead Account
137876 , p_source_45 IN NUMBER
137877 --DISTRIBUTION_IDENTIFIER
137878 , p_source_84 IN NUMBER
137879 --Distribution Type
137880 , p_source_85 IN VARCHAR2
137881 , p_source_85_meaning IN VARCHAR2
137882 --Entered Currency Code
137883 , p_source_88 IN VARCHAR2
137884 --Entered Amount
137885 , p_source_91 IN NUMBER
137886 --Currency Conversion Date
137887 , p_source_92 IN DATE
137888 --Currency Conversion Rate
137889 , p_source_93 IN NUMBER
137890 --Currency Conversion Type
137891 , p_source_94 IN VARCHAR2
137892 --Accounted Amount
137893 , p_source_95 IN NUMBER
137894 --Accounting Line Type
137895 , p_source_97 IN NUMBER
137896 --Organization Code
137897 , p_source_108 IN VARCHAR2
137898 )
137899 IS
137900
137901 l_component_type VARCHAR2(80);
137902 l_component_code VARCHAR2(30);
137903 l_component_type_code VARCHAR2(1);
137904 l_component_appl_id INTEGER;
137905 l_amb_context_code VARCHAR2(30);
137906 l_entity_code VARCHAR2(30);
137907 l_event_class_code VARCHAR2(30);
137908 l_ae_header_id NUMBER;
137909 l_event_type_code VARCHAR2(30);
137910 l_line_definition_code VARCHAR2(30);
137911 l_line_definition_owner_code VARCHAR2(1);
137912 --
137913 -- adr variables
137914 l_segment VARCHAR2(30);
137915 l_ccid NUMBER;
137916 l_adr_transaction_coa_id NUMBER;
137917 l_adr_accounting_coa_id NUMBER;
137918 l_adr_flexfield_segment_code VARCHAR2(30);
137919 l_adr_flex_value_set_id NUMBER;
137920 l_adr_value_type_code VARCHAR2(30);
137921 l_adr_value_combination_id NUMBER;
137922 l_adr_value_segment_code VARCHAR2(30);
137923
137924 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
137925 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
137926 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
137927 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
137928
137929 -- 4262811 Variables ------------------------------------------------------------------------------------------
137930 l_entered_amt_idx NUMBER;
137931 l_accted_amt_idx NUMBER;
137932 l_acc_rev_flag VARCHAR2(1);
137933 l_accrual_line_num NUMBER;
137934 l_tmp_amt NUMBER;
137935 l_acc_rev_natural_side_code VARCHAR2(1);
137936
137937 l_num_entries NUMBER;
137938 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
137939 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
137940 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
137941 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
137942 l_recog_line_1 NUMBER;
137943 l_recog_line_2 NUMBER;
137944
137945 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
137946 l_bflow_applied_to_amt NUMBER; -- 5132302
137947 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
137948
137949 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
137950
137951 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
137952 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
137953
137954 ---------------------------------------------------------------------------------------------------------------
137955
137956
137957 --
137958 -- bulk performance
137959 --
137960 l_balance_type_code VARCHAR2(1);
137961 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
137962 l_log_module VARCHAR2(240);
137963
137964 --
137965 -- Upgrade strategy
137966 --
137967 l_actual_upg_option VARCHAR2(1);
137968 l_enc_upg_option VARCHAR2(1);
137969
137970 --
137971 BEGIN
137972 --
137973 IF g_log_enabled THEN
137974 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_262';
137975 END IF;
137976 --
137977 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
137978
137979 trace
137980 (p_msg => 'BEGIN of AcctLineType_262'
137981 ,p_level => C_LEVEL_PROCEDURE
137982 ,p_module => l_log_module);
137983
137984 END IF;
137985 --
137986 l_component_type := 'AMB_JLT';
137987 l_component_code := 'INVENTORY_VALUATION';
137988 l_component_type_code := 'S';
137989 l_component_appl_id := 707;
137990 l_amb_context_code := 'DEFAULT';
137991 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
137992 l_event_class_code := 'WIP_MTL';
137993 l_event_type_code := 'WIP_ASSEMBLY_RETURN';
137994 l_line_definition_owner_code := 'S';
137995 l_line_definition_code := 'PI_WIP_ASSEMBLY_RETURN';
137996 --
137997 l_balance_type_code := 'A';
137998 l_segment := NULL;
137999 l_ccid := NULL;
138000 l_adr_transaction_coa_id := NULL;
138001 l_adr_accounting_coa_id := NULL;
138002 l_adr_flexfield_segment_code := NULL;
138003 l_adr_flex_value_set_id := NULL;
138004 l_adr_value_type_code := NULL;
138005 l_adr_value_combination_id := NULL;
138006 l_adr_value_segment_code := NULL;
138007
138008 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
138009 l_bflow_class_code := ''; -- 4219869 Business Flow
138010 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
138011 l_budgetary_control_flag := 'N';
138012
138013 l_bflow_applied_to_amt_idx := NULL; -- 5132302
138014 l_bflow_applied_to_amt := NULL; -- 5132302
138015 l_entered_amt_idx := NULL; -- 4262811
138016 l_accted_amt_idx := NULL; -- 4262811
138017 l_acc_rev_flag := NULL; -- 4262811
138018 l_accrual_line_num := NULL; -- 4262811
138019 l_tmp_amt := NULL; -- 4262811
138020 --
138021
138022 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
138023 l_balance_type_code <> 'B' THEN
138024 IF NVL(p_source_97,9E125) = 1
138025 THEN
138026
138027 --
138028 XLA_AE_LINES_PKG.SetNewLine;
138029
138030 p_balance_type_code := l_balance_type_code;
138031 -- set the flag so later we will know whether the gain loss line needs to be created
138032
138033 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
138034 p_actual_flag :='A';
138035 END IF;
138036
138037 --
138038 -- bulk performance
138039 --
138040 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
138041 p_header_num => 0); -- 4262811
138042 --
138043 -- set accounting line options
138044 --
138045 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
138046 p_natural_side_code => 'D'
138047 , p_gain_or_loss_flag => 'N'
138048 , p_gl_transfer_mode_code => 'S'
138049 , p_acct_entry_type_code => 'A'
138050 , p_switch_side_flag => 'Y'
138051 , p_merge_duplicate_code => 'N'
138052 );
138053 --
138054 l_acc_rev_natural_side_code := 'C'; -- 4262811
138055 --
138056 --
138057 -- set accounting line type info
138058 --
138059 xla_ae_lines_pkg.SetAcctLineType
138060 (p_component_type => l_component_type
138061 ,p_event_type_code => l_event_type_code
138062 ,p_line_definition_owner_code => l_line_definition_owner_code
138063 ,p_line_definition_code => l_line_definition_code
138064 ,p_accounting_line_code => l_component_code
138065 ,p_accounting_line_type_code => l_component_type_code
138066 ,p_accounting_line_appl_id => l_component_appl_id
138067 ,p_amb_context_code => l_amb_context_code
138068 ,p_entity_code => l_entity_code
138069 ,p_event_class_code => l_event_class_code);
138070 --
138071 -- set accounting class
138072 --
138073 xla_ae_lines_pkg.SetAcctClass(
138074 p_accounting_class_code => 'INVENTORY_VALUATION'
138075 , p_ae_header_id => l_ae_header_id
138076 );
138077
138078 --
138079 -- set rounding class
138080 --
138081 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
138082 'INVENTORY_VALUATION';
138083
138084 --
138085 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
138086 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
138087 --
138088 -- bulk performance
138089 --
138090 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
138091
138092 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
138093 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
138094
138095 -- 4955764
138096 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
138097 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
138098
138099 -- 4458381 Public Sector Enh
138100
138101 --
138102 -- set accounting attributes for the line type
138103 --
138104 l_entered_amt_idx := 3;
138105 l_accted_amt_idx := 8;
138106 l_bflow_applied_to_amt_idx := NULL; -- 5132302
138107 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
138108 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
138109 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
138110 l_rec_acct_attrs.array_char_value(2) := p_source_85;
138111 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
138112 l_rec_acct_attrs.array_num_value(3) := p_source_91;
138113 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
138114 l_rec_acct_attrs.array_char_value(4) := p_source_88;
138115 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
138116 l_rec_acct_attrs.array_date_value(5) := p_source_92;
138117 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
138118 l_rec_acct_attrs.array_num_value(6) := p_source_93;
138119 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
138120 l_rec_acct_attrs.array_char_value(7) := p_source_94;
138121 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
138122 l_rec_acct_attrs.array_num_value(8) := p_source_95;
138123
138124 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
138125 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
138126
138127 ---------------------------------------------------------------------------------------------------------------
138128 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
138129 ---------------------------------------------------------------------------------------------------------------
138130 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
138131
138132 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
138133 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
138134
138135 IF xla_accounting_cache_pkg.GetValueChar
138136 (p_source_code => 'LEDGER_CATEGORY_CODE'
138137 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
138138 AND l_bflow_method_code = 'PRIOR_ENTRY'
138139 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
138140 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
138141 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
138142 )
138143 THEN
138144 xla_ae_lines_pkg.BflowUpgEntry
138145 (p_business_method_code => l_bflow_method_code
138146 ,p_business_class_code => l_bflow_class_code
138147 ,p_balance_type => l_balance_type_code);
138148 ELSE
138149 NULL;
138150 -- No business flow processing for business flow method of NONE.
138151 END IF;
138152
138153 --
138154 -- call analytical criteria
138155 --
138156
138157
138158 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
138159 xla_ae_lines_pkg.SetAnalyticalCriteria(
138160 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
138161 , p_analytical_criterion_owner => 'S'
138162 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
138163 , p_amb_context_code => 'DEFAULT'
138164 , p_balancing_flag => 'Y'
138165
138166 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
138167 , p_analytical_detail_num_1 => NULL
138168 , p_analytical_detail_date_1 => NULL
138169
138170 , p_ae_header_id => l_ae_header_id
138171 )
138172 ;
138173 --
138174
138175 --
138176 -- call description
138177 --
138178
138179 xla_ae_lines_pkg.SetLineDescription(
138180 p_ae_header_id => l_ae_header_id
138181 ,p_description => Description_1 (
138182 p_application_id => p_application_id
138183 , p_ae_header_id => l_ae_header_id
138184 , p_source_1 => p_source_1
138185 , p_source_2 => p_source_2
138186 , p_source_3 => p_source_3
138187 , p_source_4 => p_source_4
138188 , p_source_5 => p_source_5
138189 )
138190 );
138191
138192
138193 --
138194 -- call ADRs
138195 -- Bug 4922099
138196 --
138197 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
138198 (NVL(l_actual_upg_option, 'N') = 'O') OR
138199 (NVL(l_enc_upg_option, 'N') = 'O')
138200 )
138201 THEN
138202 NULL;
138203 --
138204 --
138205
138206 l_ccid := AcctDerRule_28(
138207 p_application_id => p_application_id
138208 , p_ae_header_id => l_ae_header_id
138209 , p_source_15 => p_source_15
138210 , p_source_41 => p_source_41
138211 , p_source_42 => p_source_42
138212 , p_source_43 => p_source_43
138213 , p_source_44 => p_source_44
138214 , p_source_45 => p_source_45
138215 , x_transaction_coa_id => l_adr_transaction_coa_id
138216 , x_accounting_coa_id => l_adr_accounting_coa_id
138217 , x_value_type_code => l_adr_value_type_code
138218 , p_side => 'NA'
138219 );
138220
138221 xla_ae_lines_pkg.set_ccid(
138222 p_code_combination_id => l_ccid
138223 , p_value_type_code => l_adr_value_type_code
138224 , p_transaction_coa_id => l_adr_transaction_coa_id
138225 , p_accounting_coa_id => l_adr_accounting_coa_id
138226 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
138227 , p_adr_type_code => 'S'
138228 , p_component_type => l_component_type
138229 , p_component_code => l_component_code
138230 , p_component_type_code => l_component_type_code
138231 , p_component_appl_id => l_component_appl_id
138232 , p_amb_context_code => l_amb_context_code
138233 , p_side => 'NA'
138234 );
138235
138236
138237 --
138238 --
138239 END IF;
138240 --
138241 -- Bug 4922099
138242 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
138243 (NVL(l_enc_upg_option, 'N') = 'O')
138244 ) AND
138245 (l_bflow_method_code = 'PRIOR_ENTRY')
138246 )
138247 THEN
138248 IF
138249 --
138250 1 = 2
138251 --
138252 THEN
138253 xla_accounting_err_pkg.build_message
138254 (p_appli_s_name => 'XLA'
138255 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
138256 ,p_token_1 => 'LINE_NUMBER'
138257 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
138258 ,p_token_2 => 'LINE_TYPE_NAME'
138259 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
138260 l_component_type
138261 ,l_component_code
138262 ,l_component_type_code
138263 ,l_component_appl_id
138264 ,l_amb_context_code
138265 ,l_entity_code
138266 ,l_event_class_code
138267 )
138268 ,p_token_3 => 'OWNER'
138269 ,p_value_3 => xla_lookups_pkg.get_meaning(
138270 p_lookup_type => 'XLA_OWNER_TYPE'
138271 ,p_lookup_code => l_component_type_code
138272 )
138273 ,p_token_4 => 'PRODUCT_NAME'
138274 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
138275 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
138276 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
138277 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
138278 ,p_ae_header_id => NULL
138279 );
138280
138281 IF (C_LEVEL_ERROR>= g_log_level) THEN
138282 trace
138283 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
138284 ,p_level => C_LEVEL_ERROR
138285 ,p_module => l_log_module);
138286 END IF;
138287 END IF;
138288 END IF;
138289 --
138290 --
138291 ------------------------------------------------------------------------------------------------
138292 -- 4219869 Business Flow
138293 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
138294 -- Prior Entry. Currently, the following code is always generated.
138295 ------------------------------------------------------------------------------------------------
138296 XLA_AE_LINES_PKG.ValidateCurrentLine;
138297
138298 ------------------------------------------------------------------------------------
138299 -- 4219869 Business Flow
138300 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
138301 ------------------------------------------------------------------------------------
138302 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
138303
138304 ----------------------------------------------------------------------------------
138305 -- 4219869 Business Flow
138306 -- Update journal entry status -- Need to generate this within IF <condition>
138307 ----------------------------------------------------------------------------------
138308 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
138309 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
138310 ,p_balance_type_code => l_balance_type_code
138311 );
138312
138313 -------------------------------------------------------------------------------------------
138314 -- 4262811 - Generate the Accrual Reversal lines
138315 -------------------------------------------------------------------------------------------
138316 BEGIN
138317 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
138318 (g_array_event(p_event_id).array_value_num('header_index'));
138319 IF l_acc_rev_flag IS NULL THEN
138320 l_acc_rev_flag := 'N';
138321 END IF;
138322 EXCEPTION
138323 WHEN OTHERS THEN
138324 l_acc_rev_flag := 'N';
138325 END;
138326 --
138327 IF (l_acc_rev_flag = 'Y') THEN
138328
138329 -- 4645092 ------------------------------------------------------------------------------
138330 -- To allow MPA report to determine if it should generate report process
138331 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
138332 ------------------------------------------------------------------------------------------
138333
138334 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
138335 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
138336 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
138337 -- call ADRs
138338 -- Bug 4922099
138339 --
138340 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
138341 (NVL(l_actual_upg_option, 'N') = 'O') OR
138342 (NVL(l_enc_upg_option, 'N') = 'O')
138343 )
138344 THEN
138345 NULL;
138346 --
138347 --
138348
138349 l_ccid := AcctDerRule_28(
138350 p_application_id => p_application_id
138351 , p_ae_header_id => l_ae_header_id
138352 , p_source_15 => p_source_15
138353 , p_source_41 => p_source_41
138354 , p_source_42 => p_source_42
138355 , p_source_43 => p_source_43
138356 , p_source_44 => p_source_44
138357 , p_source_45 => p_source_45
138358 , x_transaction_coa_id => l_adr_transaction_coa_id
138359 , x_accounting_coa_id => l_adr_accounting_coa_id
138360 , x_value_type_code => l_adr_value_type_code
138361 , p_side => 'NA'
138362 );
138363
138364 xla_ae_lines_pkg.set_ccid(
138365 p_code_combination_id => l_ccid
138366 , p_value_type_code => l_adr_value_type_code
138367 , p_transaction_coa_id => l_adr_transaction_coa_id
138368 , p_accounting_coa_id => l_adr_accounting_coa_id
138369 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
138370 , p_adr_type_code => 'S'
138371 , p_component_type => l_component_type
138372 , p_component_code => l_component_code
138373 , p_component_type_code => l_component_type_code
138374 , p_component_appl_id => l_component_appl_id
138375 , p_amb_context_code => l_amb_context_code
138376 , p_side => 'NA'
138377 );
138378
138379
138380 --
138381 --
138382 END IF;
138383
138384 --
138385 -- Update the line information that should be overwritten
138386 --
138387 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
138388 p_header_num => 1);
138389 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
138390
138391 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
138392
138393 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
138394 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
138395 END IF;
138396
138397 --
138398 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
138399 --
138400 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
138401 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
138402 ELSE
138403 ---------------------------------------------------------------------------------------------------
138404 -- 4262811a Switch Sign
138405 ---------------------------------------------------------------------------------------------------
138406 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
138407 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
138408 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
138409 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
138410 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
138411 -- 5132302
138412 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
138413 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
138414
138415 END IF;
138416
138417 -- 4955764
138418 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
138419 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
138420
138421
138422 XLA_AE_LINES_PKG.ValidateCurrentLine;
138423 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
138424
138425 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
138426 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
138427 ,p_balance_type_code => l_balance_type_code);
138428
138429 END IF;
138430
138431 -----------------------------------------------------------------------------------------
138432 -- 4262811 Multiperiod Accounting
138433 -----------------------------------------------------------------------------------------
138434 -- No MPA option is assigned.
138435
138436
138437 END IF;
138438 END IF;
138439 --
138440
138441 --
138442 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
138443 trace
138444 (p_msg => 'END of AcctLineType_262'
138445 ,p_level => C_LEVEL_PROCEDURE
138446 ,p_module => l_log_module);
138447 END IF;
138448 --
138449 EXCEPTION
138450 WHEN xla_exceptions_pkg.application_exception THEN
138451 RAISE;
138452 WHEN OTHERS THEN
138453 xla_exceptions_pkg.raise_message
138454 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_262');
138455 END AcctLineType_262;
138456 --
138457
138458 ---------------------------------------
138459 --
138460 -- PRIVATE FUNCTION
138461 -- AcctLineType_263
138462 --
138463 ---------------------------------------
138464 PROCEDURE AcctLineType_263 (
138465 p_application_id IN NUMBER
138466 ,p_event_id IN NUMBER
138467 ,p_calculate_acctd_flag IN VARCHAR2
138468 ,p_calculate_g_l_flag IN VARCHAR2
138469 ,p_actual_flag IN OUT VARCHAR2
138470 ,p_balance_type_code OUT VARCHAR2
138471 ,p_gain_or_loss_ref OUT VARCHAR2
138472
138473 --TRANSACTION_ID
138474 , p_source_1 IN NUMBER
138475 --Item Concatenated Segments
138476 , p_source_2 IN VARCHAR2
138477 --Transaction Quantity
138478 , p_source_3 IN NUMBER
138479 --Transaction Unit of Measure Code
138480 , p_source_4 IN VARCHAR2
138481 --Inventory Transaction Type Description
138482 , p_source_5 IN VARCHAR2
138483 --Cost Element Name
138484 , p_source_15 IN NUMBER
138485 --Product Line Accounting Category Material Account
138486 , p_source_41 IN NUMBER
138487 --Product Line Accounting Category Material Overhead Account
138488 , p_source_42 IN NUMBER
138489 --Product Line Accounting Category Resource Account
138490 , p_source_43 IN NUMBER
138491 --Product Line Accounting Category Outside Processing Account
138492 , p_source_44 IN NUMBER
138493 --Product Line Accounting Category Overhead Account
138494 , p_source_45 IN NUMBER
138495 --DISTRIBUTION_IDENTIFIER
138496 , p_source_84 IN NUMBER
138497 --Distribution Type
138498 , p_source_85 IN VARCHAR2
138499 , p_source_85_meaning IN VARCHAR2
138500 --Entered Currency Code
138501 , p_source_88 IN VARCHAR2
138502 --Entered Amount
138503 , p_source_91 IN NUMBER
138504 --Currency Conversion Date
138505 , p_source_92 IN DATE
138506 --Currency Conversion Rate
138507 , p_source_93 IN NUMBER
138508 --Currency Conversion Type
138509 , p_source_94 IN VARCHAR2
138510 --Accounted Amount
138511 , p_source_95 IN NUMBER
138512 --Accounting Line Type
138513 , p_source_97 IN NUMBER
138514 --Organization Code
138515 , p_source_108 IN VARCHAR2
138516 )
138517 IS
138518
138519 l_component_type VARCHAR2(80);
138520 l_component_code VARCHAR2(30);
138521 l_component_type_code VARCHAR2(1);
138522 l_component_appl_id INTEGER;
138523 l_amb_context_code VARCHAR2(30);
138524 l_entity_code VARCHAR2(30);
138525 l_event_class_code VARCHAR2(30);
138526 l_ae_header_id NUMBER;
138527 l_event_type_code VARCHAR2(30);
138528 l_line_definition_code VARCHAR2(30);
138529 l_line_definition_owner_code VARCHAR2(1);
138530 --
138531 -- adr variables
138532 l_segment VARCHAR2(30);
138533 l_ccid NUMBER;
138534 l_adr_transaction_coa_id NUMBER;
138535 l_adr_accounting_coa_id NUMBER;
138536 l_adr_flexfield_segment_code VARCHAR2(30);
138537 l_adr_flex_value_set_id NUMBER;
138538 l_adr_value_type_code VARCHAR2(30);
138539 l_adr_value_combination_id NUMBER;
138540 l_adr_value_segment_code VARCHAR2(30);
138541
138542 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
138543 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
138544 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
138545 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
138546
138547 -- 4262811 Variables ------------------------------------------------------------------------------------------
138548 l_entered_amt_idx NUMBER;
138549 l_accted_amt_idx NUMBER;
138550 l_acc_rev_flag VARCHAR2(1);
138551 l_accrual_line_num NUMBER;
138552 l_tmp_amt NUMBER;
138553 l_acc_rev_natural_side_code VARCHAR2(1);
138554
138555 l_num_entries NUMBER;
138556 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
138557 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
138558 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
138559 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
138560 l_recog_line_1 NUMBER;
138561 l_recog_line_2 NUMBER;
138562
138563 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
138564 l_bflow_applied_to_amt NUMBER; -- 5132302
138565 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
138566
138567 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
138568
138569 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
138570 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
138571
138572 ---------------------------------------------------------------------------------------------------------------
138573
138574
138575 --
138576 -- bulk performance
138577 --
138578 l_balance_type_code VARCHAR2(1);
138579 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
138580 l_log_module VARCHAR2(240);
138581
138582 --
138583 -- Upgrade strategy
138584 --
138585 l_actual_upg_option VARCHAR2(1);
138586 l_enc_upg_option VARCHAR2(1);
138587
138588 --
138589 BEGIN
138590 --
138591 IF g_log_enabled THEN
138592 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_263';
138593 END IF;
138594 --
138595 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
138596
138597 trace
138598 (p_msg => 'BEGIN of AcctLineType_263'
138599 ,p_level => C_LEVEL_PROCEDURE
138600 ,p_module => l_log_module);
138601
138602 END IF;
138603 --
138604 l_component_type := 'AMB_JLT';
138605 l_component_code := 'INVENTORY_VALUATION';
138606 l_component_type_code := 'S';
138607 l_component_appl_id := 707;
138608 l_amb_context_code := 'DEFAULT';
138609 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
138610 l_event_class_code := 'WIP_MTL';
138611 l_event_type_code := 'WIP_COMP_ISSUE';
138612 l_line_definition_owner_code := 'S';
138613 l_line_definition_code := 'PI_WIP_COMP_ISSUE';
138614 --
138615 l_balance_type_code := 'A';
138616 l_segment := NULL;
138617 l_ccid := NULL;
138618 l_adr_transaction_coa_id := NULL;
138619 l_adr_accounting_coa_id := NULL;
138620 l_adr_flexfield_segment_code := NULL;
138621 l_adr_flex_value_set_id := NULL;
138622 l_adr_value_type_code := NULL;
138623 l_adr_value_combination_id := NULL;
138624 l_adr_value_segment_code := NULL;
138625
138626 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
138627 l_bflow_class_code := ''; -- 4219869 Business Flow
138628 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
138629 l_budgetary_control_flag := 'N';
138630
138631 l_bflow_applied_to_amt_idx := NULL; -- 5132302
138632 l_bflow_applied_to_amt := NULL; -- 5132302
138633 l_entered_amt_idx := NULL; -- 4262811
138634 l_accted_amt_idx := NULL; -- 4262811
138635 l_acc_rev_flag := NULL; -- 4262811
138636 l_accrual_line_num := NULL; -- 4262811
138637 l_tmp_amt := NULL; -- 4262811
138638 --
138639
138640 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
138641 l_balance_type_code <> 'B' THEN
138642 IF NVL(p_source_97,9E125) = 1
138643 THEN
138644
138645 --
138646 XLA_AE_LINES_PKG.SetNewLine;
138647
138648 p_balance_type_code := l_balance_type_code;
138649 -- set the flag so later we will know whether the gain loss line needs to be created
138650
138651 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
138652 p_actual_flag :='A';
138653 END IF;
138654
138655 --
138656 -- bulk performance
138657 --
138658 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
138659 p_header_num => 0); -- 4262811
138660 --
138661 -- set accounting line options
138662 --
138663 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
138664 p_natural_side_code => 'D'
138665 , p_gain_or_loss_flag => 'N'
138666 , p_gl_transfer_mode_code => 'S'
138667 , p_acct_entry_type_code => 'A'
138668 , p_switch_side_flag => 'Y'
138669 , p_merge_duplicate_code => 'N'
138670 );
138671 --
138672 l_acc_rev_natural_side_code := 'C'; -- 4262811
138673 --
138674 --
138675 -- set accounting line type info
138676 --
138677 xla_ae_lines_pkg.SetAcctLineType
138678 (p_component_type => l_component_type
138679 ,p_event_type_code => l_event_type_code
138680 ,p_line_definition_owner_code => l_line_definition_owner_code
138681 ,p_line_definition_code => l_line_definition_code
138682 ,p_accounting_line_code => l_component_code
138683 ,p_accounting_line_type_code => l_component_type_code
138684 ,p_accounting_line_appl_id => l_component_appl_id
138685 ,p_amb_context_code => l_amb_context_code
138686 ,p_entity_code => l_entity_code
138687 ,p_event_class_code => l_event_class_code);
138688 --
138689 -- set accounting class
138690 --
138691 xla_ae_lines_pkg.SetAcctClass(
138692 p_accounting_class_code => 'INVENTORY_VALUATION'
138693 , p_ae_header_id => l_ae_header_id
138694 );
138695
138696 --
138697 -- set rounding class
138698 --
138699 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
138700 'INVENTORY_VALUATION';
138701
138702 --
138703 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
138704 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
138705 --
138706 -- bulk performance
138707 --
138708 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
138709
138710 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
138711 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
138712
138713 -- 4955764
138714 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
138715 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
138716
138717 -- 4458381 Public Sector Enh
138718
138719 --
138720 -- set accounting attributes for the line type
138721 --
138722 l_entered_amt_idx := 3;
138723 l_accted_amt_idx := 8;
138724 l_bflow_applied_to_amt_idx := NULL; -- 5132302
138725 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
138726 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
138727 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
138728 l_rec_acct_attrs.array_char_value(2) := p_source_85;
138729 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
138730 l_rec_acct_attrs.array_num_value(3) := p_source_91;
138731 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
138732 l_rec_acct_attrs.array_char_value(4) := p_source_88;
138733 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
138734 l_rec_acct_attrs.array_date_value(5) := p_source_92;
138735 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
138736 l_rec_acct_attrs.array_num_value(6) := p_source_93;
138737 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
138738 l_rec_acct_attrs.array_char_value(7) := p_source_94;
138739 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
138740 l_rec_acct_attrs.array_num_value(8) := p_source_95;
138741
138742 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
138743 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
138744
138745 ---------------------------------------------------------------------------------------------------------------
138746 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
138747 ---------------------------------------------------------------------------------------------------------------
138748 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
138749
138750 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
138751 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
138752
138753 IF xla_accounting_cache_pkg.GetValueChar
138754 (p_source_code => 'LEDGER_CATEGORY_CODE'
138755 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
138756 AND l_bflow_method_code = 'PRIOR_ENTRY'
138757 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
138758 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
138759 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
138760 )
138761 THEN
138762 xla_ae_lines_pkg.BflowUpgEntry
138763 (p_business_method_code => l_bflow_method_code
138764 ,p_business_class_code => l_bflow_class_code
138765 ,p_balance_type => l_balance_type_code);
138766 ELSE
138767 NULL;
138768 -- No business flow processing for business flow method of NONE.
138769 END IF;
138770
138771 --
138772 -- call analytical criteria
138773 --
138774
138775
138776 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
138777 xla_ae_lines_pkg.SetAnalyticalCriteria(
138778 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
138779 , p_analytical_criterion_owner => 'S'
138780 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
138781 , p_amb_context_code => 'DEFAULT'
138782 , p_balancing_flag => 'Y'
138783
138784 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
138785 , p_analytical_detail_num_1 => NULL
138786 , p_analytical_detail_date_1 => NULL
138787
138788 , p_ae_header_id => l_ae_header_id
138789 )
138790 ;
138791 --
138792
138793 --
138794 -- call description
138795 --
138796
138797 xla_ae_lines_pkg.SetLineDescription(
138798 p_ae_header_id => l_ae_header_id
138799 ,p_description => Description_1 (
138800 p_application_id => p_application_id
138801 , p_ae_header_id => l_ae_header_id
138802 , p_source_1 => p_source_1
138803 , p_source_2 => p_source_2
138804 , p_source_3 => p_source_3
138805 , p_source_4 => p_source_4
138806 , p_source_5 => p_source_5
138807 )
138808 );
138809
138810
138811 --
138812 -- call ADRs
138813 -- Bug 4922099
138814 --
138815 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
138816 (NVL(l_actual_upg_option, 'N') = 'O') OR
138817 (NVL(l_enc_upg_option, 'N') = 'O')
138818 )
138819 THEN
138820 NULL;
138821 --
138822 --
138823
138824 l_ccid := AcctDerRule_28(
138825 p_application_id => p_application_id
138826 , p_ae_header_id => l_ae_header_id
138827 , p_source_15 => p_source_15
138828 , p_source_41 => p_source_41
138829 , p_source_42 => p_source_42
138830 , p_source_43 => p_source_43
138831 , p_source_44 => p_source_44
138832 , p_source_45 => p_source_45
138833 , x_transaction_coa_id => l_adr_transaction_coa_id
138834 , x_accounting_coa_id => l_adr_accounting_coa_id
138835 , x_value_type_code => l_adr_value_type_code
138836 , p_side => 'NA'
138837 );
138838
138839 xla_ae_lines_pkg.set_ccid(
138840 p_code_combination_id => l_ccid
138841 , p_value_type_code => l_adr_value_type_code
138842 , p_transaction_coa_id => l_adr_transaction_coa_id
138843 , p_accounting_coa_id => l_adr_accounting_coa_id
138844 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
138845 , p_adr_type_code => 'S'
138846 , p_component_type => l_component_type
138847 , p_component_code => l_component_code
138848 , p_component_type_code => l_component_type_code
138849 , p_component_appl_id => l_component_appl_id
138850 , p_amb_context_code => l_amb_context_code
138851 , p_side => 'NA'
138852 );
138853
138854
138855 --
138856 --
138857 END IF;
138858 --
138859 -- Bug 4922099
138860 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
138861 (NVL(l_enc_upg_option, 'N') = 'O')
138862 ) AND
138863 (l_bflow_method_code = 'PRIOR_ENTRY')
138864 )
138865 THEN
138866 IF
138867 --
138868 1 = 2
138869 --
138870 THEN
138871 xla_accounting_err_pkg.build_message
138872 (p_appli_s_name => 'XLA'
138873 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
138874 ,p_token_1 => 'LINE_NUMBER'
138875 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
138876 ,p_token_2 => 'LINE_TYPE_NAME'
138877 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
138878 l_component_type
138879 ,l_component_code
138880 ,l_component_type_code
138881 ,l_component_appl_id
138882 ,l_amb_context_code
138883 ,l_entity_code
138884 ,l_event_class_code
138885 )
138886 ,p_token_3 => 'OWNER'
138887 ,p_value_3 => xla_lookups_pkg.get_meaning(
138888 p_lookup_type => 'XLA_OWNER_TYPE'
138889 ,p_lookup_code => l_component_type_code
138890 )
138891 ,p_token_4 => 'PRODUCT_NAME'
138892 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
138893 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
138894 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
138895 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
138896 ,p_ae_header_id => NULL
138897 );
138898
138899 IF (C_LEVEL_ERROR>= g_log_level) THEN
138900 trace
138901 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
138902 ,p_level => C_LEVEL_ERROR
138903 ,p_module => l_log_module);
138904 END IF;
138905 END IF;
138906 END IF;
138907 --
138908 --
138909 ------------------------------------------------------------------------------------------------
138910 -- 4219869 Business Flow
138911 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
138912 -- Prior Entry. Currently, the following code is always generated.
138913 ------------------------------------------------------------------------------------------------
138914 XLA_AE_LINES_PKG.ValidateCurrentLine;
138915
138916 ------------------------------------------------------------------------------------
138917 -- 4219869 Business Flow
138918 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
138919 ------------------------------------------------------------------------------------
138920 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
138921
138922 ----------------------------------------------------------------------------------
138923 -- 4219869 Business Flow
138924 -- Update journal entry status -- Need to generate this within IF <condition>
138925 ----------------------------------------------------------------------------------
138926 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
138927 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
138928 ,p_balance_type_code => l_balance_type_code
138929 );
138930
138931 -------------------------------------------------------------------------------------------
138932 -- 4262811 - Generate the Accrual Reversal lines
138933 -------------------------------------------------------------------------------------------
138934 BEGIN
138935 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
138936 (g_array_event(p_event_id).array_value_num('header_index'));
138937 IF l_acc_rev_flag IS NULL THEN
138938 l_acc_rev_flag := 'N';
138939 END IF;
138940 EXCEPTION
138941 WHEN OTHERS THEN
138942 l_acc_rev_flag := 'N';
138943 END;
138944 --
138945 IF (l_acc_rev_flag = 'Y') THEN
138946
138947 -- 4645092 ------------------------------------------------------------------------------
138948 -- To allow MPA report to determine if it should generate report process
138949 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
138950 ------------------------------------------------------------------------------------------
138951
138952 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
138953 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
138954 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
138955 -- call ADRs
138956 -- Bug 4922099
138957 --
138958 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
138959 (NVL(l_actual_upg_option, 'N') = 'O') OR
138960 (NVL(l_enc_upg_option, 'N') = 'O')
138961 )
138962 THEN
138963 NULL;
138964 --
138965 --
138966
138967 l_ccid := AcctDerRule_28(
138968 p_application_id => p_application_id
138969 , p_ae_header_id => l_ae_header_id
138970 , p_source_15 => p_source_15
138971 , p_source_41 => p_source_41
138972 , p_source_42 => p_source_42
138973 , p_source_43 => p_source_43
138974 , p_source_44 => p_source_44
138975 , p_source_45 => p_source_45
138976 , x_transaction_coa_id => l_adr_transaction_coa_id
138977 , x_accounting_coa_id => l_adr_accounting_coa_id
138978 , x_value_type_code => l_adr_value_type_code
138979 , p_side => 'NA'
138980 );
138981
138982 xla_ae_lines_pkg.set_ccid(
138983 p_code_combination_id => l_ccid
138984 , p_value_type_code => l_adr_value_type_code
138985 , p_transaction_coa_id => l_adr_transaction_coa_id
138986 , p_accounting_coa_id => l_adr_accounting_coa_id
138987 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
138988 , p_adr_type_code => 'S'
138989 , p_component_type => l_component_type
138990 , p_component_code => l_component_code
138991 , p_component_type_code => l_component_type_code
138992 , p_component_appl_id => l_component_appl_id
138993 , p_amb_context_code => l_amb_context_code
138994 , p_side => 'NA'
138995 );
138996
138997
138998 --
138999 --
139000 END IF;
139001
139002 --
139003 -- Update the line information that should be overwritten
139004 --
139005 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
139006 p_header_num => 1);
139007 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
139008
139009 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
139010
139011 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
139012 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
139013 END IF;
139014
139015 --
139016 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
139017 --
139018 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
139019 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
139020 ELSE
139021 ---------------------------------------------------------------------------------------------------
139022 -- 4262811a Switch Sign
139023 ---------------------------------------------------------------------------------------------------
139024 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
139025 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
139026 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139027 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
139028 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139029 -- 5132302
139030 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
139031 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139032
139033 END IF;
139034
139035 -- 4955764
139036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
139037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
139038
139039
139040 XLA_AE_LINES_PKG.ValidateCurrentLine;
139041 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
139042
139043 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
139044 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
139045 ,p_balance_type_code => l_balance_type_code);
139046
139047 END IF;
139048
139049 -----------------------------------------------------------------------------------------
139050 -- 4262811 Multiperiod Accounting
139051 -----------------------------------------------------------------------------------------
139052 -- No MPA option is assigned.
139053
139054
139055 END IF;
139056 END IF;
139057 --
139058
139059 --
139060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
139061 trace
139062 (p_msg => 'END of AcctLineType_263'
139063 ,p_level => C_LEVEL_PROCEDURE
139064 ,p_module => l_log_module);
139065 END IF;
139066 --
139067 EXCEPTION
139068 WHEN xla_exceptions_pkg.application_exception THEN
139069 RAISE;
139070 WHEN OTHERS THEN
139071 xla_exceptions_pkg.raise_message
139072 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_263');
139073 END AcctLineType_263;
139074 --
139075
139076 ---------------------------------------
139077 --
139078 -- PRIVATE FUNCTION
139079 -- AcctLineType_264
139080 --
139081 ---------------------------------------
139082 PROCEDURE AcctLineType_264 (
139083 p_application_id IN NUMBER
139084 ,p_event_id IN NUMBER
139085 ,p_calculate_acctd_flag IN VARCHAR2
139086 ,p_calculate_g_l_flag IN VARCHAR2
139087 ,p_actual_flag IN OUT VARCHAR2
139088 ,p_balance_type_code OUT VARCHAR2
139089 ,p_gain_or_loss_ref OUT VARCHAR2
139090
139091 --TRANSACTION_ID
139092 , p_source_1 IN NUMBER
139093 --Item Concatenated Segments
139094 , p_source_2 IN VARCHAR2
139095 --Transaction Quantity
139096 , p_source_3 IN NUMBER
139097 --Transaction Unit of Measure Code
139098 , p_source_4 IN VARCHAR2
139099 --Inventory Transaction Type Description
139100 , p_source_5 IN VARCHAR2
139101 --Cost Element Name
139102 , p_source_15 IN NUMBER
139103 --Product Line Accounting Category Material Account
139104 , p_source_41 IN NUMBER
139105 --Product Line Accounting Category Material Overhead Account
139106 , p_source_42 IN NUMBER
139107 --Product Line Accounting Category Resource Account
139108 , p_source_43 IN NUMBER
139109 --Product Line Accounting Category Outside Processing Account
139110 , p_source_44 IN NUMBER
139111 --Product Line Accounting Category Overhead Account
139112 , p_source_45 IN NUMBER
139113 --DISTRIBUTION_IDENTIFIER
139114 , p_source_84 IN NUMBER
139115 --Distribution Type
139116 , p_source_85 IN VARCHAR2
139117 , p_source_85_meaning IN VARCHAR2
139118 --Entered Currency Code
139119 , p_source_88 IN VARCHAR2
139120 --Entered Amount
139121 , p_source_91 IN NUMBER
139122 --Currency Conversion Date
139123 , p_source_92 IN DATE
139124 --Currency Conversion Rate
139125 , p_source_93 IN NUMBER
139126 --Currency Conversion Type
139127 , p_source_94 IN VARCHAR2
139128 --Accounted Amount
139129 , p_source_95 IN NUMBER
139130 --Accounting Line Type
139131 , p_source_97 IN NUMBER
139132 --Organization Code
139133 , p_source_108 IN VARCHAR2
139134 )
139135 IS
139136
139137 l_component_type VARCHAR2(80);
139138 l_component_code VARCHAR2(30);
139139 l_component_type_code VARCHAR2(1);
139140 l_component_appl_id INTEGER;
139141 l_amb_context_code VARCHAR2(30);
139142 l_entity_code VARCHAR2(30);
139143 l_event_class_code VARCHAR2(30);
139144 l_ae_header_id NUMBER;
139145 l_event_type_code VARCHAR2(30);
139146 l_line_definition_code VARCHAR2(30);
139147 l_line_definition_owner_code VARCHAR2(1);
139148 --
139149 -- adr variables
139150 l_segment VARCHAR2(30);
139151 l_ccid NUMBER;
139152 l_adr_transaction_coa_id NUMBER;
139153 l_adr_accounting_coa_id NUMBER;
139154 l_adr_flexfield_segment_code VARCHAR2(30);
139155 l_adr_flex_value_set_id NUMBER;
139156 l_adr_value_type_code VARCHAR2(30);
139157 l_adr_value_combination_id NUMBER;
139158 l_adr_value_segment_code VARCHAR2(30);
139159
139160 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
139161 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
139162 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
139163 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
139164
139165 -- 4262811 Variables ------------------------------------------------------------------------------------------
139166 l_entered_amt_idx NUMBER;
139167 l_accted_amt_idx NUMBER;
139168 l_acc_rev_flag VARCHAR2(1);
139169 l_accrual_line_num NUMBER;
139170 l_tmp_amt NUMBER;
139171 l_acc_rev_natural_side_code VARCHAR2(1);
139172
139173 l_num_entries NUMBER;
139174 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
139175 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
139176 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
139177 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
139178 l_recog_line_1 NUMBER;
139179 l_recog_line_2 NUMBER;
139180
139181 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
139182 l_bflow_applied_to_amt NUMBER; -- 5132302
139183 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
139184
139185 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
139186
139187 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
139188 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
139189
139190 ---------------------------------------------------------------------------------------------------------------
139191
139192
139193 --
139194 -- bulk performance
139195 --
139196 l_balance_type_code VARCHAR2(1);
139197 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
139198 l_log_module VARCHAR2(240);
139199
139200 --
139201 -- Upgrade strategy
139202 --
139203 l_actual_upg_option VARCHAR2(1);
139204 l_enc_upg_option VARCHAR2(1);
139205
139206 --
139207 BEGIN
139208 --
139209 IF g_log_enabled THEN
139210 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_264';
139211 END IF;
139212 --
139213 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
139214
139215 trace
139216 (p_msg => 'BEGIN of AcctLineType_264'
139217 ,p_level => C_LEVEL_PROCEDURE
139218 ,p_module => l_log_module);
139219
139220 END IF;
139221 --
139222 l_component_type := 'AMB_JLT';
139223 l_component_code := 'INVENTORY_VALUATION';
139224 l_component_type_code := 'S';
139225 l_component_appl_id := 707;
139226 l_amb_context_code := 'DEFAULT';
139227 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
139228 l_event_class_code := 'WIP_MTL';
139229 l_event_type_code := 'WIP_COMP_RETURN';
139230 l_line_definition_owner_code := 'S';
139231 l_line_definition_code := 'PI_WIP_COMP_RETURN';
139232 --
139233 l_balance_type_code := 'A';
139234 l_segment := NULL;
139235 l_ccid := NULL;
139236 l_adr_transaction_coa_id := NULL;
139237 l_adr_accounting_coa_id := NULL;
139238 l_adr_flexfield_segment_code := NULL;
139239 l_adr_flex_value_set_id := NULL;
139240 l_adr_value_type_code := NULL;
139241 l_adr_value_combination_id := NULL;
139242 l_adr_value_segment_code := NULL;
139243
139244 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
139245 l_bflow_class_code := ''; -- 4219869 Business Flow
139246 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
139247 l_budgetary_control_flag := 'N';
139248
139249 l_bflow_applied_to_amt_idx := NULL; -- 5132302
139250 l_bflow_applied_to_amt := NULL; -- 5132302
139251 l_entered_amt_idx := NULL; -- 4262811
139252 l_accted_amt_idx := NULL; -- 4262811
139253 l_acc_rev_flag := NULL; -- 4262811
139254 l_accrual_line_num := NULL; -- 4262811
139255 l_tmp_amt := NULL; -- 4262811
139256 --
139257
139258 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
139259 l_balance_type_code <> 'B' THEN
139260 IF NVL(p_source_97,9E125) = 1
139261 THEN
139262
139263 --
139264 XLA_AE_LINES_PKG.SetNewLine;
139265
139266 p_balance_type_code := l_balance_type_code;
139267 -- set the flag so later we will know whether the gain loss line needs to be created
139268
139269 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
139270 p_actual_flag :='A';
139271 END IF;
139272
139273 --
139274 -- bulk performance
139275 --
139276 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
139277 p_header_num => 0); -- 4262811
139278 --
139279 -- set accounting line options
139280 --
139281 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
139282 p_natural_side_code => 'D'
139283 , p_gain_or_loss_flag => 'N'
139284 , p_gl_transfer_mode_code => 'S'
139285 , p_acct_entry_type_code => 'A'
139286 , p_switch_side_flag => 'Y'
139287 , p_merge_duplicate_code => 'N'
139288 );
139289 --
139290 l_acc_rev_natural_side_code := 'C'; -- 4262811
139291 --
139292 --
139293 -- set accounting line type info
139294 --
139295 xla_ae_lines_pkg.SetAcctLineType
139296 (p_component_type => l_component_type
139297 ,p_event_type_code => l_event_type_code
139298 ,p_line_definition_owner_code => l_line_definition_owner_code
139299 ,p_line_definition_code => l_line_definition_code
139300 ,p_accounting_line_code => l_component_code
139301 ,p_accounting_line_type_code => l_component_type_code
139302 ,p_accounting_line_appl_id => l_component_appl_id
139303 ,p_amb_context_code => l_amb_context_code
139304 ,p_entity_code => l_entity_code
139305 ,p_event_class_code => l_event_class_code);
139306 --
139307 -- set accounting class
139308 --
139309 xla_ae_lines_pkg.SetAcctClass(
139310 p_accounting_class_code => 'INVENTORY_VALUATION'
139311 , p_ae_header_id => l_ae_header_id
139312 );
139313
139314 --
139315 -- set rounding class
139316 --
139317 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
139318 'INVENTORY_VALUATION';
139319
139320 --
139321 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
139322 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
139323 --
139324 -- bulk performance
139325 --
139326 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
139327
139328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
139329 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
139330
139331 -- 4955764
139332 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
139333 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
139334
139335 -- 4458381 Public Sector Enh
139336
139337 --
139338 -- set accounting attributes for the line type
139339 --
139340 l_entered_amt_idx := 3;
139341 l_accted_amt_idx := 8;
139342 l_bflow_applied_to_amt_idx := NULL; -- 5132302
139343 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
139344 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
139345 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
139346 l_rec_acct_attrs.array_char_value(2) := p_source_85;
139347 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
139348 l_rec_acct_attrs.array_num_value(3) := p_source_91;
139349 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
139350 l_rec_acct_attrs.array_char_value(4) := p_source_88;
139351 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
139352 l_rec_acct_attrs.array_date_value(5) := p_source_92;
139353 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
139354 l_rec_acct_attrs.array_num_value(6) := p_source_93;
139355 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
139356 l_rec_acct_attrs.array_char_value(7) := p_source_94;
139357 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
139358 l_rec_acct_attrs.array_num_value(8) := p_source_95;
139359
139360 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
139361 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
139362
139363 ---------------------------------------------------------------------------------------------------------------
139364 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
139365 ---------------------------------------------------------------------------------------------------------------
139366 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
139367
139368 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
139369 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
139370
139371 IF xla_accounting_cache_pkg.GetValueChar
139372 (p_source_code => 'LEDGER_CATEGORY_CODE'
139373 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
139374 AND l_bflow_method_code = 'PRIOR_ENTRY'
139375 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
139376 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
139377 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
139378 )
139379 THEN
139380 xla_ae_lines_pkg.BflowUpgEntry
139381 (p_business_method_code => l_bflow_method_code
139382 ,p_business_class_code => l_bflow_class_code
139383 ,p_balance_type => l_balance_type_code);
139384 ELSE
139385 NULL;
139386 -- No business flow processing for business flow method of NONE.
139387 END IF;
139388
139389 --
139390 -- call analytical criteria
139391 --
139392
139393
139394 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
139395 xla_ae_lines_pkg.SetAnalyticalCriteria(
139396 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
139397 , p_analytical_criterion_owner => 'S'
139398 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
139399 , p_amb_context_code => 'DEFAULT'
139400 , p_balancing_flag => 'Y'
139401
139402 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
139403 , p_analytical_detail_num_1 => NULL
139404 , p_analytical_detail_date_1 => NULL
139405
139406 , p_ae_header_id => l_ae_header_id
139407 )
139408 ;
139409 --
139410
139411 --
139412 -- call description
139413 --
139414
139415 xla_ae_lines_pkg.SetLineDescription(
139416 p_ae_header_id => l_ae_header_id
139417 ,p_description => Description_1 (
139418 p_application_id => p_application_id
139419 , p_ae_header_id => l_ae_header_id
139420 , p_source_1 => p_source_1
139421 , p_source_2 => p_source_2
139422 , p_source_3 => p_source_3
139423 , p_source_4 => p_source_4
139424 , p_source_5 => p_source_5
139425 )
139426 );
139427
139428
139429 --
139430 -- call ADRs
139431 -- Bug 4922099
139432 --
139433 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
139434 (NVL(l_actual_upg_option, 'N') = 'O') OR
139435 (NVL(l_enc_upg_option, 'N') = 'O')
139436 )
139437 THEN
139438 NULL;
139439 --
139440 --
139441
139442 l_ccid := AcctDerRule_28(
139443 p_application_id => p_application_id
139444 , p_ae_header_id => l_ae_header_id
139445 , p_source_15 => p_source_15
139446 , p_source_41 => p_source_41
139447 , p_source_42 => p_source_42
139448 , p_source_43 => p_source_43
139449 , p_source_44 => p_source_44
139450 , p_source_45 => p_source_45
139451 , x_transaction_coa_id => l_adr_transaction_coa_id
139452 , x_accounting_coa_id => l_adr_accounting_coa_id
139453 , x_value_type_code => l_adr_value_type_code
139454 , p_side => 'NA'
139455 );
139456
139457 xla_ae_lines_pkg.set_ccid(
139458 p_code_combination_id => l_ccid
139459 , p_value_type_code => l_adr_value_type_code
139460 , p_transaction_coa_id => l_adr_transaction_coa_id
139461 , p_accounting_coa_id => l_adr_accounting_coa_id
139462 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
139463 , p_adr_type_code => 'S'
139464 , p_component_type => l_component_type
139465 , p_component_code => l_component_code
139466 , p_component_type_code => l_component_type_code
139467 , p_component_appl_id => l_component_appl_id
139468 , p_amb_context_code => l_amb_context_code
139469 , p_side => 'NA'
139470 );
139471
139472
139473 --
139474 --
139475 END IF;
139476 --
139477 -- Bug 4922099
139478 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
139479 (NVL(l_enc_upg_option, 'N') = 'O')
139480 ) AND
139481 (l_bflow_method_code = 'PRIOR_ENTRY')
139482 )
139483 THEN
139484 IF
139485 --
139486 1 = 2
139487 --
139488 THEN
139489 xla_accounting_err_pkg.build_message
139490 (p_appli_s_name => 'XLA'
139491 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
139492 ,p_token_1 => 'LINE_NUMBER'
139493 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
139494 ,p_token_2 => 'LINE_TYPE_NAME'
139495 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
139496 l_component_type
139497 ,l_component_code
139498 ,l_component_type_code
139499 ,l_component_appl_id
139500 ,l_amb_context_code
139501 ,l_entity_code
139502 ,l_event_class_code
139503 )
139504 ,p_token_3 => 'OWNER'
139505 ,p_value_3 => xla_lookups_pkg.get_meaning(
139506 p_lookup_type => 'XLA_OWNER_TYPE'
139507 ,p_lookup_code => l_component_type_code
139508 )
139509 ,p_token_4 => 'PRODUCT_NAME'
139510 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
139511 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
139512 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
139513 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
139514 ,p_ae_header_id => NULL
139515 );
139516
139517 IF (C_LEVEL_ERROR>= g_log_level) THEN
139518 trace
139519 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
139520 ,p_level => C_LEVEL_ERROR
139521 ,p_module => l_log_module);
139522 END IF;
139523 END IF;
139524 END IF;
139525 --
139526 --
139527 ------------------------------------------------------------------------------------------------
139528 -- 4219869 Business Flow
139529 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
139530 -- Prior Entry. Currently, the following code is always generated.
139531 ------------------------------------------------------------------------------------------------
139532 XLA_AE_LINES_PKG.ValidateCurrentLine;
139533
139534 ------------------------------------------------------------------------------------
139535 -- 4219869 Business Flow
139536 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
139537 ------------------------------------------------------------------------------------
139538 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
139539
139540 ----------------------------------------------------------------------------------
139541 -- 4219869 Business Flow
139542 -- Update journal entry status -- Need to generate this within IF <condition>
139543 ----------------------------------------------------------------------------------
139544 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
139545 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
139546 ,p_balance_type_code => l_balance_type_code
139547 );
139548
139549 -------------------------------------------------------------------------------------------
139550 -- 4262811 - Generate the Accrual Reversal lines
139551 -------------------------------------------------------------------------------------------
139552 BEGIN
139553 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
139554 (g_array_event(p_event_id).array_value_num('header_index'));
139555 IF l_acc_rev_flag IS NULL THEN
139556 l_acc_rev_flag := 'N';
139557 END IF;
139558 EXCEPTION
139559 WHEN OTHERS THEN
139560 l_acc_rev_flag := 'N';
139561 END;
139562 --
139563 IF (l_acc_rev_flag = 'Y') THEN
139564
139565 -- 4645092 ------------------------------------------------------------------------------
139566 -- To allow MPA report to determine if it should generate report process
139567 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
139568 ------------------------------------------------------------------------------------------
139569
139570 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
139571 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
139572 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
139573 -- call ADRs
139574 -- Bug 4922099
139575 --
139576 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
139577 (NVL(l_actual_upg_option, 'N') = 'O') OR
139578 (NVL(l_enc_upg_option, 'N') = 'O')
139579 )
139580 THEN
139581 NULL;
139582 --
139583 --
139584
139585 l_ccid := AcctDerRule_28(
139586 p_application_id => p_application_id
139587 , p_ae_header_id => l_ae_header_id
139588 , p_source_15 => p_source_15
139589 , p_source_41 => p_source_41
139590 , p_source_42 => p_source_42
139591 , p_source_43 => p_source_43
139592 , p_source_44 => p_source_44
139593 , p_source_45 => p_source_45
139594 , x_transaction_coa_id => l_adr_transaction_coa_id
139595 , x_accounting_coa_id => l_adr_accounting_coa_id
139596 , x_value_type_code => l_adr_value_type_code
139597 , p_side => 'NA'
139598 );
139599
139600 xla_ae_lines_pkg.set_ccid(
139601 p_code_combination_id => l_ccid
139602 , p_value_type_code => l_adr_value_type_code
139603 , p_transaction_coa_id => l_adr_transaction_coa_id
139604 , p_accounting_coa_id => l_adr_accounting_coa_id
139605 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
139606 , p_adr_type_code => 'S'
139607 , p_component_type => l_component_type
139608 , p_component_code => l_component_code
139609 , p_component_type_code => l_component_type_code
139610 , p_component_appl_id => l_component_appl_id
139611 , p_amb_context_code => l_amb_context_code
139612 , p_side => 'NA'
139613 );
139614
139615
139616 --
139617 --
139618 END IF;
139619
139620 --
139621 -- Update the line information that should be overwritten
139622 --
139623 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
139624 p_header_num => 1);
139625 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
139626
139627 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
139628
139629 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
139630 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
139631 END IF;
139632
139633 --
139634 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
139635 --
139636 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
139637 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
139638 ELSE
139639 ---------------------------------------------------------------------------------------------------
139640 -- 4262811a Switch Sign
139641 ---------------------------------------------------------------------------------------------------
139642 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
139643 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
139644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139645 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
139646 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139647 -- 5132302
139648 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
139649 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
139650
139651 END IF;
139652
139653 -- 4955764
139654 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
139655 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
139656
139657
139658 XLA_AE_LINES_PKG.ValidateCurrentLine;
139659 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
139660
139661 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
139662 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
139663 ,p_balance_type_code => l_balance_type_code);
139664
139665 END IF;
139666
139667 -----------------------------------------------------------------------------------------
139668 -- 4262811 Multiperiod Accounting
139669 -----------------------------------------------------------------------------------------
139670 -- No MPA option is assigned.
139671
139672
139673 END IF;
139674 END IF;
139675 --
139676
139677 --
139678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
139679 trace
139680 (p_msg => 'END of AcctLineType_264'
139681 ,p_level => C_LEVEL_PROCEDURE
139682 ,p_module => l_log_module);
139683 END IF;
139684 --
139685 EXCEPTION
139686 WHEN xla_exceptions_pkg.application_exception THEN
139687 RAISE;
139688 WHEN OTHERS THEN
139689 xla_exceptions_pkg.raise_message
139690 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_264');
139691 END AcctLineType_264;
139692 --
139693
139694 ---------------------------------------
139695 --
139696 -- PRIVATE FUNCTION
139697 -- AcctLineType_265
139698 --
139699 ---------------------------------------
139700 PROCEDURE AcctLineType_265 (
139701 p_application_id IN NUMBER
139702 ,p_event_id IN NUMBER
139703 ,p_calculate_acctd_flag IN VARCHAR2
139704 ,p_calculate_g_l_flag IN VARCHAR2
139705 ,p_actual_flag IN OUT VARCHAR2
139706 ,p_balance_type_code OUT VARCHAR2
139707 ,p_gain_or_loss_ref OUT VARCHAR2
139708
139709 --TRANSACTION_ID
139710 , p_source_1 IN NUMBER
139711 --Item Concatenated Segments
139712 , p_source_2 IN VARCHAR2
139713 --Transaction Quantity
139714 , p_source_3 IN NUMBER
139715 --Transaction Unit of Measure Code
139716 , p_source_4 IN VARCHAR2
139717 --Inventory Transaction Type Description
139718 , p_source_5 IN VARCHAR2
139719 --Cost Element Name
139720 , p_source_15 IN NUMBER
139721 --Product Line Accounting Category Material Account
139722 , p_source_41 IN NUMBER
139723 --Product Line Accounting Category Material Overhead Account
139724 , p_source_42 IN NUMBER
139725 --Product Line Accounting Category Resource Account
139726 , p_source_43 IN NUMBER
139727 --Product Line Accounting Category Outside Processing Account
139728 , p_source_44 IN NUMBER
139729 --Product Line Accounting Category Overhead Account
139730 , p_source_45 IN NUMBER
139731 --Applied to Application ID
139732 , p_source_79 IN NUMBER
139733 --Applied to Distribution Link Type
139734 , p_source_80 IN VARCHAR2
139735 --Applied to Entity Code
139736 , p_source_81 IN VARCHAR2
139737 --DISTRIBUTION_IDENTIFIER
139738 , p_source_84 IN NUMBER
139739 --Distribution Type
139740 , p_source_85 IN VARCHAR2
139741 , p_source_85_meaning IN VARCHAR2
139742 --Encumbrance Reversal Amount Entered
139743 , p_source_87 IN NUMBER
139744 --Entered Currency Code
139745 , p_source_88 IN VARCHAR2
139746 --Transaction Encumbrance Reversal Amount
139747 , p_source_89 IN NUMBER
139748 --Entered Amount
139749 , p_source_91 IN NUMBER
139750 --Currency Conversion Date
139751 , p_source_92 IN DATE
139752 --Currency Conversion Rate
139753 , p_source_93 IN NUMBER
139754 --Currency Conversion Type
139755 , p_source_94 IN VARCHAR2
139756 --Accounted Amount
139757 , p_source_95 IN NUMBER
139758 --Accounting Line Type
139759 , p_source_97 IN NUMBER
139760 --Costing Encumbrance Upgrade Option
139761 , p_source_100 IN VARCHAR2
139762 --TXN_PO_DISTRIBUTION_ID
139763 , p_source_101 IN NUMBER
139764 --TXN_PO_HEADER_ID
139765 , p_source_102 IN NUMBER
139766 --Requisition Budget Account
139767 , p_source_103 IN NUMBER
139768 --Requisition Encumbrance Type Identifier
139769 , p_source_104 IN NUMBER
139770 --Organization Code
139771 , p_source_108 IN VARCHAR2
139772 )
139773 IS
139774
139775 l_component_type VARCHAR2(80);
139776 l_component_code VARCHAR2(30);
139777 l_component_type_code VARCHAR2(1);
139778 l_component_appl_id INTEGER;
139779 l_amb_context_code VARCHAR2(30);
139780 l_entity_code VARCHAR2(30);
139781 l_event_class_code VARCHAR2(30);
139782 l_ae_header_id NUMBER;
139783 l_event_type_code VARCHAR2(30);
139784 l_line_definition_code VARCHAR2(30);
139785 l_line_definition_owner_code VARCHAR2(1);
139786 --
139787 -- adr variables
139788 l_segment VARCHAR2(30);
139789 l_ccid NUMBER;
139790 l_adr_transaction_coa_id NUMBER;
139791 l_adr_accounting_coa_id NUMBER;
139792 l_adr_flexfield_segment_code VARCHAR2(30);
139793 l_adr_flex_value_set_id NUMBER;
139794 l_adr_value_type_code VARCHAR2(30);
139795 l_adr_value_combination_id NUMBER;
139796 l_adr_value_segment_code VARCHAR2(30);
139797
139798 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
139799 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
139800 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
139801 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
139802
139803 -- 4262811 Variables ------------------------------------------------------------------------------------------
139804 l_entered_amt_idx NUMBER;
139805 l_accted_amt_idx NUMBER;
139806 l_acc_rev_flag VARCHAR2(1);
139807 l_accrual_line_num NUMBER;
139808 l_tmp_amt NUMBER;
139809 l_acc_rev_natural_side_code VARCHAR2(1);
139810
139811 l_num_entries NUMBER;
139812 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
139813 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
139814 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
139815 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
139816 l_recog_line_1 NUMBER;
139817 l_recog_line_2 NUMBER;
139818
139819 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
139820 l_bflow_applied_to_amt NUMBER; -- 5132302
139821 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
139822
139823 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
139824
139825 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
139826 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
139827
139828 ---------------------------------------------------------------------------------------------------------------
139829
139830
139831 --
139832 -- bulk performance
139833 --
139834 l_balance_type_code VARCHAR2(1);
139835 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
139836 l_log_module VARCHAR2(240);
139837
139838 --
139839 -- Upgrade strategy
139840 --
139841 l_actual_upg_option VARCHAR2(1);
139842 l_enc_upg_option VARCHAR2(1);
139843
139844 --
139845 BEGIN
139846 --
139847 IF g_log_enabled THEN
139848 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_265';
139849 END IF;
139850 --
139851 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
139852
139853 trace
139854 (p_msg => 'BEGIN of AcctLineType_265'
139855 ,p_level => C_LEVEL_PROCEDURE
139856 ,p_module => l_log_module);
139857
139858 END IF;
139859 --
139860 l_component_type := 'AMB_JLT';
139861 l_component_code := 'INVENTORY_VALUATION';
139862 l_component_type_code := 'S';
139863 l_component_appl_id := 707;
139864 l_amb_context_code := 'DEFAULT';
139865 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
139866 l_event_class_code := 'DIR_INTERORG_RCPT';
139867 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
139868 l_line_definition_owner_code := 'S';
139869 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
139870 --
139871 l_balance_type_code := 'A';
139872 l_segment := NULL;
139873 l_ccid := NULL;
139874 l_adr_transaction_coa_id := NULL;
139875 l_adr_accounting_coa_id := NULL;
139876 l_adr_flexfield_segment_code := NULL;
139877 l_adr_flex_value_set_id := NULL;
139878 l_adr_value_type_code := NULL;
139879 l_adr_value_combination_id := NULL;
139880 l_adr_value_segment_code := NULL;
139881
139882 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
139883 l_bflow_class_code := ''; -- 4219869 Business Flow
139884 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
139885 l_budgetary_control_flag := 'N';
139886
139887 l_bflow_applied_to_amt_idx := NULL; -- 5132302
139888 l_bflow_applied_to_amt := NULL; -- 5132302
139889 l_entered_amt_idx := NULL; -- 4262811
139890 l_accted_amt_idx := NULL; -- 4262811
139891 l_acc_rev_flag := NULL; -- 4262811
139892 l_accrual_line_num := NULL; -- 4262811
139893 l_tmp_amt := NULL; -- 4262811
139894 --
139895
139896 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
139897 l_balance_type_code <> 'B' THEN
139898 IF NVL(p_source_97,9E125) = 1
139899 THEN
139900
139901 --
139902 XLA_AE_LINES_PKG.SetNewLine;
139903
139904 p_balance_type_code := l_balance_type_code;
139905 -- set the flag so later we will know whether the gain loss line needs to be created
139906
139907 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
139908 p_actual_flag :='A';
139909 END IF;
139910
139911 --
139912 -- bulk performance
139913 --
139914 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
139915 p_header_num => 0); -- 4262811
139916 --
139917 -- set accounting line options
139918 --
139919 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
139920 p_natural_side_code => 'D'
139921 , p_gain_or_loss_flag => 'N'
139922 , p_gl_transfer_mode_code => 'S'
139923 , p_acct_entry_type_code => 'A'
139924 , p_switch_side_flag => 'Y'
139925 , p_merge_duplicate_code => 'N'
139926 );
139927 --
139928 l_acc_rev_natural_side_code := 'C'; -- 4262811
139929 --
139930 --
139931 -- set accounting line type info
139932 --
139933 xla_ae_lines_pkg.SetAcctLineType
139934 (p_component_type => l_component_type
139935 ,p_event_type_code => l_event_type_code
139936 ,p_line_definition_owner_code => l_line_definition_owner_code
139937 ,p_line_definition_code => l_line_definition_code
139938 ,p_accounting_line_code => l_component_code
139939 ,p_accounting_line_type_code => l_component_type_code
139940 ,p_accounting_line_appl_id => l_component_appl_id
139941 ,p_amb_context_code => l_amb_context_code
139942 ,p_entity_code => l_entity_code
139943 ,p_event_class_code => l_event_class_code);
139944 --
139945 -- set accounting class
139946 --
139947 xla_ae_lines_pkg.SetAcctClass(
139948 p_accounting_class_code => 'INVENTORY_VALUATION'
139949 , p_ae_header_id => l_ae_header_id
139950 );
139951
139952 --
139953 -- set rounding class
139954 --
139955 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
139956 'INVENTORY_VALUATION';
139957
139958 --
139959 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
139960 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
139961 --
139962 -- bulk performance
139963 --
139964 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
139965
139966 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
139967 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
139968
139969 -- 4955764
139970 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
139971 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
139972
139973 -- 4458381 Public Sector Enh
139974
139975 --
139976 -- set accounting attributes for the line type
139977 --
139978 l_entered_amt_idx := 17;
139979 l_accted_amt_idx := 22;
139980 l_bflow_applied_to_amt_idx := NULL; -- 5132302
139981 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
139982 l_rec_acct_attrs.array_num_value(1) := p_source_79;
139983 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
139984 l_rec_acct_attrs.array_char_value(2) := p_source_80;
139985 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
139986 l_rec_acct_attrs.array_char_value(3) := p_source_81;
139987 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
139988 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
139989 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
139990 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
139991 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
139992 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
139993 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
139994 l_rec_acct_attrs.array_char_value(7) := p_source_85;
139995 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
139996 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
139997 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
139998 l_rec_acct_attrs.array_num_value(9) := p_source_87;
139999 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
140000 l_rec_acct_attrs.array_char_value(10) := p_source_88;
140001 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
140002 l_rec_acct_attrs.array_num_value(11) := p_source_89;
140003 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
140004 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
140005 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
140006 l_rec_acct_attrs.array_num_value(13) := p_source_87;
140007 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
140008 l_rec_acct_attrs.array_char_value(14) := p_source_88;
140009 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
140010 l_rec_acct_attrs.array_num_value(15) := p_source_89;
140011 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
140012 l_rec_acct_attrs.array_char_value(16) := p_source_100;
140013 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
140014 l_rec_acct_attrs.array_num_value(17) := p_source_91;
140015 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
140016 l_rec_acct_attrs.array_char_value(18) := p_source_88;
140017 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
140018 l_rec_acct_attrs.array_date_value(19) := p_source_92;
140019 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
140020 l_rec_acct_attrs.array_num_value(20) := p_source_93;
140021 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
140022 l_rec_acct_attrs.array_char_value(21) := p_source_94;
140023 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
140024 l_rec_acct_attrs.array_num_value(22) := p_source_95;
140025 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
140026 l_rec_acct_attrs.array_num_value(23) := p_source_104;
140027 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
140028 l_rec_acct_attrs.array_num_value(24) := p_source_104;
140029
140030 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
140031 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
140032
140033 ---------------------------------------------------------------------------------------------------------------
140034 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
140035 ---------------------------------------------------------------------------------------------------------------
140036 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
140037
140038 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
140039 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
140040
140041 IF xla_accounting_cache_pkg.GetValueChar
140042 (p_source_code => 'LEDGER_CATEGORY_CODE'
140043 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
140044 AND l_bflow_method_code = 'PRIOR_ENTRY'
140045 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
140046 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
140047 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
140048 )
140049 THEN
140050 xla_ae_lines_pkg.BflowUpgEntry
140051 (p_business_method_code => l_bflow_method_code
140052 ,p_business_class_code => l_bflow_class_code
140053 ,p_balance_type => l_balance_type_code);
140054 ELSE
140055 NULL;
140056 -- No business flow processing for business flow method of NONE.
140057 END IF;
140058
140059 --
140060 -- call analytical criteria
140061 --
140062
140063
140064 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
140065 xla_ae_lines_pkg.SetAnalyticalCriteria(
140066 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
140067 , p_analytical_criterion_owner => 'S'
140068 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
140069 , p_amb_context_code => 'DEFAULT'
140070 , p_balancing_flag => 'Y'
140071
140072 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
140073 , p_analytical_detail_num_1 => NULL
140074 , p_analytical_detail_date_1 => NULL
140075
140076 , p_ae_header_id => l_ae_header_id
140077 )
140078 ;
140079 --
140080
140081 --
140082 -- call description
140083 --
140084
140085 xla_ae_lines_pkg.SetLineDescription(
140086 p_ae_header_id => l_ae_header_id
140087 ,p_description => Description_1 (
140088 p_application_id => p_application_id
140089 , p_ae_header_id => l_ae_header_id
140090 , p_source_1 => p_source_1
140091 , p_source_2 => p_source_2
140092 , p_source_3 => p_source_3
140093 , p_source_4 => p_source_4
140094 , p_source_5 => p_source_5
140095 )
140096 );
140097
140098
140099 --
140100 -- call ADRs
140101 -- Bug 4922099
140102 --
140103 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
140104 (NVL(l_actual_upg_option, 'N') = 'O') OR
140105 (NVL(l_enc_upg_option, 'N') = 'O')
140106 )
140107 THEN
140108 NULL;
140109 --
140110 --
140111
140112 l_ccid := AcctDerRule_28(
140113 p_application_id => p_application_id
140114 , p_ae_header_id => l_ae_header_id
140115 , p_source_15 => p_source_15
140116 , p_source_41 => p_source_41
140117 , p_source_42 => p_source_42
140118 , p_source_43 => p_source_43
140119 , p_source_44 => p_source_44
140120 , p_source_45 => p_source_45
140121 , x_transaction_coa_id => l_adr_transaction_coa_id
140122 , x_accounting_coa_id => l_adr_accounting_coa_id
140123 , x_value_type_code => l_adr_value_type_code
140124 , p_side => 'NA'
140125 );
140126
140127 xla_ae_lines_pkg.set_ccid(
140128 p_code_combination_id => l_ccid
140129 , p_value_type_code => l_adr_value_type_code
140130 , p_transaction_coa_id => l_adr_transaction_coa_id
140131 , p_accounting_coa_id => l_adr_accounting_coa_id
140132 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
140133 , p_adr_type_code => 'S'
140134 , p_component_type => l_component_type
140135 , p_component_code => l_component_code
140136 , p_component_type_code => l_component_type_code
140137 , p_component_appl_id => l_component_appl_id
140138 , p_amb_context_code => l_amb_context_code
140139 , p_side => 'NA'
140140 );
140141
140142
140143 --
140144 --
140145 END IF;
140146 --
140147 -- Bug 4922099
140148 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
140149 (NVL(l_enc_upg_option, 'N') = 'O')
140150 ) AND
140151 (l_bflow_method_code = 'PRIOR_ENTRY')
140152 )
140153 THEN
140154 IF
140155 --
140156 1 = 2
140157 --
140158 THEN
140159 xla_accounting_err_pkg.build_message
140160 (p_appli_s_name => 'XLA'
140161 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
140162 ,p_token_1 => 'LINE_NUMBER'
140163 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
140164 ,p_token_2 => 'LINE_TYPE_NAME'
140165 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
140166 l_component_type
140167 ,l_component_code
140168 ,l_component_type_code
140169 ,l_component_appl_id
140170 ,l_amb_context_code
140171 ,l_entity_code
140172 ,l_event_class_code
140173 )
140174 ,p_token_3 => 'OWNER'
140175 ,p_value_3 => xla_lookups_pkg.get_meaning(
140176 p_lookup_type => 'XLA_OWNER_TYPE'
140177 ,p_lookup_code => l_component_type_code
140178 )
140179 ,p_token_4 => 'PRODUCT_NAME'
140180 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
140181 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
140182 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
140183 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
140184 ,p_ae_header_id => NULL
140185 );
140186
140187 IF (C_LEVEL_ERROR>= g_log_level) THEN
140188 trace
140189 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
140190 ,p_level => C_LEVEL_ERROR
140191 ,p_module => l_log_module);
140192 END IF;
140193 END IF;
140194 END IF;
140195 --
140196 --
140197 ------------------------------------------------------------------------------------------------
140198 -- 4219869 Business Flow
140199 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
140200 -- Prior Entry. Currently, the following code is always generated.
140201 ------------------------------------------------------------------------------------------------
140202 XLA_AE_LINES_PKG.ValidateCurrentLine;
140203
140204 ------------------------------------------------------------------------------------
140205 -- 4219869 Business Flow
140206 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
140207 ------------------------------------------------------------------------------------
140208 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
140209
140210 ----------------------------------------------------------------------------------
140211 -- 4219869 Business Flow
140212 -- Update journal entry status -- Need to generate this within IF <condition>
140213 ----------------------------------------------------------------------------------
140214 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
140215 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
140216 ,p_balance_type_code => l_balance_type_code
140217 );
140218
140219 -------------------------------------------------------------------------------------------
140220 -- 4262811 - Generate the Accrual Reversal lines
140221 -------------------------------------------------------------------------------------------
140222 BEGIN
140223 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
140224 (g_array_event(p_event_id).array_value_num('header_index'));
140225 IF l_acc_rev_flag IS NULL THEN
140226 l_acc_rev_flag := 'N';
140227 END IF;
140228 EXCEPTION
140229 WHEN OTHERS THEN
140230 l_acc_rev_flag := 'N';
140231 END;
140232 --
140233 IF (l_acc_rev_flag = 'Y') THEN
140234
140235 -- 4645092 ------------------------------------------------------------------------------
140236 -- To allow MPA report to determine if it should generate report process
140237 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
140238 ------------------------------------------------------------------------------------------
140239
140240 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
140241 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
140242 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
140243 -- call ADRs
140244 -- Bug 4922099
140245 --
140246 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
140247 (NVL(l_actual_upg_option, 'N') = 'O') OR
140248 (NVL(l_enc_upg_option, 'N') = 'O')
140249 )
140250 THEN
140251 NULL;
140252 --
140253 --
140254
140255 l_ccid := AcctDerRule_28(
140256 p_application_id => p_application_id
140257 , p_ae_header_id => l_ae_header_id
140258 , p_source_15 => p_source_15
140259 , p_source_41 => p_source_41
140260 , p_source_42 => p_source_42
140261 , p_source_43 => p_source_43
140262 , p_source_44 => p_source_44
140263 , p_source_45 => p_source_45
140264 , x_transaction_coa_id => l_adr_transaction_coa_id
140265 , x_accounting_coa_id => l_adr_accounting_coa_id
140266 , x_value_type_code => l_adr_value_type_code
140267 , p_side => 'NA'
140268 );
140269
140270 xla_ae_lines_pkg.set_ccid(
140271 p_code_combination_id => l_ccid
140272 , p_value_type_code => l_adr_value_type_code
140273 , p_transaction_coa_id => l_adr_transaction_coa_id
140274 , p_accounting_coa_id => l_adr_accounting_coa_id
140275 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
140276 , p_adr_type_code => 'S'
140277 , p_component_type => l_component_type
140278 , p_component_code => l_component_code
140279 , p_component_type_code => l_component_type_code
140280 , p_component_appl_id => l_component_appl_id
140281 , p_amb_context_code => l_amb_context_code
140282 , p_side => 'NA'
140283 );
140284
140285
140286 --
140287 --
140288 END IF;
140289
140290 --
140291 -- Update the line information that should be overwritten
140292 --
140293 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
140294 p_header_num => 1);
140295 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
140296
140297 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
140298
140299 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
140300 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
140301 END IF;
140302
140303 --
140304 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
140305 --
140306 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
140307 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
140308 ELSE
140309 ---------------------------------------------------------------------------------------------------
140310 -- 4262811a Switch Sign
140311 ---------------------------------------------------------------------------------------------------
140312 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
140313 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
140314 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140315 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
140316 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140317 -- 5132302
140318 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
140319 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140320
140321 END IF;
140322
140323 -- 4955764
140324 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
140325 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
140326
140327
140328 XLA_AE_LINES_PKG.ValidateCurrentLine;
140329 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
140330
140331 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
140332 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
140333 ,p_balance_type_code => l_balance_type_code);
140334
140335 END IF;
140336
140337 -----------------------------------------------------------------------------------------
140338 -- 4262811 Multiperiod Accounting
140339 -----------------------------------------------------------------------------------------
140340 -- No MPA option is assigned.
140341
140342
140343 END IF;
140344 END IF;
140345 --
140346
140347 --
140348 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
140349 trace
140350 (p_msg => 'END of AcctLineType_265'
140351 ,p_level => C_LEVEL_PROCEDURE
140352 ,p_module => l_log_module);
140353 END IF;
140354 --
140355 EXCEPTION
140356 WHEN xla_exceptions_pkg.application_exception THEN
140357 RAISE;
140358 WHEN OTHERS THEN
140359 xla_exceptions_pkg.raise_message
140360 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_265');
140361 END AcctLineType_265;
140362 --
140363
140364 ---------------------------------------
140365 --
140366 -- PRIVATE FUNCTION
140367 -- AcctLineType_266
140368 --
140369 ---------------------------------------
140370 PROCEDURE AcctLineType_266 (
140371 p_application_id IN NUMBER
140372 ,p_event_id IN NUMBER
140373 ,p_calculate_acctd_flag IN VARCHAR2
140374 ,p_calculate_g_l_flag IN VARCHAR2
140375 ,p_actual_flag IN OUT VARCHAR2
140376 ,p_balance_type_code OUT VARCHAR2
140377 ,p_gain_or_loss_ref OUT VARCHAR2
140378
140379 --TRANSACTION_ID
140380 , p_source_1 IN NUMBER
140381 --Item Concatenated Segments
140382 , p_source_2 IN VARCHAR2
140383 --Transaction Quantity
140384 , p_source_3 IN NUMBER
140385 --Transaction Unit of Measure Code
140386 , p_source_4 IN VARCHAR2
140387 --Inventory Transaction Type Description
140388 , p_source_5 IN VARCHAR2
140389 --Cost Element Name
140390 , p_source_15 IN NUMBER
140391 --Product Line Accounting Category Material Account
140392 , p_source_41 IN NUMBER
140393 --Product Line Accounting Category Material Overhead Account
140394 , p_source_42 IN NUMBER
140395 --Product Line Accounting Category Resource Account
140396 , p_source_43 IN NUMBER
140397 --Product Line Accounting Category Outside Processing Account
140398 , p_source_44 IN NUMBER
140399 --Product Line Accounting Category Overhead Account
140400 , p_source_45 IN NUMBER
140401 --Applied to Application ID
140402 , p_source_79 IN NUMBER
140403 --Applied to Distribution Link Type
140404 , p_source_80 IN VARCHAR2
140405 --Applied to Entity Code
140406 , p_source_81 IN VARCHAR2
140407 --DISTRIBUTION_IDENTIFIER
140408 , p_source_84 IN NUMBER
140409 --Distribution Type
140410 , p_source_85 IN VARCHAR2
140411 , p_source_85_meaning IN VARCHAR2
140412 --Encumbrance Reversal Amount Entered
140413 , p_source_87 IN NUMBER
140414 --Entered Currency Code
140415 , p_source_88 IN VARCHAR2
140416 --Transaction Encumbrance Reversal Amount
140417 , p_source_89 IN NUMBER
140418 --Entered Amount
140419 , p_source_91 IN NUMBER
140420 --Currency Conversion Date
140421 , p_source_92 IN DATE
140422 --Currency Conversion Rate
140423 , p_source_93 IN NUMBER
140424 --Currency Conversion Type
140425 , p_source_94 IN VARCHAR2
140426 --Accounted Amount
140427 , p_source_95 IN NUMBER
140428 --Accounting Line Type
140429 , p_source_97 IN NUMBER
140430 --Costing Encumbrance Upgrade Option
140431 , p_source_100 IN VARCHAR2
140432 --TXN_PO_DISTRIBUTION_ID
140433 , p_source_101 IN NUMBER
140434 --TXN_PO_HEADER_ID
140435 , p_source_102 IN NUMBER
140436 --Requisition Budget Account
140437 , p_source_103 IN NUMBER
140438 --Requisition Encumbrance Type Identifier
140439 , p_source_104 IN NUMBER
140440 --Organization Code
140441 , p_source_108 IN VARCHAR2
140442 )
140443 IS
140444
140445 l_component_type VARCHAR2(80);
140446 l_component_code VARCHAR2(30);
140447 l_component_type_code VARCHAR2(1);
140448 l_component_appl_id INTEGER;
140449 l_amb_context_code VARCHAR2(30);
140450 l_entity_code VARCHAR2(30);
140451 l_event_class_code VARCHAR2(30);
140452 l_ae_header_id NUMBER;
140453 l_event_type_code VARCHAR2(30);
140454 l_line_definition_code VARCHAR2(30);
140455 l_line_definition_owner_code VARCHAR2(1);
140456 --
140457 -- adr variables
140458 l_segment VARCHAR2(30);
140459 l_ccid NUMBER;
140460 l_adr_transaction_coa_id NUMBER;
140461 l_adr_accounting_coa_id NUMBER;
140462 l_adr_flexfield_segment_code VARCHAR2(30);
140463 l_adr_flex_value_set_id NUMBER;
140464 l_adr_value_type_code VARCHAR2(30);
140465 l_adr_value_combination_id NUMBER;
140466 l_adr_value_segment_code VARCHAR2(30);
140467
140468 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
140469 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
140470 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
140471 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
140472
140473 -- 4262811 Variables ------------------------------------------------------------------------------------------
140474 l_entered_amt_idx NUMBER;
140475 l_accted_amt_idx NUMBER;
140476 l_acc_rev_flag VARCHAR2(1);
140477 l_accrual_line_num NUMBER;
140478 l_tmp_amt NUMBER;
140479 l_acc_rev_natural_side_code VARCHAR2(1);
140480
140481 l_num_entries NUMBER;
140482 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
140483 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
140484 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
140485 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
140486 l_recog_line_1 NUMBER;
140487 l_recog_line_2 NUMBER;
140488
140489 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
140490 l_bflow_applied_to_amt NUMBER; -- 5132302
140491 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
140492
140493 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
140494
140495 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
140496 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
140497
140498 ---------------------------------------------------------------------------------------------------------------
140499
140500
140501 --
140502 -- bulk performance
140503 --
140504 l_balance_type_code VARCHAR2(1);
140505 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
140506 l_log_module VARCHAR2(240);
140507
140508 --
140509 -- Upgrade strategy
140510 --
140511 l_actual_upg_option VARCHAR2(1);
140512 l_enc_upg_option VARCHAR2(1);
140513
140514 --
140515 BEGIN
140516 --
140517 IF g_log_enabled THEN
140518 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_266';
140519 END IF;
140520 --
140521 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
140522
140523 trace
140524 (p_msg => 'BEGIN of AcctLineType_266'
140525 ,p_level => C_LEVEL_PROCEDURE
140526 ,p_module => l_log_module);
140527
140528 END IF;
140529 --
140530 l_component_type := 'AMB_JLT';
140531 l_component_code := 'INVENTORY_VALUATION';
140532 l_component_type_code := 'S';
140533 l_component_appl_id := 707;
140534 l_amb_context_code := 'DEFAULT';
140535 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
140536 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
140537 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
140538 l_line_definition_owner_code := 'S';
140539 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
140540 --
140541 l_balance_type_code := 'A';
140542 l_segment := NULL;
140543 l_ccid := NULL;
140544 l_adr_transaction_coa_id := NULL;
140545 l_adr_accounting_coa_id := NULL;
140546 l_adr_flexfield_segment_code := NULL;
140547 l_adr_flex_value_set_id := NULL;
140548 l_adr_value_type_code := NULL;
140549 l_adr_value_combination_id := NULL;
140550 l_adr_value_segment_code := NULL;
140551
140552 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
140553 l_bflow_class_code := ''; -- 4219869 Business Flow
140554 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
140555 l_budgetary_control_flag := 'N';
140556
140557 l_bflow_applied_to_amt_idx := NULL; -- 5132302
140558 l_bflow_applied_to_amt := NULL; -- 5132302
140559 l_entered_amt_idx := NULL; -- 4262811
140560 l_accted_amt_idx := NULL; -- 4262811
140561 l_acc_rev_flag := NULL; -- 4262811
140562 l_accrual_line_num := NULL; -- 4262811
140563 l_tmp_amt := NULL; -- 4262811
140564 --
140565
140566 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
140567 l_balance_type_code <> 'B' THEN
140568 IF NVL(p_source_97,9E125) = 1
140569 THEN
140570
140571 --
140572 XLA_AE_LINES_PKG.SetNewLine;
140573
140574 p_balance_type_code := l_balance_type_code;
140575 -- set the flag so later we will know whether the gain loss line needs to be created
140576
140577 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
140578 p_actual_flag :='A';
140579 END IF;
140580
140581 --
140582 -- bulk performance
140583 --
140584 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
140585 p_header_num => 0); -- 4262811
140586 --
140587 -- set accounting line options
140588 --
140589 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
140590 p_natural_side_code => 'D'
140591 , p_gain_or_loss_flag => 'N'
140592 , p_gl_transfer_mode_code => 'S'
140593 , p_acct_entry_type_code => 'A'
140594 , p_switch_side_flag => 'Y'
140595 , p_merge_duplicate_code => 'N'
140596 );
140597 --
140598 l_acc_rev_natural_side_code := 'C'; -- 4262811
140599 --
140600 --
140601 -- set accounting line type info
140602 --
140603 xla_ae_lines_pkg.SetAcctLineType
140604 (p_component_type => l_component_type
140605 ,p_event_type_code => l_event_type_code
140606 ,p_line_definition_owner_code => l_line_definition_owner_code
140607 ,p_line_definition_code => l_line_definition_code
140608 ,p_accounting_line_code => l_component_code
140609 ,p_accounting_line_type_code => l_component_type_code
140610 ,p_accounting_line_appl_id => l_component_appl_id
140611 ,p_amb_context_code => l_amb_context_code
140612 ,p_entity_code => l_entity_code
140613 ,p_event_class_code => l_event_class_code);
140614 --
140615 -- set accounting class
140616 --
140617 xla_ae_lines_pkg.SetAcctClass(
140618 p_accounting_class_code => 'INVENTORY_VALUATION'
140619 , p_ae_header_id => l_ae_header_id
140620 );
140621
140622 --
140623 -- set rounding class
140624 --
140625 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
140626 'INVENTORY_VALUATION';
140627
140628 --
140629 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
140630 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
140631 --
140632 -- bulk performance
140633 --
140634 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
140635
140636 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
140637 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
140638
140639 -- 4955764
140640 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
140641 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
140642
140643 -- 4458381 Public Sector Enh
140644
140645 --
140646 -- set accounting attributes for the line type
140647 --
140648 l_entered_amt_idx := 17;
140649 l_accted_amt_idx := 22;
140650 l_bflow_applied_to_amt_idx := NULL; -- 5132302
140651 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
140652 l_rec_acct_attrs.array_num_value(1) := p_source_79;
140653 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
140654 l_rec_acct_attrs.array_char_value(2) := p_source_80;
140655 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
140656 l_rec_acct_attrs.array_char_value(3) := p_source_81;
140657 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
140658 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
140659 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
140660 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
140661 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
140662 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
140663 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
140664 l_rec_acct_attrs.array_char_value(7) := p_source_85;
140665 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
140666 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
140667 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
140668 l_rec_acct_attrs.array_num_value(9) := p_source_87;
140669 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
140670 l_rec_acct_attrs.array_char_value(10) := p_source_88;
140671 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
140672 l_rec_acct_attrs.array_num_value(11) := p_source_89;
140673 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
140674 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
140675 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
140676 l_rec_acct_attrs.array_num_value(13) := p_source_87;
140677 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
140678 l_rec_acct_attrs.array_char_value(14) := p_source_88;
140679 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
140680 l_rec_acct_attrs.array_num_value(15) := p_source_89;
140681 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
140682 l_rec_acct_attrs.array_char_value(16) := p_source_100;
140683 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
140684 l_rec_acct_attrs.array_num_value(17) := p_source_91;
140685 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
140686 l_rec_acct_attrs.array_char_value(18) := p_source_88;
140687 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
140688 l_rec_acct_attrs.array_date_value(19) := p_source_92;
140689 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
140690 l_rec_acct_attrs.array_num_value(20) := p_source_93;
140691 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
140692 l_rec_acct_attrs.array_char_value(21) := p_source_94;
140693 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
140694 l_rec_acct_attrs.array_num_value(22) := p_source_95;
140695 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
140696 l_rec_acct_attrs.array_num_value(23) := p_source_104;
140697 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
140698 l_rec_acct_attrs.array_num_value(24) := p_source_104;
140699
140700 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
140701 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
140702
140703 ---------------------------------------------------------------------------------------------------------------
140704 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
140705 ---------------------------------------------------------------------------------------------------------------
140706 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
140707
140708 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
140709 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
140710
140711 IF xla_accounting_cache_pkg.GetValueChar
140712 (p_source_code => 'LEDGER_CATEGORY_CODE'
140713 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
140714 AND l_bflow_method_code = 'PRIOR_ENTRY'
140715 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
140716 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
140717 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
140718 )
140719 THEN
140720 xla_ae_lines_pkg.BflowUpgEntry
140721 (p_business_method_code => l_bflow_method_code
140722 ,p_business_class_code => l_bflow_class_code
140723 ,p_balance_type => l_balance_type_code);
140724 ELSE
140725 NULL;
140726 -- No business flow processing for business flow method of NONE.
140727 END IF;
140728
140729 --
140730 -- call analytical criteria
140731 --
140732
140733
140734 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
140735 xla_ae_lines_pkg.SetAnalyticalCriteria(
140736 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
140737 , p_analytical_criterion_owner => 'S'
140738 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
140739 , p_amb_context_code => 'DEFAULT'
140740 , p_balancing_flag => 'Y'
140741
140742 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
140743 , p_analytical_detail_num_1 => NULL
140744 , p_analytical_detail_date_1 => NULL
140745
140746 , p_ae_header_id => l_ae_header_id
140747 )
140748 ;
140749 --
140750
140751 --
140752 -- call description
140753 --
140754
140755 xla_ae_lines_pkg.SetLineDescription(
140756 p_ae_header_id => l_ae_header_id
140757 ,p_description => Description_1 (
140758 p_application_id => p_application_id
140759 , p_ae_header_id => l_ae_header_id
140760 , p_source_1 => p_source_1
140761 , p_source_2 => p_source_2
140762 , p_source_3 => p_source_3
140763 , p_source_4 => p_source_4
140764 , p_source_5 => p_source_5
140765 )
140766 );
140767
140768
140769 --
140770 -- call ADRs
140771 -- Bug 4922099
140772 --
140773 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
140774 (NVL(l_actual_upg_option, 'N') = 'O') OR
140775 (NVL(l_enc_upg_option, 'N') = 'O')
140776 )
140777 THEN
140778 NULL;
140779 --
140780 --
140781
140782 l_ccid := AcctDerRule_28(
140783 p_application_id => p_application_id
140784 , p_ae_header_id => l_ae_header_id
140785 , p_source_15 => p_source_15
140786 , p_source_41 => p_source_41
140787 , p_source_42 => p_source_42
140788 , p_source_43 => p_source_43
140789 , p_source_44 => p_source_44
140790 , p_source_45 => p_source_45
140791 , x_transaction_coa_id => l_adr_transaction_coa_id
140792 , x_accounting_coa_id => l_adr_accounting_coa_id
140793 , x_value_type_code => l_adr_value_type_code
140794 , p_side => 'NA'
140795 );
140796
140797 xla_ae_lines_pkg.set_ccid(
140798 p_code_combination_id => l_ccid
140799 , p_value_type_code => l_adr_value_type_code
140800 , p_transaction_coa_id => l_adr_transaction_coa_id
140801 , p_accounting_coa_id => l_adr_accounting_coa_id
140802 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
140803 , p_adr_type_code => 'S'
140804 , p_component_type => l_component_type
140805 , p_component_code => l_component_code
140806 , p_component_type_code => l_component_type_code
140807 , p_component_appl_id => l_component_appl_id
140808 , p_amb_context_code => l_amb_context_code
140809 , p_side => 'NA'
140810 );
140811
140812
140813 --
140814 --
140815 END IF;
140816 --
140817 -- Bug 4922099
140818 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
140819 (NVL(l_enc_upg_option, 'N') = 'O')
140820 ) AND
140821 (l_bflow_method_code = 'PRIOR_ENTRY')
140822 )
140823 THEN
140824 IF
140825 --
140826 1 = 2
140827 --
140828 THEN
140829 xla_accounting_err_pkg.build_message
140830 (p_appli_s_name => 'XLA'
140831 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
140832 ,p_token_1 => 'LINE_NUMBER'
140833 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
140834 ,p_token_2 => 'LINE_TYPE_NAME'
140835 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
140836 l_component_type
140837 ,l_component_code
140838 ,l_component_type_code
140839 ,l_component_appl_id
140840 ,l_amb_context_code
140841 ,l_entity_code
140842 ,l_event_class_code
140843 )
140844 ,p_token_3 => 'OWNER'
140845 ,p_value_3 => xla_lookups_pkg.get_meaning(
140846 p_lookup_type => 'XLA_OWNER_TYPE'
140847 ,p_lookup_code => l_component_type_code
140848 )
140849 ,p_token_4 => 'PRODUCT_NAME'
140850 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
140851 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
140852 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
140853 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
140854 ,p_ae_header_id => NULL
140855 );
140856
140857 IF (C_LEVEL_ERROR>= g_log_level) THEN
140858 trace
140859 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
140860 ,p_level => C_LEVEL_ERROR
140861 ,p_module => l_log_module);
140862 END IF;
140863 END IF;
140864 END IF;
140865 --
140866 --
140867 ------------------------------------------------------------------------------------------------
140868 -- 4219869 Business Flow
140869 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
140870 -- Prior Entry. Currently, the following code is always generated.
140871 ------------------------------------------------------------------------------------------------
140872 XLA_AE_LINES_PKG.ValidateCurrentLine;
140873
140874 ------------------------------------------------------------------------------------
140875 -- 4219869 Business Flow
140876 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
140877 ------------------------------------------------------------------------------------
140878 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
140879
140880 ----------------------------------------------------------------------------------
140881 -- 4219869 Business Flow
140882 -- Update journal entry status -- Need to generate this within IF <condition>
140883 ----------------------------------------------------------------------------------
140884 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
140885 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
140886 ,p_balance_type_code => l_balance_type_code
140887 );
140888
140889 -------------------------------------------------------------------------------------------
140890 -- 4262811 - Generate the Accrual Reversal lines
140891 -------------------------------------------------------------------------------------------
140892 BEGIN
140893 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
140894 (g_array_event(p_event_id).array_value_num('header_index'));
140895 IF l_acc_rev_flag IS NULL THEN
140896 l_acc_rev_flag := 'N';
140897 END IF;
140898 EXCEPTION
140899 WHEN OTHERS THEN
140900 l_acc_rev_flag := 'N';
140901 END;
140902 --
140903 IF (l_acc_rev_flag = 'Y') THEN
140904
140905 -- 4645092 ------------------------------------------------------------------------------
140906 -- To allow MPA report to determine if it should generate report process
140907 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
140908 ------------------------------------------------------------------------------------------
140909
140910 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
140911 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
140912 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
140913 -- call ADRs
140914 -- Bug 4922099
140915 --
140916 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
140917 (NVL(l_actual_upg_option, 'N') = 'O') OR
140918 (NVL(l_enc_upg_option, 'N') = 'O')
140919 )
140920 THEN
140921 NULL;
140922 --
140923 --
140924
140925 l_ccid := AcctDerRule_28(
140926 p_application_id => p_application_id
140927 , p_ae_header_id => l_ae_header_id
140928 , p_source_15 => p_source_15
140929 , p_source_41 => p_source_41
140930 , p_source_42 => p_source_42
140931 , p_source_43 => p_source_43
140932 , p_source_44 => p_source_44
140933 , p_source_45 => p_source_45
140934 , x_transaction_coa_id => l_adr_transaction_coa_id
140935 , x_accounting_coa_id => l_adr_accounting_coa_id
140936 , x_value_type_code => l_adr_value_type_code
140937 , p_side => 'NA'
140938 );
140939
140940 xla_ae_lines_pkg.set_ccid(
140941 p_code_combination_id => l_ccid
140942 , p_value_type_code => l_adr_value_type_code
140943 , p_transaction_coa_id => l_adr_transaction_coa_id
140944 , p_accounting_coa_id => l_adr_accounting_coa_id
140945 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
140946 , p_adr_type_code => 'S'
140947 , p_component_type => l_component_type
140948 , p_component_code => l_component_code
140949 , p_component_type_code => l_component_type_code
140950 , p_component_appl_id => l_component_appl_id
140951 , p_amb_context_code => l_amb_context_code
140952 , p_side => 'NA'
140953 );
140954
140955
140956 --
140957 --
140958 END IF;
140959
140960 --
140961 -- Update the line information that should be overwritten
140962 --
140963 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
140964 p_header_num => 1);
140965 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
140966
140967 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
140968
140969 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
140970 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
140971 END IF;
140972
140973 --
140974 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
140975 --
140976 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
140977 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
140978 ELSE
140979 ---------------------------------------------------------------------------------------------------
140980 -- 4262811a Switch Sign
140981 ---------------------------------------------------------------------------------------------------
140982 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
140983 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
140984 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140985 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
140986 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140987 -- 5132302
140988 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
140989 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
140990
140991 END IF;
140992
140993 -- 4955764
140994 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
140995 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
140996
140997
140998 XLA_AE_LINES_PKG.ValidateCurrentLine;
140999 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
141000
141001 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
141002 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
141003 ,p_balance_type_code => l_balance_type_code);
141004
141005 END IF;
141006
141007 -----------------------------------------------------------------------------------------
141008 -- 4262811 Multiperiod Accounting
141009 -----------------------------------------------------------------------------------------
141010 -- No MPA option is assigned.
141011
141012
141013 END IF;
141014 END IF;
141015 --
141016
141017 --
141018 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
141019 trace
141020 (p_msg => 'END of AcctLineType_266'
141021 ,p_level => C_LEVEL_PROCEDURE
141022 ,p_module => l_log_module);
141023 END IF;
141024 --
141025 EXCEPTION
141026 WHEN xla_exceptions_pkg.application_exception THEN
141027 RAISE;
141028 WHEN OTHERS THEN
141029 xla_exceptions_pkg.raise_message
141030 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_266');
141031 END AcctLineType_266;
141032 --
141033
141034 ---------------------------------------
141035 --
141036 -- PRIVATE FUNCTION
141037 -- AcctLineType_267
141038 --
141039 ---------------------------------------
141040 PROCEDURE AcctLineType_267 (
141041 p_application_id IN NUMBER
141042 ,p_event_id IN NUMBER
141043 ,p_calculate_acctd_flag IN VARCHAR2
141044 ,p_calculate_g_l_flag IN VARCHAR2
141045 ,p_actual_flag IN OUT VARCHAR2
141046 ,p_balance_type_code OUT VARCHAR2
141047 ,p_gain_or_loss_ref OUT VARCHAR2
141048
141049 --TRANSACTION_ID
141050 , p_source_1 IN NUMBER
141051 --Item Concatenated Segments
141052 , p_source_2 IN VARCHAR2
141053 --Transaction Quantity
141054 , p_source_3 IN NUMBER
141055 --Transaction Unit of Measure Code
141056 , p_source_4 IN VARCHAR2
141057 --Inventory Transaction Type Description
141058 , p_source_5 IN VARCHAR2
141059 --Cost Element Name
141060 , p_source_15 IN NUMBER
141061 --Product Line Accounting Category Material Account
141062 , p_source_41 IN NUMBER
141063 --Product Line Accounting Category Material Overhead Account
141064 , p_source_42 IN NUMBER
141065 --Product Line Accounting Category Resource Account
141066 , p_source_43 IN NUMBER
141067 --Product Line Accounting Category Outside Processing Account
141068 , p_source_44 IN NUMBER
141069 --Product Line Accounting Category Overhead Account
141070 , p_source_45 IN NUMBER
141071 --DISTRIBUTION_IDENTIFIER
141072 , p_source_84 IN NUMBER
141073 --Distribution Type
141074 , p_source_85 IN VARCHAR2
141075 , p_source_85_meaning IN VARCHAR2
141076 --Entered Currency Code
141077 , p_source_88 IN VARCHAR2
141078 --Entered Amount
141079 , p_source_91 IN NUMBER
141080 --Currency Conversion Date
141081 , p_source_92 IN DATE
141082 --Currency Conversion Rate
141083 , p_source_93 IN NUMBER
141084 --Currency Conversion Type
141085 , p_source_94 IN VARCHAR2
141086 --Accounted Amount
141087 , p_source_95 IN NUMBER
141088 --Accounting Line Type
141089 , p_source_97 IN NUMBER
141090 --Organization Code
141091 , p_source_108 IN VARCHAR2
141092 )
141093 IS
141094
141095 l_component_type VARCHAR2(80);
141096 l_component_code VARCHAR2(30);
141097 l_component_type_code VARCHAR2(1);
141098 l_component_appl_id INTEGER;
141099 l_amb_context_code VARCHAR2(30);
141100 l_entity_code VARCHAR2(30);
141101 l_event_class_code VARCHAR2(30);
141102 l_ae_header_id NUMBER;
141103 l_event_type_code VARCHAR2(30);
141104 l_line_definition_code VARCHAR2(30);
141105 l_line_definition_owner_code VARCHAR2(1);
141106 --
141107 -- adr variables
141108 l_segment VARCHAR2(30);
141109 l_ccid NUMBER;
141110 l_adr_transaction_coa_id NUMBER;
141111 l_adr_accounting_coa_id NUMBER;
141112 l_adr_flexfield_segment_code VARCHAR2(30);
141113 l_adr_flex_value_set_id NUMBER;
141114 l_adr_value_type_code VARCHAR2(30);
141115 l_adr_value_combination_id NUMBER;
141116 l_adr_value_segment_code VARCHAR2(30);
141117
141118 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
141119 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
141120 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
141121 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
141122
141123 -- 4262811 Variables ------------------------------------------------------------------------------------------
141124 l_entered_amt_idx NUMBER;
141125 l_accted_amt_idx NUMBER;
141126 l_acc_rev_flag VARCHAR2(1);
141127 l_accrual_line_num NUMBER;
141128 l_tmp_amt NUMBER;
141129 l_acc_rev_natural_side_code VARCHAR2(1);
141130
141131 l_num_entries NUMBER;
141132 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
141133 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
141134 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
141135 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
141136 l_recog_line_1 NUMBER;
141137 l_recog_line_2 NUMBER;
141138
141139 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
141140 l_bflow_applied_to_amt NUMBER; -- 5132302
141141 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
141142
141143 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
141144
141145 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
141146 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
141147
141148 ---------------------------------------------------------------------------------------------------------------
141149
141150
141151 --
141152 -- bulk performance
141153 --
141154 l_balance_type_code VARCHAR2(1);
141155 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
141156 l_log_module VARCHAR2(240);
141157
141158 --
141159 -- Upgrade strategy
141160 --
141161 l_actual_upg_option VARCHAR2(1);
141162 l_enc_upg_option VARCHAR2(1);
141163
141164 --
141165 BEGIN
141166 --
141167 IF g_log_enabled THEN
141168 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_267';
141169 END IF;
141170 --
141171 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
141172
141173 trace
141174 (p_msg => 'BEGIN of AcctLineType_267'
141175 ,p_level => C_LEVEL_PROCEDURE
141176 ,p_module => l_log_module);
141177
141178 END IF;
141179 --
141180 l_component_type := 'AMB_JLT';
141181 l_component_code := 'INVENTORY_VALUATION';
141182 l_component_type_code := 'S';
141183 l_component_appl_id := 707;
141184 l_amb_context_code := 'DEFAULT';
141185 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
141186 l_event_class_code := 'LOG_INTERCOMPANY';
141187 l_event_type_code := 'LOG_IC_SALES_ISSUE';
141188 l_line_definition_owner_code := 'S';
141189 l_line_definition_code := 'PI_LOG_IC_SALES_ISSUE';
141190 --
141191 l_balance_type_code := 'A';
141192 l_segment := NULL;
141193 l_ccid := NULL;
141194 l_adr_transaction_coa_id := NULL;
141195 l_adr_accounting_coa_id := NULL;
141196 l_adr_flexfield_segment_code := NULL;
141197 l_adr_flex_value_set_id := NULL;
141198 l_adr_value_type_code := NULL;
141199 l_adr_value_combination_id := NULL;
141200 l_adr_value_segment_code := NULL;
141201
141202 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
141203 l_bflow_class_code := ''; -- 4219869 Business Flow
141204 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
141205 l_budgetary_control_flag := 'N';
141206
141207 l_bflow_applied_to_amt_idx := NULL; -- 5132302
141208 l_bflow_applied_to_amt := NULL; -- 5132302
141209 l_entered_amt_idx := NULL; -- 4262811
141210 l_accted_amt_idx := NULL; -- 4262811
141211 l_acc_rev_flag := NULL; -- 4262811
141212 l_accrual_line_num := NULL; -- 4262811
141213 l_tmp_amt := NULL; -- 4262811
141214 --
141215
141216 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
141217 l_balance_type_code <> 'B' THEN
141218 IF NVL(p_source_97,9E125) = 1
141219 THEN
141220
141221 --
141222 XLA_AE_LINES_PKG.SetNewLine;
141223
141224 p_balance_type_code := l_balance_type_code;
141225 -- set the flag so later we will know whether the gain loss line needs to be created
141226
141227 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
141228 p_actual_flag :='A';
141229 END IF;
141230
141231 --
141232 -- bulk performance
141233 --
141234 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
141235 p_header_num => 0); -- 4262811
141236 --
141237 -- set accounting line options
141238 --
141239 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
141240 p_natural_side_code => 'D'
141241 , p_gain_or_loss_flag => 'N'
141242 , p_gl_transfer_mode_code => 'S'
141243 , p_acct_entry_type_code => 'A'
141244 , p_switch_side_flag => 'Y'
141245 , p_merge_duplicate_code => 'N'
141246 );
141247 --
141248 l_acc_rev_natural_side_code := 'C'; -- 4262811
141249 --
141250 --
141251 -- set accounting line type info
141252 --
141253 xla_ae_lines_pkg.SetAcctLineType
141254 (p_component_type => l_component_type
141255 ,p_event_type_code => l_event_type_code
141256 ,p_line_definition_owner_code => l_line_definition_owner_code
141257 ,p_line_definition_code => l_line_definition_code
141258 ,p_accounting_line_code => l_component_code
141259 ,p_accounting_line_type_code => l_component_type_code
141260 ,p_accounting_line_appl_id => l_component_appl_id
141261 ,p_amb_context_code => l_amb_context_code
141262 ,p_entity_code => l_entity_code
141263 ,p_event_class_code => l_event_class_code);
141264 --
141265 -- set accounting class
141266 --
141267 xla_ae_lines_pkg.SetAcctClass(
141268 p_accounting_class_code => 'INVENTORY_VALUATION'
141269 , p_ae_header_id => l_ae_header_id
141270 );
141271
141272 --
141273 -- set rounding class
141274 --
141275 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
141276 'INVENTORY_VALUATION';
141277
141278 --
141279 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
141280 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
141281 --
141282 -- bulk performance
141283 --
141284 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
141285
141286 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
141287 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
141288
141289 -- 4955764
141290 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
141291 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
141292
141293 -- 4458381 Public Sector Enh
141294
141295 --
141296 -- set accounting attributes for the line type
141297 --
141298 l_entered_amt_idx := 3;
141299 l_accted_amt_idx := 8;
141300 l_bflow_applied_to_amt_idx := NULL; -- 5132302
141301 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
141302 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
141303 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
141304 l_rec_acct_attrs.array_char_value(2) := p_source_85;
141305 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
141306 l_rec_acct_attrs.array_num_value(3) := p_source_91;
141307 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
141308 l_rec_acct_attrs.array_char_value(4) := p_source_88;
141309 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
141310 l_rec_acct_attrs.array_date_value(5) := p_source_92;
141311 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
141312 l_rec_acct_attrs.array_num_value(6) := p_source_93;
141313 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
141314 l_rec_acct_attrs.array_char_value(7) := p_source_94;
141315 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
141316 l_rec_acct_attrs.array_num_value(8) := p_source_95;
141317
141318 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
141319 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
141320
141321 ---------------------------------------------------------------------------------------------------------------
141322 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
141323 ---------------------------------------------------------------------------------------------------------------
141324 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
141325
141326 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
141327 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
141328
141329 IF xla_accounting_cache_pkg.GetValueChar
141330 (p_source_code => 'LEDGER_CATEGORY_CODE'
141331 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
141332 AND l_bflow_method_code = 'PRIOR_ENTRY'
141333 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
141334 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
141335 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
141336 )
141337 THEN
141338 xla_ae_lines_pkg.BflowUpgEntry
141339 (p_business_method_code => l_bflow_method_code
141340 ,p_business_class_code => l_bflow_class_code
141341 ,p_balance_type => l_balance_type_code);
141342 ELSE
141343 NULL;
141344 -- No business flow processing for business flow method of NONE.
141345 END IF;
141346
141347 --
141348 -- call analytical criteria
141349 --
141350
141351
141352 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
141353 xla_ae_lines_pkg.SetAnalyticalCriteria(
141354 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
141355 , p_analytical_criterion_owner => 'S'
141356 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
141357 , p_amb_context_code => 'DEFAULT'
141358 , p_balancing_flag => 'Y'
141359
141360 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
141361 , p_analytical_detail_num_1 => NULL
141362 , p_analytical_detail_date_1 => NULL
141363
141364 , p_ae_header_id => l_ae_header_id
141365 )
141366 ;
141367 --
141368
141369 --
141370 -- call description
141371 --
141372
141373 xla_ae_lines_pkg.SetLineDescription(
141374 p_ae_header_id => l_ae_header_id
141375 ,p_description => Description_1 (
141376 p_application_id => p_application_id
141377 , p_ae_header_id => l_ae_header_id
141378 , p_source_1 => p_source_1
141379 , p_source_2 => p_source_2
141380 , p_source_3 => p_source_3
141381 , p_source_4 => p_source_4
141382 , p_source_5 => p_source_5
141383 )
141384 );
141385
141386
141387 --
141388 -- call ADRs
141389 -- Bug 4922099
141390 --
141391 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
141392 (NVL(l_actual_upg_option, 'N') = 'O') OR
141393 (NVL(l_enc_upg_option, 'N') = 'O')
141394 )
141395 THEN
141396 NULL;
141397 --
141398 --
141399
141400 l_ccid := AcctDerRule_28(
141401 p_application_id => p_application_id
141402 , p_ae_header_id => l_ae_header_id
141403 , p_source_15 => p_source_15
141404 , p_source_41 => p_source_41
141405 , p_source_42 => p_source_42
141406 , p_source_43 => p_source_43
141407 , p_source_44 => p_source_44
141408 , p_source_45 => p_source_45
141409 , x_transaction_coa_id => l_adr_transaction_coa_id
141410 , x_accounting_coa_id => l_adr_accounting_coa_id
141411 , x_value_type_code => l_adr_value_type_code
141412 , p_side => 'NA'
141413 );
141414
141415 xla_ae_lines_pkg.set_ccid(
141416 p_code_combination_id => l_ccid
141417 , p_value_type_code => l_adr_value_type_code
141418 , p_transaction_coa_id => l_adr_transaction_coa_id
141419 , p_accounting_coa_id => l_adr_accounting_coa_id
141420 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
141421 , p_adr_type_code => 'S'
141422 , p_component_type => l_component_type
141423 , p_component_code => l_component_code
141424 , p_component_type_code => l_component_type_code
141425 , p_component_appl_id => l_component_appl_id
141426 , p_amb_context_code => l_amb_context_code
141427 , p_side => 'NA'
141428 );
141429
141430
141431 --
141432 --
141433 END IF;
141434 --
141435 -- Bug 4922099
141436 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
141437 (NVL(l_enc_upg_option, 'N') = 'O')
141438 ) AND
141439 (l_bflow_method_code = 'PRIOR_ENTRY')
141440 )
141441 THEN
141442 IF
141443 --
141444 1 = 2
141445 --
141446 THEN
141447 xla_accounting_err_pkg.build_message
141448 (p_appli_s_name => 'XLA'
141449 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
141450 ,p_token_1 => 'LINE_NUMBER'
141451 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
141452 ,p_token_2 => 'LINE_TYPE_NAME'
141453 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
141454 l_component_type
141455 ,l_component_code
141456 ,l_component_type_code
141457 ,l_component_appl_id
141458 ,l_amb_context_code
141459 ,l_entity_code
141460 ,l_event_class_code
141461 )
141462 ,p_token_3 => 'OWNER'
141463 ,p_value_3 => xla_lookups_pkg.get_meaning(
141464 p_lookup_type => 'XLA_OWNER_TYPE'
141465 ,p_lookup_code => l_component_type_code
141466 )
141467 ,p_token_4 => 'PRODUCT_NAME'
141468 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
141469 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
141470 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
141471 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
141472 ,p_ae_header_id => NULL
141473 );
141474
141475 IF (C_LEVEL_ERROR>= g_log_level) THEN
141476 trace
141477 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
141478 ,p_level => C_LEVEL_ERROR
141479 ,p_module => l_log_module);
141480 END IF;
141481 END IF;
141482 END IF;
141483 --
141484 --
141485 ------------------------------------------------------------------------------------------------
141486 -- 4219869 Business Flow
141487 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
141488 -- Prior Entry. Currently, the following code is always generated.
141489 ------------------------------------------------------------------------------------------------
141490 XLA_AE_LINES_PKG.ValidateCurrentLine;
141491
141492 ------------------------------------------------------------------------------------
141493 -- 4219869 Business Flow
141494 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
141495 ------------------------------------------------------------------------------------
141496 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
141497
141498 ----------------------------------------------------------------------------------
141499 -- 4219869 Business Flow
141500 -- Update journal entry status -- Need to generate this within IF <condition>
141501 ----------------------------------------------------------------------------------
141502 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
141503 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
141504 ,p_balance_type_code => l_balance_type_code
141505 );
141506
141507 -------------------------------------------------------------------------------------------
141508 -- 4262811 - Generate the Accrual Reversal lines
141509 -------------------------------------------------------------------------------------------
141510 BEGIN
141511 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
141512 (g_array_event(p_event_id).array_value_num('header_index'));
141513 IF l_acc_rev_flag IS NULL THEN
141514 l_acc_rev_flag := 'N';
141515 END IF;
141516 EXCEPTION
141517 WHEN OTHERS THEN
141518 l_acc_rev_flag := 'N';
141519 END;
141520 --
141521 IF (l_acc_rev_flag = 'Y') THEN
141522
141523 -- 4645092 ------------------------------------------------------------------------------
141524 -- To allow MPA report to determine if it should generate report process
141525 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
141526 ------------------------------------------------------------------------------------------
141527
141528 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
141529 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
141530 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
141531 -- call ADRs
141532 -- Bug 4922099
141533 --
141534 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
141535 (NVL(l_actual_upg_option, 'N') = 'O') OR
141536 (NVL(l_enc_upg_option, 'N') = 'O')
141537 )
141538 THEN
141539 NULL;
141540 --
141541 --
141542
141543 l_ccid := AcctDerRule_28(
141544 p_application_id => p_application_id
141545 , p_ae_header_id => l_ae_header_id
141546 , p_source_15 => p_source_15
141547 , p_source_41 => p_source_41
141548 , p_source_42 => p_source_42
141549 , p_source_43 => p_source_43
141550 , p_source_44 => p_source_44
141551 , p_source_45 => p_source_45
141552 , x_transaction_coa_id => l_adr_transaction_coa_id
141553 , x_accounting_coa_id => l_adr_accounting_coa_id
141554 , x_value_type_code => l_adr_value_type_code
141555 , p_side => 'NA'
141556 );
141557
141558 xla_ae_lines_pkg.set_ccid(
141559 p_code_combination_id => l_ccid
141560 , p_value_type_code => l_adr_value_type_code
141561 , p_transaction_coa_id => l_adr_transaction_coa_id
141562 , p_accounting_coa_id => l_adr_accounting_coa_id
141563 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
141564 , p_adr_type_code => 'S'
141565 , p_component_type => l_component_type
141566 , p_component_code => l_component_code
141567 , p_component_type_code => l_component_type_code
141568 , p_component_appl_id => l_component_appl_id
141569 , p_amb_context_code => l_amb_context_code
141570 , p_side => 'NA'
141571 );
141572
141573
141574 --
141575 --
141576 END IF;
141577
141578 --
141579 -- Update the line information that should be overwritten
141580 --
141581 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
141582 p_header_num => 1);
141583 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
141584
141585 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
141586
141587 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
141588 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
141589 END IF;
141590
141591 --
141592 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
141593 --
141594 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
141595 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
141596 ELSE
141597 ---------------------------------------------------------------------------------------------------
141598 -- 4262811a Switch Sign
141599 ---------------------------------------------------------------------------------------------------
141600 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
141601 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
141602 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
141603 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
141604 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
141605 -- 5132302
141606 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
141607 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
141608
141609 END IF;
141610
141611 -- 4955764
141612 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
141613 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
141614
141615
141616 XLA_AE_LINES_PKG.ValidateCurrentLine;
141617 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
141618
141619 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
141620 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
141621 ,p_balance_type_code => l_balance_type_code);
141622
141623 END IF;
141624
141625 -----------------------------------------------------------------------------------------
141626 -- 4262811 Multiperiod Accounting
141627 -----------------------------------------------------------------------------------------
141628 -- No MPA option is assigned.
141629
141630
141631 END IF;
141632 END IF;
141633 --
141634
141635 --
141636 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
141637 trace
141638 (p_msg => 'END of AcctLineType_267'
141639 ,p_level => C_LEVEL_PROCEDURE
141640 ,p_module => l_log_module);
141641 END IF;
141642 --
141643 EXCEPTION
141644 WHEN xla_exceptions_pkg.application_exception THEN
141645 RAISE;
141646 WHEN OTHERS THEN
141647 xla_exceptions_pkg.raise_message
141648 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_267');
141649 END AcctLineType_267;
141650 --
141651
141652 ---------------------------------------
141653 --
141654 -- PRIVATE FUNCTION
141655 -- AcctLineType_268
141656 --
141657 ---------------------------------------
141658 PROCEDURE AcctLineType_268 (
141659 p_application_id IN NUMBER
141660 ,p_event_id IN NUMBER
141661 ,p_calculate_acctd_flag IN VARCHAR2
141662 ,p_calculate_g_l_flag IN VARCHAR2
141663 ,p_actual_flag IN OUT VARCHAR2
141664 ,p_balance_type_code OUT VARCHAR2
141665 ,p_gain_or_loss_ref OUT VARCHAR2
141666
141667 --TRANSACTION_ID
141668 , p_source_1 IN NUMBER
141669 --Item Concatenated Segments
141670 , p_source_2 IN VARCHAR2
141671 --Transaction Quantity
141672 , p_source_3 IN NUMBER
141673 --Transaction Unit of Measure Code
141674 , p_source_4 IN VARCHAR2
141675 --Inventory Transaction Type Description
141676 , p_source_5 IN VARCHAR2
141677 --Cost Element Name
141678 , p_source_15 IN NUMBER
141679 --Product Line Accounting Category Material Account
141680 , p_source_41 IN NUMBER
141681 --Product Line Accounting Category Material Overhead Account
141682 , p_source_42 IN NUMBER
141683 --Product Line Accounting Category Resource Account
141684 , p_source_43 IN NUMBER
141685 --Product Line Accounting Category Outside Processing Account
141686 , p_source_44 IN NUMBER
141687 --Product Line Accounting Category Overhead Account
141688 , p_source_45 IN NUMBER
141689 --DISTRIBUTION_IDENTIFIER
141690 , p_source_84 IN NUMBER
141691 --Distribution Type
141692 , p_source_85 IN VARCHAR2
141693 , p_source_85_meaning IN VARCHAR2
141694 --Entered Currency Code
141695 , p_source_88 IN VARCHAR2
141696 --Entered Amount
141697 , p_source_91 IN NUMBER
141698 --Currency Conversion Date
141699 , p_source_92 IN DATE
141700 --Currency Conversion Rate
141701 , p_source_93 IN NUMBER
141702 --Currency Conversion Type
141703 , p_source_94 IN VARCHAR2
141704 --Accounted Amount
141705 , p_source_95 IN NUMBER
141706 --Accounting Line Type
141707 , p_source_97 IN NUMBER
141708 --Organization Code
141709 , p_source_108 IN VARCHAR2
141710 )
141711 IS
141712
141713 l_component_type VARCHAR2(80);
141714 l_component_code VARCHAR2(30);
141715 l_component_type_code VARCHAR2(1);
141716 l_component_appl_id INTEGER;
141717 l_amb_context_code VARCHAR2(30);
141718 l_entity_code VARCHAR2(30);
141719 l_event_class_code VARCHAR2(30);
141720 l_ae_header_id NUMBER;
141721 l_event_type_code VARCHAR2(30);
141722 l_line_definition_code VARCHAR2(30);
141723 l_line_definition_owner_code VARCHAR2(1);
141724 --
141725 -- adr variables
141726 l_segment VARCHAR2(30);
141727 l_ccid NUMBER;
141728 l_adr_transaction_coa_id NUMBER;
141729 l_adr_accounting_coa_id NUMBER;
141730 l_adr_flexfield_segment_code VARCHAR2(30);
141731 l_adr_flex_value_set_id NUMBER;
141732 l_adr_value_type_code VARCHAR2(30);
141733 l_adr_value_combination_id NUMBER;
141734 l_adr_value_segment_code VARCHAR2(30);
141735
141736 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
141737 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
141738 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
141739 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
141740
141741 -- 4262811 Variables ------------------------------------------------------------------------------------------
141742 l_entered_amt_idx NUMBER;
141743 l_accted_amt_idx NUMBER;
141744 l_acc_rev_flag VARCHAR2(1);
141745 l_accrual_line_num NUMBER;
141746 l_tmp_amt NUMBER;
141747 l_acc_rev_natural_side_code VARCHAR2(1);
141748
141749 l_num_entries NUMBER;
141750 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
141751 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
141752 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
141753 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
141754 l_recog_line_1 NUMBER;
141755 l_recog_line_2 NUMBER;
141756
141757 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
141758 l_bflow_applied_to_amt NUMBER; -- 5132302
141759 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
141760
141761 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
141762
141763 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
141764 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
141765
141766 ---------------------------------------------------------------------------------------------------------------
141767
141768
141769 --
141770 -- bulk performance
141771 --
141772 l_balance_type_code VARCHAR2(1);
141773 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
141774 l_log_module VARCHAR2(240);
141775
141776 --
141777 -- Upgrade strategy
141778 --
141779 l_actual_upg_option VARCHAR2(1);
141780 l_enc_upg_option VARCHAR2(1);
141781
141782 --
141783 BEGIN
141784 --
141785 IF g_log_enabled THEN
141786 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_268';
141787 END IF;
141788 --
141789 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
141790
141791 trace
141792 (p_msg => 'BEGIN of AcctLineType_268'
141793 ,p_level => C_LEVEL_PROCEDURE
141794 ,p_module => l_log_module);
141795
141796 END IF;
141797 --
141798 l_component_type := 'AMB_JLT';
141799 l_component_code := 'INVENTORY_VALUATION';
141800 l_component_type_code := 'S';
141801 l_component_appl_id := 707;
141802 l_amb_context_code := 'DEFAULT';
141803 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
141804 l_event_class_code := 'LOG_INTERCOMPANY';
141805 l_event_type_code := 'LOG_IC_SALES_RETURN';
141806 l_line_definition_owner_code := 'S';
141807 l_line_definition_code := 'PI_LOG_IC_SALES_RETURN';
141808 --
141809 l_balance_type_code := 'A';
141810 l_segment := NULL;
141811 l_ccid := NULL;
141812 l_adr_transaction_coa_id := NULL;
141813 l_adr_accounting_coa_id := NULL;
141814 l_adr_flexfield_segment_code := NULL;
141815 l_adr_flex_value_set_id := NULL;
141816 l_adr_value_type_code := NULL;
141817 l_adr_value_combination_id := NULL;
141818 l_adr_value_segment_code := NULL;
141819
141820 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
141821 l_bflow_class_code := ''; -- 4219869 Business Flow
141822 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
141823 l_budgetary_control_flag := 'N';
141824
141825 l_bflow_applied_to_amt_idx := NULL; -- 5132302
141826 l_bflow_applied_to_amt := NULL; -- 5132302
141827 l_entered_amt_idx := NULL; -- 4262811
141828 l_accted_amt_idx := NULL; -- 4262811
141829 l_acc_rev_flag := NULL; -- 4262811
141830 l_accrual_line_num := NULL; -- 4262811
141831 l_tmp_amt := NULL; -- 4262811
141832 --
141833
141834 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
141835 l_balance_type_code <> 'B' THEN
141836 IF NVL(p_source_97,9E125) = 1
141837 THEN
141838
141839 --
141840 XLA_AE_LINES_PKG.SetNewLine;
141841
141842 p_balance_type_code := l_balance_type_code;
141843 -- set the flag so later we will know whether the gain loss line needs to be created
141844
141845 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
141846 p_actual_flag :='A';
141847 END IF;
141848
141849 --
141850 -- bulk performance
141851 --
141852 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
141853 p_header_num => 0); -- 4262811
141854 --
141855 -- set accounting line options
141856 --
141857 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
141858 p_natural_side_code => 'D'
141859 , p_gain_or_loss_flag => 'N'
141860 , p_gl_transfer_mode_code => 'S'
141861 , p_acct_entry_type_code => 'A'
141862 , p_switch_side_flag => 'Y'
141863 , p_merge_duplicate_code => 'N'
141864 );
141865 --
141866 l_acc_rev_natural_side_code := 'C'; -- 4262811
141867 --
141868 --
141869 -- set accounting line type info
141870 --
141871 xla_ae_lines_pkg.SetAcctLineType
141872 (p_component_type => l_component_type
141873 ,p_event_type_code => l_event_type_code
141874 ,p_line_definition_owner_code => l_line_definition_owner_code
141875 ,p_line_definition_code => l_line_definition_code
141876 ,p_accounting_line_code => l_component_code
141877 ,p_accounting_line_type_code => l_component_type_code
141878 ,p_accounting_line_appl_id => l_component_appl_id
141879 ,p_amb_context_code => l_amb_context_code
141880 ,p_entity_code => l_entity_code
141881 ,p_event_class_code => l_event_class_code);
141882 --
141883 -- set accounting class
141884 --
141885 xla_ae_lines_pkg.SetAcctClass(
141886 p_accounting_class_code => 'INVENTORY_VALUATION'
141887 , p_ae_header_id => l_ae_header_id
141888 );
141889
141890 --
141891 -- set rounding class
141892 --
141893 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
141894 'INVENTORY_VALUATION';
141895
141896 --
141897 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
141898 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
141899 --
141900 -- bulk performance
141901 --
141902 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
141903
141904 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
141905 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
141906
141907 -- 4955764
141908 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
141909 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
141910
141911 -- 4458381 Public Sector Enh
141912
141913 --
141914 -- set accounting attributes for the line type
141915 --
141916 l_entered_amt_idx := 3;
141917 l_accted_amt_idx := 8;
141918 l_bflow_applied_to_amt_idx := NULL; -- 5132302
141919 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
141920 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
141921 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
141922 l_rec_acct_attrs.array_char_value(2) := p_source_85;
141923 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
141924 l_rec_acct_attrs.array_num_value(3) := p_source_91;
141925 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
141926 l_rec_acct_attrs.array_char_value(4) := p_source_88;
141927 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
141928 l_rec_acct_attrs.array_date_value(5) := p_source_92;
141929 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
141930 l_rec_acct_attrs.array_num_value(6) := p_source_93;
141931 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
141932 l_rec_acct_attrs.array_char_value(7) := p_source_94;
141933 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
141934 l_rec_acct_attrs.array_num_value(8) := p_source_95;
141935
141936 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
141937 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
141938
141939 ---------------------------------------------------------------------------------------------------------------
141940 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
141941 ---------------------------------------------------------------------------------------------------------------
141942 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
141943
141944 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
141945 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
141946
141947 IF xla_accounting_cache_pkg.GetValueChar
141948 (p_source_code => 'LEDGER_CATEGORY_CODE'
141949 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
141950 AND l_bflow_method_code = 'PRIOR_ENTRY'
141951 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
141952 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
141953 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
141954 )
141955 THEN
141956 xla_ae_lines_pkg.BflowUpgEntry
141957 (p_business_method_code => l_bflow_method_code
141958 ,p_business_class_code => l_bflow_class_code
141959 ,p_balance_type => l_balance_type_code);
141960 ELSE
141961 NULL;
141962 -- No business flow processing for business flow method of NONE.
141963 END IF;
141964
141965 --
141966 -- call analytical criteria
141967 --
141968
141969
141970 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
141971 xla_ae_lines_pkg.SetAnalyticalCriteria(
141972 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
141973 , p_analytical_criterion_owner => 'S'
141974 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
141975 , p_amb_context_code => 'DEFAULT'
141976 , p_balancing_flag => 'Y'
141977
141978 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
141979 , p_analytical_detail_num_1 => NULL
141980 , p_analytical_detail_date_1 => NULL
141981
141982 , p_ae_header_id => l_ae_header_id
141983 )
141984 ;
141985 --
141986
141987 --
141988 -- call description
141989 --
141990
141991 xla_ae_lines_pkg.SetLineDescription(
141992 p_ae_header_id => l_ae_header_id
141993 ,p_description => Description_1 (
141994 p_application_id => p_application_id
141995 , p_ae_header_id => l_ae_header_id
141996 , p_source_1 => p_source_1
141997 , p_source_2 => p_source_2
141998 , p_source_3 => p_source_3
141999 , p_source_4 => p_source_4
142000 , p_source_5 => p_source_5
142001 )
142002 );
142003
142004
142005 --
142006 -- call ADRs
142007 -- Bug 4922099
142008 --
142009 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
142010 (NVL(l_actual_upg_option, 'N') = 'O') OR
142011 (NVL(l_enc_upg_option, 'N') = 'O')
142012 )
142013 THEN
142014 NULL;
142015 --
142016 --
142017
142018 l_ccid := AcctDerRule_28(
142019 p_application_id => p_application_id
142020 , p_ae_header_id => l_ae_header_id
142021 , p_source_15 => p_source_15
142022 , p_source_41 => p_source_41
142023 , p_source_42 => p_source_42
142024 , p_source_43 => p_source_43
142025 , p_source_44 => p_source_44
142026 , p_source_45 => p_source_45
142027 , x_transaction_coa_id => l_adr_transaction_coa_id
142028 , x_accounting_coa_id => l_adr_accounting_coa_id
142029 , x_value_type_code => l_adr_value_type_code
142030 , p_side => 'NA'
142031 );
142032
142033 xla_ae_lines_pkg.set_ccid(
142034 p_code_combination_id => l_ccid
142035 , p_value_type_code => l_adr_value_type_code
142036 , p_transaction_coa_id => l_adr_transaction_coa_id
142037 , p_accounting_coa_id => l_adr_accounting_coa_id
142038 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
142039 , p_adr_type_code => 'S'
142040 , p_component_type => l_component_type
142041 , p_component_code => l_component_code
142042 , p_component_type_code => l_component_type_code
142043 , p_component_appl_id => l_component_appl_id
142044 , p_amb_context_code => l_amb_context_code
142045 , p_side => 'NA'
142046 );
142047
142048
142049 --
142050 --
142051 END IF;
142052 --
142053 -- Bug 4922099
142054 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
142055 (NVL(l_enc_upg_option, 'N') = 'O')
142056 ) AND
142057 (l_bflow_method_code = 'PRIOR_ENTRY')
142058 )
142059 THEN
142060 IF
142061 --
142062 1 = 2
142063 --
142064 THEN
142065 xla_accounting_err_pkg.build_message
142066 (p_appli_s_name => 'XLA'
142067 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
142068 ,p_token_1 => 'LINE_NUMBER'
142069 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
142070 ,p_token_2 => 'LINE_TYPE_NAME'
142071 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
142072 l_component_type
142073 ,l_component_code
142074 ,l_component_type_code
142075 ,l_component_appl_id
142076 ,l_amb_context_code
142077 ,l_entity_code
142078 ,l_event_class_code
142079 )
142080 ,p_token_3 => 'OWNER'
142081 ,p_value_3 => xla_lookups_pkg.get_meaning(
142082 p_lookup_type => 'XLA_OWNER_TYPE'
142083 ,p_lookup_code => l_component_type_code
142084 )
142085 ,p_token_4 => 'PRODUCT_NAME'
142086 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
142087 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
142088 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
142089 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
142090 ,p_ae_header_id => NULL
142091 );
142092
142093 IF (C_LEVEL_ERROR>= g_log_level) THEN
142094 trace
142095 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
142096 ,p_level => C_LEVEL_ERROR
142097 ,p_module => l_log_module);
142098 END IF;
142099 END IF;
142100 END IF;
142101 --
142102 --
142103 ------------------------------------------------------------------------------------------------
142104 -- 4219869 Business Flow
142105 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
142106 -- Prior Entry. Currently, the following code is always generated.
142107 ------------------------------------------------------------------------------------------------
142108 XLA_AE_LINES_PKG.ValidateCurrentLine;
142109
142110 ------------------------------------------------------------------------------------
142111 -- 4219869 Business Flow
142112 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
142113 ------------------------------------------------------------------------------------
142114 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
142115
142116 ----------------------------------------------------------------------------------
142117 -- 4219869 Business Flow
142118 -- Update journal entry status -- Need to generate this within IF <condition>
142119 ----------------------------------------------------------------------------------
142120 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
142121 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
142122 ,p_balance_type_code => l_balance_type_code
142123 );
142124
142125 -------------------------------------------------------------------------------------------
142126 -- 4262811 - Generate the Accrual Reversal lines
142127 -------------------------------------------------------------------------------------------
142128 BEGIN
142129 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
142130 (g_array_event(p_event_id).array_value_num('header_index'));
142131 IF l_acc_rev_flag IS NULL THEN
142132 l_acc_rev_flag := 'N';
142133 END IF;
142134 EXCEPTION
142135 WHEN OTHERS THEN
142136 l_acc_rev_flag := 'N';
142137 END;
142138 --
142139 IF (l_acc_rev_flag = 'Y') THEN
142140
142141 -- 4645092 ------------------------------------------------------------------------------
142142 -- To allow MPA report to determine if it should generate report process
142143 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
142144 ------------------------------------------------------------------------------------------
142145
142146 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
142147 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
142148 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
142149 -- call ADRs
142150 -- Bug 4922099
142151 --
142152 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
142153 (NVL(l_actual_upg_option, 'N') = 'O') OR
142154 (NVL(l_enc_upg_option, 'N') = 'O')
142155 )
142156 THEN
142157 NULL;
142158 --
142159 --
142160
142161 l_ccid := AcctDerRule_28(
142162 p_application_id => p_application_id
142163 , p_ae_header_id => l_ae_header_id
142164 , p_source_15 => p_source_15
142165 , p_source_41 => p_source_41
142166 , p_source_42 => p_source_42
142167 , p_source_43 => p_source_43
142168 , p_source_44 => p_source_44
142169 , p_source_45 => p_source_45
142170 , x_transaction_coa_id => l_adr_transaction_coa_id
142171 , x_accounting_coa_id => l_adr_accounting_coa_id
142172 , x_value_type_code => l_adr_value_type_code
142173 , p_side => 'NA'
142174 );
142175
142176 xla_ae_lines_pkg.set_ccid(
142177 p_code_combination_id => l_ccid
142178 , p_value_type_code => l_adr_value_type_code
142179 , p_transaction_coa_id => l_adr_transaction_coa_id
142180 , p_accounting_coa_id => l_adr_accounting_coa_id
142181 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
142182 , p_adr_type_code => 'S'
142183 , p_component_type => l_component_type
142184 , p_component_code => l_component_code
142185 , p_component_type_code => l_component_type_code
142186 , p_component_appl_id => l_component_appl_id
142187 , p_amb_context_code => l_amb_context_code
142188 , p_side => 'NA'
142189 );
142190
142191
142192 --
142193 --
142194 END IF;
142195
142196 --
142197 -- Update the line information that should be overwritten
142198 --
142199 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
142200 p_header_num => 1);
142201 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
142202
142203 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
142204
142205 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
142206 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
142207 END IF;
142208
142209 --
142210 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
142211 --
142212 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
142213 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
142214 ELSE
142215 ---------------------------------------------------------------------------------------------------
142216 -- 4262811a Switch Sign
142217 ---------------------------------------------------------------------------------------------------
142218 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
142219 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
142220 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142221 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
142222 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142223 -- 5132302
142224 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
142225 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142226
142227 END IF;
142228
142229 -- 4955764
142230 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
142231 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
142232
142233
142234 XLA_AE_LINES_PKG.ValidateCurrentLine;
142235 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
142236
142237 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
142238 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
142239 ,p_balance_type_code => l_balance_type_code);
142240
142241 END IF;
142242
142243 -----------------------------------------------------------------------------------------
142244 -- 4262811 Multiperiod Accounting
142245 -----------------------------------------------------------------------------------------
142246 -- No MPA option is assigned.
142247
142248
142249 END IF;
142250 END IF;
142251 --
142252
142253 --
142254 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142255 trace
142256 (p_msg => 'END of AcctLineType_268'
142257 ,p_level => C_LEVEL_PROCEDURE
142258 ,p_module => l_log_module);
142259 END IF;
142260 --
142261 EXCEPTION
142262 WHEN xla_exceptions_pkg.application_exception THEN
142263 RAISE;
142264 WHEN OTHERS THEN
142265 xla_exceptions_pkg.raise_message
142266 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_268');
142267 END AcctLineType_268;
142268 --
142269
142270 ---------------------------------------
142271 --
142272 -- PRIVATE FUNCTION
142273 -- AcctLineType_269
142274 --
142275 ---------------------------------------
142276 PROCEDURE AcctLineType_269 (
142277 p_application_id IN NUMBER
142278 ,p_event_id IN NUMBER
142279 ,p_calculate_acctd_flag IN VARCHAR2
142280 ,p_calculate_g_l_flag IN VARCHAR2
142281 ,p_actual_flag IN OUT VARCHAR2
142282 ,p_balance_type_code OUT VARCHAR2
142283 ,p_gain_or_loss_ref OUT VARCHAR2
142284
142285 --TRANSACTION_ID
142286 , p_source_1 IN NUMBER
142287 --Item Concatenated Segments
142288 , p_source_2 IN VARCHAR2
142289 --Transaction Quantity
142290 , p_source_3 IN NUMBER
142291 --Transaction Unit of Measure Code
142292 , p_source_4 IN VARCHAR2
142293 --Inventory Transaction Type Description
142294 , p_source_5 IN VARCHAR2
142295 --Cost Element Name
142296 , p_source_15 IN NUMBER
142297 --Product Line Accounting Category Material Account
142298 , p_source_41 IN NUMBER
142299 --Product Line Accounting Category Material Overhead Account
142300 , p_source_42 IN NUMBER
142301 --Product Line Accounting Category Resource Account
142302 , p_source_43 IN NUMBER
142303 --Product Line Accounting Category Outside Processing Account
142304 , p_source_44 IN NUMBER
142305 --Product Line Accounting Category Overhead Account
142306 , p_source_45 IN NUMBER
142307 --DISTRIBUTION_IDENTIFIER
142308 , p_source_84 IN NUMBER
142309 --Distribution Type
142310 , p_source_85 IN VARCHAR2
142311 , p_source_85_meaning IN VARCHAR2
142312 --Entered Currency Code
142313 , p_source_88 IN VARCHAR2
142314 --Entered Amount
142315 , p_source_91 IN NUMBER
142316 --Currency Conversion Date
142317 , p_source_92 IN DATE
142318 --Currency Conversion Rate
142319 , p_source_93 IN NUMBER
142320 --Currency Conversion Type
142321 , p_source_94 IN VARCHAR2
142322 --Accounted Amount
142323 , p_source_95 IN NUMBER
142324 --Accounting Line Type
142325 , p_source_97 IN NUMBER
142326 --Organization Code
142327 , p_source_108 IN VARCHAR2
142328 )
142329 IS
142330
142331 l_component_type VARCHAR2(80);
142332 l_component_code VARCHAR2(30);
142333 l_component_type_code VARCHAR2(1);
142334 l_component_appl_id INTEGER;
142335 l_amb_context_code VARCHAR2(30);
142336 l_entity_code VARCHAR2(30);
142337 l_event_class_code VARCHAR2(30);
142338 l_ae_header_id NUMBER;
142339 l_event_type_code VARCHAR2(30);
142340 l_line_definition_code VARCHAR2(30);
142341 l_line_definition_owner_code VARCHAR2(1);
142342 --
142343 -- adr variables
142344 l_segment VARCHAR2(30);
142345 l_ccid NUMBER;
142346 l_adr_transaction_coa_id NUMBER;
142347 l_adr_accounting_coa_id NUMBER;
142348 l_adr_flexfield_segment_code VARCHAR2(30);
142349 l_adr_flex_value_set_id NUMBER;
142350 l_adr_value_type_code VARCHAR2(30);
142351 l_adr_value_combination_id NUMBER;
142352 l_adr_value_segment_code VARCHAR2(30);
142353
142354 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
142355 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
142356 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
142357 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
142358
142359 -- 4262811 Variables ------------------------------------------------------------------------------------------
142360 l_entered_amt_idx NUMBER;
142361 l_accted_amt_idx NUMBER;
142362 l_acc_rev_flag VARCHAR2(1);
142363 l_accrual_line_num NUMBER;
142364 l_tmp_amt NUMBER;
142365 l_acc_rev_natural_side_code VARCHAR2(1);
142366
142367 l_num_entries NUMBER;
142368 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
142369 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
142370 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
142371 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
142372 l_recog_line_1 NUMBER;
142373 l_recog_line_2 NUMBER;
142374
142375 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
142376 l_bflow_applied_to_amt NUMBER; -- 5132302
142377 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
142378
142379 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
142380
142381 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
142382 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
142383
142384 ---------------------------------------------------------------------------------------------------------------
142385
142386
142387 --
142388 -- bulk performance
142389 --
142390 l_balance_type_code VARCHAR2(1);
142391 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
142392 l_log_module VARCHAR2(240);
142393
142394 --
142395 -- Upgrade strategy
142396 --
142397 l_actual_upg_option VARCHAR2(1);
142398 l_enc_upg_option VARCHAR2(1);
142399
142400 --
142401 BEGIN
142402 --
142403 IF g_log_enabled THEN
142404 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_269';
142405 END IF;
142406 --
142407 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142408
142409 trace
142410 (p_msg => 'BEGIN of AcctLineType_269'
142411 ,p_level => C_LEVEL_PROCEDURE
142412 ,p_module => l_log_module);
142413
142414 END IF;
142415 --
142416 l_component_type := 'AMB_JLT';
142417 l_component_code := 'INVENTORY_VALUATION';
142418 l_component_type_code := 'S';
142419 l_component_appl_id := 707;
142420 l_amb_context_code := 'DEFAULT';
142421 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
142422 l_event_class_code := 'MISC_ISSUE_RCPT';
142423 l_event_type_code := 'MISC_ISSUE_RCPT_ALL';
142424 l_line_definition_owner_code := 'S';
142425 l_line_definition_code := 'PI_MISC_ISSUE_RCPT';
142426 --
142427 l_balance_type_code := 'A';
142428 l_segment := NULL;
142429 l_ccid := NULL;
142430 l_adr_transaction_coa_id := NULL;
142431 l_adr_accounting_coa_id := NULL;
142432 l_adr_flexfield_segment_code := NULL;
142433 l_adr_flex_value_set_id := NULL;
142434 l_adr_value_type_code := NULL;
142435 l_adr_value_combination_id := NULL;
142436 l_adr_value_segment_code := NULL;
142437
142438 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
142439 l_bflow_class_code := ''; -- 4219869 Business Flow
142440 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
142441 l_budgetary_control_flag := 'N';
142442
142443 l_bflow_applied_to_amt_idx := NULL; -- 5132302
142444 l_bflow_applied_to_amt := NULL; -- 5132302
142445 l_entered_amt_idx := NULL; -- 4262811
142446 l_accted_amt_idx := NULL; -- 4262811
142447 l_acc_rev_flag := NULL; -- 4262811
142448 l_accrual_line_num := NULL; -- 4262811
142449 l_tmp_amt := NULL; -- 4262811
142450 --
142451
142452 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
142453 l_balance_type_code <> 'B' THEN
142454 IF NVL(p_source_97,9E125) = 1
142455 THEN
142456
142457 --
142458 XLA_AE_LINES_PKG.SetNewLine;
142459
142460 p_balance_type_code := l_balance_type_code;
142461 -- set the flag so later we will know whether the gain loss line needs to be created
142462
142463 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
142464 p_actual_flag :='A';
142465 END IF;
142466
142467 --
142468 -- bulk performance
142469 --
142470 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
142471 p_header_num => 0); -- 4262811
142472 --
142473 -- set accounting line options
142474 --
142475 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
142476 p_natural_side_code => 'D'
142477 , p_gain_or_loss_flag => 'N'
142478 , p_gl_transfer_mode_code => 'S'
142479 , p_acct_entry_type_code => 'A'
142480 , p_switch_side_flag => 'Y'
142481 , p_merge_duplicate_code => 'N'
142482 );
142483 --
142484 l_acc_rev_natural_side_code := 'C'; -- 4262811
142485 --
142486 --
142487 -- set accounting line type info
142488 --
142489 xla_ae_lines_pkg.SetAcctLineType
142490 (p_component_type => l_component_type
142491 ,p_event_type_code => l_event_type_code
142492 ,p_line_definition_owner_code => l_line_definition_owner_code
142493 ,p_line_definition_code => l_line_definition_code
142494 ,p_accounting_line_code => l_component_code
142495 ,p_accounting_line_type_code => l_component_type_code
142496 ,p_accounting_line_appl_id => l_component_appl_id
142497 ,p_amb_context_code => l_amb_context_code
142498 ,p_entity_code => l_entity_code
142499 ,p_event_class_code => l_event_class_code);
142500 --
142501 -- set accounting class
142502 --
142503 xla_ae_lines_pkg.SetAcctClass(
142504 p_accounting_class_code => 'INVENTORY_VALUATION'
142505 , p_ae_header_id => l_ae_header_id
142506 );
142507
142508 --
142509 -- set rounding class
142510 --
142511 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
142512 'INVENTORY_VALUATION';
142513
142514 --
142515 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
142516 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
142517 --
142518 -- bulk performance
142519 --
142520 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
142521
142522 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
142523 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
142524
142525 -- 4955764
142526 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
142527 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
142528
142529 -- 4458381 Public Sector Enh
142530
142531 --
142532 -- set accounting attributes for the line type
142533 --
142534 l_entered_amt_idx := 3;
142535 l_accted_amt_idx := 8;
142536 l_bflow_applied_to_amt_idx := NULL; -- 5132302
142537 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
142538 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
142539 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
142540 l_rec_acct_attrs.array_char_value(2) := p_source_85;
142541 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
142542 l_rec_acct_attrs.array_num_value(3) := p_source_91;
142543 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
142544 l_rec_acct_attrs.array_char_value(4) := p_source_88;
142545 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
142546 l_rec_acct_attrs.array_date_value(5) := p_source_92;
142547 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
142548 l_rec_acct_attrs.array_num_value(6) := p_source_93;
142549 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
142550 l_rec_acct_attrs.array_char_value(7) := p_source_94;
142551 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
142552 l_rec_acct_attrs.array_num_value(8) := p_source_95;
142553
142554 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
142555 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
142556
142557 ---------------------------------------------------------------------------------------------------------------
142558 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
142559 ---------------------------------------------------------------------------------------------------------------
142560 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
142561
142562 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
142563 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
142564
142565 IF xla_accounting_cache_pkg.GetValueChar
142566 (p_source_code => 'LEDGER_CATEGORY_CODE'
142567 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
142568 AND l_bflow_method_code = 'PRIOR_ENTRY'
142569 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
142570 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
142571 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
142572 )
142573 THEN
142574 xla_ae_lines_pkg.BflowUpgEntry
142575 (p_business_method_code => l_bflow_method_code
142576 ,p_business_class_code => l_bflow_class_code
142577 ,p_balance_type => l_balance_type_code);
142578 ELSE
142579 NULL;
142580 -- No business flow processing for business flow method of NONE.
142581 END IF;
142582
142583 --
142584 -- call analytical criteria
142585 --
142586
142587
142588 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
142589 xla_ae_lines_pkg.SetAnalyticalCriteria(
142590 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
142591 , p_analytical_criterion_owner => 'S'
142592 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
142593 , p_amb_context_code => 'DEFAULT'
142594 , p_balancing_flag => 'Y'
142595
142596 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
142597 , p_analytical_detail_num_1 => NULL
142598 , p_analytical_detail_date_1 => NULL
142599
142600 , p_ae_header_id => l_ae_header_id
142601 )
142602 ;
142603 --
142604
142605 --
142606 -- call description
142607 --
142608
142609 xla_ae_lines_pkg.SetLineDescription(
142610 p_ae_header_id => l_ae_header_id
142611 ,p_description => Description_1 (
142612 p_application_id => p_application_id
142613 , p_ae_header_id => l_ae_header_id
142614 , p_source_1 => p_source_1
142615 , p_source_2 => p_source_2
142616 , p_source_3 => p_source_3
142617 , p_source_4 => p_source_4
142618 , p_source_5 => p_source_5
142619 )
142620 );
142621
142622
142623 --
142624 -- call ADRs
142625 -- Bug 4922099
142626 --
142627 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
142628 (NVL(l_actual_upg_option, 'N') = 'O') OR
142629 (NVL(l_enc_upg_option, 'N') = 'O')
142630 )
142631 THEN
142632 NULL;
142633 --
142634 --
142635
142636 l_ccid := AcctDerRule_28(
142637 p_application_id => p_application_id
142638 , p_ae_header_id => l_ae_header_id
142639 , p_source_15 => p_source_15
142640 , p_source_41 => p_source_41
142641 , p_source_42 => p_source_42
142642 , p_source_43 => p_source_43
142643 , p_source_44 => p_source_44
142644 , p_source_45 => p_source_45
142645 , x_transaction_coa_id => l_adr_transaction_coa_id
142646 , x_accounting_coa_id => l_adr_accounting_coa_id
142647 , x_value_type_code => l_adr_value_type_code
142648 , p_side => 'NA'
142649 );
142650
142651 xla_ae_lines_pkg.set_ccid(
142652 p_code_combination_id => l_ccid
142653 , p_value_type_code => l_adr_value_type_code
142654 , p_transaction_coa_id => l_adr_transaction_coa_id
142655 , p_accounting_coa_id => l_adr_accounting_coa_id
142656 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
142657 , p_adr_type_code => 'S'
142658 , p_component_type => l_component_type
142659 , p_component_code => l_component_code
142660 , p_component_type_code => l_component_type_code
142661 , p_component_appl_id => l_component_appl_id
142662 , p_amb_context_code => l_amb_context_code
142663 , p_side => 'NA'
142664 );
142665
142666
142667 --
142668 --
142669 END IF;
142670 --
142671 -- Bug 4922099
142672 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
142673 (NVL(l_enc_upg_option, 'N') = 'O')
142674 ) AND
142675 (l_bflow_method_code = 'PRIOR_ENTRY')
142676 )
142677 THEN
142678 IF
142679 --
142680 1 = 2
142681 --
142682 THEN
142683 xla_accounting_err_pkg.build_message
142684 (p_appli_s_name => 'XLA'
142685 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
142686 ,p_token_1 => 'LINE_NUMBER'
142687 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
142688 ,p_token_2 => 'LINE_TYPE_NAME'
142689 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
142690 l_component_type
142691 ,l_component_code
142692 ,l_component_type_code
142693 ,l_component_appl_id
142694 ,l_amb_context_code
142695 ,l_entity_code
142696 ,l_event_class_code
142697 )
142698 ,p_token_3 => 'OWNER'
142699 ,p_value_3 => xla_lookups_pkg.get_meaning(
142700 p_lookup_type => 'XLA_OWNER_TYPE'
142701 ,p_lookup_code => l_component_type_code
142702 )
142703 ,p_token_4 => 'PRODUCT_NAME'
142704 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
142705 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
142706 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
142707 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
142708 ,p_ae_header_id => NULL
142709 );
142710
142711 IF (C_LEVEL_ERROR>= g_log_level) THEN
142712 trace
142713 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
142714 ,p_level => C_LEVEL_ERROR
142715 ,p_module => l_log_module);
142716 END IF;
142717 END IF;
142718 END IF;
142719 --
142720 --
142721 ------------------------------------------------------------------------------------------------
142722 -- 4219869 Business Flow
142723 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
142724 -- Prior Entry. Currently, the following code is always generated.
142725 ------------------------------------------------------------------------------------------------
142726 XLA_AE_LINES_PKG.ValidateCurrentLine;
142727
142728 ------------------------------------------------------------------------------------
142729 -- 4219869 Business Flow
142730 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
142731 ------------------------------------------------------------------------------------
142732 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
142733
142734 ----------------------------------------------------------------------------------
142735 -- 4219869 Business Flow
142736 -- Update journal entry status -- Need to generate this within IF <condition>
142737 ----------------------------------------------------------------------------------
142738 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
142739 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
142740 ,p_balance_type_code => l_balance_type_code
142741 );
142742
142743 -------------------------------------------------------------------------------------------
142744 -- 4262811 - Generate the Accrual Reversal lines
142745 -------------------------------------------------------------------------------------------
142746 BEGIN
142747 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
142748 (g_array_event(p_event_id).array_value_num('header_index'));
142749 IF l_acc_rev_flag IS NULL THEN
142750 l_acc_rev_flag := 'N';
142751 END IF;
142752 EXCEPTION
142753 WHEN OTHERS THEN
142754 l_acc_rev_flag := 'N';
142755 END;
142756 --
142757 IF (l_acc_rev_flag = 'Y') THEN
142758
142759 -- 4645092 ------------------------------------------------------------------------------
142760 -- To allow MPA report to determine if it should generate report process
142761 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
142762 ------------------------------------------------------------------------------------------
142763
142764 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
142765 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
142766 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
142767 -- call ADRs
142768 -- Bug 4922099
142769 --
142770 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
142771 (NVL(l_actual_upg_option, 'N') = 'O') OR
142772 (NVL(l_enc_upg_option, 'N') = 'O')
142773 )
142774 THEN
142775 NULL;
142776 --
142777 --
142778
142779 l_ccid := AcctDerRule_28(
142780 p_application_id => p_application_id
142781 , p_ae_header_id => l_ae_header_id
142782 , p_source_15 => p_source_15
142783 , p_source_41 => p_source_41
142784 , p_source_42 => p_source_42
142785 , p_source_43 => p_source_43
142786 , p_source_44 => p_source_44
142787 , p_source_45 => p_source_45
142788 , x_transaction_coa_id => l_adr_transaction_coa_id
142789 , x_accounting_coa_id => l_adr_accounting_coa_id
142790 , x_value_type_code => l_adr_value_type_code
142791 , p_side => 'NA'
142792 );
142793
142794 xla_ae_lines_pkg.set_ccid(
142795 p_code_combination_id => l_ccid
142796 , p_value_type_code => l_adr_value_type_code
142797 , p_transaction_coa_id => l_adr_transaction_coa_id
142798 , p_accounting_coa_id => l_adr_accounting_coa_id
142799 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
142800 , p_adr_type_code => 'S'
142801 , p_component_type => l_component_type
142802 , p_component_code => l_component_code
142803 , p_component_type_code => l_component_type_code
142804 , p_component_appl_id => l_component_appl_id
142805 , p_amb_context_code => l_amb_context_code
142806 , p_side => 'NA'
142807 );
142808
142809
142810 --
142811 --
142812 END IF;
142813
142814 --
142815 -- Update the line information that should be overwritten
142816 --
142817 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
142818 p_header_num => 1);
142819 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
142820
142821 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
142822
142823 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
142824 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
142825 END IF;
142826
142827 --
142828 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
142829 --
142830 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
142831 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
142832 ELSE
142833 ---------------------------------------------------------------------------------------------------
142834 -- 4262811a Switch Sign
142835 ---------------------------------------------------------------------------------------------------
142836 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
142837 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
142838 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142839 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
142840 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142841 -- 5132302
142842 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
142843 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
142844
142845 END IF;
142846
142847 -- 4955764
142848 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
142849 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
142850
142851
142852 XLA_AE_LINES_PKG.ValidateCurrentLine;
142853 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
142854
142855 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
142856 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
142857 ,p_balance_type_code => l_balance_type_code);
142858
142859 END IF;
142860
142861 -----------------------------------------------------------------------------------------
142862 -- 4262811 Multiperiod Accounting
142863 -----------------------------------------------------------------------------------------
142864 -- No MPA option is assigned.
142865
142866
142867 END IF;
142868 END IF;
142869 --
142870
142871 --
142872 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142873 trace
142874 (p_msg => 'END of AcctLineType_269'
142875 ,p_level => C_LEVEL_PROCEDURE
142876 ,p_module => l_log_module);
142877 END IF;
142878 --
142879 EXCEPTION
142880 WHEN xla_exceptions_pkg.application_exception THEN
142881 RAISE;
142882 WHEN OTHERS THEN
142883 xla_exceptions_pkg.raise_message
142884 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_269');
142885 END AcctLineType_269;
142886 --
142887
142888 ---------------------------------------
142889 --
142890 -- PRIVATE FUNCTION
142891 -- AcctLineType_270
142892 --
142893 ---------------------------------------
142894 PROCEDURE AcctLineType_270 (
142895 p_application_id IN NUMBER
142896 ,p_event_id IN NUMBER
142897 ,p_calculate_acctd_flag IN VARCHAR2
142898 ,p_calculate_g_l_flag IN VARCHAR2
142899 ,p_actual_flag IN OUT VARCHAR2
142900 ,p_balance_type_code OUT VARCHAR2
142901 ,p_gain_or_loss_ref OUT VARCHAR2
142902
142903 --TRANSACTION_ID
142904 , p_source_1 IN NUMBER
142905 --Item Concatenated Segments
142906 , p_source_2 IN VARCHAR2
142907 --Transaction Quantity
142908 , p_source_3 IN NUMBER
142909 --Transaction Unit of Measure Code
142910 , p_source_4 IN VARCHAR2
142911 --Inventory Transaction Type Description
142912 , p_source_5 IN VARCHAR2
142913 --Cost Element Name
142914 , p_source_15 IN NUMBER
142915 --Product Line Accounting Category Material Account
142916 , p_source_41 IN NUMBER
142917 --Product Line Accounting Category Material Overhead Account
142918 , p_source_42 IN NUMBER
142919 --Product Line Accounting Category Resource Account
142920 , p_source_43 IN NUMBER
142921 --Product Line Accounting Category Outside Processing Account
142922 , p_source_44 IN NUMBER
142923 --Product Line Accounting Category Overhead Account
142924 , p_source_45 IN NUMBER
142925 --Applied to Application ID
142926 , p_source_79 IN NUMBER
142927 --Applied to Distribution Link Type
142928 , p_source_80 IN VARCHAR2
142929 --Applied to Entity Code
142930 , p_source_81 IN VARCHAR2
142931 --Applied To Purchase Document Identifier
142932 , p_source_83 IN NUMBER
142933 --DISTRIBUTION_IDENTIFIER
142934 , p_source_84 IN NUMBER
142935 --Distribution Type
142936 , p_source_85 IN VARCHAR2
142937 , p_source_85_meaning IN VARCHAR2
142938 --PO Budget Account
142939 , p_source_86 IN NUMBER
142940 --Encumbrance Reversal Amount Entered
142941 , p_source_87 IN NUMBER
142942 --Entered Currency Code
142943 , p_source_88 IN VARCHAR2
142944 --Transaction Encumbrance Reversal Amount
142945 , p_source_89 IN NUMBER
142946 --Entered Amount
142947 , p_source_91 IN NUMBER
142948 --Currency Conversion Date
142949 , p_source_92 IN DATE
142950 --Currency Conversion Rate
142951 , p_source_93 IN NUMBER
142952 --Currency Conversion Type
142953 , p_source_94 IN VARCHAR2
142954 --Accounted Amount
142955 , p_source_95 IN NUMBER
142956 --Purchasing Encumbrance Type Identifier
142957 , p_source_96 IN NUMBER
142958 --Accounting Line Type
142959 , p_source_97 IN NUMBER
142960 --Costing Encumbrance Upgrade Option
142961 , p_source_100 IN VARCHAR2
142962 --TXN_PO_DISTRIBUTION_ID
142963 , p_source_101 IN NUMBER
142964 --Organization Code
142965 , p_source_108 IN VARCHAR2
142966 )
142967 IS
142968
142969 l_component_type VARCHAR2(80);
142970 l_component_code VARCHAR2(30);
142971 l_component_type_code VARCHAR2(1);
142972 l_component_appl_id INTEGER;
142973 l_amb_context_code VARCHAR2(30);
142974 l_entity_code VARCHAR2(30);
142975 l_event_class_code VARCHAR2(30);
142976 l_ae_header_id NUMBER;
142977 l_event_type_code VARCHAR2(30);
142978 l_line_definition_code VARCHAR2(30);
142979 l_line_definition_owner_code VARCHAR2(1);
142980 --
142981 -- adr variables
142982 l_segment VARCHAR2(30);
142983 l_ccid NUMBER;
142984 l_adr_transaction_coa_id NUMBER;
142985 l_adr_accounting_coa_id NUMBER;
142986 l_adr_flexfield_segment_code VARCHAR2(30);
142987 l_adr_flex_value_set_id NUMBER;
142988 l_adr_value_type_code VARCHAR2(30);
142989 l_adr_value_combination_id NUMBER;
142990 l_adr_value_segment_code VARCHAR2(30);
142991
142992 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
142993 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
142994 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
142995 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
142996
142997 -- 4262811 Variables ------------------------------------------------------------------------------------------
142998 l_entered_amt_idx NUMBER;
142999 l_accted_amt_idx NUMBER;
143000 l_acc_rev_flag VARCHAR2(1);
143001 l_accrual_line_num NUMBER;
143002 l_tmp_amt NUMBER;
143003 l_acc_rev_natural_side_code VARCHAR2(1);
143004
143005 l_num_entries NUMBER;
143006 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
143007 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
143008 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
143009 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
143010 l_recog_line_1 NUMBER;
143011 l_recog_line_2 NUMBER;
143012
143013 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
143014 l_bflow_applied_to_amt NUMBER; -- 5132302
143015 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
143016
143017 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
143018
143019 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
143020 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
143021
143022 ---------------------------------------------------------------------------------------------------------------
143023
143024
143025 --
143026 -- bulk performance
143027 --
143028 l_balance_type_code VARCHAR2(1);
143029 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
143030 l_log_module VARCHAR2(240);
143031
143032 --
143033 -- Upgrade strategy
143034 --
143035 l_actual_upg_option VARCHAR2(1);
143036 l_enc_upg_option VARCHAR2(1);
143037
143038 --
143039 BEGIN
143040 --
143041 IF g_log_enabled THEN
143042 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_270';
143043 END IF;
143044 --
143045 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
143046
143047 trace
143048 (p_msg => 'BEGIN of AcctLineType_270'
143049 ,p_level => C_LEVEL_PROCEDURE
143050 ,p_module => l_log_module);
143051
143052 END IF;
143053 --
143054 l_component_type := 'AMB_JLT';
143055 l_component_code := 'INVENTORY_VALUATION';
143056 l_component_type_code := 'S';
143057 l_component_appl_id := 707;
143058 l_amb_context_code := 'DEFAULT';
143059 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
143060 l_event_class_code := 'PURCHASE_ORDER';
143061 l_event_type_code := 'LOG_RET_RI_INV';
143062 l_line_definition_owner_code := 'S';
143063 l_line_definition_code := 'PI_LOG_RET_RI_INV';
143064 --
143065 l_balance_type_code := 'A';
143066 l_segment := NULL;
143067 l_ccid := NULL;
143068 l_adr_transaction_coa_id := NULL;
143069 l_adr_accounting_coa_id := NULL;
143070 l_adr_flexfield_segment_code := NULL;
143071 l_adr_flex_value_set_id := NULL;
143072 l_adr_value_type_code := NULL;
143073 l_adr_value_combination_id := NULL;
143074 l_adr_value_segment_code := NULL;
143075
143076 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
143077 l_bflow_class_code := ''; -- 4219869 Business Flow
143078 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
143079 l_budgetary_control_flag := 'N';
143080
143081 l_bflow_applied_to_amt_idx := NULL; -- 5132302
143082 l_bflow_applied_to_amt := NULL; -- 5132302
143083 l_entered_amt_idx := NULL; -- 4262811
143084 l_accted_amt_idx := NULL; -- 4262811
143085 l_acc_rev_flag := NULL; -- 4262811
143086 l_accrual_line_num := NULL; -- 4262811
143087 l_tmp_amt := NULL; -- 4262811
143088 --
143089
143090 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
143091 l_balance_type_code <> 'B' THEN
143092 IF NVL(p_source_97,9E125) = 1
143093 THEN
143094
143095 --
143096 XLA_AE_LINES_PKG.SetNewLine;
143097
143098 p_balance_type_code := l_balance_type_code;
143099 -- set the flag so later we will know whether the gain loss line needs to be created
143100
143101 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
143102 p_actual_flag :='A';
143103 END IF;
143104
143105 --
143106 -- bulk performance
143107 --
143108 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
143109 p_header_num => 0); -- 4262811
143110 --
143111 -- set accounting line options
143112 --
143113 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
143114 p_natural_side_code => 'D'
143115 , p_gain_or_loss_flag => 'N'
143116 , p_gl_transfer_mode_code => 'S'
143117 , p_acct_entry_type_code => 'A'
143118 , p_switch_side_flag => 'Y'
143119 , p_merge_duplicate_code => 'N'
143120 );
143121 --
143122 l_acc_rev_natural_side_code := 'C'; -- 4262811
143123 --
143124 --
143125 -- set accounting line type info
143126 --
143127 xla_ae_lines_pkg.SetAcctLineType
143128 (p_component_type => l_component_type
143129 ,p_event_type_code => l_event_type_code
143130 ,p_line_definition_owner_code => l_line_definition_owner_code
143131 ,p_line_definition_code => l_line_definition_code
143132 ,p_accounting_line_code => l_component_code
143133 ,p_accounting_line_type_code => l_component_type_code
143134 ,p_accounting_line_appl_id => l_component_appl_id
143135 ,p_amb_context_code => l_amb_context_code
143136 ,p_entity_code => l_entity_code
143137 ,p_event_class_code => l_event_class_code);
143138 --
143139 -- set accounting class
143140 --
143141 xla_ae_lines_pkg.SetAcctClass(
143142 p_accounting_class_code => 'INVENTORY_VALUATION'
143143 , p_ae_header_id => l_ae_header_id
143144 );
143145
143146 --
143147 -- set rounding class
143148 --
143149 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
143150 'INVENTORY_VALUATION';
143151
143152 --
143153 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
143154 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
143155 --
143156 -- bulk performance
143157 --
143158 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
143159
143160 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
143161 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
143162
143163 -- 4955764
143164 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
143165 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
143166
143167 -- 4458381 Public Sector Enh
143168
143169 --
143170 -- set accounting attributes for the line type
143171 --
143172 l_entered_amt_idx := 17;
143173 l_accted_amt_idx := 22;
143174 l_bflow_applied_to_amt_idx := NULL; -- 5132302
143175 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
143176 l_rec_acct_attrs.array_num_value(1) := p_source_79;
143177 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
143178 l_rec_acct_attrs.array_char_value(2) := p_source_80;
143179 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
143180 l_rec_acct_attrs.array_char_value(3) := p_source_81;
143181 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
143182 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
143183 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
143184 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
143185 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
143186 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
143187 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
143188 l_rec_acct_attrs.array_char_value(7) := p_source_85;
143189 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
143190 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
143191 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
143192 l_rec_acct_attrs.array_num_value(9) := p_source_87;
143193 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
143194 l_rec_acct_attrs.array_char_value(10) := p_source_88;
143195 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
143196 l_rec_acct_attrs.array_num_value(11) := p_source_89;
143197 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
143198 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
143199 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
143200 l_rec_acct_attrs.array_num_value(13) := p_source_87;
143201 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
143202 l_rec_acct_attrs.array_char_value(14) := p_source_88;
143203 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
143204 l_rec_acct_attrs.array_num_value(15) := p_source_89;
143205 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
143206 l_rec_acct_attrs.array_char_value(16) := p_source_100;
143207 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
143208 l_rec_acct_attrs.array_num_value(17) := p_source_91;
143209 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
143210 l_rec_acct_attrs.array_char_value(18) := p_source_88;
143211 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
143212 l_rec_acct_attrs.array_date_value(19) := p_source_92;
143213 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
143214 l_rec_acct_attrs.array_num_value(20) := p_source_93;
143215 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
143216 l_rec_acct_attrs.array_char_value(21) := p_source_94;
143217 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
143218 l_rec_acct_attrs.array_num_value(22) := p_source_95;
143219 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
143220 l_rec_acct_attrs.array_num_value(23) := p_source_96;
143221 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
143222 l_rec_acct_attrs.array_num_value(24) := p_source_96;
143223
143224 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
143225 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
143226
143227 ---------------------------------------------------------------------------------------------------------------
143228 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
143229 ---------------------------------------------------------------------------------------------------------------
143230 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
143231
143232 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
143233 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
143234
143235 IF xla_accounting_cache_pkg.GetValueChar
143236 (p_source_code => 'LEDGER_CATEGORY_CODE'
143237 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
143238 AND l_bflow_method_code = 'PRIOR_ENTRY'
143239 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
143240 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
143241 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
143242 )
143243 THEN
143244 xla_ae_lines_pkg.BflowUpgEntry
143245 (p_business_method_code => l_bflow_method_code
143246 ,p_business_class_code => l_bflow_class_code
143247 ,p_balance_type => l_balance_type_code);
143248 ELSE
143249 NULL;
143250 -- No business flow processing for business flow method of NONE.
143251 END IF;
143252
143253 --
143254 -- call analytical criteria
143255 --
143256
143257
143258 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
143259 xla_ae_lines_pkg.SetAnalyticalCriteria(
143260 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
143261 , p_analytical_criterion_owner => 'S'
143262 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
143263 , p_amb_context_code => 'DEFAULT'
143264 , p_balancing_flag => 'Y'
143265
143266 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
143267 , p_analytical_detail_num_1 => NULL
143268 , p_analytical_detail_date_1 => NULL
143269
143270 , p_ae_header_id => l_ae_header_id
143271 )
143272 ;
143273 --
143274
143275 --
143276 -- call description
143277 --
143278
143279 xla_ae_lines_pkg.SetLineDescription(
143280 p_ae_header_id => l_ae_header_id
143281 ,p_description => Description_1 (
143282 p_application_id => p_application_id
143283 , p_ae_header_id => l_ae_header_id
143284 , p_source_1 => p_source_1
143285 , p_source_2 => p_source_2
143286 , p_source_3 => p_source_3
143287 , p_source_4 => p_source_4
143288 , p_source_5 => p_source_5
143289 )
143290 );
143291
143292
143293 --
143294 -- call ADRs
143295 -- Bug 4922099
143296 --
143297 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
143298 (NVL(l_actual_upg_option, 'N') = 'O') OR
143299 (NVL(l_enc_upg_option, 'N') = 'O')
143300 )
143301 THEN
143302 NULL;
143303 --
143304 --
143305
143306 l_ccid := AcctDerRule_28(
143307 p_application_id => p_application_id
143308 , p_ae_header_id => l_ae_header_id
143309 , p_source_15 => p_source_15
143310 , p_source_41 => p_source_41
143311 , p_source_42 => p_source_42
143312 , p_source_43 => p_source_43
143313 , p_source_44 => p_source_44
143314 , p_source_45 => p_source_45
143315 , x_transaction_coa_id => l_adr_transaction_coa_id
143316 , x_accounting_coa_id => l_adr_accounting_coa_id
143317 , x_value_type_code => l_adr_value_type_code
143318 , p_side => 'NA'
143319 );
143320
143321 xla_ae_lines_pkg.set_ccid(
143322 p_code_combination_id => l_ccid
143323 , p_value_type_code => l_adr_value_type_code
143324 , p_transaction_coa_id => l_adr_transaction_coa_id
143325 , p_accounting_coa_id => l_adr_accounting_coa_id
143326 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
143327 , p_adr_type_code => 'S'
143328 , p_component_type => l_component_type
143329 , p_component_code => l_component_code
143330 , p_component_type_code => l_component_type_code
143331 , p_component_appl_id => l_component_appl_id
143332 , p_amb_context_code => l_amb_context_code
143333 , p_side => 'NA'
143334 );
143335
143336
143337 --
143338 --
143339 END IF;
143340 --
143341 -- Bug 4922099
143342 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
143343 (NVL(l_enc_upg_option, 'N') = 'O')
143344 ) AND
143345 (l_bflow_method_code = 'PRIOR_ENTRY')
143346 )
143347 THEN
143348 IF
143349 --
143350 1 = 2
143351 --
143352 THEN
143353 xla_accounting_err_pkg.build_message
143354 (p_appli_s_name => 'XLA'
143355 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
143356 ,p_token_1 => 'LINE_NUMBER'
143357 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
143358 ,p_token_2 => 'LINE_TYPE_NAME'
143359 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
143360 l_component_type
143361 ,l_component_code
143362 ,l_component_type_code
143363 ,l_component_appl_id
143364 ,l_amb_context_code
143365 ,l_entity_code
143366 ,l_event_class_code
143367 )
143368 ,p_token_3 => 'OWNER'
143369 ,p_value_3 => xla_lookups_pkg.get_meaning(
143370 p_lookup_type => 'XLA_OWNER_TYPE'
143371 ,p_lookup_code => l_component_type_code
143372 )
143373 ,p_token_4 => 'PRODUCT_NAME'
143374 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
143375 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
143376 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
143377 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
143378 ,p_ae_header_id => NULL
143379 );
143380
143381 IF (C_LEVEL_ERROR>= g_log_level) THEN
143382 trace
143383 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
143384 ,p_level => C_LEVEL_ERROR
143385 ,p_module => l_log_module);
143386 END IF;
143387 END IF;
143388 END IF;
143389 --
143390 --
143391 ------------------------------------------------------------------------------------------------
143392 -- 4219869 Business Flow
143393 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
143394 -- Prior Entry. Currently, the following code is always generated.
143395 ------------------------------------------------------------------------------------------------
143396 XLA_AE_LINES_PKG.ValidateCurrentLine;
143397
143398 ------------------------------------------------------------------------------------
143399 -- 4219869 Business Flow
143400 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
143401 ------------------------------------------------------------------------------------
143402 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
143403
143404 ----------------------------------------------------------------------------------
143405 -- 4219869 Business Flow
143406 -- Update journal entry status -- Need to generate this within IF <condition>
143407 ----------------------------------------------------------------------------------
143408 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
143409 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
143410 ,p_balance_type_code => l_balance_type_code
143411 );
143412
143413 -------------------------------------------------------------------------------------------
143414 -- 4262811 - Generate the Accrual Reversal lines
143415 -------------------------------------------------------------------------------------------
143416 BEGIN
143417 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
143418 (g_array_event(p_event_id).array_value_num('header_index'));
143419 IF l_acc_rev_flag IS NULL THEN
143420 l_acc_rev_flag := 'N';
143421 END IF;
143422 EXCEPTION
143423 WHEN OTHERS THEN
143424 l_acc_rev_flag := 'N';
143425 END;
143426 --
143427 IF (l_acc_rev_flag = 'Y') THEN
143428
143429 -- 4645092 ------------------------------------------------------------------------------
143430 -- To allow MPA report to determine if it should generate report process
143431 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
143432 ------------------------------------------------------------------------------------------
143433
143434 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
143435 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
143436 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
143437 -- call ADRs
143438 -- Bug 4922099
143439 --
143440 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
143441 (NVL(l_actual_upg_option, 'N') = 'O') OR
143442 (NVL(l_enc_upg_option, 'N') = 'O')
143443 )
143444 THEN
143445 NULL;
143446 --
143447 --
143448
143449 l_ccid := AcctDerRule_28(
143450 p_application_id => p_application_id
143451 , p_ae_header_id => l_ae_header_id
143452 , p_source_15 => p_source_15
143453 , p_source_41 => p_source_41
143454 , p_source_42 => p_source_42
143455 , p_source_43 => p_source_43
143456 , p_source_44 => p_source_44
143457 , p_source_45 => p_source_45
143458 , x_transaction_coa_id => l_adr_transaction_coa_id
143459 , x_accounting_coa_id => l_adr_accounting_coa_id
143460 , x_value_type_code => l_adr_value_type_code
143461 , p_side => 'NA'
143462 );
143463
143464 xla_ae_lines_pkg.set_ccid(
143465 p_code_combination_id => l_ccid
143466 , p_value_type_code => l_adr_value_type_code
143467 , p_transaction_coa_id => l_adr_transaction_coa_id
143468 , p_accounting_coa_id => l_adr_accounting_coa_id
143469 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
143470 , p_adr_type_code => 'S'
143471 , p_component_type => l_component_type
143472 , p_component_code => l_component_code
143473 , p_component_type_code => l_component_type_code
143474 , p_component_appl_id => l_component_appl_id
143475 , p_amb_context_code => l_amb_context_code
143476 , p_side => 'NA'
143477 );
143478
143479
143480 --
143481 --
143482 END IF;
143483
143484 --
143485 -- Update the line information that should be overwritten
143486 --
143487 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
143488 p_header_num => 1);
143489 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
143490
143491 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
143492
143493 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
143494 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
143495 END IF;
143496
143497 --
143498 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
143499 --
143500 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
143501 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
143502 ELSE
143503 ---------------------------------------------------------------------------------------------------
143504 -- 4262811a Switch Sign
143505 ---------------------------------------------------------------------------------------------------
143506 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
143507 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
143508 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
143509 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
143510 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
143511 -- 5132302
143512 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
143513 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
143514
143515 END IF;
143516
143517 -- 4955764
143518 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
143519 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
143520
143521
143522 XLA_AE_LINES_PKG.ValidateCurrentLine;
143523 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
143524
143525 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
143526 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
143527 ,p_balance_type_code => l_balance_type_code);
143528
143529 END IF;
143530
143531 -----------------------------------------------------------------------------------------
143532 -- 4262811 Multiperiod Accounting
143533 -----------------------------------------------------------------------------------------
143534 -- No MPA option is assigned.
143535
143536
143537 END IF;
143538 END IF;
143539 --
143540
143541 --
143542 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
143543 trace
143544 (p_msg => 'END of AcctLineType_270'
143545 ,p_level => C_LEVEL_PROCEDURE
143546 ,p_module => l_log_module);
143547 END IF;
143548 --
143549 EXCEPTION
143550 WHEN xla_exceptions_pkg.application_exception THEN
143551 RAISE;
143552 WHEN OTHERS THEN
143553 xla_exceptions_pkg.raise_message
143554 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_270');
143555 END AcctLineType_270;
143556 --
143557
143558 ---------------------------------------
143559 --
143560 -- PRIVATE FUNCTION
143561 -- AcctLineType_271
143562 --
143563 ---------------------------------------
143564 PROCEDURE AcctLineType_271 (
143565 p_application_id IN NUMBER
143566 ,p_event_id IN NUMBER
143567 ,p_calculate_acctd_flag IN VARCHAR2
143568 ,p_calculate_g_l_flag IN VARCHAR2
143569 ,p_actual_flag IN OUT VARCHAR2
143570 ,p_balance_type_code OUT VARCHAR2
143571 ,p_gain_or_loss_ref OUT VARCHAR2
143572
143573 --TRANSACTION_ID
143574 , p_source_1 IN NUMBER
143575 --Item Concatenated Segments
143576 , p_source_2 IN VARCHAR2
143577 --Transaction Quantity
143578 , p_source_3 IN NUMBER
143579 --Transaction Unit of Measure Code
143580 , p_source_4 IN VARCHAR2
143581 --Inventory Transaction Type Description
143582 , p_source_5 IN VARCHAR2
143583 --Cost Element Name
143584 , p_source_15 IN NUMBER
143585 --Product Line Accounting Category Material Account
143586 , p_source_41 IN NUMBER
143587 --Product Line Accounting Category Material Overhead Account
143588 , p_source_42 IN NUMBER
143589 --Product Line Accounting Category Resource Account
143590 , p_source_43 IN NUMBER
143591 --Product Line Accounting Category Outside Processing Account
143592 , p_source_44 IN NUMBER
143593 --Product Line Accounting Category Overhead Account
143594 , p_source_45 IN NUMBER
143595 --DISTRIBUTION_IDENTIFIER
143596 , p_source_84 IN NUMBER
143597 --Distribution Type
143598 , p_source_85 IN VARCHAR2
143599 , p_source_85_meaning IN VARCHAR2
143600 --Entered Currency Code
143601 , p_source_88 IN VARCHAR2
143602 --Entered Amount
143603 , p_source_91 IN NUMBER
143604 --Currency Conversion Date
143605 , p_source_92 IN DATE
143606 --Currency Conversion Rate
143607 , p_source_93 IN NUMBER
143608 --Currency Conversion Type
143609 , p_source_94 IN VARCHAR2
143610 --Accounted Amount
143611 , p_source_95 IN NUMBER
143612 --Accounting Line Type
143613 , p_source_97 IN NUMBER
143614 --Organization Code
143615 , p_source_108 IN VARCHAR2
143616 )
143617 IS
143618
143619 l_component_type VARCHAR2(80);
143620 l_component_code VARCHAR2(30);
143621 l_component_type_code VARCHAR2(1);
143622 l_component_appl_id INTEGER;
143623 l_amb_context_code VARCHAR2(30);
143624 l_entity_code VARCHAR2(30);
143625 l_event_class_code VARCHAR2(30);
143626 l_ae_header_id NUMBER;
143627 l_event_type_code VARCHAR2(30);
143628 l_line_definition_code VARCHAR2(30);
143629 l_line_definition_owner_code VARCHAR2(1);
143630 --
143631 -- adr variables
143632 l_segment VARCHAR2(30);
143633 l_ccid NUMBER;
143634 l_adr_transaction_coa_id NUMBER;
143635 l_adr_accounting_coa_id NUMBER;
143636 l_adr_flexfield_segment_code VARCHAR2(30);
143637 l_adr_flex_value_set_id NUMBER;
143638 l_adr_value_type_code VARCHAR2(30);
143639 l_adr_value_combination_id NUMBER;
143640 l_adr_value_segment_code VARCHAR2(30);
143641
143642 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
143643 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
143644 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
143645 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
143646
143647 -- 4262811 Variables ------------------------------------------------------------------------------------------
143648 l_entered_amt_idx NUMBER;
143649 l_accted_amt_idx NUMBER;
143650 l_acc_rev_flag VARCHAR2(1);
143651 l_accrual_line_num NUMBER;
143652 l_tmp_amt NUMBER;
143653 l_acc_rev_natural_side_code VARCHAR2(1);
143654
143655 l_num_entries NUMBER;
143656 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
143657 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
143658 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
143659 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
143660 l_recog_line_1 NUMBER;
143661 l_recog_line_2 NUMBER;
143662
143663 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
143664 l_bflow_applied_to_amt NUMBER; -- 5132302
143665 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
143666
143667 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
143668
143669 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
143670 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
143671
143672 ---------------------------------------------------------------------------------------------------------------
143673
143674
143675 --
143676 -- bulk performance
143677 --
143678 l_balance_type_code VARCHAR2(1);
143679 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
143680 l_log_module VARCHAR2(240);
143681
143682 --
143683 -- Upgrade strategy
143684 --
143685 l_actual_upg_option VARCHAR2(1);
143686 l_enc_upg_option VARCHAR2(1);
143687
143688 --
143689 BEGIN
143690 --
143691 IF g_log_enabled THEN
143692 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_271';
143693 END IF;
143694 --
143695 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
143696
143697 trace
143698 (p_msg => 'BEGIN of AcctLineType_271'
143699 ,p_level => C_LEVEL_PROCEDURE
143700 ,p_module => l_log_module);
143701
143702 END IF;
143703 --
143704 l_component_type := 'AMB_JLT';
143705 l_component_code := 'INVENTORY_VALUATION';
143706 l_component_type_code := 'S';
143707 l_component_appl_id := 707;
143708 l_amb_context_code := 'DEFAULT';
143709 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
143710 l_event_class_code := 'SALES_ORDER';
143711 l_event_type_code := 'LOG_RMA_RCPT';
143712 l_line_definition_owner_code := 'S';
143713 l_line_definition_code := 'PI_LOG_RMA_RCPT';
143714 --
143715 l_balance_type_code := 'A';
143716 l_segment := NULL;
143717 l_ccid := NULL;
143718 l_adr_transaction_coa_id := NULL;
143719 l_adr_accounting_coa_id := NULL;
143720 l_adr_flexfield_segment_code := NULL;
143721 l_adr_flex_value_set_id := NULL;
143722 l_adr_value_type_code := NULL;
143723 l_adr_value_combination_id := NULL;
143724 l_adr_value_segment_code := NULL;
143725
143726 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
143727 l_bflow_class_code := ''; -- 4219869 Business Flow
143728 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
143729 l_budgetary_control_flag := 'N';
143730
143731 l_bflow_applied_to_amt_idx := NULL; -- 5132302
143732 l_bflow_applied_to_amt := NULL; -- 5132302
143733 l_entered_amt_idx := NULL; -- 4262811
143734 l_accted_amt_idx := NULL; -- 4262811
143735 l_acc_rev_flag := NULL; -- 4262811
143736 l_accrual_line_num := NULL; -- 4262811
143737 l_tmp_amt := NULL; -- 4262811
143738 --
143739
143740 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
143741 l_balance_type_code <> 'B' THEN
143742 IF NVL(p_source_97,9E125) = 1
143743 THEN
143744
143745 --
143746 XLA_AE_LINES_PKG.SetNewLine;
143747
143748 p_balance_type_code := l_balance_type_code;
143749 -- set the flag so later we will know whether the gain loss line needs to be created
143750
143751 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
143752 p_actual_flag :='A';
143753 END IF;
143754
143755 --
143756 -- bulk performance
143757 --
143758 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
143759 p_header_num => 0); -- 4262811
143760 --
143761 -- set accounting line options
143762 --
143763 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
143764 p_natural_side_code => 'D'
143765 , p_gain_or_loss_flag => 'N'
143766 , p_gl_transfer_mode_code => 'S'
143767 , p_acct_entry_type_code => 'A'
143768 , p_switch_side_flag => 'Y'
143769 , p_merge_duplicate_code => 'N'
143770 );
143771 --
143772 l_acc_rev_natural_side_code := 'C'; -- 4262811
143773 --
143774 --
143775 -- set accounting line type info
143776 --
143777 xla_ae_lines_pkg.SetAcctLineType
143778 (p_component_type => l_component_type
143779 ,p_event_type_code => l_event_type_code
143780 ,p_line_definition_owner_code => l_line_definition_owner_code
143781 ,p_line_definition_code => l_line_definition_code
143782 ,p_accounting_line_code => l_component_code
143783 ,p_accounting_line_type_code => l_component_type_code
143784 ,p_accounting_line_appl_id => l_component_appl_id
143785 ,p_amb_context_code => l_amb_context_code
143786 ,p_entity_code => l_entity_code
143787 ,p_event_class_code => l_event_class_code);
143788 --
143789 -- set accounting class
143790 --
143791 xla_ae_lines_pkg.SetAcctClass(
143792 p_accounting_class_code => 'INVENTORY_VALUATION'
143793 , p_ae_header_id => l_ae_header_id
143794 );
143795
143796 --
143797 -- set rounding class
143798 --
143799 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
143800 'INVENTORY_VALUATION';
143801
143802 --
143803 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
143804 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
143805 --
143806 -- bulk performance
143807 --
143808 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
143809
143810 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
143811 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
143812
143813 -- 4955764
143814 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
143815 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
143816
143817 -- 4458381 Public Sector Enh
143818
143819 --
143820 -- set accounting attributes for the line type
143821 --
143822 l_entered_amt_idx := 3;
143823 l_accted_amt_idx := 8;
143824 l_bflow_applied_to_amt_idx := NULL; -- 5132302
143825 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
143826 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
143827 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
143828 l_rec_acct_attrs.array_char_value(2) := p_source_85;
143829 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
143830 l_rec_acct_attrs.array_num_value(3) := p_source_91;
143831 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
143832 l_rec_acct_attrs.array_char_value(4) := p_source_88;
143833 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
143834 l_rec_acct_attrs.array_date_value(5) := p_source_92;
143835 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
143836 l_rec_acct_attrs.array_num_value(6) := p_source_93;
143837 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
143838 l_rec_acct_attrs.array_char_value(7) := p_source_94;
143839 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
143840 l_rec_acct_attrs.array_num_value(8) := p_source_95;
143841
143842 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
143843 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
143844
143845 ---------------------------------------------------------------------------------------------------------------
143846 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
143847 ---------------------------------------------------------------------------------------------------------------
143848 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
143849
143850 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
143851 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
143852
143853 IF xla_accounting_cache_pkg.GetValueChar
143854 (p_source_code => 'LEDGER_CATEGORY_CODE'
143855 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
143856 AND l_bflow_method_code = 'PRIOR_ENTRY'
143857 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
143858 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
143859 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
143860 )
143861 THEN
143862 xla_ae_lines_pkg.BflowUpgEntry
143863 (p_business_method_code => l_bflow_method_code
143864 ,p_business_class_code => l_bflow_class_code
143865 ,p_balance_type => l_balance_type_code);
143866 ELSE
143867 NULL;
143868 -- No business flow processing for business flow method of NONE.
143869 END IF;
143870
143871 --
143872 -- call analytical criteria
143873 --
143874
143875
143876 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
143877 xla_ae_lines_pkg.SetAnalyticalCriteria(
143878 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
143879 , p_analytical_criterion_owner => 'S'
143880 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
143881 , p_amb_context_code => 'DEFAULT'
143882 , p_balancing_flag => 'Y'
143883
143884 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
143885 , p_analytical_detail_num_1 => NULL
143886 , p_analytical_detail_date_1 => NULL
143887
143888 , p_ae_header_id => l_ae_header_id
143889 )
143890 ;
143891 --
143892
143893 --
143894 -- call description
143895 --
143896
143897 xla_ae_lines_pkg.SetLineDescription(
143898 p_ae_header_id => l_ae_header_id
143899 ,p_description => Description_1 (
143900 p_application_id => p_application_id
143901 , p_ae_header_id => l_ae_header_id
143902 , p_source_1 => p_source_1
143903 , p_source_2 => p_source_2
143904 , p_source_3 => p_source_3
143905 , p_source_4 => p_source_4
143906 , p_source_5 => p_source_5
143907 )
143908 );
143909
143910
143911 --
143912 -- call ADRs
143913 -- Bug 4922099
143914 --
143915 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
143916 (NVL(l_actual_upg_option, 'N') = 'O') OR
143917 (NVL(l_enc_upg_option, 'N') = 'O')
143918 )
143919 THEN
143920 NULL;
143921 --
143922 --
143923
143924 l_ccid := AcctDerRule_28(
143925 p_application_id => p_application_id
143926 , p_ae_header_id => l_ae_header_id
143927 , p_source_15 => p_source_15
143928 , p_source_41 => p_source_41
143929 , p_source_42 => p_source_42
143930 , p_source_43 => p_source_43
143931 , p_source_44 => p_source_44
143932 , p_source_45 => p_source_45
143933 , x_transaction_coa_id => l_adr_transaction_coa_id
143934 , x_accounting_coa_id => l_adr_accounting_coa_id
143935 , x_value_type_code => l_adr_value_type_code
143936 , p_side => 'NA'
143937 );
143938
143939 xla_ae_lines_pkg.set_ccid(
143940 p_code_combination_id => l_ccid
143941 , p_value_type_code => l_adr_value_type_code
143942 , p_transaction_coa_id => l_adr_transaction_coa_id
143943 , p_accounting_coa_id => l_adr_accounting_coa_id
143944 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
143945 , p_adr_type_code => 'S'
143946 , p_component_type => l_component_type
143947 , p_component_code => l_component_code
143948 , p_component_type_code => l_component_type_code
143949 , p_component_appl_id => l_component_appl_id
143950 , p_amb_context_code => l_amb_context_code
143951 , p_side => 'NA'
143952 );
143953
143954
143955 --
143956 --
143957 END IF;
143958 --
143959 -- Bug 4922099
143960 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
143961 (NVL(l_enc_upg_option, 'N') = 'O')
143962 ) AND
143963 (l_bflow_method_code = 'PRIOR_ENTRY')
143964 )
143965 THEN
143966 IF
143967 --
143968 1 = 2
143969 --
143970 THEN
143971 xla_accounting_err_pkg.build_message
143972 (p_appli_s_name => 'XLA'
143973 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
143974 ,p_token_1 => 'LINE_NUMBER'
143975 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
143976 ,p_token_2 => 'LINE_TYPE_NAME'
143977 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
143978 l_component_type
143979 ,l_component_code
143980 ,l_component_type_code
143981 ,l_component_appl_id
143982 ,l_amb_context_code
143983 ,l_entity_code
143984 ,l_event_class_code
143985 )
143986 ,p_token_3 => 'OWNER'
143987 ,p_value_3 => xla_lookups_pkg.get_meaning(
143988 p_lookup_type => 'XLA_OWNER_TYPE'
143989 ,p_lookup_code => l_component_type_code
143990 )
143991 ,p_token_4 => 'PRODUCT_NAME'
143992 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
143993 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
143994 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
143995 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
143996 ,p_ae_header_id => NULL
143997 );
143998
143999 IF (C_LEVEL_ERROR>= g_log_level) THEN
144000 trace
144001 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
144002 ,p_level => C_LEVEL_ERROR
144003 ,p_module => l_log_module);
144004 END IF;
144005 END IF;
144006 END IF;
144007 --
144008 --
144009 ------------------------------------------------------------------------------------------------
144010 -- 4219869 Business Flow
144011 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
144012 -- Prior Entry. Currently, the following code is always generated.
144013 ------------------------------------------------------------------------------------------------
144014 XLA_AE_LINES_PKG.ValidateCurrentLine;
144015
144016 ------------------------------------------------------------------------------------
144017 -- 4219869 Business Flow
144018 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
144019 ------------------------------------------------------------------------------------
144020 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
144021
144022 ----------------------------------------------------------------------------------
144023 -- 4219869 Business Flow
144024 -- Update journal entry status -- Need to generate this within IF <condition>
144025 ----------------------------------------------------------------------------------
144026 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
144027 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
144028 ,p_balance_type_code => l_balance_type_code
144029 );
144030
144031 -------------------------------------------------------------------------------------------
144032 -- 4262811 - Generate the Accrual Reversal lines
144033 -------------------------------------------------------------------------------------------
144034 BEGIN
144035 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
144036 (g_array_event(p_event_id).array_value_num('header_index'));
144037 IF l_acc_rev_flag IS NULL THEN
144038 l_acc_rev_flag := 'N';
144039 END IF;
144040 EXCEPTION
144041 WHEN OTHERS THEN
144042 l_acc_rev_flag := 'N';
144043 END;
144044 --
144045 IF (l_acc_rev_flag = 'Y') THEN
144046
144047 -- 4645092 ------------------------------------------------------------------------------
144048 -- To allow MPA report to determine if it should generate report process
144049 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
144050 ------------------------------------------------------------------------------------------
144051
144052 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
144053 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
144054 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
144055 -- call ADRs
144056 -- Bug 4922099
144057 --
144058 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
144059 (NVL(l_actual_upg_option, 'N') = 'O') OR
144060 (NVL(l_enc_upg_option, 'N') = 'O')
144061 )
144062 THEN
144063 NULL;
144064 --
144065 --
144066
144067 l_ccid := AcctDerRule_28(
144068 p_application_id => p_application_id
144069 , p_ae_header_id => l_ae_header_id
144070 , p_source_15 => p_source_15
144071 , p_source_41 => p_source_41
144072 , p_source_42 => p_source_42
144073 , p_source_43 => p_source_43
144074 , p_source_44 => p_source_44
144075 , p_source_45 => p_source_45
144076 , x_transaction_coa_id => l_adr_transaction_coa_id
144077 , x_accounting_coa_id => l_adr_accounting_coa_id
144078 , x_value_type_code => l_adr_value_type_code
144079 , p_side => 'NA'
144080 );
144081
144082 xla_ae_lines_pkg.set_ccid(
144083 p_code_combination_id => l_ccid
144084 , p_value_type_code => l_adr_value_type_code
144085 , p_transaction_coa_id => l_adr_transaction_coa_id
144086 , p_accounting_coa_id => l_adr_accounting_coa_id
144087 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
144088 , p_adr_type_code => 'S'
144089 , p_component_type => l_component_type
144090 , p_component_code => l_component_code
144091 , p_component_type_code => l_component_type_code
144092 , p_component_appl_id => l_component_appl_id
144093 , p_amb_context_code => l_amb_context_code
144094 , p_side => 'NA'
144095 );
144096
144097
144098 --
144099 --
144100 END IF;
144101
144102 --
144103 -- Update the line information that should be overwritten
144104 --
144105 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
144106 p_header_num => 1);
144107 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
144108
144109 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
144110
144111 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
144112 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
144113 END IF;
144114
144115 --
144116 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
144117 --
144118 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
144119 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
144120 ELSE
144121 ---------------------------------------------------------------------------------------------------
144122 -- 4262811a Switch Sign
144123 ---------------------------------------------------------------------------------------------------
144124 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
144125 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
144126 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144127 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
144128 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144129 -- 5132302
144130 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
144131 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144132
144133 END IF;
144134
144135 -- 4955764
144136 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
144137 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
144138
144139
144140 XLA_AE_LINES_PKG.ValidateCurrentLine;
144141 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
144142
144143 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
144144 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
144145 ,p_balance_type_code => l_balance_type_code);
144146
144147 END IF;
144148
144149 -----------------------------------------------------------------------------------------
144150 -- 4262811 Multiperiod Accounting
144151 -----------------------------------------------------------------------------------------
144152 -- No MPA option is assigned.
144153
144154
144155 END IF;
144156 END IF;
144157 --
144158
144159 --
144160 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
144161 trace
144162 (p_msg => 'END of AcctLineType_271'
144163 ,p_level => C_LEVEL_PROCEDURE
144164 ,p_module => l_log_module);
144165 END IF;
144166 --
144167 EXCEPTION
144168 WHEN xla_exceptions_pkg.application_exception THEN
144169 RAISE;
144170 WHEN OTHERS THEN
144171 xla_exceptions_pkg.raise_message
144172 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_271');
144173 END AcctLineType_271;
144174 --
144175
144176 ---------------------------------------
144177 --
144178 -- PRIVATE FUNCTION
144179 -- AcctLineType_272
144180 --
144181 ---------------------------------------
144182 PROCEDURE AcctLineType_272 (
144183 p_application_id IN NUMBER
144184 ,p_event_id IN NUMBER
144185 ,p_calculate_acctd_flag IN VARCHAR2
144186 ,p_calculate_g_l_flag IN VARCHAR2
144187 ,p_actual_flag IN OUT VARCHAR2
144188 ,p_balance_type_code OUT VARCHAR2
144189 ,p_gain_or_loss_ref OUT VARCHAR2
144190
144191 --TRANSACTION_ID
144192 , p_source_1 IN NUMBER
144193 --Item Concatenated Segments
144194 , p_source_2 IN VARCHAR2
144195 --Transaction Quantity
144196 , p_source_3 IN NUMBER
144197 --Transaction Unit of Measure Code
144198 , p_source_4 IN VARCHAR2
144199 --Inventory Transaction Type Description
144200 , p_source_5 IN VARCHAR2
144201 --Cost Element Name
144202 , p_source_15 IN NUMBER
144203 --Product Line Accounting Category Material Account
144204 , p_source_41 IN NUMBER
144205 --Product Line Accounting Category Material Overhead Account
144206 , p_source_42 IN NUMBER
144207 --Product Line Accounting Category Resource Account
144208 , p_source_43 IN NUMBER
144209 --Product Line Accounting Category Outside Processing Account
144210 , p_source_44 IN NUMBER
144211 --Product Line Accounting Category Overhead Account
144212 , p_source_45 IN NUMBER
144213 --DISTRIBUTION_IDENTIFIER
144214 , p_source_84 IN NUMBER
144215 --Distribution Type
144216 , p_source_85 IN VARCHAR2
144217 , p_source_85_meaning IN VARCHAR2
144218 --Entered Currency Code
144219 , p_source_88 IN VARCHAR2
144220 --Entered Amount
144221 , p_source_91 IN NUMBER
144222 --Currency Conversion Date
144223 , p_source_92 IN DATE
144224 --Currency Conversion Rate
144225 , p_source_93 IN NUMBER
144226 --Currency Conversion Type
144227 , p_source_94 IN VARCHAR2
144228 --Accounted Amount
144229 , p_source_95 IN NUMBER
144230 --Accounting Line Type
144231 , p_source_97 IN NUMBER
144232 --Organization Code
144233 , p_source_108 IN VARCHAR2
144234 )
144235 IS
144236
144237 l_component_type VARCHAR2(80);
144238 l_component_code VARCHAR2(30);
144239 l_component_type_code VARCHAR2(1);
144240 l_component_appl_id INTEGER;
144241 l_amb_context_code VARCHAR2(30);
144242 l_entity_code VARCHAR2(30);
144243 l_event_class_code VARCHAR2(30);
144244 l_ae_header_id NUMBER;
144245 l_event_type_code VARCHAR2(30);
144246 l_line_definition_code VARCHAR2(30);
144247 l_line_definition_owner_code VARCHAR2(1);
144248 --
144249 -- adr variables
144250 l_segment VARCHAR2(30);
144251 l_ccid NUMBER;
144252 l_adr_transaction_coa_id NUMBER;
144253 l_adr_accounting_coa_id NUMBER;
144254 l_adr_flexfield_segment_code VARCHAR2(30);
144255 l_adr_flex_value_set_id NUMBER;
144256 l_adr_value_type_code VARCHAR2(30);
144257 l_adr_value_combination_id NUMBER;
144258 l_adr_value_segment_code VARCHAR2(30);
144259
144260 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
144261 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
144262 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
144263 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
144264
144265 -- 4262811 Variables ------------------------------------------------------------------------------------------
144266 l_entered_amt_idx NUMBER;
144267 l_accted_amt_idx NUMBER;
144268 l_acc_rev_flag VARCHAR2(1);
144269 l_accrual_line_num NUMBER;
144270 l_tmp_amt NUMBER;
144271 l_acc_rev_natural_side_code VARCHAR2(1);
144272
144273 l_num_entries NUMBER;
144274 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
144275 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
144276 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
144277 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
144278 l_recog_line_1 NUMBER;
144279 l_recog_line_2 NUMBER;
144280
144281 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
144282 l_bflow_applied_to_amt NUMBER; -- 5132302
144283 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
144284
144285 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
144286
144287 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
144288 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
144289
144290 ---------------------------------------------------------------------------------------------------------------
144291
144292
144293 --
144294 -- bulk performance
144295 --
144296 l_balance_type_code VARCHAR2(1);
144297 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
144298 l_log_module VARCHAR2(240);
144299
144300 --
144301 -- Upgrade strategy
144302 --
144303 l_actual_upg_option VARCHAR2(1);
144304 l_enc_upg_option VARCHAR2(1);
144305
144306 --
144307 BEGIN
144308 --
144309 IF g_log_enabled THEN
144310 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_272';
144311 END IF;
144312 --
144313 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
144314
144315 trace
144316 (p_msg => 'BEGIN of AcctLineType_272'
144317 ,p_level => C_LEVEL_PROCEDURE
144318 ,p_module => l_log_module);
144319
144320 END IF;
144321 --
144322 l_component_type := 'AMB_JLT';
144323 l_component_code := 'INVENTORY_VALUATION';
144324 l_component_type_code := 'S';
144325 l_component_appl_id := 707;
144326 l_amb_context_code := 'DEFAULT';
144327 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
144328 l_event_class_code := 'USER_DEFINE';
144329 l_event_type_code := 'UIPV_TXFR';
144330 l_line_definition_owner_code := 'S';
144331 l_line_definition_code := 'PI_IPV_TXFR';
144332 --
144333 l_balance_type_code := 'A';
144334 l_segment := NULL;
144335 l_ccid := NULL;
144336 l_adr_transaction_coa_id := NULL;
144337 l_adr_accounting_coa_id := NULL;
144338 l_adr_flexfield_segment_code := NULL;
144339 l_adr_flex_value_set_id := NULL;
144340 l_adr_value_type_code := NULL;
144341 l_adr_value_combination_id := NULL;
144342 l_adr_value_segment_code := NULL;
144343
144344 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
144345 l_bflow_class_code := ''; -- 4219869 Business Flow
144346 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
144347 l_budgetary_control_flag := 'N';
144348
144349 l_bflow_applied_to_amt_idx := NULL; -- 5132302
144350 l_bflow_applied_to_amt := NULL; -- 5132302
144351 l_entered_amt_idx := NULL; -- 4262811
144352 l_accted_amt_idx := NULL; -- 4262811
144353 l_acc_rev_flag := NULL; -- 4262811
144354 l_accrual_line_num := NULL; -- 4262811
144355 l_tmp_amt := NULL; -- 4262811
144356 --
144357
144358 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
144359 l_balance_type_code <> 'B' THEN
144360 IF NVL(p_source_97,9E125) = 1
144361 THEN
144362
144363 --
144364 XLA_AE_LINES_PKG.SetNewLine;
144365
144366 p_balance_type_code := l_balance_type_code;
144367 -- set the flag so later we will know whether the gain loss line needs to be created
144368
144369 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
144370 p_actual_flag :='A';
144371 END IF;
144372
144373 --
144374 -- bulk performance
144375 --
144376 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
144377 p_header_num => 0); -- 4262811
144378 --
144379 -- set accounting line options
144380 --
144381 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
144382 p_natural_side_code => 'D'
144383 , p_gain_or_loss_flag => 'N'
144384 , p_gl_transfer_mode_code => 'S'
144385 , p_acct_entry_type_code => 'A'
144386 , p_switch_side_flag => 'Y'
144387 , p_merge_duplicate_code => 'N'
144388 );
144389 --
144390 l_acc_rev_natural_side_code := 'C'; -- 4262811
144391 --
144392 --
144393 -- set accounting line type info
144394 --
144395 xla_ae_lines_pkg.SetAcctLineType
144396 (p_component_type => l_component_type
144397 ,p_event_type_code => l_event_type_code
144398 ,p_line_definition_owner_code => l_line_definition_owner_code
144399 ,p_line_definition_code => l_line_definition_code
144400 ,p_accounting_line_code => l_component_code
144401 ,p_accounting_line_type_code => l_component_type_code
144402 ,p_accounting_line_appl_id => l_component_appl_id
144403 ,p_amb_context_code => l_amb_context_code
144404 ,p_entity_code => l_entity_code
144405 ,p_event_class_code => l_event_class_code);
144406 --
144407 -- set accounting class
144408 --
144409 xla_ae_lines_pkg.SetAcctClass(
144410 p_accounting_class_code => 'INVENTORY_VALUATION'
144411 , p_ae_header_id => l_ae_header_id
144412 );
144413
144414 --
144415 -- set rounding class
144416 --
144417 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
144418 'INVENTORY_VALUATION';
144419
144420 --
144421 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
144422 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
144423 --
144424 -- bulk performance
144425 --
144426 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
144427
144428 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
144429 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
144430
144431 -- 4955764
144432 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
144433 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
144434
144435 -- 4458381 Public Sector Enh
144436
144437 --
144438 -- set accounting attributes for the line type
144439 --
144440 l_entered_amt_idx := 3;
144441 l_accted_amt_idx := 8;
144442 l_bflow_applied_to_amt_idx := NULL; -- 5132302
144443 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
144444 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
144445 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
144446 l_rec_acct_attrs.array_char_value(2) := p_source_85;
144447 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
144448 l_rec_acct_attrs.array_num_value(3) := p_source_91;
144449 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
144450 l_rec_acct_attrs.array_char_value(4) := p_source_88;
144451 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
144452 l_rec_acct_attrs.array_date_value(5) := p_source_92;
144453 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
144454 l_rec_acct_attrs.array_num_value(6) := p_source_93;
144455 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
144456 l_rec_acct_attrs.array_char_value(7) := p_source_94;
144457 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
144458 l_rec_acct_attrs.array_num_value(8) := p_source_95;
144459
144460 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
144461 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
144462
144463 ---------------------------------------------------------------------------------------------------------------
144464 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
144465 ---------------------------------------------------------------------------------------------------------------
144466 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
144467
144468 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
144469 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
144470
144471 IF xla_accounting_cache_pkg.GetValueChar
144472 (p_source_code => 'LEDGER_CATEGORY_CODE'
144473 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
144474 AND l_bflow_method_code = 'PRIOR_ENTRY'
144475 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
144476 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
144477 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
144478 )
144479 THEN
144480 xla_ae_lines_pkg.BflowUpgEntry
144481 (p_business_method_code => l_bflow_method_code
144482 ,p_business_class_code => l_bflow_class_code
144483 ,p_balance_type => l_balance_type_code);
144484 ELSE
144485 NULL;
144486 -- No business flow processing for business flow method of NONE.
144487 END IF;
144488
144489 --
144490 -- call analytical criteria
144491 --
144492
144493
144494 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
144495 xla_ae_lines_pkg.SetAnalyticalCriteria(
144496 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
144497 , p_analytical_criterion_owner => 'S'
144498 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
144499 , p_amb_context_code => 'DEFAULT'
144500 , p_balancing_flag => 'Y'
144501
144502 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
144503 , p_analytical_detail_num_1 => NULL
144504 , p_analytical_detail_date_1 => NULL
144505
144506 , p_ae_header_id => l_ae_header_id
144507 )
144508 ;
144509 --
144510
144511 --
144512 -- call description
144513 --
144514
144515 xla_ae_lines_pkg.SetLineDescription(
144516 p_ae_header_id => l_ae_header_id
144517 ,p_description => Description_1 (
144518 p_application_id => p_application_id
144519 , p_ae_header_id => l_ae_header_id
144520 , p_source_1 => p_source_1
144521 , p_source_2 => p_source_2
144522 , p_source_3 => p_source_3
144523 , p_source_4 => p_source_4
144524 , p_source_5 => p_source_5
144525 )
144526 );
144527
144528
144529 --
144530 -- call ADRs
144531 -- Bug 4922099
144532 --
144533 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
144534 (NVL(l_actual_upg_option, 'N') = 'O') OR
144535 (NVL(l_enc_upg_option, 'N') = 'O')
144536 )
144537 THEN
144538 NULL;
144539 --
144540 --
144541
144542 l_ccid := AcctDerRule_28(
144543 p_application_id => p_application_id
144544 , p_ae_header_id => l_ae_header_id
144545 , p_source_15 => p_source_15
144546 , p_source_41 => p_source_41
144547 , p_source_42 => p_source_42
144548 , p_source_43 => p_source_43
144549 , p_source_44 => p_source_44
144550 , p_source_45 => p_source_45
144551 , x_transaction_coa_id => l_adr_transaction_coa_id
144552 , x_accounting_coa_id => l_adr_accounting_coa_id
144553 , x_value_type_code => l_adr_value_type_code
144554 , p_side => 'NA'
144555 );
144556
144557 xla_ae_lines_pkg.set_ccid(
144558 p_code_combination_id => l_ccid
144559 , p_value_type_code => l_adr_value_type_code
144560 , p_transaction_coa_id => l_adr_transaction_coa_id
144561 , p_accounting_coa_id => l_adr_accounting_coa_id
144562 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
144563 , p_adr_type_code => 'S'
144564 , p_component_type => l_component_type
144565 , p_component_code => l_component_code
144566 , p_component_type_code => l_component_type_code
144567 , p_component_appl_id => l_component_appl_id
144568 , p_amb_context_code => l_amb_context_code
144569 , p_side => 'NA'
144570 );
144571
144572
144573 --
144574 --
144575 END IF;
144576 --
144577 -- Bug 4922099
144578 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
144579 (NVL(l_enc_upg_option, 'N') = 'O')
144580 ) AND
144581 (l_bflow_method_code = 'PRIOR_ENTRY')
144582 )
144583 THEN
144584 IF
144585 --
144586 1 = 2
144587 --
144588 THEN
144589 xla_accounting_err_pkg.build_message
144590 (p_appli_s_name => 'XLA'
144591 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
144592 ,p_token_1 => 'LINE_NUMBER'
144593 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
144594 ,p_token_2 => 'LINE_TYPE_NAME'
144595 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
144596 l_component_type
144597 ,l_component_code
144598 ,l_component_type_code
144599 ,l_component_appl_id
144600 ,l_amb_context_code
144601 ,l_entity_code
144602 ,l_event_class_code
144603 )
144604 ,p_token_3 => 'OWNER'
144605 ,p_value_3 => xla_lookups_pkg.get_meaning(
144606 p_lookup_type => 'XLA_OWNER_TYPE'
144607 ,p_lookup_code => l_component_type_code
144608 )
144609 ,p_token_4 => 'PRODUCT_NAME'
144610 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
144611 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
144612 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
144613 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
144614 ,p_ae_header_id => NULL
144615 );
144616
144617 IF (C_LEVEL_ERROR>= g_log_level) THEN
144618 trace
144619 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
144620 ,p_level => C_LEVEL_ERROR
144621 ,p_module => l_log_module);
144622 END IF;
144623 END IF;
144624 END IF;
144625 --
144626 --
144627 ------------------------------------------------------------------------------------------------
144628 -- 4219869 Business Flow
144629 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
144630 -- Prior Entry. Currently, the following code is always generated.
144631 ------------------------------------------------------------------------------------------------
144632 XLA_AE_LINES_PKG.ValidateCurrentLine;
144633
144634 ------------------------------------------------------------------------------------
144635 -- 4219869 Business Flow
144636 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
144637 ------------------------------------------------------------------------------------
144638 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
144639
144640 ----------------------------------------------------------------------------------
144641 -- 4219869 Business Flow
144642 -- Update journal entry status -- Need to generate this within IF <condition>
144643 ----------------------------------------------------------------------------------
144644 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
144645 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
144646 ,p_balance_type_code => l_balance_type_code
144647 );
144648
144649 -------------------------------------------------------------------------------------------
144650 -- 4262811 - Generate the Accrual Reversal lines
144651 -------------------------------------------------------------------------------------------
144652 BEGIN
144653 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
144654 (g_array_event(p_event_id).array_value_num('header_index'));
144655 IF l_acc_rev_flag IS NULL THEN
144656 l_acc_rev_flag := 'N';
144657 END IF;
144658 EXCEPTION
144659 WHEN OTHERS THEN
144660 l_acc_rev_flag := 'N';
144661 END;
144662 --
144663 IF (l_acc_rev_flag = 'Y') THEN
144664
144665 -- 4645092 ------------------------------------------------------------------------------
144666 -- To allow MPA report to determine if it should generate report process
144667 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
144668 ------------------------------------------------------------------------------------------
144669
144670 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
144671 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
144672 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
144673 -- call ADRs
144674 -- Bug 4922099
144675 --
144676 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
144677 (NVL(l_actual_upg_option, 'N') = 'O') OR
144678 (NVL(l_enc_upg_option, 'N') = 'O')
144679 )
144680 THEN
144681 NULL;
144682 --
144683 --
144684
144685 l_ccid := AcctDerRule_28(
144686 p_application_id => p_application_id
144687 , p_ae_header_id => l_ae_header_id
144688 , p_source_15 => p_source_15
144689 , p_source_41 => p_source_41
144690 , p_source_42 => p_source_42
144691 , p_source_43 => p_source_43
144692 , p_source_44 => p_source_44
144693 , p_source_45 => p_source_45
144694 , x_transaction_coa_id => l_adr_transaction_coa_id
144695 , x_accounting_coa_id => l_adr_accounting_coa_id
144696 , x_value_type_code => l_adr_value_type_code
144697 , p_side => 'NA'
144698 );
144699
144700 xla_ae_lines_pkg.set_ccid(
144701 p_code_combination_id => l_ccid
144702 , p_value_type_code => l_adr_value_type_code
144703 , p_transaction_coa_id => l_adr_transaction_coa_id
144704 , p_accounting_coa_id => l_adr_accounting_coa_id
144705 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
144706 , p_adr_type_code => 'S'
144707 , p_component_type => l_component_type
144708 , p_component_code => l_component_code
144709 , p_component_type_code => l_component_type_code
144710 , p_component_appl_id => l_component_appl_id
144711 , p_amb_context_code => l_amb_context_code
144712 , p_side => 'NA'
144713 );
144714
144715
144716 --
144717 --
144718 END IF;
144719
144720 --
144721 -- Update the line information that should be overwritten
144722 --
144723 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
144724 p_header_num => 1);
144725 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
144726
144727 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
144728
144729 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
144730 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
144731 END IF;
144732
144733 --
144734 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
144735 --
144736 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
144737 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
144738 ELSE
144739 ---------------------------------------------------------------------------------------------------
144740 -- 4262811a Switch Sign
144741 ---------------------------------------------------------------------------------------------------
144742 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
144743 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
144744 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144745 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
144746 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144747 -- 5132302
144748 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
144749 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
144750
144751 END IF;
144752
144753 -- 4955764
144754 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
144755 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
144756
144757
144758 XLA_AE_LINES_PKG.ValidateCurrentLine;
144759 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
144760
144761 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
144762 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
144763 ,p_balance_type_code => l_balance_type_code);
144764
144765 END IF;
144766
144767 -----------------------------------------------------------------------------------------
144768 -- 4262811 Multiperiod Accounting
144769 -----------------------------------------------------------------------------------------
144770 -- No MPA option is assigned.
144771
144772
144773 END IF;
144774 END IF;
144775 --
144776
144777 --
144778 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
144779 trace
144780 (p_msg => 'END of AcctLineType_272'
144781 ,p_level => C_LEVEL_PROCEDURE
144782 ,p_module => l_log_module);
144783 END IF;
144784 --
144785 EXCEPTION
144786 WHEN xla_exceptions_pkg.application_exception THEN
144787 RAISE;
144788 WHEN OTHERS THEN
144789 xla_exceptions_pkg.raise_message
144790 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_272');
144791 END AcctLineType_272;
144792 --
144793
144794 ---------------------------------------
144795 --
144796 -- PRIVATE FUNCTION
144797 -- AcctLineType_273
144798 --
144799 ---------------------------------------
144800 PROCEDURE AcctLineType_273 (
144801 p_application_id IN NUMBER
144802 ,p_event_id IN NUMBER
144803 ,p_calculate_acctd_flag IN VARCHAR2
144804 ,p_calculate_g_l_flag IN VARCHAR2
144805 ,p_actual_flag IN OUT VARCHAR2
144806 ,p_balance_type_code OUT VARCHAR2
144807 ,p_gain_or_loss_ref OUT VARCHAR2
144808
144809 --TRANSACTION_ID
144810 , p_source_1 IN NUMBER
144811 --Item Concatenated Segments
144812 , p_source_2 IN VARCHAR2
144813 --Transaction Quantity
144814 , p_source_3 IN NUMBER
144815 --Transaction Unit of Measure Code
144816 , p_source_4 IN VARCHAR2
144817 --Inventory Transaction Type Description
144818 , p_source_5 IN VARCHAR2
144819 --Cost Element Name
144820 , p_source_15 IN NUMBER
144821 --Product Line Accounting Category Material Account
144822 , p_source_41 IN NUMBER
144823 --Product Line Accounting Category Material Overhead Account
144824 , p_source_42 IN NUMBER
144825 --Product Line Accounting Category Resource Account
144826 , p_source_43 IN NUMBER
144827 --Product Line Accounting Category Outside Processing Account
144828 , p_source_44 IN NUMBER
144829 --Product Line Accounting Category Overhead Account
144830 , p_source_45 IN NUMBER
144831 --DISTRIBUTION_IDENTIFIER
144832 , p_source_84 IN NUMBER
144833 --Distribution Type
144834 , p_source_85 IN VARCHAR2
144835 , p_source_85_meaning IN VARCHAR2
144836 --Entered Currency Code
144837 , p_source_88 IN VARCHAR2
144838 --Entered Amount
144839 , p_source_91 IN NUMBER
144840 --Currency Conversion Date
144841 , p_source_92 IN DATE
144842 --Currency Conversion Rate
144843 , p_source_93 IN NUMBER
144844 --Currency Conversion Type
144845 , p_source_94 IN VARCHAR2
144846 --Accounted Amount
144847 , p_source_95 IN NUMBER
144848 --Accounting Line Type
144849 , p_source_97 IN NUMBER
144850 --Organization Code
144851 , p_source_108 IN VARCHAR2
144852 )
144853 IS
144854
144855 l_component_type VARCHAR2(80);
144856 l_component_code VARCHAR2(30);
144857 l_component_type_code VARCHAR2(1);
144858 l_component_appl_id INTEGER;
144859 l_amb_context_code VARCHAR2(30);
144860 l_entity_code VARCHAR2(30);
144861 l_event_class_code VARCHAR2(30);
144862 l_ae_header_id NUMBER;
144863 l_event_type_code VARCHAR2(30);
144864 l_line_definition_code VARCHAR2(30);
144865 l_line_definition_owner_code VARCHAR2(1);
144866 --
144867 -- adr variables
144868 l_segment VARCHAR2(30);
144869 l_ccid NUMBER;
144870 l_adr_transaction_coa_id NUMBER;
144871 l_adr_accounting_coa_id NUMBER;
144872 l_adr_flexfield_segment_code VARCHAR2(30);
144873 l_adr_flex_value_set_id NUMBER;
144874 l_adr_value_type_code VARCHAR2(30);
144875 l_adr_value_combination_id NUMBER;
144876 l_adr_value_segment_code VARCHAR2(30);
144877
144878 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
144879 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
144880 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
144881 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
144882
144883 -- 4262811 Variables ------------------------------------------------------------------------------------------
144884 l_entered_amt_idx NUMBER;
144885 l_accted_amt_idx NUMBER;
144886 l_acc_rev_flag VARCHAR2(1);
144887 l_accrual_line_num NUMBER;
144888 l_tmp_amt NUMBER;
144889 l_acc_rev_natural_side_code VARCHAR2(1);
144890
144891 l_num_entries NUMBER;
144892 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
144893 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
144894 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
144895 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
144896 l_recog_line_1 NUMBER;
144897 l_recog_line_2 NUMBER;
144898
144899 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
144900 l_bflow_applied_to_amt NUMBER; -- 5132302
144901 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
144902
144903 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
144904
144905 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
144906 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
144907
144908 ---------------------------------------------------------------------------------------------------------------
144909
144910
144911 --
144912 -- bulk performance
144913 --
144914 l_balance_type_code VARCHAR2(1);
144915 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
144916 l_log_module VARCHAR2(240);
144917
144918 --
144919 -- Upgrade strategy
144920 --
144921 l_actual_upg_option VARCHAR2(1);
144922 l_enc_upg_option VARCHAR2(1);
144923
144924 --
144925 BEGIN
144926 --
144927 IF g_log_enabled THEN
144928 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_273';
144929 END IF;
144930 --
144931 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
144932
144933 trace
144934 (p_msg => 'BEGIN of AcctLineType_273'
144935 ,p_level => C_LEVEL_PROCEDURE
144936 ,p_module => l_log_module);
144937
144938 END IF;
144939 --
144940 l_component_type := 'AMB_JLT';
144941 l_component_code := 'INVENTORY_VALUATION';
144942 l_component_type_code := 'S';
144943 l_component_appl_id := 707;
144944 l_amb_context_code := 'DEFAULT';
144945 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
144946 l_event_class_code := 'WIP_MTL';
144947 l_event_type_code := 'WIP_ASSEMBLY_COMPLETION';
144948 l_line_definition_owner_code := 'S';
144949 l_line_definition_code := 'PI_WIP_ASSEMBLY_COMPLETION';
144950 --
144951 l_balance_type_code := 'A';
144952 l_segment := NULL;
144953 l_ccid := NULL;
144954 l_adr_transaction_coa_id := NULL;
144955 l_adr_accounting_coa_id := NULL;
144956 l_adr_flexfield_segment_code := NULL;
144957 l_adr_flex_value_set_id := NULL;
144958 l_adr_value_type_code := NULL;
144959 l_adr_value_combination_id := NULL;
144960 l_adr_value_segment_code := NULL;
144961
144962 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
144963 l_bflow_class_code := ''; -- 4219869 Business Flow
144964 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
144965 l_budgetary_control_flag := 'N';
144966
144967 l_bflow_applied_to_amt_idx := NULL; -- 5132302
144968 l_bflow_applied_to_amt := NULL; -- 5132302
144969 l_entered_amt_idx := NULL; -- 4262811
144970 l_accted_amt_idx := NULL; -- 4262811
144971 l_acc_rev_flag := NULL; -- 4262811
144972 l_accrual_line_num := NULL; -- 4262811
144973 l_tmp_amt := NULL; -- 4262811
144974 --
144975
144976 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
144977 l_balance_type_code <> 'B' THEN
144978 IF NVL(p_source_97,9E125) = 1
144979 THEN
144980
144981 --
144982 XLA_AE_LINES_PKG.SetNewLine;
144983
144984 p_balance_type_code := l_balance_type_code;
144985 -- set the flag so later we will know whether the gain loss line needs to be created
144986
144987 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
144988 p_actual_flag :='A';
144989 END IF;
144990
144991 --
144992 -- bulk performance
144993 --
144994 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
144995 p_header_num => 0); -- 4262811
144996 --
144997 -- set accounting line options
144998 --
144999 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
145000 p_natural_side_code => 'D'
145001 , p_gain_or_loss_flag => 'N'
145002 , p_gl_transfer_mode_code => 'S'
145003 , p_acct_entry_type_code => 'A'
145004 , p_switch_side_flag => 'Y'
145005 , p_merge_duplicate_code => 'N'
145006 );
145007 --
145008 l_acc_rev_natural_side_code := 'C'; -- 4262811
145009 --
145010 --
145011 -- set accounting line type info
145012 --
145013 xla_ae_lines_pkg.SetAcctLineType
145014 (p_component_type => l_component_type
145015 ,p_event_type_code => l_event_type_code
145016 ,p_line_definition_owner_code => l_line_definition_owner_code
145017 ,p_line_definition_code => l_line_definition_code
145018 ,p_accounting_line_code => l_component_code
145019 ,p_accounting_line_type_code => l_component_type_code
145020 ,p_accounting_line_appl_id => l_component_appl_id
145021 ,p_amb_context_code => l_amb_context_code
145022 ,p_entity_code => l_entity_code
145023 ,p_event_class_code => l_event_class_code);
145024 --
145025 -- set accounting class
145026 --
145027 xla_ae_lines_pkg.SetAcctClass(
145028 p_accounting_class_code => 'INVENTORY_VALUATION'
145029 , p_ae_header_id => l_ae_header_id
145030 );
145031
145032 --
145033 -- set rounding class
145034 --
145035 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
145036 'INVENTORY_VALUATION';
145037
145038 --
145039 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
145040 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
145041 --
145042 -- bulk performance
145043 --
145044 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
145045
145046 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
145047 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
145048
145049 -- 4955764
145050 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
145051 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
145052
145053 -- 4458381 Public Sector Enh
145054
145055 --
145056 -- set accounting attributes for the line type
145057 --
145058 l_entered_amt_idx := 3;
145059 l_accted_amt_idx := 8;
145060 l_bflow_applied_to_amt_idx := NULL; -- 5132302
145061 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
145062 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
145063 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
145064 l_rec_acct_attrs.array_char_value(2) := p_source_85;
145065 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
145066 l_rec_acct_attrs.array_num_value(3) := p_source_91;
145067 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
145068 l_rec_acct_attrs.array_char_value(4) := p_source_88;
145069 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
145070 l_rec_acct_attrs.array_date_value(5) := p_source_92;
145071 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
145072 l_rec_acct_attrs.array_num_value(6) := p_source_93;
145073 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
145074 l_rec_acct_attrs.array_char_value(7) := p_source_94;
145075 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
145076 l_rec_acct_attrs.array_num_value(8) := p_source_95;
145077
145078 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
145079 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
145080
145081 ---------------------------------------------------------------------------------------------------------------
145082 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
145083 ---------------------------------------------------------------------------------------------------------------
145084 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
145085
145086 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
145087 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
145088
145089 IF xla_accounting_cache_pkg.GetValueChar
145090 (p_source_code => 'LEDGER_CATEGORY_CODE'
145091 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
145092 AND l_bflow_method_code = 'PRIOR_ENTRY'
145093 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
145094 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
145095 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
145096 )
145097 THEN
145098 xla_ae_lines_pkg.BflowUpgEntry
145099 (p_business_method_code => l_bflow_method_code
145100 ,p_business_class_code => l_bflow_class_code
145101 ,p_balance_type => l_balance_type_code);
145102 ELSE
145103 NULL;
145104 -- No business flow processing for business flow method of NONE.
145105 END IF;
145106
145107 --
145108 -- call analytical criteria
145109 --
145110
145111
145112 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
145113 xla_ae_lines_pkg.SetAnalyticalCriteria(
145114 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
145115 , p_analytical_criterion_owner => 'S'
145116 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
145117 , p_amb_context_code => 'DEFAULT'
145118 , p_balancing_flag => 'Y'
145119
145120 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
145121 , p_analytical_detail_num_1 => NULL
145122 , p_analytical_detail_date_1 => NULL
145123
145124 , p_ae_header_id => l_ae_header_id
145125 )
145126 ;
145127 --
145128
145129 --
145130 -- call description
145131 --
145132
145133 xla_ae_lines_pkg.SetLineDescription(
145134 p_ae_header_id => l_ae_header_id
145135 ,p_description => Description_1 (
145136 p_application_id => p_application_id
145137 , p_ae_header_id => l_ae_header_id
145138 , p_source_1 => p_source_1
145139 , p_source_2 => p_source_2
145140 , p_source_3 => p_source_3
145141 , p_source_4 => p_source_4
145142 , p_source_5 => p_source_5
145143 )
145144 );
145145
145146
145147 --
145148 -- call ADRs
145149 -- Bug 4922099
145150 --
145151 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
145152 (NVL(l_actual_upg_option, 'N') = 'O') OR
145153 (NVL(l_enc_upg_option, 'N') = 'O')
145154 )
145155 THEN
145156 NULL;
145157 --
145158 --
145159
145160 l_ccid := AcctDerRule_28(
145161 p_application_id => p_application_id
145162 , p_ae_header_id => l_ae_header_id
145163 , p_source_15 => p_source_15
145164 , p_source_41 => p_source_41
145165 , p_source_42 => p_source_42
145166 , p_source_43 => p_source_43
145167 , p_source_44 => p_source_44
145168 , p_source_45 => p_source_45
145169 , x_transaction_coa_id => l_adr_transaction_coa_id
145170 , x_accounting_coa_id => l_adr_accounting_coa_id
145171 , x_value_type_code => l_adr_value_type_code
145172 , p_side => 'NA'
145173 );
145174
145175 xla_ae_lines_pkg.set_ccid(
145176 p_code_combination_id => l_ccid
145177 , p_value_type_code => l_adr_value_type_code
145178 , p_transaction_coa_id => l_adr_transaction_coa_id
145179 , p_accounting_coa_id => l_adr_accounting_coa_id
145180 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
145181 , p_adr_type_code => 'S'
145182 , p_component_type => l_component_type
145183 , p_component_code => l_component_code
145184 , p_component_type_code => l_component_type_code
145185 , p_component_appl_id => l_component_appl_id
145186 , p_amb_context_code => l_amb_context_code
145187 , p_side => 'NA'
145188 );
145189
145190
145191 --
145192 --
145193 END IF;
145194 --
145195 -- Bug 4922099
145196 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
145197 (NVL(l_enc_upg_option, 'N') = 'O')
145198 ) AND
145199 (l_bflow_method_code = 'PRIOR_ENTRY')
145200 )
145201 THEN
145202 IF
145203 --
145204 1 = 2
145205 --
145206 THEN
145207 xla_accounting_err_pkg.build_message
145208 (p_appli_s_name => 'XLA'
145209 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
145210 ,p_token_1 => 'LINE_NUMBER'
145211 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
145212 ,p_token_2 => 'LINE_TYPE_NAME'
145213 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
145214 l_component_type
145215 ,l_component_code
145216 ,l_component_type_code
145217 ,l_component_appl_id
145218 ,l_amb_context_code
145219 ,l_entity_code
145220 ,l_event_class_code
145221 )
145222 ,p_token_3 => 'OWNER'
145223 ,p_value_3 => xla_lookups_pkg.get_meaning(
145224 p_lookup_type => 'XLA_OWNER_TYPE'
145225 ,p_lookup_code => l_component_type_code
145226 )
145227 ,p_token_4 => 'PRODUCT_NAME'
145228 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
145229 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
145230 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
145231 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
145232 ,p_ae_header_id => NULL
145233 );
145234
145235 IF (C_LEVEL_ERROR>= g_log_level) THEN
145236 trace
145237 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
145238 ,p_level => C_LEVEL_ERROR
145239 ,p_module => l_log_module);
145240 END IF;
145241 END IF;
145242 END IF;
145243 --
145244 --
145245 ------------------------------------------------------------------------------------------------
145246 -- 4219869 Business Flow
145247 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
145248 -- Prior Entry. Currently, the following code is always generated.
145249 ------------------------------------------------------------------------------------------------
145250 XLA_AE_LINES_PKG.ValidateCurrentLine;
145251
145252 ------------------------------------------------------------------------------------
145253 -- 4219869 Business Flow
145254 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
145255 ------------------------------------------------------------------------------------
145256 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
145257
145258 ----------------------------------------------------------------------------------
145259 -- 4219869 Business Flow
145260 -- Update journal entry status -- Need to generate this within IF <condition>
145261 ----------------------------------------------------------------------------------
145262 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
145263 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
145264 ,p_balance_type_code => l_balance_type_code
145265 );
145266
145267 -------------------------------------------------------------------------------------------
145268 -- 4262811 - Generate the Accrual Reversal lines
145269 -------------------------------------------------------------------------------------------
145270 BEGIN
145271 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
145272 (g_array_event(p_event_id).array_value_num('header_index'));
145273 IF l_acc_rev_flag IS NULL THEN
145274 l_acc_rev_flag := 'N';
145275 END IF;
145276 EXCEPTION
145277 WHEN OTHERS THEN
145278 l_acc_rev_flag := 'N';
145279 END;
145280 --
145281 IF (l_acc_rev_flag = 'Y') THEN
145282
145283 -- 4645092 ------------------------------------------------------------------------------
145284 -- To allow MPA report to determine if it should generate report process
145285 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
145286 ------------------------------------------------------------------------------------------
145287
145288 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
145289 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
145290 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
145291 -- call ADRs
145292 -- Bug 4922099
145293 --
145294 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
145295 (NVL(l_actual_upg_option, 'N') = 'O') OR
145296 (NVL(l_enc_upg_option, 'N') = 'O')
145297 )
145298 THEN
145299 NULL;
145300 --
145301 --
145302
145303 l_ccid := AcctDerRule_28(
145304 p_application_id => p_application_id
145305 , p_ae_header_id => l_ae_header_id
145306 , p_source_15 => p_source_15
145307 , p_source_41 => p_source_41
145308 , p_source_42 => p_source_42
145309 , p_source_43 => p_source_43
145310 , p_source_44 => p_source_44
145311 , p_source_45 => p_source_45
145312 , x_transaction_coa_id => l_adr_transaction_coa_id
145313 , x_accounting_coa_id => l_adr_accounting_coa_id
145314 , x_value_type_code => l_adr_value_type_code
145315 , p_side => 'NA'
145316 );
145317
145318 xla_ae_lines_pkg.set_ccid(
145319 p_code_combination_id => l_ccid
145320 , p_value_type_code => l_adr_value_type_code
145321 , p_transaction_coa_id => l_adr_transaction_coa_id
145322 , p_accounting_coa_id => l_adr_accounting_coa_id
145323 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
145324 , p_adr_type_code => 'S'
145325 , p_component_type => l_component_type
145326 , p_component_code => l_component_code
145327 , p_component_type_code => l_component_type_code
145328 , p_component_appl_id => l_component_appl_id
145329 , p_amb_context_code => l_amb_context_code
145330 , p_side => 'NA'
145331 );
145332
145333
145334 --
145335 --
145336 END IF;
145337
145338 --
145339 -- Update the line information that should be overwritten
145340 --
145341 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
145342 p_header_num => 1);
145343 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
145344
145345 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
145346
145347 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
145348 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
145349 END IF;
145350
145351 --
145352 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
145353 --
145354 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
145355 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
145356 ELSE
145357 ---------------------------------------------------------------------------------------------------
145358 -- 4262811a Switch Sign
145359 ---------------------------------------------------------------------------------------------------
145360 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
145361 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
145362 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145363 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
145364 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145365 -- 5132302
145366 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
145367 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145368
145369 END IF;
145370
145371 -- 4955764
145372 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
145373 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
145374
145375
145376 XLA_AE_LINES_PKG.ValidateCurrentLine;
145377 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
145378
145379 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
145380 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
145381 ,p_balance_type_code => l_balance_type_code);
145382
145383 END IF;
145384
145385 -----------------------------------------------------------------------------------------
145386 -- 4262811 Multiperiod Accounting
145387 -----------------------------------------------------------------------------------------
145388 -- No MPA option is assigned.
145389
145390
145391 END IF;
145392 END IF;
145393 --
145394
145395 --
145396 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
145397 trace
145398 (p_msg => 'END of AcctLineType_273'
145399 ,p_level => C_LEVEL_PROCEDURE
145400 ,p_module => l_log_module);
145401 END IF;
145402 --
145403 EXCEPTION
145404 WHEN xla_exceptions_pkg.application_exception THEN
145405 RAISE;
145406 WHEN OTHERS THEN
145407 xla_exceptions_pkg.raise_message
145408 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_273');
145409 END AcctLineType_273;
145410 --
145411
145412 ---------------------------------------
145413 --
145414 -- PRIVATE FUNCTION
145415 -- AcctLineType_274
145416 --
145417 ---------------------------------------
145418 PROCEDURE AcctLineType_274 (
145419 p_application_id IN NUMBER
145420 ,p_event_id IN NUMBER
145421 ,p_calculate_acctd_flag IN VARCHAR2
145422 ,p_calculate_g_l_flag IN VARCHAR2
145423 ,p_actual_flag IN OUT VARCHAR2
145424 ,p_balance_type_code OUT VARCHAR2
145425 ,p_gain_or_loss_ref OUT VARCHAR2
145426
145427 --TRANSACTION_ID
145428 , p_source_1 IN NUMBER
145429 --Item Concatenated Segments
145430 , p_source_2 IN VARCHAR2
145431 --Transaction Quantity
145432 , p_source_3 IN NUMBER
145433 --Transaction Unit of Measure Code
145434 , p_source_4 IN VARCHAR2
145435 --Inventory Transaction Type Description
145436 , p_source_5 IN VARCHAR2
145437 --Cost Element Name
145438 , p_source_15 IN NUMBER
145439 --Product Line Accounting Category Material Account
145440 , p_source_41 IN NUMBER
145441 --Product Line Accounting Category Material Overhead Account
145442 , p_source_42 IN NUMBER
145443 --Product Line Accounting Category Resource Account
145444 , p_source_43 IN NUMBER
145445 --Product Line Accounting Category Outside Processing Account
145446 , p_source_44 IN NUMBER
145447 --Product Line Accounting Category Overhead Account
145448 , p_source_45 IN NUMBER
145449 --DISTRIBUTION_IDENTIFIER
145450 , p_source_84 IN NUMBER
145451 --Distribution Type
145452 , p_source_85 IN VARCHAR2
145453 , p_source_85_meaning IN VARCHAR2
145454 --Entered Currency Code
145455 , p_source_88 IN VARCHAR2
145456 --Entered Amount
145457 , p_source_91 IN NUMBER
145458 --Currency Conversion Date
145459 , p_source_92 IN DATE
145460 --Currency Conversion Rate
145461 , p_source_93 IN NUMBER
145462 --Currency Conversion Type
145463 , p_source_94 IN VARCHAR2
145464 --Accounted Amount
145465 , p_source_95 IN NUMBER
145466 --Accounting Line Type
145467 , p_source_97 IN NUMBER
145468 --Organization Code
145469 , p_source_108 IN VARCHAR2
145470 )
145471 IS
145472
145473 l_component_type VARCHAR2(80);
145474 l_component_code VARCHAR2(30);
145475 l_component_type_code VARCHAR2(1);
145476 l_component_appl_id INTEGER;
145477 l_amb_context_code VARCHAR2(30);
145478 l_entity_code VARCHAR2(30);
145479 l_event_class_code VARCHAR2(30);
145480 l_ae_header_id NUMBER;
145481 l_event_type_code VARCHAR2(30);
145482 l_line_definition_code VARCHAR2(30);
145483 l_line_definition_owner_code VARCHAR2(1);
145484 --
145485 -- adr variables
145486 l_segment VARCHAR2(30);
145487 l_ccid NUMBER;
145488 l_adr_transaction_coa_id NUMBER;
145489 l_adr_accounting_coa_id NUMBER;
145490 l_adr_flexfield_segment_code VARCHAR2(30);
145491 l_adr_flex_value_set_id NUMBER;
145492 l_adr_value_type_code VARCHAR2(30);
145493 l_adr_value_combination_id NUMBER;
145494 l_adr_value_segment_code VARCHAR2(30);
145495
145496 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
145497 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
145498 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
145499 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
145500
145501 -- 4262811 Variables ------------------------------------------------------------------------------------------
145502 l_entered_amt_idx NUMBER;
145503 l_accted_amt_idx NUMBER;
145504 l_acc_rev_flag VARCHAR2(1);
145505 l_accrual_line_num NUMBER;
145506 l_tmp_amt NUMBER;
145507 l_acc_rev_natural_side_code VARCHAR2(1);
145508
145509 l_num_entries NUMBER;
145510 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
145511 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
145512 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
145513 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
145514 l_recog_line_1 NUMBER;
145515 l_recog_line_2 NUMBER;
145516
145517 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
145518 l_bflow_applied_to_amt NUMBER; -- 5132302
145519 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
145520
145521 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
145522
145523 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
145524 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
145525
145526 ---------------------------------------------------------------------------------------------------------------
145527
145528
145529 --
145530 -- bulk performance
145531 --
145532 l_balance_type_code VARCHAR2(1);
145533 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
145534 l_log_module VARCHAR2(240);
145535
145536 --
145537 -- Upgrade strategy
145538 --
145539 l_actual_upg_option VARCHAR2(1);
145540 l_enc_upg_option VARCHAR2(1);
145541
145542 --
145543 BEGIN
145544 --
145545 IF g_log_enabled THEN
145546 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_274';
145547 END IF;
145548 --
145549 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
145550
145551 trace
145552 (p_msg => 'BEGIN of AcctLineType_274'
145553 ,p_level => C_LEVEL_PROCEDURE
145554 ,p_module => l_log_module);
145555
145556 END IF;
145557 --
145558 l_component_type := 'AMB_JLT';
145559 l_component_code := 'INVENTORY_VALUATION';
145560 l_component_type_code := 'S';
145561 l_component_appl_id := 707;
145562 l_amb_context_code := 'DEFAULT';
145563 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
145564 l_event_class_code := 'WIP_MTL';
145565 l_event_type_code := 'WIP_NEG_COMP_ISSUE';
145566 l_line_definition_owner_code := 'S';
145567 l_line_definition_code := 'PI_WIP_NEG_COMP_ISSUE';
145568 --
145569 l_balance_type_code := 'A';
145570 l_segment := NULL;
145571 l_ccid := NULL;
145572 l_adr_transaction_coa_id := NULL;
145573 l_adr_accounting_coa_id := NULL;
145574 l_adr_flexfield_segment_code := NULL;
145575 l_adr_flex_value_set_id := NULL;
145576 l_adr_value_type_code := NULL;
145577 l_adr_value_combination_id := NULL;
145578 l_adr_value_segment_code := NULL;
145579
145580 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
145581 l_bflow_class_code := ''; -- 4219869 Business Flow
145582 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
145583 l_budgetary_control_flag := 'N';
145584
145585 l_bflow_applied_to_amt_idx := NULL; -- 5132302
145586 l_bflow_applied_to_amt := NULL; -- 5132302
145587 l_entered_amt_idx := NULL; -- 4262811
145588 l_accted_amt_idx := NULL; -- 4262811
145589 l_acc_rev_flag := NULL; -- 4262811
145590 l_accrual_line_num := NULL; -- 4262811
145591 l_tmp_amt := NULL; -- 4262811
145592 --
145593
145594 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
145595 l_balance_type_code <> 'B' THEN
145596 IF NVL(p_source_97,9E125) = 1
145597 THEN
145598
145599 --
145600 XLA_AE_LINES_PKG.SetNewLine;
145601
145602 p_balance_type_code := l_balance_type_code;
145603 -- set the flag so later we will know whether the gain loss line needs to be created
145604
145605 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
145606 p_actual_flag :='A';
145607 END IF;
145608
145609 --
145610 -- bulk performance
145611 --
145612 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
145613 p_header_num => 0); -- 4262811
145614 --
145615 -- set accounting line options
145616 --
145617 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
145618 p_natural_side_code => 'D'
145619 , p_gain_or_loss_flag => 'N'
145620 , p_gl_transfer_mode_code => 'S'
145621 , p_acct_entry_type_code => 'A'
145622 , p_switch_side_flag => 'Y'
145623 , p_merge_duplicate_code => 'N'
145624 );
145625 --
145626 l_acc_rev_natural_side_code := 'C'; -- 4262811
145627 --
145628 --
145629 -- set accounting line type info
145630 --
145631 xla_ae_lines_pkg.SetAcctLineType
145632 (p_component_type => l_component_type
145633 ,p_event_type_code => l_event_type_code
145634 ,p_line_definition_owner_code => l_line_definition_owner_code
145635 ,p_line_definition_code => l_line_definition_code
145636 ,p_accounting_line_code => l_component_code
145637 ,p_accounting_line_type_code => l_component_type_code
145638 ,p_accounting_line_appl_id => l_component_appl_id
145639 ,p_amb_context_code => l_amb_context_code
145640 ,p_entity_code => l_entity_code
145641 ,p_event_class_code => l_event_class_code);
145642 --
145643 -- set accounting class
145644 --
145645 xla_ae_lines_pkg.SetAcctClass(
145646 p_accounting_class_code => 'INVENTORY_VALUATION'
145647 , p_ae_header_id => l_ae_header_id
145648 );
145649
145650 --
145651 -- set rounding class
145652 --
145653 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
145654 'INVENTORY_VALUATION';
145655
145656 --
145657 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
145658 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
145659 --
145660 -- bulk performance
145661 --
145662 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
145663
145664 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
145665 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
145666
145667 -- 4955764
145668 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
145669 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
145670
145671 -- 4458381 Public Sector Enh
145672
145673 --
145674 -- set accounting attributes for the line type
145675 --
145676 l_entered_amt_idx := 3;
145677 l_accted_amt_idx := 8;
145678 l_bflow_applied_to_amt_idx := NULL; -- 5132302
145679 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
145680 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
145681 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
145682 l_rec_acct_attrs.array_char_value(2) := p_source_85;
145683 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
145684 l_rec_acct_attrs.array_num_value(3) := p_source_91;
145685 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
145686 l_rec_acct_attrs.array_char_value(4) := p_source_88;
145687 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
145688 l_rec_acct_attrs.array_date_value(5) := p_source_92;
145689 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
145690 l_rec_acct_attrs.array_num_value(6) := p_source_93;
145691 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
145692 l_rec_acct_attrs.array_char_value(7) := p_source_94;
145693 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
145694 l_rec_acct_attrs.array_num_value(8) := p_source_95;
145695
145696 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
145697 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
145698
145699 ---------------------------------------------------------------------------------------------------------------
145700 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
145701 ---------------------------------------------------------------------------------------------------------------
145702 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
145703
145704 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
145705 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
145706
145707 IF xla_accounting_cache_pkg.GetValueChar
145708 (p_source_code => 'LEDGER_CATEGORY_CODE'
145709 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
145710 AND l_bflow_method_code = 'PRIOR_ENTRY'
145711 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
145712 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
145713 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
145714 )
145715 THEN
145716 xla_ae_lines_pkg.BflowUpgEntry
145717 (p_business_method_code => l_bflow_method_code
145718 ,p_business_class_code => l_bflow_class_code
145719 ,p_balance_type => l_balance_type_code);
145720 ELSE
145721 NULL;
145722 -- No business flow processing for business flow method of NONE.
145723 END IF;
145724
145725 --
145726 -- call analytical criteria
145727 --
145728
145729
145730 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
145731 xla_ae_lines_pkg.SetAnalyticalCriteria(
145732 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
145733 , p_analytical_criterion_owner => 'S'
145734 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
145735 , p_amb_context_code => 'DEFAULT'
145736 , p_balancing_flag => 'Y'
145737
145738 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
145739 , p_analytical_detail_num_1 => NULL
145740 , p_analytical_detail_date_1 => NULL
145741
145742 , p_ae_header_id => l_ae_header_id
145743 )
145744 ;
145745 --
145746
145747 --
145748 -- call description
145749 --
145750
145751 xla_ae_lines_pkg.SetLineDescription(
145752 p_ae_header_id => l_ae_header_id
145753 ,p_description => Description_1 (
145754 p_application_id => p_application_id
145755 , p_ae_header_id => l_ae_header_id
145756 , p_source_1 => p_source_1
145757 , p_source_2 => p_source_2
145758 , p_source_3 => p_source_3
145759 , p_source_4 => p_source_4
145760 , p_source_5 => p_source_5
145761 )
145762 );
145763
145764
145765 --
145766 -- call ADRs
145767 -- Bug 4922099
145768 --
145769 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
145770 (NVL(l_actual_upg_option, 'N') = 'O') OR
145771 (NVL(l_enc_upg_option, 'N') = 'O')
145772 )
145773 THEN
145774 NULL;
145775 --
145776 --
145777
145778 l_ccid := AcctDerRule_28(
145779 p_application_id => p_application_id
145780 , p_ae_header_id => l_ae_header_id
145781 , p_source_15 => p_source_15
145782 , p_source_41 => p_source_41
145783 , p_source_42 => p_source_42
145784 , p_source_43 => p_source_43
145785 , p_source_44 => p_source_44
145786 , p_source_45 => p_source_45
145787 , x_transaction_coa_id => l_adr_transaction_coa_id
145788 , x_accounting_coa_id => l_adr_accounting_coa_id
145789 , x_value_type_code => l_adr_value_type_code
145790 , p_side => 'NA'
145791 );
145792
145793 xla_ae_lines_pkg.set_ccid(
145794 p_code_combination_id => l_ccid
145795 , p_value_type_code => l_adr_value_type_code
145796 , p_transaction_coa_id => l_adr_transaction_coa_id
145797 , p_accounting_coa_id => l_adr_accounting_coa_id
145798 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
145799 , p_adr_type_code => 'S'
145800 , p_component_type => l_component_type
145801 , p_component_code => l_component_code
145802 , p_component_type_code => l_component_type_code
145803 , p_component_appl_id => l_component_appl_id
145804 , p_amb_context_code => l_amb_context_code
145805 , p_side => 'NA'
145806 );
145807
145808
145809 --
145810 --
145811 END IF;
145812 --
145813 -- Bug 4922099
145814 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
145815 (NVL(l_enc_upg_option, 'N') = 'O')
145816 ) AND
145817 (l_bflow_method_code = 'PRIOR_ENTRY')
145818 )
145819 THEN
145820 IF
145821 --
145822 1 = 2
145823 --
145824 THEN
145825 xla_accounting_err_pkg.build_message
145826 (p_appli_s_name => 'XLA'
145827 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
145828 ,p_token_1 => 'LINE_NUMBER'
145829 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
145830 ,p_token_2 => 'LINE_TYPE_NAME'
145831 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
145832 l_component_type
145833 ,l_component_code
145834 ,l_component_type_code
145835 ,l_component_appl_id
145836 ,l_amb_context_code
145837 ,l_entity_code
145838 ,l_event_class_code
145839 )
145840 ,p_token_3 => 'OWNER'
145841 ,p_value_3 => xla_lookups_pkg.get_meaning(
145842 p_lookup_type => 'XLA_OWNER_TYPE'
145843 ,p_lookup_code => l_component_type_code
145844 )
145845 ,p_token_4 => 'PRODUCT_NAME'
145846 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
145847 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
145848 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
145849 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
145850 ,p_ae_header_id => NULL
145851 );
145852
145853 IF (C_LEVEL_ERROR>= g_log_level) THEN
145854 trace
145855 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
145856 ,p_level => C_LEVEL_ERROR
145857 ,p_module => l_log_module);
145858 END IF;
145859 END IF;
145860 END IF;
145861 --
145862 --
145863 ------------------------------------------------------------------------------------------------
145864 -- 4219869 Business Flow
145865 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
145866 -- Prior Entry. Currently, the following code is always generated.
145867 ------------------------------------------------------------------------------------------------
145868 XLA_AE_LINES_PKG.ValidateCurrentLine;
145869
145870 ------------------------------------------------------------------------------------
145871 -- 4219869 Business Flow
145872 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
145873 ------------------------------------------------------------------------------------
145874 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
145875
145876 ----------------------------------------------------------------------------------
145877 -- 4219869 Business Flow
145878 -- Update journal entry status -- Need to generate this within IF <condition>
145879 ----------------------------------------------------------------------------------
145880 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
145881 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
145882 ,p_balance_type_code => l_balance_type_code
145883 );
145884
145885 -------------------------------------------------------------------------------------------
145886 -- 4262811 - Generate the Accrual Reversal lines
145887 -------------------------------------------------------------------------------------------
145888 BEGIN
145889 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
145890 (g_array_event(p_event_id).array_value_num('header_index'));
145891 IF l_acc_rev_flag IS NULL THEN
145892 l_acc_rev_flag := 'N';
145893 END IF;
145894 EXCEPTION
145895 WHEN OTHERS THEN
145896 l_acc_rev_flag := 'N';
145897 END;
145898 --
145899 IF (l_acc_rev_flag = 'Y') THEN
145900
145901 -- 4645092 ------------------------------------------------------------------------------
145902 -- To allow MPA report to determine if it should generate report process
145903 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
145904 ------------------------------------------------------------------------------------------
145905
145906 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
145907 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
145908 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
145909 -- call ADRs
145910 -- Bug 4922099
145911 --
145912 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
145913 (NVL(l_actual_upg_option, 'N') = 'O') OR
145914 (NVL(l_enc_upg_option, 'N') = 'O')
145915 )
145916 THEN
145917 NULL;
145918 --
145919 --
145920
145921 l_ccid := AcctDerRule_28(
145922 p_application_id => p_application_id
145923 , p_ae_header_id => l_ae_header_id
145924 , p_source_15 => p_source_15
145925 , p_source_41 => p_source_41
145926 , p_source_42 => p_source_42
145927 , p_source_43 => p_source_43
145928 , p_source_44 => p_source_44
145929 , p_source_45 => p_source_45
145930 , x_transaction_coa_id => l_adr_transaction_coa_id
145931 , x_accounting_coa_id => l_adr_accounting_coa_id
145932 , x_value_type_code => l_adr_value_type_code
145933 , p_side => 'NA'
145934 );
145935
145936 xla_ae_lines_pkg.set_ccid(
145937 p_code_combination_id => l_ccid
145938 , p_value_type_code => l_adr_value_type_code
145939 , p_transaction_coa_id => l_adr_transaction_coa_id
145940 , p_accounting_coa_id => l_adr_accounting_coa_id
145941 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
145942 , p_adr_type_code => 'S'
145943 , p_component_type => l_component_type
145944 , p_component_code => l_component_code
145945 , p_component_type_code => l_component_type_code
145946 , p_component_appl_id => l_component_appl_id
145947 , p_amb_context_code => l_amb_context_code
145948 , p_side => 'NA'
145949 );
145950
145951
145952 --
145953 --
145954 END IF;
145955
145956 --
145957 -- Update the line information that should be overwritten
145958 --
145959 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
145960 p_header_num => 1);
145961 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
145962
145963 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
145964
145965 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
145966 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
145967 END IF;
145968
145969 --
145970 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
145971 --
145972 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
145973 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
145974 ELSE
145975 ---------------------------------------------------------------------------------------------------
145976 -- 4262811a Switch Sign
145977 ---------------------------------------------------------------------------------------------------
145978 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
145979 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
145980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145981 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
145982 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145983 -- 5132302
145984 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
145985 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
145986
145987 END IF;
145988
145989 -- 4955764
145990 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
145991 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
145992
145993
145994 XLA_AE_LINES_PKG.ValidateCurrentLine;
145995 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
145996
145997 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
145998 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
145999 ,p_balance_type_code => l_balance_type_code);
146000
146001 END IF;
146002
146003 -----------------------------------------------------------------------------------------
146004 -- 4262811 Multiperiod Accounting
146005 -----------------------------------------------------------------------------------------
146006 -- No MPA option is assigned.
146007
146008
146009 END IF;
146010 END IF;
146011 --
146012
146013 --
146014 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
146015 trace
146016 (p_msg => 'END of AcctLineType_274'
146017 ,p_level => C_LEVEL_PROCEDURE
146018 ,p_module => l_log_module);
146019 END IF;
146020 --
146021 EXCEPTION
146022 WHEN xla_exceptions_pkg.application_exception THEN
146023 RAISE;
146024 WHEN OTHERS THEN
146025 xla_exceptions_pkg.raise_message
146026 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_274');
146027 END AcctLineType_274;
146028 --
146029
146030 ---------------------------------------
146031 --
146032 -- PRIVATE FUNCTION
146033 -- AcctLineType_275
146034 --
146035 ---------------------------------------
146036 PROCEDURE AcctLineType_275 (
146037 p_application_id IN NUMBER
146038 ,p_event_id IN NUMBER
146039 ,p_calculate_acctd_flag IN VARCHAR2
146040 ,p_calculate_g_l_flag IN VARCHAR2
146041 ,p_actual_flag IN OUT VARCHAR2
146042 ,p_balance_type_code OUT VARCHAR2
146043 ,p_gain_or_loss_ref OUT VARCHAR2
146044
146045 --TRANSACTION_ID
146046 , p_source_1 IN NUMBER
146047 --Item Concatenated Segments
146048 , p_source_2 IN VARCHAR2
146049 --Transaction Quantity
146050 , p_source_3 IN NUMBER
146051 --Transaction Unit of Measure Code
146052 , p_source_4 IN VARCHAR2
146053 --Inventory Transaction Type Description
146054 , p_source_5 IN VARCHAR2
146055 --Cost Element Name
146056 , p_source_15 IN NUMBER
146057 --Product Line Accounting Category Material Account
146058 , p_source_41 IN NUMBER
146059 --Product Line Accounting Category Material Overhead Account
146060 , p_source_42 IN NUMBER
146061 --Product Line Accounting Category Resource Account
146062 , p_source_43 IN NUMBER
146063 --Product Line Accounting Category Outside Processing Account
146064 , p_source_44 IN NUMBER
146065 --Product Line Accounting Category Overhead Account
146066 , p_source_45 IN NUMBER
146067 --Applied to Application ID
146068 , p_source_79 IN NUMBER
146069 --Applied to Distribution Link Type
146070 , p_source_80 IN VARCHAR2
146071 --Applied to Entity Code
146072 , p_source_81 IN VARCHAR2
146073 --DISTRIBUTION_IDENTIFIER
146074 , p_source_84 IN NUMBER
146075 --Distribution Type
146076 , p_source_85 IN VARCHAR2
146077 , p_source_85_meaning IN VARCHAR2
146078 --Encumbrance Reversal Amount Entered
146079 , p_source_87 IN NUMBER
146080 --Entered Currency Code
146081 , p_source_88 IN VARCHAR2
146082 --Transaction Encumbrance Reversal Amount
146083 , p_source_89 IN NUMBER
146084 --Entered Amount
146085 , p_source_91 IN NUMBER
146086 --Currency Conversion Date
146087 , p_source_92 IN DATE
146088 --Currency Conversion Rate
146089 , p_source_93 IN NUMBER
146090 --Currency Conversion Type
146091 , p_source_94 IN VARCHAR2
146092 --Accounted Amount
146093 , p_source_95 IN NUMBER
146094 --Accounting Line Type
146095 , p_source_97 IN NUMBER
146096 --Costing Encumbrance Upgrade Option
146097 , p_source_100 IN VARCHAR2
146098 --TXN_PO_DISTRIBUTION_ID
146099 , p_source_101 IN NUMBER
146100 --TXN_PO_HEADER_ID
146101 , p_source_102 IN NUMBER
146102 --Requisition Budget Account
146103 , p_source_103 IN NUMBER
146104 --Requisition Encumbrance Type Identifier
146105 , p_source_104 IN NUMBER
146106 --Organization Code
146107 , p_source_108 IN VARCHAR2
146108 )
146109 IS
146110
146111 l_component_type VARCHAR2(80);
146112 l_component_code VARCHAR2(30);
146113 l_component_type_code VARCHAR2(1);
146114 l_component_appl_id INTEGER;
146115 l_amb_context_code VARCHAR2(30);
146116 l_entity_code VARCHAR2(30);
146117 l_event_class_code VARCHAR2(30);
146118 l_ae_header_id NUMBER;
146119 l_event_type_code VARCHAR2(30);
146120 l_line_definition_code VARCHAR2(30);
146121 l_line_definition_owner_code VARCHAR2(1);
146122 --
146123 -- adr variables
146124 l_segment VARCHAR2(30);
146125 l_ccid NUMBER;
146126 l_adr_transaction_coa_id NUMBER;
146127 l_adr_accounting_coa_id NUMBER;
146128 l_adr_flexfield_segment_code VARCHAR2(30);
146129 l_adr_flex_value_set_id NUMBER;
146130 l_adr_value_type_code VARCHAR2(30);
146131 l_adr_value_combination_id NUMBER;
146132 l_adr_value_segment_code VARCHAR2(30);
146133
146134 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
146135 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
146136 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
146137 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
146138
146139 -- 4262811 Variables ------------------------------------------------------------------------------------------
146140 l_entered_amt_idx NUMBER;
146141 l_accted_amt_idx NUMBER;
146142 l_acc_rev_flag VARCHAR2(1);
146143 l_accrual_line_num NUMBER;
146144 l_tmp_amt NUMBER;
146145 l_acc_rev_natural_side_code VARCHAR2(1);
146146
146147 l_num_entries NUMBER;
146148 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
146149 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
146150 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
146151 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
146152 l_recog_line_1 NUMBER;
146153 l_recog_line_2 NUMBER;
146154
146155 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
146156 l_bflow_applied_to_amt NUMBER; -- 5132302
146157 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
146158
146159 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
146160
146161 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
146162 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
146163
146164 ---------------------------------------------------------------------------------------------------------------
146165
146166
146167 --
146168 -- bulk performance
146169 --
146170 l_balance_type_code VARCHAR2(1);
146171 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
146172 l_log_module VARCHAR2(240);
146173
146174 --
146175 -- Upgrade strategy
146176 --
146177 l_actual_upg_option VARCHAR2(1);
146178 l_enc_upg_option VARCHAR2(1);
146179
146180 --
146181 BEGIN
146182 --
146183 IF g_log_enabled THEN
146184 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_275';
146185 END IF;
146186 --
146187 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
146188
146189 trace
146190 (p_msg => 'BEGIN of AcctLineType_275'
146191 ,p_level => C_LEVEL_PROCEDURE
146192 ,p_module => l_log_module);
146193
146194 END IF;
146195 --
146196 l_component_type := 'AMB_JLT';
146197 l_component_code := 'INVENTORY_VALUATION';
146198 l_component_type_code := 'S';
146199 l_component_appl_id := 707;
146200 l_amb_context_code := 'DEFAULT';
146201 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
146202 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
146203 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
146204 l_line_definition_owner_code := 'S';
146205 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
146206 --
146207 l_balance_type_code := 'A';
146208 l_segment := NULL;
146209 l_ccid := NULL;
146210 l_adr_transaction_coa_id := NULL;
146211 l_adr_accounting_coa_id := NULL;
146212 l_adr_flexfield_segment_code := NULL;
146213 l_adr_flex_value_set_id := NULL;
146214 l_adr_value_type_code := NULL;
146215 l_adr_value_combination_id := NULL;
146216 l_adr_value_segment_code := NULL;
146217
146218 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
146219 l_bflow_class_code := ''; -- 4219869 Business Flow
146220 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
146221 l_budgetary_control_flag := 'N';
146222
146223 l_bflow_applied_to_amt_idx := NULL; -- 5132302
146224 l_bflow_applied_to_amt := NULL; -- 5132302
146225 l_entered_amt_idx := NULL; -- 4262811
146226 l_accted_amt_idx := NULL; -- 4262811
146227 l_acc_rev_flag := NULL; -- 4262811
146228 l_accrual_line_num := NULL; -- 4262811
146229 l_tmp_amt := NULL; -- 4262811
146230 --
146231
146232 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
146233 l_balance_type_code <> 'B' THEN
146234 IF NVL(p_source_97,9E125) = 1
146235 THEN
146236
146237 --
146238 XLA_AE_LINES_PKG.SetNewLine;
146239
146240 p_balance_type_code := l_balance_type_code;
146241 -- set the flag so later we will know whether the gain loss line needs to be created
146242
146243 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
146244 p_actual_flag :='A';
146245 END IF;
146246
146247 --
146248 -- bulk performance
146249 --
146250 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
146251 p_header_num => 0); -- 4262811
146252 --
146253 -- set accounting line options
146254 --
146255 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
146256 p_natural_side_code => 'D'
146257 , p_gain_or_loss_flag => 'N'
146258 , p_gl_transfer_mode_code => 'S'
146259 , p_acct_entry_type_code => 'A'
146260 , p_switch_side_flag => 'Y'
146261 , p_merge_duplicate_code => 'N'
146262 );
146263 --
146264 l_acc_rev_natural_side_code := 'C'; -- 4262811
146265 --
146266 --
146267 -- set accounting line type info
146268 --
146269 xla_ae_lines_pkg.SetAcctLineType
146270 (p_component_type => l_component_type
146271 ,p_event_type_code => l_event_type_code
146272 ,p_line_definition_owner_code => l_line_definition_owner_code
146273 ,p_line_definition_code => l_line_definition_code
146274 ,p_accounting_line_code => l_component_code
146275 ,p_accounting_line_type_code => l_component_type_code
146276 ,p_accounting_line_appl_id => l_component_appl_id
146277 ,p_amb_context_code => l_amb_context_code
146278 ,p_entity_code => l_entity_code
146279 ,p_event_class_code => l_event_class_code);
146280 --
146281 -- set accounting class
146282 --
146283 xla_ae_lines_pkg.SetAcctClass(
146284 p_accounting_class_code => 'INVENTORY_VALUATION'
146285 , p_ae_header_id => l_ae_header_id
146286 );
146287
146288 --
146289 -- set rounding class
146290 --
146291 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
146292 'INVENTORY_VALUATION';
146293
146294 --
146295 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
146296 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
146297 --
146298 -- bulk performance
146299 --
146300 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
146301
146302 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
146303 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
146304
146305 -- 4955764
146306 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
146307 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
146308
146309 -- 4458381 Public Sector Enh
146310
146311 --
146312 -- set accounting attributes for the line type
146313 --
146314 l_entered_amt_idx := 17;
146315 l_accted_amt_idx := 22;
146316 l_bflow_applied_to_amt_idx := NULL; -- 5132302
146317 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
146318 l_rec_acct_attrs.array_num_value(1) := p_source_79;
146319 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
146320 l_rec_acct_attrs.array_char_value(2) := p_source_80;
146321 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
146322 l_rec_acct_attrs.array_char_value(3) := p_source_81;
146323 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
146324 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
146325 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
146326 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
146327 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
146328 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
146329 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
146330 l_rec_acct_attrs.array_char_value(7) := p_source_85;
146331 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
146332 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
146333 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
146334 l_rec_acct_attrs.array_num_value(9) := p_source_87;
146335 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
146336 l_rec_acct_attrs.array_char_value(10) := p_source_88;
146337 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
146338 l_rec_acct_attrs.array_num_value(11) := p_source_89;
146339 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
146340 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
146341 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
146342 l_rec_acct_attrs.array_num_value(13) := p_source_87;
146343 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
146344 l_rec_acct_attrs.array_char_value(14) := p_source_88;
146345 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
146346 l_rec_acct_attrs.array_num_value(15) := p_source_89;
146347 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
146348 l_rec_acct_attrs.array_char_value(16) := p_source_100;
146349 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
146350 l_rec_acct_attrs.array_num_value(17) := p_source_91;
146351 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
146352 l_rec_acct_attrs.array_char_value(18) := p_source_88;
146353 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
146354 l_rec_acct_attrs.array_date_value(19) := p_source_92;
146355 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
146356 l_rec_acct_attrs.array_num_value(20) := p_source_93;
146357 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
146358 l_rec_acct_attrs.array_char_value(21) := p_source_94;
146359 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
146360 l_rec_acct_attrs.array_num_value(22) := p_source_95;
146361 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
146362 l_rec_acct_attrs.array_num_value(23) := p_source_104;
146363 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
146364 l_rec_acct_attrs.array_num_value(24) := p_source_104;
146365
146366 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
146367 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
146368
146369 ---------------------------------------------------------------------------------------------------------------
146370 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
146371 ---------------------------------------------------------------------------------------------------------------
146372 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
146373
146374 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
146375 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
146376
146377 IF xla_accounting_cache_pkg.GetValueChar
146378 (p_source_code => 'LEDGER_CATEGORY_CODE'
146379 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
146380 AND l_bflow_method_code = 'PRIOR_ENTRY'
146381 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
146382 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
146383 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
146384 )
146385 THEN
146386 xla_ae_lines_pkg.BflowUpgEntry
146387 (p_business_method_code => l_bflow_method_code
146388 ,p_business_class_code => l_bflow_class_code
146389 ,p_balance_type => l_balance_type_code);
146390 ELSE
146391 NULL;
146392 -- No business flow processing for business flow method of NONE.
146393 END IF;
146394
146395 --
146396 -- call analytical criteria
146397 --
146398
146399
146400 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
146401 xla_ae_lines_pkg.SetAnalyticalCriteria(
146402 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
146403 , p_analytical_criterion_owner => 'S'
146404 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
146405 , p_amb_context_code => 'DEFAULT'
146406 , p_balancing_flag => 'Y'
146407
146408 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
146409 , p_analytical_detail_num_1 => NULL
146410 , p_analytical_detail_date_1 => NULL
146411
146412 , p_ae_header_id => l_ae_header_id
146413 )
146414 ;
146415 --
146416
146417 --
146418 -- call description
146419 --
146420
146421 xla_ae_lines_pkg.SetLineDescription(
146422 p_ae_header_id => l_ae_header_id
146423 ,p_description => Description_1 (
146424 p_application_id => p_application_id
146425 , p_ae_header_id => l_ae_header_id
146426 , p_source_1 => p_source_1
146427 , p_source_2 => p_source_2
146428 , p_source_3 => p_source_3
146429 , p_source_4 => p_source_4
146430 , p_source_5 => p_source_5
146431 )
146432 );
146433
146434
146435 --
146436 -- call ADRs
146437 -- Bug 4922099
146438 --
146439 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
146440 (NVL(l_actual_upg_option, 'N') = 'O') OR
146441 (NVL(l_enc_upg_option, 'N') = 'O')
146442 )
146443 THEN
146444 NULL;
146445 --
146446 --
146447
146448 l_ccid := AcctDerRule_28(
146449 p_application_id => p_application_id
146450 , p_ae_header_id => l_ae_header_id
146451 , p_source_15 => p_source_15
146452 , p_source_41 => p_source_41
146453 , p_source_42 => p_source_42
146454 , p_source_43 => p_source_43
146455 , p_source_44 => p_source_44
146456 , p_source_45 => p_source_45
146457 , x_transaction_coa_id => l_adr_transaction_coa_id
146458 , x_accounting_coa_id => l_adr_accounting_coa_id
146459 , x_value_type_code => l_adr_value_type_code
146460 , p_side => 'NA'
146461 );
146462
146463 xla_ae_lines_pkg.set_ccid(
146464 p_code_combination_id => l_ccid
146465 , p_value_type_code => l_adr_value_type_code
146466 , p_transaction_coa_id => l_adr_transaction_coa_id
146467 , p_accounting_coa_id => l_adr_accounting_coa_id
146468 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
146469 , p_adr_type_code => 'S'
146470 , p_component_type => l_component_type
146471 , p_component_code => l_component_code
146472 , p_component_type_code => l_component_type_code
146473 , p_component_appl_id => l_component_appl_id
146474 , p_amb_context_code => l_amb_context_code
146475 , p_side => 'NA'
146476 );
146477
146478
146479 --
146480 --
146481 END IF;
146482 --
146483 -- Bug 4922099
146484 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
146485 (NVL(l_enc_upg_option, 'N') = 'O')
146486 ) AND
146487 (l_bflow_method_code = 'PRIOR_ENTRY')
146488 )
146489 THEN
146490 IF
146491 --
146492 1 = 2
146493 --
146494 THEN
146495 xla_accounting_err_pkg.build_message
146496 (p_appli_s_name => 'XLA'
146497 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
146498 ,p_token_1 => 'LINE_NUMBER'
146499 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
146500 ,p_token_2 => 'LINE_TYPE_NAME'
146501 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
146502 l_component_type
146503 ,l_component_code
146504 ,l_component_type_code
146505 ,l_component_appl_id
146506 ,l_amb_context_code
146507 ,l_entity_code
146508 ,l_event_class_code
146509 )
146510 ,p_token_3 => 'OWNER'
146511 ,p_value_3 => xla_lookups_pkg.get_meaning(
146512 p_lookup_type => 'XLA_OWNER_TYPE'
146513 ,p_lookup_code => l_component_type_code
146514 )
146515 ,p_token_4 => 'PRODUCT_NAME'
146516 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
146517 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
146518 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
146519 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
146520 ,p_ae_header_id => NULL
146521 );
146522
146523 IF (C_LEVEL_ERROR>= g_log_level) THEN
146524 trace
146525 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
146526 ,p_level => C_LEVEL_ERROR
146527 ,p_module => l_log_module);
146528 END IF;
146529 END IF;
146530 END IF;
146531 --
146532 --
146533 ------------------------------------------------------------------------------------------------
146534 -- 4219869 Business Flow
146535 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
146536 -- Prior Entry. Currently, the following code is always generated.
146537 ------------------------------------------------------------------------------------------------
146538 XLA_AE_LINES_PKG.ValidateCurrentLine;
146539
146540 ------------------------------------------------------------------------------------
146541 -- 4219869 Business Flow
146542 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
146543 ------------------------------------------------------------------------------------
146544 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
146545
146546 ----------------------------------------------------------------------------------
146547 -- 4219869 Business Flow
146548 -- Update journal entry status -- Need to generate this within IF <condition>
146549 ----------------------------------------------------------------------------------
146550 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
146551 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
146552 ,p_balance_type_code => l_balance_type_code
146553 );
146554
146555 -------------------------------------------------------------------------------------------
146556 -- 4262811 - Generate the Accrual Reversal lines
146557 -------------------------------------------------------------------------------------------
146558 BEGIN
146559 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
146560 (g_array_event(p_event_id).array_value_num('header_index'));
146561 IF l_acc_rev_flag IS NULL THEN
146562 l_acc_rev_flag := 'N';
146563 END IF;
146564 EXCEPTION
146565 WHEN OTHERS THEN
146566 l_acc_rev_flag := 'N';
146567 END;
146568 --
146569 IF (l_acc_rev_flag = 'Y') THEN
146570
146571 -- 4645092 ------------------------------------------------------------------------------
146572 -- To allow MPA report to determine if it should generate report process
146573 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
146574 ------------------------------------------------------------------------------------------
146575
146576 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
146577 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
146578 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
146579 -- call ADRs
146580 -- Bug 4922099
146581 --
146582 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
146583 (NVL(l_actual_upg_option, 'N') = 'O') OR
146584 (NVL(l_enc_upg_option, 'N') = 'O')
146585 )
146586 THEN
146587 NULL;
146588 --
146589 --
146590
146591 l_ccid := AcctDerRule_28(
146592 p_application_id => p_application_id
146593 , p_ae_header_id => l_ae_header_id
146594 , p_source_15 => p_source_15
146595 , p_source_41 => p_source_41
146596 , p_source_42 => p_source_42
146597 , p_source_43 => p_source_43
146598 , p_source_44 => p_source_44
146599 , p_source_45 => p_source_45
146600 , x_transaction_coa_id => l_adr_transaction_coa_id
146601 , x_accounting_coa_id => l_adr_accounting_coa_id
146602 , x_value_type_code => l_adr_value_type_code
146603 , p_side => 'NA'
146604 );
146605
146606 xla_ae_lines_pkg.set_ccid(
146607 p_code_combination_id => l_ccid
146608 , p_value_type_code => l_adr_value_type_code
146609 , p_transaction_coa_id => l_adr_transaction_coa_id
146610 , p_accounting_coa_id => l_adr_accounting_coa_id
146611 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
146612 , p_adr_type_code => 'S'
146613 , p_component_type => l_component_type
146614 , p_component_code => l_component_code
146615 , p_component_type_code => l_component_type_code
146616 , p_component_appl_id => l_component_appl_id
146617 , p_amb_context_code => l_amb_context_code
146618 , p_side => 'NA'
146619 );
146620
146621
146622 --
146623 --
146624 END IF;
146625
146626 --
146627 -- Update the line information that should be overwritten
146628 --
146629 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
146630 p_header_num => 1);
146631 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
146632
146633 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
146634
146635 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
146636 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
146637 END IF;
146638
146639 --
146640 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
146641 --
146642 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
146643 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
146644 ELSE
146645 ---------------------------------------------------------------------------------------------------
146646 -- 4262811a Switch Sign
146647 ---------------------------------------------------------------------------------------------------
146648 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
146649 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
146650 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
146651 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
146652 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
146653 -- 5132302
146654 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
146655 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
146656
146657 END IF;
146658
146659 -- 4955764
146660 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
146661 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
146662
146663
146664 XLA_AE_LINES_PKG.ValidateCurrentLine;
146665 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
146666
146667 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
146668 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
146669 ,p_balance_type_code => l_balance_type_code);
146670
146671 END IF;
146672
146673 -----------------------------------------------------------------------------------------
146674 -- 4262811 Multiperiod Accounting
146675 -----------------------------------------------------------------------------------------
146676 -- No MPA option is assigned.
146677
146678
146679 END IF;
146680 END IF;
146681 --
146682
146683 --
146684 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
146685 trace
146686 (p_msg => 'END of AcctLineType_275'
146687 ,p_level => C_LEVEL_PROCEDURE
146688 ,p_module => l_log_module);
146689 END IF;
146690 --
146691 EXCEPTION
146692 WHEN xla_exceptions_pkg.application_exception THEN
146693 RAISE;
146694 WHEN OTHERS THEN
146695 xla_exceptions_pkg.raise_message
146696 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_275');
146697 END AcctLineType_275;
146698 --
146699
146700 ---------------------------------------
146701 --
146702 -- PRIVATE FUNCTION
146703 -- AcctLineType_276
146704 --
146705 ---------------------------------------
146706 PROCEDURE AcctLineType_276 (
146707 p_application_id IN NUMBER
146708 ,p_event_id IN NUMBER
146709 ,p_calculate_acctd_flag IN VARCHAR2
146710 ,p_calculate_g_l_flag IN VARCHAR2
146711 ,p_actual_flag IN OUT VARCHAR2
146712 ,p_balance_type_code OUT VARCHAR2
146713 ,p_gain_or_loss_ref OUT VARCHAR2
146714
146715 --TRANSACTION_ID
146716 , p_source_1 IN NUMBER
146717 --Item Concatenated Segments
146718 , p_source_2 IN VARCHAR2
146719 --Transaction Quantity
146720 , p_source_3 IN NUMBER
146721 --Transaction Unit of Measure Code
146722 , p_source_4 IN VARCHAR2
146723 --Inventory Transaction Type Description
146724 , p_source_5 IN VARCHAR2
146725 --Cost Element Name
146726 , p_source_15 IN NUMBER
146727 --Product Line Accounting Category Material Account
146728 , p_source_41 IN NUMBER
146729 --Product Line Accounting Category Material Overhead Account
146730 , p_source_42 IN NUMBER
146731 --Product Line Accounting Category Resource Account
146732 , p_source_43 IN NUMBER
146733 --Product Line Accounting Category Outside Processing Account
146734 , p_source_44 IN NUMBER
146735 --Product Line Accounting Category Overhead Account
146736 , p_source_45 IN NUMBER
146737 --DISTRIBUTION_IDENTIFIER
146738 , p_source_84 IN NUMBER
146739 --Distribution Type
146740 , p_source_85 IN VARCHAR2
146741 , p_source_85_meaning IN VARCHAR2
146742 --Entered Currency Code
146743 , p_source_88 IN VARCHAR2
146744 --Entered Amount
146745 , p_source_91 IN NUMBER
146746 --Currency Conversion Date
146747 , p_source_92 IN DATE
146748 --Currency Conversion Rate
146749 , p_source_93 IN NUMBER
146750 --Currency Conversion Type
146751 , p_source_94 IN VARCHAR2
146752 --Accounted Amount
146753 , p_source_95 IN NUMBER
146754 --Accounting Line Type
146755 , p_source_97 IN NUMBER
146756 --Organization Code
146757 , p_source_108 IN VARCHAR2
146758 )
146759 IS
146760
146761 l_component_type VARCHAR2(80);
146762 l_component_code VARCHAR2(30);
146763 l_component_type_code VARCHAR2(1);
146764 l_component_appl_id INTEGER;
146765 l_amb_context_code VARCHAR2(30);
146766 l_entity_code VARCHAR2(30);
146767 l_event_class_code VARCHAR2(30);
146768 l_ae_header_id NUMBER;
146769 l_event_type_code VARCHAR2(30);
146770 l_line_definition_code VARCHAR2(30);
146771 l_line_definition_owner_code VARCHAR2(1);
146772 --
146773 -- adr variables
146774 l_segment VARCHAR2(30);
146775 l_ccid NUMBER;
146776 l_adr_transaction_coa_id NUMBER;
146777 l_adr_accounting_coa_id NUMBER;
146778 l_adr_flexfield_segment_code VARCHAR2(30);
146779 l_adr_flex_value_set_id NUMBER;
146780 l_adr_value_type_code VARCHAR2(30);
146781 l_adr_value_combination_id NUMBER;
146782 l_adr_value_segment_code VARCHAR2(30);
146783
146784 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
146785 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
146786 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
146787 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
146788
146789 -- 4262811 Variables ------------------------------------------------------------------------------------------
146790 l_entered_amt_idx NUMBER;
146791 l_accted_amt_idx NUMBER;
146792 l_acc_rev_flag VARCHAR2(1);
146793 l_accrual_line_num NUMBER;
146794 l_tmp_amt NUMBER;
146795 l_acc_rev_natural_side_code VARCHAR2(1);
146796
146797 l_num_entries NUMBER;
146798 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
146799 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
146800 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
146801 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
146802 l_recog_line_1 NUMBER;
146803 l_recog_line_2 NUMBER;
146804
146805 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
146806 l_bflow_applied_to_amt NUMBER; -- 5132302
146807 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
146808
146809 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
146810
146811 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
146812 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
146813
146814 ---------------------------------------------------------------------------------------------------------------
146815
146816
146817 --
146818 -- bulk performance
146819 --
146820 l_balance_type_code VARCHAR2(1);
146821 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
146822 l_log_module VARCHAR2(240);
146823
146824 --
146825 -- Upgrade strategy
146826 --
146827 l_actual_upg_option VARCHAR2(1);
146828 l_enc_upg_option VARCHAR2(1);
146829
146830 --
146831 BEGIN
146832 --
146833 IF g_log_enabled THEN
146834 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_276';
146835 END IF;
146836 --
146837 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
146838
146839 trace
146840 (p_msg => 'BEGIN of AcctLineType_276'
146841 ,p_level => C_LEVEL_PROCEDURE
146842 ,p_module => l_log_module);
146843
146844 END IF;
146845 --
146846 l_component_type := 'AMB_JLT';
146847 l_component_code := 'INVENTORY_VALUATION';
146848 l_component_type_code := 'S';
146849 l_component_appl_id := 707;
146850 l_amb_context_code := 'DEFAULT';
146851 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
146852 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
146853 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_TP';
146854 l_line_definition_owner_code := 'S';
146855 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_TP';
146856 --
146857 l_balance_type_code := 'A';
146858 l_segment := NULL;
146859 l_ccid := NULL;
146860 l_adr_transaction_coa_id := NULL;
146861 l_adr_accounting_coa_id := NULL;
146862 l_adr_flexfield_segment_code := NULL;
146863 l_adr_flex_value_set_id := NULL;
146864 l_adr_value_type_code := NULL;
146865 l_adr_value_combination_id := NULL;
146866 l_adr_value_segment_code := NULL;
146867
146868 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
146869 l_bflow_class_code := ''; -- 4219869 Business Flow
146870 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
146871 l_budgetary_control_flag := 'N';
146872
146873 l_bflow_applied_to_amt_idx := NULL; -- 5132302
146874 l_bflow_applied_to_amt := NULL; -- 5132302
146875 l_entered_amt_idx := NULL; -- 4262811
146876 l_accted_amt_idx := NULL; -- 4262811
146877 l_acc_rev_flag := NULL; -- 4262811
146878 l_accrual_line_num := NULL; -- 4262811
146879 l_tmp_amt := NULL; -- 4262811
146880 --
146881
146882 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
146883 l_balance_type_code <> 'B' THEN
146884 IF NVL(p_source_97,9E125) = 1
146885 THEN
146886
146887 --
146888 XLA_AE_LINES_PKG.SetNewLine;
146889
146890 p_balance_type_code := l_balance_type_code;
146891 -- set the flag so later we will know whether the gain loss line needs to be created
146892
146893 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
146894 p_actual_flag :='A';
146895 END IF;
146896
146897 --
146898 -- bulk performance
146899 --
146900 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
146901 p_header_num => 0); -- 4262811
146902 --
146903 -- set accounting line options
146904 --
146905 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
146906 p_natural_side_code => 'D'
146907 , p_gain_or_loss_flag => 'N'
146908 , p_gl_transfer_mode_code => 'S'
146909 , p_acct_entry_type_code => 'A'
146910 , p_switch_side_flag => 'Y'
146911 , p_merge_duplicate_code => 'N'
146912 );
146913 --
146914 l_acc_rev_natural_side_code := 'C'; -- 4262811
146915 --
146916 --
146917 -- set accounting line type info
146918 --
146919 xla_ae_lines_pkg.SetAcctLineType
146920 (p_component_type => l_component_type
146921 ,p_event_type_code => l_event_type_code
146922 ,p_line_definition_owner_code => l_line_definition_owner_code
146923 ,p_line_definition_code => l_line_definition_code
146924 ,p_accounting_line_code => l_component_code
146925 ,p_accounting_line_type_code => l_component_type_code
146926 ,p_accounting_line_appl_id => l_component_appl_id
146927 ,p_amb_context_code => l_amb_context_code
146928 ,p_entity_code => l_entity_code
146929 ,p_event_class_code => l_event_class_code);
146930 --
146931 -- set accounting class
146932 --
146933 xla_ae_lines_pkg.SetAcctClass(
146934 p_accounting_class_code => 'INVENTORY_VALUATION'
146935 , p_ae_header_id => l_ae_header_id
146936 );
146937
146938 --
146939 -- set rounding class
146940 --
146941 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
146942 'INVENTORY_VALUATION';
146943
146944 --
146945 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
146946 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
146947 --
146948 -- bulk performance
146949 --
146950 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
146951
146952 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
146953 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
146954
146955 -- 4955764
146956 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
146957 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
146958
146959 -- 4458381 Public Sector Enh
146960
146961 --
146962 -- set accounting attributes for the line type
146963 --
146964 l_entered_amt_idx := 3;
146965 l_accted_amt_idx := 8;
146966 l_bflow_applied_to_amt_idx := NULL; -- 5132302
146967 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
146968 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
146969 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
146970 l_rec_acct_attrs.array_char_value(2) := p_source_85;
146971 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
146972 l_rec_acct_attrs.array_num_value(3) := p_source_91;
146973 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
146974 l_rec_acct_attrs.array_char_value(4) := p_source_88;
146975 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
146976 l_rec_acct_attrs.array_date_value(5) := p_source_92;
146977 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
146978 l_rec_acct_attrs.array_num_value(6) := p_source_93;
146979 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
146980 l_rec_acct_attrs.array_char_value(7) := p_source_94;
146981 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
146982 l_rec_acct_attrs.array_num_value(8) := p_source_95;
146983
146984 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
146985 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
146986
146987 ---------------------------------------------------------------------------------------------------------------
146988 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
146989 ---------------------------------------------------------------------------------------------------------------
146990 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
146991
146992 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
146993 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
146994
146995 IF xla_accounting_cache_pkg.GetValueChar
146996 (p_source_code => 'LEDGER_CATEGORY_CODE'
146997 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
146998 AND l_bflow_method_code = 'PRIOR_ENTRY'
146999 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
147000 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
147001 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
147002 )
147003 THEN
147004 xla_ae_lines_pkg.BflowUpgEntry
147005 (p_business_method_code => l_bflow_method_code
147006 ,p_business_class_code => l_bflow_class_code
147007 ,p_balance_type => l_balance_type_code);
147008 ELSE
147009 NULL;
147010 -- No business flow processing for business flow method of NONE.
147011 END IF;
147012
147013 --
147014 -- call analytical criteria
147015 --
147016
147017
147018 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
147019 xla_ae_lines_pkg.SetAnalyticalCriteria(
147020 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
147021 , p_analytical_criterion_owner => 'S'
147022 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
147023 , p_amb_context_code => 'DEFAULT'
147024 , p_balancing_flag => 'Y'
147025
147026 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
147027 , p_analytical_detail_num_1 => NULL
147028 , p_analytical_detail_date_1 => NULL
147029
147030 , p_ae_header_id => l_ae_header_id
147031 )
147032 ;
147033 --
147034
147035 --
147036 -- call description
147037 --
147038
147039 xla_ae_lines_pkg.SetLineDescription(
147040 p_ae_header_id => l_ae_header_id
147041 ,p_description => Description_1 (
147042 p_application_id => p_application_id
147043 , p_ae_header_id => l_ae_header_id
147044 , p_source_1 => p_source_1
147045 , p_source_2 => p_source_2
147046 , p_source_3 => p_source_3
147047 , p_source_4 => p_source_4
147048 , p_source_5 => p_source_5
147049 )
147050 );
147051
147052
147053 --
147054 -- call ADRs
147055 -- Bug 4922099
147056 --
147057 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
147058 (NVL(l_actual_upg_option, 'N') = 'O') OR
147059 (NVL(l_enc_upg_option, 'N') = 'O')
147060 )
147061 THEN
147062 NULL;
147063 --
147064 --
147065
147066 l_ccid := AcctDerRule_28(
147067 p_application_id => p_application_id
147068 , p_ae_header_id => l_ae_header_id
147069 , p_source_15 => p_source_15
147070 , p_source_41 => p_source_41
147071 , p_source_42 => p_source_42
147072 , p_source_43 => p_source_43
147073 , p_source_44 => p_source_44
147074 , p_source_45 => p_source_45
147075 , x_transaction_coa_id => l_adr_transaction_coa_id
147076 , x_accounting_coa_id => l_adr_accounting_coa_id
147077 , x_value_type_code => l_adr_value_type_code
147078 , p_side => 'NA'
147079 );
147080
147081 xla_ae_lines_pkg.set_ccid(
147082 p_code_combination_id => l_ccid
147083 , p_value_type_code => l_adr_value_type_code
147084 , p_transaction_coa_id => l_adr_transaction_coa_id
147085 , p_accounting_coa_id => l_adr_accounting_coa_id
147086 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
147087 , p_adr_type_code => 'S'
147088 , p_component_type => l_component_type
147089 , p_component_code => l_component_code
147090 , p_component_type_code => l_component_type_code
147091 , p_component_appl_id => l_component_appl_id
147092 , p_amb_context_code => l_amb_context_code
147093 , p_side => 'NA'
147094 );
147095
147096
147097 --
147098 --
147099 END IF;
147100 --
147101 -- Bug 4922099
147102 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
147103 (NVL(l_enc_upg_option, 'N') = 'O')
147104 ) AND
147105 (l_bflow_method_code = 'PRIOR_ENTRY')
147106 )
147107 THEN
147108 IF
147109 --
147110 1 = 2
147111 --
147112 THEN
147113 xla_accounting_err_pkg.build_message
147114 (p_appli_s_name => 'XLA'
147115 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
147116 ,p_token_1 => 'LINE_NUMBER'
147117 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
147118 ,p_token_2 => 'LINE_TYPE_NAME'
147119 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
147120 l_component_type
147121 ,l_component_code
147122 ,l_component_type_code
147123 ,l_component_appl_id
147124 ,l_amb_context_code
147125 ,l_entity_code
147126 ,l_event_class_code
147127 )
147128 ,p_token_3 => 'OWNER'
147129 ,p_value_3 => xla_lookups_pkg.get_meaning(
147130 p_lookup_type => 'XLA_OWNER_TYPE'
147131 ,p_lookup_code => l_component_type_code
147132 )
147133 ,p_token_4 => 'PRODUCT_NAME'
147134 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
147135 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
147136 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
147137 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
147138 ,p_ae_header_id => NULL
147139 );
147140
147141 IF (C_LEVEL_ERROR>= g_log_level) THEN
147142 trace
147143 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
147144 ,p_level => C_LEVEL_ERROR
147145 ,p_module => l_log_module);
147146 END IF;
147147 END IF;
147148 END IF;
147149 --
147150 --
147151 ------------------------------------------------------------------------------------------------
147152 -- 4219869 Business Flow
147153 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
147154 -- Prior Entry. Currently, the following code is always generated.
147155 ------------------------------------------------------------------------------------------------
147156 XLA_AE_LINES_PKG.ValidateCurrentLine;
147157
147158 ------------------------------------------------------------------------------------
147159 -- 4219869 Business Flow
147160 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
147161 ------------------------------------------------------------------------------------
147162 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
147163
147164 ----------------------------------------------------------------------------------
147165 -- 4219869 Business Flow
147166 -- Update journal entry status -- Need to generate this within IF <condition>
147167 ----------------------------------------------------------------------------------
147168 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
147169 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
147170 ,p_balance_type_code => l_balance_type_code
147171 );
147172
147173 -------------------------------------------------------------------------------------------
147174 -- 4262811 - Generate the Accrual Reversal lines
147175 -------------------------------------------------------------------------------------------
147176 BEGIN
147177 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
147178 (g_array_event(p_event_id).array_value_num('header_index'));
147179 IF l_acc_rev_flag IS NULL THEN
147180 l_acc_rev_flag := 'N';
147181 END IF;
147182 EXCEPTION
147183 WHEN OTHERS THEN
147184 l_acc_rev_flag := 'N';
147185 END;
147186 --
147187 IF (l_acc_rev_flag = 'Y') THEN
147188
147189 -- 4645092 ------------------------------------------------------------------------------
147190 -- To allow MPA report to determine if it should generate report process
147191 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
147192 ------------------------------------------------------------------------------------------
147193
147194 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
147195 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
147196 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
147197 -- call ADRs
147198 -- Bug 4922099
147199 --
147200 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
147201 (NVL(l_actual_upg_option, 'N') = 'O') OR
147202 (NVL(l_enc_upg_option, 'N') = 'O')
147203 )
147204 THEN
147205 NULL;
147206 --
147207 --
147208
147209 l_ccid := AcctDerRule_28(
147210 p_application_id => p_application_id
147211 , p_ae_header_id => l_ae_header_id
147212 , p_source_15 => p_source_15
147213 , p_source_41 => p_source_41
147214 , p_source_42 => p_source_42
147215 , p_source_43 => p_source_43
147216 , p_source_44 => p_source_44
147217 , p_source_45 => p_source_45
147218 , x_transaction_coa_id => l_adr_transaction_coa_id
147219 , x_accounting_coa_id => l_adr_accounting_coa_id
147220 , x_value_type_code => l_adr_value_type_code
147221 , p_side => 'NA'
147222 );
147223
147224 xla_ae_lines_pkg.set_ccid(
147225 p_code_combination_id => l_ccid
147226 , p_value_type_code => l_adr_value_type_code
147227 , p_transaction_coa_id => l_adr_transaction_coa_id
147228 , p_accounting_coa_id => l_adr_accounting_coa_id
147229 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
147230 , p_adr_type_code => 'S'
147231 , p_component_type => l_component_type
147232 , p_component_code => l_component_code
147233 , p_component_type_code => l_component_type_code
147234 , p_component_appl_id => l_component_appl_id
147235 , p_amb_context_code => l_amb_context_code
147236 , p_side => 'NA'
147237 );
147238
147239
147240 --
147241 --
147242 END IF;
147243
147244 --
147245 -- Update the line information that should be overwritten
147246 --
147247 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
147248 p_header_num => 1);
147249 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
147250
147251 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
147252
147253 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
147254 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
147255 END IF;
147256
147257 --
147258 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
147259 --
147260 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
147261 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
147262 ELSE
147263 ---------------------------------------------------------------------------------------------------
147264 -- 4262811a Switch Sign
147265 ---------------------------------------------------------------------------------------------------
147266 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
147267 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
147268 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147269 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
147270 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147271 -- 5132302
147272 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
147273 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147274
147275 END IF;
147276
147277 -- 4955764
147278 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
147279 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
147280
147281
147282 XLA_AE_LINES_PKG.ValidateCurrentLine;
147283 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
147284
147285 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
147286 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
147287 ,p_balance_type_code => l_balance_type_code);
147288
147289 END IF;
147290
147291 -----------------------------------------------------------------------------------------
147292 -- 4262811 Multiperiod Accounting
147293 -----------------------------------------------------------------------------------------
147294 -- No MPA option is assigned.
147295
147296
147297 END IF;
147298 END IF;
147299 --
147300
147301 --
147302 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
147303 trace
147304 (p_msg => 'END of AcctLineType_276'
147305 ,p_level => C_LEVEL_PROCEDURE
147306 ,p_module => l_log_module);
147307 END IF;
147308 --
147309 EXCEPTION
147310 WHEN xla_exceptions_pkg.application_exception THEN
147311 RAISE;
147312 WHEN OTHERS THEN
147313 xla_exceptions_pkg.raise_message
147314 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_276');
147315 END AcctLineType_276;
147316 --
147317
147318 ---------------------------------------
147319 --
147320 -- PRIVATE FUNCTION
147321 -- AcctLineType_277
147322 --
147323 ---------------------------------------
147324 PROCEDURE AcctLineType_277 (
147325 p_application_id IN NUMBER
147326 ,p_event_id IN NUMBER
147327 ,p_calculate_acctd_flag IN VARCHAR2
147328 ,p_calculate_g_l_flag IN VARCHAR2
147329 ,p_actual_flag IN OUT VARCHAR2
147330 ,p_balance_type_code OUT VARCHAR2
147331 ,p_gain_or_loss_ref OUT VARCHAR2
147332
147333 --TRANSACTION_ID
147334 , p_source_1 IN NUMBER
147335 --Item Concatenated Segments
147336 , p_source_2 IN VARCHAR2
147337 --Transaction Quantity
147338 , p_source_3 IN NUMBER
147339 --Transaction Unit of Measure Code
147340 , p_source_4 IN VARCHAR2
147341 --Inventory Transaction Type Description
147342 , p_source_5 IN VARCHAR2
147343 --Cost Element Name
147344 , p_source_15 IN NUMBER
147345 --Cost Group Identifier
147346 , p_source_26 IN NUMBER
147347 --INV Header Transfer Cost Group ID
147348 , p_source_27 IN NUMBER
147349 --INV Header Cost Group ID
147350 , p_source_28 IN NUMBER
147351 --Subinventory Name
147352 , p_source_29 IN VARCHAR2
147353 --INV Header Transfer Subinventory
147354 , p_source_31 IN VARCHAR2
147355 --Product Line Accounting Category Material Account
147356 , p_source_41 IN NUMBER
147357 --Product Line Accounting Category Material Overhead Account
147358 , p_source_42 IN NUMBER
147359 --Product Line Accounting Category Resource Account
147360 , p_source_43 IN NUMBER
147361 --Product Line Accounting Category Outside Processing Account
147362 , p_source_44 IN NUMBER
147363 --Product Line Accounting Category Overhead Account
147364 , p_source_45 IN NUMBER
147365 --Transfer to Subinventory or Cost Group category material account
147366 , p_source_48 IN NUMBER
147367 --Transfer to Subinventory or Cost Group category material overhead account
147368 , p_source_49 IN NUMBER
147369 --Transfer to Subinventory or Cost Group category resource account
147370 , p_source_50 IN NUMBER
147371 --Transfer to Subinventory or Cost Group category outside processing account
147372 , p_source_51 IN NUMBER
147373 --Transfer to Subinventory or Cost Group category overhead account
147374 , p_source_52 IN NUMBER
147375 --DISTRIBUTION_IDENTIFIER
147376 , p_source_84 IN NUMBER
147377 --Distribution Type
147378 , p_source_85 IN VARCHAR2
147379 , p_source_85_meaning IN VARCHAR2
147380 --Entered Currency Code
147381 , p_source_88 IN VARCHAR2
147382 --Entered Amount
147383 , p_source_91 IN NUMBER
147384 --Currency Conversion Date
147385 , p_source_92 IN DATE
147386 --Currency Conversion Rate
147387 , p_source_93 IN NUMBER
147388 --Currency Conversion Type
147389 , p_source_94 IN VARCHAR2
147390 --Accounted Amount
147391 , p_source_95 IN NUMBER
147392 --Accounting Line Type
147393 , p_source_97 IN NUMBER
147394 --Organization Code
147395 , p_source_108 IN VARCHAR2
147396 )
147397 IS
147398
147399 l_component_type VARCHAR2(80);
147400 l_component_code VARCHAR2(30);
147401 l_component_type_code VARCHAR2(1);
147402 l_component_appl_id INTEGER;
147403 l_amb_context_code VARCHAR2(30);
147404 l_entity_code VARCHAR2(30);
147405 l_event_class_code VARCHAR2(30);
147406 l_ae_header_id NUMBER;
147407 l_event_type_code VARCHAR2(30);
147408 l_line_definition_code VARCHAR2(30);
147409 l_line_definition_owner_code VARCHAR2(1);
147410 --
147411 -- adr variables
147412 l_segment VARCHAR2(30);
147413 l_ccid NUMBER;
147414 l_adr_transaction_coa_id NUMBER;
147415 l_adr_accounting_coa_id NUMBER;
147416 l_adr_flexfield_segment_code VARCHAR2(30);
147417 l_adr_flex_value_set_id NUMBER;
147418 l_adr_value_type_code VARCHAR2(30);
147419 l_adr_value_combination_id NUMBER;
147420 l_adr_value_segment_code VARCHAR2(30);
147421
147422 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
147423 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
147424 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
147425 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
147426
147427 -- 4262811 Variables ------------------------------------------------------------------------------------------
147428 l_entered_amt_idx NUMBER;
147429 l_accted_amt_idx NUMBER;
147430 l_acc_rev_flag VARCHAR2(1);
147431 l_accrual_line_num NUMBER;
147432 l_tmp_amt NUMBER;
147433 l_acc_rev_natural_side_code VARCHAR2(1);
147434
147435 l_num_entries NUMBER;
147436 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
147437 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
147438 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
147439 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
147440 l_recog_line_1 NUMBER;
147441 l_recog_line_2 NUMBER;
147442
147443 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
147444 l_bflow_applied_to_amt NUMBER; -- 5132302
147445 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
147446
147447 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
147448
147449 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
147450 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
147451
147452 ---------------------------------------------------------------------------------------------------------------
147453
147454
147455 --
147456 -- bulk performance
147457 --
147458 l_balance_type_code VARCHAR2(1);
147459 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
147460 l_log_module VARCHAR2(240);
147461
147462 --
147463 -- Upgrade strategy
147464 --
147465 l_actual_upg_option VARCHAR2(1);
147466 l_enc_upg_option VARCHAR2(1);
147467
147468 --
147469 BEGIN
147470 --
147471 IF g_log_enabled THEN
147472 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_277';
147473 END IF;
147474 --
147475 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
147476
147477 trace
147478 (p_msg => 'BEGIN of AcctLineType_277'
147479 ,p_level => C_LEVEL_PROCEDURE
147480 ,p_module => l_log_module);
147481
147482 END IF;
147483 --
147484 l_component_type := 'AMB_JLT';
147485 l_component_code := 'INVENTORY_VALUATION';
147486 l_component_type_code := 'S';
147487 l_component_appl_id := 707;
147488 l_amb_context_code := 'DEFAULT';
147489 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
147490 l_event_class_code := 'INTRAORG_TXFR';
147491 l_event_type_code := 'INTRAORG_TXFR_ALL';
147492 l_line_definition_owner_code := 'S';
147493 l_line_definition_code := 'PI_INTRAORG_TXFR';
147494 --
147495 l_balance_type_code := 'A';
147496 l_segment := NULL;
147497 l_ccid := NULL;
147498 l_adr_transaction_coa_id := NULL;
147499 l_adr_accounting_coa_id := NULL;
147500 l_adr_flexfield_segment_code := NULL;
147501 l_adr_flex_value_set_id := NULL;
147502 l_adr_value_type_code := NULL;
147503 l_adr_value_combination_id := NULL;
147504 l_adr_value_segment_code := NULL;
147505
147506 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
147507 l_bflow_class_code := ''; -- 4219869 Business Flow
147508 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
147509 l_budgetary_control_flag := 'N';
147510
147511 l_bflow_applied_to_amt_idx := NULL; -- 5132302
147512 l_bflow_applied_to_amt := NULL; -- 5132302
147513 l_entered_amt_idx := NULL; -- 4262811
147514 l_accted_amt_idx := NULL; -- 4262811
147515 l_acc_rev_flag := NULL; -- 4262811
147516 l_accrual_line_num := NULL; -- 4262811
147517 l_tmp_amt := NULL; -- 4262811
147518 --
147519
147520 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
147521 l_balance_type_code <> 'B' THEN
147522 IF NVL(p_source_97,9E125) = 1
147523 THEN
147524
147525 --
147526 XLA_AE_LINES_PKG.SetNewLine;
147527
147528 p_balance_type_code := l_balance_type_code;
147529 -- set the flag so later we will know whether the gain loss line needs to be created
147530
147531 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
147532 p_actual_flag :='A';
147533 END IF;
147534
147535 --
147536 -- bulk performance
147537 --
147538 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
147539 p_header_num => 0); -- 4262811
147540 --
147541 -- set accounting line options
147542 --
147543 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
147544 p_natural_side_code => 'D'
147545 , p_gain_or_loss_flag => 'N'
147546 , p_gl_transfer_mode_code => 'S'
147547 , p_acct_entry_type_code => 'A'
147548 , p_switch_side_flag => 'Y'
147549 , p_merge_duplicate_code => 'N'
147550 );
147551 --
147552 l_acc_rev_natural_side_code := 'C'; -- 4262811
147553 --
147554 --
147555 -- set accounting line type info
147556 --
147557 xla_ae_lines_pkg.SetAcctLineType
147558 (p_component_type => l_component_type
147559 ,p_event_type_code => l_event_type_code
147560 ,p_line_definition_owner_code => l_line_definition_owner_code
147561 ,p_line_definition_code => l_line_definition_code
147562 ,p_accounting_line_code => l_component_code
147563 ,p_accounting_line_type_code => l_component_type_code
147564 ,p_accounting_line_appl_id => l_component_appl_id
147565 ,p_amb_context_code => l_amb_context_code
147566 ,p_entity_code => l_entity_code
147567 ,p_event_class_code => l_event_class_code);
147568 --
147569 -- set accounting class
147570 --
147571 xla_ae_lines_pkg.SetAcctClass(
147572 p_accounting_class_code => 'INVENTORY_VALUATION'
147573 , p_ae_header_id => l_ae_header_id
147574 );
147575
147576 --
147577 -- set rounding class
147578 --
147579 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
147580 'INVENTORY_VALUATION';
147581
147582 --
147583 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
147584 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
147585 --
147586 -- bulk performance
147587 --
147588 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
147589
147590 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
147591 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
147592
147593 -- 4955764
147594 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
147595 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
147596
147597 -- 4458381 Public Sector Enh
147598
147599 --
147600 -- set accounting attributes for the line type
147601 --
147602 l_entered_amt_idx := 3;
147603 l_accted_amt_idx := 8;
147604 l_bflow_applied_to_amt_idx := NULL; -- 5132302
147605 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
147606 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
147607 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
147608 l_rec_acct_attrs.array_char_value(2) := p_source_85;
147609 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
147610 l_rec_acct_attrs.array_num_value(3) := p_source_91;
147611 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
147612 l_rec_acct_attrs.array_char_value(4) := p_source_88;
147613 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
147614 l_rec_acct_attrs.array_date_value(5) := p_source_92;
147615 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
147616 l_rec_acct_attrs.array_num_value(6) := p_source_93;
147617 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
147618 l_rec_acct_attrs.array_char_value(7) := p_source_94;
147619 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
147620 l_rec_acct_attrs.array_num_value(8) := p_source_95;
147621
147622 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
147623 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
147624
147625 ---------------------------------------------------------------------------------------------------------------
147626 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
147627 ---------------------------------------------------------------------------------------------------------------
147628 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
147629
147630 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
147631 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
147632
147633 IF xla_accounting_cache_pkg.GetValueChar
147634 (p_source_code => 'LEDGER_CATEGORY_CODE'
147635 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
147636 AND l_bflow_method_code = 'PRIOR_ENTRY'
147637 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
147638 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
147639 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
147640 )
147641 THEN
147642 xla_ae_lines_pkg.BflowUpgEntry
147643 (p_business_method_code => l_bflow_method_code
147644 ,p_business_class_code => l_bflow_class_code
147645 ,p_balance_type => l_balance_type_code);
147646 ELSE
147647 NULL;
147648 -- No business flow processing for business flow method of NONE.
147649 END IF;
147650
147651 --
147652 -- call analytical criteria
147653 --
147654
147655
147656 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
147657 xla_ae_lines_pkg.SetAnalyticalCriteria(
147658 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
147659 , p_analytical_criterion_owner => 'S'
147660 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
147661 , p_amb_context_code => 'DEFAULT'
147662 , p_balancing_flag => 'Y'
147663
147664 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
147665 , p_analytical_detail_num_1 => NULL
147666 , p_analytical_detail_date_1 => NULL
147667
147668 , p_ae_header_id => l_ae_header_id
147669 )
147670 ;
147671 --
147672
147673 --
147674 -- call description
147675 --
147676
147677 xla_ae_lines_pkg.SetLineDescription(
147678 p_ae_header_id => l_ae_header_id
147679 ,p_description => Description_1 (
147680 p_application_id => p_application_id
147681 , p_ae_header_id => l_ae_header_id
147682 , p_source_1 => p_source_1
147683 , p_source_2 => p_source_2
147684 , p_source_3 => p_source_3
147685 , p_source_4 => p_source_4
147686 , p_source_5 => p_source_5
147687 )
147688 );
147689
147690
147691 --
147692 -- call ADRs
147693 -- Bug 4922099
147694 --
147695 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
147696 (NVL(l_actual_upg_option, 'N') = 'O') OR
147697 (NVL(l_enc_upg_option, 'N') = 'O')
147698 )
147699 THEN
147700 NULL;
147701 --
147702 --
147703
147704 l_ccid := AcctDerRule_29(
147705 p_application_id => p_application_id
147706 , p_ae_header_id => l_ae_header_id
147707 , p_source_15 => p_source_15
147708 , p_source_26 => p_source_26
147709 , p_source_27 => p_source_27
147710 , p_source_28 => p_source_28
147711 , p_source_29 => p_source_29
147712 , p_source_31 => p_source_31
147713 , p_source_41 => p_source_41
147714 , p_source_42 => p_source_42
147715 , p_source_43 => p_source_43
147716 , p_source_44 => p_source_44
147717 , p_source_45 => p_source_45
147718 , p_source_48 => p_source_48
147719 , p_source_49 => p_source_49
147720 , p_source_50 => p_source_50
147721 , p_source_51 => p_source_51
147722 , p_source_52 => p_source_52
147723 , x_transaction_coa_id => l_adr_transaction_coa_id
147724 , x_accounting_coa_id => l_adr_accounting_coa_id
147725 , x_value_type_code => l_adr_value_type_code
147726 , p_side => 'NA'
147727 );
147728
147729 xla_ae_lines_pkg.set_ccid(
147730 p_code_combination_id => l_ccid
147731 , p_value_type_code => l_adr_value_type_code
147732 , p_transaction_coa_id => l_adr_transaction_coa_id
147733 , p_accounting_coa_id => l_adr_accounting_coa_id
147734 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
147735 , p_adr_type_code => 'S'
147736 , p_component_type => l_component_type
147737 , p_component_code => l_component_code
147738 , p_component_type_code => l_component_type_code
147739 , p_component_appl_id => l_component_appl_id
147740 , p_amb_context_code => l_amb_context_code
147741 , p_side => 'NA'
147742 );
147743
147744
147745 --
147746 --
147747 END IF;
147748 --
147749 -- Bug 4922099
147750 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
147751 (NVL(l_enc_upg_option, 'N') = 'O')
147752 ) AND
147753 (l_bflow_method_code = 'PRIOR_ENTRY')
147754 )
147755 THEN
147756 IF
147757 --
147758 1 = 2
147759 --
147760 THEN
147761 xla_accounting_err_pkg.build_message
147762 (p_appli_s_name => 'XLA'
147763 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
147764 ,p_token_1 => 'LINE_NUMBER'
147765 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
147766 ,p_token_2 => 'LINE_TYPE_NAME'
147767 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
147768 l_component_type
147769 ,l_component_code
147770 ,l_component_type_code
147771 ,l_component_appl_id
147772 ,l_amb_context_code
147773 ,l_entity_code
147774 ,l_event_class_code
147775 )
147776 ,p_token_3 => 'OWNER'
147777 ,p_value_3 => xla_lookups_pkg.get_meaning(
147778 p_lookup_type => 'XLA_OWNER_TYPE'
147779 ,p_lookup_code => l_component_type_code
147780 )
147781 ,p_token_4 => 'PRODUCT_NAME'
147782 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
147783 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
147784 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
147785 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
147786 ,p_ae_header_id => NULL
147787 );
147788
147789 IF (C_LEVEL_ERROR>= g_log_level) THEN
147790 trace
147791 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
147792 ,p_level => C_LEVEL_ERROR
147793 ,p_module => l_log_module);
147794 END IF;
147795 END IF;
147796 END IF;
147797 --
147798 --
147799 ------------------------------------------------------------------------------------------------
147800 -- 4219869 Business Flow
147801 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
147802 -- Prior Entry. Currently, the following code is always generated.
147803 ------------------------------------------------------------------------------------------------
147804 XLA_AE_LINES_PKG.ValidateCurrentLine;
147805
147806 ------------------------------------------------------------------------------------
147807 -- 4219869 Business Flow
147808 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
147809 ------------------------------------------------------------------------------------
147810 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
147811
147812 ----------------------------------------------------------------------------------
147813 -- 4219869 Business Flow
147814 -- Update journal entry status -- Need to generate this within IF <condition>
147815 ----------------------------------------------------------------------------------
147816 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
147817 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
147818 ,p_balance_type_code => l_balance_type_code
147819 );
147820
147821 -------------------------------------------------------------------------------------------
147822 -- 4262811 - Generate the Accrual Reversal lines
147823 -------------------------------------------------------------------------------------------
147824 BEGIN
147825 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
147826 (g_array_event(p_event_id).array_value_num('header_index'));
147827 IF l_acc_rev_flag IS NULL THEN
147828 l_acc_rev_flag := 'N';
147829 END IF;
147830 EXCEPTION
147831 WHEN OTHERS THEN
147832 l_acc_rev_flag := 'N';
147833 END;
147834 --
147835 IF (l_acc_rev_flag = 'Y') THEN
147836
147837 -- 4645092 ------------------------------------------------------------------------------
147838 -- To allow MPA report to determine if it should generate report process
147839 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
147840 ------------------------------------------------------------------------------------------
147841
147842 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
147843 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
147844 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
147845 -- call ADRs
147846 -- Bug 4922099
147847 --
147848 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
147849 (NVL(l_actual_upg_option, 'N') = 'O') OR
147850 (NVL(l_enc_upg_option, 'N') = 'O')
147851 )
147852 THEN
147853 NULL;
147854 --
147855 --
147856
147857 l_ccid := AcctDerRule_29(
147858 p_application_id => p_application_id
147859 , p_ae_header_id => l_ae_header_id
147860 , p_source_15 => p_source_15
147861 , p_source_26 => p_source_26
147862 , p_source_27 => p_source_27
147863 , p_source_28 => p_source_28
147864 , p_source_29 => p_source_29
147865 , p_source_31 => p_source_31
147866 , p_source_41 => p_source_41
147867 , p_source_42 => p_source_42
147868 , p_source_43 => p_source_43
147869 , p_source_44 => p_source_44
147870 , p_source_45 => p_source_45
147871 , p_source_48 => p_source_48
147872 , p_source_49 => p_source_49
147873 , p_source_50 => p_source_50
147874 , p_source_51 => p_source_51
147875 , p_source_52 => p_source_52
147876 , x_transaction_coa_id => l_adr_transaction_coa_id
147877 , x_accounting_coa_id => l_adr_accounting_coa_id
147878 , x_value_type_code => l_adr_value_type_code
147879 , p_side => 'NA'
147880 );
147881
147882 xla_ae_lines_pkg.set_ccid(
147883 p_code_combination_id => l_ccid
147884 , p_value_type_code => l_adr_value_type_code
147885 , p_transaction_coa_id => l_adr_transaction_coa_id
147886 , p_accounting_coa_id => l_adr_accounting_coa_id
147887 , p_adr_code => 'PI_INVENTORY_ACCOUNT_ADR'
147888 , p_adr_type_code => 'S'
147889 , p_component_type => l_component_type
147890 , p_component_code => l_component_code
147891 , p_component_type_code => l_component_type_code
147892 , p_component_appl_id => l_component_appl_id
147893 , p_amb_context_code => l_amb_context_code
147894 , p_side => 'NA'
147895 );
147896
147897
147898 --
147899 --
147900 END IF;
147901
147902 --
147903 -- Update the line information that should be overwritten
147904 --
147905 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
147906 p_header_num => 1);
147907 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
147908
147909 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
147910
147911 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
147912 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
147913 END IF;
147914
147915 --
147916 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
147917 --
147918 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
147919 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
147920 ELSE
147921 ---------------------------------------------------------------------------------------------------
147922 -- 4262811a Switch Sign
147923 ---------------------------------------------------------------------------------------------------
147924 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
147925 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
147926 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147927 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
147928 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147929 -- 5132302
147930 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
147931 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
147932
147933 END IF;
147934
147935 -- 4955764
147936 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
147937 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
147938
147939
147940 XLA_AE_LINES_PKG.ValidateCurrentLine;
147941 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
147942
147943 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
147944 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
147945 ,p_balance_type_code => l_balance_type_code);
147946
147947 END IF;
147948
147949 -----------------------------------------------------------------------------------------
147950 -- 4262811 Multiperiod Accounting
147951 -----------------------------------------------------------------------------------------
147952 -- No MPA option is assigned.
147953
147954
147955 END IF;
147956 END IF;
147957 --
147958
147959 --
147960 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
147961 trace
147962 (p_msg => 'END of AcctLineType_277'
147963 ,p_level => C_LEVEL_PROCEDURE
147964 ,p_module => l_log_module);
147965 END IF;
147966 --
147967 EXCEPTION
147968 WHEN xla_exceptions_pkg.application_exception THEN
147969 RAISE;
147970 WHEN OTHERS THEN
147971 xla_exceptions_pkg.raise_message
147972 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_277');
147973 END AcctLineType_277;
147974 --
147975
147976 ---------------------------------------
147977 --
147978 -- PRIVATE FUNCTION
147979 -- AcctLineType_278
147980 --
147981 ---------------------------------------
147982 PROCEDURE AcctLineType_278 (
147983 p_application_id IN NUMBER
147984 ,p_event_id IN NUMBER
147985 ,p_calculate_acctd_flag IN VARCHAR2
147986 ,p_calculate_g_l_flag IN VARCHAR2
147987 ,p_actual_flag IN OUT VARCHAR2
147988 ,p_balance_type_code OUT VARCHAR2
147989 ,p_gain_or_loss_ref OUT VARCHAR2
147990
147991 --TRANSACTION_ID
147992 , p_source_1 IN NUMBER
147993 --Item Concatenated Segments
147994 , p_source_2 IN VARCHAR2
147995 --Transaction Quantity
147996 , p_source_3 IN NUMBER
147997 --Transaction Unit of Measure Code
147998 , p_source_4 IN VARCHAR2
147999 --Inventory Transaction Type Description
148000 , p_source_5 IN VARCHAR2
148001 --Cost Element Name
148002 , p_source_15 IN NUMBER
148003 --Product Line Accounting Category Material Account
148004 , p_source_41 IN NUMBER
148005 --Product Line Accounting Category Material Overhead Account
148006 , p_source_42 IN NUMBER
148007 --Product Line Accounting Category Resource Account
148008 , p_source_43 IN NUMBER
148009 --Product Line Accounting Category Outside Processing Account
148010 , p_source_44 IN NUMBER
148011 --Product Line Accounting Category Overhead Account
148012 , p_source_45 IN NUMBER
148013 --DISTRIBUTION_IDENTIFIER
148014 , p_source_84 IN NUMBER
148015 --Distribution Type
148016 , p_source_85 IN VARCHAR2
148017 , p_source_85_meaning IN VARCHAR2
148018 --Entered Currency Code
148019 , p_source_88 IN VARCHAR2
148020 --Entered Amount
148021 , p_source_91 IN NUMBER
148022 --Currency Conversion Date
148023 , p_source_92 IN DATE
148024 --Currency Conversion Rate
148025 , p_source_93 IN NUMBER
148026 --Currency Conversion Type
148027 , p_source_94 IN VARCHAR2
148028 --Accounted Amount
148029 , p_source_95 IN NUMBER
148030 --Accounting Line Type
148031 , p_source_97 IN NUMBER
148032 --Organization Code
148033 , p_source_108 IN VARCHAR2
148034 )
148035 IS
148036
148037 l_component_type VARCHAR2(80);
148038 l_component_code VARCHAR2(30);
148039 l_component_type_code VARCHAR2(1);
148040 l_component_appl_id INTEGER;
148041 l_amb_context_code VARCHAR2(30);
148042 l_entity_code VARCHAR2(30);
148043 l_event_class_code VARCHAR2(30);
148044 l_ae_header_id NUMBER;
148045 l_event_type_code VARCHAR2(30);
148046 l_line_definition_code VARCHAR2(30);
148047 l_line_definition_owner_code VARCHAR2(1);
148048 --
148049 -- adr variables
148050 l_segment VARCHAR2(30);
148051 l_ccid NUMBER;
148052 l_adr_transaction_coa_id NUMBER;
148053 l_adr_accounting_coa_id NUMBER;
148054 l_adr_flexfield_segment_code VARCHAR2(30);
148055 l_adr_flex_value_set_id NUMBER;
148056 l_adr_value_type_code VARCHAR2(30);
148057 l_adr_value_combination_id NUMBER;
148058 l_adr_value_segment_code VARCHAR2(30);
148059
148060 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
148061 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
148062 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
148063 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
148064
148065 -- 4262811 Variables ------------------------------------------------------------------------------------------
148066 l_entered_amt_idx NUMBER;
148067 l_accted_amt_idx NUMBER;
148068 l_acc_rev_flag VARCHAR2(1);
148069 l_accrual_line_num NUMBER;
148070 l_tmp_amt NUMBER;
148071 l_acc_rev_natural_side_code VARCHAR2(1);
148072
148073 l_num_entries NUMBER;
148074 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
148075 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
148076 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
148077 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
148078 l_recog_line_1 NUMBER;
148079 l_recog_line_2 NUMBER;
148080
148081 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
148082 l_bflow_applied_to_amt NUMBER; -- 5132302
148083 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
148084
148085 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
148086
148087 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
148088 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
148089
148090 ---------------------------------------------------------------------------------------------------------------
148091
148092
148093 --
148094 -- bulk performance
148095 --
148096 l_balance_type_code VARCHAR2(1);
148097 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
148098 l_log_module VARCHAR2(240);
148099
148100 --
148101 -- Upgrade strategy
148102 --
148103 l_actual_upg_option VARCHAR2(1);
148104 l_enc_upg_option VARCHAR2(1);
148105
148106 --
148107 BEGIN
148108 --
148109 IF g_log_enabled THEN
148110 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_278';
148111 END IF;
148112 --
148113 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
148114
148115 trace
148116 (p_msg => 'BEGIN of AcctLineType_278'
148117 ,p_level => C_LEVEL_PROCEDURE
148118 ,p_module => l_log_module);
148119
148120 END IF;
148121 --
148122 l_component_type := 'AMB_JLT';
148123 l_component_code := 'INVENTORY_VALUATION';
148124 l_component_type_code := 'S';
148125 l_component_appl_id := 707;
148126 l_amb_context_code := 'DEFAULT';
148127 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
148128 l_event_class_code := 'LOG_INTERCOMPANY';
148129 l_event_type_code := 'LOG_IC_RCPT_RETURN';
148130 l_line_definition_owner_code := 'S';
148131 l_line_definition_code := 'PI_LOG_IC_RCPT_RETURN';
148132 --
148133 l_balance_type_code := 'A';
148134 l_segment := NULL;
148135 l_ccid := NULL;
148136 l_adr_transaction_coa_id := NULL;
148137 l_adr_accounting_coa_id := NULL;
148138 l_adr_flexfield_segment_code := NULL;
148139 l_adr_flex_value_set_id := NULL;
148140 l_adr_value_type_code := NULL;
148141 l_adr_value_combination_id := NULL;
148142 l_adr_value_segment_code := NULL;
148143
148144 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
148145 l_bflow_class_code := ''; -- 4219869 Business Flow
148146 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
148147 l_budgetary_control_flag := 'N';
148148
148149 l_bflow_applied_to_amt_idx := NULL; -- 5132302
148150 l_bflow_applied_to_amt := NULL; -- 5132302
148151 l_entered_amt_idx := NULL; -- 4262811
148152 l_accted_amt_idx := NULL; -- 4262811
148153 l_acc_rev_flag := NULL; -- 4262811
148154 l_accrual_line_num := NULL; -- 4262811
148155 l_tmp_amt := NULL; -- 4262811
148156 --
148157
148158 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
148159 l_balance_type_code <> 'B' THEN
148160 IF NVL(p_source_97,9E125) = 1
148161 THEN
148162
148163 --
148164 XLA_AE_LINES_PKG.SetNewLine;
148165
148166 p_balance_type_code := l_balance_type_code;
148167 -- set the flag so later we will know whether the gain loss line needs to be created
148168
148169 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
148170 p_actual_flag :='A';
148171 END IF;
148172
148173 --
148174 -- bulk performance
148175 --
148176 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
148177 p_header_num => 0); -- 4262811
148178 --
148179 -- set accounting line options
148180 --
148181 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
148182 p_natural_side_code => 'D'
148183 , p_gain_or_loss_flag => 'N'
148184 , p_gl_transfer_mode_code => 'S'
148185 , p_acct_entry_type_code => 'A'
148186 , p_switch_side_flag => 'Y'
148187 , p_merge_duplicate_code => 'N'
148188 );
148189 --
148190 l_acc_rev_natural_side_code := 'C'; -- 4262811
148191 --
148192 --
148193 -- set accounting line type info
148194 --
148195 xla_ae_lines_pkg.SetAcctLineType
148196 (p_component_type => l_component_type
148197 ,p_event_type_code => l_event_type_code
148198 ,p_line_definition_owner_code => l_line_definition_owner_code
148199 ,p_line_definition_code => l_line_definition_code
148200 ,p_accounting_line_code => l_component_code
148201 ,p_accounting_line_type_code => l_component_type_code
148202 ,p_accounting_line_appl_id => l_component_appl_id
148203 ,p_amb_context_code => l_amb_context_code
148204 ,p_entity_code => l_entity_code
148205 ,p_event_class_code => l_event_class_code);
148206 --
148207 -- set accounting class
148208 --
148209 xla_ae_lines_pkg.SetAcctClass(
148210 p_accounting_class_code => 'INVENTORY_VALUATION'
148211 , p_ae_header_id => l_ae_header_id
148212 );
148213
148214 --
148215 -- set rounding class
148216 --
148217 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
148218 'INVENTORY_VALUATION';
148219
148220 --
148221 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
148222 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
148223 --
148224 -- bulk performance
148225 --
148226 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
148227
148228 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
148229 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
148230
148231 -- 4955764
148232 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
148233 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
148234
148235 -- 4458381 Public Sector Enh
148236
148237 --
148238 -- set accounting attributes for the line type
148239 --
148240 l_entered_amt_idx := 3;
148241 l_accted_amt_idx := 8;
148242 l_bflow_applied_to_amt_idx := NULL; -- 5132302
148243 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
148244 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
148245 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
148246 l_rec_acct_attrs.array_char_value(2) := p_source_85;
148247 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
148248 l_rec_acct_attrs.array_num_value(3) := p_source_91;
148249 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
148250 l_rec_acct_attrs.array_char_value(4) := p_source_88;
148251 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
148252 l_rec_acct_attrs.array_date_value(5) := p_source_92;
148253 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
148254 l_rec_acct_attrs.array_num_value(6) := p_source_93;
148255 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
148256 l_rec_acct_attrs.array_char_value(7) := p_source_94;
148257 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
148258 l_rec_acct_attrs.array_num_value(8) := p_source_95;
148259
148260 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
148261 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
148262
148263 ---------------------------------------------------------------------------------------------------------------
148264 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
148265 ---------------------------------------------------------------------------------------------------------------
148266 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
148267
148268 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
148269 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
148270
148271 IF xla_accounting_cache_pkg.GetValueChar
148272 (p_source_code => 'LEDGER_CATEGORY_CODE'
148273 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
148274 AND l_bflow_method_code = 'PRIOR_ENTRY'
148275 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
148276 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
148277 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
148278 )
148279 THEN
148280 xla_ae_lines_pkg.BflowUpgEntry
148281 (p_business_method_code => l_bflow_method_code
148282 ,p_business_class_code => l_bflow_class_code
148283 ,p_balance_type => l_balance_type_code);
148284 ELSE
148285 NULL;
148286 -- No business flow processing for business flow method of NONE.
148287 END IF;
148288
148289 --
148290 -- call analytical criteria
148291 --
148292
148293
148294 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
148295 xla_ae_lines_pkg.SetAnalyticalCriteria(
148296 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
148297 , p_analytical_criterion_owner => 'S'
148298 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
148299 , p_amb_context_code => 'DEFAULT'
148300 , p_balancing_flag => 'Y'
148301
148302 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
148303 , p_analytical_detail_num_1 => NULL
148304 , p_analytical_detail_date_1 => NULL
148305
148306 , p_ae_header_id => l_ae_header_id
148307 )
148308 ;
148309 --
148310
148311 --
148312 -- call description
148313 --
148314
148315 xla_ae_lines_pkg.SetLineDescription(
148316 p_ae_header_id => l_ae_header_id
148317 ,p_description => Description_1 (
148318 p_application_id => p_application_id
148319 , p_ae_header_id => l_ae_header_id
148320 , p_source_1 => p_source_1
148321 , p_source_2 => p_source_2
148322 , p_source_3 => p_source_3
148323 , p_source_4 => p_source_4
148324 , p_source_5 => p_source_5
148325 )
148326 );
148327
148328
148329 --
148330 -- call ADRs
148331 -- Bug 4922099
148332 --
148333 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
148334 (NVL(l_actual_upg_option, 'N') = 'O') OR
148335 (NVL(l_enc_upg_option, 'N') = 'O')
148336 )
148337 THEN
148338 NULL;
148339 --
148340 --
148341
148342 l_ccid := AcctDerRule_28(
148343 p_application_id => p_application_id
148344 , p_ae_header_id => l_ae_header_id
148345 , p_source_15 => p_source_15
148346 , p_source_41 => p_source_41
148347 , p_source_42 => p_source_42
148348 , p_source_43 => p_source_43
148349 , p_source_44 => p_source_44
148350 , p_source_45 => p_source_45
148351 , x_transaction_coa_id => l_adr_transaction_coa_id
148352 , x_accounting_coa_id => l_adr_accounting_coa_id
148353 , x_value_type_code => l_adr_value_type_code
148354 , p_side => 'NA'
148355 );
148356
148357 xla_ae_lines_pkg.set_ccid(
148358 p_code_combination_id => l_ccid
148359 , p_value_type_code => l_adr_value_type_code
148360 , p_transaction_coa_id => l_adr_transaction_coa_id
148361 , p_accounting_coa_id => l_adr_accounting_coa_id
148362 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
148363 , p_adr_type_code => 'S'
148364 , p_component_type => l_component_type
148365 , p_component_code => l_component_code
148366 , p_component_type_code => l_component_type_code
148367 , p_component_appl_id => l_component_appl_id
148368 , p_amb_context_code => l_amb_context_code
148369 , p_side => 'NA'
148370 );
148371
148372
148373 --
148374 --
148375 END IF;
148376 --
148377 -- Bug 4922099
148378 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
148379 (NVL(l_enc_upg_option, 'N') = 'O')
148380 ) AND
148381 (l_bflow_method_code = 'PRIOR_ENTRY')
148382 )
148383 THEN
148384 IF
148385 --
148386 1 = 2
148387 --
148388 THEN
148389 xla_accounting_err_pkg.build_message
148390 (p_appli_s_name => 'XLA'
148391 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
148392 ,p_token_1 => 'LINE_NUMBER'
148393 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
148394 ,p_token_2 => 'LINE_TYPE_NAME'
148395 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
148396 l_component_type
148397 ,l_component_code
148398 ,l_component_type_code
148399 ,l_component_appl_id
148400 ,l_amb_context_code
148401 ,l_entity_code
148402 ,l_event_class_code
148403 )
148404 ,p_token_3 => 'OWNER'
148405 ,p_value_3 => xla_lookups_pkg.get_meaning(
148406 p_lookup_type => 'XLA_OWNER_TYPE'
148407 ,p_lookup_code => l_component_type_code
148408 )
148409 ,p_token_4 => 'PRODUCT_NAME'
148410 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
148411 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
148412 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
148413 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
148414 ,p_ae_header_id => NULL
148415 );
148416
148417 IF (C_LEVEL_ERROR>= g_log_level) THEN
148418 trace
148419 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
148420 ,p_level => C_LEVEL_ERROR
148421 ,p_module => l_log_module);
148422 END IF;
148423 END IF;
148424 END IF;
148425 --
148426 --
148427 ------------------------------------------------------------------------------------------------
148428 -- 4219869 Business Flow
148429 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
148430 -- Prior Entry. Currently, the following code is always generated.
148431 ------------------------------------------------------------------------------------------------
148432 XLA_AE_LINES_PKG.ValidateCurrentLine;
148433
148434 ------------------------------------------------------------------------------------
148435 -- 4219869 Business Flow
148436 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
148437 ------------------------------------------------------------------------------------
148438 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
148439
148440 ----------------------------------------------------------------------------------
148441 -- 4219869 Business Flow
148442 -- Update journal entry status -- Need to generate this within IF <condition>
148443 ----------------------------------------------------------------------------------
148444 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
148445 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
148446 ,p_balance_type_code => l_balance_type_code
148447 );
148448
148449 -------------------------------------------------------------------------------------------
148450 -- 4262811 - Generate the Accrual Reversal lines
148451 -------------------------------------------------------------------------------------------
148452 BEGIN
148453 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
148454 (g_array_event(p_event_id).array_value_num('header_index'));
148455 IF l_acc_rev_flag IS NULL THEN
148456 l_acc_rev_flag := 'N';
148457 END IF;
148458 EXCEPTION
148459 WHEN OTHERS THEN
148460 l_acc_rev_flag := 'N';
148461 END;
148462 --
148463 IF (l_acc_rev_flag = 'Y') THEN
148464
148465 -- 4645092 ------------------------------------------------------------------------------
148466 -- To allow MPA report to determine if it should generate report process
148467 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
148468 ------------------------------------------------------------------------------------------
148469
148470 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
148471 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
148472 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
148473 -- call ADRs
148474 -- Bug 4922099
148475 --
148476 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
148477 (NVL(l_actual_upg_option, 'N') = 'O') OR
148478 (NVL(l_enc_upg_option, 'N') = 'O')
148479 )
148480 THEN
148481 NULL;
148482 --
148483 --
148484
148485 l_ccid := AcctDerRule_28(
148486 p_application_id => p_application_id
148487 , p_ae_header_id => l_ae_header_id
148488 , p_source_15 => p_source_15
148489 , p_source_41 => p_source_41
148490 , p_source_42 => p_source_42
148491 , p_source_43 => p_source_43
148492 , p_source_44 => p_source_44
148493 , p_source_45 => p_source_45
148494 , x_transaction_coa_id => l_adr_transaction_coa_id
148495 , x_accounting_coa_id => l_adr_accounting_coa_id
148496 , x_value_type_code => l_adr_value_type_code
148497 , p_side => 'NA'
148498 );
148499
148500 xla_ae_lines_pkg.set_ccid(
148501 p_code_combination_id => l_ccid
148502 , p_value_type_code => l_adr_value_type_code
148503 , p_transaction_coa_id => l_adr_transaction_coa_id
148504 , p_accounting_coa_id => l_adr_accounting_coa_id
148505 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
148506 , p_adr_type_code => 'S'
148507 , p_component_type => l_component_type
148508 , p_component_code => l_component_code
148509 , p_component_type_code => l_component_type_code
148510 , p_component_appl_id => l_component_appl_id
148511 , p_amb_context_code => l_amb_context_code
148512 , p_side => 'NA'
148513 );
148514
148515
148516 --
148517 --
148518 END IF;
148519
148520 --
148521 -- Update the line information that should be overwritten
148522 --
148523 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
148524 p_header_num => 1);
148525 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
148526
148527 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
148528
148529 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
148530 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
148531 END IF;
148532
148533 --
148534 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
148535 --
148536 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
148537 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
148538 ELSE
148539 ---------------------------------------------------------------------------------------------------
148540 -- 4262811a Switch Sign
148541 ---------------------------------------------------------------------------------------------------
148542 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
148543 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
148544 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
148545 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
148546 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
148547 -- 5132302
148548 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
148549 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
148550
148551 END IF;
148552
148553 -- 4955764
148554 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
148555 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
148556
148557
148558 XLA_AE_LINES_PKG.ValidateCurrentLine;
148559 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
148560
148561 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
148562 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
148563 ,p_balance_type_code => l_balance_type_code);
148564
148565 END IF;
148566
148567 -----------------------------------------------------------------------------------------
148568 -- 4262811 Multiperiod Accounting
148569 -----------------------------------------------------------------------------------------
148570 -- No MPA option is assigned.
148571
148572
148573 END IF;
148574 END IF;
148575 --
148576
148577 --
148578 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
148579 trace
148580 (p_msg => 'END of AcctLineType_278'
148581 ,p_level => C_LEVEL_PROCEDURE
148582 ,p_module => l_log_module);
148583 END IF;
148584 --
148585 EXCEPTION
148586 WHEN xla_exceptions_pkg.application_exception THEN
148587 RAISE;
148588 WHEN OTHERS THEN
148589 xla_exceptions_pkg.raise_message
148590 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_278');
148591 END AcctLineType_278;
148592 --
148593
148594 ---------------------------------------
148595 --
148596 -- PRIVATE FUNCTION
148597 -- AcctLineType_279
148598 --
148599 ---------------------------------------
148600 PROCEDURE AcctLineType_279 (
148601 p_application_id IN NUMBER
148602 ,p_event_id IN NUMBER
148603 ,p_calculate_acctd_flag IN VARCHAR2
148604 ,p_calculate_g_l_flag IN VARCHAR2
148605 ,p_actual_flag IN OUT VARCHAR2
148606 ,p_balance_type_code OUT VARCHAR2
148607 ,p_gain_or_loss_ref OUT VARCHAR2
148608
148609 --TRANSACTION_ID
148610 , p_source_1 IN NUMBER
148611 --Item Concatenated Segments
148612 , p_source_2 IN VARCHAR2
148613 --Transaction Quantity
148614 , p_source_3 IN NUMBER
148615 --Transaction Unit of Measure Code
148616 , p_source_4 IN VARCHAR2
148617 --Inventory Transaction Type Description
148618 , p_source_5 IN VARCHAR2
148619 --Cost Element Name
148620 , p_source_15 IN NUMBER
148621 --Product Line Accounting Category Material Account
148622 , p_source_41 IN NUMBER
148623 --Product Line Accounting Category Material Overhead Account
148624 , p_source_42 IN NUMBER
148625 --Product Line Accounting Category Resource Account
148626 , p_source_43 IN NUMBER
148627 --Product Line Accounting Category Outside Processing Account
148628 , p_source_44 IN NUMBER
148629 --Product Line Accounting Category Overhead Account
148630 , p_source_45 IN NUMBER
148631 --DISTRIBUTION_IDENTIFIER
148632 , p_source_84 IN NUMBER
148633 --Distribution Type
148634 , p_source_85 IN VARCHAR2
148635 , p_source_85_meaning IN VARCHAR2
148636 --Entered Currency Code
148637 , p_source_88 IN VARCHAR2
148638 --Entered Amount
148639 , p_source_91 IN NUMBER
148640 --Currency Conversion Date
148641 , p_source_92 IN DATE
148642 --Currency Conversion Rate
148643 , p_source_93 IN NUMBER
148644 --Currency Conversion Type
148645 , p_source_94 IN VARCHAR2
148646 --Accounted Amount
148647 , p_source_95 IN NUMBER
148648 --Accounting Line Type
148649 , p_source_97 IN NUMBER
148650 --Organization Code
148651 , p_source_108 IN VARCHAR2
148652 )
148653 IS
148654
148655 l_component_type VARCHAR2(80);
148656 l_component_code VARCHAR2(30);
148657 l_component_type_code VARCHAR2(1);
148658 l_component_appl_id INTEGER;
148659 l_amb_context_code VARCHAR2(30);
148660 l_entity_code VARCHAR2(30);
148661 l_event_class_code VARCHAR2(30);
148662 l_ae_header_id NUMBER;
148663 l_event_type_code VARCHAR2(30);
148664 l_line_definition_code VARCHAR2(30);
148665 l_line_definition_owner_code VARCHAR2(1);
148666 --
148667 -- adr variables
148668 l_segment VARCHAR2(30);
148669 l_ccid NUMBER;
148670 l_adr_transaction_coa_id NUMBER;
148671 l_adr_accounting_coa_id NUMBER;
148672 l_adr_flexfield_segment_code VARCHAR2(30);
148673 l_adr_flex_value_set_id NUMBER;
148674 l_adr_value_type_code VARCHAR2(30);
148675 l_adr_value_combination_id NUMBER;
148676 l_adr_value_segment_code VARCHAR2(30);
148677
148678 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
148679 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
148680 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
148681 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
148682
148683 -- 4262811 Variables ------------------------------------------------------------------------------------------
148684 l_entered_amt_idx NUMBER;
148685 l_accted_amt_idx NUMBER;
148686 l_acc_rev_flag VARCHAR2(1);
148687 l_accrual_line_num NUMBER;
148688 l_tmp_amt NUMBER;
148689 l_acc_rev_natural_side_code VARCHAR2(1);
148690
148691 l_num_entries NUMBER;
148692 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
148693 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
148694 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
148695 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
148696 l_recog_line_1 NUMBER;
148697 l_recog_line_2 NUMBER;
148698
148699 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
148700 l_bflow_applied_to_amt NUMBER; -- 5132302
148701 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
148702
148703 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
148704
148705 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
148706 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
148707
148708 ---------------------------------------------------------------------------------------------------------------
148709
148710
148711 --
148712 -- bulk performance
148713 --
148714 l_balance_type_code VARCHAR2(1);
148715 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
148716 l_log_module VARCHAR2(240);
148717
148718 --
148719 -- Upgrade strategy
148720 --
148721 l_actual_upg_option VARCHAR2(1);
148722 l_enc_upg_option VARCHAR2(1);
148723
148724 --
148725 BEGIN
148726 --
148727 IF g_log_enabled THEN
148728 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_279';
148729 END IF;
148730 --
148731 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
148732
148733 trace
148734 (p_msg => 'BEGIN of AcctLineType_279'
148735 ,p_level => C_LEVEL_PROCEDURE
148736 ,p_module => l_log_module);
148737
148738 END IF;
148739 --
148740 l_component_type := 'AMB_JLT';
148741 l_component_code := 'INVENTORY_VALUATION';
148742 l_component_type_code := 'S';
148743 l_component_appl_id := 707;
148744 l_amb_context_code := 'DEFAULT';
148745 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
148746 l_event_class_code := 'MTL_COST_UPD';
148747 l_event_type_code := 'AVG_COST_UPD';
148748 l_line_definition_owner_code := 'S';
148749 l_line_definition_code := 'PI_AVG_COST_UPD';
148750 --
148751 l_balance_type_code := 'A';
148752 l_segment := NULL;
148753 l_ccid := NULL;
148754 l_adr_transaction_coa_id := NULL;
148755 l_adr_accounting_coa_id := NULL;
148756 l_adr_flexfield_segment_code := NULL;
148757 l_adr_flex_value_set_id := NULL;
148758 l_adr_value_type_code := NULL;
148759 l_adr_value_combination_id := NULL;
148760 l_adr_value_segment_code := NULL;
148761
148762 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
148763 l_bflow_class_code := ''; -- 4219869 Business Flow
148764 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
148765 l_budgetary_control_flag := 'N';
148766
148767 l_bflow_applied_to_amt_idx := NULL; -- 5132302
148768 l_bflow_applied_to_amt := NULL; -- 5132302
148769 l_entered_amt_idx := NULL; -- 4262811
148770 l_accted_amt_idx := NULL; -- 4262811
148771 l_acc_rev_flag := NULL; -- 4262811
148772 l_accrual_line_num := NULL; -- 4262811
148773 l_tmp_amt := NULL; -- 4262811
148774 --
148775
148776 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
148777 l_balance_type_code <> 'B' THEN
148778 IF NVL(p_source_97,9E125) = 1
148779 THEN
148780
148781 --
148782 XLA_AE_LINES_PKG.SetNewLine;
148783
148784 p_balance_type_code := l_balance_type_code;
148785 -- set the flag so later we will know whether the gain loss line needs to be created
148786
148787 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
148788 p_actual_flag :='A';
148789 END IF;
148790
148791 --
148792 -- bulk performance
148793 --
148794 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
148795 p_header_num => 0); -- 4262811
148796 --
148797 -- set accounting line options
148798 --
148799 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
148800 p_natural_side_code => 'D'
148801 , p_gain_or_loss_flag => 'N'
148802 , p_gl_transfer_mode_code => 'S'
148803 , p_acct_entry_type_code => 'A'
148804 , p_switch_side_flag => 'Y'
148805 , p_merge_duplicate_code => 'N'
148806 );
148807 --
148808 l_acc_rev_natural_side_code := 'C'; -- 4262811
148809 --
148810 --
148811 -- set accounting line type info
148812 --
148813 xla_ae_lines_pkg.SetAcctLineType
148814 (p_component_type => l_component_type
148815 ,p_event_type_code => l_event_type_code
148816 ,p_line_definition_owner_code => l_line_definition_owner_code
148817 ,p_line_definition_code => l_line_definition_code
148818 ,p_accounting_line_code => l_component_code
148819 ,p_accounting_line_type_code => l_component_type_code
148820 ,p_accounting_line_appl_id => l_component_appl_id
148821 ,p_amb_context_code => l_amb_context_code
148822 ,p_entity_code => l_entity_code
148823 ,p_event_class_code => l_event_class_code);
148824 --
148825 -- set accounting class
148826 --
148827 xla_ae_lines_pkg.SetAcctClass(
148828 p_accounting_class_code => 'INVENTORY_VALUATION'
148829 , p_ae_header_id => l_ae_header_id
148830 );
148831
148832 --
148833 -- set rounding class
148834 --
148835 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
148836 'INVENTORY_VALUATION';
148837
148838 --
148839 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
148840 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
148841 --
148842 -- bulk performance
148843 --
148844 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
148845
148846 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
148847 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
148848
148849 -- 4955764
148850 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
148851 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
148852
148853 -- 4458381 Public Sector Enh
148854
148855 --
148856 -- set accounting attributes for the line type
148857 --
148858 l_entered_amt_idx := 3;
148859 l_accted_amt_idx := 8;
148860 l_bflow_applied_to_amt_idx := NULL; -- 5132302
148861 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
148862 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
148863 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
148864 l_rec_acct_attrs.array_char_value(2) := p_source_85;
148865 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
148866 l_rec_acct_attrs.array_num_value(3) := p_source_91;
148867 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
148868 l_rec_acct_attrs.array_char_value(4) := p_source_88;
148869 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
148870 l_rec_acct_attrs.array_date_value(5) := p_source_92;
148871 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
148872 l_rec_acct_attrs.array_num_value(6) := p_source_93;
148873 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
148874 l_rec_acct_attrs.array_char_value(7) := p_source_94;
148875 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
148876 l_rec_acct_attrs.array_num_value(8) := p_source_95;
148877
148878 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
148879 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
148880
148881 ---------------------------------------------------------------------------------------------------------------
148882 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
148883 ---------------------------------------------------------------------------------------------------------------
148884 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
148885
148886 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
148887 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
148888
148889 IF xla_accounting_cache_pkg.GetValueChar
148890 (p_source_code => 'LEDGER_CATEGORY_CODE'
148891 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
148892 AND l_bflow_method_code = 'PRIOR_ENTRY'
148893 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
148894 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
148895 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
148896 )
148897 THEN
148898 xla_ae_lines_pkg.BflowUpgEntry
148899 (p_business_method_code => l_bflow_method_code
148900 ,p_business_class_code => l_bflow_class_code
148901 ,p_balance_type => l_balance_type_code);
148902 ELSE
148903 NULL;
148904 -- No business flow processing for business flow method of NONE.
148905 END IF;
148906
148907 --
148908 -- call analytical criteria
148909 --
148910
148911
148912 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
148913 xla_ae_lines_pkg.SetAnalyticalCriteria(
148914 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
148915 , p_analytical_criterion_owner => 'S'
148916 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
148917 , p_amb_context_code => 'DEFAULT'
148918 , p_balancing_flag => 'Y'
148919
148920 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
148921 , p_analytical_detail_num_1 => NULL
148922 , p_analytical_detail_date_1 => NULL
148923
148924 , p_ae_header_id => l_ae_header_id
148925 )
148926 ;
148927 --
148928
148929 --
148930 -- call description
148931 --
148932
148933 xla_ae_lines_pkg.SetLineDescription(
148934 p_ae_header_id => l_ae_header_id
148935 ,p_description => Description_1 (
148936 p_application_id => p_application_id
148937 , p_ae_header_id => l_ae_header_id
148938 , p_source_1 => p_source_1
148939 , p_source_2 => p_source_2
148940 , p_source_3 => p_source_3
148941 , p_source_4 => p_source_4
148942 , p_source_5 => p_source_5
148943 )
148944 );
148945
148946
148947 --
148948 -- call ADRs
148949 -- Bug 4922099
148950 --
148951 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
148952 (NVL(l_actual_upg_option, 'N') = 'O') OR
148953 (NVL(l_enc_upg_option, 'N') = 'O')
148954 )
148955 THEN
148956 NULL;
148957 --
148958 --
148959
148960 l_ccid := AcctDerRule_28(
148961 p_application_id => p_application_id
148962 , p_ae_header_id => l_ae_header_id
148963 , p_source_15 => p_source_15
148964 , p_source_41 => p_source_41
148965 , p_source_42 => p_source_42
148966 , p_source_43 => p_source_43
148967 , p_source_44 => p_source_44
148968 , p_source_45 => p_source_45
148969 , x_transaction_coa_id => l_adr_transaction_coa_id
148970 , x_accounting_coa_id => l_adr_accounting_coa_id
148971 , x_value_type_code => l_adr_value_type_code
148972 , p_side => 'NA'
148973 );
148974
148975 xla_ae_lines_pkg.set_ccid(
148976 p_code_combination_id => l_ccid
148977 , p_value_type_code => l_adr_value_type_code
148978 , p_transaction_coa_id => l_adr_transaction_coa_id
148979 , p_accounting_coa_id => l_adr_accounting_coa_id
148980 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
148981 , p_adr_type_code => 'S'
148982 , p_component_type => l_component_type
148983 , p_component_code => l_component_code
148984 , p_component_type_code => l_component_type_code
148985 , p_component_appl_id => l_component_appl_id
148986 , p_amb_context_code => l_amb_context_code
148987 , p_side => 'NA'
148988 );
148989
148990
148991 --
148992 --
148993 END IF;
148994 --
148995 -- Bug 4922099
148996 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
148997 (NVL(l_enc_upg_option, 'N') = 'O')
148998 ) AND
148999 (l_bflow_method_code = 'PRIOR_ENTRY')
149000 )
149001 THEN
149002 IF
149003 --
149004 1 = 2
149005 --
149006 THEN
149007 xla_accounting_err_pkg.build_message
149008 (p_appli_s_name => 'XLA'
149009 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
149010 ,p_token_1 => 'LINE_NUMBER'
149011 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
149012 ,p_token_2 => 'LINE_TYPE_NAME'
149013 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
149014 l_component_type
149015 ,l_component_code
149016 ,l_component_type_code
149017 ,l_component_appl_id
149018 ,l_amb_context_code
149019 ,l_entity_code
149020 ,l_event_class_code
149021 )
149022 ,p_token_3 => 'OWNER'
149023 ,p_value_3 => xla_lookups_pkg.get_meaning(
149024 p_lookup_type => 'XLA_OWNER_TYPE'
149025 ,p_lookup_code => l_component_type_code
149026 )
149027 ,p_token_4 => 'PRODUCT_NAME'
149028 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
149029 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
149030 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
149031 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
149032 ,p_ae_header_id => NULL
149033 );
149034
149035 IF (C_LEVEL_ERROR>= g_log_level) THEN
149036 trace
149037 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
149038 ,p_level => C_LEVEL_ERROR
149039 ,p_module => l_log_module);
149040 END IF;
149041 END IF;
149042 END IF;
149043 --
149044 --
149045 ------------------------------------------------------------------------------------------------
149046 -- 4219869 Business Flow
149047 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
149048 -- Prior Entry. Currently, the following code is always generated.
149049 ------------------------------------------------------------------------------------------------
149050 XLA_AE_LINES_PKG.ValidateCurrentLine;
149051
149052 ------------------------------------------------------------------------------------
149053 -- 4219869 Business Flow
149054 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
149055 ------------------------------------------------------------------------------------
149056 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
149057
149058 ----------------------------------------------------------------------------------
149059 -- 4219869 Business Flow
149060 -- Update journal entry status -- Need to generate this within IF <condition>
149061 ----------------------------------------------------------------------------------
149062 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
149063 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
149064 ,p_balance_type_code => l_balance_type_code
149065 );
149066
149067 -------------------------------------------------------------------------------------------
149068 -- 4262811 - Generate the Accrual Reversal lines
149069 -------------------------------------------------------------------------------------------
149070 BEGIN
149071 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
149072 (g_array_event(p_event_id).array_value_num('header_index'));
149073 IF l_acc_rev_flag IS NULL THEN
149074 l_acc_rev_flag := 'N';
149075 END IF;
149076 EXCEPTION
149077 WHEN OTHERS THEN
149078 l_acc_rev_flag := 'N';
149079 END;
149080 --
149081 IF (l_acc_rev_flag = 'Y') THEN
149082
149083 -- 4645092 ------------------------------------------------------------------------------
149084 -- To allow MPA report to determine if it should generate report process
149085 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
149086 ------------------------------------------------------------------------------------------
149087
149088 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
149089 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
149090 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
149091 -- call ADRs
149092 -- Bug 4922099
149093 --
149094 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
149095 (NVL(l_actual_upg_option, 'N') = 'O') OR
149096 (NVL(l_enc_upg_option, 'N') = 'O')
149097 )
149098 THEN
149099 NULL;
149100 --
149101 --
149102
149103 l_ccid := AcctDerRule_28(
149104 p_application_id => p_application_id
149105 , p_ae_header_id => l_ae_header_id
149106 , p_source_15 => p_source_15
149107 , p_source_41 => p_source_41
149108 , p_source_42 => p_source_42
149109 , p_source_43 => p_source_43
149110 , p_source_44 => p_source_44
149111 , p_source_45 => p_source_45
149112 , x_transaction_coa_id => l_adr_transaction_coa_id
149113 , x_accounting_coa_id => l_adr_accounting_coa_id
149114 , x_value_type_code => l_adr_value_type_code
149115 , p_side => 'NA'
149116 );
149117
149118 xla_ae_lines_pkg.set_ccid(
149119 p_code_combination_id => l_ccid
149120 , p_value_type_code => l_adr_value_type_code
149121 , p_transaction_coa_id => l_adr_transaction_coa_id
149122 , p_accounting_coa_id => l_adr_accounting_coa_id
149123 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
149124 , p_adr_type_code => 'S'
149125 , p_component_type => l_component_type
149126 , p_component_code => l_component_code
149127 , p_component_type_code => l_component_type_code
149128 , p_component_appl_id => l_component_appl_id
149129 , p_amb_context_code => l_amb_context_code
149130 , p_side => 'NA'
149131 );
149132
149133
149134 --
149135 --
149136 END IF;
149137
149138 --
149139 -- Update the line information that should be overwritten
149140 --
149141 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
149142 p_header_num => 1);
149143 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
149144
149145 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
149146
149147 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
149148 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
149149 END IF;
149150
149151 --
149152 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
149153 --
149154 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
149155 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
149156 ELSE
149157 ---------------------------------------------------------------------------------------------------
149158 -- 4262811a Switch Sign
149159 ---------------------------------------------------------------------------------------------------
149160 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
149161 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
149162 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149163 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
149164 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149165 -- 5132302
149166 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
149167 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149168
149169 END IF;
149170
149171 -- 4955764
149172 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
149173 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
149174
149175
149176 XLA_AE_LINES_PKG.ValidateCurrentLine;
149177 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
149178
149179 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
149180 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
149181 ,p_balance_type_code => l_balance_type_code);
149182
149183 END IF;
149184
149185 -----------------------------------------------------------------------------------------
149186 -- 4262811 Multiperiod Accounting
149187 -----------------------------------------------------------------------------------------
149188 -- No MPA option is assigned.
149189
149190
149191 END IF;
149192 END IF;
149193 --
149194
149195 --
149196 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
149197 trace
149198 (p_msg => 'END of AcctLineType_279'
149199 ,p_level => C_LEVEL_PROCEDURE
149200 ,p_module => l_log_module);
149201 END IF;
149202 --
149203 EXCEPTION
149204 WHEN xla_exceptions_pkg.application_exception THEN
149205 RAISE;
149206 WHEN OTHERS THEN
149207 xla_exceptions_pkg.raise_message
149208 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_279');
149209 END AcctLineType_279;
149210 --
149211
149212 ---------------------------------------
149213 --
149214 -- PRIVATE FUNCTION
149215 -- AcctLineType_280
149216 --
149217 ---------------------------------------
149218 PROCEDURE AcctLineType_280 (
149219 p_application_id IN NUMBER
149220 ,p_event_id IN NUMBER
149221 ,p_calculate_acctd_flag IN VARCHAR2
149222 ,p_calculate_g_l_flag IN VARCHAR2
149223 ,p_actual_flag IN OUT VARCHAR2
149224 ,p_balance_type_code OUT VARCHAR2
149225 ,p_gain_or_loss_ref OUT VARCHAR2
149226
149227 --TRANSACTION_ID
149228 , p_source_1 IN NUMBER
149229 --Item Concatenated Segments
149230 , p_source_2 IN VARCHAR2
149231 --Transaction Quantity
149232 , p_source_3 IN NUMBER
149233 --Transaction Unit of Measure Code
149234 , p_source_4 IN VARCHAR2
149235 --Inventory Transaction Type Description
149236 , p_source_5 IN VARCHAR2
149237 --Cost Element Name
149238 , p_source_15 IN NUMBER
149239 --Product Line Accounting Category Material Account
149240 , p_source_41 IN NUMBER
149241 --Product Line Accounting Category Material Overhead Account
149242 , p_source_42 IN NUMBER
149243 --Product Line Accounting Category Resource Account
149244 , p_source_43 IN NUMBER
149245 --Product Line Accounting Category Outside Processing Account
149246 , p_source_44 IN NUMBER
149247 --Product Line Accounting Category Overhead Account
149248 , p_source_45 IN NUMBER
149249 --Applied to Application ID
149250 , p_source_79 IN NUMBER
149251 --Applied to Distribution Link Type
149252 , p_source_80 IN VARCHAR2
149253 --Applied to Entity Code
149254 , p_source_81 IN VARCHAR2
149255 --Applied To Purchase Document Identifier
149256 , p_source_83 IN NUMBER
149257 --DISTRIBUTION_IDENTIFIER
149258 , p_source_84 IN NUMBER
149259 --Distribution Type
149260 , p_source_85 IN VARCHAR2
149261 , p_source_85_meaning IN VARCHAR2
149262 --PO Budget Account
149263 , p_source_86 IN NUMBER
149264 --Encumbrance Reversal Amount Entered
149265 , p_source_87 IN NUMBER
149266 --Entered Currency Code
149267 , p_source_88 IN VARCHAR2
149268 --Transaction Encumbrance Reversal Amount
149269 , p_source_89 IN NUMBER
149270 --Entered Amount
149271 , p_source_91 IN NUMBER
149272 --Currency Conversion Date
149273 , p_source_92 IN DATE
149274 --Currency Conversion Rate
149275 , p_source_93 IN NUMBER
149276 --Currency Conversion Type
149277 , p_source_94 IN VARCHAR2
149278 --Accounted Amount
149279 , p_source_95 IN NUMBER
149280 --Purchasing Encumbrance Type Identifier
149281 , p_source_96 IN NUMBER
149282 --Accounting Line Type
149283 , p_source_97 IN NUMBER
149284 --Costing Encumbrance Upgrade Option
149285 , p_source_100 IN VARCHAR2
149286 --TXN_PO_DISTRIBUTION_ID
149287 , p_source_101 IN NUMBER
149288 --Organization Code
149289 , p_source_108 IN VARCHAR2
149290 )
149291 IS
149292
149293 l_component_type VARCHAR2(80);
149294 l_component_code VARCHAR2(30);
149295 l_component_type_code VARCHAR2(1);
149296 l_component_appl_id INTEGER;
149297 l_amb_context_code VARCHAR2(30);
149298 l_entity_code VARCHAR2(30);
149299 l_event_class_code VARCHAR2(30);
149300 l_ae_header_id NUMBER;
149301 l_event_type_code VARCHAR2(30);
149302 l_line_definition_code VARCHAR2(30);
149303 l_line_definition_owner_code VARCHAR2(1);
149304 --
149305 -- adr variables
149306 l_segment VARCHAR2(30);
149307 l_ccid NUMBER;
149308 l_adr_transaction_coa_id NUMBER;
149309 l_adr_accounting_coa_id NUMBER;
149310 l_adr_flexfield_segment_code VARCHAR2(30);
149311 l_adr_flex_value_set_id NUMBER;
149312 l_adr_value_type_code VARCHAR2(30);
149313 l_adr_value_combination_id NUMBER;
149314 l_adr_value_segment_code VARCHAR2(30);
149315
149316 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
149317 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
149318 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
149319 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
149320
149321 -- 4262811 Variables ------------------------------------------------------------------------------------------
149322 l_entered_amt_idx NUMBER;
149323 l_accted_amt_idx NUMBER;
149324 l_acc_rev_flag VARCHAR2(1);
149325 l_accrual_line_num NUMBER;
149326 l_tmp_amt NUMBER;
149327 l_acc_rev_natural_side_code VARCHAR2(1);
149328
149329 l_num_entries NUMBER;
149330 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
149331 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
149332 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
149333 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
149334 l_recog_line_1 NUMBER;
149335 l_recog_line_2 NUMBER;
149336
149337 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
149338 l_bflow_applied_to_amt NUMBER; -- 5132302
149339 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
149340
149341 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
149342
149343 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
149344 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
149345
149346 ---------------------------------------------------------------------------------------------------------------
149347
149348
149349 --
149350 -- bulk performance
149351 --
149352 l_balance_type_code VARCHAR2(1);
149353 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
149354 l_log_module VARCHAR2(240);
149355
149356 --
149357 -- Upgrade strategy
149358 --
149359 l_actual_upg_option VARCHAR2(1);
149360 l_enc_upg_option VARCHAR2(1);
149361
149362 --
149363 BEGIN
149364 --
149365 IF g_log_enabled THEN
149366 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_280';
149367 END IF;
149368 --
149369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
149370
149371 trace
149372 (p_msg => 'BEGIN of AcctLineType_280'
149373 ,p_level => C_LEVEL_PROCEDURE
149374 ,p_module => l_log_module);
149375
149376 END IF;
149377 --
149378 l_component_type := 'AMB_JLT';
149379 l_component_code := 'INVENTORY_VALUATION';
149380 l_component_type_code := 'S';
149381 l_component_appl_id := 707;
149382 l_amb_context_code := 'DEFAULT';
149383 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
149384 l_event_class_code := 'PURCHASE_ORDER';
149385 l_event_type_code := 'RET_RI_INV';
149386 l_line_definition_owner_code := 'S';
149387 l_line_definition_code := 'PI_RET_RI_INV';
149388 --
149389 l_balance_type_code := 'A';
149390 l_segment := NULL;
149391 l_ccid := NULL;
149392 l_adr_transaction_coa_id := NULL;
149393 l_adr_accounting_coa_id := NULL;
149394 l_adr_flexfield_segment_code := NULL;
149395 l_adr_flex_value_set_id := NULL;
149396 l_adr_value_type_code := NULL;
149397 l_adr_value_combination_id := NULL;
149398 l_adr_value_segment_code := NULL;
149399
149400 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
149401 l_bflow_class_code := ''; -- 4219869 Business Flow
149402 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
149403 l_budgetary_control_flag := 'N';
149404
149405 l_bflow_applied_to_amt_idx := NULL; -- 5132302
149406 l_bflow_applied_to_amt := NULL; -- 5132302
149407 l_entered_amt_idx := NULL; -- 4262811
149408 l_accted_amt_idx := NULL; -- 4262811
149409 l_acc_rev_flag := NULL; -- 4262811
149410 l_accrual_line_num := NULL; -- 4262811
149411 l_tmp_amt := NULL; -- 4262811
149412 --
149413
149414 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
149415 l_balance_type_code <> 'B' THEN
149416 IF NVL(p_source_97,9E125) = 1
149417 THEN
149418
149419 --
149420 XLA_AE_LINES_PKG.SetNewLine;
149421
149422 p_balance_type_code := l_balance_type_code;
149423 -- set the flag so later we will know whether the gain loss line needs to be created
149424
149425 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
149426 p_actual_flag :='A';
149427 END IF;
149428
149429 --
149430 -- bulk performance
149431 --
149432 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
149433 p_header_num => 0); -- 4262811
149434 --
149435 -- set accounting line options
149436 --
149437 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
149438 p_natural_side_code => 'D'
149439 , p_gain_or_loss_flag => 'N'
149440 , p_gl_transfer_mode_code => 'S'
149441 , p_acct_entry_type_code => 'A'
149442 , p_switch_side_flag => 'Y'
149443 , p_merge_duplicate_code => 'N'
149444 );
149445 --
149446 l_acc_rev_natural_side_code := 'C'; -- 4262811
149447 --
149448 --
149449 -- set accounting line type info
149450 --
149451 xla_ae_lines_pkg.SetAcctLineType
149452 (p_component_type => l_component_type
149453 ,p_event_type_code => l_event_type_code
149454 ,p_line_definition_owner_code => l_line_definition_owner_code
149455 ,p_line_definition_code => l_line_definition_code
149456 ,p_accounting_line_code => l_component_code
149457 ,p_accounting_line_type_code => l_component_type_code
149458 ,p_accounting_line_appl_id => l_component_appl_id
149459 ,p_amb_context_code => l_amb_context_code
149460 ,p_entity_code => l_entity_code
149461 ,p_event_class_code => l_event_class_code);
149462 --
149463 -- set accounting class
149464 --
149465 xla_ae_lines_pkg.SetAcctClass(
149466 p_accounting_class_code => 'INVENTORY_VALUATION'
149467 , p_ae_header_id => l_ae_header_id
149468 );
149469
149470 --
149471 -- set rounding class
149472 --
149473 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
149474 'INVENTORY_VALUATION';
149475
149476 --
149477 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
149478 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
149479 --
149480 -- bulk performance
149481 --
149482 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
149483
149484 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
149485 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
149486
149487 -- 4955764
149488 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
149489 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
149490
149491 -- 4458381 Public Sector Enh
149492
149493 --
149494 -- set accounting attributes for the line type
149495 --
149496 l_entered_amt_idx := 17;
149497 l_accted_amt_idx := 22;
149498 l_bflow_applied_to_amt_idx := NULL; -- 5132302
149499 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
149500 l_rec_acct_attrs.array_num_value(1) := p_source_79;
149501 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
149502 l_rec_acct_attrs.array_char_value(2) := p_source_80;
149503 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
149504 l_rec_acct_attrs.array_char_value(3) := p_source_81;
149505 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
149506 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
149507 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
149508 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
149509 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
149510 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
149511 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
149512 l_rec_acct_attrs.array_char_value(7) := p_source_85;
149513 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
149514 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
149515 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
149516 l_rec_acct_attrs.array_num_value(9) := p_source_87;
149517 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
149518 l_rec_acct_attrs.array_char_value(10) := p_source_88;
149519 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
149520 l_rec_acct_attrs.array_num_value(11) := p_source_89;
149521 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
149522 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
149523 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
149524 l_rec_acct_attrs.array_num_value(13) := p_source_87;
149525 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
149526 l_rec_acct_attrs.array_char_value(14) := p_source_88;
149527 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
149528 l_rec_acct_attrs.array_num_value(15) := p_source_89;
149529 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
149530 l_rec_acct_attrs.array_char_value(16) := p_source_100;
149531 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
149532 l_rec_acct_attrs.array_num_value(17) := p_source_91;
149533 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
149534 l_rec_acct_attrs.array_char_value(18) := p_source_88;
149535 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
149536 l_rec_acct_attrs.array_date_value(19) := p_source_92;
149537 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
149538 l_rec_acct_attrs.array_num_value(20) := p_source_93;
149539 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
149540 l_rec_acct_attrs.array_char_value(21) := p_source_94;
149541 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
149542 l_rec_acct_attrs.array_num_value(22) := p_source_95;
149543 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
149544 l_rec_acct_attrs.array_num_value(23) := p_source_96;
149545 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
149546 l_rec_acct_attrs.array_num_value(24) := p_source_96;
149547
149548 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
149549 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
149550
149551 ---------------------------------------------------------------------------------------------------------------
149552 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
149553 ---------------------------------------------------------------------------------------------------------------
149554 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
149555
149556 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
149557 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
149558
149559 IF xla_accounting_cache_pkg.GetValueChar
149560 (p_source_code => 'LEDGER_CATEGORY_CODE'
149561 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
149562 AND l_bflow_method_code = 'PRIOR_ENTRY'
149563 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
149564 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
149565 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
149566 )
149567 THEN
149568 xla_ae_lines_pkg.BflowUpgEntry
149569 (p_business_method_code => l_bflow_method_code
149570 ,p_business_class_code => l_bflow_class_code
149571 ,p_balance_type => l_balance_type_code);
149572 ELSE
149573 NULL;
149574 -- No business flow processing for business flow method of NONE.
149575 END IF;
149576
149577 --
149578 -- call analytical criteria
149579 --
149580
149581
149582 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
149583 xla_ae_lines_pkg.SetAnalyticalCriteria(
149584 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
149585 , p_analytical_criterion_owner => 'S'
149586 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
149587 , p_amb_context_code => 'DEFAULT'
149588 , p_balancing_flag => 'Y'
149589
149590 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
149591 , p_analytical_detail_num_1 => NULL
149592 , p_analytical_detail_date_1 => NULL
149593
149594 , p_ae_header_id => l_ae_header_id
149595 )
149596 ;
149597 --
149598
149599 --
149600 -- call description
149601 --
149602
149603 xla_ae_lines_pkg.SetLineDescription(
149604 p_ae_header_id => l_ae_header_id
149605 ,p_description => Description_1 (
149606 p_application_id => p_application_id
149607 , p_ae_header_id => l_ae_header_id
149608 , p_source_1 => p_source_1
149609 , p_source_2 => p_source_2
149610 , p_source_3 => p_source_3
149611 , p_source_4 => p_source_4
149612 , p_source_5 => p_source_5
149613 )
149614 );
149615
149616
149617 --
149618 -- call ADRs
149619 -- Bug 4922099
149620 --
149621 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
149622 (NVL(l_actual_upg_option, 'N') = 'O') OR
149623 (NVL(l_enc_upg_option, 'N') = 'O')
149624 )
149625 THEN
149626 NULL;
149627 --
149628 --
149629
149630 l_ccid := AcctDerRule_28(
149631 p_application_id => p_application_id
149632 , p_ae_header_id => l_ae_header_id
149633 , p_source_15 => p_source_15
149634 , p_source_41 => p_source_41
149635 , p_source_42 => p_source_42
149636 , p_source_43 => p_source_43
149637 , p_source_44 => p_source_44
149638 , p_source_45 => p_source_45
149639 , x_transaction_coa_id => l_adr_transaction_coa_id
149640 , x_accounting_coa_id => l_adr_accounting_coa_id
149641 , x_value_type_code => l_adr_value_type_code
149642 , p_side => 'NA'
149643 );
149644
149645 xla_ae_lines_pkg.set_ccid(
149646 p_code_combination_id => l_ccid
149647 , p_value_type_code => l_adr_value_type_code
149648 , p_transaction_coa_id => l_adr_transaction_coa_id
149649 , p_accounting_coa_id => l_adr_accounting_coa_id
149650 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
149651 , p_adr_type_code => 'S'
149652 , p_component_type => l_component_type
149653 , p_component_code => l_component_code
149654 , p_component_type_code => l_component_type_code
149655 , p_component_appl_id => l_component_appl_id
149656 , p_amb_context_code => l_amb_context_code
149657 , p_side => 'NA'
149658 );
149659
149660
149661 --
149662 --
149663 END IF;
149664 --
149665 -- Bug 4922099
149666 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
149667 (NVL(l_enc_upg_option, 'N') = 'O')
149668 ) AND
149669 (l_bflow_method_code = 'PRIOR_ENTRY')
149670 )
149671 THEN
149672 IF
149673 --
149674 1 = 2
149675 --
149676 THEN
149677 xla_accounting_err_pkg.build_message
149678 (p_appli_s_name => 'XLA'
149679 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
149680 ,p_token_1 => 'LINE_NUMBER'
149681 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
149682 ,p_token_2 => 'LINE_TYPE_NAME'
149683 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
149684 l_component_type
149685 ,l_component_code
149686 ,l_component_type_code
149687 ,l_component_appl_id
149688 ,l_amb_context_code
149689 ,l_entity_code
149690 ,l_event_class_code
149691 )
149692 ,p_token_3 => 'OWNER'
149693 ,p_value_3 => xla_lookups_pkg.get_meaning(
149694 p_lookup_type => 'XLA_OWNER_TYPE'
149695 ,p_lookup_code => l_component_type_code
149696 )
149697 ,p_token_4 => 'PRODUCT_NAME'
149698 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
149699 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
149700 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
149701 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
149702 ,p_ae_header_id => NULL
149703 );
149704
149705 IF (C_LEVEL_ERROR>= g_log_level) THEN
149706 trace
149707 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
149708 ,p_level => C_LEVEL_ERROR
149709 ,p_module => l_log_module);
149710 END IF;
149711 END IF;
149712 END IF;
149713 --
149714 --
149715 ------------------------------------------------------------------------------------------------
149716 -- 4219869 Business Flow
149717 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
149718 -- Prior Entry. Currently, the following code is always generated.
149719 ------------------------------------------------------------------------------------------------
149720 XLA_AE_LINES_PKG.ValidateCurrentLine;
149721
149722 ------------------------------------------------------------------------------------
149723 -- 4219869 Business Flow
149724 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
149725 ------------------------------------------------------------------------------------
149726 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
149727
149728 ----------------------------------------------------------------------------------
149729 -- 4219869 Business Flow
149730 -- Update journal entry status -- Need to generate this within IF <condition>
149731 ----------------------------------------------------------------------------------
149732 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
149733 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
149734 ,p_balance_type_code => l_balance_type_code
149735 );
149736
149737 -------------------------------------------------------------------------------------------
149738 -- 4262811 - Generate the Accrual Reversal lines
149739 -------------------------------------------------------------------------------------------
149740 BEGIN
149741 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
149742 (g_array_event(p_event_id).array_value_num('header_index'));
149743 IF l_acc_rev_flag IS NULL THEN
149744 l_acc_rev_flag := 'N';
149745 END IF;
149746 EXCEPTION
149747 WHEN OTHERS THEN
149748 l_acc_rev_flag := 'N';
149749 END;
149750 --
149751 IF (l_acc_rev_flag = 'Y') THEN
149752
149753 -- 4645092 ------------------------------------------------------------------------------
149754 -- To allow MPA report to determine if it should generate report process
149755 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
149756 ------------------------------------------------------------------------------------------
149757
149758 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
149759 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
149760 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
149761 -- call ADRs
149762 -- Bug 4922099
149763 --
149764 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
149765 (NVL(l_actual_upg_option, 'N') = 'O') OR
149766 (NVL(l_enc_upg_option, 'N') = 'O')
149767 )
149768 THEN
149769 NULL;
149770 --
149771 --
149772
149773 l_ccid := AcctDerRule_28(
149774 p_application_id => p_application_id
149775 , p_ae_header_id => l_ae_header_id
149776 , p_source_15 => p_source_15
149777 , p_source_41 => p_source_41
149778 , p_source_42 => p_source_42
149779 , p_source_43 => p_source_43
149780 , p_source_44 => p_source_44
149781 , p_source_45 => p_source_45
149782 , x_transaction_coa_id => l_adr_transaction_coa_id
149783 , x_accounting_coa_id => l_adr_accounting_coa_id
149784 , x_value_type_code => l_adr_value_type_code
149785 , p_side => 'NA'
149786 );
149787
149788 xla_ae_lines_pkg.set_ccid(
149789 p_code_combination_id => l_ccid
149790 , p_value_type_code => l_adr_value_type_code
149791 , p_transaction_coa_id => l_adr_transaction_coa_id
149792 , p_accounting_coa_id => l_adr_accounting_coa_id
149793 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
149794 , p_adr_type_code => 'S'
149795 , p_component_type => l_component_type
149796 , p_component_code => l_component_code
149797 , p_component_type_code => l_component_type_code
149798 , p_component_appl_id => l_component_appl_id
149799 , p_amb_context_code => l_amb_context_code
149800 , p_side => 'NA'
149801 );
149802
149803
149804 --
149805 --
149806 END IF;
149807
149808 --
149809 -- Update the line information that should be overwritten
149810 --
149811 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
149812 p_header_num => 1);
149813 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
149814
149815 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
149816
149817 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
149818 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
149819 END IF;
149820
149821 --
149822 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
149823 --
149824 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
149825 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
149826 ELSE
149827 ---------------------------------------------------------------------------------------------------
149828 -- 4262811a Switch Sign
149829 ---------------------------------------------------------------------------------------------------
149830 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
149831 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
149832 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149833 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
149834 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149835 -- 5132302
149836 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
149837 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
149838
149839 END IF;
149840
149841 -- 4955764
149842 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
149843 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
149844
149845
149846 XLA_AE_LINES_PKG.ValidateCurrentLine;
149847 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
149848
149849 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
149850 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
149851 ,p_balance_type_code => l_balance_type_code);
149852
149853 END IF;
149854
149855 -----------------------------------------------------------------------------------------
149856 -- 4262811 Multiperiod Accounting
149857 -----------------------------------------------------------------------------------------
149858 -- No MPA option is assigned.
149859
149860
149861 END IF;
149862 END IF;
149863 --
149864
149865 --
149866 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
149867 trace
149868 (p_msg => 'END of AcctLineType_280'
149869 ,p_level => C_LEVEL_PROCEDURE
149870 ,p_module => l_log_module);
149871 END IF;
149872 --
149873 EXCEPTION
149874 WHEN xla_exceptions_pkg.application_exception THEN
149875 RAISE;
149876 WHEN OTHERS THEN
149877 xla_exceptions_pkg.raise_message
149878 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_280');
149879 END AcctLineType_280;
149880 --
149881
149882 ---------------------------------------
149883 --
149884 -- PRIVATE FUNCTION
149885 -- AcctLineType_281
149886 --
149887 ---------------------------------------
149888 PROCEDURE AcctLineType_281 (
149889 p_application_id IN NUMBER
149890 ,p_event_id IN NUMBER
149891 ,p_calculate_acctd_flag IN VARCHAR2
149892 ,p_calculate_g_l_flag IN VARCHAR2
149893 ,p_actual_flag IN OUT VARCHAR2
149894 ,p_balance_type_code OUT VARCHAR2
149895 ,p_gain_or_loss_ref OUT VARCHAR2
149896
149897 --TRANSACTION_ID
149898 , p_source_1 IN NUMBER
149899 --Item Concatenated Segments
149900 , p_source_2 IN VARCHAR2
149901 --Transaction Quantity
149902 , p_source_3 IN NUMBER
149903 --Transaction Unit of Measure Code
149904 , p_source_4 IN VARCHAR2
149905 --Inventory Transaction Type Description
149906 , p_source_5 IN VARCHAR2
149907 --Cost Element Name
149908 , p_source_15 IN NUMBER
149909 --Product Line Accounting Category Material Account
149910 , p_source_41 IN NUMBER
149911 --Product Line Accounting Category Material Overhead Account
149912 , p_source_42 IN NUMBER
149913 --Product Line Accounting Category Resource Account
149914 , p_source_43 IN NUMBER
149915 --Product Line Accounting Category Outside Processing Account
149916 , p_source_44 IN NUMBER
149917 --Product Line Accounting Category Overhead Account
149918 , p_source_45 IN NUMBER
149919 --DISTRIBUTION_IDENTIFIER
149920 , p_source_84 IN NUMBER
149921 --Distribution Type
149922 , p_source_85 IN VARCHAR2
149923 , p_source_85_meaning IN VARCHAR2
149924 --Entered Currency Code
149925 , p_source_88 IN VARCHAR2
149926 --Entered Amount
149927 , p_source_91 IN NUMBER
149928 --Currency Conversion Date
149929 , p_source_92 IN DATE
149930 --Currency Conversion Rate
149931 , p_source_93 IN NUMBER
149932 --Currency Conversion Type
149933 , p_source_94 IN VARCHAR2
149934 --Accounted Amount
149935 , p_source_95 IN NUMBER
149936 --Accounting Line Type
149937 , p_source_97 IN NUMBER
149938 --Organization Code
149939 , p_source_108 IN VARCHAR2
149940 )
149941 IS
149942
149943 l_component_type VARCHAR2(80);
149944 l_component_code VARCHAR2(30);
149945 l_component_type_code VARCHAR2(1);
149946 l_component_appl_id INTEGER;
149947 l_amb_context_code VARCHAR2(30);
149948 l_entity_code VARCHAR2(30);
149949 l_event_class_code VARCHAR2(30);
149950 l_ae_header_id NUMBER;
149951 l_event_type_code VARCHAR2(30);
149952 l_line_definition_code VARCHAR2(30);
149953 l_line_definition_owner_code VARCHAR2(1);
149954 --
149955 -- adr variables
149956 l_segment VARCHAR2(30);
149957 l_ccid NUMBER;
149958 l_adr_transaction_coa_id NUMBER;
149959 l_adr_accounting_coa_id NUMBER;
149960 l_adr_flexfield_segment_code VARCHAR2(30);
149961 l_adr_flex_value_set_id NUMBER;
149962 l_adr_value_type_code VARCHAR2(30);
149963 l_adr_value_combination_id NUMBER;
149964 l_adr_value_segment_code VARCHAR2(30);
149965
149966 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
149967 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
149968 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
149969 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
149970
149971 -- 4262811 Variables ------------------------------------------------------------------------------------------
149972 l_entered_amt_idx NUMBER;
149973 l_accted_amt_idx NUMBER;
149974 l_acc_rev_flag VARCHAR2(1);
149975 l_accrual_line_num NUMBER;
149976 l_tmp_amt NUMBER;
149977 l_acc_rev_natural_side_code VARCHAR2(1);
149978
149979 l_num_entries NUMBER;
149980 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
149981 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
149982 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
149983 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
149984 l_recog_line_1 NUMBER;
149985 l_recog_line_2 NUMBER;
149986
149987 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
149988 l_bflow_applied_to_amt NUMBER; -- 5132302
149989 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
149990
149991 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
149992
149993 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
149994 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
149995
149996 ---------------------------------------------------------------------------------------------------------------
149997
149998
149999 --
150000 -- bulk performance
150001 --
150002 l_balance_type_code VARCHAR2(1);
150003 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
150004 l_log_module VARCHAR2(240);
150005
150006 --
150007 -- Upgrade strategy
150008 --
150009 l_actual_upg_option VARCHAR2(1);
150010 l_enc_upg_option VARCHAR2(1);
150011
150012 --
150013 BEGIN
150014 --
150015 IF g_log_enabled THEN
150016 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_281';
150017 END IF;
150018 --
150019 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
150020
150021 trace
150022 (p_msg => 'BEGIN of AcctLineType_281'
150023 ,p_level => C_LEVEL_PROCEDURE
150024 ,p_module => l_log_module);
150025
150026 END IF;
150027 --
150028 l_component_type := 'AMB_JLT';
150029 l_component_code := 'INVENTORY_VALUATION';
150030 l_component_type_code := 'S';
150031 l_component_appl_id := 707;
150032 l_amb_context_code := 'DEFAULT';
150033 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
150034 l_event_class_code := 'SALES_ORDER';
150035 l_event_type_code := 'RMA_RCPT';
150036 l_line_definition_owner_code := 'S';
150037 l_line_definition_code := 'PI_RMA_RCPT';
150038 --
150039 l_balance_type_code := 'A';
150040 l_segment := NULL;
150041 l_ccid := NULL;
150042 l_adr_transaction_coa_id := NULL;
150043 l_adr_accounting_coa_id := NULL;
150044 l_adr_flexfield_segment_code := NULL;
150045 l_adr_flex_value_set_id := NULL;
150046 l_adr_value_type_code := NULL;
150047 l_adr_value_combination_id := NULL;
150048 l_adr_value_segment_code := NULL;
150049
150050 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
150051 l_bflow_class_code := ''; -- 4219869 Business Flow
150052 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
150053 l_budgetary_control_flag := 'N';
150054
150055 l_bflow_applied_to_amt_idx := NULL; -- 5132302
150056 l_bflow_applied_to_amt := NULL; -- 5132302
150057 l_entered_amt_idx := NULL; -- 4262811
150058 l_accted_amt_idx := NULL; -- 4262811
150059 l_acc_rev_flag := NULL; -- 4262811
150060 l_accrual_line_num := NULL; -- 4262811
150061 l_tmp_amt := NULL; -- 4262811
150062 --
150063
150064 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
150065 l_balance_type_code <> 'B' THEN
150066 IF NVL(p_source_97,9E125) = 1
150067 THEN
150068
150069 --
150070 XLA_AE_LINES_PKG.SetNewLine;
150071
150072 p_balance_type_code := l_balance_type_code;
150073 -- set the flag so later we will know whether the gain loss line needs to be created
150074
150075 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
150076 p_actual_flag :='A';
150077 END IF;
150078
150079 --
150080 -- bulk performance
150081 --
150082 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
150083 p_header_num => 0); -- 4262811
150084 --
150085 -- set accounting line options
150086 --
150087 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
150088 p_natural_side_code => 'D'
150089 , p_gain_or_loss_flag => 'N'
150090 , p_gl_transfer_mode_code => 'S'
150091 , p_acct_entry_type_code => 'A'
150092 , p_switch_side_flag => 'Y'
150093 , p_merge_duplicate_code => 'N'
150094 );
150095 --
150096 l_acc_rev_natural_side_code := 'C'; -- 4262811
150097 --
150098 --
150099 -- set accounting line type info
150100 --
150101 xla_ae_lines_pkg.SetAcctLineType
150102 (p_component_type => l_component_type
150103 ,p_event_type_code => l_event_type_code
150104 ,p_line_definition_owner_code => l_line_definition_owner_code
150105 ,p_line_definition_code => l_line_definition_code
150106 ,p_accounting_line_code => l_component_code
150107 ,p_accounting_line_type_code => l_component_type_code
150108 ,p_accounting_line_appl_id => l_component_appl_id
150109 ,p_amb_context_code => l_amb_context_code
150110 ,p_entity_code => l_entity_code
150111 ,p_event_class_code => l_event_class_code);
150112 --
150113 -- set accounting class
150114 --
150115 xla_ae_lines_pkg.SetAcctClass(
150116 p_accounting_class_code => 'INVENTORY_VALUATION'
150117 , p_ae_header_id => l_ae_header_id
150118 );
150119
150120 --
150121 -- set rounding class
150122 --
150123 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
150124 'INVENTORY_VALUATION';
150125
150126 --
150127 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
150128 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
150129 --
150130 -- bulk performance
150131 --
150132 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
150133
150134 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
150135 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
150136
150137 -- 4955764
150138 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
150139 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
150140
150141 -- 4458381 Public Sector Enh
150142
150143 --
150144 -- set accounting attributes for the line type
150145 --
150146 l_entered_amt_idx := 3;
150147 l_accted_amt_idx := 8;
150148 l_bflow_applied_to_amt_idx := NULL; -- 5132302
150149 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
150150 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
150151 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
150152 l_rec_acct_attrs.array_char_value(2) := p_source_85;
150153 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
150154 l_rec_acct_attrs.array_num_value(3) := p_source_91;
150155 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
150156 l_rec_acct_attrs.array_char_value(4) := p_source_88;
150157 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
150158 l_rec_acct_attrs.array_date_value(5) := p_source_92;
150159 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
150160 l_rec_acct_attrs.array_num_value(6) := p_source_93;
150161 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
150162 l_rec_acct_attrs.array_char_value(7) := p_source_94;
150163 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
150164 l_rec_acct_attrs.array_num_value(8) := p_source_95;
150165
150166 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
150167 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
150168
150169 ---------------------------------------------------------------------------------------------------------------
150170 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
150171 ---------------------------------------------------------------------------------------------------------------
150172 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
150173
150174 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
150175 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
150176
150177 IF xla_accounting_cache_pkg.GetValueChar
150178 (p_source_code => 'LEDGER_CATEGORY_CODE'
150179 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
150180 AND l_bflow_method_code = 'PRIOR_ENTRY'
150181 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
150182 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
150183 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
150184 )
150185 THEN
150186 xla_ae_lines_pkg.BflowUpgEntry
150187 (p_business_method_code => l_bflow_method_code
150188 ,p_business_class_code => l_bflow_class_code
150189 ,p_balance_type => l_balance_type_code);
150190 ELSE
150191 NULL;
150192 -- No business flow processing for business flow method of NONE.
150193 END IF;
150194
150195 --
150196 -- call analytical criteria
150197 --
150198
150199
150200 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
150201 xla_ae_lines_pkg.SetAnalyticalCriteria(
150202 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
150203 , p_analytical_criterion_owner => 'S'
150204 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
150205 , p_amb_context_code => 'DEFAULT'
150206 , p_balancing_flag => 'Y'
150207
150208 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
150209 , p_analytical_detail_num_1 => NULL
150210 , p_analytical_detail_date_1 => NULL
150211
150212 , p_ae_header_id => l_ae_header_id
150213 )
150214 ;
150215 --
150216
150217 --
150218 -- call description
150219 --
150220
150221 xla_ae_lines_pkg.SetLineDescription(
150222 p_ae_header_id => l_ae_header_id
150223 ,p_description => Description_1 (
150224 p_application_id => p_application_id
150225 , p_ae_header_id => l_ae_header_id
150226 , p_source_1 => p_source_1
150227 , p_source_2 => p_source_2
150228 , p_source_3 => p_source_3
150229 , p_source_4 => p_source_4
150230 , p_source_5 => p_source_5
150231 )
150232 );
150233
150234
150235 --
150236 -- call ADRs
150237 -- Bug 4922099
150238 --
150239 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
150240 (NVL(l_actual_upg_option, 'N') = 'O') OR
150241 (NVL(l_enc_upg_option, 'N') = 'O')
150242 )
150243 THEN
150244 NULL;
150245 --
150246 --
150247
150248 l_ccid := AcctDerRule_28(
150249 p_application_id => p_application_id
150250 , p_ae_header_id => l_ae_header_id
150251 , p_source_15 => p_source_15
150252 , p_source_41 => p_source_41
150253 , p_source_42 => p_source_42
150254 , p_source_43 => p_source_43
150255 , p_source_44 => p_source_44
150256 , p_source_45 => p_source_45
150257 , x_transaction_coa_id => l_adr_transaction_coa_id
150258 , x_accounting_coa_id => l_adr_accounting_coa_id
150259 , x_value_type_code => l_adr_value_type_code
150260 , p_side => 'NA'
150261 );
150262
150263 xla_ae_lines_pkg.set_ccid(
150264 p_code_combination_id => l_ccid
150265 , p_value_type_code => l_adr_value_type_code
150266 , p_transaction_coa_id => l_adr_transaction_coa_id
150267 , p_accounting_coa_id => l_adr_accounting_coa_id
150268 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
150269 , p_adr_type_code => 'S'
150270 , p_component_type => l_component_type
150271 , p_component_code => l_component_code
150272 , p_component_type_code => l_component_type_code
150273 , p_component_appl_id => l_component_appl_id
150274 , p_amb_context_code => l_amb_context_code
150275 , p_side => 'NA'
150276 );
150277
150278
150279 --
150280 --
150281 END IF;
150282 --
150283 -- Bug 4922099
150284 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
150285 (NVL(l_enc_upg_option, 'N') = 'O')
150286 ) AND
150287 (l_bflow_method_code = 'PRIOR_ENTRY')
150288 )
150289 THEN
150290 IF
150291 --
150292 1 = 2
150293 --
150294 THEN
150295 xla_accounting_err_pkg.build_message
150296 (p_appli_s_name => 'XLA'
150297 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
150298 ,p_token_1 => 'LINE_NUMBER'
150299 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
150300 ,p_token_2 => 'LINE_TYPE_NAME'
150301 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
150302 l_component_type
150303 ,l_component_code
150304 ,l_component_type_code
150305 ,l_component_appl_id
150306 ,l_amb_context_code
150307 ,l_entity_code
150308 ,l_event_class_code
150309 )
150310 ,p_token_3 => 'OWNER'
150311 ,p_value_3 => xla_lookups_pkg.get_meaning(
150312 p_lookup_type => 'XLA_OWNER_TYPE'
150313 ,p_lookup_code => l_component_type_code
150314 )
150315 ,p_token_4 => 'PRODUCT_NAME'
150316 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
150317 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
150318 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
150319 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
150320 ,p_ae_header_id => NULL
150321 );
150322
150323 IF (C_LEVEL_ERROR>= g_log_level) THEN
150324 trace
150325 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
150326 ,p_level => C_LEVEL_ERROR
150327 ,p_module => l_log_module);
150328 END IF;
150329 END IF;
150330 END IF;
150331 --
150332 --
150333 ------------------------------------------------------------------------------------------------
150334 -- 4219869 Business Flow
150335 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
150336 -- Prior Entry. Currently, the following code is always generated.
150337 ------------------------------------------------------------------------------------------------
150338 XLA_AE_LINES_PKG.ValidateCurrentLine;
150339
150340 ------------------------------------------------------------------------------------
150341 -- 4219869 Business Flow
150342 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
150343 ------------------------------------------------------------------------------------
150344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
150345
150346 ----------------------------------------------------------------------------------
150347 -- 4219869 Business Flow
150348 -- Update journal entry status -- Need to generate this within IF <condition>
150349 ----------------------------------------------------------------------------------
150350 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
150351 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
150352 ,p_balance_type_code => l_balance_type_code
150353 );
150354
150355 -------------------------------------------------------------------------------------------
150356 -- 4262811 - Generate the Accrual Reversal lines
150357 -------------------------------------------------------------------------------------------
150358 BEGIN
150359 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
150360 (g_array_event(p_event_id).array_value_num('header_index'));
150361 IF l_acc_rev_flag IS NULL THEN
150362 l_acc_rev_flag := 'N';
150363 END IF;
150364 EXCEPTION
150365 WHEN OTHERS THEN
150366 l_acc_rev_flag := 'N';
150367 END;
150368 --
150369 IF (l_acc_rev_flag = 'Y') THEN
150370
150371 -- 4645092 ------------------------------------------------------------------------------
150372 -- To allow MPA report to determine if it should generate report process
150373 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
150374 ------------------------------------------------------------------------------------------
150375
150376 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
150377 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
150378 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
150379 -- call ADRs
150380 -- Bug 4922099
150381 --
150382 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
150383 (NVL(l_actual_upg_option, 'N') = 'O') OR
150384 (NVL(l_enc_upg_option, 'N') = 'O')
150385 )
150386 THEN
150387 NULL;
150388 --
150389 --
150390
150391 l_ccid := AcctDerRule_28(
150392 p_application_id => p_application_id
150393 , p_ae_header_id => l_ae_header_id
150394 , p_source_15 => p_source_15
150395 , p_source_41 => p_source_41
150396 , p_source_42 => p_source_42
150397 , p_source_43 => p_source_43
150398 , p_source_44 => p_source_44
150399 , p_source_45 => p_source_45
150400 , x_transaction_coa_id => l_adr_transaction_coa_id
150401 , x_accounting_coa_id => l_adr_accounting_coa_id
150402 , x_value_type_code => l_adr_value_type_code
150403 , p_side => 'NA'
150404 );
150405
150406 xla_ae_lines_pkg.set_ccid(
150407 p_code_combination_id => l_ccid
150408 , p_value_type_code => l_adr_value_type_code
150409 , p_transaction_coa_id => l_adr_transaction_coa_id
150410 , p_accounting_coa_id => l_adr_accounting_coa_id
150411 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
150412 , p_adr_type_code => 'S'
150413 , p_component_type => l_component_type
150414 , p_component_code => l_component_code
150415 , p_component_type_code => l_component_type_code
150416 , p_component_appl_id => l_component_appl_id
150417 , p_amb_context_code => l_amb_context_code
150418 , p_side => 'NA'
150419 );
150420
150421
150422 --
150423 --
150424 END IF;
150425
150426 --
150427 -- Update the line information that should be overwritten
150428 --
150429 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
150430 p_header_num => 1);
150431 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
150432
150433 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
150434
150435 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
150436 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
150437 END IF;
150438
150439 --
150440 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
150441 --
150442 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
150443 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
150444 ELSE
150445 ---------------------------------------------------------------------------------------------------
150446 -- 4262811a Switch Sign
150447 ---------------------------------------------------------------------------------------------------
150448 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
150449 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
150450 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
150451 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
150452 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
150453 -- 5132302
150454 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
150455 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
150456
150457 END IF;
150458
150459 -- 4955764
150460 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
150461 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
150462
150463
150464 XLA_AE_LINES_PKG.ValidateCurrentLine;
150465 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
150466
150467 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
150468 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
150469 ,p_balance_type_code => l_balance_type_code);
150470
150471 END IF;
150472
150473 -----------------------------------------------------------------------------------------
150474 -- 4262811 Multiperiod Accounting
150475 -----------------------------------------------------------------------------------------
150476 -- No MPA option is assigned.
150477
150478
150479 END IF;
150480 END IF;
150481 --
150482
150483 --
150484 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
150485 trace
150486 (p_msg => 'END of AcctLineType_281'
150487 ,p_level => C_LEVEL_PROCEDURE
150488 ,p_module => l_log_module);
150489 END IF;
150490 --
150491 EXCEPTION
150492 WHEN xla_exceptions_pkg.application_exception THEN
150493 RAISE;
150494 WHEN OTHERS THEN
150495 xla_exceptions_pkg.raise_message
150496 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_281');
150497 END AcctLineType_281;
150498 --
150499
150500 ---------------------------------------
150501 --
150502 -- PRIVATE FUNCTION
150503 -- AcctLineType_282
150504 --
150505 ---------------------------------------
150506 PROCEDURE AcctLineType_282 (
150507 p_application_id IN NUMBER
150508 ,p_event_id IN NUMBER
150509 ,p_calculate_acctd_flag IN VARCHAR2
150510 ,p_calculate_g_l_flag IN VARCHAR2
150511 ,p_actual_flag IN OUT VARCHAR2
150512 ,p_balance_type_code OUT VARCHAR2
150513 ,p_gain_or_loss_ref OUT VARCHAR2
150514
150515 --TRANSACTION_ID
150516 , p_source_1 IN NUMBER
150517 --Item Concatenated Segments
150518 , p_source_2 IN VARCHAR2
150519 --Transaction Quantity
150520 , p_source_3 IN NUMBER
150521 --Transaction Unit of Measure Code
150522 , p_source_4 IN VARCHAR2
150523 --Inventory Transaction Type Description
150524 , p_source_5 IN VARCHAR2
150525 --Cost Element Name
150526 , p_source_15 IN NUMBER
150527 --Product Line Accounting Category Material Account
150528 , p_source_41 IN NUMBER
150529 --Product Line Accounting Category Material Overhead Account
150530 , p_source_42 IN NUMBER
150531 --Product Line Accounting Category Resource Account
150532 , p_source_43 IN NUMBER
150533 --Product Line Accounting Category Outside Processing Account
150534 , p_source_44 IN NUMBER
150535 --Product Line Accounting Category Overhead Account
150536 , p_source_45 IN NUMBER
150537 --DISTRIBUTION_IDENTIFIER
150538 , p_source_84 IN NUMBER
150539 --Distribution Type
150540 , p_source_85 IN VARCHAR2
150541 , p_source_85_meaning IN VARCHAR2
150542 --Entered Currency Code
150543 , p_source_88 IN VARCHAR2
150544 --Entered Amount
150545 , p_source_91 IN NUMBER
150546 --Currency Conversion Date
150547 , p_source_92 IN DATE
150548 --Currency Conversion Rate
150549 , p_source_93 IN NUMBER
150550 --Currency Conversion Type
150551 , p_source_94 IN VARCHAR2
150552 --Accounted Amount
150553 , p_source_95 IN NUMBER
150554 --Accounting Line Type
150555 , p_source_97 IN NUMBER
150556 --Organization Code
150557 , p_source_108 IN VARCHAR2
150558 )
150559 IS
150560
150561 l_component_type VARCHAR2(80);
150562 l_component_code VARCHAR2(30);
150563 l_component_type_code VARCHAR2(1);
150564 l_component_appl_id INTEGER;
150565 l_amb_context_code VARCHAR2(30);
150566 l_entity_code VARCHAR2(30);
150567 l_event_class_code VARCHAR2(30);
150568 l_ae_header_id NUMBER;
150569 l_event_type_code VARCHAR2(30);
150570 l_line_definition_code VARCHAR2(30);
150571 l_line_definition_owner_code VARCHAR2(1);
150572 --
150573 -- adr variables
150574 l_segment VARCHAR2(30);
150575 l_ccid NUMBER;
150576 l_adr_transaction_coa_id NUMBER;
150577 l_adr_accounting_coa_id NUMBER;
150578 l_adr_flexfield_segment_code VARCHAR2(30);
150579 l_adr_flex_value_set_id NUMBER;
150580 l_adr_value_type_code VARCHAR2(30);
150581 l_adr_value_combination_id NUMBER;
150582 l_adr_value_segment_code VARCHAR2(30);
150583
150584 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
150585 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
150586 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
150587 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
150588
150589 -- 4262811 Variables ------------------------------------------------------------------------------------------
150590 l_entered_amt_idx NUMBER;
150591 l_accted_amt_idx NUMBER;
150592 l_acc_rev_flag VARCHAR2(1);
150593 l_accrual_line_num NUMBER;
150594 l_tmp_amt NUMBER;
150595 l_acc_rev_natural_side_code VARCHAR2(1);
150596
150597 l_num_entries NUMBER;
150598 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
150599 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
150600 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
150601 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
150602 l_recog_line_1 NUMBER;
150603 l_recog_line_2 NUMBER;
150604
150605 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
150606 l_bflow_applied_to_amt NUMBER; -- 5132302
150607 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
150608
150609 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
150610
150611 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
150612 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
150613
150614 ---------------------------------------------------------------------------------------------------------------
150615
150616
150617 --
150618 -- bulk performance
150619 --
150620 l_balance_type_code VARCHAR2(1);
150621 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
150622 l_log_module VARCHAR2(240);
150623
150624 --
150625 -- Upgrade strategy
150626 --
150627 l_actual_upg_option VARCHAR2(1);
150628 l_enc_upg_option VARCHAR2(1);
150629
150630 --
150631 BEGIN
150632 --
150633 IF g_log_enabled THEN
150634 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_282';
150635 END IF;
150636 --
150637 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
150638
150639 trace
150640 (p_msg => 'BEGIN of AcctLineType_282'
150641 ,p_level => C_LEVEL_PROCEDURE
150642 ,p_module => l_log_module);
150643
150644 END IF;
150645 --
150646 l_component_type := 'AMB_JLT';
150647 l_component_code := 'INVENTORY_VALUATION';
150648 l_component_type_code := 'S';
150649 l_component_appl_id := 707;
150650 l_amb_context_code := 'DEFAULT';
150651 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
150652 l_event_class_code := 'USER_DEFINE';
150653 l_event_type_code := 'UDIR_INTERORG_SHIP';
150654 l_line_definition_owner_code := 'S';
150655 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
150656 --
150657 l_balance_type_code := 'A';
150658 l_segment := NULL;
150659 l_ccid := NULL;
150660 l_adr_transaction_coa_id := NULL;
150661 l_adr_accounting_coa_id := NULL;
150662 l_adr_flexfield_segment_code := NULL;
150663 l_adr_flex_value_set_id := NULL;
150664 l_adr_value_type_code := NULL;
150665 l_adr_value_combination_id := NULL;
150666 l_adr_value_segment_code := NULL;
150667
150668 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
150669 l_bflow_class_code := ''; -- 4219869 Business Flow
150670 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
150671 l_budgetary_control_flag := 'N';
150672
150673 l_bflow_applied_to_amt_idx := NULL; -- 5132302
150674 l_bflow_applied_to_amt := NULL; -- 5132302
150675 l_entered_amt_idx := NULL; -- 4262811
150676 l_accted_amt_idx := NULL; -- 4262811
150677 l_acc_rev_flag := NULL; -- 4262811
150678 l_accrual_line_num := NULL; -- 4262811
150679 l_tmp_amt := NULL; -- 4262811
150680 --
150681
150682 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
150683 l_balance_type_code <> 'B' THEN
150684 IF NVL(p_source_97,9E125) = 1
150685 THEN
150686
150687 --
150688 XLA_AE_LINES_PKG.SetNewLine;
150689
150690 p_balance_type_code := l_balance_type_code;
150691 -- set the flag so later we will know whether the gain loss line needs to be created
150692
150693 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
150694 p_actual_flag :='A';
150695 END IF;
150696
150697 --
150698 -- bulk performance
150699 --
150700 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
150701 p_header_num => 0); -- 4262811
150702 --
150703 -- set accounting line options
150704 --
150705 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
150706 p_natural_side_code => 'D'
150707 , p_gain_or_loss_flag => 'N'
150708 , p_gl_transfer_mode_code => 'S'
150709 , p_acct_entry_type_code => 'A'
150710 , p_switch_side_flag => 'Y'
150711 , p_merge_duplicate_code => 'N'
150712 );
150713 --
150714 l_acc_rev_natural_side_code := 'C'; -- 4262811
150715 --
150716 --
150717 -- set accounting line type info
150718 --
150719 xla_ae_lines_pkg.SetAcctLineType
150720 (p_component_type => l_component_type
150721 ,p_event_type_code => l_event_type_code
150722 ,p_line_definition_owner_code => l_line_definition_owner_code
150723 ,p_line_definition_code => l_line_definition_code
150724 ,p_accounting_line_code => l_component_code
150725 ,p_accounting_line_type_code => l_component_type_code
150726 ,p_accounting_line_appl_id => l_component_appl_id
150727 ,p_amb_context_code => l_amb_context_code
150728 ,p_entity_code => l_entity_code
150729 ,p_event_class_code => l_event_class_code);
150730 --
150731 -- set accounting class
150732 --
150733 xla_ae_lines_pkg.SetAcctClass(
150734 p_accounting_class_code => 'INVENTORY_VALUATION'
150735 , p_ae_header_id => l_ae_header_id
150736 );
150737
150738 --
150739 -- set rounding class
150740 --
150741 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
150742 'INVENTORY_VALUATION';
150743
150744 --
150745 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
150746 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
150747 --
150748 -- bulk performance
150749 --
150750 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
150751
150752 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
150753 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
150754
150755 -- 4955764
150756 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
150757 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
150758
150759 -- 4458381 Public Sector Enh
150760
150761 --
150762 -- set accounting attributes for the line type
150763 --
150764 l_entered_amt_idx := 3;
150765 l_accted_amt_idx := 8;
150766 l_bflow_applied_to_amt_idx := NULL; -- 5132302
150767 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
150768 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
150769 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
150770 l_rec_acct_attrs.array_char_value(2) := p_source_85;
150771 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
150772 l_rec_acct_attrs.array_num_value(3) := p_source_91;
150773 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
150774 l_rec_acct_attrs.array_char_value(4) := p_source_88;
150775 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
150776 l_rec_acct_attrs.array_date_value(5) := p_source_92;
150777 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
150778 l_rec_acct_attrs.array_num_value(6) := p_source_93;
150779 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
150780 l_rec_acct_attrs.array_char_value(7) := p_source_94;
150781 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
150782 l_rec_acct_attrs.array_num_value(8) := p_source_95;
150783
150784 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
150785 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
150786
150787 ---------------------------------------------------------------------------------------------------------------
150788 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
150789 ---------------------------------------------------------------------------------------------------------------
150790 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
150791
150792 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
150793 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
150794
150795 IF xla_accounting_cache_pkg.GetValueChar
150796 (p_source_code => 'LEDGER_CATEGORY_CODE'
150797 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
150798 AND l_bflow_method_code = 'PRIOR_ENTRY'
150799 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
150800 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
150801 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
150802 )
150803 THEN
150804 xla_ae_lines_pkg.BflowUpgEntry
150805 (p_business_method_code => l_bflow_method_code
150806 ,p_business_class_code => l_bflow_class_code
150807 ,p_balance_type => l_balance_type_code);
150808 ELSE
150809 NULL;
150810 -- No business flow processing for business flow method of NONE.
150811 END IF;
150812
150813 --
150814 -- call analytical criteria
150815 --
150816
150817
150818 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
150819 xla_ae_lines_pkg.SetAnalyticalCriteria(
150820 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
150821 , p_analytical_criterion_owner => 'S'
150822 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
150823 , p_amb_context_code => 'DEFAULT'
150824 , p_balancing_flag => 'Y'
150825
150826 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
150827 , p_analytical_detail_num_1 => NULL
150828 , p_analytical_detail_date_1 => NULL
150829
150830 , p_ae_header_id => l_ae_header_id
150831 )
150832 ;
150833 --
150834
150835 --
150836 -- call description
150837 --
150838
150839 xla_ae_lines_pkg.SetLineDescription(
150840 p_ae_header_id => l_ae_header_id
150841 ,p_description => Description_1 (
150842 p_application_id => p_application_id
150843 , p_ae_header_id => l_ae_header_id
150844 , p_source_1 => p_source_1
150845 , p_source_2 => p_source_2
150846 , p_source_3 => p_source_3
150847 , p_source_4 => p_source_4
150848 , p_source_5 => p_source_5
150849 )
150850 );
150851
150852
150853 --
150854 -- call ADRs
150855 -- Bug 4922099
150856 --
150857 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
150858 (NVL(l_actual_upg_option, 'N') = 'O') OR
150859 (NVL(l_enc_upg_option, 'N') = 'O')
150860 )
150861 THEN
150862 NULL;
150863 --
150864 --
150865
150866 l_ccid := AcctDerRule_28(
150867 p_application_id => p_application_id
150868 , p_ae_header_id => l_ae_header_id
150869 , p_source_15 => p_source_15
150870 , p_source_41 => p_source_41
150871 , p_source_42 => p_source_42
150872 , p_source_43 => p_source_43
150873 , p_source_44 => p_source_44
150874 , p_source_45 => p_source_45
150875 , x_transaction_coa_id => l_adr_transaction_coa_id
150876 , x_accounting_coa_id => l_adr_accounting_coa_id
150877 , x_value_type_code => l_adr_value_type_code
150878 , p_side => 'NA'
150879 );
150880
150881 xla_ae_lines_pkg.set_ccid(
150882 p_code_combination_id => l_ccid
150883 , p_value_type_code => l_adr_value_type_code
150884 , p_transaction_coa_id => l_adr_transaction_coa_id
150885 , p_accounting_coa_id => l_adr_accounting_coa_id
150886 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
150887 , p_adr_type_code => 'S'
150888 , p_component_type => l_component_type
150889 , p_component_code => l_component_code
150890 , p_component_type_code => l_component_type_code
150891 , p_component_appl_id => l_component_appl_id
150892 , p_amb_context_code => l_amb_context_code
150893 , p_side => 'NA'
150894 );
150895
150896
150897 --
150898 --
150899 END IF;
150900 --
150901 -- Bug 4922099
150902 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
150903 (NVL(l_enc_upg_option, 'N') = 'O')
150904 ) AND
150905 (l_bflow_method_code = 'PRIOR_ENTRY')
150906 )
150907 THEN
150908 IF
150909 --
150910 1 = 2
150911 --
150912 THEN
150913 xla_accounting_err_pkg.build_message
150914 (p_appli_s_name => 'XLA'
150915 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
150916 ,p_token_1 => 'LINE_NUMBER'
150917 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
150918 ,p_token_2 => 'LINE_TYPE_NAME'
150919 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
150920 l_component_type
150921 ,l_component_code
150922 ,l_component_type_code
150923 ,l_component_appl_id
150924 ,l_amb_context_code
150925 ,l_entity_code
150926 ,l_event_class_code
150927 )
150928 ,p_token_3 => 'OWNER'
150929 ,p_value_3 => xla_lookups_pkg.get_meaning(
150930 p_lookup_type => 'XLA_OWNER_TYPE'
150931 ,p_lookup_code => l_component_type_code
150932 )
150933 ,p_token_4 => 'PRODUCT_NAME'
150934 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
150935 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
150936 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
150937 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
150938 ,p_ae_header_id => NULL
150939 );
150940
150941 IF (C_LEVEL_ERROR>= g_log_level) THEN
150942 trace
150943 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
150944 ,p_level => C_LEVEL_ERROR
150945 ,p_module => l_log_module);
150946 END IF;
150947 END IF;
150948 END IF;
150949 --
150950 --
150951 ------------------------------------------------------------------------------------------------
150952 -- 4219869 Business Flow
150953 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
150954 -- Prior Entry. Currently, the following code is always generated.
150955 ------------------------------------------------------------------------------------------------
150956 XLA_AE_LINES_PKG.ValidateCurrentLine;
150957
150958 ------------------------------------------------------------------------------------
150959 -- 4219869 Business Flow
150960 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
150961 ------------------------------------------------------------------------------------
150962 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
150963
150964 ----------------------------------------------------------------------------------
150965 -- 4219869 Business Flow
150966 -- Update journal entry status -- Need to generate this within IF <condition>
150967 ----------------------------------------------------------------------------------
150968 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
150969 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
150970 ,p_balance_type_code => l_balance_type_code
150971 );
150972
150973 -------------------------------------------------------------------------------------------
150974 -- 4262811 - Generate the Accrual Reversal lines
150975 -------------------------------------------------------------------------------------------
150976 BEGIN
150977 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
150978 (g_array_event(p_event_id).array_value_num('header_index'));
150979 IF l_acc_rev_flag IS NULL THEN
150980 l_acc_rev_flag := 'N';
150981 END IF;
150982 EXCEPTION
150983 WHEN OTHERS THEN
150984 l_acc_rev_flag := 'N';
150985 END;
150986 --
150987 IF (l_acc_rev_flag = 'Y') THEN
150988
150989 -- 4645092 ------------------------------------------------------------------------------
150990 -- To allow MPA report to determine if it should generate report process
150991 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
150992 ------------------------------------------------------------------------------------------
150993
150994 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
150995 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
150996 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
150997 -- call ADRs
150998 -- Bug 4922099
150999 --
151000 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
151001 (NVL(l_actual_upg_option, 'N') = 'O') OR
151002 (NVL(l_enc_upg_option, 'N') = 'O')
151003 )
151004 THEN
151005 NULL;
151006 --
151007 --
151008
151009 l_ccid := AcctDerRule_28(
151010 p_application_id => p_application_id
151011 , p_ae_header_id => l_ae_header_id
151012 , p_source_15 => p_source_15
151013 , p_source_41 => p_source_41
151014 , p_source_42 => p_source_42
151015 , p_source_43 => p_source_43
151016 , p_source_44 => p_source_44
151017 , p_source_45 => p_source_45
151018 , x_transaction_coa_id => l_adr_transaction_coa_id
151019 , x_accounting_coa_id => l_adr_accounting_coa_id
151020 , x_value_type_code => l_adr_value_type_code
151021 , p_side => 'NA'
151022 );
151023
151024 xla_ae_lines_pkg.set_ccid(
151025 p_code_combination_id => l_ccid
151026 , p_value_type_code => l_adr_value_type_code
151027 , p_transaction_coa_id => l_adr_transaction_coa_id
151028 , p_accounting_coa_id => l_adr_accounting_coa_id
151029 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
151030 , p_adr_type_code => 'S'
151031 , p_component_type => l_component_type
151032 , p_component_code => l_component_code
151033 , p_component_type_code => l_component_type_code
151034 , p_component_appl_id => l_component_appl_id
151035 , p_amb_context_code => l_amb_context_code
151036 , p_side => 'NA'
151037 );
151038
151039
151040 --
151041 --
151042 END IF;
151043
151044 --
151045 -- Update the line information that should be overwritten
151046 --
151047 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
151048 p_header_num => 1);
151049 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
151050
151051 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
151052
151053 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
151054 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
151055 END IF;
151056
151057 --
151058 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
151059 --
151060 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
151061 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
151062 ELSE
151063 ---------------------------------------------------------------------------------------------------
151064 -- 4262811a Switch Sign
151065 ---------------------------------------------------------------------------------------------------
151066 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
151067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
151068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
151070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151071 -- 5132302
151072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
151073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151074
151075 END IF;
151076
151077 -- 4955764
151078 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
151079 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
151080
151081
151082 XLA_AE_LINES_PKG.ValidateCurrentLine;
151083 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
151084
151085 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
151086 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
151087 ,p_balance_type_code => l_balance_type_code);
151088
151089 END IF;
151090
151091 -----------------------------------------------------------------------------------------
151092 -- 4262811 Multiperiod Accounting
151093 -----------------------------------------------------------------------------------------
151094 -- No MPA option is assigned.
151095
151096
151097 END IF;
151098 END IF;
151099 --
151100
151101 --
151102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
151103 trace
151104 (p_msg => 'END of AcctLineType_282'
151105 ,p_level => C_LEVEL_PROCEDURE
151106 ,p_module => l_log_module);
151107 END IF;
151108 --
151109 EXCEPTION
151110 WHEN xla_exceptions_pkg.application_exception THEN
151111 RAISE;
151112 WHEN OTHERS THEN
151113 xla_exceptions_pkg.raise_message
151114 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_282');
151115 END AcctLineType_282;
151116 --
151117
151118 ---------------------------------------
151119 --
151120 -- PRIVATE FUNCTION
151121 -- AcctLineType_283
151122 --
151123 ---------------------------------------
151124 PROCEDURE AcctLineType_283 (
151125 p_application_id IN NUMBER
151126 ,p_event_id IN NUMBER
151127 ,p_calculate_acctd_flag IN VARCHAR2
151128 ,p_calculate_g_l_flag IN VARCHAR2
151129 ,p_actual_flag IN OUT VARCHAR2
151130 ,p_balance_type_code OUT VARCHAR2
151131 ,p_gain_or_loss_ref OUT VARCHAR2
151132
151133 --TRANSACTION_ID
151134 , p_source_1 IN NUMBER
151135 --Item Concatenated Segments
151136 , p_source_2 IN VARCHAR2
151137 --Transaction Quantity
151138 , p_source_3 IN NUMBER
151139 --Transaction Unit of Measure Code
151140 , p_source_4 IN VARCHAR2
151141 --Inventory Transaction Type Description
151142 , p_source_5 IN VARCHAR2
151143 --Cost Element Name
151144 , p_source_15 IN NUMBER
151145 --Product Line Accounting Category Material Account
151146 , p_source_41 IN NUMBER
151147 --Product Line Accounting Category Material Overhead Account
151148 , p_source_42 IN NUMBER
151149 --Product Line Accounting Category Resource Account
151150 , p_source_43 IN NUMBER
151151 --Product Line Accounting Category Outside Processing Account
151152 , p_source_44 IN NUMBER
151153 --Product Line Accounting Category Overhead Account
151154 , p_source_45 IN NUMBER
151155 --Applied to Application ID
151156 , p_source_79 IN NUMBER
151157 --Applied to Distribution Link Type
151158 , p_source_80 IN VARCHAR2
151159 --Applied to Entity Code
151160 , p_source_81 IN VARCHAR2
151161 --DISTRIBUTION_IDENTIFIER
151162 , p_source_84 IN NUMBER
151163 --Distribution Type
151164 , p_source_85 IN VARCHAR2
151165 , p_source_85_meaning IN VARCHAR2
151166 --Encumbrance Reversal Amount Entered
151167 , p_source_87 IN NUMBER
151168 --Entered Currency Code
151169 , p_source_88 IN VARCHAR2
151170 --Transaction Encumbrance Reversal Amount
151171 , p_source_89 IN NUMBER
151172 --Entered Amount
151173 , p_source_91 IN NUMBER
151174 --Currency Conversion Date
151175 , p_source_92 IN DATE
151176 --Currency Conversion Rate
151177 , p_source_93 IN NUMBER
151178 --Currency Conversion Type
151179 , p_source_94 IN VARCHAR2
151180 --Accounted Amount
151181 , p_source_95 IN NUMBER
151182 --Accounting Line Type
151183 , p_source_97 IN NUMBER
151184 --Costing Encumbrance Upgrade Option
151185 , p_source_100 IN VARCHAR2
151186 --TXN_PO_DISTRIBUTION_ID
151187 , p_source_101 IN NUMBER
151188 --TXN_PO_HEADER_ID
151189 , p_source_102 IN NUMBER
151190 --Requisition Budget Account
151191 , p_source_103 IN NUMBER
151192 --Requisition Encumbrance Type Identifier
151193 , p_source_104 IN NUMBER
151194 --Organization Code
151195 , p_source_108 IN VARCHAR2
151196 )
151197 IS
151198
151199 l_component_type VARCHAR2(80);
151200 l_component_code VARCHAR2(30);
151201 l_component_type_code VARCHAR2(1);
151202 l_component_appl_id INTEGER;
151203 l_amb_context_code VARCHAR2(30);
151204 l_entity_code VARCHAR2(30);
151205 l_event_class_code VARCHAR2(30);
151206 l_ae_header_id NUMBER;
151207 l_event_type_code VARCHAR2(30);
151208 l_line_definition_code VARCHAR2(30);
151209 l_line_definition_owner_code VARCHAR2(1);
151210 --
151211 -- adr variables
151212 l_segment VARCHAR2(30);
151213 l_ccid NUMBER;
151214 l_adr_transaction_coa_id NUMBER;
151215 l_adr_accounting_coa_id NUMBER;
151216 l_adr_flexfield_segment_code VARCHAR2(30);
151217 l_adr_flex_value_set_id NUMBER;
151218 l_adr_value_type_code VARCHAR2(30);
151219 l_adr_value_combination_id NUMBER;
151220 l_adr_value_segment_code VARCHAR2(30);
151221
151222 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
151223 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
151224 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
151225 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
151226
151227 -- 4262811 Variables ------------------------------------------------------------------------------------------
151228 l_entered_amt_idx NUMBER;
151229 l_accted_amt_idx NUMBER;
151230 l_acc_rev_flag VARCHAR2(1);
151231 l_accrual_line_num NUMBER;
151232 l_tmp_amt NUMBER;
151233 l_acc_rev_natural_side_code VARCHAR2(1);
151234
151235 l_num_entries NUMBER;
151236 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
151237 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
151238 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
151239 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
151240 l_recog_line_1 NUMBER;
151241 l_recog_line_2 NUMBER;
151242
151243 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
151244 l_bflow_applied_to_amt NUMBER; -- 5132302
151245 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
151246
151247 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
151248
151249 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
151250 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
151251
151252 ---------------------------------------------------------------------------------------------------------------
151253
151254
151255 --
151256 -- bulk performance
151257 --
151258 l_balance_type_code VARCHAR2(1);
151259 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
151260 l_log_module VARCHAR2(240);
151261
151262 --
151263 -- Upgrade strategy
151264 --
151265 l_actual_upg_option VARCHAR2(1);
151266 l_enc_upg_option VARCHAR2(1);
151267
151268 --
151269 BEGIN
151270 --
151271 IF g_log_enabled THEN
151272 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_283';
151273 END IF;
151274 --
151275 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
151276
151277 trace
151278 (p_msg => 'BEGIN of AcctLineType_283'
151279 ,p_level => C_LEVEL_PROCEDURE
151280 ,p_module => l_log_module);
151281
151282 END IF;
151283 --
151284 l_component_type := 'AMB_JLT';
151285 l_component_code := 'INVENTORY_VALUATION';
151286 l_component_type_code := 'S';
151287 l_component_appl_id := 707;
151288 l_amb_context_code := 'DEFAULT';
151289 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
151290 l_event_class_code := 'FOB_SHIP_RECIPIENT_RCPT';
151291 l_event_type_code := 'FOB_SHIP_RECIPIENT_RCPT';
151292 l_line_definition_owner_code := 'S';
151293 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_RCPT';
151294 --
151295 l_balance_type_code := 'A';
151296 l_segment := NULL;
151297 l_ccid := NULL;
151298 l_adr_transaction_coa_id := NULL;
151299 l_adr_accounting_coa_id := NULL;
151300 l_adr_flexfield_segment_code := NULL;
151301 l_adr_flex_value_set_id := NULL;
151302 l_adr_value_type_code := NULL;
151303 l_adr_value_combination_id := NULL;
151304 l_adr_value_segment_code := NULL;
151305
151306 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
151307 l_bflow_class_code := ''; -- 4219869 Business Flow
151308 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
151309 l_budgetary_control_flag := 'N';
151310
151311 l_bflow_applied_to_amt_idx := NULL; -- 5132302
151312 l_bflow_applied_to_amt := NULL; -- 5132302
151313 l_entered_amt_idx := NULL; -- 4262811
151314 l_accted_amt_idx := NULL; -- 4262811
151315 l_acc_rev_flag := NULL; -- 4262811
151316 l_accrual_line_num := NULL; -- 4262811
151317 l_tmp_amt := NULL; -- 4262811
151318 --
151319
151320 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
151321 l_balance_type_code <> 'B' THEN
151322 IF NVL(p_source_97,9E125) = 1
151323 THEN
151324
151325 --
151326 XLA_AE_LINES_PKG.SetNewLine;
151327
151328 p_balance_type_code := l_balance_type_code;
151329 -- set the flag so later we will know whether the gain loss line needs to be created
151330
151331 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
151332 p_actual_flag :='A';
151333 END IF;
151334
151335 --
151336 -- bulk performance
151337 --
151338 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
151339 p_header_num => 0); -- 4262811
151340 --
151341 -- set accounting line options
151342 --
151343 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
151344 p_natural_side_code => 'D'
151345 , p_gain_or_loss_flag => 'N'
151346 , p_gl_transfer_mode_code => 'S'
151347 , p_acct_entry_type_code => 'A'
151348 , p_switch_side_flag => 'Y'
151349 , p_merge_duplicate_code => 'N'
151350 );
151351 --
151352 l_acc_rev_natural_side_code := 'C'; -- 4262811
151353 --
151354 --
151355 -- set accounting line type info
151356 --
151357 xla_ae_lines_pkg.SetAcctLineType
151358 (p_component_type => l_component_type
151359 ,p_event_type_code => l_event_type_code
151360 ,p_line_definition_owner_code => l_line_definition_owner_code
151361 ,p_line_definition_code => l_line_definition_code
151362 ,p_accounting_line_code => l_component_code
151363 ,p_accounting_line_type_code => l_component_type_code
151364 ,p_accounting_line_appl_id => l_component_appl_id
151365 ,p_amb_context_code => l_amb_context_code
151366 ,p_entity_code => l_entity_code
151367 ,p_event_class_code => l_event_class_code);
151368 --
151369 -- set accounting class
151370 --
151371 xla_ae_lines_pkg.SetAcctClass(
151372 p_accounting_class_code => 'INVENTORY_VALUATION'
151373 , p_ae_header_id => l_ae_header_id
151374 );
151375
151376 --
151377 -- set rounding class
151378 --
151379 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
151380 'INVENTORY_VALUATION';
151381
151382 --
151383 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
151384 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
151385 --
151386 -- bulk performance
151387 --
151388 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
151389
151390 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
151391 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
151392
151393 -- 4955764
151394 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
151395 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
151396
151397 -- 4458381 Public Sector Enh
151398
151399 --
151400 -- set accounting attributes for the line type
151401 --
151402 l_entered_amt_idx := 17;
151403 l_accted_amt_idx := 22;
151404 l_bflow_applied_to_amt_idx := NULL; -- 5132302
151405 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
151406 l_rec_acct_attrs.array_num_value(1) := p_source_79;
151407 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
151408 l_rec_acct_attrs.array_char_value(2) := p_source_80;
151409 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
151410 l_rec_acct_attrs.array_char_value(3) := p_source_81;
151411 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
151412 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
151413 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
151414 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
151415 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
151416 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
151417 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
151418 l_rec_acct_attrs.array_char_value(7) := p_source_85;
151419 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
151420 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
151421 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
151422 l_rec_acct_attrs.array_num_value(9) := p_source_87;
151423 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
151424 l_rec_acct_attrs.array_char_value(10) := p_source_88;
151425 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
151426 l_rec_acct_attrs.array_num_value(11) := p_source_89;
151427 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
151428 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
151429 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
151430 l_rec_acct_attrs.array_num_value(13) := p_source_87;
151431 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
151432 l_rec_acct_attrs.array_char_value(14) := p_source_88;
151433 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
151434 l_rec_acct_attrs.array_num_value(15) := p_source_89;
151435 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
151436 l_rec_acct_attrs.array_char_value(16) := p_source_100;
151437 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
151438 l_rec_acct_attrs.array_num_value(17) := p_source_91;
151439 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
151440 l_rec_acct_attrs.array_char_value(18) := p_source_88;
151441 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
151442 l_rec_acct_attrs.array_date_value(19) := p_source_92;
151443 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
151444 l_rec_acct_attrs.array_num_value(20) := p_source_93;
151445 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
151446 l_rec_acct_attrs.array_char_value(21) := p_source_94;
151447 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
151448 l_rec_acct_attrs.array_num_value(22) := p_source_95;
151449 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
151450 l_rec_acct_attrs.array_num_value(23) := p_source_104;
151451 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
151452 l_rec_acct_attrs.array_num_value(24) := p_source_104;
151453
151454 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
151455 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
151456
151457 ---------------------------------------------------------------------------------------------------------------
151458 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
151459 ---------------------------------------------------------------------------------------------------------------
151460 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
151461
151462 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
151463 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
151464
151465 IF xla_accounting_cache_pkg.GetValueChar
151466 (p_source_code => 'LEDGER_CATEGORY_CODE'
151467 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
151468 AND l_bflow_method_code = 'PRIOR_ENTRY'
151469 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
151470 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
151471 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
151472 )
151473 THEN
151474 xla_ae_lines_pkg.BflowUpgEntry
151475 (p_business_method_code => l_bflow_method_code
151476 ,p_business_class_code => l_bflow_class_code
151477 ,p_balance_type => l_balance_type_code);
151478 ELSE
151479 NULL;
151480 -- No business flow processing for business flow method of NONE.
151481 END IF;
151482
151483 --
151484 -- call analytical criteria
151485 --
151486
151487
151488 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
151489 xla_ae_lines_pkg.SetAnalyticalCriteria(
151490 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
151491 , p_analytical_criterion_owner => 'S'
151492 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
151493 , p_amb_context_code => 'DEFAULT'
151494 , p_balancing_flag => 'Y'
151495
151496 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
151497 , p_analytical_detail_num_1 => NULL
151498 , p_analytical_detail_date_1 => NULL
151499
151500 , p_ae_header_id => l_ae_header_id
151501 )
151502 ;
151503 --
151504
151505 --
151506 -- call description
151507 --
151508
151509 xla_ae_lines_pkg.SetLineDescription(
151510 p_ae_header_id => l_ae_header_id
151511 ,p_description => Description_1 (
151512 p_application_id => p_application_id
151513 , p_ae_header_id => l_ae_header_id
151514 , p_source_1 => p_source_1
151515 , p_source_2 => p_source_2
151516 , p_source_3 => p_source_3
151517 , p_source_4 => p_source_4
151518 , p_source_5 => p_source_5
151519 )
151520 );
151521
151522
151523 --
151524 -- call ADRs
151525 -- Bug 4922099
151526 --
151527 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
151528 (NVL(l_actual_upg_option, 'N') = 'O') OR
151529 (NVL(l_enc_upg_option, 'N') = 'O')
151530 )
151531 THEN
151532 NULL;
151533 --
151534 --
151535
151536 l_ccid := AcctDerRule_28(
151537 p_application_id => p_application_id
151538 , p_ae_header_id => l_ae_header_id
151539 , p_source_15 => p_source_15
151540 , p_source_41 => p_source_41
151541 , p_source_42 => p_source_42
151542 , p_source_43 => p_source_43
151543 , p_source_44 => p_source_44
151544 , p_source_45 => p_source_45
151545 , x_transaction_coa_id => l_adr_transaction_coa_id
151546 , x_accounting_coa_id => l_adr_accounting_coa_id
151547 , x_value_type_code => l_adr_value_type_code
151548 , p_side => 'NA'
151549 );
151550
151551 xla_ae_lines_pkg.set_ccid(
151552 p_code_combination_id => l_ccid
151553 , p_value_type_code => l_adr_value_type_code
151554 , p_transaction_coa_id => l_adr_transaction_coa_id
151555 , p_accounting_coa_id => l_adr_accounting_coa_id
151556 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
151557 , p_adr_type_code => 'S'
151558 , p_component_type => l_component_type
151559 , p_component_code => l_component_code
151560 , p_component_type_code => l_component_type_code
151561 , p_component_appl_id => l_component_appl_id
151562 , p_amb_context_code => l_amb_context_code
151563 , p_side => 'NA'
151564 );
151565
151566
151567 --
151568 --
151569 END IF;
151570 --
151571 -- Bug 4922099
151572 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
151573 (NVL(l_enc_upg_option, 'N') = 'O')
151574 ) AND
151575 (l_bflow_method_code = 'PRIOR_ENTRY')
151576 )
151577 THEN
151578 IF
151579 --
151580 1 = 2
151581 --
151582 THEN
151583 xla_accounting_err_pkg.build_message
151584 (p_appli_s_name => 'XLA'
151585 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
151586 ,p_token_1 => 'LINE_NUMBER'
151587 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
151588 ,p_token_2 => 'LINE_TYPE_NAME'
151589 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
151590 l_component_type
151591 ,l_component_code
151592 ,l_component_type_code
151593 ,l_component_appl_id
151594 ,l_amb_context_code
151595 ,l_entity_code
151596 ,l_event_class_code
151597 )
151598 ,p_token_3 => 'OWNER'
151599 ,p_value_3 => xla_lookups_pkg.get_meaning(
151600 p_lookup_type => 'XLA_OWNER_TYPE'
151601 ,p_lookup_code => l_component_type_code
151602 )
151603 ,p_token_4 => 'PRODUCT_NAME'
151604 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
151605 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
151606 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
151607 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
151608 ,p_ae_header_id => NULL
151609 );
151610
151611 IF (C_LEVEL_ERROR>= g_log_level) THEN
151612 trace
151613 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
151614 ,p_level => C_LEVEL_ERROR
151615 ,p_module => l_log_module);
151616 END IF;
151617 END IF;
151618 END IF;
151619 --
151620 --
151621 ------------------------------------------------------------------------------------------------
151622 -- 4219869 Business Flow
151623 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
151624 -- Prior Entry. Currently, the following code is always generated.
151625 ------------------------------------------------------------------------------------------------
151626 XLA_AE_LINES_PKG.ValidateCurrentLine;
151627
151628 ------------------------------------------------------------------------------------
151629 -- 4219869 Business Flow
151630 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
151631 ------------------------------------------------------------------------------------
151632 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
151633
151634 ----------------------------------------------------------------------------------
151635 -- 4219869 Business Flow
151636 -- Update journal entry status -- Need to generate this within IF <condition>
151637 ----------------------------------------------------------------------------------
151638 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
151639 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
151640 ,p_balance_type_code => l_balance_type_code
151641 );
151642
151643 -------------------------------------------------------------------------------------------
151644 -- 4262811 - Generate the Accrual Reversal lines
151645 -------------------------------------------------------------------------------------------
151646 BEGIN
151647 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
151648 (g_array_event(p_event_id).array_value_num('header_index'));
151649 IF l_acc_rev_flag IS NULL THEN
151650 l_acc_rev_flag := 'N';
151651 END IF;
151652 EXCEPTION
151653 WHEN OTHERS THEN
151654 l_acc_rev_flag := 'N';
151655 END;
151656 --
151657 IF (l_acc_rev_flag = 'Y') THEN
151658
151659 -- 4645092 ------------------------------------------------------------------------------
151660 -- To allow MPA report to determine if it should generate report process
151661 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
151662 ------------------------------------------------------------------------------------------
151663
151664 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
151665 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
151666 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
151667 -- call ADRs
151668 -- Bug 4922099
151669 --
151670 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
151671 (NVL(l_actual_upg_option, 'N') = 'O') OR
151672 (NVL(l_enc_upg_option, 'N') = 'O')
151673 )
151674 THEN
151675 NULL;
151676 --
151677 --
151678
151679 l_ccid := AcctDerRule_28(
151680 p_application_id => p_application_id
151681 , p_ae_header_id => l_ae_header_id
151682 , p_source_15 => p_source_15
151683 , p_source_41 => p_source_41
151684 , p_source_42 => p_source_42
151685 , p_source_43 => p_source_43
151686 , p_source_44 => p_source_44
151687 , p_source_45 => p_source_45
151688 , x_transaction_coa_id => l_adr_transaction_coa_id
151689 , x_accounting_coa_id => l_adr_accounting_coa_id
151690 , x_value_type_code => l_adr_value_type_code
151691 , p_side => 'NA'
151692 );
151693
151694 xla_ae_lines_pkg.set_ccid(
151695 p_code_combination_id => l_ccid
151696 , p_value_type_code => l_adr_value_type_code
151697 , p_transaction_coa_id => l_adr_transaction_coa_id
151698 , p_accounting_coa_id => l_adr_accounting_coa_id
151699 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
151700 , p_adr_type_code => 'S'
151701 , p_component_type => l_component_type
151702 , p_component_code => l_component_code
151703 , p_component_type_code => l_component_type_code
151704 , p_component_appl_id => l_component_appl_id
151705 , p_amb_context_code => l_amb_context_code
151706 , p_side => 'NA'
151707 );
151708
151709
151710 --
151711 --
151712 END IF;
151713
151714 --
151715 -- Update the line information that should be overwritten
151716 --
151717 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
151718 p_header_num => 1);
151719 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
151720
151721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
151722
151723 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
151724 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
151725 END IF;
151726
151727 --
151728 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
151729 --
151730 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
151731 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
151732 ELSE
151733 ---------------------------------------------------------------------------------------------------
151734 -- 4262811a Switch Sign
151735 ---------------------------------------------------------------------------------------------------
151736 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
151737 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
151738 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151739 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
151740 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151741 -- 5132302
151742 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
151743 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
151744
151745 END IF;
151746
151747 -- 4955764
151748 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
151749 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
151750
151751
151752 XLA_AE_LINES_PKG.ValidateCurrentLine;
151753 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
151754
151755 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
151756 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
151757 ,p_balance_type_code => l_balance_type_code);
151758
151759 END IF;
151760
151761 -----------------------------------------------------------------------------------------
151762 -- 4262811 Multiperiod Accounting
151763 -----------------------------------------------------------------------------------------
151764 -- No MPA option is assigned.
151765
151766
151767 END IF;
151768 END IF;
151769 --
151770
151771 --
151772 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
151773 trace
151774 (p_msg => 'END of AcctLineType_283'
151775 ,p_level => C_LEVEL_PROCEDURE
151776 ,p_module => l_log_module);
151777 END IF;
151778 --
151779 EXCEPTION
151780 WHEN xla_exceptions_pkg.application_exception THEN
151781 RAISE;
151782 WHEN OTHERS THEN
151783 xla_exceptions_pkg.raise_message
151784 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_283');
151785 END AcctLineType_283;
151786 --
151787
151788 ---------------------------------------
151789 --
151790 -- PRIVATE FUNCTION
151791 -- AcctLineType_284
151792 --
151793 ---------------------------------------
151794 PROCEDURE AcctLineType_284 (
151795 p_application_id IN NUMBER
151796 ,p_event_id IN NUMBER
151797 ,p_calculate_acctd_flag IN VARCHAR2
151798 ,p_calculate_g_l_flag IN VARCHAR2
151799 ,p_actual_flag IN OUT VARCHAR2
151800 ,p_balance_type_code OUT VARCHAR2
151801 ,p_gain_or_loss_ref OUT VARCHAR2
151802
151803 --TRANSACTION_ID
151804 , p_source_1 IN NUMBER
151805 --Item Concatenated Segments
151806 , p_source_2 IN VARCHAR2
151807 --Transaction Quantity
151808 , p_source_3 IN NUMBER
151809 --Transaction Unit of Measure Code
151810 , p_source_4 IN VARCHAR2
151811 --Inventory Transaction Type Description
151812 , p_source_5 IN VARCHAR2
151813 --Cost Element Name
151814 , p_source_15 IN NUMBER
151815 --Product Line Accounting Category Material Account
151816 , p_source_41 IN NUMBER
151817 --Product Line Accounting Category Material Overhead Account
151818 , p_source_42 IN NUMBER
151819 --Product Line Accounting Category Resource Account
151820 , p_source_43 IN NUMBER
151821 --Product Line Accounting Category Outside Processing Account
151822 , p_source_44 IN NUMBER
151823 --Product Line Accounting Category Overhead Account
151824 , p_source_45 IN NUMBER
151825 --DISTRIBUTION_IDENTIFIER
151826 , p_source_84 IN NUMBER
151827 --Distribution Type
151828 , p_source_85 IN VARCHAR2
151829 , p_source_85_meaning IN VARCHAR2
151830 --Entered Currency Code
151831 , p_source_88 IN VARCHAR2
151832 --Entered Amount
151833 , p_source_91 IN NUMBER
151834 --Currency Conversion Date
151835 , p_source_92 IN DATE
151836 --Currency Conversion Rate
151837 , p_source_93 IN NUMBER
151838 --Currency Conversion Type
151839 , p_source_94 IN VARCHAR2
151840 --Accounted Amount
151841 , p_source_95 IN NUMBER
151842 --Accounting Line Type
151843 , p_source_97 IN NUMBER
151844 --Organization Code
151845 , p_source_108 IN VARCHAR2
151846 )
151847 IS
151848
151849 l_component_type VARCHAR2(80);
151850 l_component_code VARCHAR2(30);
151851 l_component_type_code VARCHAR2(1);
151852 l_component_appl_id INTEGER;
151853 l_amb_context_code VARCHAR2(30);
151854 l_entity_code VARCHAR2(30);
151855 l_event_class_code VARCHAR2(30);
151856 l_ae_header_id NUMBER;
151857 l_event_type_code VARCHAR2(30);
151858 l_line_definition_code VARCHAR2(30);
151859 l_line_definition_owner_code VARCHAR2(1);
151860 --
151861 -- adr variables
151862 l_segment VARCHAR2(30);
151863 l_ccid NUMBER;
151864 l_adr_transaction_coa_id NUMBER;
151865 l_adr_accounting_coa_id NUMBER;
151866 l_adr_flexfield_segment_code VARCHAR2(30);
151867 l_adr_flex_value_set_id NUMBER;
151868 l_adr_value_type_code VARCHAR2(30);
151869 l_adr_value_combination_id NUMBER;
151870 l_adr_value_segment_code VARCHAR2(30);
151871
151872 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
151873 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
151874 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
151875 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
151876
151877 -- 4262811 Variables ------------------------------------------------------------------------------------------
151878 l_entered_amt_idx NUMBER;
151879 l_accted_amt_idx NUMBER;
151880 l_acc_rev_flag VARCHAR2(1);
151881 l_accrual_line_num NUMBER;
151882 l_tmp_amt NUMBER;
151883 l_acc_rev_natural_side_code VARCHAR2(1);
151884
151885 l_num_entries NUMBER;
151886 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
151887 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
151888 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
151889 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
151890 l_recog_line_1 NUMBER;
151891 l_recog_line_2 NUMBER;
151892
151893 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
151894 l_bflow_applied_to_amt NUMBER; -- 5132302
151895 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
151896
151897 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
151898
151899 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
151900 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
151901
151902 ---------------------------------------------------------------------------------------------------------------
151903
151904
151905 --
151906 -- bulk performance
151907 --
151908 l_balance_type_code VARCHAR2(1);
151909 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
151910 l_log_module VARCHAR2(240);
151911
151912 --
151913 -- Upgrade strategy
151914 --
151915 l_actual_upg_option VARCHAR2(1);
151916 l_enc_upg_option VARCHAR2(1);
151917
151918 --
151919 BEGIN
151920 --
151921 IF g_log_enabled THEN
151922 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_284';
151923 END IF;
151924 --
151925 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
151926
151927 trace
151928 (p_msg => 'BEGIN of AcctLineType_284'
151929 ,p_level => C_LEVEL_PROCEDURE
151930 ,p_module => l_log_module);
151931
151932 END IF;
151933 --
151934 l_component_type := 'AMB_JLT';
151935 l_component_code := 'INVENTORY_VALUATION';
151936 l_component_type_code := 'S';
151937 l_component_appl_id := 707;
151938 l_amb_context_code := 'DEFAULT';
151939 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
151940 l_event_class_code := 'INT_ORDER_TO_EXP';
151941 l_event_type_code := 'INT_ORDER_ISSUE_TP';
151942 l_line_definition_owner_code := 'S';
151943 l_line_definition_code := 'PI_INT_ORDER_ISSUE_TP';
151944 --
151945 l_balance_type_code := 'A';
151946 l_segment := NULL;
151947 l_ccid := NULL;
151948 l_adr_transaction_coa_id := NULL;
151949 l_adr_accounting_coa_id := NULL;
151950 l_adr_flexfield_segment_code := NULL;
151951 l_adr_flex_value_set_id := NULL;
151952 l_adr_value_type_code := NULL;
151953 l_adr_value_combination_id := NULL;
151954 l_adr_value_segment_code := NULL;
151955
151956 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
151957 l_bflow_class_code := ''; -- 4219869 Business Flow
151958 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
151959 l_budgetary_control_flag := 'N';
151960
151961 l_bflow_applied_to_amt_idx := NULL; -- 5132302
151962 l_bflow_applied_to_amt := NULL; -- 5132302
151963 l_entered_amt_idx := NULL; -- 4262811
151964 l_accted_amt_idx := NULL; -- 4262811
151965 l_acc_rev_flag := NULL; -- 4262811
151966 l_accrual_line_num := NULL; -- 4262811
151967 l_tmp_amt := NULL; -- 4262811
151968 --
151969
151970 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
151971 l_balance_type_code <> 'B' THEN
151972 IF NVL(p_source_97,9E125) = 1
151973 THEN
151974
151975 --
151976 XLA_AE_LINES_PKG.SetNewLine;
151977
151978 p_balance_type_code := l_balance_type_code;
151979 -- set the flag so later we will know whether the gain loss line needs to be created
151980
151981 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
151982 p_actual_flag :='A';
151983 END IF;
151984
151985 --
151986 -- bulk performance
151987 --
151988 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
151989 p_header_num => 0); -- 4262811
151990 --
151991 -- set accounting line options
151992 --
151993 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
151994 p_natural_side_code => 'D'
151995 , p_gain_or_loss_flag => 'N'
151996 , p_gl_transfer_mode_code => 'S'
151997 , p_acct_entry_type_code => 'A'
151998 , p_switch_side_flag => 'Y'
151999 , p_merge_duplicate_code => 'N'
152000 );
152001 --
152002 l_acc_rev_natural_side_code := 'C'; -- 4262811
152003 --
152004 --
152005 -- set accounting line type info
152006 --
152007 xla_ae_lines_pkg.SetAcctLineType
152008 (p_component_type => l_component_type
152009 ,p_event_type_code => l_event_type_code
152010 ,p_line_definition_owner_code => l_line_definition_owner_code
152011 ,p_line_definition_code => l_line_definition_code
152012 ,p_accounting_line_code => l_component_code
152013 ,p_accounting_line_type_code => l_component_type_code
152014 ,p_accounting_line_appl_id => l_component_appl_id
152015 ,p_amb_context_code => l_amb_context_code
152016 ,p_entity_code => l_entity_code
152017 ,p_event_class_code => l_event_class_code);
152018 --
152019 -- set accounting class
152020 --
152021 xla_ae_lines_pkg.SetAcctClass(
152022 p_accounting_class_code => 'INVENTORY_VALUATION'
152023 , p_ae_header_id => l_ae_header_id
152024 );
152025
152026 --
152027 -- set rounding class
152028 --
152029 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
152030 'INVENTORY_VALUATION';
152031
152032 --
152033 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
152034 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
152035 --
152036 -- bulk performance
152037 --
152038 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
152039
152040 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
152041 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
152042
152043 -- 4955764
152044 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
152045 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
152046
152047 -- 4458381 Public Sector Enh
152048
152049 --
152050 -- set accounting attributes for the line type
152051 --
152052 l_entered_amt_idx := 3;
152053 l_accted_amt_idx := 8;
152054 l_bflow_applied_to_amt_idx := NULL; -- 5132302
152055 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
152056 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
152057 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
152058 l_rec_acct_attrs.array_char_value(2) := p_source_85;
152059 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
152060 l_rec_acct_attrs.array_num_value(3) := p_source_91;
152061 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
152062 l_rec_acct_attrs.array_char_value(4) := p_source_88;
152063 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
152064 l_rec_acct_attrs.array_date_value(5) := p_source_92;
152065 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
152066 l_rec_acct_attrs.array_num_value(6) := p_source_93;
152067 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
152068 l_rec_acct_attrs.array_char_value(7) := p_source_94;
152069 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
152070 l_rec_acct_attrs.array_num_value(8) := p_source_95;
152071
152072 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
152073 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
152074
152075 ---------------------------------------------------------------------------------------------------------------
152076 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
152077 ---------------------------------------------------------------------------------------------------------------
152078 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
152079
152080 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
152081 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
152082
152083 IF xla_accounting_cache_pkg.GetValueChar
152084 (p_source_code => 'LEDGER_CATEGORY_CODE'
152085 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
152086 AND l_bflow_method_code = 'PRIOR_ENTRY'
152087 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
152088 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
152089 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
152090 )
152091 THEN
152092 xla_ae_lines_pkg.BflowUpgEntry
152093 (p_business_method_code => l_bflow_method_code
152094 ,p_business_class_code => l_bflow_class_code
152095 ,p_balance_type => l_balance_type_code);
152096 ELSE
152097 NULL;
152098 -- No business flow processing for business flow method of NONE.
152099 END IF;
152100
152101 --
152102 -- call analytical criteria
152103 --
152104
152105
152106 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
152107 xla_ae_lines_pkg.SetAnalyticalCriteria(
152108 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
152109 , p_analytical_criterion_owner => 'S'
152110 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
152111 , p_amb_context_code => 'DEFAULT'
152112 , p_balancing_flag => 'Y'
152113
152114 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
152115 , p_analytical_detail_num_1 => NULL
152116 , p_analytical_detail_date_1 => NULL
152117
152118 , p_ae_header_id => l_ae_header_id
152119 )
152120 ;
152121 --
152122
152123 --
152124 -- call description
152125 --
152126
152127 xla_ae_lines_pkg.SetLineDescription(
152128 p_ae_header_id => l_ae_header_id
152129 ,p_description => Description_1 (
152130 p_application_id => p_application_id
152131 , p_ae_header_id => l_ae_header_id
152132 , p_source_1 => p_source_1
152133 , p_source_2 => p_source_2
152134 , p_source_3 => p_source_3
152135 , p_source_4 => p_source_4
152136 , p_source_5 => p_source_5
152137 )
152138 );
152139
152140
152141 --
152142 -- call ADRs
152143 -- Bug 4922099
152144 --
152145 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
152146 (NVL(l_actual_upg_option, 'N') = 'O') OR
152147 (NVL(l_enc_upg_option, 'N') = 'O')
152148 )
152149 THEN
152150 NULL;
152151 --
152152 --
152153
152154 l_ccid := AcctDerRule_28(
152155 p_application_id => p_application_id
152156 , p_ae_header_id => l_ae_header_id
152157 , p_source_15 => p_source_15
152158 , p_source_41 => p_source_41
152159 , p_source_42 => p_source_42
152160 , p_source_43 => p_source_43
152161 , p_source_44 => p_source_44
152162 , p_source_45 => p_source_45
152163 , x_transaction_coa_id => l_adr_transaction_coa_id
152164 , x_accounting_coa_id => l_adr_accounting_coa_id
152165 , x_value_type_code => l_adr_value_type_code
152166 , p_side => 'NA'
152167 );
152168
152169 xla_ae_lines_pkg.set_ccid(
152170 p_code_combination_id => l_ccid
152171 , p_value_type_code => l_adr_value_type_code
152172 , p_transaction_coa_id => l_adr_transaction_coa_id
152173 , p_accounting_coa_id => l_adr_accounting_coa_id
152174 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
152175 , p_adr_type_code => 'S'
152176 , p_component_type => l_component_type
152177 , p_component_code => l_component_code
152178 , p_component_type_code => l_component_type_code
152179 , p_component_appl_id => l_component_appl_id
152180 , p_amb_context_code => l_amb_context_code
152181 , p_side => 'NA'
152182 );
152183
152184
152185 --
152186 --
152187 END IF;
152188 --
152189 -- Bug 4922099
152190 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
152191 (NVL(l_enc_upg_option, 'N') = 'O')
152192 ) AND
152193 (l_bflow_method_code = 'PRIOR_ENTRY')
152194 )
152195 THEN
152196 IF
152197 --
152198 1 = 2
152199 --
152200 THEN
152201 xla_accounting_err_pkg.build_message
152202 (p_appli_s_name => 'XLA'
152203 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
152204 ,p_token_1 => 'LINE_NUMBER'
152205 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
152206 ,p_token_2 => 'LINE_TYPE_NAME'
152207 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
152208 l_component_type
152209 ,l_component_code
152210 ,l_component_type_code
152211 ,l_component_appl_id
152212 ,l_amb_context_code
152213 ,l_entity_code
152214 ,l_event_class_code
152215 )
152216 ,p_token_3 => 'OWNER'
152217 ,p_value_3 => xla_lookups_pkg.get_meaning(
152218 p_lookup_type => 'XLA_OWNER_TYPE'
152219 ,p_lookup_code => l_component_type_code
152220 )
152221 ,p_token_4 => 'PRODUCT_NAME'
152222 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
152223 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
152224 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
152225 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
152226 ,p_ae_header_id => NULL
152227 );
152228
152229 IF (C_LEVEL_ERROR>= g_log_level) THEN
152230 trace
152231 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
152232 ,p_level => C_LEVEL_ERROR
152233 ,p_module => l_log_module);
152234 END IF;
152235 END IF;
152236 END IF;
152237 --
152238 --
152239 ------------------------------------------------------------------------------------------------
152240 -- 4219869 Business Flow
152241 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
152242 -- Prior Entry. Currently, the following code is always generated.
152243 ------------------------------------------------------------------------------------------------
152244 XLA_AE_LINES_PKG.ValidateCurrentLine;
152245
152246 ------------------------------------------------------------------------------------
152247 -- 4219869 Business Flow
152248 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
152249 ------------------------------------------------------------------------------------
152250 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
152251
152252 ----------------------------------------------------------------------------------
152253 -- 4219869 Business Flow
152254 -- Update journal entry status -- Need to generate this within IF <condition>
152255 ----------------------------------------------------------------------------------
152256 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
152257 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
152258 ,p_balance_type_code => l_balance_type_code
152259 );
152260
152261 -------------------------------------------------------------------------------------------
152262 -- 4262811 - Generate the Accrual Reversal lines
152263 -------------------------------------------------------------------------------------------
152264 BEGIN
152265 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
152266 (g_array_event(p_event_id).array_value_num('header_index'));
152267 IF l_acc_rev_flag IS NULL THEN
152268 l_acc_rev_flag := 'N';
152269 END IF;
152270 EXCEPTION
152271 WHEN OTHERS THEN
152272 l_acc_rev_flag := 'N';
152273 END;
152274 --
152275 IF (l_acc_rev_flag = 'Y') THEN
152276
152277 -- 4645092 ------------------------------------------------------------------------------
152278 -- To allow MPA report to determine if it should generate report process
152279 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
152280 ------------------------------------------------------------------------------------------
152281
152282 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
152283 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
152284 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
152285 -- call ADRs
152286 -- Bug 4922099
152287 --
152288 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
152289 (NVL(l_actual_upg_option, 'N') = 'O') OR
152290 (NVL(l_enc_upg_option, 'N') = 'O')
152291 )
152292 THEN
152293 NULL;
152294 --
152295 --
152296
152297 l_ccid := AcctDerRule_28(
152298 p_application_id => p_application_id
152299 , p_ae_header_id => l_ae_header_id
152300 , p_source_15 => p_source_15
152301 , p_source_41 => p_source_41
152302 , p_source_42 => p_source_42
152303 , p_source_43 => p_source_43
152304 , p_source_44 => p_source_44
152305 , p_source_45 => p_source_45
152306 , x_transaction_coa_id => l_adr_transaction_coa_id
152307 , x_accounting_coa_id => l_adr_accounting_coa_id
152308 , x_value_type_code => l_adr_value_type_code
152309 , p_side => 'NA'
152310 );
152311
152312 xla_ae_lines_pkg.set_ccid(
152313 p_code_combination_id => l_ccid
152314 , p_value_type_code => l_adr_value_type_code
152315 , p_transaction_coa_id => l_adr_transaction_coa_id
152316 , p_accounting_coa_id => l_adr_accounting_coa_id
152317 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
152318 , p_adr_type_code => 'S'
152319 , p_component_type => l_component_type
152320 , p_component_code => l_component_code
152321 , p_component_type_code => l_component_type_code
152322 , p_component_appl_id => l_component_appl_id
152323 , p_amb_context_code => l_amb_context_code
152324 , p_side => 'NA'
152325 );
152326
152327
152328 --
152329 --
152330 END IF;
152331
152332 --
152333 -- Update the line information that should be overwritten
152334 --
152335 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
152336 p_header_num => 1);
152337 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
152338
152339 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
152340
152341 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
152342 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
152343 END IF;
152344
152345 --
152346 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
152347 --
152348 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
152349 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
152350 ELSE
152351 ---------------------------------------------------------------------------------------------------
152352 -- 4262811a Switch Sign
152353 ---------------------------------------------------------------------------------------------------
152354 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
152355 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
152356 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
152357 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
152358 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
152359 -- 5132302
152360 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
152361 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
152362
152363 END IF;
152364
152365 -- 4955764
152366 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
152367 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
152368
152369
152370 XLA_AE_LINES_PKG.ValidateCurrentLine;
152371 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
152372
152373 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
152374 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
152375 ,p_balance_type_code => l_balance_type_code);
152376
152377 END IF;
152378
152379 -----------------------------------------------------------------------------------------
152380 -- 4262811 Multiperiod Accounting
152381 -----------------------------------------------------------------------------------------
152382 -- No MPA option is assigned.
152383
152384
152385 END IF;
152386 END IF;
152387 --
152388
152389 --
152390 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
152391 trace
152392 (p_msg => 'END of AcctLineType_284'
152393 ,p_level => C_LEVEL_PROCEDURE
152394 ,p_module => l_log_module);
152395 END IF;
152396 --
152397 EXCEPTION
152398 WHEN xla_exceptions_pkg.application_exception THEN
152399 RAISE;
152400 WHEN OTHERS THEN
152401 xla_exceptions_pkg.raise_message
152402 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_284');
152403 END AcctLineType_284;
152404 --
152405
152406 ---------------------------------------
152407 --
152408 -- PRIVATE FUNCTION
152409 -- AcctLineType_285
152410 --
152411 ---------------------------------------
152412 PROCEDURE AcctLineType_285 (
152413 p_application_id IN NUMBER
152414 ,p_event_id IN NUMBER
152415 ,p_calculate_acctd_flag IN VARCHAR2
152416 ,p_calculate_g_l_flag IN VARCHAR2
152417 ,p_actual_flag IN OUT VARCHAR2
152418 ,p_balance_type_code OUT VARCHAR2
152419 ,p_gain_or_loss_ref OUT VARCHAR2
152420
152421 --TRANSACTION_ID
152422 , p_source_1 IN NUMBER
152423 --Item Concatenated Segments
152424 , p_source_2 IN VARCHAR2
152425 --Transaction Quantity
152426 , p_source_3 IN NUMBER
152427 --Transaction Unit of Measure Code
152428 , p_source_4 IN VARCHAR2
152429 --Inventory Transaction Type Description
152430 , p_source_5 IN VARCHAR2
152431 --Cost Element Name
152432 , p_source_15 IN NUMBER
152433 --Product Line Accounting Category Material Account
152434 , p_source_41 IN NUMBER
152435 --Product Line Accounting Category Material Overhead Account
152436 , p_source_42 IN NUMBER
152437 --Product Line Accounting Category Resource Account
152438 , p_source_43 IN NUMBER
152439 --Product Line Accounting Category Outside Processing Account
152440 , p_source_44 IN NUMBER
152441 --Product Line Accounting Category Overhead Account
152442 , p_source_45 IN NUMBER
152443 --Applied to Application ID
152444 , p_source_79 IN NUMBER
152445 --Applied to Distribution Link Type
152446 , p_source_80 IN VARCHAR2
152447 --Applied to Entity Code
152448 , p_source_81 IN VARCHAR2
152449 --Applied To Purchase Document Identifier
152450 , p_source_83 IN NUMBER
152451 --DISTRIBUTION_IDENTIFIER
152452 , p_source_84 IN NUMBER
152453 --Distribution Type
152454 , p_source_85 IN VARCHAR2
152455 , p_source_85_meaning IN VARCHAR2
152456 --PO Budget Account
152457 , p_source_86 IN NUMBER
152458 --Encumbrance Reversal Amount Entered
152459 , p_source_87 IN NUMBER
152460 --Entered Currency Code
152461 , p_source_88 IN VARCHAR2
152462 --Transaction Encumbrance Reversal Amount
152463 , p_source_89 IN NUMBER
152464 --Entered Amount
152465 , p_source_91 IN NUMBER
152466 --Currency Conversion Date
152467 , p_source_92 IN DATE
152468 --Currency Conversion Rate
152469 , p_source_93 IN NUMBER
152470 --Currency Conversion Type
152471 , p_source_94 IN VARCHAR2
152472 --Accounted Amount
152473 , p_source_95 IN NUMBER
152474 --Purchasing Encumbrance Type Identifier
152475 , p_source_96 IN NUMBER
152476 --Accounting Line Type
152477 , p_source_97 IN NUMBER
152478 --Costing Encumbrance Upgrade Option
152479 , p_source_100 IN VARCHAR2
152480 --TXN_PO_DISTRIBUTION_ID
152481 , p_source_101 IN NUMBER
152482 --Organization Code
152483 , p_source_108 IN VARCHAR2
152484 )
152485 IS
152486
152487 l_component_type VARCHAR2(80);
152488 l_component_code VARCHAR2(30);
152489 l_component_type_code VARCHAR2(1);
152490 l_component_appl_id INTEGER;
152491 l_amb_context_code VARCHAR2(30);
152492 l_entity_code VARCHAR2(30);
152493 l_event_class_code VARCHAR2(30);
152494 l_ae_header_id NUMBER;
152495 l_event_type_code VARCHAR2(30);
152496 l_line_definition_code VARCHAR2(30);
152497 l_line_definition_owner_code VARCHAR2(1);
152498 --
152499 -- adr variables
152500 l_segment VARCHAR2(30);
152501 l_ccid NUMBER;
152502 l_adr_transaction_coa_id NUMBER;
152503 l_adr_accounting_coa_id NUMBER;
152504 l_adr_flexfield_segment_code VARCHAR2(30);
152505 l_adr_flex_value_set_id NUMBER;
152506 l_adr_value_type_code VARCHAR2(30);
152507 l_adr_value_combination_id NUMBER;
152508 l_adr_value_segment_code VARCHAR2(30);
152509
152510 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
152511 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
152512 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
152513 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
152514
152515 -- 4262811 Variables ------------------------------------------------------------------------------------------
152516 l_entered_amt_idx NUMBER;
152517 l_accted_amt_idx NUMBER;
152518 l_acc_rev_flag VARCHAR2(1);
152519 l_accrual_line_num NUMBER;
152520 l_tmp_amt NUMBER;
152521 l_acc_rev_natural_side_code VARCHAR2(1);
152522
152523 l_num_entries NUMBER;
152524 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
152525 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
152526 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
152527 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
152528 l_recog_line_1 NUMBER;
152529 l_recog_line_2 NUMBER;
152530
152531 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
152532 l_bflow_applied_to_amt NUMBER; -- 5132302
152533 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
152534
152535 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
152536
152537 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
152538 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
152539
152540 ---------------------------------------------------------------------------------------------------------------
152541
152542
152543 --
152544 -- bulk performance
152545 --
152546 l_balance_type_code VARCHAR2(1);
152547 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
152548 l_log_module VARCHAR2(240);
152549
152550 --
152551 -- Upgrade strategy
152552 --
152553 l_actual_upg_option VARCHAR2(1);
152554 l_enc_upg_option VARCHAR2(1);
152555
152556 --
152557 BEGIN
152558 --
152559 IF g_log_enabled THEN
152560 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_285';
152561 END IF;
152562 --
152563 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
152564
152565 trace
152566 (p_msg => 'BEGIN of AcctLineType_285'
152567 ,p_level => C_LEVEL_PROCEDURE
152568 ,p_module => l_log_module);
152569
152570 END IF;
152571 --
152572 l_component_type := 'AMB_JLT';
152573 l_component_code := 'INVENTORY_VALUATION';
152574 l_component_type_code := 'S';
152575 l_component_appl_id := 707;
152576 l_amb_context_code := 'DEFAULT';
152577 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
152578 l_event_class_code := 'PURCHASE_ORDER';
152579 l_event_type_code := 'LOG_PO_DEL_ADJ';
152580 l_line_definition_owner_code := 'S';
152581 l_line_definition_code := 'PI_LOG_PO_DEL_ADJ';
152582 --
152583 l_balance_type_code := 'A';
152584 l_segment := NULL;
152585 l_ccid := NULL;
152586 l_adr_transaction_coa_id := NULL;
152587 l_adr_accounting_coa_id := NULL;
152588 l_adr_flexfield_segment_code := NULL;
152589 l_adr_flex_value_set_id := NULL;
152590 l_adr_value_type_code := NULL;
152591 l_adr_value_combination_id := NULL;
152592 l_adr_value_segment_code := NULL;
152593
152594 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
152595 l_bflow_class_code := ''; -- 4219869 Business Flow
152596 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
152597 l_budgetary_control_flag := 'N';
152598
152599 l_bflow_applied_to_amt_idx := NULL; -- 5132302
152600 l_bflow_applied_to_amt := NULL; -- 5132302
152601 l_entered_amt_idx := NULL; -- 4262811
152602 l_accted_amt_idx := NULL; -- 4262811
152603 l_acc_rev_flag := NULL; -- 4262811
152604 l_accrual_line_num := NULL; -- 4262811
152605 l_tmp_amt := NULL; -- 4262811
152606 --
152607
152608 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
152609 l_balance_type_code <> 'B' THEN
152610 IF NVL(p_source_97,9E125) = 1
152611 THEN
152612
152613 --
152614 XLA_AE_LINES_PKG.SetNewLine;
152615
152616 p_balance_type_code := l_balance_type_code;
152617 -- set the flag so later we will know whether the gain loss line needs to be created
152618
152619 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
152620 p_actual_flag :='A';
152621 END IF;
152622
152623 --
152624 -- bulk performance
152625 --
152626 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
152627 p_header_num => 0); -- 4262811
152628 --
152629 -- set accounting line options
152630 --
152631 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
152632 p_natural_side_code => 'D'
152633 , p_gain_or_loss_flag => 'N'
152634 , p_gl_transfer_mode_code => 'S'
152635 , p_acct_entry_type_code => 'A'
152636 , p_switch_side_flag => 'Y'
152637 , p_merge_duplicate_code => 'N'
152638 );
152639 --
152640 l_acc_rev_natural_side_code := 'C'; -- 4262811
152641 --
152642 --
152643 -- set accounting line type info
152644 --
152645 xla_ae_lines_pkg.SetAcctLineType
152646 (p_component_type => l_component_type
152647 ,p_event_type_code => l_event_type_code
152648 ,p_line_definition_owner_code => l_line_definition_owner_code
152649 ,p_line_definition_code => l_line_definition_code
152650 ,p_accounting_line_code => l_component_code
152651 ,p_accounting_line_type_code => l_component_type_code
152652 ,p_accounting_line_appl_id => l_component_appl_id
152653 ,p_amb_context_code => l_amb_context_code
152654 ,p_entity_code => l_entity_code
152655 ,p_event_class_code => l_event_class_code);
152656 --
152657 -- set accounting class
152658 --
152659 xla_ae_lines_pkg.SetAcctClass(
152660 p_accounting_class_code => 'INVENTORY_VALUATION'
152661 , p_ae_header_id => l_ae_header_id
152662 );
152663
152664 --
152665 -- set rounding class
152666 --
152667 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
152668 'INVENTORY_VALUATION';
152669
152670 --
152671 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
152672 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
152673 --
152674 -- bulk performance
152675 --
152676 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
152677
152678 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
152679 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
152680
152681 -- 4955764
152682 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
152683 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
152684
152685 -- 4458381 Public Sector Enh
152686
152687 --
152688 -- set accounting attributes for the line type
152689 --
152690 l_entered_amt_idx := 17;
152691 l_accted_amt_idx := 22;
152692 l_bflow_applied_to_amt_idx := NULL; -- 5132302
152693 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
152694 l_rec_acct_attrs.array_num_value(1) := p_source_79;
152695 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
152696 l_rec_acct_attrs.array_char_value(2) := p_source_80;
152697 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
152698 l_rec_acct_attrs.array_char_value(3) := p_source_81;
152699 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
152700 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
152701 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
152702 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
152703 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
152704 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
152705 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
152706 l_rec_acct_attrs.array_char_value(7) := p_source_85;
152707 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
152708 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
152709 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
152710 l_rec_acct_attrs.array_num_value(9) := p_source_87;
152711 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
152712 l_rec_acct_attrs.array_char_value(10) := p_source_88;
152713 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
152714 l_rec_acct_attrs.array_num_value(11) := p_source_89;
152715 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
152716 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
152717 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
152718 l_rec_acct_attrs.array_num_value(13) := p_source_87;
152719 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
152720 l_rec_acct_attrs.array_char_value(14) := p_source_88;
152721 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
152722 l_rec_acct_attrs.array_num_value(15) := p_source_89;
152723 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
152724 l_rec_acct_attrs.array_char_value(16) := p_source_100;
152725 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
152726 l_rec_acct_attrs.array_num_value(17) := p_source_91;
152727 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
152728 l_rec_acct_attrs.array_char_value(18) := p_source_88;
152729 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
152730 l_rec_acct_attrs.array_date_value(19) := p_source_92;
152731 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
152732 l_rec_acct_attrs.array_num_value(20) := p_source_93;
152733 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
152734 l_rec_acct_attrs.array_char_value(21) := p_source_94;
152735 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
152736 l_rec_acct_attrs.array_num_value(22) := p_source_95;
152737 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
152738 l_rec_acct_attrs.array_num_value(23) := p_source_96;
152739 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
152740 l_rec_acct_attrs.array_num_value(24) := p_source_96;
152741
152742 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
152743 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
152744
152745 ---------------------------------------------------------------------------------------------------------------
152746 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
152747 ---------------------------------------------------------------------------------------------------------------
152748 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
152749
152750 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
152751 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
152752
152753 IF xla_accounting_cache_pkg.GetValueChar
152754 (p_source_code => 'LEDGER_CATEGORY_CODE'
152755 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
152756 AND l_bflow_method_code = 'PRIOR_ENTRY'
152757 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
152758 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
152759 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
152760 )
152761 THEN
152762 xla_ae_lines_pkg.BflowUpgEntry
152763 (p_business_method_code => l_bflow_method_code
152764 ,p_business_class_code => l_bflow_class_code
152765 ,p_balance_type => l_balance_type_code);
152766 ELSE
152767 NULL;
152768 -- No business flow processing for business flow method of NONE.
152769 END IF;
152770
152771 --
152772 -- call analytical criteria
152773 --
152774
152775
152776 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
152777 xla_ae_lines_pkg.SetAnalyticalCriteria(
152778 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
152779 , p_analytical_criterion_owner => 'S'
152780 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
152781 , p_amb_context_code => 'DEFAULT'
152782 , p_balancing_flag => 'Y'
152783
152784 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
152785 , p_analytical_detail_num_1 => NULL
152786 , p_analytical_detail_date_1 => NULL
152787
152788 , p_ae_header_id => l_ae_header_id
152789 )
152790 ;
152791 --
152792
152793 --
152794 -- call description
152795 --
152796
152797 xla_ae_lines_pkg.SetLineDescription(
152798 p_ae_header_id => l_ae_header_id
152799 ,p_description => Description_1 (
152800 p_application_id => p_application_id
152801 , p_ae_header_id => l_ae_header_id
152802 , p_source_1 => p_source_1
152803 , p_source_2 => p_source_2
152804 , p_source_3 => p_source_3
152805 , p_source_4 => p_source_4
152806 , p_source_5 => p_source_5
152807 )
152808 );
152809
152810
152811 --
152812 -- call ADRs
152813 -- Bug 4922099
152814 --
152815 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
152816 (NVL(l_actual_upg_option, 'N') = 'O') OR
152817 (NVL(l_enc_upg_option, 'N') = 'O')
152818 )
152819 THEN
152820 NULL;
152821 --
152822 --
152823
152824 l_ccid := AcctDerRule_28(
152825 p_application_id => p_application_id
152826 , p_ae_header_id => l_ae_header_id
152827 , p_source_15 => p_source_15
152828 , p_source_41 => p_source_41
152829 , p_source_42 => p_source_42
152830 , p_source_43 => p_source_43
152831 , p_source_44 => p_source_44
152832 , p_source_45 => p_source_45
152833 , x_transaction_coa_id => l_adr_transaction_coa_id
152834 , x_accounting_coa_id => l_adr_accounting_coa_id
152835 , x_value_type_code => l_adr_value_type_code
152836 , p_side => 'NA'
152837 );
152838
152839 xla_ae_lines_pkg.set_ccid(
152840 p_code_combination_id => l_ccid
152841 , p_value_type_code => l_adr_value_type_code
152842 , p_transaction_coa_id => l_adr_transaction_coa_id
152843 , p_accounting_coa_id => l_adr_accounting_coa_id
152844 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
152845 , p_adr_type_code => 'S'
152846 , p_component_type => l_component_type
152847 , p_component_code => l_component_code
152848 , p_component_type_code => l_component_type_code
152849 , p_component_appl_id => l_component_appl_id
152850 , p_amb_context_code => l_amb_context_code
152851 , p_side => 'NA'
152852 );
152853
152854
152855 --
152856 --
152857 END IF;
152858 --
152859 -- Bug 4922099
152860 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
152861 (NVL(l_enc_upg_option, 'N') = 'O')
152862 ) AND
152863 (l_bflow_method_code = 'PRIOR_ENTRY')
152864 )
152865 THEN
152866 IF
152867 --
152868 1 = 2
152869 --
152870 THEN
152871 xla_accounting_err_pkg.build_message
152872 (p_appli_s_name => 'XLA'
152873 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
152874 ,p_token_1 => 'LINE_NUMBER'
152875 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
152876 ,p_token_2 => 'LINE_TYPE_NAME'
152877 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
152878 l_component_type
152879 ,l_component_code
152880 ,l_component_type_code
152881 ,l_component_appl_id
152882 ,l_amb_context_code
152883 ,l_entity_code
152884 ,l_event_class_code
152885 )
152886 ,p_token_3 => 'OWNER'
152887 ,p_value_3 => xla_lookups_pkg.get_meaning(
152888 p_lookup_type => 'XLA_OWNER_TYPE'
152889 ,p_lookup_code => l_component_type_code
152890 )
152891 ,p_token_4 => 'PRODUCT_NAME'
152892 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
152893 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
152894 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
152895 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
152896 ,p_ae_header_id => NULL
152897 );
152898
152899 IF (C_LEVEL_ERROR>= g_log_level) THEN
152900 trace
152901 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
152902 ,p_level => C_LEVEL_ERROR
152903 ,p_module => l_log_module);
152904 END IF;
152905 END IF;
152906 END IF;
152907 --
152908 --
152909 ------------------------------------------------------------------------------------------------
152910 -- 4219869 Business Flow
152911 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
152912 -- Prior Entry. Currently, the following code is always generated.
152913 ------------------------------------------------------------------------------------------------
152914 XLA_AE_LINES_PKG.ValidateCurrentLine;
152915
152916 ------------------------------------------------------------------------------------
152917 -- 4219869 Business Flow
152918 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
152919 ------------------------------------------------------------------------------------
152920 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
152921
152922 ----------------------------------------------------------------------------------
152923 -- 4219869 Business Flow
152924 -- Update journal entry status -- Need to generate this within IF <condition>
152925 ----------------------------------------------------------------------------------
152926 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
152927 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
152928 ,p_balance_type_code => l_balance_type_code
152929 );
152930
152931 -------------------------------------------------------------------------------------------
152932 -- 4262811 - Generate the Accrual Reversal lines
152933 -------------------------------------------------------------------------------------------
152934 BEGIN
152935 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
152936 (g_array_event(p_event_id).array_value_num('header_index'));
152937 IF l_acc_rev_flag IS NULL THEN
152938 l_acc_rev_flag := 'N';
152939 END IF;
152940 EXCEPTION
152941 WHEN OTHERS THEN
152942 l_acc_rev_flag := 'N';
152943 END;
152944 --
152945 IF (l_acc_rev_flag = 'Y') THEN
152946
152947 -- 4645092 ------------------------------------------------------------------------------
152948 -- To allow MPA report to determine if it should generate report process
152949 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
152950 ------------------------------------------------------------------------------------------
152951
152952 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
152953 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
152954 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
152955 -- call ADRs
152956 -- Bug 4922099
152957 --
152958 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
152959 (NVL(l_actual_upg_option, 'N') = 'O') OR
152960 (NVL(l_enc_upg_option, 'N') = 'O')
152961 )
152962 THEN
152963 NULL;
152964 --
152965 --
152966
152967 l_ccid := AcctDerRule_28(
152968 p_application_id => p_application_id
152969 , p_ae_header_id => l_ae_header_id
152970 , p_source_15 => p_source_15
152971 , p_source_41 => p_source_41
152972 , p_source_42 => p_source_42
152973 , p_source_43 => p_source_43
152974 , p_source_44 => p_source_44
152975 , p_source_45 => p_source_45
152976 , x_transaction_coa_id => l_adr_transaction_coa_id
152977 , x_accounting_coa_id => l_adr_accounting_coa_id
152978 , x_value_type_code => l_adr_value_type_code
152979 , p_side => 'NA'
152980 );
152981
152982 xla_ae_lines_pkg.set_ccid(
152983 p_code_combination_id => l_ccid
152984 , p_value_type_code => l_adr_value_type_code
152985 , p_transaction_coa_id => l_adr_transaction_coa_id
152986 , p_accounting_coa_id => l_adr_accounting_coa_id
152987 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
152988 , p_adr_type_code => 'S'
152989 , p_component_type => l_component_type
152990 , p_component_code => l_component_code
152991 , p_component_type_code => l_component_type_code
152992 , p_component_appl_id => l_component_appl_id
152993 , p_amb_context_code => l_amb_context_code
152994 , p_side => 'NA'
152995 );
152996
152997
152998 --
152999 --
153000 END IF;
153001
153002 --
153003 -- Update the line information that should be overwritten
153004 --
153005 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
153006 p_header_num => 1);
153007 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
153008
153009 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
153010
153011 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
153012 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
153013 END IF;
153014
153015 --
153016 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
153017 --
153018 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
153019 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
153020 ELSE
153021 ---------------------------------------------------------------------------------------------------
153022 -- 4262811a Switch Sign
153023 ---------------------------------------------------------------------------------------------------
153024 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
153025 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
153026 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153027 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
153028 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153029 -- 5132302
153030 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
153031 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153032
153033 END IF;
153034
153035 -- 4955764
153036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
153037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
153038
153039
153040 XLA_AE_LINES_PKG.ValidateCurrentLine;
153041 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
153042
153043 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
153044 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
153045 ,p_balance_type_code => l_balance_type_code);
153046
153047 END IF;
153048
153049 -----------------------------------------------------------------------------------------
153050 -- 4262811 Multiperiod Accounting
153051 -----------------------------------------------------------------------------------------
153052 -- No MPA option is assigned.
153053
153054
153055 END IF;
153056 END IF;
153057 --
153058
153059 --
153060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
153061 trace
153062 (p_msg => 'END of AcctLineType_285'
153063 ,p_level => C_LEVEL_PROCEDURE
153064 ,p_module => l_log_module);
153065 END IF;
153066 --
153067 EXCEPTION
153068 WHEN xla_exceptions_pkg.application_exception THEN
153069 RAISE;
153070 WHEN OTHERS THEN
153071 xla_exceptions_pkg.raise_message
153072 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_285');
153073 END AcctLineType_285;
153074 --
153075
153076 ---------------------------------------
153077 --
153078 -- PRIVATE FUNCTION
153079 -- AcctLineType_286
153080 --
153081 ---------------------------------------
153082 PROCEDURE AcctLineType_286 (
153083 p_application_id IN NUMBER
153084 ,p_event_id IN NUMBER
153085 ,p_calculate_acctd_flag IN VARCHAR2
153086 ,p_calculate_g_l_flag IN VARCHAR2
153087 ,p_actual_flag IN OUT VARCHAR2
153088 ,p_balance_type_code OUT VARCHAR2
153089 ,p_gain_or_loss_ref OUT VARCHAR2
153090
153091 --TRANSACTION_ID
153092 , p_source_1 IN NUMBER
153093 --Item Concatenated Segments
153094 , p_source_2 IN VARCHAR2
153095 --Transaction Quantity
153096 , p_source_3 IN NUMBER
153097 --Transaction Unit of Measure Code
153098 , p_source_4 IN VARCHAR2
153099 --Inventory Transaction Type Description
153100 , p_source_5 IN VARCHAR2
153101 --Cost Element Name
153102 , p_source_15 IN NUMBER
153103 --Product Line Accounting Category Material Account
153104 , p_source_41 IN NUMBER
153105 --Product Line Accounting Category Material Overhead Account
153106 , p_source_42 IN NUMBER
153107 --Product Line Accounting Category Resource Account
153108 , p_source_43 IN NUMBER
153109 --Product Line Accounting Category Outside Processing Account
153110 , p_source_44 IN NUMBER
153111 --Product Line Accounting Category Overhead Account
153112 , p_source_45 IN NUMBER
153113 --DISTRIBUTION_IDENTIFIER
153114 , p_source_84 IN NUMBER
153115 --Distribution Type
153116 , p_source_85 IN VARCHAR2
153117 , p_source_85_meaning IN VARCHAR2
153118 --Entered Currency Code
153119 , p_source_88 IN VARCHAR2
153120 --Entered Amount
153121 , p_source_91 IN NUMBER
153122 --Currency Conversion Date
153123 , p_source_92 IN DATE
153124 --Currency Conversion Rate
153125 , p_source_93 IN NUMBER
153126 --Currency Conversion Type
153127 , p_source_94 IN VARCHAR2
153128 --Accounted Amount
153129 , p_source_95 IN NUMBER
153130 --Accounting Line Type
153131 , p_source_97 IN NUMBER
153132 --Organization Code
153133 , p_source_108 IN VARCHAR2
153134 )
153135 IS
153136
153137 l_component_type VARCHAR2(80);
153138 l_component_code VARCHAR2(30);
153139 l_component_type_code VARCHAR2(1);
153140 l_component_appl_id INTEGER;
153141 l_amb_context_code VARCHAR2(30);
153142 l_entity_code VARCHAR2(30);
153143 l_event_class_code VARCHAR2(30);
153144 l_ae_header_id NUMBER;
153145 l_event_type_code VARCHAR2(30);
153146 l_line_definition_code VARCHAR2(30);
153147 l_line_definition_owner_code VARCHAR2(1);
153148 --
153149 -- adr variables
153150 l_segment VARCHAR2(30);
153151 l_ccid NUMBER;
153152 l_adr_transaction_coa_id NUMBER;
153153 l_adr_accounting_coa_id NUMBER;
153154 l_adr_flexfield_segment_code VARCHAR2(30);
153155 l_adr_flex_value_set_id NUMBER;
153156 l_adr_value_type_code VARCHAR2(30);
153157 l_adr_value_combination_id NUMBER;
153158 l_adr_value_segment_code VARCHAR2(30);
153159
153160 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
153161 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
153162 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
153163 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
153164
153165 -- 4262811 Variables ------------------------------------------------------------------------------------------
153166 l_entered_amt_idx NUMBER;
153167 l_accted_amt_idx NUMBER;
153168 l_acc_rev_flag VARCHAR2(1);
153169 l_accrual_line_num NUMBER;
153170 l_tmp_amt NUMBER;
153171 l_acc_rev_natural_side_code VARCHAR2(1);
153172
153173 l_num_entries NUMBER;
153174 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
153175 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
153176 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
153177 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
153178 l_recog_line_1 NUMBER;
153179 l_recog_line_2 NUMBER;
153180
153181 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
153182 l_bflow_applied_to_amt NUMBER; -- 5132302
153183 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
153184
153185 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
153186
153187 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
153188 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
153189
153190 ---------------------------------------------------------------------------------------------------------------
153191
153192
153193 --
153194 -- bulk performance
153195 --
153196 l_balance_type_code VARCHAR2(1);
153197 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
153198 l_log_module VARCHAR2(240);
153199
153200 --
153201 -- Upgrade strategy
153202 --
153203 l_actual_upg_option VARCHAR2(1);
153204 l_enc_upg_option VARCHAR2(1);
153205
153206 --
153207 BEGIN
153208 --
153209 IF g_log_enabled THEN
153210 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_286';
153211 END IF;
153212 --
153213 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
153214
153215 trace
153216 (p_msg => 'BEGIN of AcctLineType_286'
153217 ,p_level => C_LEVEL_PROCEDURE
153218 ,p_module => l_log_module);
153219
153220 END IF;
153221 --
153222 l_component_type := 'AMB_JLT';
153223 l_component_code := 'INVENTORY_VALUATION';
153224 l_component_type_code := 'S';
153225 l_component_appl_id := 707;
153226 l_amb_context_code := 'DEFAULT';
153227 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
153228 l_event_class_code := 'USER_DEFINE';
153229 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
153230 l_line_definition_owner_code := 'S';
153231 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
153232 --
153233 l_balance_type_code := 'A';
153234 l_segment := NULL;
153235 l_ccid := NULL;
153236 l_adr_transaction_coa_id := NULL;
153237 l_adr_accounting_coa_id := NULL;
153238 l_adr_flexfield_segment_code := NULL;
153239 l_adr_flex_value_set_id := NULL;
153240 l_adr_value_type_code := NULL;
153241 l_adr_value_combination_id := NULL;
153242 l_adr_value_segment_code := NULL;
153243
153244 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
153245 l_bflow_class_code := ''; -- 4219869 Business Flow
153246 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
153247 l_budgetary_control_flag := 'N';
153248
153249 l_bflow_applied_to_amt_idx := NULL; -- 5132302
153250 l_bflow_applied_to_amt := NULL; -- 5132302
153251 l_entered_amt_idx := NULL; -- 4262811
153252 l_accted_amt_idx := NULL; -- 4262811
153253 l_acc_rev_flag := NULL; -- 4262811
153254 l_accrual_line_num := NULL; -- 4262811
153255 l_tmp_amt := NULL; -- 4262811
153256 --
153257
153258 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
153259 l_balance_type_code <> 'B' THEN
153260 IF NVL(p_source_97,9E125) = 1
153261 THEN
153262
153263 --
153264 XLA_AE_LINES_PKG.SetNewLine;
153265
153266 p_balance_type_code := l_balance_type_code;
153267 -- set the flag so later we will know whether the gain loss line needs to be created
153268
153269 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
153270 p_actual_flag :='A';
153271 END IF;
153272
153273 --
153274 -- bulk performance
153275 --
153276 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
153277 p_header_num => 0); -- 4262811
153278 --
153279 -- set accounting line options
153280 --
153281 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
153282 p_natural_side_code => 'D'
153283 , p_gain_or_loss_flag => 'N'
153284 , p_gl_transfer_mode_code => 'S'
153285 , p_acct_entry_type_code => 'A'
153286 , p_switch_side_flag => 'Y'
153287 , p_merge_duplicate_code => 'N'
153288 );
153289 --
153290 l_acc_rev_natural_side_code := 'C'; -- 4262811
153291 --
153292 --
153293 -- set accounting line type info
153294 --
153295 xla_ae_lines_pkg.SetAcctLineType
153296 (p_component_type => l_component_type
153297 ,p_event_type_code => l_event_type_code
153298 ,p_line_definition_owner_code => l_line_definition_owner_code
153299 ,p_line_definition_code => l_line_definition_code
153300 ,p_accounting_line_code => l_component_code
153301 ,p_accounting_line_type_code => l_component_type_code
153302 ,p_accounting_line_appl_id => l_component_appl_id
153303 ,p_amb_context_code => l_amb_context_code
153304 ,p_entity_code => l_entity_code
153305 ,p_event_class_code => l_event_class_code);
153306 --
153307 -- set accounting class
153308 --
153309 xla_ae_lines_pkg.SetAcctClass(
153310 p_accounting_class_code => 'INVENTORY_VALUATION'
153311 , p_ae_header_id => l_ae_header_id
153312 );
153313
153314 --
153315 -- set rounding class
153316 --
153317 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
153318 'INVENTORY_VALUATION';
153319
153320 --
153321 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
153322 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
153323 --
153324 -- bulk performance
153325 --
153326 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
153327
153328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
153329 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
153330
153331 -- 4955764
153332 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
153333 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
153334
153335 -- 4458381 Public Sector Enh
153336
153337 --
153338 -- set accounting attributes for the line type
153339 --
153340 l_entered_amt_idx := 3;
153341 l_accted_amt_idx := 8;
153342 l_bflow_applied_to_amt_idx := NULL; -- 5132302
153343 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
153344 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
153345 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
153346 l_rec_acct_attrs.array_char_value(2) := p_source_85;
153347 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
153348 l_rec_acct_attrs.array_num_value(3) := p_source_91;
153349 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
153350 l_rec_acct_attrs.array_char_value(4) := p_source_88;
153351 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
153352 l_rec_acct_attrs.array_date_value(5) := p_source_92;
153353 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
153354 l_rec_acct_attrs.array_num_value(6) := p_source_93;
153355 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
153356 l_rec_acct_attrs.array_char_value(7) := p_source_94;
153357 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
153358 l_rec_acct_attrs.array_num_value(8) := p_source_95;
153359
153360 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
153361 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
153362
153363 ---------------------------------------------------------------------------------------------------------------
153364 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
153365 ---------------------------------------------------------------------------------------------------------------
153366 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
153367
153368 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
153369 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
153370
153371 IF xla_accounting_cache_pkg.GetValueChar
153372 (p_source_code => 'LEDGER_CATEGORY_CODE'
153373 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
153374 AND l_bflow_method_code = 'PRIOR_ENTRY'
153375 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
153376 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
153377 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
153378 )
153379 THEN
153380 xla_ae_lines_pkg.BflowUpgEntry
153381 (p_business_method_code => l_bflow_method_code
153382 ,p_business_class_code => l_bflow_class_code
153383 ,p_balance_type => l_balance_type_code);
153384 ELSE
153385 NULL;
153386 -- No business flow processing for business flow method of NONE.
153387 END IF;
153388
153389 --
153390 -- call analytical criteria
153391 --
153392
153393
153394 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
153395 xla_ae_lines_pkg.SetAnalyticalCriteria(
153396 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
153397 , p_analytical_criterion_owner => 'S'
153398 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
153399 , p_amb_context_code => 'DEFAULT'
153400 , p_balancing_flag => 'Y'
153401
153402 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
153403 , p_analytical_detail_num_1 => NULL
153404 , p_analytical_detail_date_1 => NULL
153405
153406 , p_ae_header_id => l_ae_header_id
153407 )
153408 ;
153409 --
153410
153411 --
153412 -- call description
153413 --
153414
153415 xla_ae_lines_pkg.SetLineDescription(
153416 p_ae_header_id => l_ae_header_id
153417 ,p_description => Description_1 (
153418 p_application_id => p_application_id
153419 , p_ae_header_id => l_ae_header_id
153420 , p_source_1 => p_source_1
153421 , p_source_2 => p_source_2
153422 , p_source_3 => p_source_3
153423 , p_source_4 => p_source_4
153424 , p_source_5 => p_source_5
153425 )
153426 );
153427
153428
153429 --
153430 -- call ADRs
153431 -- Bug 4922099
153432 --
153433 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
153434 (NVL(l_actual_upg_option, 'N') = 'O') OR
153435 (NVL(l_enc_upg_option, 'N') = 'O')
153436 )
153437 THEN
153438 NULL;
153439 --
153440 --
153441
153442 l_ccid := AcctDerRule_28(
153443 p_application_id => p_application_id
153444 , p_ae_header_id => l_ae_header_id
153445 , p_source_15 => p_source_15
153446 , p_source_41 => p_source_41
153447 , p_source_42 => p_source_42
153448 , p_source_43 => p_source_43
153449 , p_source_44 => p_source_44
153450 , p_source_45 => p_source_45
153451 , x_transaction_coa_id => l_adr_transaction_coa_id
153452 , x_accounting_coa_id => l_adr_accounting_coa_id
153453 , x_value_type_code => l_adr_value_type_code
153454 , p_side => 'NA'
153455 );
153456
153457 xla_ae_lines_pkg.set_ccid(
153458 p_code_combination_id => l_ccid
153459 , p_value_type_code => l_adr_value_type_code
153460 , p_transaction_coa_id => l_adr_transaction_coa_id
153461 , p_accounting_coa_id => l_adr_accounting_coa_id
153462 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
153463 , p_adr_type_code => 'S'
153464 , p_component_type => l_component_type
153465 , p_component_code => l_component_code
153466 , p_component_type_code => l_component_type_code
153467 , p_component_appl_id => l_component_appl_id
153468 , p_amb_context_code => l_amb_context_code
153469 , p_side => 'NA'
153470 );
153471
153472
153473 --
153474 --
153475 END IF;
153476 --
153477 -- Bug 4922099
153478 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
153479 (NVL(l_enc_upg_option, 'N') = 'O')
153480 ) AND
153481 (l_bflow_method_code = 'PRIOR_ENTRY')
153482 )
153483 THEN
153484 IF
153485 --
153486 1 = 2
153487 --
153488 THEN
153489 xla_accounting_err_pkg.build_message
153490 (p_appli_s_name => 'XLA'
153491 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
153492 ,p_token_1 => 'LINE_NUMBER'
153493 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
153494 ,p_token_2 => 'LINE_TYPE_NAME'
153495 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
153496 l_component_type
153497 ,l_component_code
153498 ,l_component_type_code
153499 ,l_component_appl_id
153500 ,l_amb_context_code
153501 ,l_entity_code
153502 ,l_event_class_code
153503 )
153504 ,p_token_3 => 'OWNER'
153505 ,p_value_3 => xla_lookups_pkg.get_meaning(
153506 p_lookup_type => 'XLA_OWNER_TYPE'
153507 ,p_lookup_code => l_component_type_code
153508 )
153509 ,p_token_4 => 'PRODUCT_NAME'
153510 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
153511 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
153512 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
153513 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
153514 ,p_ae_header_id => NULL
153515 );
153516
153517 IF (C_LEVEL_ERROR>= g_log_level) THEN
153518 trace
153519 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
153520 ,p_level => C_LEVEL_ERROR
153521 ,p_module => l_log_module);
153522 END IF;
153523 END IF;
153524 END IF;
153525 --
153526 --
153527 ------------------------------------------------------------------------------------------------
153528 -- 4219869 Business Flow
153529 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
153530 -- Prior Entry. Currently, the following code is always generated.
153531 ------------------------------------------------------------------------------------------------
153532 XLA_AE_LINES_PKG.ValidateCurrentLine;
153533
153534 ------------------------------------------------------------------------------------
153535 -- 4219869 Business Flow
153536 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
153537 ------------------------------------------------------------------------------------
153538 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
153539
153540 ----------------------------------------------------------------------------------
153541 -- 4219869 Business Flow
153542 -- Update journal entry status -- Need to generate this within IF <condition>
153543 ----------------------------------------------------------------------------------
153544 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
153545 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
153546 ,p_balance_type_code => l_balance_type_code
153547 );
153548
153549 -------------------------------------------------------------------------------------------
153550 -- 4262811 - Generate the Accrual Reversal lines
153551 -------------------------------------------------------------------------------------------
153552 BEGIN
153553 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
153554 (g_array_event(p_event_id).array_value_num('header_index'));
153555 IF l_acc_rev_flag IS NULL THEN
153556 l_acc_rev_flag := 'N';
153557 END IF;
153558 EXCEPTION
153559 WHEN OTHERS THEN
153560 l_acc_rev_flag := 'N';
153561 END;
153562 --
153563 IF (l_acc_rev_flag = 'Y') THEN
153564
153565 -- 4645092 ------------------------------------------------------------------------------
153566 -- To allow MPA report to determine if it should generate report process
153567 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
153568 ------------------------------------------------------------------------------------------
153569
153570 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
153571 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
153572 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
153573 -- call ADRs
153574 -- Bug 4922099
153575 --
153576 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
153577 (NVL(l_actual_upg_option, 'N') = 'O') OR
153578 (NVL(l_enc_upg_option, 'N') = 'O')
153579 )
153580 THEN
153581 NULL;
153582 --
153583 --
153584
153585 l_ccid := AcctDerRule_28(
153586 p_application_id => p_application_id
153587 , p_ae_header_id => l_ae_header_id
153588 , p_source_15 => p_source_15
153589 , p_source_41 => p_source_41
153590 , p_source_42 => p_source_42
153591 , p_source_43 => p_source_43
153592 , p_source_44 => p_source_44
153593 , p_source_45 => p_source_45
153594 , x_transaction_coa_id => l_adr_transaction_coa_id
153595 , x_accounting_coa_id => l_adr_accounting_coa_id
153596 , x_value_type_code => l_adr_value_type_code
153597 , p_side => 'NA'
153598 );
153599
153600 xla_ae_lines_pkg.set_ccid(
153601 p_code_combination_id => l_ccid
153602 , p_value_type_code => l_adr_value_type_code
153603 , p_transaction_coa_id => l_adr_transaction_coa_id
153604 , p_accounting_coa_id => l_adr_accounting_coa_id
153605 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
153606 , p_adr_type_code => 'S'
153607 , p_component_type => l_component_type
153608 , p_component_code => l_component_code
153609 , p_component_type_code => l_component_type_code
153610 , p_component_appl_id => l_component_appl_id
153611 , p_amb_context_code => l_amb_context_code
153612 , p_side => 'NA'
153613 );
153614
153615
153616 --
153617 --
153618 END IF;
153619
153620 --
153621 -- Update the line information that should be overwritten
153622 --
153623 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
153624 p_header_num => 1);
153625 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
153626
153627 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
153628
153629 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
153630 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
153631 END IF;
153632
153633 --
153634 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
153635 --
153636 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
153637 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
153638 ELSE
153639 ---------------------------------------------------------------------------------------------------
153640 -- 4262811a Switch Sign
153641 ---------------------------------------------------------------------------------------------------
153642 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
153643 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
153644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153645 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
153646 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153647 -- 5132302
153648 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
153649 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
153650
153651 END IF;
153652
153653 -- 4955764
153654 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
153655 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
153656
153657
153658 XLA_AE_LINES_PKG.ValidateCurrentLine;
153659 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
153660
153661 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
153662 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
153663 ,p_balance_type_code => l_balance_type_code);
153664
153665 END IF;
153666
153667 -----------------------------------------------------------------------------------------
153668 -- 4262811 Multiperiod Accounting
153669 -----------------------------------------------------------------------------------------
153670 -- No MPA option is assigned.
153671
153672
153673 END IF;
153674 END IF;
153675 --
153676
153677 --
153678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
153679 trace
153680 (p_msg => 'END of AcctLineType_286'
153681 ,p_level => C_LEVEL_PROCEDURE
153682 ,p_module => l_log_module);
153683 END IF;
153684 --
153685 EXCEPTION
153686 WHEN xla_exceptions_pkg.application_exception THEN
153687 RAISE;
153688 WHEN OTHERS THEN
153689 xla_exceptions_pkg.raise_message
153690 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_286');
153691 END AcctLineType_286;
153692 --
153693
153694 ---------------------------------------
153695 --
153696 -- PRIVATE FUNCTION
153697 -- AcctLineType_287
153698 --
153699 ---------------------------------------
153700 PROCEDURE AcctLineType_287 (
153701 p_application_id IN NUMBER
153702 ,p_event_id IN NUMBER
153703 ,p_calculate_acctd_flag IN VARCHAR2
153704 ,p_calculate_g_l_flag IN VARCHAR2
153705 ,p_actual_flag IN OUT VARCHAR2
153706 ,p_balance_type_code OUT VARCHAR2
153707 ,p_gain_or_loss_ref OUT VARCHAR2
153708
153709 --TRANSACTION_ID
153710 , p_source_1 IN NUMBER
153711 --Item Concatenated Segments
153712 , p_source_2 IN VARCHAR2
153713 --Transaction Quantity
153714 , p_source_3 IN NUMBER
153715 --Transaction Unit of Measure Code
153716 , p_source_4 IN VARCHAR2
153717 --Inventory Transaction Type Description
153718 , p_source_5 IN VARCHAR2
153719 --Cost Element Name
153720 , p_source_15 IN NUMBER
153721 --Product Line Accounting Category Material Account
153722 , p_source_41 IN NUMBER
153723 --Product Line Accounting Category Material Overhead Account
153724 , p_source_42 IN NUMBER
153725 --Product Line Accounting Category Resource Account
153726 , p_source_43 IN NUMBER
153727 --Product Line Accounting Category Outside Processing Account
153728 , p_source_44 IN NUMBER
153729 --Product Line Accounting Category Overhead Account
153730 , p_source_45 IN NUMBER
153731 --DISTRIBUTION_IDENTIFIER
153732 , p_source_84 IN NUMBER
153733 --Distribution Type
153734 , p_source_85 IN VARCHAR2
153735 , p_source_85_meaning IN VARCHAR2
153736 --Entered Currency Code
153737 , p_source_88 IN VARCHAR2
153738 --Entered Amount
153739 , p_source_91 IN NUMBER
153740 --Currency Conversion Date
153741 , p_source_92 IN DATE
153742 --Currency Conversion Rate
153743 , p_source_93 IN NUMBER
153744 --Currency Conversion Type
153745 , p_source_94 IN VARCHAR2
153746 --Accounted Amount
153747 , p_source_95 IN NUMBER
153748 --Accounting Line Type
153749 , p_source_97 IN NUMBER
153750 --Organization Code
153751 , p_source_108 IN VARCHAR2
153752 )
153753 IS
153754
153755 l_component_type VARCHAR2(80);
153756 l_component_code VARCHAR2(30);
153757 l_component_type_code VARCHAR2(1);
153758 l_component_appl_id INTEGER;
153759 l_amb_context_code VARCHAR2(30);
153760 l_entity_code VARCHAR2(30);
153761 l_event_class_code VARCHAR2(30);
153762 l_ae_header_id NUMBER;
153763 l_event_type_code VARCHAR2(30);
153764 l_line_definition_code VARCHAR2(30);
153765 l_line_definition_owner_code VARCHAR2(1);
153766 --
153767 -- adr variables
153768 l_segment VARCHAR2(30);
153769 l_ccid NUMBER;
153770 l_adr_transaction_coa_id NUMBER;
153771 l_adr_accounting_coa_id NUMBER;
153772 l_adr_flexfield_segment_code VARCHAR2(30);
153773 l_adr_flex_value_set_id NUMBER;
153774 l_adr_value_type_code VARCHAR2(30);
153775 l_adr_value_combination_id NUMBER;
153776 l_adr_value_segment_code VARCHAR2(30);
153777
153778 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
153779 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
153780 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
153781 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
153782
153783 -- 4262811 Variables ------------------------------------------------------------------------------------------
153784 l_entered_amt_idx NUMBER;
153785 l_accted_amt_idx NUMBER;
153786 l_acc_rev_flag VARCHAR2(1);
153787 l_accrual_line_num NUMBER;
153788 l_tmp_amt NUMBER;
153789 l_acc_rev_natural_side_code VARCHAR2(1);
153790
153791 l_num_entries NUMBER;
153792 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
153793 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
153794 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
153795 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
153796 l_recog_line_1 NUMBER;
153797 l_recog_line_2 NUMBER;
153798
153799 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
153800 l_bflow_applied_to_amt NUMBER; -- 5132302
153801 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
153802
153803 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
153804
153805 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
153806 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
153807
153808 ---------------------------------------------------------------------------------------------------------------
153809
153810
153811 --
153812 -- bulk performance
153813 --
153814 l_balance_type_code VARCHAR2(1);
153815 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
153816 l_log_module VARCHAR2(240);
153817
153818 --
153819 -- Upgrade strategy
153820 --
153821 l_actual_upg_option VARCHAR2(1);
153822 l_enc_upg_option VARCHAR2(1);
153823
153824 --
153825 BEGIN
153826 --
153827 IF g_log_enabled THEN
153828 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_287';
153829 END IF;
153830 --
153831 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
153832
153833 trace
153834 (p_msg => 'BEGIN of AcctLineType_287'
153835 ,p_level => C_LEVEL_PROCEDURE
153836 ,p_module => l_log_module);
153837
153838 END IF;
153839 --
153840 l_component_type := 'AMB_JLT';
153841 l_component_code := 'INVENTORY_VALUATION';
153842 l_component_type_code := 'S';
153843 l_component_appl_id := 707;
153844 l_amb_context_code := 'DEFAULT';
153845 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
153846 l_event_class_code := 'USER_DEFINE';
153847 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
153848 l_line_definition_owner_code := 'S';
153849 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
153850 --
153851 l_balance_type_code := 'A';
153852 l_segment := NULL;
153853 l_ccid := NULL;
153854 l_adr_transaction_coa_id := NULL;
153855 l_adr_accounting_coa_id := NULL;
153856 l_adr_flexfield_segment_code := NULL;
153857 l_adr_flex_value_set_id := NULL;
153858 l_adr_value_type_code := NULL;
153859 l_adr_value_combination_id := NULL;
153860 l_adr_value_segment_code := NULL;
153861
153862 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
153863 l_bflow_class_code := ''; -- 4219869 Business Flow
153864 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
153865 l_budgetary_control_flag := 'N';
153866
153867 l_bflow_applied_to_amt_idx := NULL; -- 5132302
153868 l_bflow_applied_to_amt := NULL; -- 5132302
153869 l_entered_amt_idx := NULL; -- 4262811
153870 l_accted_amt_idx := NULL; -- 4262811
153871 l_acc_rev_flag := NULL; -- 4262811
153872 l_accrual_line_num := NULL; -- 4262811
153873 l_tmp_amt := NULL; -- 4262811
153874 --
153875
153876 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
153877 l_balance_type_code <> 'B' THEN
153878 IF NVL(p_source_97,9E125) = 1
153879 THEN
153880
153881 --
153882 XLA_AE_LINES_PKG.SetNewLine;
153883
153884 p_balance_type_code := l_balance_type_code;
153885 -- set the flag so later we will know whether the gain loss line needs to be created
153886
153887 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
153888 p_actual_flag :='A';
153889 END IF;
153890
153891 --
153892 -- bulk performance
153893 --
153894 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
153895 p_header_num => 0); -- 4262811
153896 --
153897 -- set accounting line options
153898 --
153899 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
153900 p_natural_side_code => 'D'
153901 , p_gain_or_loss_flag => 'N'
153902 , p_gl_transfer_mode_code => 'S'
153903 , p_acct_entry_type_code => 'A'
153904 , p_switch_side_flag => 'Y'
153905 , p_merge_duplicate_code => 'N'
153906 );
153907 --
153908 l_acc_rev_natural_side_code := 'C'; -- 4262811
153909 --
153910 --
153911 -- set accounting line type info
153912 --
153913 xla_ae_lines_pkg.SetAcctLineType
153914 (p_component_type => l_component_type
153915 ,p_event_type_code => l_event_type_code
153916 ,p_line_definition_owner_code => l_line_definition_owner_code
153917 ,p_line_definition_code => l_line_definition_code
153918 ,p_accounting_line_code => l_component_code
153919 ,p_accounting_line_type_code => l_component_type_code
153920 ,p_accounting_line_appl_id => l_component_appl_id
153921 ,p_amb_context_code => l_amb_context_code
153922 ,p_entity_code => l_entity_code
153923 ,p_event_class_code => l_event_class_code);
153924 --
153925 -- set accounting class
153926 --
153927 xla_ae_lines_pkg.SetAcctClass(
153928 p_accounting_class_code => 'INVENTORY_VALUATION'
153929 , p_ae_header_id => l_ae_header_id
153930 );
153931
153932 --
153933 -- set rounding class
153934 --
153935 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
153936 'INVENTORY_VALUATION';
153937
153938 --
153939 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
153940 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
153941 --
153942 -- bulk performance
153943 --
153944 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
153945
153946 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
153947 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
153948
153949 -- 4955764
153950 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
153951 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
153952
153953 -- 4458381 Public Sector Enh
153954
153955 --
153956 -- set accounting attributes for the line type
153957 --
153958 l_entered_amt_idx := 3;
153959 l_accted_amt_idx := 8;
153960 l_bflow_applied_to_amt_idx := NULL; -- 5132302
153961 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
153962 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
153963 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
153964 l_rec_acct_attrs.array_char_value(2) := p_source_85;
153965 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
153966 l_rec_acct_attrs.array_num_value(3) := p_source_91;
153967 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
153968 l_rec_acct_attrs.array_char_value(4) := p_source_88;
153969 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
153970 l_rec_acct_attrs.array_date_value(5) := p_source_92;
153971 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
153972 l_rec_acct_attrs.array_num_value(6) := p_source_93;
153973 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
153974 l_rec_acct_attrs.array_char_value(7) := p_source_94;
153975 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
153976 l_rec_acct_attrs.array_num_value(8) := p_source_95;
153977
153978 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
153979 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
153980
153981 ---------------------------------------------------------------------------------------------------------------
153982 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
153983 ---------------------------------------------------------------------------------------------------------------
153984 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
153985
153986 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
153987 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
153988
153989 IF xla_accounting_cache_pkg.GetValueChar
153990 (p_source_code => 'LEDGER_CATEGORY_CODE'
153991 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
153992 AND l_bflow_method_code = 'PRIOR_ENTRY'
153993 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
153994 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
153995 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
153996 )
153997 THEN
153998 xla_ae_lines_pkg.BflowUpgEntry
153999 (p_business_method_code => l_bflow_method_code
154000 ,p_business_class_code => l_bflow_class_code
154001 ,p_balance_type => l_balance_type_code);
154002 ELSE
154003 NULL;
154004 -- No business flow processing for business flow method of NONE.
154005 END IF;
154006
154007 --
154008 -- call analytical criteria
154009 --
154010
154011
154012 xla_ae_lines_pkg.g_rec_lines.array_anc_id_1(xla_ae_lines_pkg.g_LineNumber) :=
154013 xla_ae_lines_pkg.SetAnalyticalCriteria(
154014 p_analytical_criterion_name => 'Inventory Value Supporting Reference'
154015 , p_analytical_criterion_owner => 'S'
154016 , p_analytical_criterion_code => 'INVENTORY_VALUE_SR'
154017 , p_amb_context_code => 'DEFAULT'
154018 , p_balancing_flag => 'Y'
154019
154020 , p_analytical_detail_char_1 => TO_CHAR(p_source_108)
154021 , p_analytical_detail_num_1 => NULL
154022 , p_analytical_detail_date_1 => NULL
154023
154024 , p_ae_header_id => l_ae_header_id
154025 )
154026 ;
154027 --
154028
154029 --
154030 -- call description
154031 --
154032
154033 xla_ae_lines_pkg.SetLineDescription(
154034 p_ae_header_id => l_ae_header_id
154035 ,p_description => Description_1 (
154036 p_application_id => p_application_id
154037 , p_ae_header_id => l_ae_header_id
154038 , p_source_1 => p_source_1
154039 , p_source_2 => p_source_2
154040 , p_source_3 => p_source_3
154041 , p_source_4 => p_source_4
154042 , p_source_5 => p_source_5
154043 )
154044 );
154045
154046
154047 --
154048 -- call ADRs
154049 -- Bug 4922099
154050 --
154051 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
154052 (NVL(l_actual_upg_option, 'N') = 'O') OR
154053 (NVL(l_enc_upg_option, 'N') = 'O')
154054 )
154055 THEN
154056 NULL;
154057 --
154058 --
154059
154060 l_ccid := AcctDerRule_28(
154061 p_application_id => p_application_id
154062 , p_ae_header_id => l_ae_header_id
154063 , p_source_15 => p_source_15
154064 , p_source_41 => p_source_41
154065 , p_source_42 => p_source_42
154066 , p_source_43 => p_source_43
154067 , p_source_44 => p_source_44
154068 , p_source_45 => p_source_45
154069 , x_transaction_coa_id => l_adr_transaction_coa_id
154070 , x_accounting_coa_id => l_adr_accounting_coa_id
154071 , x_value_type_code => l_adr_value_type_code
154072 , p_side => 'NA'
154073 );
154074
154075 xla_ae_lines_pkg.set_ccid(
154076 p_code_combination_id => l_ccid
154077 , p_value_type_code => l_adr_value_type_code
154078 , p_transaction_coa_id => l_adr_transaction_coa_id
154079 , p_accounting_coa_id => l_adr_accounting_coa_id
154080 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
154081 , p_adr_type_code => 'S'
154082 , p_component_type => l_component_type
154083 , p_component_code => l_component_code
154084 , p_component_type_code => l_component_type_code
154085 , p_component_appl_id => l_component_appl_id
154086 , p_amb_context_code => l_amb_context_code
154087 , p_side => 'NA'
154088 );
154089
154090
154091 --
154092 --
154093 END IF;
154094 --
154095 -- Bug 4922099
154096 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
154097 (NVL(l_enc_upg_option, 'N') = 'O')
154098 ) AND
154099 (l_bflow_method_code = 'PRIOR_ENTRY')
154100 )
154101 THEN
154102 IF
154103 --
154104 1 = 2
154105 --
154106 THEN
154107 xla_accounting_err_pkg.build_message
154108 (p_appli_s_name => 'XLA'
154109 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
154110 ,p_token_1 => 'LINE_NUMBER'
154111 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
154112 ,p_token_2 => 'LINE_TYPE_NAME'
154113 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
154114 l_component_type
154115 ,l_component_code
154116 ,l_component_type_code
154117 ,l_component_appl_id
154118 ,l_amb_context_code
154119 ,l_entity_code
154120 ,l_event_class_code
154121 )
154122 ,p_token_3 => 'OWNER'
154123 ,p_value_3 => xla_lookups_pkg.get_meaning(
154124 p_lookup_type => 'XLA_OWNER_TYPE'
154125 ,p_lookup_code => l_component_type_code
154126 )
154127 ,p_token_4 => 'PRODUCT_NAME'
154128 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
154129 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
154130 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
154131 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
154132 ,p_ae_header_id => NULL
154133 );
154134
154135 IF (C_LEVEL_ERROR>= g_log_level) THEN
154136 trace
154137 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
154138 ,p_level => C_LEVEL_ERROR
154139 ,p_module => l_log_module);
154140 END IF;
154141 END IF;
154142 END IF;
154143 --
154144 --
154145 ------------------------------------------------------------------------------------------------
154146 -- 4219869 Business Flow
154147 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
154148 -- Prior Entry. Currently, the following code is always generated.
154149 ------------------------------------------------------------------------------------------------
154150 XLA_AE_LINES_PKG.ValidateCurrentLine;
154151
154152 ------------------------------------------------------------------------------------
154153 -- 4219869 Business Flow
154154 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
154155 ------------------------------------------------------------------------------------
154156 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
154157
154158 ----------------------------------------------------------------------------------
154159 -- 4219869 Business Flow
154160 -- Update journal entry status -- Need to generate this within IF <condition>
154161 ----------------------------------------------------------------------------------
154162 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
154163 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
154164 ,p_balance_type_code => l_balance_type_code
154165 );
154166
154167 -------------------------------------------------------------------------------------------
154168 -- 4262811 - Generate the Accrual Reversal lines
154169 -------------------------------------------------------------------------------------------
154170 BEGIN
154171 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
154172 (g_array_event(p_event_id).array_value_num('header_index'));
154173 IF l_acc_rev_flag IS NULL THEN
154174 l_acc_rev_flag := 'N';
154175 END IF;
154176 EXCEPTION
154177 WHEN OTHERS THEN
154178 l_acc_rev_flag := 'N';
154179 END;
154180 --
154181 IF (l_acc_rev_flag = 'Y') THEN
154182
154183 -- 4645092 ------------------------------------------------------------------------------
154184 -- To allow MPA report to determine if it should generate report process
154185 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
154186 ------------------------------------------------------------------------------------------
154187
154188 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
154189 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
154190 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
154191 -- call ADRs
154192 -- Bug 4922099
154193 --
154194 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
154195 (NVL(l_actual_upg_option, 'N') = 'O') OR
154196 (NVL(l_enc_upg_option, 'N') = 'O')
154197 )
154198 THEN
154199 NULL;
154200 --
154201 --
154202
154203 l_ccid := AcctDerRule_28(
154204 p_application_id => p_application_id
154205 , p_ae_header_id => l_ae_header_id
154206 , p_source_15 => p_source_15
154207 , p_source_41 => p_source_41
154208 , p_source_42 => p_source_42
154209 , p_source_43 => p_source_43
154210 , p_source_44 => p_source_44
154211 , p_source_45 => p_source_45
154212 , x_transaction_coa_id => l_adr_transaction_coa_id
154213 , x_accounting_coa_id => l_adr_accounting_coa_id
154214 , x_value_type_code => l_adr_value_type_code
154215 , p_side => 'NA'
154216 );
154217
154218 xla_ae_lines_pkg.set_ccid(
154219 p_code_combination_id => l_ccid
154220 , p_value_type_code => l_adr_value_type_code
154221 , p_transaction_coa_id => l_adr_transaction_coa_id
154222 , p_accounting_coa_id => l_adr_accounting_coa_id
154223 , p_adr_code => 'PI_INVENTORY_ACCOUNT'
154224 , p_adr_type_code => 'S'
154225 , p_component_type => l_component_type
154226 , p_component_code => l_component_code
154227 , p_component_type_code => l_component_type_code
154228 , p_component_appl_id => l_component_appl_id
154229 , p_amb_context_code => l_amb_context_code
154230 , p_side => 'NA'
154231 );
154232
154233
154234 --
154235 --
154236 END IF;
154237
154238 --
154239 -- Update the line information that should be overwritten
154240 --
154241 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
154242 p_header_num => 1);
154243 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
154244
154245 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
154246
154247 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
154248 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
154249 END IF;
154250
154251 --
154252 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
154253 --
154254 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
154255 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
154256 ELSE
154257 ---------------------------------------------------------------------------------------------------
154258 -- 4262811a Switch Sign
154259 ---------------------------------------------------------------------------------------------------
154260 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
154261 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
154262 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154263 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
154264 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154265 -- 5132302
154266 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
154267 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154268
154269 END IF;
154270
154271 -- 4955764
154272 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
154273 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
154274
154275
154276 XLA_AE_LINES_PKG.ValidateCurrentLine;
154277 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
154278
154279 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
154280 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
154281 ,p_balance_type_code => l_balance_type_code);
154282
154283 END IF;
154284
154285 -----------------------------------------------------------------------------------------
154286 -- 4262811 Multiperiod Accounting
154287 -----------------------------------------------------------------------------------------
154288 -- No MPA option is assigned.
154289
154290
154291 END IF;
154292 END IF;
154293 --
154294
154295 --
154296 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
154297 trace
154298 (p_msg => 'END of AcctLineType_287'
154299 ,p_level => C_LEVEL_PROCEDURE
154300 ,p_module => l_log_module);
154301 END IF;
154302 --
154303 EXCEPTION
154304 WHEN xla_exceptions_pkg.application_exception THEN
154305 RAISE;
154306 WHEN OTHERS THEN
154307 xla_exceptions_pkg.raise_message
154308 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_287');
154309 END AcctLineType_287;
154310 --
154311
154312 ---------------------------------------
154313 --
154314 -- PRIVATE FUNCTION
154315 -- AcctLineType_288
154316 --
154317 ---------------------------------------
154318 PROCEDURE AcctLineType_288 (
154319 p_application_id IN NUMBER
154320 ,p_event_id IN NUMBER
154321 ,p_calculate_acctd_flag IN VARCHAR2
154322 ,p_calculate_g_l_flag IN VARCHAR2
154323 ,p_actual_flag IN OUT VARCHAR2
154324 ,p_balance_type_code OUT VARCHAR2
154325 ,p_gain_or_loss_ref OUT VARCHAR2
154326
154327 --Cost Management Default Account
154328 , p_source_11 IN NUMBER
154329 --Receiving Accounting Line Type
154330 , p_source_78 IN VARCHAR2
154331 --DISTRIBUTION_IDENTIFIER
154332 , p_source_84 IN NUMBER
154333 --Distribution Type
154334 , p_source_85 IN VARCHAR2
154335 , p_source_85_meaning IN VARCHAR2
154336 --Entered Amount
154337 , p_source_91 IN NUMBER
154338 --Accounted Amount
154339 , p_source_95 IN NUMBER
154340 --Entered Currency Code
154341 , p_source_105 IN VARCHAR2
154342 --Currency Conversion Date
154343 , p_source_106 IN DATE
154344 --Currency Conversion Rate
154345 , p_source_107 IN NUMBER
154346 --Currency Conversion Type
154347 , p_source_109 IN VARCHAR2
154348 )
154349 IS
154350
154351 l_component_type VARCHAR2(80);
154352 l_component_code VARCHAR2(30);
154353 l_component_type_code VARCHAR2(1);
154354 l_component_appl_id INTEGER;
154355 l_amb_context_code VARCHAR2(30);
154356 l_entity_code VARCHAR2(30);
154357 l_event_class_code VARCHAR2(30);
154358 l_ae_header_id NUMBER;
154359 l_event_type_code VARCHAR2(30);
154360 l_line_definition_code VARCHAR2(30);
154361 l_line_definition_owner_code VARCHAR2(1);
154362 --
154363 -- adr variables
154364 l_segment VARCHAR2(30);
154365 l_ccid NUMBER;
154366 l_adr_transaction_coa_id NUMBER;
154367 l_adr_accounting_coa_id NUMBER;
154368 l_adr_flexfield_segment_code VARCHAR2(30);
154369 l_adr_flex_value_set_id NUMBER;
154370 l_adr_value_type_code VARCHAR2(30);
154371 l_adr_value_combination_id NUMBER;
154372 l_adr_value_segment_code VARCHAR2(30);
154373
154374 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
154375 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
154376 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
154377 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
154378
154379 -- 4262811 Variables ------------------------------------------------------------------------------------------
154380 l_entered_amt_idx NUMBER;
154381 l_accted_amt_idx NUMBER;
154382 l_acc_rev_flag VARCHAR2(1);
154383 l_accrual_line_num NUMBER;
154384 l_tmp_amt NUMBER;
154385 l_acc_rev_natural_side_code VARCHAR2(1);
154386
154387 l_num_entries NUMBER;
154388 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
154389 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
154390 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
154391 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
154392 l_recog_line_1 NUMBER;
154393 l_recog_line_2 NUMBER;
154394
154395 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
154396 l_bflow_applied_to_amt NUMBER; -- 5132302
154397 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
154398
154399 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
154400
154401 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
154402 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
154403
154404 ---------------------------------------------------------------------------------------------------------------
154405
154406
154407 --
154408 -- bulk performance
154409 --
154410 l_balance_type_code VARCHAR2(1);
154411 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
154412 l_log_module VARCHAR2(240);
154413
154414 --
154415 -- Upgrade strategy
154416 --
154417 l_actual_upg_option VARCHAR2(1);
154418 l_enc_upg_option VARCHAR2(1);
154419
154420 --
154421 BEGIN
154422 --
154423 IF g_log_enabled THEN
154424 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_288';
154425 END IF;
154426 --
154427 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
154428
154429 trace
154430 (p_msg => 'BEGIN of AcctLineType_288'
154431 ,p_level => C_LEVEL_PROCEDURE
154432 ,p_module => l_log_module);
154433
154434 END IF;
154435 --
154436 l_component_type := 'AMB_JLT';
154437 l_component_code := 'LANDED_COST_ABSORPTION';
154438 l_component_type_code := 'S';
154439 l_component_appl_id := 707;
154440 l_amb_context_code := 'DEFAULT';
154441 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
154442 l_event_class_code := 'LDD_COST_ADJ_RCV';
154443 l_event_type_code := 'LDD_COST_ADJ_RCV_ALL';
154444 l_line_definition_owner_code := 'S';
154445 l_line_definition_code := 'LDD_COST_ADJ_RCV';
154446 --
154447 l_balance_type_code := 'A';
154448 l_segment := NULL;
154449 l_ccid := NULL;
154450 l_adr_transaction_coa_id := NULL;
154451 l_adr_accounting_coa_id := NULL;
154452 l_adr_flexfield_segment_code := NULL;
154453 l_adr_flex_value_set_id := NULL;
154454 l_adr_value_type_code := NULL;
154455 l_adr_value_combination_id := NULL;
154456 l_adr_value_segment_code := NULL;
154457
154458 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
154459 l_bflow_class_code := ''; -- 4219869 Business Flow
154460 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
154461 l_budgetary_control_flag := 'N';
154462
154463 l_bflow_applied_to_amt_idx := NULL; -- 5132302
154464 l_bflow_applied_to_amt := NULL; -- 5132302
154465 l_entered_amt_idx := NULL; -- 4262811
154466 l_accted_amt_idx := NULL; -- 4262811
154467 l_acc_rev_flag := NULL; -- 4262811
154468 l_accrual_line_num := NULL; -- 4262811
154469 l_tmp_amt := NULL; -- 4262811
154470 --
154471
154472 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
154473 l_balance_type_code <> 'B' THEN
154474 IF NVL(p_source_78,'
154475 ') = 'Landed Cost Absorption'
154476 THEN
154477
154478 --
154479 XLA_AE_LINES_PKG.SetNewLine;
154480
154481 p_balance_type_code := l_balance_type_code;
154482 -- set the flag so later we will know whether the gain loss line needs to be created
154483
154484 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
154485 p_actual_flag :='A';
154486 END IF;
154487
154488 --
154489 -- bulk performance
154490 --
154491 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
154492 p_header_num => 0); -- 4262811
154493 --
154494 -- set accounting line options
154495 --
154496 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
154497 p_natural_side_code => 'D'
154498 , p_gain_or_loss_flag => 'N'
154499 , p_gl_transfer_mode_code => 'S'
154500 , p_acct_entry_type_code => 'A'
154501 , p_switch_side_flag => 'Y'
154502 , p_merge_duplicate_code => 'N'
154503 );
154504 --
154505 l_acc_rev_natural_side_code := 'C'; -- 4262811
154506 --
154507 --
154508 -- set accounting line type info
154509 --
154510 xla_ae_lines_pkg.SetAcctLineType
154511 (p_component_type => l_component_type
154512 ,p_event_type_code => l_event_type_code
154513 ,p_line_definition_owner_code => l_line_definition_owner_code
154514 ,p_line_definition_code => l_line_definition_code
154515 ,p_accounting_line_code => l_component_code
154516 ,p_accounting_line_type_code => l_component_type_code
154517 ,p_accounting_line_appl_id => l_component_appl_id
154518 ,p_amb_context_code => l_amb_context_code
154519 ,p_entity_code => l_entity_code
154520 ,p_event_class_code => l_event_class_code);
154521 --
154522 -- set accounting class
154523 --
154524 xla_ae_lines_pkg.SetAcctClass(
154525 p_accounting_class_code => 'LANDED_COST_ABSORPTION'
154526 , p_ae_header_id => l_ae_header_id
154527 );
154528
154529 --
154530 -- set rounding class
154531 --
154532 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
154533 'LANDED_COST_ABSORPTION';
154534
154535 --
154536 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
154537 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
154538 --
154539 -- bulk performance
154540 --
154541 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
154542
154543 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
154544 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
154545
154546 -- 4955764
154547 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
154548 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
154549
154550 -- 4458381 Public Sector Enh
154551
154552 --
154553 -- set accounting attributes for the line type
154554 --
154555 l_entered_amt_idx := 3;
154556 l_accted_amt_idx := 8;
154557 l_bflow_applied_to_amt_idx := NULL; -- 5132302
154558 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
154559 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
154560 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
154561 l_rec_acct_attrs.array_char_value(2) := p_source_85;
154562 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
154563 l_rec_acct_attrs.array_num_value(3) := p_source_91;
154564 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
154565 l_rec_acct_attrs.array_char_value(4) := p_source_105;
154566 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
154567 l_rec_acct_attrs.array_date_value(5) := p_source_106;
154568 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
154569 l_rec_acct_attrs.array_num_value(6) := p_source_107;
154570 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
154571 l_rec_acct_attrs.array_char_value(7) := p_source_109;
154572 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
154573 l_rec_acct_attrs.array_num_value(8) := p_source_95;
154574
154575 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
154576 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
154577
154578 ---------------------------------------------------------------------------------------------------------------
154579 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
154580 ---------------------------------------------------------------------------------------------------------------
154581 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
154582
154583 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
154584 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
154585
154586 IF xla_accounting_cache_pkg.GetValueChar
154587 (p_source_code => 'LEDGER_CATEGORY_CODE'
154588 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
154589 AND l_bflow_method_code = 'PRIOR_ENTRY'
154590 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
154591 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
154592 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
154593 )
154594 THEN
154595 xla_ae_lines_pkg.BflowUpgEntry
154596 (p_business_method_code => l_bflow_method_code
154597 ,p_business_class_code => l_bflow_class_code
154598 ,p_balance_type => l_balance_type_code);
154599 ELSE
154600 NULL;
154601 -- No business flow processing for business flow method of NONE.
154602 END IF;
154603
154604 --
154605 -- call analytical criteria
154606 --
154607
154608 --
154609 -- call description
154610 --
154611 -- No description or it is inherited.
154612 --
154613 -- call ADRs
154614 -- Bug 4922099
154615 --
154616 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
154617 (NVL(l_actual_upg_option, 'N') = 'O') OR
154618 (NVL(l_enc_upg_option, 'N') = 'O')
154619 )
154620 THEN
154621 NULL;
154622 --
154623 --
154624
154625 l_ccid := AcctDerRule_6(
154626 p_application_id => p_application_id
154627 , p_ae_header_id => l_ae_header_id
154628 , p_source_11 => p_source_11
154629 , x_transaction_coa_id => l_adr_transaction_coa_id
154630 , x_accounting_coa_id => l_adr_accounting_coa_id
154631 , x_value_type_code => l_adr_value_type_code
154632 , p_side => 'NA'
154633 );
154634
154635 xla_ae_lines_pkg.set_ccid(
154636 p_code_combination_id => l_ccid
154637 , p_value_type_code => l_adr_value_type_code
154638 , p_transaction_coa_id => l_adr_transaction_coa_id
154639 , p_accounting_coa_id => l_adr_accounting_coa_id
154640 , p_adr_code => 'CST_DEFAULT'
154641 , p_adr_type_code => 'S'
154642 , p_component_type => l_component_type
154643 , p_component_code => l_component_code
154644 , p_component_type_code => l_component_type_code
154645 , p_component_appl_id => l_component_appl_id
154646 , p_amb_context_code => l_amb_context_code
154647 , p_side => 'NA'
154648 );
154649
154650
154651 --
154652 --
154653 END IF;
154654 --
154655 -- Bug 4922099
154656 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
154657 (NVL(l_enc_upg_option, 'N') = 'O')
154658 ) AND
154659 (l_bflow_method_code = 'PRIOR_ENTRY')
154660 )
154661 THEN
154662 IF
154663 --
154664 1 = 2
154665 --
154666 THEN
154667 xla_accounting_err_pkg.build_message
154668 (p_appli_s_name => 'XLA'
154669 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
154670 ,p_token_1 => 'LINE_NUMBER'
154671 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
154672 ,p_token_2 => 'LINE_TYPE_NAME'
154673 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
154674 l_component_type
154675 ,l_component_code
154676 ,l_component_type_code
154677 ,l_component_appl_id
154678 ,l_amb_context_code
154679 ,l_entity_code
154680 ,l_event_class_code
154681 )
154682 ,p_token_3 => 'OWNER'
154683 ,p_value_3 => xla_lookups_pkg.get_meaning(
154684 p_lookup_type => 'XLA_OWNER_TYPE'
154685 ,p_lookup_code => l_component_type_code
154686 )
154687 ,p_token_4 => 'PRODUCT_NAME'
154688 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
154689 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
154690 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
154691 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
154692 ,p_ae_header_id => NULL
154693 );
154694
154695 IF (C_LEVEL_ERROR>= g_log_level) THEN
154696 trace
154697 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
154698 ,p_level => C_LEVEL_ERROR
154699 ,p_module => l_log_module);
154700 END IF;
154701 END IF;
154702 END IF;
154703 --
154704 --
154705 ------------------------------------------------------------------------------------------------
154706 -- 4219869 Business Flow
154707 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
154708 -- Prior Entry. Currently, the following code is always generated.
154709 ------------------------------------------------------------------------------------------------
154710 XLA_AE_LINES_PKG.ValidateCurrentLine;
154711
154712 ------------------------------------------------------------------------------------
154713 -- 4219869 Business Flow
154714 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
154715 ------------------------------------------------------------------------------------
154716 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
154717
154718 ----------------------------------------------------------------------------------
154719 -- 4219869 Business Flow
154720 -- Update journal entry status -- Need to generate this within IF <condition>
154721 ----------------------------------------------------------------------------------
154722 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
154723 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
154724 ,p_balance_type_code => l_balance_type_code
154725 );
154726
154727 -------------------------------------------------------------------------------------------
154728 -- 4262811 - Generate the Accrual Reversal lines
154729 -------------------------------------------------------------------------------------------
154730 BEGIN
154731 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
154732 (g_array_event(p_event_id).array_value_num('header_index'));
154733 IF l_acc_rev_flag IS NULL THEN
154734 l_acc_rev_flag := 'N';
154735 END IF;
154736 EXCEPTION
154737 WHEN OTHERS THEN
154738 l_acc_rev_flag := 'N';
154739 END;
154740 --
154741 IF (l_acc_rev_flag = 'Y') THEN
154742
154743 -- 4645092 ------------------------------------------------------------------------------
154744 -- To allow MPA report to determine if it should generate report process
154745 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
154746 ------------------------------------------------------------------------------------------
154747
154748 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
154749 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
154750 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
154751 -- call ADRs
154752 -- Bug 4922099
154753 --
154754 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
154755 (NVL(l_actual_upg_option, 'N') = 'O') OR
154756 (NVL(l_enc_upg_option, 'N') = 'O')
154757 )
154758 THEN
154759 NULL;
154760 --
154761 --
154762
154763 l_ccid := AcctDerRule_6(
154764 p_application_id => p_application_id
154765 , p_ae_header_id => l_ae_header_id
154766 , p_source_11 => p_source_11
154767 , x_transaction_coa_id => l_adr_transaction_coa_id
154768 , x_accounting_coa_id => l_adr_accounting_coa_id
154769 , x_value_type_code => l_adr_value_type_code
154770 , p_side => 'NA'
154771 );
154772
154773 xla_ae_lines_pkg.set_ccid(
154774 p_code_combination_id => l_ccid
154775 , p_value_type_code => l_adr_value_type_code
154776 , p_transaction_coa_id => l_adr_transaction_coa_id
154777 , p_accounting_coa_id => l_adr_accounting_coa_id
154778 , p_adr_code => 'CST_DEFAULT'
154779 , p_adr_type_code => 'S'
154780 , p_component_type => l_component_type
154781 , p_component_code => l_component_code
154782 , p_component_type_code => l_component_type_code
154783 , p_component_appl_id => l_component_appl_id
154784 , p_amb_context_code => l_amb_context_code
154785 , p_side => 'NA'
154786 );
154787
154788
154789 --
154790 --
154791 END IF;
154792
154793 --
154794 -- Update the line information that should be overwritten
154795 --
154796 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
154797 p_header_num => 1);
154798 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
154799
154800 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
154801
154802 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
154803 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
154804 END IF;
154805
154806 --
154807 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
154808 --
154809 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
154810 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
154811 ELSE
154812 ---------------------------------------------------------------------------------------------------
154813 -- 4262811a Switch Sign
154814 ---------------------------------------------------------------------------------------------------
154815 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
154816 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
154817 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154818 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
154819 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154820 -- 5132302
154821 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
154822 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
154823
154824 END IF;
154825
154826 -- 4955764
154827 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
154828 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
154829
154830
154831 XLA_AE_LINES_PKG.ValidateCurrentLine;
154832 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
154833
154834 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
154835 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
154836 ,p_balance_type_code => l_balance_type_code);
154837
154838 END IF;
154839
154840 -----------------------------------------------------------------------------------------
154841 -- 4262811 Multiperiod Accounting
154842 -----------------------------------------------------------------------------------------
154843 -- No MPA option is assigned.
154844
154845
154846 END IF;
154847 END IF;
154848 --
154849
154850 --
154851 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
154852 trace
154853 (p_msg => 'END of AcctLineType_288'
154854 ,p_level => C_LEVEL_PROCEDURE
154855 ,p_module => l_log_module);
154856 END IF;
154857 --
154858 EXCEPTION
154859 WHEN xla_exceptions_pkg.application_exception THEN
154860 RAISE;
154861 WHEN OTHERS THEN
154862 xla_exceptions_pkg.raise_message
154863 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_288');
154864 END AcctLineType_288;
154865 --
154866
154867 ---------------------------------------
154868 --
154869 -- PRIVATE FUNCTION
154870 -- AcctLineType_289
154871 --
154872 ---------------------------------------
154873 PROCEDURE AcctLineType_289 (
154874 p_application_id IN NUMBER
154875 ,p_event_id IN NUMBER
154876 ,p_calculate_acctd_flag IN VARCHAR2
154877 ,p_calculate_g_l_flag IN VARCHAR2
154878 ,p_actual_flag IN OUT VARCHAR2
154879 ,p_balance_type_code OUT VARCHAR2
154880 ,p_gain_or_loss_ref OUT VARCHAR2
154881
154882 --Cost Management Default Account
154883 , p_source_11 IN NUMBER
154884 --Receiving Accounting Line Type
154885 , p_source_78 IN VARCHAR2
154886 --DISTRIBUTION_IDENTIFIER
154887 , p_source_84 IN NUMBER
154888 --Distribution Type
154889 , p_source_85 IN VARCHAR2
154890 , p_source_85_meaning IN VARCHAR2
154891 --Entered Currency Code
154892 , p_source_88 IN VARCHAR2
154893 --Entered Amount
154894 , p_source_91 IN NUMBER
154895 --Currency Conversion Date
154896 , p_source_92 IN DATE
154897 --Currency Conversion Rate
154898 , p_source_93 IN NUMBER
154899 --Currency Conversion Type
154900 , p_source_94 IN VARCHAR2
154901 --Accounted Amount
154902 , p_source_95 IN NUMBER
154903 )
154904 IS
154905
154906 l_component_type VARCHAR2(80);
154907 l_component_code VARCHAR2(30);
154908 l_component_type_code VARCHAR2(1);
154909 l_component_appl_id INTEGER;
154910 l_amb_context_code VARCHAR2(30);
154911 l_entity_code VARCHAR2(30);
154912 l_event_class_code VARCHAR2(30);
154913 l_ae_header_id NUMBER;
154914 l_event_type_code VARCHAR2(30);
154915 l_line_definition_code VARCHAR2(30);
154916 l_line_definition_owner_code VARCHAR2(1);
154917 --
154918 -- adr variables
154919 l_segment VARCHAR2(30);
154920 l_ccid NUMBER;
154921 l_adr_transaction_coa_id NUMBER;
154922 l_adr_accounting_coa_id NUMBER;
154923 l_adr_flexfield_segment_code VARCHAR2(30);
154924 l_adr_flex_value_set_id NUMBER;
154925 l_adr_value_type_code VARCHAR2(30);
154926 l_adr_value_combination_id NUMBER;
154927 l_adr_value_segment_code VARCHAR2(30);
154928
154929 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
154930 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
154931 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
154932 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
154933
154934 -- 4262811 Variables ------------------------------------------------------------------------------------------
154935 l_entered_amt_idx NUMBER;
154936 l_accted_amt_idx NUMBER;
154937 l_acc_rev_flag VARCHAR2(1);
154938 l_accrual_line_num NUMBER;
154939 l_tmp_amt NUMBER;
154940 l_acc_rev_natural_side_code VARCHAR2(1);
154941
154942 l_num_entries NUMBER;
154943 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
154944 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
154945 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
154946 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
154947 l_recog_line_1 NUMBER;
154948 l_recog_line_2 NUMBER;
154949
154950 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
154951 l_bflow_applied_to_amt NUMBER; -- 5132302
154952 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
154953
154954 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
154955
154956 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
154957 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
154958
154959 ---------------------------------------------------------------------------------------------------------------
154960
154961
154962 --
154963 -- bulk performance
154964 --
154965 l_balance_type_code VARCHAR2(1);
154966 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
154967 l_log_module VARCHAR2(240);
154968
154969 --
154970 -- Upgrade strategy
154971 --
154972 l_actual_upg_option VARCHAR2(1);
154973 l_enc_upg_option VARCHAR2(1);
154974
154975 --
154976 BEGIN
154977 --
154978 IF g_log_enabled THEN
154979 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_289';
154980 END IF;
154981 --
154982 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
154983
154984 trace
154985 (p_msg => 'BEGIN of AcctLineType_289'
154986 ,p_level => C_LEVEL_PROCEDURE
154987 ,p_module => l_log_module);
154988
154989 END IF;
154990 --
154991 l_component_type := 'AMB_JLT';
154992 l_component_code := 'LANDED_COST_ABSORPTION';
154993 l_component_type_code := 'S';
154994 l_component_appl_id := 707;
154995 l_amb_context_code := 'DEFAULT';
154996 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
154997 l_event_class_code := 'RCPT_REC_INSP';
154998 l_event_type_code := 'RCPT_REC_INSP_ALL';
154999 l_line_definition_owner_code := 'S';
155000 l_line_definition_code := 'RCPT_REC_INSP';
155001 --
155002 l_balance_type_code := 'A';
155003 l_segment := NULL;
155004 l_ccid := NULL;
155005 l_adr_transaction_coa_id := NULL;
155006 l_adr_accounting_coa_id := NULL;
155007 l_adr_flexfield_segment_code := NULL;
155008 l_adr_flex_value_set_id := NULL;
155009 l_adr_value_type_code := NULL;
155010 l_adr_value_combination_id := NULL;
155011 l_adr_value_segment_code := NULL;
155012
155013 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
155014 l_bflow_class_code := ''; -- 4219869 Business Flow
155015 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
155016 l_budgetary_control_flag := 'N';
155017
155018 l_bflow_applied_to_amt_idx := NULL; -- 5132302
155019 l_bflow_applied_to_amt := NULL; -- 5132302
155020 l_entered_amt_idx := NULL; -- 4262811
155021 l_accted_amt_idx := NULL; -- 4262811
155022 l_acc_rev_flag := NULL; -- 4262811
155023 l_accrual_line_num := NULL; -- 4262811
155024 l_tmp_amt := NULL; -- 4262811
155025 --
155026
155027 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
155028 l_balance_type_code <> 'B' THEN
155029 IF NVL(p_source_78,'
155030 ') = 'Landed Cost Absorption'
155031 THEN
155032
155033 --
155034 XLA_AE_LINES_PKG.SetNewLine;
155035
155036 p_balance_type_code := l_balance_type_code;
155037 -- set the flag so later we will know whether the gain loss line needs to be created
155038
155039 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
155040 p_actual_flag :='A';
155041 END IF;
155042
155043 --
155044 -- bulk performance
155045 --
155046 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
155047 p_header_num => 0); -- 4262811
155048 --
155049 -- set accounting line options
155050 --
155051 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
155052 p_natural_side_code => 'D'
155053 , p_gain_or_loss_flag => 'N'
155054 , p_gl_transfer_mode_code => 'S'
155055 , p_acct_entry_type_code => 'A'
155056 , p_switch_side_flag => 'Y'
155057 , p_merge_duplicate_code => 'N'
155058 );
155059 --
155060 l_acc_rev_natural_side_code := 'C'; -- 4262811
155061 --
155062 --
155063 -- set accounting line type info
155064 --
155065 xla_ae_lines_pkg.SetAcctLineType
155066 (p_component_type => l_component_type
155067 ,p_event_type_code => l_event_type_code
155068 ,p_line_definition_owner_code => l_line_definition_owner_code
155069 ,p_line_definition_code => l_line_definition_code
155070 ,p_accounting_line_code => l_component_code
155071 ,p_accounting_line_type_code => l_component_type_code
155072 ,p_accounting_line_appl_id => l_component_appl_id
155073 ,p_amb_context_code => l_amb_context_code
155074 ,p_entity_code => l_entity_code
155075 ,p_event_class_code => l_event_class_code);
155076 --
155077 -- set accounting class
155078 --
155079 xla_ae_lines_pkg.SetAcctClass(
155080 p_accounting_class_code => 'LANDED_COST_ABSORPTION'
155081 , p_ae_header_id => l_ae_header_id
155082 );
155083
155084 --
155085 -- set rounding class
155086 --
155087 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
155088 'LANDED_COST_ABSORPTION';
155089
155090 --
155091 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
155092 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
155093 --
155094 -- bulk performance
155095 --
155096 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
155097
155098 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
155099 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
155100
155101 -- 4955764
155102 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
155103 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
155104
155105 -- 4458381 Public Sector Enh
155106
155107 --
155108 -- set accounting attributes for the line type
155109 --
155110 l_entered_amt_idx := 3;
155111 l_accted_amt_idx := 8;
155112 l_bflow_applied_to_amt_idx := NULL; -- 5132302
155113 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
155114 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
155115 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
155116 l_rec_acct_attrs.array_char_value(2) := p_source_85;
155117 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
155118 l_rec_acct_attrs.array_num_value(3) := p_source_91;
155119 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
155120 l_rec_acct_attrs.array_char_value(4) := p_source_88;
155121 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
155122 l_rec_acct_attrs.array_date_value(5) := p_source_92;
155123 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
155124 l_rec_acct_attrs.array_num_value(6) := p_source_93;
155125 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
155126 l_rec_acct_attrs.array_char_value(7) := p_source_94;
155127 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
155128 l_rec_acct_attrs.array_num_value(8) := p_source_95;
155129
155130 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
155131 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
155132
155133 ---------------------------------------------------------------------------------------------------------------
155134 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
155135 ---------------------------------------------------------------------------------------------------------------
155136 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
155137
155138 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
155139 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
155140
155141 IF xla_accounting_cache_pkg.GetValueChar
155142 (p_source_code => 'LEDGER_CATEGORY_CODE'
155143 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
155144 AND l_bflow_method_code = 'PRIOR_ENTRY'
155145 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
155146 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
155147 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
155148 )
155149 THEN
155150 xla_ae_lines_pkg.BflowUpgEntry
155151 (p_business_method_code => l_bflow_method_code
155152 ,p_business_class_code => l_bflow_class_code
155153 ,p_balance_type => l_balance_type_code);
155154 ELSE
155155 NULL;
155156 -- No business flow processing for business flow method of NONE.
155157 END IF;
155158
155159 --
155160 -- call analytical criteria
155161 --
155162
155163 --
155164 -- call description
155165 --
155166 -- No description or it is inherited.
155167 --
155168 -- call ADRs
155169 -- Bug 4922099
155170 --
155171 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
155172 (NVL(l_actual_upg_option, 'N') = 'O') OR
155173 (NVL(l_enc_upg_option, 'N') = 'O')
155174 )
155175 THEN
155176 NULL;
155177 --
155178 --
155179
155180 l_ccid := AcctDerRule_6(
155181 p_application_id => p_application_id
155182 , p_ae_header_id => l_ae_header_id
155183 , p_source_11 => p_source_11
155184 , x_transaction_coa_id => l_adr_transaction_coa_id
155185 , x_accounting_coa_id => l_adr_accounting_coa_id
155186 , x_value_type_code => l_adr_value_type_code
155187 , p_side => 'NA'
155188 );
155189
155190 xla_ae_lines_pkg.set_ccid(
155191 p_code_combination_id => l_ccid
155192 , p_value_type_code => l_adr_value_type_code
155193 , p_transaction_coa_id => l_adr_transaction_coa_id
155194 , p_accounting_coa_id => l_adr_accounting_coa_id
155195 , p_adr_code => 'CST_DEFAULT'
155196 , p_adr_type_code => 'S'
155197 , p_component_type => l_component_type
155198 , p_component_code => l_component_code
155199 , p_component_type_code => l_component_type_code
155200 , p_component_appl_id => l_component_appl_id
155201 , p_amb_context_code => l_amb_context_code
155202 , p_side => 'NA'
155203 );
155204
155205
155206 --
155207 --
155208 END IF;
155209 --
155210 -- Bug 4922099
155211 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
155212 (NVL(l_enc_upg_option, 'N') = 'O')
155213 ) AND
155214 (l_bflow_method_code = 'PRIOR_ENTRY')
155215 )
155216 THEN
155217 IF
155218 --
155219 1 = 2
155220 --
155221 THEN
155222 xla_accounting_err_pkg.build_message
155223 (p_appli_s_name => 'XLA'
155224 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
155225 ,p_token_1 => 'LINE_NUMBER'
155226 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
155227 ,p_token_2 => 'LINE_TYPE_NAME'
155228 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
155229 l_component_type
155230 ,l_component_code
155231 ,l_component_type_code
155232 ,l_component_appl_id
155233 ,l_amb_context_code
155234 ,l_entity_code
155235 ,l_event_class_code
155236 )
155237 ,p_token_3 => 'OWNER'
155238 ,p_value_3 => xla_lookups_pkg.get_meaning(
155239 p_lookup_type => 'XLA_OWNER_TYPE'
155240 ,p_lookup_code => l_component_type_code
155241 )
155242 ,p_token_4 => 'PRODUCT_NAME'
155243 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
155244 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
155245 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
155246 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
155247 ,p_ae_header_id => NULL
155248 );
155249
155250 IF (C_LEVEL_ERROR>= g_log_level) THEN
155251 trace
155252 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
155253 ,p_level => C_LEVEL_ERROR
155254 ,p_module => l_log_module);
155255 END IF;
155256 END IF;
155257 END IF;
155258 --
155259 --
155260 ------------------------------------------------------------------------------------------------
155261 -- 4219869 Business Flow
155262 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
155263 -- Prior Entry. Currently, the following code is always generated.
155264 ------------------------------------------------------------------------------------------------
155265 XLA_AE_LINES_PKG.ValidateCurrentLine;
155266
155267 ------------------------------------------------------------------------------------
155268 -- 4219869 Business Flow
155269 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
155270 ------------------------------------------------------------------------------------
155271 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
155272
155273 ----------------------------------------------------------------------------------
155274 -- 4219869 Business Flow
155275 -- Update journal entry status -- Need to generate this within IF <condition>
155276 ----------------------------------------------------------------------------------
155277 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
155278 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
155279 ,p_balance_type_code => l_balance_type_code
155280 );
155281
155282 -------------------------------------------------------------------------------------------
155283 -- 4262811 - Generate the Accrual Reversal lines
155284 -------------------------------------------------------------------------------------------
155285 BEGIN
155286 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
155287 (g_array_event(p_event_id).array_value_num('header_index'));
155288 IF l_acc_rev_flag IS NULL THEN
155289 l_acc_rev_flag := 'N';
155290 END IF;
155291 EXCEPTION
155292 WHEN OTHERS THEN
155293 l_acc_rev_flag := 'N';
155294 END;
155295 --
155296 IF (l_acc_rev_flag = 'Y') THEN
155297
155298 -- 4645092 ------------------------------------------------------------------------------
155299 -- To allow MPA report to determine if it should generate report process
155300 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
155301 ------------------------------------------------------------------------------------------
155302
155303 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
155304 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
155305 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
155306 -- call ADRs
155307 -- Bug 4922099
155308 --
155309 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
155310 (NVL(l_actual_upg_option, 'N') = 'O') OR
155311 (NVL(l_enc_upg_option, 'N') = 'O')
155312 )
155313 THEN
155314 NULL;
155315 --
155316 --
155317
155318 l_ccid := AcctDerRule_6(
155319 p_application_id => p_application_id
155320 , p_ae_header_id => l_ae_header_id
155321 , p_source_11 => p_source_11
155322 , x_transaction_coa_id => l_adr_transaction_coa_id
155323 , x_accounting_coa_id => l_adr_accounting_coa_id
155324 , x_value_type_code => l_adr_value_type_code
155325 , p_side => 'NA'
155326 );
155327
155328 xla_ae_lines_pkg.set_ccid(
155329 p_code_combination_id => l_ccid
155330 , p_value_type_code => l_adr_value_type_code
155331 , p_transaction_coa_id => l_adr_transaction_coa_id
155332 , p_accounting_coa_id => l_adr_accounting_coa_id
155333 , p_adr_code => 'CST_DEFAULT'
155334 , p_adr_type_code => 'S'
155335 , p_component_type => l_component_type
155336 , p_component_code => l_component_code
155337 , p_component_type_code => l_component_type_code
155338 , p_component_appl_id => l_component_appl_id
155339 , p_amb_context_code => l_amb_context_code
155340 , p_side => 'NA'
155341 );
155342
155343
155344 --
155345 --
155346 END IF;
155347
155348 --
155349 -- Update the line information that should be overwritten
155350 --
155351 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
155352 p_header_num => 1);
155353 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
155354
155355 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
155356
155357 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
155358 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
155359 END IF;
155360
155361 --
155362 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
155363 --
155364 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
155365 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
155366 ELSE
155367 ---------------------------------------------------------------------------------------------------
155368 -- 4262811a Switch Sign
155369 ---------------------------------------------------------------------------------------------------
155370 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
155371 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
155372 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155373 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
155374 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155375 -- 5132302
155376 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
155377 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155378
155379 END IF;
155380
155381 -- 4955764
155382 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
155383 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
155384
155385
155386 XLA_AE_LINES_PKG.ValidateCurrentLine;
155387 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
155388
155389 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
155390 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
155391 ,p_balance_type_code => l_balance_type_code);
155392
155393 END IF;
155394
155395 -----------------------------------------------------------------------------------------
155396 -- 4262811 Multiperiod Accounting
155397 -----------------------------------------------------------------------------------------
155398 -- No MPA option is assigned.
155399
155400
155401 END IF;
155402 END IF;
155403 --
155404
155405 --
155406 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
155407 trace
155408 (p_msg => 'END of AcctLineType_289'
155409 ,p_level => C_LEVEL_PROCEDURE
155410 ,p_module => l_log_module);
155411 END IF;
155412 --
155413 EXCEPTION
155414 WHEN xla_exceptions_pkg.application_exception THEN
155415 RAISE;
155416 WHEN OTHERS THEN
155417 xla_exceptions_pkg.raise_message
155418 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_289');
155419 END AcctLineType_289;
155420 --
155421
155422 ---------------------------------------
155423 --
155424 -- PRIVATE FUNCTION
155425 -- AcctLineType_290
155426 --
155427 ---------------------------------------
155428 PROCEDURE AcctLineType_290 (
155429 p_application_id IN NUMBER
155430 ,p_event_id IN NUMBER
155431 ,p_calculate_acctd_flag IN VARCHAR2
155432 ,p_calculate_g_l_flag IN VARCHAR2
155433 ,p_actual_flag IN OUT VARCHAR2
155434 ,p_balance_type_code OUT VARCHAR2
155435 ,p_gain_or_loss_ref OUT VARCHAR2
155436
155437 --Cost Management Default Account
155438 , p_source_11 IN NUMBER
155439 --Receiving Accounting Line Type
155440 , p_source_78 IN VARCHAR2
155441 --DISTRIBUTION_IDENTIFIER
155442 , p_source_84 IN NUMBER
155443 --Distribution Type
155444 , p_source_85 IN VARCHAR2
155445 , p_source_85_meaning IN VARCHAR2
155446 --Entered Amount
155447 , p_source_91 IN NUMBER
155448 --Accounted Amount
155449 , p_source_95 IN NUMBER
155450 --Entered Currency Code
155451 , p_source_105 IN VARCHAR2
155452 --Currency Conversion Date
155453 , p_source_106 IN DATE
155454 --Currency Conversion Rate
155455 , p_source_107 IN NUMBER
155456 )
155457 IS
155458
155459 l_component_type VARCHAR2(80);
155460 l_component_code VARCHAR2(30);
155461 l_component_type_code VARCHAR2(1);
155462 l_component_appl_id INTEGER;
155463 l_amb_context_code VARCHAR2(30);
155464 l_entity_code VARCHAR2(30);
155465 l_event_class_code VARCHAR2(30);
155466 l_ae_header_id NUMBER;
155467 l_event_type_code VARCHAR2(30);
155468 l_line_definition_code VARCHAR2(30);
155469 l_line_definition_owner_code VARCHAR2(1);
155470 --
155471 -- adr variables
155472 l_segment VARCHAR2(30);
155473 l_ccid NUMBER;
155474 l_adr_transaction_coa_id NUMBER;
155475 l_adr_accounting_coa_id NUMBER;
155476 l_adr_flexfield_segment_code VARCHAR2(30);
155477 l_adr_flex_value_set_id NUMBER;
155478 l_adr_value_type_code VARCHAR2(30);
155479 l_adr_value_combination_id NUMBER;
155480 l_adr_value_segment_code VARCHAR2(30);
155481
155482 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
155483 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
155484 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
155485 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
155486
155487 -- 4262811 Variables ------------------------------------------------------------------------------------------
155488 l_entered_amt_idx NUMBER;
155489 l_accted_amt_idx NUMBER;
155490 l_acc_rev_flag VARCHAR2(1);
155491 l_accrual_line_num NUMBER;
155492 l_tmp_amt NUMBER;
155493 l_acc_rev_natural_side_code VARCHAR2(1);
155494
155495 l_num_entries NUMBER;
155496 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
155497 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
155498 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
155499 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
155500 l_recog_line_1 NUMBER;
155501 l_recog_line_2 NUMBER;
155502
155503 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
155504 l_bflow_applied_to_amt NUMBER; -- 5132302
155505 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
155506
155507 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
155508
155509 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
155510 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
155511
155512 ---------------------------------------------------------------------------------------------------------------
155513
155514
155515 --
155516 -- bulk performance
155517 --
155518 l_balance_type_code VARCHAR2(1);
155519 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
155520 l_log_module VARCHAR2(240);
155521
155522 --
155523 -- Upgrade strategy
155524 --
155525 l_actual_upg_option VARCHAR2(1);
155526 l_enc_upg_option VARCHAR2(1);
155527
155528 --
155529 BEGIN
155530 --
155531 IF g_log_enabled THEN
155532 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_290';
155533 END IF;
155534 --
155535 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
155536
155537 trace
155538 (p_msg => 'BEGIN of AcctLineType_290'
155539 ,p_level => C_LEVEL_PROCEDURE
155540 ,p_module => l_log_module);
155541
155542 END IF;
155543 --
155544 l_component_type := 'AMB_JLT';
155545 l_component_code := 'LANDED_COST_ABSORPTION';
155546 l_component_type_code := 'S';
155547 l_component_appl_id := 707;
155548 l_amb_context_code := 'DEFAULT';
155549 l_entity_code := 'RCV_ACCOUNTING_EVENTS';
155550 l_event_class_code := 'LDD_COST_ADJ_DEL';
155551 l_event_type_code := 'LDD_COST_ADJ_DEL_ALL';
155552 l_line_definition_owner_code := 'S';
155553 l_line_definition_code := 'LDD_COST_ADJ_DEL';
155554 --
155555 l_balance_type_code := 'A';
155556 l_segment := NULL;
155557 l_ccid := NULL;
155558 l_adr_transaction_coa_id := NULL;
155559 l_adr_accounting_coa_id := NULL;
155560 l_adr_flexfield_segment_code := NULL;
155561 l_adr_flex_value_set_id := NULL;
155562 l_adr_value_type_code := NULL;
155563 l_adr_value_combination_id := NULL;
155564 l_adr_value_segment_code := NULL;
155565
155566 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
155567 l_bflow_class_code := ''; -- 4219869 Business Flow
155568 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
155569 l_budgetary_control_flag := 'N';
155570
155571 l_bflow_applied_to_amt_idx := NULL; -- 5132302
155572 l_bflow_applied_to_amt := NULL; -- 5132302
155573 l_entered_amt_idx := NULL; -- 4262811
155574 l_accted_amt_idx := NULL; -- 4262811
155575 l_acc_rev_flag := NULL; -- 4262811
155576 l_accrual_line_num := NULL; -- 4262811
155577 l_tmp_amt := NULL; -- 4262811
155578 --
155579
155580 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
155581 l_balance_type_code <> 'B' THEN
155582 IF NVL(p_source_78,'
155583 ') = 'Landed Cost Absorption'
155584 THEN
155585
155586 --
155587 XLA_AE_LINES_PKG.SetNewLine;
155588
155589 p_balance_type_code := l_balance_type_code;
155590 -- set the flag so later we will know whether the gain loss line needs to be created
155591
155592 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
155593 p_actual_flag :='A';
155594 END IF;
155595
155596 --
155597 -- bulk performance
155598 --
155599 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
155600 p_header_num => 0); -- 4262811
155601 --
155602 -- set accounting line options
155603 --
155604 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
155605 p_natural_side_code => 'D'
155606 , p_gain_or_loss_flag => 'N'
155607 , p_gl_transfer_mode_code => 'S'
155608 , p_acct_entry_type_code => 'A'
155609 , p_switch_side_flag => 'Y'
155610 , p_merge_duplicate_code => 'N'
155611 );
155612 --
155613 l_acc_rev_natural_side_code := 'C'; -- 4262811
155614 --
155615 --
155616 -- set accounting line type info
155617 --
155618 xla_ae_lines_pkg.SetAcctLineType
155619 (p_component_type => l_component_type
155620 ,p_event_type_code => l_event_type_code
155621 ,p_line_definition_owner_code => l_line_definition_owner_code
155622 ,p_line_definition_code => l_line_definition_code
155623 ,p_accounting_line_code => l_component_code
155624 ,p_accounting_line_type_code => l_component_type_code
155625 ,p_accounting_line_appl_id => l_component_appl_id
155626 ,p_amb_context_code => l_amb_context_code
155627 ,p_entity_code => l_entity_code
155628 ,p_event_class_code => l_event_class_code);
155629 --
155630 -- set accounting class
155631 --
155632 xla_ae_lines_pkg.SetAcctClass(
155633 p_accounting_class_code => 'LANDED_COST_ABSORPTION'
155634 , p_ae_header_id => l_ae_header_id
155635 );
155636
155637 --
155638 -- set rounding class
155639 --
155640 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
155641 'LANDED_COST_ABSORPTION';
155642
155643 --
155644 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
155645 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
155646 --
155647 -- bulk performance
155648 --
155649 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
155650
155651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
155652 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
155653
155654 -- 4955764
155655 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
155656 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
155657
155658 -- 4458381 Public Sector Enh
155659
155660 --
155661 -- set accounting attributes for the line type
155662 --
155663 l_entered_amt_idx := 3;
155664 l_accted_amt_idx := 7;
155665 l_bflow_applied_to_amt_idx := NULL; -- 5132302
155666 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
155667 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
155668 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
155669 l_rec_acct_attrs.array_char_value(2) := p_source_85;
155670 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
155671 l_rec_acct_attrs.array_num_value(3) := p_source_91;
155672 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
155673 l_rec_acct_attrs.array_char_value(4) := p_source_105;
155674 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
155675 l_rec_acct_attrs.array_date_value(5) := p_source_106;
155676 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
155677 l_rec_acct_attrs.array_num_value(6) := p_source_107;
155678 l_rec_acct_attrs.array_acct_attr_code(7) := 'LEDGER_AMOUNT';
155679 l_rec_acct_attrs.array_num_value(7) := p_source_95;
155680
155681 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
155682 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
155683
155684 ---------------------------------------------------------------------------------------------------------------
155685 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
155686 ---------------------------------------------------------------------------------------------------------------
155687 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
155688
155689 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
155690 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
155691
155692 IF xla_accounting_cache_pkg.GetValueChar
155693 (p_source_code => 'LEDGER_CATEGORY_CODE'
155694 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
155695 AND l_bflow_method_code = 'PRIOR_ENTRY'
155696 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
155697 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
155698 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
155699 )
155700 THEN
155701 xla_ae_lines_pkg.BflowUpgEntry
155702 (p_business_method_code => l_bflow_method_code
155703 ,p_business_class_code => l_bflow_class_code
155704 ,p_balance_type => l_balance_type_code);
155705 ELSE
155706 NULL;
155707 -- No business flow processing for business flow method of NONE.
155708 END IF;
155709
155710 --
155711 -- call analytical criteria
155712 --
155713
155714 --
155715 -- call description
155716 --
155717 -- No description or it is inherited.
155718 --
155719 -- call ADRs
155720 -- Bug 4922099
155721 --
155722 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
155723 (NVL(l_actual_upg_option, 'N') = 'O') OR
155724 (NVL(l_enc_upg_option, 'N') = 'O')
155725 )
155726 THEN
155727 NULL;
155728 --
155729 --
155730
155731 l_ccid := AcctDerRule_6(
155732 p_application_id => p_application_id
155733 , p_ae_header_id => l_ae_header_id
155734 , p_source_11 => p_source_11
155735 , x_transaction_coa_id => l_adr_transaction_coa_id
155736 , x_accounting_coa_id => l_adr_accounting_coa_id
155737 , x_value_type_code => l_adr_value_type_code
155738 , p_side => 'NA'
155739 );
155740
155741 xla_ae_lines_pkg.set_ccid(
155742 p_code_combination_id => l_ccid
155743 , p_value_type_code => l_adr_value_type_code
155744 , p_transaction_coa_id => l_adr_transaction_coa_id
155745 , p_accounting_coa_id => l_adr_accounting_coa_id
155746 , p_adr_code => 'CST_DEFAULT'
155747 , p_adr_type_code => 'S'
155748 , p_component_type => l_component_type
155749 , p_component_code => l_component_code
155750 , p_component_type_code => l_component_type_code
155751 , p_component_appl_id => l_component_appl_id
155752 , p_amb_context_code => l_amb_context_code
155753 , p_side => 'NA'
155754 );
155755
155756
155757 --
155758 --
155759 END IF;
155760 --
155761 -- Bug 4922099
155762 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
155763 (NVL(l_enc_upg_option, 'N') = 'O')
155764 ) AND
155765 (l_bflow_method_code = 'PRIOR_ENTRY')
155766 )
155767 THEN
155768 IF
155769 --
155770 1 = 2
155771 --
155772 THEN
155773 xla_accounting_err_pkg.build_message
155774 (p_appli_s_name => 'XLA'
155775 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
155776 ,p_token_1 => 'LINE_NUMBER'
155777 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
155778 ,p_token_2 => 'LINE_TYPE_NAME'
155779 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
155780 l_component_type
155781 ,l_component_code
155782 ,l_component_type_code
155783 ,l_component_appl_id
155784 ,l_amb_context_code
155785 ,l_entity_code
155786 ,l_event_class_code
155787 )
155788 ,p_token_3 => 'OWNER'
155789 ,p_value_3 => xla_lookups_pkg.get_meaning(
155790 p_lookup_type => 'XLA_OWNER_TYPE'
155791 ,p_lookup_code => l_component_type_code
155792 )
155793 ,p_token_4 => 'PRODUCT_NAME'
155794 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
155795 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
155796 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
155797 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
155798 ,p_ae_header_id => NULL
155799 );
155800
155801 IF (C_LEVEL_ERROR>= g_log_level) THEN
155802 trace
155803 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
155804 ,p_level => C_LEVEL_ERROR
155805 ,p_module => l_log_module);
155806 END IF;
155807 END IF;
155808 END IF;
155809 --
155810 --
155811 ------------------------------------------------------------------------------------------------
155812 -- 4219869 Business Flow
155813 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
155814 -- Prior Entry. Currently, the following code is always generated.
155815 ------------------------------------------------------------------------------------------------
155816 XLA_AE_LINES_PKG.ValidateCurrentLine;
155817
155818 ------------------------------------------------------------------------------------
155819 -- 4219869 Business Flow
155820 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
155821 ------------------------------------------------------------------------------------
155822 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
155823
155824 ----------------------------------------------------------------------------------
155825 -- 4219869 Business Flow
155826 -- Update journal entry status -- Need to generate this within IF <condition>
155827 ----------------------------------------------------------------------------------
155828 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
155829 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
155830 ,p_balance_type_code => l_balance_type_code
155831 );
155832
155833 -------------------------------------------------------------------------------------------
155834 -- 4262811 - Generate the Accrual Reversal lines
155835 -------------------------------------------------------------------------------------------
155836 BEGIN
155837 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
155838 (g_array_event(p_event_id).array_value_num('header_index'));
155839 IF l_acc_rev_flag IS NULL THEN
155840 l_acc_rev_flag := 'N';
155841 END IF;
155842 EXCEPTION
155843 WHEN OTHERS THEN
155844 l_acc_rev_flag := 'N';
155845 END;
155846 --
155847 IF (l_acc_rev_flag = 'Y') THEN
155848
155849 -- 4645092 ------------------------------------------------------------------------------
155850 -- To allow MPA report to determine if it should generate report process
155851 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
155852 ------------------------------------------------------------------------------------------
155853
155854 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
155855 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
155856 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
155857 -- call ADRs
155858 -- Bug 4922099
155859 --
155860 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
155861 (NVL(l_actual_upg_option, 'N') = 'O') OR
155862 (NVL(l_enc_upg_option, 'N') = 'O')
155863 )
155864 THEN
155865 NULL;
155866 --
155867 --
155868
155869 l_ccid := AcctDerRule_6(
155870 p_application_id => p_application_id
155871 , p_ae_header_id => l_ae_header_id
155872 , p_source_11 => p_source_11
155873 , x_transaction_coa_id => l_adr_transaction_coa_id
155874 , x_accounting_coa_id => l_adr_accounting_coa_id
155875 , x_value_type_code => l_adr_value_type_code
155876 , p_side => 'NA'
155877 );
155878
155879 xla_ae_lines_pkg.set_ccid(
155880 p_code_combination_id => l_ccid
155881 , p_value_type_code => l_adr_value_type_code
155882 , p_transaction_coa_id => l_adr_transaction_coa_id
155883 , p_accounting_coa_id => l_adr_accounting_coa_id
155884 , p_adr_code => 'CST_DEFAULT'
155885 , p_adr_type_code => 'S'
155886 , p_component_type => l_component_type
155887 , p_component_code => l_component_code
155888 , p_component_type_code => l_component_type_code
155889 , p_component_appl_id => l_component_appl_id
155890 , p_amb_context_code => l_amb_context_code
155891 , p_side => 'NA'
155892 );
155893
155894
155895 --
155896 --
155897 END IF;
155898
155899 --
155900 -- Update the line information that should be overwritten
155901 --
155902 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
155903 p_header_num => 1);
155904 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
155905
155906 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
155907
155908 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
155909 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
155910 END IF;
155911
155912 --
155913 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
155914 --
155915 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
155916 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
155917 ELSE
155918 ---------------------------------------------------------------------------------------------------
155919 -- 4262811a Switch Sign
155920 ---------------------------------------------------------------------------------------------------
155921 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
155922 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
155923 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155924 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
155925 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155926 -- 5132302
155927 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
155928 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
155929
155930 END IF;
155931
155932 -- 4955764
155933 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
155934 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
155935
155936
155937 XLA_AE_LINES_PKG.ValidateCurrentLine;
155938 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
155939
155940 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
155941 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
155942 ,p_balance_type_code => l_balance_type_code);
155943
155944 END IF;
155945
155946 -----------------------------------------------------------------------------------------
155947 -- 4262811 Multiperiod Accounting
155948 -----------------------------------------------------------------------------------------
155949 -- No MPA option is assigned.
155950
155951
155952 END IF;
155953 END IF;
155954 --
155955
155956 --
155957 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
155958 trace
155959 (p_msg => 'END of AcctLineType_290'
155960 ,p_level => C_LEVEL_PROCEDURE
155961 ,p_module => l_log_module);
155962 END IF;
155963 --
155964 EXCEPTION
155965 WHEN xla_exceptions_pkg.application_exception THEN
155966 RAISE;
155967 WHEN OTHERS THEN
155968 xla_exceptions_pkg.raise_message
155969 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_290');
155970 END AcctLineType_290;
155971 --
155972
155973 ---------------------------------------
155974 --
155975 -- PRIVATE FUNCTION
155976 -- AcctLineType_291
155977 --
155978 ---------------------------------------
155979 PROCEDURE AcctLineType_291 (
155980 p_application_id IN NUMBER
155981 ,p_event_id IN NUMBER
155982 ,p_calculate_acctd_flag IN VARCHAR2
155983 ,p_calculate_g_l_flag IN VARCHAR2
155984 ,p_actual_flag IN OUT VARCHAR2
155985 ,p_balance_type_code OUT VARCHAR2
155986 ,p_gain_or_loss_ref OUT VARCHAR2
155987
155988 --TRANSACTION_ID
155989 , p_source_1 IN NUMBER
155990 --Item Concatenated Segments
155991 , p_source_2 IN VARCHAR2
155992 --Transaction Quantity
155993 , p_source_3 IN NUMBER
155994 --Transaction Unit of Measure Code
155995 , p_source_4 IN VARCHAR2
155996 --Inventory Transaction Type Description
155997 , p_source_5 IN VARCHAR2
155998 --Cost Management Default Account
155999 , p_source_11 IN NUMBER
156000 --Applied to Application ID
156001 , p_source_79 IN NUMBER
156002 --Applied to Distribution Link Type
156003 , p_source_80 IN VARCHAR2
156004 --Applied to Entity Code
156005 , p_source_81 IN VARCHAR2
156006 --Applied To Purchase Document Identifier
156007 , p_source_83 IN NUMBER
156008 --DISTRIBUTION_IDENTIFIER
156009 , p_source_84 IN NUMBER
156010 --Distribution Type
156011 , p_source_85 IN VARCHAR2
156012 , p_source_85_meaning IN VARCHAR2
156013 --PO Budget Account
156014 , p_source_86 IN NUMBER
156015 --Encumbrance Reversal Amount Entered
156016 , p_source_87 IN NUMBER
156017 --Entered Currency Code
156018 , p_source_88 IN VARCHAR2
156019 --Transaction Encumbrance Reversal Amount
156020 , p_source_89 IN NUMBER
156021 --Entered Amount
156022 , p_source_91 IN NUMBER
156023 --Currency Conversion Date
156024 , p_source_92 IN DATE
156025 --Currency Conversion Rate
156026 , p_source_93 IN NUMBER
156027 --Currency Conversion Type
156028 , p_source_94 IN VARCHAR2
156029 --Accounted Amount
156030 , p_source_95 IN NUMBER
156031 --Purchasing Encumbrance Type Identifier
156032 , p_source_96 IN NUMBER
156033 --Accounting Line Type
156034 , p_source_97 IN NUMBER
156035 --Costing Encumbrance Upgrade Option
156036 , p_source_100 IN VARCHAR2
156037 --TXN_PO_DISTRIBUTION_ID
156038 , p_source_101 IN NUMBER
156039 )
156040 IS
156041
156042 l_component_type VARCHAR2(80);
156043 l_component_code VARCHAR2(30);
156044 l_component_type_code VARCHAR2(1);
156045 l_component_appl_id INTEGER;
156046 l_amb_context_code VARCHAR2(30);
156047 l_entity_code VARCHAR2(30);
156048 l_event_class_code VARCHAR2(30);
156049 l_ae_header_id NUMBER;
156050 l_event_type_code VARCHAR2(30);
156051 l_line_definition_code VARCHAR2(30);
156052 l_line_definition_owner_code VARCHAR2(1);
156053 --
156054 -- adr variables
156055 l_segment VARCHAR2(30);
156056 l_ccid NUMBER;
156057 l_adr_transaction_coa_id NUMBER;
156058 l_adr_accounting_coa_id NUMBER;
156059 l_adr_flexfield_segment_code VARCHAR2(30);
156060 l_adr_flex_value_set_id NUMBER;
156061 l_adr_value_type_code VARCHAR2(30);
156062 l_adr_value_combination_id NUMBER;
156063 l_adr_value_segment_code VARCHAR2(30);
156064
156065 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
156066 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
156067 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
156068 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
156069
156070 -- 4262811 Variables ------------------------------------------------------------------------------------------
156071 l_entered_amt_idx NUMBER;
156072 l_accted_amt_idx NUMBER;
156073 l_acc_rev_flag VARCHAR2(1);
156074 l_accrual_line_num NUMBER;
156075 l_tmp_amt NUMBER;
156076 l_acc_rev_natural_side_code VARCHAR2(1);
156077
156078 l_num_entries NUMBER;
156079 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
156080 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
156081 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
156082 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
156083 l_recog_line_1 NUMBER;
156084 l_recog_line_2 NUMBER;
156085
156086 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
156087 l_bflow_applied_to_amt NUMBER; -- 5132302
156088 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
156089
156090 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
156091
156092 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
156093 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
156094
156095 ---------------------------------------------------------------------------------------------------------------
156096
156097
156098 --
156099 -- bulk performance
156100 --
156101 l_balance_type_code VARCHAR2(1);
156102 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
156103 l_log_module VARCHAR2(240);
156104
156105 --
156106 -- Upgrade strategy
156107 --
156108 l_actual_upg_option VARCHAR2(1);
156109 l_enc_upg_option VARCHAR2(1);
156110
156111 --
156112 BEGIN
156113 --
156114 IF g_log_enabled THEN
156115 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_291';
156116 END IF;
156117 --
156118 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
156119
156120 trace
156121 (p_msg => 'BEGIN of AcctLineType_291'
156122 ,p_level => C_LEVEL_PROCEDURE
156123 ,p_module => l_log_module);
156124
156125 END IF;
156126 --
156127 l_component_type := 'AMB_JLT';
156128 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
156129 l_component_type_code := 'S';
156130 l_component_appl_id := 707;
156131 l_amb_context_code := 'DEFAULT';
156132 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
156133 l_event_class_code := 'PURCHASE_ORDER';
156134 l_event_type_code := 'LOG_RET_RI_INV';
156135 l_line_definition_owner_code := 'S';
156136 l_line_definition_code := 'PI_LOG_RET_RI_INV';
156137 --
156138 l_balance_type_code := 'A';
156139 l_segment := NULL;
156140 l_ccid := NULL;
156141 l_adr_transaction_coa_id := NULL;
156142 l_adr_accounting_coa_id := NULL;
156143 l_adr_flexfield_segment_code := NULL;
156144 l_adr_flex_value_set_id := NULL;
156145 l_adr_value_type_code := NULL;
156146 l_adr_value_combination_id := NULL;
156147 l_adr_value_segment_code := NULL;
156148
156149 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
156150 l_bflow_class_code := ''; -- 4219869 Business Flow
156151 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
156152 l_budgetary_control_flag := 'N';
156153
156154 l_bflow_applied_to_amt_idx := NULL; -- 5132302
156155 l_bflow_applied_to_amt := NULL; -- 5132302
156156 l_entered_amt_idx := NULL; -- 4262811
156157 l_accted_amt_idx := NULL; -- 4262811
156158 l_acc_rev_flag := NULL; -- 4262811
156159 l_accrual_line_num := NULL; -- 4262811
156160 l_tmp_amt := NULL; -- 4262811
156161 --
156162
156163 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
156164 l_balance_type_code <> 'B' THEN
156165 IF NVL(p_source_97,9E125) = 3
156166 THEN
156167
156168 --
156169 XLA_AE_LINES_PKG.SetNewLine;
156170
156171 p_balance_type_code := l_balance_type_code;
156172 -- set the flag so later we will know whether the gain loss line needs to be created
156173
156174 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
156175 p_actual_flag :='A';
156176 END IF;
156177
156178 --
156179 -- bulk performance
156180 --
156181 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
156182 p_header_num => 0); -- 4262811
156183 --
156184 -- set accounting line options
156185 --
156186 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
156187 p_natural_side_code => 'D'
156188 , p_gain_or_loss_flag => 'N'
156189 , p_gl_transfer_mode_code => 'S'
156190 , p_acct_entry_type_code => 'A'
156191 , p_switch_side_flag => 'Y'
156192 , p_merge_duplicate_code => 'N'
156193 );
156194 --
156195 l_acc_rev_natural_side_code := 'C'; -- 4262811
156196 --
156197 --
156198 -- set accounting line type info
156199 --
156200 xla_ae_lines_pkg.SetAcctLineType
156201 (p_component_type => l_component_type
156202 ,p_event_type_code => l_event_type_code
156203 ,p_line_definition_owner_code => l_line_definition_owner_code
156204 ,p_line_definition_code => l_line_definition_code
156205 ,p_accounting_line_code => l_component_code
156206 ,p_accounting_line_type_code => l_component_type_code
156207 ,p_accounting_line_appl_id => l_component_appl_id
156208 ,p_amb_context_code => l_amb_context_code
156209 ,p_entity_code => l_entity_code
156210 ,p_event_class_code => l_event_class_code);
156211 --
156212 -- set accounting class
156213 --
156214 xla_ae_lines_pkg.SetAcctClass(
156215 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
156216 , p_ae_header_id => l_ae_header_id
156217 );
156218
156219 --
156220 -- set rounding class
156221 --
156222 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
156223 'MATERIAL_OVERHEAD_ABSORPTION';
156224
156225 --
156226 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
156227 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
156228 --
156229 -- bulk performance
156230 --
156231 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
156232
156233 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
156234 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
156235
156236 -- 4955764
156237 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
156238 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
156239
156240 -- 4458381 Public Sector Enh
156241
156242 --
156243 -- set accounting attributes for the line type
156244 --
156245 l_entered_amt_idx := 17;
156246 l_accted_amt_idx := 22;
156247 l_bflow_applied_to_amt_idx := NULL; -- 5132302
156248 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
156249 l_rec_acct_attrs.array_num_value(1) := p_source_79;
156250 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
156251 l_rec_acct_attrs.array_char_value(2) := p_source_80;
156252 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
156253 l_rec_acct_attrs.array_char_value(3) := p_source_81;
156254 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
156255 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
156256 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
156257 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
156258 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
156259 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
156260 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
156261 l_rec_acct_attrs.array_char_value(7) := p_source_85;
156262 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
156263 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
156264 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
156265 l_rec_acct_attrs.array_num_value(9) := p_source_87;
156266 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
156267 l_rec_acct_attrs.array_char_value(10) := p_source_88;
156268 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
156269 l_rec_acct_attrs.array_num_value(11) := p_source_89;
156270 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
156271 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
156272 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
156273 l_rec_acct_attrs.array_num_value(13) := p_source_87;
156274 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
156275 l_rec_acct_attrs.array_char_value(14) := p_source_88;
156276 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
156277 l_rec_acct_attrs.array_num_value(15) := p_source_89;
156278 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
156279 l_rec_acct_attrs.array_char_value(16) := p_source_100;
156280 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
156281 l_rec_acct_attrs.array_num_value(17) := p_source_91;
156282 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
156283 l_rec_acct_attrs.array_char_value(18) := p_source_88;
156284 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
156285 l_rec_acct_attrs.array_date_value(19) := p_source_92;
156286 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
156287 l_rec_acct_attrs.array_num_value(20) := p_source_93;
156288 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
156289 l_rec_acct_attrs.array_char_value(21) := p_source_94;
156290 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
156291 l_rec_acct_attrs.array_num_value(22) := p_source_95;
156292 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
156293 l_rec_acct_attrs.array_num_value(23) := p_source_96;
156294 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
156295 l_rec_acct_attrs.array_num_value(24) := p_source_96;
156296
156297 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
156298 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
156299
156300 ---------------------------------------------------------------------------------------------------------------
156301 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
156302 ---------------------------------------------------------------------------------------------------------------
156303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
156304
156305 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
156306 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
156307
156308 IF xla_accounting_cache_pkg.GetValueChar
156309 (p_source_code => 'LEDGER_CATEGORY_CODE'
156310 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
156311 AND l_bflow_method_code = 'PRIOR_ENTRY'
156312 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
156313 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
156314 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
156315 )
156316 THEN
156317 xla_ae_lines_pkg.BflowUpgEntry
156318 (p_business_method_code => l_bflow_method_code
156319 ,p_business_class_code => l_bflow_class_code
156320 ,p_balance_type => l_balance_type_code);
156321 ELSE
156322 NULL;
156323 -- No business flow processing for business flow method of NONE.
156324 END IF;
156325
156326 --
156327 -- call analytical criteria
156328 --
156329
156330 --
156331 -- call description
156332 --
156333
156334 xla_ae_lines_pkg.SetLineDescription(
156335 p_ae_header_id => l_ae_header_id
156336 ,p_description => Description_1 (
156337 p_application_id => p_application_id
156338 , p_ae_header_id => l_ae_header_id
156339 , p_source_1 => p_source_1
156340 , p_source_2 => p_source_2
156341 , p_source_3 => p_source_3
156342 , p_source_4 => p_source_4
156343 , p_source_5 => p_source_5
156344 )
156345 );
156346
156347
156348 --
156349 -- call ADRs
156350 -- Bug 4922099
156351 --
156352 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
156353 (NVL(l_actual_upg_option, 'N') = 'O') OR
156354 (NVL(l_enc_upg_option, 'N') = 'O')
156355 )
156356 THEN
156357 NULL;
156358 --
156359 --
156360
156361 l_ccid := AcctDerRule_6(
156362 p_application_id => p_application_id
156363 , p_ae_header_id => l_ae_header_id
156364 , p_source_11 => p_source_11
156365 , x_transaction_coa_id => l_adr_transaction_coa_id
156366 , x_accounting_coa_id => l_adr_accounting_coa_id
156367 , x_value_type_code => l_adr_value_type_code
156368 , p_side => 'NA'
156369 );
156370
156371 xla_ae_lines_pkg.set_ccid(
156372 p_code_combination_id => l_ccid
156373 , p_value_type_code => l_adr_value_type_code
156374 , p_transaction_coa_id => l_adr_transaction_coa_id
156375 , p_accounting_coa_id => l_adr_accounting_coa_id
156376 , p_adr_code => 'CST_DEFAULT'
156377 , p_adr_type_code => 'S'
156378 , p_component_type => l_component_type
156379 , p_component_code => l_component_code
156380 , p_component_type_code => l_component_type_code
156381 , p_component_appl_id => l_component_appl_id
156382 , p_amb_context_code => l_amb_context_code
156383 , p_side => 'NA'
156384 );
156385
156386
156387 --
156388 --
156389 END IF;
156390 --
156391 -- Bug 4922099
156392 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
156393 (NVL(l_enc_upg_option, 'N') = 'O')
156394 ) AND
156395 (l_bflow_method_code = 'PRIOR_ENTRY')
156396 )
156397 THEN
156398 IF
156399 --
156400 1 = 2
156401 --
156402 THEN
156403 xla_accounting_err_pkg.build_message
156404 (p_appli_s_name => 'XLA'
156405 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
156406 ,p_token_1 => 'LINE_NUMBER'
156407 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
156408 ,p_token_2 => 'LINE_TYPE_NAME'
156409 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
156410 l_component_type
156411 ,l_component_code
156412 ,l_component_type_code
156413 ,l_component_appl_id
156414 ,l_amb_context_code
156415 ,l_entity_code
156416 ,l_event_class_code
156417 )
156418 ,p_token_3 => 'OWNER'
156419 ,p_value_3 => xla_lookups_pkg.get_meaning(
156420 p_lookup_type => 'XLA_OWNER_TYPE'
156421 ,p_lookup_code => l_component_type_code
156422 )
156423 ,p_token_4 => 'PRODUCT_NAME'
156424 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
156425 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
156426 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
156427 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
156428 ,p_ae_header_id => NULL
156429 );
156430
156431 IF (C_LEVEL_ERROR>= g_log_level) THEN
156432 trace
156433 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
156434 ,p_level => C_LEVEL_ERROR
156435 ,p_module => l_log_module);
156436 END IF;
156437 END IF;
156438 END IF;
156439 --
156440 --
156441 ------------------------------------------------------------------------------------------------
156442 -- 4219869 Business Flow
156443 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
156444 -- Prior Entry. Currently, the following code is always generated.
156445 ------------------------------------------------------------------------------------------------
156446 XLA_AE_LINES_PKG.ValidateCurrentLine;
156447
156448 ------------------------------------------------------------------------------------
156449 -- 4219869 Business Flow
156450 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
156451 ------------------------------------------------------------------------------------
156452 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
156453
156454 ----------------------------------------------------------------------------------
156455 -- 4219869 Business Flow
156456 -- Update journal entry status -- Need to generate this within IF <condition>
156457 ----------------------------------------------------------------------------------
156458 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
156459 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
156460 ,p_balance_type_code => l_balance_type_code
156461 );
156462
156463 -------------------------------------------------------------------------------------------
156464 -- 4262811 - Generate the Accrual Reversal lines
156465 -------------------------------------------------------------------------------------------
156466 BEGIN
156467 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
156468 (g_array_event(p_event_id).array_value_num('header_index'));
156469 IF l_acc_rev_flag IS NULL THEN
156470 l_acc_rev_flag := 'N';
156471 END IF;
156472 EXCEPTION
156473 WHEN OTHERS THEN
156474 l_acc_rev_flag := 'N';
156475 END;
156476 --
156477 IF (l_acc_rev_flag = 'Y') THEN
156478
156479 -- 4645092 ------------------------------------------------------------------------------
156480 -- To allow MPA report to determine if it should generate report process
156481 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
156482 ------------------------------------------------------------------------------------------
156483
156484 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
156485 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
156486 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
156487 -- call ADRs
156488 -- Bug 4922099
156489 --
156490 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
156491 (NVL(l_actual_upg_option, 'N') = 'O') OR
156492 (NVL(l_enc_upg_option, 'N') = 'O')
156493 )
156494 THEN
156495 NULL;
156496 --
156497 --
156498
156499 l_ccid := AcctDerRule_6(
156500 p_application_id => p_application_id
156501 , p_ae_header_id => l_ae_header_id
156502 , p_source_11 => p_source_11
156503 , x_transaction_coa_id => l_adr_transaction_coa_id
156504 , x_accounting_coa_id => l_adr_accounting_coa_id
156505 , x_value_type_code => l_adr_value_type_code
156506 , p_side => 'NA'
156507 );
156508
156509 xla_ae_lines_pkg.set_ccid(
156510 p_code_combination_id => l_ccid
156511 , p_value_type_code => l_adr_value_type_code
156512 , p_transaction_coa_id => l_adr_transaction_coa_id
156513 , p_accounting_coa_id => l_adr_accounting_coa_id
156514 , p_adr_code => 'CST_DEFAULT'
156515 , p_adr_type_code => 'S'
156516 , p_component_type => l_component_type
156517 , p_component_code => l_component_code
156518 , p_component_type_code => l_component_type_code
156519 , p_component_appl_id => l_component_appl_id
156520 , p_amb_context_code => l_amb_context_code
156521 , p_side => 'NA'
156522 );
156523
156524
156525 --
156526 --
156527 END IF;
156528
156529 --
156530 -- Update the line information that should be overwritten
156531 --
156532 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
156533 p_header_num => 1);
156534 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
156535
156536 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
156537
156538 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
156539 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
156540 END IF;
156541
156542 --
156543 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
156544 --
156545 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
156546 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
156547 ELSE
156548 ---------------------------------------------------------------------------------------------------
156549 -- 4262811a Switch Sign
156550 ---------------------------------------------------------------------------------------------------
156551 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
156552 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
156553 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
156554 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
156555 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
156556 -- 5132302
156557 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
156558 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
156559
156560 END IF;
156561
156562 -- 4955764
156563 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
156564 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
156565
156566
156567 XLA_AE_LINES_PKG.ValidateCurrentLine;
156568 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
156569
156570 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
156571 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
156572 ,p_balance_type_code => l_balance_type_code);
156573
156574 END IF;
156575
156576 -----------------------------------------------------------------------------------------
156577 -- 4262811 Multiperiod Accounting
156578 -----------------------------------------------------------------------------------------
156579 -- No MPA option is assigned.
156580
156581
156582 END IF;
156583 END IF;
156584 --
156585
156586 --
156587 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
156588 trace
156589 (p_msg => 'END of AcctLineType_291'
156590 ,p_level => C_LEVEL_PROCEDURE
156591 ,p_module => l_log_module);
156592 END IF;
156593 --
156594 EXCEPTION
156595 WHEN xla_exceptions_pkg.application_exception THEN
156596 RAISE;
156597 WHEN OTHERS THEN
156598 xla_exceptions_pkg.raise_message
156599 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_291');
156600 END AcctLineType_291;
156601 --
156602
156603 ---------------------------------------
156604 --
156605 -- PRIVATE FUNCTION
156606 -- AcctLineType_292
156607 --
156608 ---------------------------------------
156609 PROCEDURE AcctLineType_292 (
156610 p_application_id IN NUMBER
156611 ,p_event_id IN NUMBER
156612 ,p_calculate_acctd_flag IN VARCHAR2
156613 ,p_calculate_g_l_flag IN VARCHAR2
156614 ,p_actual_flag IN OUT VARCHAR2
156615 ,p_balance_type_code OUT VARCHAR2
156616 ,p_gain_or_loss_ref OUT VARCHAR2
156617
156618 --TRANSACTION_ID
156619 , p_source_1 IN NUMBER
156620 --Item Concatenated Segments
156621 , p_source_2 IN VARCHAR2
156622 --Transaction Quantity
156623 , p_source_3 IN NUMBER
156624 --Transaction Unit of Measure Code
156625 , p_source_4 IN VARCHAR2
156626 --Inventory Transaction Type Description
156627 , p_source_5 IN VARCHAR2
156628 --Cost Management Default Account
156629 , p_source_11 IN NUMBER
156630 --DISTRIBUTION_IDENTIFIER
156631 , p_source_84 IN NUMBER
156632 --Distribution Type
156633 , p_source_85 IN VARCHAR2
156634 , p_source_85_meaning IN VARCHAR2
156635 --Entered Currency Code
156636 , p_source_88 IN VARCHAR2
156637 --Entered Amount
156638 , p_source_91 IN NUMBER
156639 --Currency Conversion Date
156640 , p_source_92 IN DATE
156641 --Currency Conversion Rate
156642 , p_source_93 IN NUMBER
156643 --Currency Conversion Type
156644 , p_source_94 IN VARCHAR2
156645 --Accounted Amount
156646 , p_source_95 IN NUMBER
156647 --Accounting Line Type
156648 , p_source_97 IN NUMBER
156649 )
156650 IS
156651
156652 l_component_type VARCHAR2(80);
156653 l_component_code VARCHAR2(30);
156654 l_component_type_code VARCHAR2(1);
156655 l_component_appl_id INTEGER;
156656 l_amb_context_code VARCHAR2(30);
156657 l_entity_code VARCHAR2(30);
156658 l_event_class_code VARCHAR2(30);
156659 l_ae_header_id NUMBER;
156660 l_event_type_code VARCHAR2(30);
156661 l_line_definition_code VARCHAR2(30);
156662 l_line_definition_owner_code VARCHAR2(1);
156663 --
156664 -- adr variables
156665 l_segment VARCHAR2(30);
156666 l_ccid NUMBER;
156667 l_adr_transaction_coa_id NUMBER;
156668 l_adr_accounting_coa_id NUMBER;
156669 l_adr_flexfield_segment_code VARCHAR2(30);
156670 l_adr_flex_value_set_id NUMBER;
156671 l_adr_value_type_code VARCHAR2(30);
156672 l_adr_value_combination_id NUMBER;
156673 l_adr_value_segment_code VARCHAR2(30);
156674
156675 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
156676 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
156677 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
156678 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
156679
156680 -- 4262811 Variables ------------------------------------------------------------------------------------------
156681 l_entered_amt_idx NUMBER;
156682 l_accted_amt_idx NUMBER;
156683 l_acc_rev_flag VARCHAR2(1);
156684 l_accrual_line_num NUMBER;
156685 l_tmp_amt NUMBER;
156686 l_acc_rev_natural_side_code VARCHAR2(1);
156687
156688 l_num_entries NUMBER;
156689 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
156690 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
156691 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
156692 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
156693 l_recog_line_1 NUMBER;
156694 l_recog_line_2 NUMBER;
156695
156696 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
156697 l_bflow_applied_to_amt NUMBER; -- 5132302
156698 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
156699
156700 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
156701
156702 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
156703 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
156704
156705 ---------------------------------------------------------------------------------------------------------------
156706
156707
156708 --
156709 -- bulk performance
156710 --
156711 l_balance_type_code VARCHAR2(1);
156712 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
156713 l_log_module VARCHAR2(240);
156714
156715 --
156716 -- Upgrade strategy
156717 --
156718 l_actual_upg_option VARCHAR2(1);
156719 l_enc_upg_option VARCHAR2(1);
156720
156721 --
156722 BEGIN
156723 --
156724 IF g_log_enabled THEN
156725 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_292';
156726 END IF;
156727 --
156728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
156729
156730 trace
156731 (p_msg => 'BEGIN of AcctLineType_292'
156732 ,p_level => C_LEVEL_PROCEDURE
156733 ,p_module => l_log_module);
156734
156735 END IF;
156736 --
156737 l_component_type := 'AMB_JLT';
156738 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
156739 l_component_type_code := 'S';
156740 l_component_appl_id := 707;
156741 l_amb_context_code := 'DEFAULT';
156742 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
156743 l_event_class_code := 'USER_DEFINE';
156744 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
156745 l_line_definition_owner_code := 'S';
156746 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
156747 --
156748 l_balance_type_code := 'A';
156749 l_segment := NULL;
156750 l_ccid := NULL;
156751 l_adr_transaction_coa_id := NULL;
156752 l_adr_accounting_coa_id := NULL;
156753 l_adr_flexfield_segment_code := NULL;
156754 l_adr_flex_value_set_id := NULL;
156755 l_adr_value_type_code := NULL;
156756 l_adr_value_combination_id := NULL;
156757 l_adr_value_segment_code := NULL;
156758
156759 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
156760 l_bflow_class_code := ''; -- 4219869 Business Flow
156761 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
156762 l_budgetary_control_flag := 'N';
156763
156764 l_bflow_applied_to_amt_idx := NULL; -- 5132302
156765 l_bflow_applied_to_amt := NULL; -- 5132302
156766 l_entered_amt_idx := NULL; -- 4262811
156767 l_accted_amt_idx := NULL; -- 4262811
156768 l_acc_rev_flag := NULL; -- 4262811
156769 l_accrual_line_num := NULL; -- 4262811
156770 l_tmp_amt := NULL; -- 4262811
156771 --
156772
156773 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
156774 l_balance_type_code <> 'B' THEN
156775 IF NVL(p_source_97,9E125) = 3
156776 THEN
156777
156778 --
156779 XLA_AE_LINES_PKG.SetNewLine;
156780
156781 p_balance_type_code := l_balance_type_code;
156782 -- set the flag so later we will know whether the gain loss line needs to be created
156783
156784 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
156785 p_actual_flag :='A';
156786 END IF;
156787
156788 --
156789 -- bulk performance
156790 --
156791 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
156792 p_header_num => 0); -- 4262811
156793 --
156794 -- set accounting line options
156795 --
156796 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
156797 p_natural_side_code => 'D'
156798 , p_gain_or_loss_flag => 'N'
156799 , p_gl_transfer_mode_code => 'S'
156800 , p_acct_entry_type_code => 'A'
156801 , p_switch_side_flag => 'Y'
156802 , p_merge_duplicate_code => 'N'
156803 );
156804 --
156805 l_acc_rev_natural_side_code := 'C'; -- 4262811
156806 --
156807 --
156808 -- set accounting line type info
156809 --
156810 xla_ae_lines_pkg.SetAcctLineType
156811 (p_component_type => l_component_type
156812 ,p_event_type_code => l_event_type_code
156813 ,p_line_definition_owner_code => l_line_definition_owner_code
156814 ,p_line_definition_code => l_line_definition_code
156815 ,p_accounting_line_code => l_component_code
156816 ,p_accounting_line_type_code => l_component_type_code
156817 ,p_accounting_line_appl_id => l_component_appl_id
156818 ,p_amb_context_code => l_amb_context_code
156819 ,p_entity_code => l_entity_code
156820 ,p_event_class_code => l_event_class_code);
156821 --
156822 -- set accounting class
156823 --
156824 xla_ae_lines_pkg.SetAcctClass(
156825 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
156826 , p_ae_header_id => l_ae_header_id
156827 );
156828
156829 --
156830 -- set rounding class
156831 --
156832 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
156833 'MATERIAL_OVERHEAD_ABSORPTION';
156834
156835 --
156836 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
156837 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
156838 --
156839 -- bulk performance
156840 --
156841 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
156842
156843 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
156844 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
156845
156846 -- 4955764
156847 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
156848 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
156849
156850 -- 4458381 Public Sector Enh
156851
156852 --
156853 -- set accounting attributes for the line type
156854 --
156855 l_entered_amt_idx := 3;
156856 l_accted_amt_idx := 8;
156857 l_bflow_applied_to_amt_idx := NULL; -- 5132302
156858 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
156859 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
156860 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
156861 l_rec_acct_attrs.array_char_value(2) := p_source_85;
156862 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
156863 l_rec_acct_attrs.array_num_value(3) := p_source_91;
156864 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
156865 l_rec_acct_attrs.array_char_value(4) := p_source_88;
156866 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
156867 l_rec_acct_attrs.array_date_value(5) := p_source_92;
156868 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
156869 l_rec_acct_attrs.array_num_value(6) := p_source_93;
156870 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
156871 l_rec_acct_attrs.array_char_value(7) := p_source_94;
156872 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
156873 l_rec_acct_attrs.array_num_value(8) := p_source_95;
156874
156875 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
156876 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
156877
156878 ---------------------------------------------------------------------------------------------------------------
156879 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
156880 ---------------------------------------------------------------------------------------------------------------
156881 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
156882
156883 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
156884 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
156885
156886 IF xla_accounting_cache_pkg.GetValueChar
156887 (p_source_code => 'LEDGER_CATEGORY_CODE'
156888 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
156889 AND l_bflow_method_code = 'PRIOR_ENTRY'
156890 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
156891 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
156892 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
156893 )
156894 THEN
156895 xla_ae_lines_pkg.BflowUpgEntry
156896 (p_business_method_code => l_bflow_method_code
156897 ,p_business_class_code => l_bflow_class_code
156898 ,p_balance_type => l_balance_type_code);
156899 ELSE
156900 NULL;
156901 -- No business flow processing for business flow method of NONE.
156902 END IF;
156903
156904 --
156905 -- call analytical criteria
156906 --
156907
156908 --
156909 -- call description
156910 --
156911
156912 xla_ae_lines_pkg.SetLineDescription(
156913 p_ae_header_id => l_ae_header_id
156914 ,p_description => Description_1 (
156915 p_application_id => p_application_id
156916 , p_ae_header_id => l_ae_header_id
156917 , p_source_1 => p_source_1
156918 , p_source_2 => p_source_2
156919 , p_source_3 => p_source_3
156920 , p_source_4 => p_source_4
156921 , p_source_5 => p_source_5
156922 )
156923 );
156924
156925
156926 --
156927 -- call ADRs
156928 -- Bug 4922099
156929 --
156930 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
156931 (NVL(l_actual_upg_option, 'N') = 'O') OR
156932 (NVL(l_enc_upg_option, 'N') = 'O')
156933 )
156934 THEN
156935 NULL;
156936 --
156937 --
156938
156939 l_ccid := AcctDerRule_6(
156940 p_application_id => p_application_id
156941 , p_ae_header_id => l_ae_header_id
156942 , p_source_11 => p_source_11
156943 , x_transaction_coa_id => l_adr_transaction_coa_id
156944 , x_accounting_coa_id => l_adr_accounting_coa_id
156945 , x_value_type_code => l_adr_value_type_code
156946 , p_side => 'NA'
156947 );
156948
156949 xla_ae_lines_pkg.set_ccid(
156950 p_code_combination_id => l_ccid
156951 , p_value_type_code => l_adr_value_type_code
156952 , p_transaction_coa_id => l_adr_transaction_coa_id
156953 , p_accounting_coa_id => l_adr_accounting_coa_id
156954 , p_adr_code => 'CST_DEFAULT'
156955 , p_adr_type_code => 'S'
156956 , p_component_type => l_component_type
156957 , p_component_code => l_component_code
156958 , p_component_type_code => l_component_type_code
156959 , p_component_appl_id => l_component_appl_id
156960 , p_amb_context_code => l_amb_context_code
156961 , p_side => 'NA'
156962 );
156963
156964
156965 --
156966 --
156967 END IF;
156968 --
156969 -- Bug 4922099
156970 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
156971 (NVL(l_enc_upg_option, 'N') = 'O')
156972 ) AND
156973 (l_bflow_method_code = 'PRIOR_ENTRY')
156974 )
156975 THEN
156976 IF
156977 --
156978 1 = 2
156979 --
156980 THEN
156981 xla_accounting_err_pkg.build_message
156982 (p_appli_s_name => 'XLA'
156983 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
156984 ,p_token_1 => 'LINE_NUMBER'
156985 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
156986 ,p_token_2 => 'LINE_TYPE_NAME'
156987 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
156988 l_component_type
156989 ,l_component_code
156990 ,l_component_type_code
156991 ,l_component_appl_id
156992 ,l_amb_context_code
156993 ,l_entity_code
156994 ,l_event_class_code
156995 )
156996 ,p_token_3 => 'OWNER'
156997 ,p_value_3 => xla_lookups_pkg.get_meaning(
156998 p_lookup_type => 'XLA_OWNER_TYPE'
156999 ,p_lookup_code => l_component_type_code
157000 )
157001 ,p_token_4 => 'PRODUCT_NAME'
157002 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
157003 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
157004 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
157005 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
157006 ,p_ae_header_id => NULL
157007 );
157008
157009 IF (C_LEVEL_ERROR>= g_log_level) THEN
157010 trace
157011 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
157012 ,p_level => C_LEVEL_ERROR
157013 ,p_module => l_log_module);
157014 END IF;
157015 END IF;
157016 END IF;
157017 --
157018 --
157019 ------------------------------------------------------------------------------------------------
157020 -- 4219869 Business Flow
157021 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
157022 -- Prior Entry. Currently, the following code is always generated.
157023 ------------------------------------------------------------------------------------------------
157024 XLA_AE_LINES_PKG.ValidateCurrentLine;
157025
157026 ------------------------------------------------------------------------------------
157027 -- 4219869 Business Flow
157028 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
157029 ------------------------------------------------------------------------------------
157030 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
157031
157032 ----------------------------------------------------------------------------------
157033 -- 4219869 Business Flow
157034 -- Update journal entry status -- Need to generate this within IF <condition>
157035 ----------------------------------------------------------------------------------
157036 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
157037 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
157038 ,p_balance_type_code => l_balance_type_code
157039 );
157040
157041 -------------------------------------------------------------------------------------------
157042 -- 4262811 - Generate the Accrual Reversal lines
157043 -------------------------------------------------------------------------------------------
157044 BEGIN
157045 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
157046 (g_array_event(p_event_id).array_value_num('header_index'));
157047 IF l_acc_rev_flag IS NULL THEN
157048 l_acc_rev_flag := 'N';
157049 END IF;
157050 EXCEPTION
157051 WHEN OTHERS THEN
157052 l_acc_rev_flag := 'N';
157053 END;
157054 --
157055 IF (l_acc_rev_flag = 'Y') THEN
157056
157057 -- 4645092 ------------------------------------------------------------------------------
157058 -- To allow MPA report to determine if it should generate report process
157059 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
157060 ------------------------------------------------------------------------------------------
157061
157062 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
157063 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
157064 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
157065 -- call ADRs
157066 -- Bug 4922099
157067 --
157068 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
157069 (NVL(l_actual_upg_option, 'N') = 'O') OR
157070 (NVL(l_enc_upg_option, 'N') = 'O')
157071 )
157072 THEN
157073 NULL;
157074 --
157075 --
157076
157077 l_ccid := AcctDerRule_6(
157078 p_application_id => p_application_id
157079 , p_ae_header_id => l_ae_header_id
157080 , p_source_11 => p_source_11
157081 , x_transaction_coa_id => l_adr_transaction_coa_id
157082 , x_accounting_coa_id => l_adr_accounting_coa_id
157083 , x_value_type_code => l_adr_value_type_code
157084 , p_side => 'NA'
157085 );
157086
157087 xla_ae_lines_pkg.set_ccid(
157088 p_code_combination_id => l_ccid
157089 , p_value_type_code => l_adr_value_type_code
157090 , p_transaction_coa_id => l_adr_transaction_coa_id
157091 , p_accounting_coa_id => l_adr_accounting_coa_id
157092 , p_adr_code => 'CST_DEFAULT'
157093 , p_adr_type_code => 'S'
157094 , p_component_type => l_component_type
157095 , p_component_code => l_component_code
157096 , p_component_type_code => l_component_type_code
157097 , p_component_appl_id => l_component_appl_id
157098 , p_amb_context_code => l_amb_context_code
157099 , p_side => 'NA'
157100 );
157101
157102
157103 --
157104 --
157105 END IF;
157106
157107 --
157108 -- Update the line information that should be overwritten
157109 --
157110 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
157111 p_header_num => 1);
157112 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
157113
157114 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
157115
157116 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
157117 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
157118 END IF;
157119
157120 --
157121 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
157122 --
157123 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
157124 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
157125 ELSE
157126 ---------------------------------------------------------------------------------------------------
157127 -- 4262811a Switch Sign
157128 ---------------------------------------------------------------------------------------------------
157129 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
157130 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
157131 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157132 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
157133 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157134 -- 5132302
157135 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
157136 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157137
157138 END IF;
157139
157140 -- 4955764
157141 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
157142 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
157143
157144
157145 XLA_AE_LINES_PKG.ValidateCurrentLine;
157146 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
157147
157148 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
157149 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
157150 ,p_balance_type_code => l_balance_type_code);
157151
157152 END IF;
157153
157154 -----------------------------------------------------------------------------------------
157155 -- 4262811 Multiperiod Accounting
157156 -----------------------------------------------------------------------------------------
157157 -- No MPA option is assigned.
157158
157159
157160 END IF;
157161 END IF;
157162 --
157163
157164 --
157165 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
157166 trace
157167 (p_msg => 'END of AcctLineType_292'
157168 ,p_level => C_LEVEL_PROCEDURE
157169 ,p_module => l_log_module);
157170 END IF;
157171 --
157172 EXCEPTION
157173 WHEN xla_exceptions_pkg.application_exception THEN
157174 RAISE;
157175 WHEN OTHERS THEN
157176 xla_exceptions_pkg.raise_message
157177 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_292');
157178 END AcctLineType_292;
157179 --
157180
157181 ---------------------------------------
157182 --
157183 -- PRIVATE FUNCTION
157184 -- AcctLineType_293
157185 --
157186 ---------------------------------------
157187 PROCEDURE AcctLineType_293 (
157188 p_application_id IN NUMBER
157189 ,p_event_id IN NUMBER
157190 ,p_calculate_acctd_flag IN VARCHAR2
157191 ,p_calculate_g_l_flag IN VARCHAR2
157192 ,p_actual_flag IN OUT VARCHAR2
157193 ,p_balance_type_code OUT VARCHAR2
157194 ,p_gain_or_loss_ref OUT VARCHAR2
157195
157196 --TRANSACTION_ID
157197 , p_source_1 IN NUMBER
157198 --Item Concatenated Segments
157199 , p_source_2 IN VARCHAR2
157200 --Transaction Quantity
157201 , p_source_3 IN NUMBER
157202 --Transaction Unit of Measure Code
157203 , p_source_4 IN VARCHAR2
157204 --Inventory Transaction Type Description
157205 , p_source_5 IN VARCHAR2
157206 --Cost Management Default Account
157207 , p_source_11 IN NUMBER
157208 --DISTRIBUTION_IDENTIFIER
157209 , p_source_84 IN NUMBER
157210 --Distribution Type
157211 , p_source_85 IN VARCHAR2
157212 , p_source_85_meaning IN VARCHAR2
157213 --Entered Currency Code
157214 , p_source_88 IN VARCHAR2
157215 --Entered Amount
157216 , p_source_91 IN NUMBER
157217 --Currency Conversion Date
157218 , p_source_92 IN DATE
157219 --Currency Conversion Rate
157220 , p_source_93 IN NUMBER
157221 --Currency Conversion Type
157222 , p_source_94 IN VARCHAR2
157223 --Accounted Amount
157224 , p_source_95 IN NUMBER
157225 --Accounting Line Type
157226 , p_source_97 IN NUMBER
157227 )
157228 IS
157229
157230 l_component_type VARCHAR2(80);
157231 l_component_code VARCHAR2(30);
157232 l_component_type_code VARCHAR2(1);
157233 l_component_appl_id INTEGER;
157234 l_amb_context_code VARCHAR2(30);
157235 l_entity_code VARCHAR2(30);
157236 l_event_class_code VARCHAR2(30);
157237 l_ae_header_id NUMBER;
157238 l_event_type_code VARCHAR2(30);
157239 l_line_definition_code VARCHAR2(30);
157240 l_line_definition_owner_code VARCHAR2(1);
157241 --
157242 -- adr variables
157243 l_segment VARCHAR2(30);
157244 l_ccid NUMBER;
157245 l_adr_transaction_coa_id NUMBER;
157246 l_adr_accounting_coa_id NUMBER;
157247 l_adr_flexfield_segment_code VARCHAR2(30);
157248 l_adr_flex_value_set_id NUMBER;
157249 l_adr_value_type_code VARCHAR2(30);
157250 l_adr_value_combination_id NUMBER;
157251 l_adr_value_segment_code VARCHAR2(30);
157252
157253 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
157254 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
157255 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
157256 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
157257
157258 -- 4262811 Variables ------------------------------------------------------------------------------------------
157259 l_entered_amt_idx NUMBER;
157260 l_accted_amt_idx NUMBER;
157261 l_acc_rev_flag VARCHAR2(1);
157262 l_accrual_line_num NUMBER;
157263 l_tmp_amt NUMBER;
157264 l_acc_rev_natural_side_code VARCHAR2(1);
157265
157266 l_num_entries NUMBER;
157267 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
157268 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
157269 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
157270 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
157271 l_recog_line_1 NUMBER;
157272 l_recog_line_2 NUMBER;
157273
157274 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
157275 l_bflow_applied_to_amt NUMBER; -- 5132302
157276 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
157277
157278 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
157279
157280 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
157281 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
157282
157283 ---------------------------------------------------------------------------------------------------------------
157284
157285
157286 --
157287 -- bulk performance
157288 --
157289 l_balance_type_code VARCHAR2(1);
157290 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
157291 l_log_module VARCHAR2(240);
157292
157293 --
157294 -- Upgrade strategy
157295 --
157296 l_actual_upg_option VARCHAR2(1);
157297 l_enc_upg_option VARCHAR2(1);
157298
157299 --
157300 BEGIN
157301 --
157302 IF g_log_enabled THEN
157303 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_293';
157304 END IF;
157305 --
157306 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
157307
157308 trace
157309 (p_msg => 'BEGIN of AcctLineType_293'
157310 ,p_level => C_LEVEL_PROCEDURE
157311 ,p_module => l_log_module);
157312
157313 END IF;
157314 --
157315 l_component_type := 'AMB_JLT';
157316 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
157317 l_component_type_code := 'S';
157318 l_component_appl_id := 707;
157319 l_amb_context_code := 'DEFAULT';
157320 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
157321 l_event_class_code := 'USER_DEFINE';
157322 l_event_type_code := 'UDIR_INTERORG_RCPT';
157323 l_line_definition_owner_code := 'S';
157324 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
157325 --
157326 l_balance_type_code := 'A';
157327 l_segment := NULL;
157328 l_ccid := NULL;
157329 l_adr_transaction_coa_id := NULL;
157330 l_adr_accounting_coa_id := NULL;
157331 l_adr_flexfield_segment_code := NULL;
157332 l_adr_flex_value_set_id := NULL;
157333 l_adr_value_type_code := NULL;
157334 l_adr_value_combination_id := NULL;
157335 l_adr_value_segment_code := NULL;
157336
157337 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
157338 l_bflow_class_code := ''; -- 4219869 Business Flow
157339 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
157340 l_budgetary_control_flag := 'N';
157341
157342 l_bflow_applied_to_amt_idx := NULL; -- 5132302
157343 l_bflow_applied_to_amt := NULL; -- 5132302
157344 l_entered_amt_idx := NULL; -- 4262811
157345 l_accted_amt_idx := NULL; -- 4262811
157346 l_acc_rev_flag := NULL; -- 4262811
157347 l_accrual_line_num := NULL; -- 4262811
157348 l_tmp_amt := NULL; -- 4262811
157349 --
157350
157351 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
157352 l_balance_type_code <> 'B' THEN
157353 IF NVL(p_source_97,9E125) = 3
157354 THEN
157355
157356 --
157357 XLA_AE_LINES_PKG.SetNewLine;
157358
157359 p_balance_type_code := l_balance_type_code;
157360 -- set the flag so later we will know whether the gain loss line needs to be created
157361
157362 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
157363 p_actual_flag :='A';
157364 END IF;
157365
157366 --
157367 -- bulk performance
157368 --
157369 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
157370 p_header_num => 0); -- 4262811
157371 --
157372 -- set accounting line options
157373 --
157374 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
157375 p_natural_side_code => 'D'
157376 , p_gain_or_loss_flag => 'N'
157377 , p_gl_transfer_mode_code => 'S'
157378 , p_acct_entry_type_code => 'A'
157379 , p_switch_side_flag => 'Y'
157380 , p_merge_duplicate_code => 'N'
157381 );
157382 --
157383 l_acc_rev_natural_side_code := 'C'; -- 4262811
157384 --
157385 --
157386 -- set accounting line type info
157387 --
157388 xla_ae_lines_pkg.SetAcctLineType
157389 (p_component_type => l_component_type
157390 ,p_event_type_code => l_event_type_code
157391 ,p_line_definition_owner_code => l_line_definition_owner_code
157392 ,p_line_definition_code => l_line_definition_code
157393 ,p_accounting_line_code => l_component_code
157394 ,p_accounting_line_type_code => l_component_type_code
157395 ,p_accounting_line_appl_id => l_component_appl_id
157396 ,p_amb_context_code => l_amb_context_code
157397 ,p_entity_code => l_entity_code
157398 ,p_event_class_code => l_event_class_code);
157399 --
157400 -- set accounting class
157401 --
157402 xla_ae_lines_pkg.SetAcctClass(
157403 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
157404 , p_ae_header_id => l_ae_header_id
157405 );
157406
157407 --
157408 -- set rounding class
157409 --
157410 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
157411 'MATERIAL_OVERHEAD_ABSORPTION';
157412
157413 --
157414 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
157415 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
157416 --
157417 -- bulk performance
157418 --
157419 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
157420
157421 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
157422 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
157423
157424 -- 4955764
157425 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
157426 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
157427
157428 -- 4458381 Public Sector Enh
157429
157430 --
157431 -- set accounting attributes for the line type
157432 --
157433 l_entered_amt_idx := 3;
157434 l_accted_amt_idx := 8;
157435 l_bflow_applied_to_amt_idx := NULL; -- 5132302
157436 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
157437 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
157438 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
157439 l_rec_acct_attrs.array_char_value(2) := p_source_85;
157440 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
157441 l_rec_acct_attrs.array_num_value(3) := p_source_91;
157442 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
157443 l_rec_acct_attrs.array_char_value(4) := p_source_88;
157444 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
157445 l_rec_acct_attrs.array_date_value(5) := p_source_92;
157446 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
157447 l_rec_acct_attrs.array_num_value(6) := p_source_93;
157448 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
157449 l_rec_acct_attrs.array_char_value(7) := p_source_94;
157450 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
157451 l_rec_acct_attrs.array_num_value(8) := p_source_95;
157452
157453 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
157454 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
157455
157456 ---------------------------------------------------------------------------------------------------------------
157457 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
157458 ---------------------------------------------------------------------------------------------------------------
157459 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
157460
157461 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
157462 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
157463
157464 IF xla_accounting_cache_pkg.GetValueChar
157465 (p_source_code => 'LEDGER_CATEGORY_CODE'
157466 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
157467 AND l_bflow_method_code = 'PRIOR_ENTRY'
157468 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
157469 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
157470 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
157471 )
157472 THEN
157473 xla_ae_lines_pkg.BflowUpgEntry
157474 (p_business_method_code => l_bflow_method_code
157475 ,p_business_class_code => l_bflow_class_code
157476 ,p_balance_type => l_balance_type_code);
157477 ELSE
157478 NULL;
157479 -- No business flow processing for business flow method of NONE.
157480 END IF;
157481
157482 --
157483 -- call analytical criteria
157484 --
157485
157486 --
157487 -- call description
157488 --
157489
157490 xla_ae_lines_pkg.SetLineDescription(
157491 p_ae_header_id => l_ae_header_id
157492 ,p_description => Description_1 (
157493 p_application_id => p_application_id
157494 , p_ae_header_id => l_ae_header_id
157495 , p_source_1 => p_source_1
157496 , p_source_2 => p_source_2
157497 , p_source_3 => p_source_3
157498 , p_source_4 => p_source_4
157499 , p_source_5 => p_source_5
157500 )
157501 );
157502
157503
157504 --
157505 -- call ADRs
157506 -- Bug 4922099
157507 --
157508 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
157509 (NVL(l_actual_upg_option, 'N') = 'O') OR
157510 (NVL(l_enc_upg_option, 'N') = 'O')
157511 )
157512 THEN
157513 NULL;
157514 --
157515 --
157516
157517 l_ccid := AcctDerRule_6(
157518 p_application_id => p_application_id
157519 , p_ae_header_id => l_ae_header_id
157520 , p_source_11 => p_source_11
157521 , x_transaction_coa_id => l_adr_transaction_coa_id
157522 , x_accounting_coa_id => l_adr_accounting_coa_id
157523 , x_value_type_code => l_adr_value_type_code
157524 , p_side => 'NA'
157525 );
157526
157527 xla_ae_lines_pkg.set_ccid(
157528 p_code_combination_id => l_ccid
157529 , p_value_type_code => l_adr_value_type_code
157530 , p_transaction_coa_id => l_adr_transaction_coa_id
157531 , p_accounting_coa_id => l_adr_accounting_coa_id
157532 , p_adr_code => 'CST_DEFAULT'
157533 , p_adr_type_code => 'S'
157534 , p_component_type => l_component_type
157535 , p_component_code => l_component_code
157536 , p_component_type_code => l_component_type_code
157537 , p_component_appl_id => l_component_appl_id
157538 , p_amb_context_code => l_amb_context_code
157539 , p_side => 'NA'
157540 );
157541
157542
157543 --
157544 --
157545 END IF;
157546 --
157547 -- Bug 4922099
157548 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
157549 (NVL(l_enc_upg_option, 'N') = 'O')
157550 ) AND
157551 (l_bflow_method_code = 'PRIOR_ENTRY')
157552 )
157553 THEN
157554 IF
157555 --
157556 1 = 2
157557 --
157558 THEN
157559 xla_accounting_err_pkg.build_message
157560 (p_appli_s_name => 'XLA'
157561 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
157562 ,p_token_1 => 'LINE_NUMBER'
157563 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
157564 ,p_token_2 => 'LINE_TYPE_NAME'
157565 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
157566 l_component_type
157567 ,l_component_code
157568 ,l_component_type_code
157569 ,l_component_appl_id
157570 ,l_amb_context_code
157571 ,l_entity_code
157572 ,l_event_class_code
157573 )
157574 ,p_token_3 => 'OWNER'
157575 ,p_value_3 => xla_lookups_pkg.get_meaning(
157576 p_lookup_type => 'XLA_OWNER_TYPE'
157577 ,p_lookup_code => l_component_type_code
157578 )
157579 ,p_token_4 => 'PRODUCT_NAME'
157580 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
157581 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
157582 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
157583 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
157584 ,p_ae_header_id => NULL
157585 );
157586
157587 IF (C_LEVEL_ERROR>= g_log_level) THEN
157588 trace
157589 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
157590 ,p_level => C_LEVEL_ERROR
157591 ,p_module => l_log_module);
157592 END IF;
157593 END IF;
157594 END IF;
157595 --
157596 --
157597 ------------------------------------------------------------------------------------------------
157598 -- 4219869 Business Flow
157599 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
157600 -- Prior Entry. Currently, the following code is always generated.
157601 ------------------------------------------------------------------------------------------------
157602 XLA_AE_LINES_PKG.ValidateCurrentLine;
157603
157604 ------------------------------------------------------------------------------------
157605 -- 4219869 Business Flow
157606 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
157607 ------------------------------------------------------------------------------------
157608 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
157609
157610 ----------------------------------------------------------------------------------
157611 -- 4219869 Business Flow
157612 -- Update journal entry status -- Need to generate this within IF <condition>
157613 ----------------------------------------------------------------------------------
157614 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
157615 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
157616 ,p_balance_type_code => l_balance_type_code
157617 );
157618
157619 -------------------------------------------------------------------------------------------
157620 -- 4262811 - Generate the Accrual Reversal lines
157621 -------------------------------------------------------------------------------------------
157622 BEGIN
157623 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
157624 (g_array_event(p_event_id).array_value_num('header_index'));
157625 IF l_acc_rev_flag IS NULL THEN
157626 l_acc_rev_flag := 'N';
157627 END IF;
157628 EXCEPTION
157629 WHEN OTHERS THEN
157630 l_acc_rev_flag := 'N';
157631 END;
157632 --
157633 IF (l_acc_rev_flag = 'Y') THEN
157634
157635 -- 4645092 ------------------------------------------------------------------------------
157636 -- To allow MPA report to determine if it should generate report process
157637 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
157638 ------------------------------------------------------------------------------------------
157639
157640 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
157641 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
157642 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
157643 -- call ADRs
157644 -- Bug 4922099
157645 --
157646 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
157647 (NVL(l_actual_upg_option, 'N') = 'O') OR
157648 (NVL(l_enc_upg_option, 'N') = 'O')
157649 )
157650 THEN
157651 NULL;
157652 --
157653 --
157654
157655 l_ccid := AcctDerRule_6(
157656 p_application_id => p_application_id
157657 , p_ae_header_id => l_ae_header_id
157658 , p_source_11 => p_source_11
157659 , x_transaction_coa_id => l_adr_transaction_coa_id
157660 , x_accounting_coa_id => l_adr_accounting_coa_id
157661 , x_value_type_code => l_adr_value_type_code
157662 , p_side => 'NA'
157663 );
157664
157665 xla_ae_lines_pkg.set_ccid(
157666 p_code_combination_id => l_ccid
157667 , p_value_type_code => l_adr_value_type_code
157668 , p_transaction_coa_id => l_adr_transaction_coa_id
157669 , p_accounting_coa_id => l_adr_accounting_coa_id
157670 , p_adr_code => 'CST_DEFAULT'
157671 , p_adr_type_code => 'S'
157672 , p_component_type => l_component_type
157673 , p_component_code => l_component_code
157674 , p_component_type_code => l_component_type_code
157675 , p_component_appl_id => l_component_appl_id
157676 , p_amb_context_code => l_amb_context_code
157677 , p_side => 'NA'
157678 );
157679
157680
157681 --
157682 --
157683 END IF;
157684
157685 --
157686 -- Update the line information that should be overwritten
157687 --
157688 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
157689 p_header_num => 1);
157690 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
157691
157692 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
157693
157694 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
157695 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
157696 END IF;
157697
157698 --
157699 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
157700 --
157701 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
157702 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
157703 ELSE
157704 ---------------------------------------------------------------------------------------------------
157705 -- 4262811a Switch Sign
157706 ---------------------------------------------------------------------------------------------------
157707 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
157708 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
157709 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157710 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
157711 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157712 -- 5132302
157713 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
157714 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
157715
157716 END IF;
157717
157718 -- 4955764
157719 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
157720 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
157721
157722
157723 XLA_AE_LINES_PKG.ValidateCurrentLine;
157724 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
157725
157726 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
157727 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
157728 ,p_balance_type_code => l_balance_type_code);
157729
157730 END IF;
157731
157732 -----------------------------------------------------------------------------------------
157733 -- 4262811 Multiperiod Accounting
157734 -----------------------------------------------------------------------------------------
157735 -- No MPA option is assigned.
157736
157737
157738 END IF;
157739 END IF;
157740 --
157741
157742 --
157743 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
157744 trace
157745 (p_msg => 'END of AcctLineType_293'
157746 ,p_level => C_LEVEL_PROCEDURE
157747 ,p_module => l_log_module);
157748 END IF;
157749 --
157750 EXCEPTION
157751 WHEN xla_exceptions_pkg.application_exception THEN
157752 RAISE;
157753 WHEN OTHERS THEN
157754 xla_exceptions_pkg.raise_message
157755 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_293');
157756 END AcctLineType_293;
157757 --
157758
157759 ---------------------------------------
157760 --
157761 -- PRIVATE FUNCTION
157762 -- AcctLineType_294
157763 --
157764 ---------------------------------------
157765 PROCEDURE AcctLineType_294 (
157766 p_application_id IN NUMBER
157767 ,p_event_id IN NUMBER
157768 ,p_calculate_acctd_flag IN VARCHAR2
157769 ,p_calculate_g_l_flag IN VARCHAR2
157770 ,p_actual_flag IN OUT VARCHAR2
157771 ,p_balance_type_code OUT VARCHAR2
157772 ,p_gain_or_loss_ref OUT VARCHAR2
157773
157774 --TRANSACTION_ID
157775 , p_source_1 IN NUMBER
157776 --Item Concatenated Segments
157777 , p_source_2 IN VARCHAR2
157778 --Transaction Quantity
157779 , p_source_3 IN NUMBER
157780 --Transaction Unit of Measure Code
157781 , p_source_4 IN VARCHAR2
157782 --Inventory Transaction Type Description
157783 , p_source_5 IN VARCHAR2
157784 --Cost Management Default Account
157785 , p_source_11 IN NUMBER
157786 --DISTRIBUTION_IDENTIFIER
157787 , p_source_84 IN NUMBER
157788 --Distribution Type
157789 , p_source_85 IN VARCHAR2
157790 , p_source_85_meaning IN VARCHAR2
157791 --Entered Currency Code
157792 , p_source_88 IN VARCHAR2
157793 --Entered Amount
157794 , p_source_91 IN NUMBER
157795 --Currency Conversion Date
157796 , p_source_92 IN DATE
157797 --Currency Conversion Rate
157798 , p_source_93 IN NUMBER
157799 --Currency Conversion Type
157800 , p_source_94 IN VARCHAR2
157801 --Accounted Amount
157802 , p_source_95 IN NUMBER
157803 --Accounting Line Type
157804 , p_source_97 IN NUMBER
157805 )
157806 IS
157807
157808 l_component_type VARCHAR2(80);
157809 l_component_code VARCHAR2(30);
157810 l_component_type_code VARCHAR2(1);
157811 l_component_appl_id INTEGER;
157812 l_amb_context_code VARCHAR2(30);
157813 l_entity_code VARCHAR2(30);
157814 l_event_class_code VARCHAR2(30);
157815 l_ae_header_id NUMBER;
157816 l_event_type_code VARCHAR2(30);
157817 l_line_definition_code VARCHAR2(30);
157818 l_line_definition_owner_code VARCHAR2(1);
157819 --
157820 -- adr variables
157821 l_segment VARCHAR2(30);
157822 l_ccid NUMBER;
157823 l_adr_transaction_coa_id NUMBER;
157824 l_adr_accounting_coa_id NUMBER;
157825 l_adr_flexfield_segment_code VARCHAR2(30);
157826 l_adr_flex_value_set_id NUMBER;
157827 l_adr_value_type_code VARCHAR2(30);
157828 l_adr_value_combination_id NUMBER;
157829 l_adr_value_segment_code VARCHAR2(30);
157830
157831 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
157832 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
157833 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
157834 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
157835
157836 -- 4262811 Variables ------------------------------------------------------------------------------------------
157837 l_entered_amt_idx NUMBER;
157838 l_accted_amt_idx NUMBER;
157839 l_acc_rev_flag VARCHAR2(1);
157840 l_accrual_line_num NUMBER;
157841 l_tmp_amt NUMBER;
157842 l_acc_rev_natural_side_code VARCHAR2(1);
157843
157844 l_num_entries NUMBER;
157845 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
157846 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
157847 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
157848 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
157849 l_recog_line_1 NUMBER;
157850 l_recog_line_2 NUMBER;
157851
157852 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
157853 l_bflow_applied_to_amt NUMBER; -- 5132302
157854 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
157855
157856 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
157857
157858 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
157859 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
157860
157861 ---------------------------------------------------------------------------------------------------------------
157862
157863
157864 --
157865 -- bulk performance
157866 --
157867 l_balance_type_code VARCHAR2(1);
157868 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
157869 l_log_module VARCHAR2(240);
157870
157871 --
157872 -- Upgrade strategy
157873 --
157874 l_actual_upg_option VARCHAR2(1);
157875 l_enc_upg_option VARCHAR2(1);
157876
157877 --
157878 BEGIN
157879 --
157880 IF g_log_enabled THEN
157881 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_294';
157882 END IF;
157883 --
157884 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
157885
157886 trace
157887 (p_msg => 'BEGIN of AcctLineType_294'
157888 ,p_level => C_LEVEL_PROCEDURE
157889 ,p_module => l_log_module);
157890
157891 END IF;
157892 --
157893 l_component_type := 'AMB_JLT';
157894 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
157895 l_component_type_code := 'S';
157896 l_component_appl_id := 707;
157897 l_amb_context_code := 'DEFAULT';
157898 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
157899 l_event_class_code := 'WIP_MTL';
157900 l_event_type_code := 'WIP_COMP_ISSUE';
157901 l_line_definition_owner_code := 'S';
157902 l_line_definition_code := 'PI_WIP_COMP_ISSUE';
157903 --
157904 l_balance_type_code := 'A';
157905 l_segment := NULL;
157906 l_ccid := NULL;
157907 l_adr_transaction_coa_id := NULL;
157908 l_adr_accounting_coa_id := NULL;
157909 l_adr_flexfield_segment_code := NULL;
157910 l_adr_flex_value_set_id := NULL;
157911 l_adr_value_type_code := NULL;
157912 l_adr_value_combination_id := NULL;
157913 l_adr_value_segment_code := NULL;
157914
157915 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
157916 l_bflow_class_code := ''; -- 4219869 Business Flow
157917 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
157918 l_budgetary_control_flag := 'N';
157919
157920 l_bflow_applied_to_amt_idx := NULL; -- 5132302
157921 l_bflow_applied_to_amt := NULL; -- 5132302
157922 l_entered_amt_idx := NULL; -- 4262811
157923 l_accted_amt_idx := NULL; -- 4262811
157924 l_acc_rev_flag := NULL; -- 4262811
157925 l_accrual_line_num := NULL; -- 4262811
157926 l_tmp_amt := NULL; -- 4262811
157927 --
157928
157929 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
157930 l_balance_type_code <> 'B' THEN
157931 IF NVL(p_source_97,9E125) = 3
157932 THEN
157933
157934 --
157935 XLA_AE_LINES_PKG.SetNewLine;
157936
157937 p_balance_type_code := l_balance_type_code;
157938 -- set the flag so later we will know whether the gain loss line needs to be created
157939
157940 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
157941 p_actual_flag :='A';
157942 END IF;
157943
157944 --
157945 -- bulk performance
157946 --
157947 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
157948 p_header_num => 0); -- 4262811
157949 --
157950 -- set accounting line options
157951 --
157952 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
157953 p_natural_side_code => 'D'
157954 , p_gain_or_loss_flag => 'N'
157955 , p_gl_transfer_mode_code => 'S'
157956 , p_acct_entry_type_code => 'A'
157957 , p_switch_side_flag => 'Y'
157958 , p_merge_duplicate_code => 'N'
157959 );
157960 --
157961 l_acc_rev_natural_side_code := 'C'; -- 4262811
157962 --
157963 --
157964 -- set accounting line type info
157965 --
157966 xla_ae_lines_pkg.SetAcctLineType
157967 (p_component_type => l_component_type
157968 ,p_event_type_code => l_event_type_code
157969 ,p_line_definition_owner_code => l_line_definition_owner_code
157970 ,p_line_definition_code => l_line_definition_code
157971 ,p_accounting_line_code => l_component_code
157972 ,p_accounting_line_type_code => l_component_type_code
157973 ,p_accounting_line_appl_id => l_component_appl_id
157974 ,p_amb_context_code => l_amb_context_code
157975 ,p_entity_code => l_entity_code
157976 ,p_event_class_code => l_event_class_code);
157977 --
157978 -- set accounting class
157979 --
157980 xla_ae_lines_pkg.SetAcctClass(
157981 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
157982 , p_ae_header_id => l_ae_header_id
157983 );
157984
157985 --
157986 -- set rounding class
157987 --
157988 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
157989 'MATERIAL_OVERHEAD_ABSORPTION';
157990
157991 --
157992 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
157993 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
157994 --
157995 -- bulk performance
157996 --
157997 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
157998
157999 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
158000 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
158001
158002 -- 4955764
158003 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
158004 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
158005
158006 -- 4458381 Public Sector Enh
158007
158008 --
158009 -- set accounting attributes for the line type
158010 --
158011 l_entered_amt_idx := 3;
158012 l_accted_amt_idx := 8;
158013 l_bflow_applied_to_amt_idx := NULL; -- 5132302
158014 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
158015 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
158016 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
158017 l_rec_acct_attrs.array_char_value(2) := p_source_85;
158018 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
158019 l_rec_acct_attrs.array_num_value(3) := p_source_91;
158020 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
158021 l_rec_acct_attrs.array_char_value(4) := p_source_88;
158022 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
158023 l_rec_acct_attrs.array_date_value(5) := p_source_92;
158024 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
158025 l_rec_acct_attrs.array_num_value(6) := p_source_93;
158026 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
158027 l_rec_acct_attrs.array_char_value(7) := p_source_94;
158028 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
158029 l_rec_acct_attrs.array_num_value(8) := p_source_95;
158030
158031 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
158032 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
158033
158034 ---------------------------------------------------------------------------------------------------------------
158035 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
158036 ---------------------------------------------------------------------------------------------------------------
158037 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
158038
158039 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
158040 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
158041
158042 IF xla_accounting_cache_pkg.GetValueChar
158043 (p_source_code => 'LEDGER_CATEGORY_CODE'
158044 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
158045 AND l_bflow_method_code = 'PRIOR_ENTRY'
158046 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
158047 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
158048 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
158049 )
158050 THEN
158051 xla_ae_lines_pkg.BflowUpgEntry
158052 (p_business_method_code => l_bflow_method_code
158053 ,p_business_class_code => l_bflow_class_code
158054 ,p_balance_type => l_balance_type_code);
158055 ELSE
158056 NULL;
158057 -- No business flow processing for business flow method of NONE.
158058 END IF;
158059
158060 --
158061 -- call analytical criteria
158062 --
158063
158064 --
158065 -- call description
158066 --
158067
158068 xla_ae_lines_pkg.SetLineDescription(
158069 p_ae_header_id => l_ae_header_id
158070 ,p_description => Description_1 (
158071 p_application_id => p_application_id
158072 , p_ae_header_id => l_ae_header_id
158073 , p_source_1 => p_source_1
158074 , p_source_2 => p_source_2
158075 , p_source_3 => p_source_3
158076 , p_source_4 => p_source_4
158077 , p_source_5 => p_source_5
158078 )
158079 );
158080
158081
158082 --
158083 -- call ADRs
158084 -- Bug 4922099
158085 --
158086 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
158087 (NVL(l_actual_upg_option, 'N') = 'O') OR
158088 (NVL(l_enc_upg_option, 'N') = 'O')
158089 )
158090 THEN
158091 NULL;
158092 --
158093 --
158094
158095 l_ccid := AcctDerRule_6(
158096 p_application_id => p_application_id
158097 , p_ae_header_id => l_ae_header_id
158098 , p_source_11 => p_source_11
158099 , x_transaction_coa_id => l_adr_transaction_coa_id
158100 , x_accounting_coa_id => l_adr_accounting_coa_id
158101 , x_value_type_code => l_adr_value_type_code
158102 , p_side => 'NA'
158103 );
158104
158105 xla_ae_lines_pkg.set_ccid(
158106 p_code_combination_id => l_ccid
158107 , p_value_type_code => l_adr_value_type_code
158108 , p_transaction_coa_id => l_adr_transaction_coa_id
158109 , p_accounting_coa_id => l_adr_accounting_coa_id
158110 , p_adr_code => 'CST_DEFAULT'
158111 , p_adr_type_code => 'S'
158112 , p_component_type => l_component_type
158113 , p_component_code => l_component_code
158114 , p_component_type_code => l_component_type_code
158115 , p_component_appl_id => l_component_appl_id
158116 , p_amb_context_code => l_amb_context_code
158117 , p_side => 'NA'
158118 );
158119
158120
158121 --
158122 --
158123 END IF;
158124 --
158125 -- Bug 4922099
158126 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
158127 (NVL(l_enc_upg_option, 'N') = 'O')
158128 ) AND
158129 (l_bflow_method_code = 'PRIOR_ENTRY')
158130 )
158131 THEN
158132 IF
158133 --
158134 1 = 2
158135 --
158136 THEN
158137 xla_accounting_err_pkg.build_message
158138 (p_appli_s_name => 'XLA'
158139 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
158140 ,p_token_1 => 'LINE_NUMBER'
158141 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
158142 ,p_token_2 => 'LINE_TYPE_NAME'
158143 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
158144 l_component_type
158145 ,l_component_code
158146 ,l_component_type_code
158147 ,l_component_appl_id
158148 ,l_amb_context_code
158149 ,l_entity_code
158150 ,l_event_class_code
158151 )
158152 ,p_token_3 => 'OWNER'
158153 ,p_value_3 => xla_lookups_pkg.get_meaning(
158154 p_lookup_type => 'XLA_OWNER_TYPE'
158155 ,p_lookup_code => l_component_type_code
158156 )
158157 ,p_token_4 => 'PRODUCT_NAME'
158158 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
158159 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
158160 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
158161 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
158162 ,p_ae_header_id => NULL
158163 );
158164
158165 IF (C_LEVEL_ERROR>= g_log_level) THEN
158166 trace
158167 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
158168 ,p_level => C_LEVEL_ERROR
158169 ,p_module => l_log_module);
158170 END IF;
158171 END IF;
158172 END IF;
158173 --
158174 --
158175 ------------------------------------------------------------------------------------------------
158176 -- 4219869 Business Flow
158177 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
158178 -- Prior Entry. Currently, the following code is always generated.
158179 ------------------------------------------------------------------------------------------------
158180 XLA_AE_LINES_PKG.ValidateCurrentLine;
158181
158182 ------------------------------------------------------------------------------------
158183 -- 4219869 Business Flow
158184 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
158185 ------------------------------------------------------------------------------------
158186 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
158187
158188 ----------------------------------------------------------------------------------
158189 -- 4219869 Business Flow
158190 -- Update journal entry status -- Need to generate this within IF <condition>
158191 ----------------------------------------------------------------------------------
158192 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
158193 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
158194 ,p_balance_type_code => l_balance_type_code
158195 );
158196
158197 -------------------------------------------------------------------------------------------
158198 -- 4262811 - Generate the Accrual Reversal lines
158199 -------------------------------------------------------------------------------------------
158200 BEGIN
158201 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
158202 (g_array_event(p_event_id).array_value_num('header_index'));
158203 IF l_acc_rev_flag IS NULL THEN
158204 l_acc_rev_flag := 'N';
158205 END IF;
158206 EXCEPTION
158207 WHEN OTHERS THEN
158208 l_acc_rev_flag := 'N';
158209 END;
158210 --
158211 IF (l_acc_rev_flag = 'Y') THEN
158212
158213 -- 4645092 ------------------------------------------------------------------------------
158214 -- To allow MPA report to determine if it should generate report process
158215 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
158216 ------------------------------------------------------------------------------------------
158217
158218 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
158219 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
158220 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
158221 -- call ADRs
158222 -- Bug 4922099
158223 --
158224 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
158225 (NVL(l_actual_upg_option, 'N') = 'O') OR
158226 (NVL(l_enc_upg_option, 'N') = 'O')
158227 )
158228 THEN
158229 NULL;
158230 --
158231 --
158232
158233 l_ccid := AcctDerRule_6(
158234 p_application_id => p_application_id
158235 , p_ae_header_id => l_ae_header_id
158236 , p_source_11 => p_source_11
158237 , x_transaction_coa_id => l_adr_transaction_coa_id
158238 , x_accounting_coa_id => l_adr_accounting_coa_id
158239 , x_value_type_code => l_adr_value_type_code
158240 , p_side => 'NA'
158241 );
158242
158243 xla_ae_lines_pkg.set_ccid(
158244 p_code_combination_id => l_ccid
158245 , p_value_type_code => l_adr_value_type_code
158246 , p_transaction_coa_id => l_adr_transaction_coa_id
158247 , p_accounting_coa_id => l_adr_accounting_coa_id
158248 , p_adr_code => 'CST_DEFAULT'
158249 , p_adr_type_code => 'S'
158250 , p_component_type => l_component_type
158251 , p_component_code => l_component_code
158252 , p_component_type_code => l_component_type_code
158253 , p_component_appl_id => l_component_appl_id
158254 , p_amb_context_code => l_amb_context_code
158255 , p_side => 'NA'
158256 );
158257
158258
158259 --
158260 --
158261 END IF;
158262
158263 --
158264 -- Update the line information that should be overwritten
158265 --
158266 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
158267 p_header_num => 1);
158268 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
158269
158270 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
158271
158272 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
158273 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
158274 END IF;
158275
158276 --
158277 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
158278 --
158279 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
158280 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
158281 ELSE
158282 ---------------------------------------------------------------------------------------------------
158283 -- 4262811a Switch Sign
158284 ---------------------------------------------------------------------------------------------------
158285 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
158286 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
158287 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158288 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
158289 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158290 -- 5132302
158291 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
158292 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158293
158294 END IF;
158295
158296 -- 4955764
158297 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
158298 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
158299
158300
158301 XLA_AE_LINES_PKG.ValidateCurrentLine;
158302 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
158303
158304 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
158305 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
158306 ,p_balance_type_code => l_balance_type_code);
158307
158308 END IF;
158309
158310 -----------------------------------------------------------------------------------------
158311 -- 4262811 Multiperiod Accounting
158312 -----------------------------------------------------------------------------------------
158313 -- No MPA option is assigned.
158314
158315
158316 END IF;
158317 END IF;
158318 --
158319
158320 --
158321 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
158322 trace
158323 (p_msg => 'END of AcctLineType_294'
158324 ,p_level => C_LEVEL_PROCEDURE
158325 ,p_module => l_log_module);
158326 END IF;
158327 --
158328 EXCEPTION
158329 WHEN xla_exceptions_pkg.application_exception THEN
158330 RAISE;
158331 WHEN OTHERS THEN
158332 xla_exceptions_pkg.raise_message
158333 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_294');
158334 END AcctLineType_294;
158335 --
158336
158337 ---------------------------------------
158338 --
158339 -- PRIVATE FUNCTION
158340 -- AcctLineType_295
158341 --
158342 ---------------------------------------
158343 PROCEDURE AcctLineType_295 (
158344 p_application_id IN NUMBER
158345 ,p_event_id IN NUMBER
158346 ,p_calculate_acctd_flag IN VARCHAR2
158347 ,p_calculate_g_l_flag IN VARCHAR2
158348 ,p_actual_flag IN OUT VARCHAR2
158349 ,p_balance_type_code OUT VARCHAR2
158350 ,p_gain_or_loss_ref OUT VARCHAR2
158351
158352 --TRANSACTION_ID
158353 , p_source_1 IN NUMBER
158354 --Item Concatenated Segments
158355 , p_source_2 IN VARCHAR2
158356 --Transaction Quantity
158357 , p_source_3 IN NUMBER
158358 --Transaction Unit of Measure Code
158359 , p_source_4 IN VARCHAR2
158360 --Inventory Transaction Type Description
158361 , p_source_5 IN VARCHAR2
158362 --Cost Management Default Account
158363 , p_source_11 IN NUMBER
158364 --DISTRIBUTION_IDENTIFIER
158365 , p_source_84 IN NUMBER
158366 --Distribution Type
158367 , p_source_85 IN VARCHAR2
158368 , p_source_85_meaning IN VARCHAR2
158369 --Entered Currency Code
158370 , p_source_88 IN VARCHAR2
158371 --Entered Amount
158372 , p_source_91 IN NUMBER
158373 --Currency Conversion Date
158374 , p_source_92 IN DATE
158375 --Currency Conversion Rate
158376 , p_source_93 IN NUMBER
158377 --Currency Conversion Type
158378 , p_source_94 IN VARCHAR2
158379 --Accounted Amount
158380 , p_source_95 IN NUMBER
158381 --Accounting Line Type
158382 , p_source_97 IN NUMBER
158383 )
158384 IS
158385
158386 l_component_type VARCHAR2(80);
158387 l_component_code VARCHAR2(30);
158388 l_component_type_code VARCHAR2(1);
158389 l_component_appl_id INTEGER;
158390 l_amb_context_code VARCHAR2(30);
158391 l_entity_code VARCHAR2(30);
158392 l_event_class_code VARCHAR2(30);
158393 l_ae_header_id NUMBER;
158394 l_event_type_code VARCHAR2(30);
158395 l_line_definition_code VARCHAR2(30);
158396 l_line_definition_owner_code VARCHAR2(1);
158397 --
158398 -- adr variables
158399 l_segment VARCHAR2(30);
158400 l_ccid NUMBER;
158401 l_adr_transaction_coa_id NUMBER;
158402 l_adr_accounting_coa_id NUMBER;
158403 l_adr_flexfield_segment_code VARCHAR2(30);
158404 l_adr_flex_value_set_id NUMBER;
158405 l_adr_value_type_code VARCHAR2(30);
158406 l_adr_value_combination_id NUMBER;
158407 l_adr_value_segment_code VARCHAR2(30);
158408
158409 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
158410 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
158411 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
158412 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
158413
158414 -- 4262811 Variables ------------------------------------------------------------------------------------------
158415 l_entered_amt_idx NUMBER;
158416 l_accted_amt_idx NUMBER;
158417 l_acc_rev_flag VARCHAR2(1);
158418 l_accrual_line_num NUMBER;
158419 l_tmp_amt NUMBER;
158420 l_acc_rev_natural_side_code VARCHAR2(1);
158421
158422 l_num_entries NUMBER;
158423 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
158424 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
158425 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
158426 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
158427 l_recog_line_1 NUMBER;
158428 l_recog_line_2 NUMBER;
158429
158430 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
158431 l_bflow_applied_to_amt NUMBER; -- 5132302
158432 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
158433
158434 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
158435
158436 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
158437 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
158438
158439 ---------------------------------------------------------------------------------------------------------------
158440
158441
158442 --
158443 -- bulk performance
158444 --
158445 l_balance_type_code VARCHAR2(1);
158446 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
158447 l_log_module VARCHAR2(240);
158448
158449 --
158450 -- Upgrade strategy
158451 --
158452 l_actual_upg_option VARCHAR2(1);
158453 l_enc_upg_option VARCHAR2(1);
158454
158455 --
158456 BEGIN
158457 --
158458 IF g_log_enabled THEN
158459 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_295';
158460 END IF;
158461 --
158462 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
158463
158464 trace
158465 (p_msg => 'BEGIN of AcctLineType_295'
158466 ,p_level => C_LEVEL_PROCEDURE
158467 ,p_module => l_log_module);
158468
158469 END IF;
158470 --
158471 l_component_type := 'AMB_JLT';
158472 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
158473 l_component_type_code := 'S';
158474 l_component_appl_id := 707;
158475 l_amb_context_code := 'DEFAULT';
158476 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
158477 l_event_class_code := 'CON_INV_OWNR_TXFR';
158478 l_event_type_code := 'CON_INV_OWNR_TXFR_ALL';
158479 l_line_definition_owner_code := 'S';
158480 l_line_definition_code := 'PI_CON_INV_OWNR_TRFR';
158481 --
158482 l_balance_type_code := 'A';
158483 l_segment := NULL;
158484 l_ccid := NULL;
158485 l_adr_transaction_coa_id := NULL;
158486 l_adr_accounting_coa_id := NULL;
158487 l_adr_flexfield_segment_code := NULL;
158488 l_adr_flex_value_set_id := NULL;
158489 l_adr_value_type_code := NULL;
158490 l_adr_value_combination_id := NULL;
158491 l_adr_value_segment_code := NULL;
158492
158493 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
158494 l_bflow_class_code := ''; -- 4219869 Business Flow
158495 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
158496 l_budgetary_control_flag := 'N';
158497
158498 l_bflow_applied_to_amt_idx := NULL; -- 5132302
158499 l_bflow_applied_to_amt := NULL; -- 5132302
158500 l_entered_amt_idx := NULL; -- 4262811
158501 l_accted_amt_idx := NULL; -- 4262811
158502 l_acc_rev_flag := NULL; -- 4262811
158503 l_accrual_line_num := NULL; -- 4262811
158504 l_tmp_amt := NULL; -- 4262811
158505 --
158506
158507 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
158508 l_balance_type_code <> 'B' THEN
158509 IF NVL(p_source_97,9E125) = 3
158510 THEN
158511
158512 --
158513 XLA_AE_LINES_PKG.SetNewLine;
158514
158515 p_balance_type_code := l_balance_type_code;
158516 -- set the flag so later we will know whether the gain loss line needs to be created
158517
158518 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
158519 p_actual_flag :='A';
158520 END IF;
158521
158522 --
158523 -- bulk performance
158524 --
158525 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
158526 p_header_num => 0); -- 4262811
158527 --
158528 -- set accounting line options
158529 --
158530 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
158531 p_natural_side_code => 'D'
158532 , p_gain_or_loss_flag => 'N'
158533 , p_gl_transfer_mode_code => 'S'
158534 , p_acct_entry_type_code => 'A'
158535 , p_switch_side_flag => 'Y'
158536 , p_merge_duplicate_code => 'N'
158537 );
158538 --
158539 l_acc_rev_natural_side_code := 'C'; -- 4262811
158540 --
158541 --
158542 -- set accounting line type info
158543 --
158544 xla_ae_lines_pkg.SetAcctLineType
158545 (p_component_type => l_component_type
158546 ,p_event_type_code => l_event_type_code
158547 ,p_line_definition_owner_code => l_line_definition_owner_code
158548 ,p_line_definition_code => l_line_definition_code
158549 ,p_accounting_line_code => l_component_code
158550 ,p_accounting_line_type_code => l_component_type_code
158551 ,p_accounting_line_appl_id => l_component_appl_id
158552 ,p_amb_context_code => l_amb_context_code
158553 ,p_entity_code => l_entity_code
158554 ,p_event_class_code => l_event_class_code);
158555 --
158556 -- set accounting class
158557 --
158558 xla_ae_lines_pkg.SetAcctClass(
158559 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
158560 , p_ae_header_id => l_ae_header_id
158561 );
158562
158563 --
158564 -- set rounding class
158565 --
158566 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
158567 'MATERIAL_OVERHEAD_ABSORPTION';
158568
158569 --
158570 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
158571 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
158572 --
158573 -- bulk performance
158574 --
158575 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
158576
158577 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
158578 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
158579
158580 -- 4955764
158581 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
158582 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
158583
158584 -- 4458381 Public Sector Enh
158585
158586 --
158587 -- set accounting attributes for the line type
158588 --
158589 l_entered_amt_idx := 3;
158590 l_accted_amt_idx := 8;
158591 l_bflow_applied_to_amt_idx := NULL; -- 5132302
158592 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
158593 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
158594 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
158595 l_rec_acct_attrs.array_char_value(2) := p_source_85;
158596 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
158597 l_rec_acct_attrs.array_num_value(3) := p_source_91;
158598 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
158599 l_rec_acct_attrs.array_char_value(4) := p_source_88;
158600 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
158601 l_rec_acct_attrs.array_date_value(5) := p_source_92;
158602 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
158603 l_rec_acct_attrs.array_num_value(6) := p_source_93;
158604 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
158605 l_rec_acct_attrs.array_char_value(7) := p_source_94;
158606 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
158607 l_rec_acct_attrs.array_num_value(8) := p_source_95;
158608
158609 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
158610 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
158611
158612 ---------------------------------------------------------------------------------------------------------------
158613 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
158614 ---------------------------------------------------------------------------------------------------------------
158615 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
158616
158617 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
158618 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
158619
158620 IF xla_accounting_cache_pkg.GetValueChar
158621 (p_source_code => 'LEDGER_CATEGORY_CODE'
158622 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
158623 AND l_bflow_method_code = 'PRIOR_ENTRY'
158624 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
158625 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
158626 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
158627 )
158628 THEN
158629 xla_ae_lines_pkg.BflowUpgEntry
158630 (p_business_method_code => l_bflow_method_code
158631 ,p_business_class_code => l_bflow_class_code
158632 ,p_balance_type => l_balance_type_code);
158633 ELSE
158634 NULL;
158635 -- No business flow processing for business flow method of NONE.
158636 END IF;
158637
158638 --
158639 -- call analytical criteria
158640 --
158641
158642 --
158643 -- call description
158644 --
158645
158646 xla_ae_lines_pkg.SetLineDescription(
158647 p_ae_header_id => l_ae_header_id
158648 ,p_description => Description_1 (
158649 p_application_id => p_application_id
158650 , p_ae_header_id => l_ae_header_id
158651 , p_source_1 => p_source_1
158652 , p_source_2 => p_source_2
158653 , p_source_3 => p_source_3
158654 , p_source_4 => p_source_4
158655 , p_source_5 => p_source_5
158656 )
158657 );
158658
158659
158660 --
158661 -- call ADRs
158662 -- Bug 4922099
158663 --
158664 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
158665 (NVL(l_actual_upg_option, 'N') = 'O') OR
158666 (NVL(l_enc_upg_option, 'N') = 'O')
158667 )
158668 THEN
158669 NULL;
158670 --
158671 --
158672
158673 l_ccid := AcctDerRule_6(
158674 p_application_id => p_application_id
158675 , p_ae_header_id => l_ae_header_id
158676 , p_source_11 => p_source_11
158677 , x_transaction_coa_id => l_adr_transaction_coa_id
158678 , x_accounting_coa_id => l_adr_accounting_coa_id
158679 , x_value_type_code => l_adr_value_type_code
158680 , p_side => 'NA'
158681 );
158682
158683 xla_ae_lines_pkg.set_ccid(
158684 p_code_combination_id => l_ccid
158685 , p_value_type_code => l_adr_value_type_code
158686 , p_transaction_coa_id => l_adr_transaction_coa_id
158687 , p_accounting_coa_id => l_adr_accounting_coa_id
158688 , p_adr_code => 'CST_DEFAULT'
158689 , p_adr_type_code => 'S'
158690 , p_component_type => l_component_type
158691 , p_component_code => l_component_code
158692 , p_component_type_code => l_component_type_code
158693 , p_component_appl_id => l_component_appl_id
158694 , p_amb_context_code => l_amb_context_code
158695 , p_side => 'NA'
158696 );
158697
158698
158699 --
158700 --
158701 END IF;
158702 --
158703 -- Bug 4922099
158704 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
158705 (NVL(l_enc_upg_option, 'N') = 'O')
158706 ) AND
158707 (l_bflow_method_code = 'PRIOR_ENTRY')
158708 )
158709 THEN
158710 IF
158711 --
158712 1 = 2
158713 --
158714 THEN
158715 xla_accounting_err_pkg.build_message
158716 (p_appli_s_name => 'XLA'
158717 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
158718 ,p_token_1 => 'LINE_NUMBER'
158719 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
158720 ,p_token_2 => 'LINE_TYPE_NAME'
158721 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
158722 l_component_type
158723 ,l_component_code
158724 ,l_component_type_code
158725 ,l_component_appl_id
158726 ,l_amb_context_code
158727 ,l_entity_code
158728 ,l_event_class_code
158729 )
158730 ,p_token_3 => 'OWNER'
158731 ,p_value_3 => xla_lookups_pkg.get_meaning(
158732 p_lookup_type => 'XLA_OWNER_TYPE'
158733 ,p_lookup_code => l_component_type_code
158734 )
158735 ,p_token_4 => 'PRODUCT_NAME'
158736 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
158737 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
158738 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
158739 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
158740 ,p_ae_header_id => NULL
158741 );
158742
158743 IF (C_LEVEL_ERROR>= g_log_level) THEN
158744 trace
158745 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
158746 ,p_level => C_LEVEL_ERROR
158747 ,p_module => l_log_module);
158748 END IF;
158749 END IF;
158750 END IF;
158751 --
158752 --
158753 ------------------------------------------------------------------------------------------------
158754 -- 4219869 Business Flow
158755 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
158756 -- Prior Entry. Currently, the following code is always generated.
158757 ------------------------------------------------------------------------------------------------
158758 XLA_AE_LINES_PKG.ValidateCurrentLine;
158759
158760 ------------------------------------------------------------------------------------
158761 -- 4219869 Business Flow
158762 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
158763 ------------------------------------------------------------------------------------
158764 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
158765
158766 ----------------------------------------------------------------------------------
158767 -- 4219869 Business Flow
158768 -- Update journal entry status -- Need to generate this within IF <condition>
158769 ----------------------------------------------------------------------------------
158770 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
158771 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
158772 ,p_balance_type_code => l_balance_type_code
158773 );
158774
158775 -------------------------------------------------------------------------------------------
158776 -- 4262811 - Generate the Accrual Reversal lines
158777 -------------------------------------------------------------------------------------------
158778 BEGIN
158779 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
158780 (g_array_event(p_event_id).array_value_num('header_index'));
158781 IF l_acc_rev_flag IS NULL THEN
158782 l_acc_rev_flag := 'N';
158783 END IF;
158784 EXCEPTION
158785 WHEN OTHERS THEN
158786 l_acc_rev_flag := 'N';
158787 END;
158788 --
158789 IF (l_acc_rev_flag = 'Y') THEN
158790
158791 -- 4645092 ------------------------------------------------------------------------------
158792 -- To allow MPA report to determine if it should generate report process
158793 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
158794 ------------------------------------------------------------------------------------------
158795
158796 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
158797 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
158798 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
158799 -- call ADRs
158800 -- Bug 4922099
158801 --
158802 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
158803 (NVL(l_actual_upg_option, 'N') = 'O') OR
158804 (NVL(l_enc_upg_option, 'N') = 'O')
158805 )
158806 THEN
158807 NULL;
158808 --
158809 --
158810
158811 l_ccid := AcctDerRule_6(
158812 p_application_id => p_application_id
158813 , p_ae_header_id => l_ae_header_id
158814 , p_source_11 => p_source_11
158815 , x_transaction_coa_id => l_adr_transaction_coa_id
158816 , x_accounting_coa_id => l_adr_accounting_coa_id
158817 , x_value_type_code => l_adr_value_type_code
158818 , p_side => 'NA'
158819 );
158820
158821 xla_ae_lines_pkg.set_ccid(
158822 p_code_combination_id => l_ccid
158823 , p_value_type_code => l_adr_value_type_code
158824 , p_transaction_coa_id => l_adr_transaction_coa_id
158825 , p_accounting_coa_id => l_adr_accounting_coa_id
158826 , p_adr_code => 'CST_DEFAULT'
158827 , p_adr_type_code => 'S'
158828 , p_component_type => l_component_type
158829 , p_component_code => l_component_code
158830 , p_component_type_code => l_component_type_code
158831 , p_component_appl_id => l_component_appl_id
158832 , p_amb_context_code => l_amb_context_code
158833 , p_side => 'NA'
158834 );
158835
158836
158837 --
158838 --
158839 END IF;
158840
158841 --
158842 -- Update the line information that should be overwritten
158843 --
158844 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
158845 p_header_num => 1);
158846 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
158847
158848 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
158849
158850 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
158851 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
158852 END IF;
158853
158854 --
158855 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
158856 --
158857 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
158858 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
158859 ELSE
158860 ---------------------------------------------------------------------------------------------------
158861 -- 4262811a Switch Sign
158862 ---------------------------------------------------------------------------------------------------
158863 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
158864 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
158865 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158866 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
158867 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158868 -- 5132302
158869 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
158870 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
158871
158872 END IF;
158873
158874 -- 4955764
158875 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
158876 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
158877
158878
158879 XLA_AE_LINES_PKG.ValidateCurrentLine;
158880 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
158881
158882 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
158883 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
158884 ,p_balance_type_code => l_balance_type_code);
158885
158886 END IF;
158887
158888 -----------------------------------------------------------------------------------------
158889 -- 4262811 Multiperiod Accounting
158890 -----------------------------------------------------------------------------------------
158891 -- No MPA option is assigned.
158892
158893
158894 END IF;
158895 END IF;
158896 --
158897
158898 --
158899 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
158900 trace
158901 (p_msg => 'END of AcctLineType_295'
158902 ,p_level => C_LEVEL_PROCEDURE
158903 ,p_module => l_log_module);
158904 END IF;
158905 --
158906 EXCEPTION
158907 WHEN xla_exceptions_pkg.application_exception THEN
158908 RAISE;
158909 WHEN OTHERS THEN
158910 xla_exceptions_pkg.raise_message
158911 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_295');
158912 END AcctLineType_295;
158913 --
158914
158915 ---------------------------------------
158916 --
158917 -- PRIVATE FUNCTION
158918 -- AcctLineType_296
158919 --
158920 ---------------------------------------
158921 PROCEDURE AcctLineType_296 (
158922 p_application_id IN NUMBER
158923 ,p_event_id IN NUMBER
158924 ,p_calculate_acctd_flag IN VARCHAR2
158925 ,p_calculate_g_l_flag IN VARCHAR2
158926 ,p_actual_flag IN OUT VARCHAR2
158927 ,p_balance_type_code OUT VARCHAR2
158928 ,p_gain_or_loss_ref OUT VARCHAR2
158929
158930 --TRANSACTION_ID
158931 , p_source_1 IN NUMBER
158932 --Item Concatenated Segments
158933 , p_source_2 IN VARCHAR2
158934 --Transaction Quantity
158935 , p_source_3 IN NUMBER
158936 --Transaction Unit of Measure Code
158937 , p_source_4 IN VARCHAR2
158938 --Inventory Transaction Type Description
158939 , p_source_5 IN VARCHAR2
158940 --Cost Management Default Account
158941 , p_source_11 IN NUMBER
158942 --Applied to Application ID
158943 , p_source_79 IN NUMBER
158944 --Applied to Distribution Link Type
158945 , p_source_80 IN VARCHAR2
158946 --Applied to Entity Code
158947 , p_source_81 IN VARCHAR2
158948 --DISTRIBUTION_IDENTIFIER
158949 , p_source_84 IN NUMBER
158950 --Distribution Type
158951 , p_source_85 IN VARCHAR2
158952 , p_source_85_meaning IN VARCHAR2
158953 --Encumbrance Reversal Amount Entered
158954 , p_source_87 IN NUMBER
158955 --Entered Currency Code
158956 , p_source_88 IN VARCHAR2
158957 --Transaction Encumbrance Reversal Amount
158958 , p_source_89 IN NUMBER
158959 --Entered Amount
158960 , p_source_91 IN NUMBER
158961 --Currency Conversion Date
158962 , p_source_92 IN DATE
158963 --Currency Conversion Rate
158964 , p_source_93 IN NUMBER
158965 --Currency Conversion Type
158966 , p_source_94 IN VARCHAR2
158967 --Accounted Amount
158968 , p_source_95 IN NUMBER
158969 --Accounting Line Type
158970 , p_source_97 IN NUMBER
158971 --Costing Encumbrance Upgrade Option
158972 , p_source_100 IN VARCHAR2
158973 --TXN_PO_DISTRIBUTION_ID
158974 , p_source_101 IN NUMBER
158975 --TXN_PO_HEADER_ID
158976 , p_source_102 IN NUMBER
158977 --Requisition Budget Account
158978 , p_source_103 IN NUMBER
158979 --Requisition Encumbrance Type Identifier
158980 , p_source_104 IN NUMBER
158981 )
158982 IS
158983
158984 l_component_type VARCHAR2(80);
158985 l_component_code VARCHAR2(30);
158986 l_component_type_code VARCHAR2(1);
158987 l_component_appl_id INTEGER;
158988 l_amb_context_code VARCHAR2(30);
158989 l_entity_code VARCHAR2(30);
158990 l_event_class_code VARCHAR2(30);
158991 l_ae_header_id NUMBER;
158992 l_event_type_code VARCHAR2(30);
158993 l_line_definition_code VARCHAR2(30);
158994 l_line_definition_owner_code VARCHAR2(1);
158995 --
158996 -- adr variables
158997 l_segment VARCHAR2(30);
158998 l_ccid NUMBER;
158999 l_adr_transaction_coa_id NUMBER;
159000 l_adr_accounting_coa_id NUMBER;
159001 l_adr_flexfield_segment_code VARCHAR2(30);
159002 l_adr_flex_value_set_id NUMBER;
159003 l_adr_value_type_code VARCHAR2(30);
159004 l_adr_value_combination_id NUMBER;
159005 l_adr_value_segment_code VARCHAR2(30);
159006
159007 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
159008 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
159009 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
159010 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
159011
159012 -- 4262811 Variables ------------------------------------------------------------------------------------------
159013 l_entered_amt_idx NUMBER;
159014 l_accted_amt_idx NUMBER;
159015 l_acc_rev_flag VARCHAR2(1);
159016 l_accrual_line_num NUMBER;
159017 l_tmp_amt NUMBER;
159018 l_acc_rev_natural_side_code VARCHAR2(1);
159019
159020 l_num_entries NUMBER;
159021 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
159022 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
159023 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
159024 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
159025 l_recog_line_1 NUMBER;
159026 l_recog_line_2 NUMBER;
159027
159028 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
159029 l_bflow_applied_to_amt NUMBER; -- 5132302
159030 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
159031
159032 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
159033
159034 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
159035 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
159036
159037 ---------------------------------------------------------------------------------------------------------------
159038
159039
159040 --
159041 -- bulk performance
159042 --
159043 l_balance_type_code VARCHAR2(1);
159044 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
159045 l_log_module VARCHAR2(240);
159046
159047 --
159048 -- Upgrade strategy
159049 --
159050 l_actual_upg_option VARCHAR2(1);
159051 l_enc_upg_option VARCHAR2(1);
159052
159053 --
159054 BEGIN
159055 --
159056 IF g_log_enabled THEN
159057 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_296';
159058 END IF;
159059 --
159060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
159061
159062 trace
159063 (p_msg => 'BEGIN of AcctLineType_296'
159064 ,p_level => C_LEVEL_PROCEDURE
159065 ,p_module => l_log_module);
159066
159067 END IF;
159068 --
159069 l_component_type := 'AMB_JLT';
159070 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
159071 l_component_type_code := 'S';
159072 l_component_appl_id := 707;
159073 l_amb_context_code := 'DEFAULT';
159074 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
159075 l_event_class_code := 'DIR_INTERORG_RCPT';
159076 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
159077 l_line_definition_owner_code := 'S';
159078 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
159079 --
159080 l_balance_type_code := 'A';
159081 l_segment := NULL;
159082 l_ccid := NULL;
159083 l_adr_transaction_coa_id := NULL;
159084 l_adr_accounting_coa_id := NULL;
159085 l_adr_flexfield_segment_code := NULL;
159086 l_adr_flex_value_set_id := NULL;
159087 l_adr_value_type_code := NULL;
159088 l_adr_value_combination_id := NULL;
159089 l_adr_value_segment_code := NULL;
159090
159091 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
159092 l_bflow_class_code := ''; -- 4219869 Business Flow
159093 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
159094 l_budgetary_control_flag := 'N';
159095
159096 l_bflow_applied_to_amt_idx := NULL; -- 5132302
159097 l_bflow_applied_to_amt := NULL; -- 5132302
159098 l_entered_amt_idx := NULL; -- 4262811
159099 l_accted_amt_idx := NULL; -- 4262811
159100 l_acc_rev_flag := NULL; -- 4262811
159101 l_accrual_line_num := NULL; -- 4262811
159102 l_tmp_amt := NULL; -- 4262811
159103 --
159104
159105 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
159106 l_balance_type_code <> 'B' THEN
159107 IF NVL(p_source_97,9E125) = 3
159108 THEN
159109
159110 --
159111 XLA_AE_LINES_PKG.SetNewLine;
159112
159113 p_balance_type_code := l_balance_type_code;
159114 -- set the flag so later we will know whether the gain loss line needs to be created
159115
159116 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
159117 p_actual_flag :='A';
159118 END IF;
159119
159120 --
159121 -- bulk performance
159122 --
159123 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
159124 p_header_num => 0); -- 4262811
159125 --
159126 -- set accounting line options
159127 --
159128 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
159129 p_natural_side_code => 'D'
159130 , p_gain_or_loss_flag => 'N'
159131 , p_gl_transfer_mode_code => 'S'
159132 , p_acct_entry_type_code => 'A'
159133 , p_switch_side_flag => 'Y'
159134 , p_merge_duplicate_code => 'N'
159135 );
159136 --
159137 l_acc_rev_natural_side_code := 'C'; -- 4262811
159138 --
159139 --
159140 -- set accounting line type info
159141 --
159142 xla_ae_lines_pkg.SetAcctLineType
159143 (p_component_type => l_component_type
159144 ,p_event_type_code => l_event_type_code
159145 ,p_line_definition_owner_code => l_line_definition_owner_code
159146 ,p_line_definition_code => l_line_definition_code
159147 ,p_accounting_line_code => l_component_code
159148 ,p_accounting_line_type_code => l_component_type_code
159149 ,p_accounting_line_appl_id => l_component_appl_id
159150 ,p_amb_context_code => l_amb_context_code
159151 ,p_entity_code => l_entity_code
159152 ,p_event_class_code => l_event_class_code);
159153 --
159154 -- set accounting class
159155 --
159156 xla_ae_lines_pkg.SetAcctClass(
159157 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
159158 , p_ae_header_id => l_ae_header_id
159159 );
159160
159161 --
159162 -- set rounding class
159163 --
159164 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
159165 'MATERIAL_OVERHEAD_ABSORPTION';
159166
159167 --
159168 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
159169 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
159170 --
159171 -- bulk performance
159172 --
159173 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
159174
159175 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
159176 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
159177
159178 -- 4955764
159179 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
159180 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
159181
159182 -- 4458381 Public Sector Enh
159183
159184 --
159185 -- set accounting attributes for the line type
159186 --
159187 l_entered_amt_idx := 17;
159188 l_accted_amt_idx := 22;
159189 l_bflow_applied_to_amt_idx := NULL; -- 5132302
159190 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
159191 l_rec_acct_attrs.array_num_value(1) := p_source_79;
159192 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
159193 l_rec_acct_attrs.array_char_value(2) := p_source_80;
159194 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
159195 l_rec_acct_attrs.array_char_value(3) := p_source_81;
159196 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
159197 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
159198 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
159199 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
159200 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
159201 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
159202 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
159203 l_rec_acct_attrs.array_char_value(7) := p_source_85;
159204 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
159205 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
159206 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
159207 l_rec_acct_attrs.array_num_value(9) := p_source_87;
159208 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
159209 l_rec_acct_attrs.array_char_value(10) := p_source_88;
159210 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
159211 l_rec_acct_attrs.array_num_value(11) := p_source_89;
159212 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
159213 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
159214 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
159215 l_rec_acct_attrs.array_num_value(13) := p_source_87;
159216 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
159217 l_rec_acct_attrs.array_char_value(14) := p_source_88;
159218 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
159219 l_rec_acct_attrs.array_num_value(15) := p_source_89;
159220 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
159221 l_rec_acct_attrs.array_char_value(16) := p_source_100;
159222 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
159223 l_rec_acct_attrs.array_num_value(17) := p_source_91;
159224 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
159225 l_rec_acct_attrs.array_char_value(18) := p_source_88;
159226 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
159227 l_rec_acct_attrs.array_date_value(19) := p_source_92;
159228 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
159229 l_rec_acct_attrs.array_num_value(20) := p_source_93;
159230 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
159231 l_rec_acct_attrs.array_char_value(21) := p_source_94;
159232 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
159233 l_rec_acct_attrs.array_num_value(22) := p_source_95;
159234 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
159235 l_rec_acct_attrs.array_num_value(23) := p_source_104;
159236 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
159237 l_rec_acct_attrs.array_num_value(24) := p_source_104;
159238
159239 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
159240 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
159241
159242 ---------------------------------------------------------------------------------------------------------------
159243 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
159244 ---------------------------------------------------------------------------------------------------------------
159245 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
159246
159247 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
159248 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
159249
159250 IF xla_accounting_cache_pkg.GetValueChar
159251 (p_source_code => 'LEDGER_CATEGORY_CODE'
159252 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
159253 AND l_bflow_method_code = 'PRIOR_ENTRY'
159254 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
159255 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
159256 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
159257 )
159258 THEN
159259 xla_ae_lines_pkg.BflowUpgEntry
159260 (p_business_method_code => l_bflow_method_code
159261 ,p_business_class_code => l_bflow_class_code
159262 ,p_balance_type => l_balance_type_code);
159263 ELSE
159264 NULL;
159265 -- No business flow processing for business flow method of NONE.
159266 END IF;
159267
159268 --
159269 -- call analytical criteria
159270 --
159271
159272 --
159273 -- call description
159274 --
159275
159276 xla_ae_lines_pkg.SetLineDescription(
159277 p_ae_header_id => l_ae_header_id
159278 ,p_description => Description_1 (
159279 p_application_id => p_application_id
159280 , p_ae_header_id => l_ae_header_id
159281 , p_source_1 => p_source_1
159282 , p_source_2 => p_source_2
159283 , p_source_3 => p_source_3
159284 , p_source_4 => p_source_4
159285 , p_source_5 => p_source_5
159286 )
159287 );
159288
159289
159290 --
159291 -- call ADRs
159292 -- Bug 4922099
159293 --
159294 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
159295 (NVL(l_actual_upg_option, 'N') = 'O') OR
159296 (NVL(l_enc_upg_option, 'N') = 'O')
159297 )
159298 THEN
159299 NULL;
159300 --
159301 --
159302
159303 l_ccid := AcctDerRule_6(
159304 p_application_id => p_application_id
159305 , p_ae_header_id => l_ae_header_id
159306 , p_source_11 => p_source_11
159307 , x_transaction_coa_id => l_adr_transaction_coa_id
159308 , x_accounting_coa_id => l_adr_accounting_coa_id
159309 , x_value_type_code => l_adr_value_type_code
159310 , p_side => 'NA'
159311 );
159312
159313 xla_ae_lines_pkg.set_ccid(
159314 p_code_combination_id => l_ccid
159315 , p_value_type_code => l_adr_value_type_code
159316 , p_transaction_coa_id => l_adr_transaction_coa_id
159317 , p_accounting_coa_id => l_adr_accounting_coa_id
159318 , p_adr_code => 'CST_DEFAULT'
159319 , p_adr_type_code => 'S'
159320 , p_component_type => l_component_type
159321 , p_component_code => l_component_code
159322 , p_component_type_code => l_component_type_code
159323 , p_component_appl_id => l_component_appl_id
159324 , p_amb_context_code => l_amb_context_code
159325 , p_side => 'NA'
159326 );
159327
159328
159329 --
159330 --
159331 END IF;
159332 --
159333 -- Bug 4922099
159334 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
159335 (NVL(l_enc_upg_option, 'N') = 'O')
159336 ) AND
159337 (l_bflow_method_code = 'PRIOR_ENTRY')
159338 )
159339 THEN
159340 IF
159341 --
159342 1 = 2
159343 --
159344 THEN
159345 xla_accounting_err_pkg.build_message
159346 (p_appli_s_name => 'XLA'
159347 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
159348 ,p_token_1 => 'LINE_NUMBER'
159349 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
159350 ,p_token_2 => 'LINE_TYPE_NAME'
159351 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
159352 l_component_type
159353 ,l_component_code
159354 ,l_component_type_code
159355 ,l_component_appl_id
159356 ,l_amb_context_code
159357 ,l_entity_code
159358 ,l_event_class_code
159359 )
159360 ,p_token_3 => 'OWNER'
159361 ,p_value_3 => xla_lookups_pkg.get_meaning(
159362 p_lookup_type => 'XLA_OWNER_TYPE'
159363 ,p_lookup_code => l_component_type_code
159364 )
159365 ,p_token_4 => 'PRODUCT_NAME'
159366 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
159367 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
159368 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
159369 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
159370 ,p_ae_header_id => NULL
159371 );
159372
159373 IF (C_LEVEL_ERROR>= g_log_level) THEN
159374 trace
159375 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
159376 ,p_level => C_LEVEL_ERROR
159377 ,p_module => l_log_module);
159378 END IF;
159379 END IF;
159380 END IF;
159381 --
159382 --
159383 ------------------------------------------------------------------------------------------------
159384 -- 4219869 Business Flow
159385 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
159386 -- Prior Entry. Currently, the following code is always generated.
159387 ------------------------------------------------------------------------------------------------
159388 XLA_AE_LINES_PKG.ValidateCurrentLine;
159389
159390 ------------------------------------------------------------------------------------
159391 -- 4219869 Business Flow
159392 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
159393 ------------------------------------------------------------------------------------
159394 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
159395
159396 ----------------------------------------------------------------------------------
159397 -- 4219869 Business Flow
159398 -- Update journal entry status -- Need to generate this within IF <condition>
159399 ----------------------------------------------------------------------------------
159400 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
159401 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
159402 ,p_balance_type_code => l_balance_type_code
159403 );
159404
159405 -------------------------------------------------------------------------------------------
159406 -- 4262811 - Generate the Accrual Reversal lines
159407 -------------------------------------------------------------------------------------------
159408 BEGIN
159409 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
159410 (g_array_event(p_event_id).array_value_num('header_index'));
159411 IF l_acc_rev_flag IS NULL THEN
159412 l_acc_rev_flag := 'N';
159413 END IF;
159414 EXCEPTION
159415 WHEN OTHERS THEN
159416 l_acc_rev_flag := 'N';
159417 END;
159418 --
159419 IF (l_acc_rev_flag = 'Y') THEN
159420
159421 -- 4645092 ------------------------------------------------------------------------------
159422 -- To allow MPA report to determine if it should generate report process
159423 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
159424 ------------------------------------------------------------------------------------------
159425
159426 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
159427 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
159428 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
159429 -- call ADRs
159430 -- Bug 4922099
159431 --
159432 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
159433 (NVL(l_actual_upg_option, 'N') = 'O') OR
159434 (NVL(l_enc_upg_option, 'N') = 'O')
159435 )
159436 THEN
159437 NULL;
159438 --
159439 --
159440
159441 l_ccid := AcctDerRule_6(
159442 p_application_id => p_application_id
159443 , p_ae_header_id => l_ae_header_id
159444 , p_source_11 => p_source_11
159445 , x_transaction_coa_id => l_adr_transaction_coa_id
159446 , x_accounting_coa_id => l_adr_accounting_coa_id
159447 , x_value_type_code => l_adr_value_type_code
159448 , p_side => 'NA'
159449 );
159450
159451 xla_ae_lines_pkg.set_ccid(
159452 p_code_combination_id => l_ccid
159453 , p_value_type_code => l_adr_value_type_code
159454 , p_transaction_coa_id => l_adr_transaction_coa_id
159455 , p_accounting_coa_id => l_adr_accounting_coa_id
159456 , p_adr_code => 'CST_DEFAULT'
159457 , p_adr_type_code => 'S'
159458 , p_component_type => l_component_type
159459 , p_component_code => l_component_code
159460 , p_component_type_code => l_component_type_code
159461 , p_component_appl_id => l_component_appl_id
159462 , p_amb_context_code => l_amb_context_code
159463 , p_side => 'NA'
159464 );
159465
159466
159467 --
159468 --
159469 END IF;
159470
159471 --
159472 -- Update the line information that should be overwritten
159473 --
159474 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
159475 p_header_num => 1);
159476 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
159477
159478 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
159479
159480 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
159481 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
159482 END IF;
159483
159484 --
159485 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
159486 --
159487 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
159488 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
159489 ELSE
159490 ---------------------------------------------------------------------------------------------------
159491 -- 4262811a Switch Sign
159492 ---------------------------------------------------------------------------------------------------
159493 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
159494 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
159495 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
159496 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
159497 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
159498 -- 5132302
159499 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
159500 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
159501
159502 END IF;
159503
159504 -- 4955764
159505 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
159506 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
159507
159508
159509 XLA_AE_LINES_PKG.ValidateCurrentLine;
159510 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
159511
159512 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
159513 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
159514 ,p_balance_type_code => l_balance_type_code);
159515
159516 END IF;
159517
159518 -----------------------------------------------------------------------------------------
159519 -- 4262811 Multiperiod Accounting
159520 -----------------------------------------------------------------------------------------
159521 -- No MPA option is assigned.
159522
159523
159524 END IF;
159525 END IF;
159526 --
159527
159528 --
159529 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
159530 trace
159531 (p_msg => 'END of AcctLineType_296'
159532 ,p_level => C_LEVEL_PROCEDURE
159533 ,p_module => l_log_module);
159534 END IF;
159535 --
159536 EXCEPTION
159537 WHEN xla_exceptions_pkg.application_exception THEN
159538 RAISE;
159539 WHEN OTHERS THEN
159540 xla_exceptions_pkg.raise_message
159541 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_296');
159542 END AcctLineType_296;
159543 --
159544
159545 ---------------------------------------
159546 --
159547 -- PRIVATE FUNCTION
159548 -- AcctLineType_297
159549 --
159550 ---------------------------------------
159551 PROCEDURE AcctLineType_297 (
159552 p_application_id IN NUMBER
159553 ,p_event_id IN NUMBER
159554 ,p_calculate_acctd_flag IN VARCHAR2
159555 ,p_calculate_g_l_flag IN VARCHAR2
159556 ,p_actual_flag IN OUT VARCHAR2
159557 ,p_balance_type_code OUT VARCHAR2
159558 ,p_gain_or_loss_ref OUT VARCHAR2
159559
159560 --TRANSACTION_ID
159561 , p_source_1 IN NUMBER
159562 --Item Concatenated Segments
159563 , p_source_2 IN VARCHAR2
159564 --Transaction Quantity
159565 , p_source_3 IN NUMBER
159566 --Transaction Unit of Measure Code
159567 , p_source_4 IN VARCHAR2
159568 --Inventory Transaction Type Description
159569 , p_source_5 IN VARCHAR2
159570 --Cost Management Default Account
159571 , p_source_11 IN NUMBER
159572 --DISTRIBUTION_IDENTIFIER
159573 , p_source_84 IN NUMBER
159574 --Distribution Type
159575 , p_source_85 IN VARCHAR2
159576 , p_source_85_meaning IN VARCHAR2
159577 --Entered Currency Code
159578 , p_source_88 IN VARCHAR2
159579 --Entered Amount
159580 , p_source_91 IN NUMBER
159581 --Currency Conversion Date
159582 , p_source_92 IN DATE
159583 --Currency Conversion Rate
159584 , p_source_93 IN NUMBER
159585 --Currency Conversion Type
159586 , p_source_94 IN VARCHAR2
159587 --Accounted Amount
159588 , p_source_95 IN NUMBER
159589 --Accounting Line Type
159590 , p_source_97 IN NUMBER
159591 )
159592 IS
159593
159594 l_component_type VARCHAR2(80);
159595 l_component_code VARCHAR2(30);
159596 l_component_type_code VARCHAR2(1);
159597 l_component_appl_id INTEGER;
159598 l_amb_context_code VARCHAR2(30);
159599 l_entity_code VARCHAR2(30);
159600 l_event_class_code VARCHAR2(30);
159601 l_ae_header_id NUMBER;
159602 l_event_type_code VARCHAR2(30);
159603 l_line_definition_code VARCHAR2(30);
159604 l_line_definition_owner_code VARCHAR2(1);
159605 --
159606 -- adr variables
159607 l_segment VARCHAR2(30);
159608 l_ccid NUMBER;
159609 l_adr_transaction_coa_id NUMBER;
159610 l_adr_accounting_coa_id NUMBER;
159611 l_adr_flexfield_segment_code VARCHAR2(30);
159612 l_adr_flex_value_set_id NUMBER;
159613 l_adr_value_type_code VARCHAR2(30);
159614 l_adr_value_combination_id NUMBER;
159615 l_adr_value_segment_code VARCHAR2(30);
159616
159617 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
159618 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
159619 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
159620 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
159621
159622 -- 4262811 Variables ------------------------------------------------------------------------------------------
159623 l_entered_amt_idx NUMBER;
159624 l_accted_amt_idx NUMBER;
159625 l_acc_rev_flag VARCHAR2(1);
159626 l_accrual_line_num NUMBER;
159627 l_tmp_amt NUMBER;
159628 l_acc_rev_natural_side_code VARCHAR2(1);
159629
159630 l_num_entries NUMBER;
159631 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
159632 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
159633 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
159634 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
159635 l_recog_line_1 NUMBER;
159636 l_recog_line_2 NUMBER;
159637
159638 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
159639 l_bflow_applied_to_amt NUMBER; -- 5132302
159640 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
159641
159642 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
159643
159644 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
159645 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
159646
159647 ---------------------------------------------------------------------------------------------------------------
159648
159649
159650 --
159651 -- bulk performance
159652 --
159653 l_balance_type_code VARCHAR2(1);
159654 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
159655 l_log_module VARCHAR2(240);
159656
159657 --
159658 -- Upgrade strategy
159659 --
159660 l_actual_upg_option VARCHAR2(1);
159661 l_enc_upg_option VARCHAR2(1);
159662
159663 --
159664 BEGIN
159665 --
159666 IF g_log_enabled THEN
159667 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_297';
159668 END IF;
159669 --
159670 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
159671
159672 trace
159673 (p_msg => 'BEGIN of AcctLineType_297'
159674 ,p_level => C_LEVEL_PROCEDURE
159675 ,p_module => l_log_module);
159676
159677 END IF;
159678 --
159679 l_component_type := 'AMB_JLT';
159680 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
159681 l_component_type_code := 'S';
159682 l_component_appl_id := 707;
159683 l_amb_context_code := 'DEFAULT';
159684 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
159685 l_event_class_code := 'USER_DEFINE';
159686 l_event_type_code := 'UDIR_INTERORG_SHIP';
159687 l_line_definition_owner_code := 'S';
159688 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
159689 --
159690 l_balance_type_code := 'A';
159691 l_segment := NULL;
159692 l_ccid := NULL;
159693 l_adr_transaction_coa_id := NULL;
159694 l_adr_accounting_coa_id := NULL;
159695 l_adr_flexfield_segment_code := NULL;
159696 l_adr_flex_value_set_id := NULL;
159697 l_adr_value_type_code := NULL;
159698 l_adr_value_combination_id := NULL;
159699 l_adr_value_segment_code := NULL;
159700
159701 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
159702 l_bflow_class_code := ''; -- 4219869 Business Flow
159703 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
159704 l_budgetary_control_flag := 'N';
159705
159706 l_bflow_applied_to_amt_idx := NULL; -- 5132302
159707 l_bflow_applied_to_amt := NULL; -- 5132302
159708 l_entered_amt_idx := NULL; -- 4262811
159709 l_accted_amt_idx := NULL; -- 4262811
159710 l_acc_rev_flag := NULL; -- 4262811
159711 l_accrual_line_num := NULL; -- 4262811
159712 l_tmp_amt := NULL; -- 4262811
159713 --
159714
159715 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
159716 l_balance_type_code <> 'B' THEN
159717 IF NVL(p_source_97,9E125) = 3
159718 THEN
159719
159720 --
159721 XLA_AE_LINES_PKG.SetNewLine;
159722
159723 p_balance_type_code := l_balance_type_code;
159724 -- set the flag so later we will know whether the gain loss line needs to be created
159725
159726 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
159727 p_actual_flag :='A';
159728 END IF;
159729
159730 --
159731 -- bulk performance
159732 --
159733 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
159734 p_header_num => 0); -- 4262811
159735 --
159736 -- set accounting line options
159737 --
159738 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
159739 p_natural_side_code => 'D'
159740 , p_gain_or_loss_flag => 'N'
159741 , p_gl_transfer_mode_code => 'S'
159742 , p_acct_entry_type_code => 'A'
159743 , p_switch_side_flag => 'Y'
159744 , p_merge_duplicate_code => 'N'
159745 );
159746 --
159747 l_acc_rev_natural_side_code := 'C'; -- 4262811
159748 --
159749 --
159750 -- set accounting line type info
159751 --
159752 xla_ae_lines_pkg.SetAcctLineType
159753 (p_component_type => l_component_type
159754 ,p_event_type_code => l_event_type_code
159755 ,p_line_definition_owner_code => l_line_definition_owner_code
159756 ,p_line_definition_code => l_line_definition_code
159757 ,p_accounting_line_code => l_component_code
159758 ,p_accounting_line_type_code => l_component_type_code
159759 ,p_accounting_line_appl_id => l_component_appl_id
159760 ,p_amb_context_code => l_amb_context_code
159761 ,p_entity_code => l_entity_code
159762 ,p_event_class_code => l_event_class_code);
159763 --
159764 -- set accounting class
159765 --
159766 xla_ae_lines_pkg.SetAcctClass(
159767 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
159768 , p_ae_header_id => l_ae_header_id
159769 );
159770
159771 --
159772 -- set rounding class
159773 --
159774 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
159775 'MATERIAL_OVERHEAD_ABSORPTION';
159776
159777 --
159778 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
159779 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
159780 --
159781 -- bulk performance
159782 --
159783 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
159784
159785 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
159786 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
159787
159788 -- 4955764
159789 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
159790 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
159791
159792 -- 4458381 Public Sector Enh
159793
159794 --
159795 -- set accounting attributes for the line type
159796 --
159797 l_entered_amt_idx := 3;
159798 l_accted_amt_idx := 8;
159799 l_bflow_applied_to_amt_idx := NULL; -- 5132302
159800 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
159801 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
159802 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
159803 l_rec_acct_attrs.array_char_value(2) := p_source_85;
159804 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
159805 l_rec_acct_attrs.array_num_value(3) := p_source_91;
159806 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
159807 l_rec_acct_attrs.array_char_value(4) := p_source_88;
159808 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
159809 l_rec_acct_attrs.array_date_value(5) := p_source_92;
159810 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
159811 l_rec_acct_attrs.array_num_value(6) := p_source_93;
159812 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
159813 l_rec_acct_attrs.array_char_value(7) := p_source_94;
159814 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
159815 l_rec_acct_attrs.array_num_value(8) := p_source_95;
159816
159817 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
159818 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
159819
159820 ---------------------------------------------------------------------------------------------------------------
159821 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
159822 ---------------------------------------------------------------------------------------------------------------
159823 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
159824
159825 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
159826 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
159827
159828 IF xla_accounting_cache_pkg.GetValueChar
159829 (p_source_code => 'LEDGER_CATEGORY_CODE'
159830 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
159831 AND l_bflow_method_code = 'PRIOR_ENTRY'
159832 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
159833 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
159834 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
159835 )
159836 THEN
159837 xla_ae_lines_pkg.BflowUpgEntry
159838 (p_business_method_code => l_bflow_method_code
159839 ,p_business_class_code => l_bflow_class_code
159840 ,p_balance_type => l_balance_type_code);
159841 ELSE
159842 NULL;
159843 -- No business flow processing for business flow method of NONE.
159844 END IF;
159845
159846 --
159847 -- call analytical criteria
159848 --
159849
159850 --
159851 -- call description
159852 --
159853
159854 xla_ae_lines_pkg.SetLineDescription(
159855 p_ae_header_id => l_ae_header_id
159856 ,p_description => Description_1 (
159857 p_application_id => p_application_id
159858 , p_ae_header_id => l_ae_header_id
159859 , p_source_1 => p_source_1
159860 , p_source_2 => p_source_2
159861 , p_source_3 => p_source_3
159862 , p_source_4 => p_source_4
159863 , p_source_5 => p_source_5
159864 )
159865 );
159866
159867
159868 --
159869 -- call ADRs
159870 -- Bug 4922099
159871 --
159872 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
159873 (NVL(l_actual_upg_option, 'N') = 'O') OR
159874 (NVL(l_enc_upg_option, 'N') = 'O')
159875 )
159876 THEN
159877 NULL;
159878 --
159879 --
159880
159881 l_ccid := AcctDerRule_6(
159882 p_application_id => p_application_id
159883 , p_ae_header_id => l_ae_header_id
159884 , p_source_11 => p_source_11
159885 , x_transaction_coa_id => l_adr_transaction_coa_id
159886 , x_accounting_coa_id => l_adr_accounting_coa_id
159887 , x_value_type_code => l_adr_value_type_code
159888 , p_side => 'NA'
159889 );
159890
159891 xla_ae_lines_pkg.set_ccid(
159892 p_code_combination_id => l_ccid
159893 , p_value_type_code => l_adr_value_type_code
159894 , p_transaction_coa_id => l_adr_transaction_coa_id
159895 , p_accounting_coa_id => l_adr_accounting_coa_id
159896 , p_adr_code => 'CST_DEFAULT'
159897 , p_adr_type_code => 'S'
159898 , p_component_type => l_component_type
159899 , p_component_code => l_component_code
159900 , p_component_type_code => l_component_type_code
159901 , p_component_appl_id => l_component_appl_id
159902 , p_amb_context_code => l_amb_context_code
159903 , p_side => 'NA'
159904 );
159905
159906
159907 --
159908 --
159909 END IF;
159910 --
159911 -- Bug 4922099
159912 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
159913 (NVL(l_enc_upg_option, 'N') = 'O')
159914 ) AND
159915 (l_bflow_method_code = 'PRIOR_ENTRY')
159916 )
159917 THEN
159918 IF
159919 --
159920 1 = 2
159921 --
159922 THEN
159923 xla_accounting_err_pkg.build_message
159924 (p_appli_s_name => 'XLA'
159925 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
159926 ,p_token_1 => 'LINE_NUMBER'
159927 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
159928 ,p_token_2 => 'LINE_TYPE_NAME'
159929 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
159930 l_component_type
159931 ,l_component_code
159932 ,l_component_type_code
159933 ,l_component_appl_id
159934 ,l_amb_context_code
159935 ,l_entity_code
159936 ,l_event_class_code
159937 )
159938 ,p_token_3 => 'OWNER'
159939 ,p_value_3 => xla_lookups_pkg.get_meaning(
159940 p_lookup_type => 'XLA_OWNER_TYPE'
159941 ,p_lookup_code => l_component_type_code
159942 )
159943 ,p_token_4 => 'PRODUCT_NAME'
159944 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
159945 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
159946 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
159947 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
159948 ,p_ae_header_id => NULL
159949 );
159950
159951 IF (C_LEVEL_ERROR>= g_log_level) THEN
159952 trace
159953 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
159954 ,p_level => C_LEVEL_ERROR
159955 ,p_module => l_log_module);
159956 END IF;
159957 END IF;
159958 END IF;
159959 --
159960 --
159961 ------------------------------------------------------------------------------------------------
159962 -- 4219869 Business Flow
159963 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
159964 -- Prior Entry. Currently, the following code is always generated.
159965 ------------------------------------------------------------------------------------------------
159966 XLA_AE_LINES_PKG.ValidateCurrentLine;
159967
159968 ------------------------------------------------------------------------------------
159969 -- 4219869 Business Flow
159970 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
159971 ------------------------------------------------------------------------------------
159972 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
159973
159974 ----------------------------------------------------------------------------------
159975 -- 4219869 Business Flow
159976 -- Update journal entry status -- Need to generate this within IF <condition>
159977 ----------------------------------------------------------------------------------
159978 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
159979 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
159980 ,p_balance_type_code => l_balance_type_code
159981 );
159982
159983 -------------------------------------------------------------------------------------------
159984 -- 4262811 - Generate the Accrual Reversal lines
159985 -------------------------------------------------------------------------------------------
159986 BEGIN
159987 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
159988 (g_array_event(p_event_id).array_value_num('header_index'));
159989 IF l_acc_rev_flag IS NULL THEN
159990 l_acc_rev_flag := 'N';
159991 END IF;
159992 EXCEPTION
159993 WHEN OTHERS THEN
159994 l_acc_rev_flag := 'N';
159995 END;
159996 --
159997 IF (l_acc_rev_flag = 'Y') THEN
159998
159999 -- 4645092 ------------------------------------------------------------------------------
160000 -- To allow MPA report to determine if it should generate report process
160001 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
160002 ------------------------------------------------------------------------------------------
160003
160004 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
160005 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
160006 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
160007 -- call ADRs
160008 -- Bug 4922099
160009 --
160010 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
160011 (NVL(l_actual_upg_option, 'N') = 'O') OR
160012 (NVL(l_enc_upg_option, 'N') = 'O')
160013 )
160014 THEN
160015 NULL;
160016 --
160017 --
160018
160019 l_ccid := AcctDerRule_6(
160020 p_application_id => p_application_id
160021 , p_ae_header_id => l_ae_header_id
160022 , p_source_11 => p_source_11
160023 , x_transaction_coa_id => l_adr_transaction_coa_id
160024 , x_accounting_coa_id => l_adr_accounting_coa_id
160025 , x_value_type_code => l_adr_value_type_code
160026 , p_side => 'NA'
160027 );
160028
160029 xla_ae_lines_pkg.set_ccid(
160030 p_code_combination_id => l_ccid
160031 , p_value_type_code => l_adr_value_type_code
160032 , p_transaction_coa_id => l_adr_transaction_coa_id
160033 , p_accounting_coa_id => l_adr_accounting_coa_id
160034 , p_adr_code => 'CST_DEFAULT'
160035 , p_adr_type_code => 'S'
160036 , p_component_type => l_component_type
160037 , p_component_code => l_component_code
160038 , p_component_type_code => l_component_type_code
160039 , p_component_appl_id => l_component_appl_id
160040 , p_amb_context_code => l_amb_context_code
160041 , p_side => 'NA'
160042 );
160043
160044
160045 --
160046 --
160047 END IF;
160048
160049 --
160050 -- Update the line information that should be overwritten
160051 --
160052 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
160053 p_header_num => 1);
160054 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
160055
160056 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
160057
160058 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
160059 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
160060 END IF;
160061
160062 --
160063 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
160064 --
160065 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
160066 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
160067 ELSE
160068 ---------------------------------------------------------------------------------------------------
160069 -- 4262811a Switch Sign
160070 ---------------------------------------------------------------------------------------------------
160071 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
160072 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
160073 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160074 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
160075 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160076 -- 5132302
160077 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
160078 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160079
160080 END IF;
160081
160082 -- 4955764
160083 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
160084 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
160085
160086
160087 XLA_AE_LINES_PKG.ValidateCurrentLine;
160088 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
160089
160090 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
160091 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
160092 ,p_balance_type_code => l_balance_type_code);
160093
160094 END IF;
160095
160096 -----------------------------------------------------------------------------------------
160097 -- 4262811 Multiperiod Accounting
160098 -----------------------------------------------------------------------------------------
160099 -- No MPA option is assigned.
160100
160101
160102 END IF;
160103 END IF;
160104 --
160105
160106 --
160107 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
160108 trace
160109 (p_msg => 'END of AcctLineType_297'
160110 ,p_level => C_LEVEL_PROCEDURE
160111 ,p_module => l_log_module);
160112 END IF;
160113 --
160114 EXCEPTION
160115 WHEN xla_exceptions_pkg.application_exception THEN
160116 RAISE;
160117 WHEN OTHERS THEN
160118 xla_exceptions_pkg.raise_message
160119 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_297');
160120 END AcctLineType_297;
160121 --
160122
160123 ---------------------------------------
160124 --
160125 -- PRIVATE FUNCTION
160126 -- AcctLineType_298
160127 --
160128 ---------------------------------------
160129 PROCEDURE AcctLineType_298 (
160130 p_application_id IN NUMBER
160131 ,p_event_id IN NUMBER
160132 ,p_calculate_acctd_flag IN VARCHAR2
160133 ,p_calculate_g_l_flag IN VARCHAR2
160134 ,p_actual_flag IN OUT VARCHAR2
160135 ,p_balance_type_code OUT VARCHAR2
160136 ,p_gain_or_loss_ref OUT VARCHAR2
160137
160138 --TRANSACTION_ID
160139 , p_source_1 IN NUMBER
160140 --Item Concatenated Segments
160141 , p_source_2 IN VARCHAR2
160142 --Transaction Quantity
160143 , p_source_3 IN NUMBER
160144 --Transaction Unit of Measure Code
160145 , p_source_4 IN VARCHAR2
160146 --Inventory Transaction Type Description
160147 , p_source_5 IN VARCHAR2
160148 --Cost Management Default Account
160149 , p_source_11 IN NUMBER
160150 --DISTRIBUTION_IDENTIFIER
160151 , p_source_84 IN NUMBER
160152 --Distribution Type
160153 , p_source_85 IN VARCHAR2
160154 , p_source_85_meaning IN VARCHAR2
160155 --Entered Currency Code
160156 , p_source_88 IN VARCHAR2
160157 --Entered Amount
160158 , p_source_91 IN NUMBER
160159 --Currency Conversion Date
160160 , p_source_92 IN DATE
160161 --Currency Conversion Rate
160162 , p_source_93 IN NUMBER
160163 --Currency Conversion Type
160164 , p_source_94 IN VARCHAR2
160165 --Accounted Amount
160166 , p_source_95 IN NUMBER
160167 --Accounting Line Type
160168 , p_source_97 IN NUMBER
160169 )
160170 IS
160171
160172 l_component_type VARCHAR2(80);
160173 l_component_code VARCHAR2(30);
160174 l_component_type_code VARCHAR2(1);
160175 l_component_appl_id INTEGER;
160176 l_amb_context_code VARCHAR2(30);
160177 l_entity_code VARCHAR2(30);
160178 l_event_class_code VARCHAR2(30);
160179 l_ae_header_id NUMBER;
160180 l_event_type_code VARCHAR2(30);
160181 l_line_definition_code VARCHAR2(30);
160182 l_line_definition_owner_code VARCHAR2(1);
160183 --
160184 -- adr variables
160185 l_segment VARCHAR2(30);
160186 l_ccid NUMBER;
160187 l_adr_transaction_coa_id NUMBER;
160188 l_adr_accounting_coa_id NUMBER;
160189 l_adr_flexfield_segment_code VARCHAR2(30);
160190 l_adr_flex_value_set_id NUMBER;
160191 l_adr_value_type_code VARCHAR2(30);
160192 l_adr_value_combination_id NUMBER;
160193 l_adr_value_segment_code VARCHAR2(30);
160194
160195 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
160196 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
160197 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
160198 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
160199
160200 -- 4262811 Variables ------------------------------------------------------------------------------------------
160201 l_entered_amt_idx NUMBER;
160202 l_accted_amt_idx NUMBER;
160203 l_acc_rev_flag VARCHAR2(1);
160204 l_accrual_line_num NUMBER;
160205 l_tmp_amt NUMBER;
160206 l_acc_rev_natural_side_code VARCHAR2(1);
160207
160208 l_num_entries NUMBER;
160209 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
160210 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
160211 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
160212 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
160213 l_recog_line_1 NUMBER;
160214 l_recog_line_2 NUMBER;
160215
160216 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
160217 l_bflow_applied_to_amt NUMBER; -- 5132302
160218 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
160219
160220 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
160221
160222 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
160223 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
160224
160225 ---------------------------------------------------------------------------------------------------------------
160226
160227
160228 --
160229 -- bulk performance
160230 --
160231 l_balance_type_code VARCHAR2(1);
160232 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
160233 l_log_module VARCHAR2(240);
160234
160235 --
160236 -- Upgrade strategy
160237 --
160238 l_actual_upg_option VARCHAR2(1);
160239 l_enc_upg_option VARCHAR2(1);
160240
160241 --
160242 BEGIN
160243 --
160244 IF g_log_enabled THEN
160245 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_298';
160246 END IF;
160247 --
160248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
160249
160250 trace
160251 (p_msg => 'BEGIN of AcctLineType_298'
160252 ,p_level => C_LEVEL_PROCEDURE
160253 ,p_module => l_log_module);
160254
160255 END IF;
160256 --
160257 l_component_type := 'AMB_JLT';
160258 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
160259 l_component_type_code := 'S';
160260 l_component_appl_id := 707;
160261 l_amb_context_code := 'DEFAULT';
160262 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
160263 l_event_class_code := 'USER_DEFINE';
160264 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
160265 l_line_definition_owner_code := 'S';
160266 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
160267 --
160268 l_balance_type_code := 'A';
160269 l_segment := NULL;
160270 l_ccid := NULL;
160271 l_adr_transaction_coa_id := NULL;
160272 l_adr_accounting_coa_id := NULL;
160273 l_adr_flexfield_segment_code := NULL;
160274 l_adr_flex_value_set_id := NULL;
160275 l_adr_value_type_code := NULL;
160276 l_adr_value_combination_id := NULL;
160277 l_adr_value_segment_code := NULL;
160278
160279 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
160280 l_bflow_class_code := ''; -- 4219869 Business Flow
160281 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
160282 l_budgetary_control_flag := 'N';
160283
160284 l_bflow_applied_to_amt_idx := NULL; -- 5132302
160285 l_bflow_applied_to_amt := NULL; -- 5132302
160286 l_entered_amt_idx := NULL; -- 4262811
160287 l_accted_amt_idx := NULL; -- 4262811
160288 l_acc_rev_flag := NULL; -- 4262811
160289 l_accrual_line_num := NULL; -- 4262811
160290 l_tmp_amt := NULL; -- 4262811
160291 --
160292
160293 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
160294 l_balance_type_code <> 'B' THEN
160295 IF NVL(p_source_97,9E125) = 3
160296 THEN
160297
160298 --
160299 XLA_AE_LINES_PKG.SetNewLine;
160300
160301 p_balance_type_code := l_balance_type_code;
160302 -- set the flag so later we will know whether the gain loss line needs to be created
160303
160304 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
160305 p_actual_flag :='A';
160306 END IF;
160307
160308 --
160309 -- bulk performance
160310 --
160311 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
160312 p_header_num => 0); -- 4262811
160313 --
160314 -- set accounting line options
160315 --
160316 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
160317 p_natural_side_code => 'D'
160318 , p_gain_or_loss_flag => 'N'
160319 , p_gl_transfer_mode_code => 'S'
160320 , p_acct_entry_type_code => 'A'
160321 , p_switch_side_flag => 'Y'
160322 , p_merge_duplicate_code => 'N'
160323 );
160324 --
160325 l_acc_rev_natural_side_code := 'C'; -- 4262811
160326 --
160327 --
160328 -- set accounting line type info
160329 --
160330 xla_ae_lines_pkg.SetAcctLineType
160331 (p_component_type => l_component_type
160332 ,p_event_type_code => l_event_type_code
160333 ,p_line_definition_owner_code => l_line_definition_owner_code
160334 ,p_line_definition_code => l_line_definition_code
160335 ,p_accounting_line_code => l_component_code
160336 ,p_accounting_line_type_code => l_component_type_code
160337 ,p_accounting_line_appl_id => l_component_appl_id
160338 ,p_amb_context_code => l_amb_context_code
160339 ,p_entity_code => l_entity_code
160340 ,p_event_class_code => l_event_class_code);
160341 --
160342 -- set accounting class
160343 --
160344 xla_ae_lines_pkg.SetAcctClass(
160345 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
160346 , p_ae_header_id => l_ae_header_id
160347 );
160348
160349 --
160350 -- set rounding class
160351 --
160352 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
160353 'MATERIAL_OVERHEAD_ABSORPTION';
160354
160355 --
160356 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
160357 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
160358 --
160359 -- bulk performance
160360 --
160361 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
160362
160363 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
160364 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
160365
160366 -- 4955764
160367 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
160368 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
160369
160370 -- 4458381 Public Sector Enh
160371
160372 --
160373 -- set accounting attributes for the line type
160374 --
160375 l_entered_amt_idx := 3;
160376 l_accted_amt_idx := 8;
160377 l_bflow_applied_to_amt_idx := NULL; -- 5132302
160378 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
160379 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
160380 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
160381 l_rec_acct_attrs.array_char_value(2) := p_source_85;
160382 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
160383 l_rec_acct_attrs.array_num_value(3) := p_source_91;
160384 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
160385 l_rec_acct_attrs.array_char_value(4) := p_source_88;
160386 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
160387 l_rec_acct_attrs.array_date_value(5) := p_source_92;
160388 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
160389 l_rec_acct_attrs.array_num_value(6) := p_source_93;
160390 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
160391 l_rec_acct_attrs.array_char_value(7) := p_source_94;
160392 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
160393 l_rec_acct_attrs.array_num_value(8) := p_source_95;
160394
160395 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
160396 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
160397
160398 ---------------------------------------------------------------------------------------------------------------
160399 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
160400 ---------------------------------------------------------------------------------------------------------------
160401 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
160402
160403 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
160404 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
160405
160406 IF xla_accounting_cache_pkg.GetValueChar
160407 (p_source_code => 'LEDGER_CATEGORY_CODE'
160408 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
160409 AND l_bflow_method_code = 'PRIOR_ENTRY'
160410 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
160411 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
160412 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
160413 )
160414 THEN
160415 xla_ae_lines_pkg.BflowUpgEntry
160416 (p_business_method_code => l_bflow_method_code
160417 ,p_business_class_code => l_bflow_class_code
160418 ,p_balance_type => l_balance_type_code);
160419 ELSE
160420 NULL;
160421 -- No business flow processing for business flow method of NONE.
160422 END IF;
160423
160424 --
160425 -- call analytical criteria
160426 --
160427
160428 --
160429 -- call description
160430 --
160431
160432 xla_ae_lines_pkg.SetLineDescription(
160433 p_ae_header_id => l_ae_header_id
160434 ,p_description => Description_1 (
160435 p_application_id => p_application_id
160436 , p_ae_header_id => l_ae_header_id
160437 , p_source_1 => p_source_1
160438 , p_source_2 => p_source_2
160439 , p_source_3 => p_source_3
160440 , p_source_4 => p_source_4
160441 , p_source_5 => p_source_5
160442 )
160443 );
160444
160445
160446 --
160447 -- call ADRs
160448 -- Bug 4922099
160449 --
160450 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
160451 (NVL(l_actual_upg_option, 'N') = 'O') OR
160452 (NVL(l_enc_upg_option, 'N') = 'O')
160453 )
160454 THEN
160455 NULL;
160456 --
160457 --
160458
160459 l_ccid := AcctDerRule_6(
160460 p_application_id => p_application_id
160461 , p_ae_header_id => l_ae_header_id
160462 , p_source_11 => p_source_11
160463 , x_transaction_coa_id => l_adr_transaction_coa_id
160464 , x_accounting_coa_id => l_adr_accounting_coa_id
160465 , x_value_type_code => l_adr_value_type_code
160466 , p_side => 'NA'
160467 );
160468
160469 xla_ae_lines_pkg.set_ccid(
160470 p_code_combination_id => l_ccid
160471 , p_value_type_code => l_adr_value_type_code
160472 , p_transaction_coa_id => l_adr_transaction_coa_id
160473 , p_accounting_coa_id => l_adr_accounting_coa_id
160474 , p_adr_code => 'CST_DEFAULT'
160475 , p_adr_type_code => 'S'
160476 , p_component_type => l_component_type
160477 , p_component_code => l_component_code
160478 , p_component_type_code => l_component_type_code
160479 , p_component_appl_id => l_component_appl_id
160480 , p_amb_context_code => l_amb_context_code
160481 , p_side => 'NA'
160482 );
160483
160484
160485 --
160486 --
160487 END IF;
160488 --
160489 -- Bug 4922099
160490 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
160491 (NVL(l_enc_upg_option, 'N') = 'O')
160492 ) AND
160493 (l_bflow_method_code = 'PRIOR_ENTRY')
160494 )
160495 THEN
160496 IF
160497 --
160498 1 = 2
160499 --
160500 THEN
160501 xla_accounting_err_pkg.build_message
160502 (p_appli_s_name => 'XLA'
160503 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
160504 ,p_token_1 => 'LINE_NUMBER'
160505 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
160506 ,p_token_2 => 'LINE_TYPE_NAME'
160507 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
160508 l_component_type
160509 ,l_component_code
160510 ,l_component_type_code
160511 ,l_component_appl_id
160512 ,l_amb_context_code
160513 ,l_entity_code
160514 ,l_event_class_code
160515 )
160516 ,p_token_3 => 'OWNER'
160517 ,p_value_3 => xla_lookups_pkg.get_meaning(
160518 p_lookup_type => 'XLA_OWNER_TYPE'
160519 ,p_lookup_code => l_component_type_code
160520 )
160521 ,p_token_4 => 'PRODUCT_NAME'
160522 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
160523 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
160524 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
160525 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
160526 ,p_ae_header_id => NULL
160527 );
160528
160529 IF (C_LEVEL_ERROR>= g_log_level) THEN
160530 trace
160531 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
160532 ,p_level => C_LEVEL_ERROR
160533 ,p_module => l_log_module);
160534 END IF;
160535 END IF;
160536 END IF;
160537 --
160538 --
160539 ------------------------------------------------------------------------------------------------
160540 -- 4219869 Business Flow
160541 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
160542 -- Prior Entry. Currently, the following code is always generated.
160543 ------------------------------------------------------------------------------------------------
160544 XLA_AE_LINES_PKG.ValidateCurrentLine;
160545
160546 ------------------------------------------------------------------------------------
160547 -- 4219869 Business Flow
160548 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
160549 ------------------------------------------------------------------------------------
160550 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
160551
160552 ----------------------------------------------------------------------------------
160553 -- 4219869 Business Flow
160554 -- Update journal entry status -- Need to generate this within IF <condition>
160555 ----------------------------------------------------------------------------------
160556 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
160557 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
160558 ,p_balance_type_code => l_balance_type_code
160559 );
160560
160561 -------------------------------------------------------------------------------------------
160562 -- 4262811 - Generate the Accrual Reversal lines
160563 -------------------------------------------------------------------------------------------
160564 BEGIN
160565 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
160566 (g_array_event(p_event_id).array_value_num('header_index'));
160567 IF l_acc_rev_flag IS NULL THEN
160568 l_acc_rev_flag := 'N';
160569 END IF;
160570 EXCEPTION
160571 WHEN OTHERS THEN
160572 l_acc_rev_flag := 'N';
160573 END;
160574 --
160575 IF (l_acc_rev_flag = 'Y') THEN
160576
160577 -- 4645092 ------------------------------------------------------------------------------
160578 -- To allow MPA report to determine if it should generate report process
160579 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
160580 ------------------------------------------------------------------------------------------
160581
160582 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
160583 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
160584 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
160585 -- call ADRs
160586 -- Bug 4922099
160587 --
160588 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
160589 (NVL(l_actual_upg_option, 'N') = 'O') OR
160590 (NVL(l_enc_upg_option, 'N') = 'O')
160591 )
160592 THEN
160593 NULL;
160594 --
160595 --
160596
160597 l_ccid := AcctDerRule_6(
160598 p_application_id => p_application_id
160599 , p_ae_header_id => l_ae_header_id
160600 , p_source_11 => p_source_11
160601 , x_transaction_coa_id => l_adr_transaction_coa_id
160602 , x_accounting_coa_id => l_adr_accounting_coa_id
160603 , x_value_type_code => l_adr_value_type_code
160604 , p_side => 'NA'
160605 );
160606
160607 xla_ae_lines_pkg.set_ccid(
160608 p_code_combination_id => l_ccid
160609 , p_value_type_code => l_adr_value_type_code
160610 , p_transaction_coa_id => l_adr_transaction_coa_id
160611 , p_accounting_coa_id => l_adr_accounting_coa_id
160612 , p_adr_code => 'CST_DEFAULT'
160613 , p_adr_type_code => 'S'
160614 , p_component_type => l_component_type
160615 , p_component_code => l_component_code
160616 , p_component_type_code => l_component_type_code
160617 , p_component_appl_id => l_component_appl_id
160618 , p_amb_context_code => l_amb_context_code
160619 , p_side => 'NA'
160620 );
160621
160622
160623 --
160624 --
160625 END IF;
160626
160627 --
160628 -- Update the line information that should be overwritten
160629 --
160630 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
160631 p_header_num => 1);
160632 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
160633
160634 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
160635
160636 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
160637 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
160638 END IF;
160639
160640 --
160641 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
160642 --
160643 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
160644 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
160645 ELSE
160646 ---------------------------------------------------------------------------------------------------
160647 -- 4262811a Switch Sign
160648 ---------------------------------------------------------------------------------------------------
160649 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
160650 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
160651 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160652 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
160653 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160654 -- 5132302
160655 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
160656 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
160657
160658 END IF;
160659
160660 -- 4955764
160661 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
160662 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
160663
160664
160665 XLA_AE_LINES_PKG.ValidateCurrentLine;
160666 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
160667
160668 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
160669 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
160670 ,p_balance_type_code => l_balance_type_code);
160671
160672 END IF;
160673
160674 -----------------------------------------------------------------------------------------
160675 -- 4262811 Multiperiod Accounting
160676 -----------------------------------------------------------------------------------------
160677 -- No MPA option is assigned.
160678
160679
160680 END IF;
160681 END IF;
160682 --
160683
160684 --
160685 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
160686 trace
160687 (p_msg => 'END of AcctLineType_298'
160688 ,p_level => C_LEVEL_PROCEDURE
160689 ,p_module => l_log_module);
160690 END IF;
160691 --
160692 EXCEPTION
160693 WHEN xla_exceptions_pkg.application_exception THEN
160694 RAISE;
160695 WHEN OTHERS THEN
160696 xla_exceptions_pkg.raise_message
160697 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_298');
160698 END AcctLineType_298;
160699 --
160700
160701 ---------------------------------------
160702 --
160703 -- PRIVATE FUNCTION
160704 -- AcctLineType_299
160705 --
160706 ---------------------------------------
160707 PROCEDURE AcctLineType_299 (
160708 p_application_id IN NUMBER
160709 ,p_event_id IN NUMBER
160710 ,p_calculate_acctd_flag IN VARCHAR2
160711 ,p_calculate_g_l_flag IN VARCHAR2
160712 ,p_actual_flag IN OUT VARCHAR2
160713 ,p_balance_type_code OUT VARCHAR2
160714 ,p_gain_or_loss_ref OUT VARCHAR2
160715
160716 --TRANSACTION_ID
160717 , p_source_1 IN NUMBER
160718 --Item Concatenated Segments
160719 , p_source_2 IN VARCHAR2
160720 --Transaction Quantity
160721 , p_source_3 IN NUMBER
160722 --Transaction Unit of Measure Code
160723 , p_source_4 IN VARCHAR2
160724 --Inventory Transaction Type Description
160725 , p_source_5 IN VARCHAR2
160726 --Cost Management Default Account
160727 , p_source_11 IN NUMBER
160728 --Applied to Application ID
160729 , p_source_79 IN NUMBER
160730 --Applied to Distribution Link Type
160731 , p_source_80 IN VARCHAR2
160732 --Applied to Entity Code
160733 , p_source_81 IN VARCHAR2
160734 --DISTRIBUTION_IDENTIFIER
160735 , p_source_84 IN NUMBER
160736 --Distribution Type
160737 , p_source_85 IN VARCHAR2
160738 , p_source_85_meaning IN VARCHAR2
160739 --Encumbrance Reversal Amount Entered
160740 , p_source_87 IN NUMBER
160741 --Entered Currency Code
160742 , p_source_88 IN VARCHAR2
160743 --Transaction Encumbrance Reversal Amount
160744 , p_source_89 IN NUMBER
160745 --Entered Amount
160746 , p_source_91 IN NUMBER
160747 --Currency Conversion Date
160748 , p_source_92 IN DATE
160749 --Currency Conversion Rate
160750 , p_source_93 IN NUMBER
160751 --Currency Conversion Type
160752 , p_source_94 IN VARCHAR2
160753 --Accounted Amount
160754 , p_source_95 IN NUMBER
160755 --Accounting Line Type
160756 , p_source_97 IN NUMBER
160757 --Costing Encumbrance Upgrade Option
160758 , p_source_100 IN VARCHAR2
160759 --TXN_PO_DISTRIBUTION_ID
160760 , p_source_101 IN NUMBER
160761 --TXN_PO_HEADER_ID
160762 , p_source_102 IN NUMBER
160763 --Requisition Budget Account
160764 , p_source_103 IN NUMBER
160765 --Requisition Encumbrance Type Identifier
160766 , p_source_104 IN NUMBER
160767 )
160768 IS
160769
160770 l_component_type VARCHAR2(80);
160771 l_component_code VARCHAR2(30);
160772 l_component_type_code VARCHAR2(1);
160773 l_component_appl_id INTEGER;
160774 l_amb_context_code VARCHAR2(30);
160775 l_entity_code VARCHAR2(30);
160776 l_event_class_code VARCHAR2(30);
160777 l_ae_header_id NUMBER;
160778 l_event_type_code VARCHAR2(30);
160779 l_line_definition_code VARCHAR2(30);
160780 l_line_definition_owner_code VARCHAR2(1);
160781 --
160782 -- adr variables
160783 l_segment VARCHAR2(30);
160784 l_ccid NUMBER;
160785 l_adr_transaction_coa_id NUMBER;
160786 l_adr_accounting_coa_id NUMBER;
160787 l_adr_flexfield_segment_code VARCHAR2(30);
160788 l_adr_flex_value_set_id NUMBER;
160789 l_adr_value_type_code VARCHAR2(30);
160790 l_adr_value_combination_id NUMBER;
160791 l_adr_value_segment_code VARCHAR2(30);
160792
160793 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
160794 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
160795 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
160796 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
160797
160798 -- 4262811 Variables ------------------------------------------------------------------------------------------
160799 l_entered_amt_idx NUMBER;
160800 l_accted_amt_idx NUMBER;
160801 l_acc_rev_flag VARCHAR2(1);
160802 l_accrual_line_num NUMBER;
160803 l_tmp_amt NUMBER;
160804 l_acc_rev_natural_side_code VARCHAR2(1);
160805
160806 l_num_entries NUMBER;
160807 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
160808 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
160809 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
160810 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
160811 l_recog_line_1 NUMBER;
160812 l_recog_line_2 NUMBER;
160813
160814 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
160815 l_bflow_applied_to_amt NUMBER; -- 5132302
160816 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
160817
160818 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
160819
160820 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
160821 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
160822
160823 ---------------------------------------------------------------------------------------------------------------
160824
160825
160826 --
160827 -- bulk performance
160828 --
160829 l_balance_type_code VARCHAR2(1);
160830 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
160831 l_log_module VARCHAR2(240);
160832
160833 --
160834 -- Upgrade strategy
160835 --
160836 l_actual_upg_option VARCHAR2(1);
160837 l_enc_upg_option VARCHAR2(1);
160838
160839 --
160840 BEGIN
160841 --
160842 IF g_log_enabled THEN
160843 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_299';
160844 END IF;
160845 --
160846 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
160847
160848 trace
160849 (p_msg => 'BEGIN of AcctLineType_299'
160850 ,p_level => C_LEVEL_PROCEDURE
160851 ,p_module => l_log_module);
160852
160853 END IF;
160854 --
160855 l_component_type := 'AMB_JLT';
160856 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
160857 l_component_type_code := 'S';
160858 l_component_appl_id := 707;
160859 l_amb_context_code := 'DEFAULT';
160860 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
160861 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
160862 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
160863 l_line_definition_owner_code := 'S';
160864 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
160865 --
160866 l_balance_type_code := 'A';
160867 l_segment := NULL;
160868 l_ccid := NULL;
160869 l_adr_transaction_coa_id := NULL;
160870 l_adr_accounting_coa_id := NULL;
160871 l_adr_flexfield_segment_code := NULL;
160872 l_adr_flex_value_set_id := NULL;
160873 l_adr_value_type_code := NULL;
160874 l_adr_value_combination_id := NULL;
160875 l_adr_value_segment_code := NULL;
160876
160877 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
160878 l_bflow_class_code := ''; -- 4219869 Business Flow
160879 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
160880 l_budgetary_control_flag := 'N';
160881
160882 l_bflow_applied_to_amt_idx := NULL; -- 5132302
160883 l_bflow_applied_to_amt := NULL; -- 5132302
160884 l_entered_amt_idx := NULL; -- 4262811
160885 l_accted_amt_idx := NULL; -- 4262811
160886 l_acc_rev_flag := NULL; -- 4262811
160887 l_accrual_line_num := NULL; -- 4262811
160888 l_tmp_amt := NULL; -- 4262811
160889 --
160890
160891 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
160892 l_balance_type_code <> 'B' THEN
160893 IF NVL(p_source_97,9E125) = 3
160894 THEN
160895
160896 --
160897 XLA_AE_LINES_PKG.SetNewLine;
160898
160899 p_balance_type_code := l_balance_type_code;
160900 -- set the flag so later we will know whether the gain loss line needs to be created
160901
160902 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
160903 p_actual_flag :='A';
160904 END IF;
160905
160906 --
160907 -- bulk performance
160908 --
160909 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
160910 p_header_num => 0); -- 4262811
160911 --
160912 -- set accounting line options
160913 --
160914 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
160915 p_natural_side_code => 'D'
160916 , p_gain_or_loss_flag => 'N'
160917 , p_gl_transfer_mode_code => 'S'
160918 , p_acct_entry_type_code => 'A'
160919 , p_switch_side_flag => 'Y'
160920 , p_merge_duplicate_code => 'N'
160921 );
160922 --
160923 l_acc_rev_natural_side_code := 'C'; -- 4262811
160924 --
160925 --
160926 -- set accounting line type info
160927 --
160928 xla_ae_lines_pkg.SetAcctLineType
160929 (p_component_type => l_component_type
160930 ,p_event_type_code => l_event_type_code
160931 ,p_line_definition_owner_code => l_line_definition_owner_code
160932 ,p_line_definition_code => l_line_definition_code
160933 ,p_accounting_line_code => l_component_code
160934 ,p_accounting_line_type_code => l_component_type_code
160935 ,p_accounting_line_appl_id => l_component_appl_id
160936 ,p_amb_context_code => l_amb_context_code
160937 ,p_entity_code => l_entity_code
160938 ,p_event_class_code => l_event_class_code);
160939 --
160940 -- set accounting class
160941 --
160942 xla_ae_lines_pkg.SetAcctClass(
160943 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
160944 , p_ae_header_id => l_ae_header_id
160945 );
160946
160947 --
160948 -- set rounding class
160949 --
160950 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
160951 'MATERIAL_OVERHEAD_ABSORPTION';
160952
160953 --
160954 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
160955 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
160956 --
160957 -- bulk performance
160958 --
160959 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
160960
160961 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
160962 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
160963
160964 -- 4955764
160965 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
160966 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
160967
160968 -- 4458381 Public Sector Enh
160969
160970 --
160971 -- set accounting attributes for the line type
160972 --
160973 l_entered_amt_idx := 17;
160974 l_accted_amt_idx := 22;
160975 l_bflow_applied_to_amt_idx := NULL; -- 5132302
160976 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
160977 l_rec_acct_attrs.array_num_value(1) := p_source_79;
160978 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
160979 l_rec_acct_attrs.array_char_value(2) := p_source_80;
160980 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
160981 l_rec_acct_attrs.array_char_value(3) := p_source_81;
160982 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
160983 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
160984 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
160985 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
160986 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
160987 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
160988 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
160989 l_rec_acct_attrs.array_char_value(7) := p_source_85;
160990 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
160991 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
160992 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
160993 l_rec_acct_attrs.array_num_value(9) := p_source_87;
160994 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
160995 l_rec_acct_attrs.array_char_value(10) := p_source_88;
160996 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
160997 l_rec_acct_attrs.array_num_value(11) := p_source_89;
160998 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
160999 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
161000 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
161001 l_rec_acct_attrs.array_num_value(13) := p_source_87;
161002 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
161003 l_rec_acct_attrs.array_char_value(14) := p_source_88;
161004 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
161005 l_rec_acct_attrs.array_num_value(15) := p_source_89;
161006 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
161007 l_rec_acct_attrs.array_char_value(16) := p_source_100;
161008 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
161009 l_rec_acct_attrs.array_num_value(17) := p_source_91;
161010 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
161011 l_rec_acct_attrs.array_char_value(18) := p_source_88;
161012 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
161013 l_rec_acct_attrs.array_date_value(19) := p_source_92;
161014 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
161015 l_rec_acct_attrs.array_num_value(20) := p_source_93;
161016 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
161017 l_rec_acct_attrs.array_char_value(21) := p_source_94;
161018 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
161019 l_rec_acct_attrs.array_num_value(22) := p_source_95;
161020 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
161021 l_rec_acct_attrs.array_num_value(23) := p_source_104;
161022 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
161023 l_rec_acct_attrs.array_num_value(24) := p_source_104;
161024
161025 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
161026 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
161027
161028 ---------------------------------------------------------------------------------------------------------------
161029 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
161030 ---------------------------------------------------------------------------------------------------------------
161031 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
161032
161033 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
161034 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
161035
161036 IF xla_accounting_cache_pkg.GetValueChar
161037 (p_source_code => 'LEDGER_CATEGORY_CODE'
161038 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
161039 AND l_bflow_method_code = 'PRIOR_ENTRY'
161040 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
161041 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
161042 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
161043 )
161044 THEN
161045 xla_ae_lines_pkg.BflowUpgEntry
161046 (p_business_method_code => l_bflow_method_code
161047 ,p_business_class_code => l_bflow_class_code
161048 ,p_balance_type => l_balance_type_code);
161049 ELSE
161050 NULL;
161051 -- No business flow processing for business flow method of NONE.
161052 END IF;
161053
161054 --
161055 -- call analytical criteria
161056 --
161057
161058 --
161059 -- call description
161060 --
161061
161062 xla_ae_lines_pkg.SetLineDescription(
161063 p_ae_header_id => l_ae_header_id
161064 ,p_description => Description_1 (
161065 p_application_id => p_application_id
161066 , p_ae_header_id => l_ae_header_id
161067 , p_source_1 => p_source_1
161068 , p_source_2 => p_source_2
161069 , p_source_3 => p_source_3
161070 , p_source_4 => p_source_4
161071 , p_source_5 => p_source_5
161072 )
161073 );
161074
161075
161076 --
161077 -- call ADRs
161078 -- Bug 4922099
161079 --
161080 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
161081 (NVL(l_actual_upg_option, 'N') = 'O') OR
161082 (NVL(l_enc_upg_option, 'N') = 'O')
161083 )
161084 THEN
161085 NULL;
161086 --
161087 --
161088
161089 l_ccid := AcctDerRule_6(
161090 p_application_id => p_application_id
161091 , p_ae_header_id => l_ae_header_id
161092 , p_source_11 => p_source_11
161093 , x_transaction_coa_id => l_adr_transaction_coa_id
161094 , x_accounting_coa_id => l_adr_accounting_coa_id
161095 , x_value_type_code => l_adr_value_type_code
161096 , p_side => 'NA'
161097 );
161098
161099 xla_ae_lines_pkg.set_ccid(
161100 p_code_combination_id => l_ccid
161101 , p_value_type_code => l_adr_value_type_code
161102 , p_transaction_coa_id => l_adr_transaction_coa_id
161103 , p_accounting_coa_id => l_adr_accounting_coa_id
161104 , p_adr_code => 'CST_DEFAULT'
161105 , p_adr_type_code => 'S'
161106 , p_component_type => l_component_type
161107 , p_component_code => l_component_code
161108 , p_component_type_code => l_component_type_code
161109 , p_component_appl_id => l_component_appl_id
161110 , p_amb_context_code => l_amb_context_code
161111 , p_side => 'NA'
161112 );
161113
161114
161115 --
161116 --
161117 END IF;
161118 --
161119 -- Bug 4922099
161120 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
161121 (NVL(l_enc_upg_option, 'N') = 'O')
161122 ) AND
161123 (l_bflow_method_code = 'PRIOR_ENTRY')
161124 )
161125 THEN
161126 IF
161127 --
161128 1 = 2
161129 --
161130 THEN
161131 xla_accounting_err_pkg.build_message
161132 (p_appli_s_name => 'XLA'
161133 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
161134 ,p_token_1 => 'LINE_NUMBER'
161135 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
161136 ,p_token_2 => 'LINE_TYPE_NAME'
161137 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
161138 l_component_type
161139 ,l_component_code
161140 ,l_component_type_code
161141 ,l_component_appl_id
161142 ,l_amb_context_code
161143 ,l_entity_code
161144 ,l_event_class_code
161145 )
161146 ,p_token_3 => 'OWNER'
161147 ,p_value_3 => xla_lookups_pkg.get_meaning(
161148 p_lookup_type => 'XLA_OWNER_TYPE'
161149 ,p_lookup_code => l_component_type_code
161150 )
161151 ,p_token_4 => 'PRODUCT_NAME'
161152 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
161153 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
161154 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
161155 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
161156 ,p_ae_header_id => NULL
161157 );
161158
161159 IF (C_LEVEL_ERROR>= g_log_level) THEN
161160 trace
161161 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
161162 ,p_level => C_LEVEL_ERROR
161163 ,p_module => l_log_module);
161164 END IF;
161165 END IF;
161166 END IF;
161167 --
161168 --
161169 ------------------------------------------------------------------------------------------------
161170 -- 4219869 Business Flow
161171 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
161172 -- Prior Entry. Currently, the following code is always generated.
161173 ------------------------------------------------------------------------------------------------
161174 XLA_AE_LINES_PKG.ValidateCurrentLine;
161175
161176 ------------------------------------------------------------------------------------
161177 -- 4219869 Business Flow
161178 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
161179 ------------------------------------------------------------------------------------
161180 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
161181
161182 ----------------------------------------------------------------------------------
161183 -- 4219869 Business Flow
161184 -- Update journal entry status -- Need to generate this within IF <condition>
161185 ----------------------------------------------------------------------------------
161186 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
161187 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
161188 ,p_balance_type_code => l_balance_type_code
161189 );
161190
161191 -------------------------------------------------------------------------------------------
161192 -- 4262811 - Generate the Accrual Reversal lines
161193 -------------------------------------------------------------------------------------------
161194 BEGIN
161195 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
161196 (g_array_event(p_event_id).array_value_num('header_index'));
161197 IF l_acc_rev_flag IS NULL THEN
161198 l_acc_rev_flag := 'N';
161199 END IF;
161200 EXCEPTION
161201 WHEN OTHERS THEN
161202 l_acc_rev_flag := 'N';
161203 END;
161204 --
161205 IF (l_acc_rev_flag = 'Y') THEN
161206
161207 -- 4645092 ------------------------------------------------------------------------------
161208 -- To allow MPA report to determine if it should generate report process
161209 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
161210 ------------------------------------------------------------------------------------------
161211
161212 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
161213 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
161214 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
161215 -- call ADRs
161216 -- Bug 4922099
161217 --
161218 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
161219 (NVL(l_actual_upg_option, 'N') = 'O') OR
161220 (NVL(l_enc_upg_option, 'N') = 'O')
161221 )
161222 THEN
161223 NULL;
161224 --
161225 --
161226
161227 l_ccid := AcctDerRule_6(
161228 p_application_id => p_application_id
161229 , p_ae_header_id => l_ae_header_id
161230 , p_source_11 => p_source_11
161231 , x_transaction_coa_id => l_adr_transaction_coa_id
161232 , x_accounting_coa_id => l_adr_accounting_coa_id
161233 , x_value_type_code => l_adr_value_type_code
161234 , p_side => 'NA'
161235 );
161236
161237 xla_ae_lines_pkg.set_ccid(
161238 p_code_combination_id => l_ccid
161239 , p_value_type_code => l_adr_value_type_code
161240 , p_transaction_coa_id => l_adr_transaction_coa_id
161241 , p_accounting_coa_id => l_adr_accounting_coa_id
161242 , p_adr_code => 'CST_DEFAULT'
161243 , p_adr_type_code => 'S'
161244 , p_component_type => l_component_type
161245 , p_component_code => l_component_code
161246 , p_component_type_code => l_component_type_code
161247 , p_component_appl_id => l_component_appl_id
161248 , p_amb_context_code => l_amb_context_code
161249 , p_side => 'NA'
161250 );
161251
161252
161253 --
161254 --
161255 END IF;
161256
161257 --
161258 -- Update the line information that should be overwritten
161259 --
161260 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
161261 p_header_num => 1);
161262 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
161263
161264 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
161265
161266 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
161267 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
161268 END IF;
161269
161270 --
161271 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
161272 --
161273 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
161274 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
161275 ELSE
161276 ---------------------------------------------------------------------------------------------------
161277 -- 4262811a Switch Sign
161278 ---------------------------------------------------------------------------------------------------
161279 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
161280 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
161281 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161282 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
161283 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161284 -- 5132302
161285 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
161286 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161287
161288 END IF;
161289
161290 -- 4955764
161291 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
161292 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
161293
161294
161295 XLA_AE_LINES_PKG.ValidateCurrentLine;
161296 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
161297
161298 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
161299 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
161300 ,p_balance_type_code => l_balance_type_code);
161301
161302 END IF;
161303
161304 -----------------------------------------------------------------------------------------
161305 -- 4262811 Multiperiod Accounting
161306 -----------------------------------------------------------------------------------------
161307 -- No MPA option is assigned.
161308
161309
161310 END IF;
161311 END IF;
161312 --
161313
161314 --
161315 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
161316 trace
161317 (p_msg => 'END of AcctLineType_299'
161318 ,p_level => C_LEVEL_PROCEDURE
161319 ,p_module => l_log_module);
161320 END IF;
161321 --
161322 EXCEPTION
161323 WHEN xla_exceptions_pkg.application_exception THEN
161324 RAISE;
161325 WHEN OTHERS THEN
161326 xla_exceptions_pkg.raise_message
161327 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_299');
161328 END AcctLineType_299;
161329 --
161330
161331 ---------------------------------------
161332 --
161333 -- PRIVATE FUNCTION
161334 -- AcctLineType_300
161335 --
161336 ---------------------------------------
161337 PROCEDURE AcctLineType_300 (
161338 p_application_id IN NUMBER
161339 ,p_event_id IN NUMBER
161340 ,p_calculate_acctd_flag IN VARCHAR2
161341 ,p_calculate_g_l_flag IN VARCHAR2
161342 ,p_actual_flag IN OUT VARCHAR2
161343 ,p_balance_type_code OUT VARCHAR2
161344 ,p_gain_or_loss_ref OUT VARCHAR2
161345
161346 --TRANSACTION_ID
161347 , p_source_1 IN NUMBER
161348 --Item Concatenated Segments
161349 , p_source_2 IN VARCHAR2
161350 --Transaction Quantity
161351 , p_source_3 IN NUMBER
161352 --Transaction Unit of Measure Code
161353 , p_source_4 IN VARCHAR2
161354 --Inventory Transaction Type Description
161355 , p_source_5 IN VARCHAR2
161356 --Cost Management Default Account
161357 , p_source_11 IN NUMBER
161358 --Applied to Application ID
161359 , p_source_79 IN NUMBER
161360 --Applied to Distribution Link Type
161361 , p_source_80 IN VARCHAR2
161362 --Applied to Entity Code
161363 , p_source_81 IN VARCHAR2
161364 --Applied To Purchase Document Identifier
161365 , p_source_83 IN NUMBER
161366 --DISTRIBUTION_IDENTIFIER
161367 , p_source_84 IN NUMBER
161368 --Distribution Type
161369 , p_source_85 IN VARCHAR2
161370 , p_source_85_meaning IN VARCHAR2
161371 --PO Budget Account
161372 , p_source_86 IN NUMBER
161373 --Encumbrance Reversal Amount Entered
161374 , p_source_87 IN NUMBER
161375 --Entered Currency Code
161376 , p_source_88 IN VARCHAR2
161377 --Transaction Encumbrance Reversal Amount
161378 , p_source_89 IN NUMBER
161379 --Entered Amount
161380 , p_source_91 IN NUMBER
161381 --Currency Conversion Date
161382 , p_source_92 IN DATE
161383 --Currency Conversion Rate
161384 , p_source_93 IN NUMBER
161385 --Currency Conversion Type
161386 , p_source_94 IN VARCHAR2
161387 --Accounted Amount
161388 , p_source_95 IN NUMBER
161389 --Purchasing Encumbrance Type Identifier
161390 , p_source_96 IN NUMBER
161391 --Accounting Line Type
161392 , p_source_97 IN NUMBER
161393 --Costing Encumbrance Upgrade Option
161394 , p_source_100 IN VARCHAR2
161395 --TXN_PO_DISTRIBUTION_ID
161396 , p_source_101 IN NUMBER
161397 )
161398 IS
161399
161400 l_component_type VARCHAR2(80);
161401 l_component_code VARCHAR2(30);
161402 l_component_type_code VARCHAR2(1);
161403 l_component_appl_id INTEGER;
161404 l_amb_context_code VARCHAR2(30);
161405 l_entity_code VARCHAR2(30);
161406 l_event_class_code VARCHAR2(30);
161407 l_ae_header_id NUMBER;
161408 l_event_type_code VARCHAR2(30);
161409 l_line_definition_code VARCHAR2(30);
161410 l_line_definition_owner_code VARCHAR2(1);
161411 --
161412 -- adr variables
161413 l_segment VARCHAR2(30);
161414 l_ccid NUMBER;
161415 l_adr_transaction_coa_id NUMBER;
161416 l_adr_accounting_coa_id NUMBER;
161417 l_adr_flexfield_segment_code VARCHAR2(30);
161418 l_adr_flex_value_set_id NUMBER;
161419 l_adr_value_type_code VARCHAR2(30);
161420 l_adr_value_combination_id NUMBER;
161421 l_adr_value_segment_code VARCHAR2(30);
161422
161423 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
161424 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
161425 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
161426 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
161427
161428 -- 4262811 Variables ------------------------------------------------------------------------------------------
161429 l_entered_amt_idx NUMBER;
161430 l_accted_amt_idx NUMBER;
161431 l_acc_rev_flag VARCHAR2(1);
161432 l_accrual_line_num NUMBER;
161433 l_tmp_amt NUMBER;
161434 l_acc_rev_natural_side_code VARCHAR2(1);
161435
161436 l_num_entries NUMBER;
161437 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
161438 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
161439 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
161440 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
161441 l_recog_line_1 NUMBER;
161442 l_recog_line_2 NUMBER;
161443
161444 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
161445 l_bflow_applied_to_amt NUMBER; -- 5132302
161446 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
161447
161448 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
161449
161450 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
161451 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
161452
161453 ---------------------------------------------------------------------------------------------------------------
161454
161455
161456 --
161457 -- bulk performance
161458 --
161459 l_balance_type_code VARCHAR2(1);
161460 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
161461 l_log_module VARCHAR2(240);
161462
161463 --
161464 -- Upgrade strategy
161465 --
161466 l_actual_upg_option VARCHAR2(1);
161467 l_enc_upg_option VARCHAR2(1);
161468
161469 --
161470 BEGIN
161471 --
161472 IF g_log_enabled THEN
161473 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_300';
161474 END IF;
161475 --
161476 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
161477
161478 trace
161479 (p_msg => 'BEGIN of AcctLineType_300'
161480 ,p_level => C_LEVEL_PROCEDURE
161481 ,p_module => l_log_module);
161482
161483 END IF;
161484 --
161485 l_component_type := 'AMB_JLT';
161486 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
161487 l_component_type_code := 'S';
161488 l_component_appl_id := 707;
161489 l_amb_context_code := 'DEFAULT';
161490 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
161491 l_event_class_code := 'PURCHASE_ORDER';
161492 l_event_type_code := 'LOG_PO_DEL_INV';
161493 l_line_definition_owner_code := 'S';
161494 l_line_definition_code := 'PI_LOG_DEL_INV';
161495 --
161496 l_balance_type_code := 'A';
161497 l_segment := NULL;
161498 l_ccid := NULL;
161499 l_adr_transaction_coa_id := NULL;
161500 l_adr_accounting_coa_id := NULL;
161501 l_adr_flexfield_segment_code := NULL;
161502 l_adr_flex_value_set_id := NULL;
161503 l_adr_value_type_code := NULL;
161504 l_adr_value_combination_id := NULL;
161505 l_adr_value_segment_code := NULL;
161506
161507 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
161508 l_bflow_class_code := ''; -- 4219869 Business Flow
161509 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
161510 l_budgetary_control_flag := 'N';
161511
161512 l_bflow_applied_to_amt_idx := NULL; -- 5132302
161513 l_bflow_applied_to_amt := NULL; -- 5132302
161514 l_entered_amt_idx := NULL; -- 4262811
161515 l_accted_amt_idx := NULL; -- 4262811
161516 l_acc_rev_flag := NULL; -- 4262811
161517 l_accrual_line_num := NULL; -- 4262811
161518 l_tmp_amt := NULL; -- 4262811
161519 --
161520
161521 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
161522 l_balance_type_code <> 'B' THEN
161523 IF NVL(p_source_97,9E125) = 3
161524 THEN
161525
161526 --
161527 XLA_AE_LINES_PKG.SetNewLine;
161528
161529 p_balance_type_code := l_balance_type_code;
161530 -- set the flag so later we will know whether the gain loss line needs to be created
161531
161532 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
161533 p_actual_flag :='A';
161534 END IF;
161535
161536 --
161537 -- bulk performance
161538 --
161539 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
161540 p_header_num => 0); -- 4262811
161541 --
161542 -- set accounting line options
161543 --
161544 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
161545 p_natural_side_code => 'D'
161546 , p_gain_or_loss_flag => 'N'
161547 , p_gl_transfer_mode_code => 'S'
161548 , p_acct_entry_type_code => 'A'
161549 , p_switch_side_flag => 'Y'
161550 , p_merge_duplicate_code => 'N'
161551 );
161552 --
161553 l_acc_rev_natural_side_code := 'C'; -- 4262811
161554 --
161555 --
161556 -- set accounting line type info
161557 --
161558 xla_ae_lines_pkg.SetAcctLineType
161559 (p_component_type => l_component_type
161560 ,p_event_type_code => l_event_type_code
161561 ,p_line_definition_owner_code => l_line_definition_owner_code
161562 ,p_line_definition_code => l_line_definition_code
161563 ,p_accounting_line_code => l_component_code
161564 ,p_accounting_line_type_code => l_component_type_code
161565 ,p_accounting_line_appl_id => l_component_appl_id
161566 ,p_amb_context_code => l_amb_context_code
161567 ,p_entity_code => l_entity_code
161568 ,p_event_class_code => l_event_class_code);
161569 --
161570 -- set accounting class
161571 --
161572 xla_ae_lines_pkg.SetAcctClass(
161573 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
161574 , p_ae_header_id => l_ae_header_id
161575 );
161576
161577 --
161578 -- set rounding class
161579 --
161580 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
161581 'MATERIAL_OVERHEAD_ABSORPTION';
161582
161583 --
161584 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
161585 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
161586 --
161587 -- bulk performance
161588 --
161589 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
161590
161591 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
161592 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
161593
161594 -- 4955764
161595 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
161596 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
161597
161598 -- 4458381 Public Sector Enh
161599
161600 --
161601 -- set accounting attributes for the line type
161602 --
161603 l_entered_amt_idx := 17;
161604 l_accted_amt_idx := 22;
161605 l_bflow_applied_to_amt_idx := NULL; -- 5132302
161606 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
161607 l_rec_acct_attrs.array_num_value(1) := p_source_79;
161608 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
161609 l_rec_acct_attrs.array_char_value(2) := p_source_80;
161610 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
161611 l_rec_acct_attrs.array_char_value(3) := p_source_81;
161612 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
161613 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
161614 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
161615 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
161616 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
161617 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
161618 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
161619 l_rec_acct_attrs.array_char_value(7) := p_source_85;
161620 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
161621 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
161622 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
161623 l_rec_acct_attrs.array_num_value(9) := p_source_87;
161624 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
161625 l_rec_acct_attrs.array_char_value(10) := p_source_88;
161626 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
161627 l_rec_acct_attrs.array_num_value(11) := p_source_89;
161628 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
161629 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
161630 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
161631 l_rec_acct_attrs.array_num_value(13) := p_source_87;
161632 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
161633 l_rec_acct_attrs.array_char_value(14) := p_source_88;
161634 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
161635 l_rec_acct_attrs.array_num_value(15) := p_source_89;
161636 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
161637 l_rec_acct_attrs.array_char_value(16) := p_source_100;
161638 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
161639 l_rec_acct_attrs.array_num_value(17) := p_source_91;
161640 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
161641 l_rec_acct_attrs.array_char_value(18) := p_source_88;
161642 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
161643 l_rec_acct_attrs.array_date_value(19) := p_source_92;
161644 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
161645 l_rec_acct_attrs.array_num_value(20) := p_source_93;
161646 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
161647 l_rec_acct_attrs.array_char_value(21) := p_source_94;
161648 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
161649 l_rec_acct_attrs.array_num_value(22) := p_source_95;
161650 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
161651 l_rec_acct_attrs.array_num_value(23) := p_source_96;
161652 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
161653 l_rec_acct_attrs.array_num_value(24) := p_source_96;
161654
161655 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
161656 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
161657
161658 ---------------------------------------------------------------------------------------------------------------
161659 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
161660 ---------------------------------------------------------------------------------------------------------------
161661 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
161662
161663 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
161664 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
161665
161666 IF xla_accounting_cache_pkg.GetValueChar
161667 (p_source_code => 'LEDGER_CATEGORY_CODE'
161668 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
161669 AND l_bflow_method_code = 'PRIOR_ENTRY'
161670 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
161671 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
161672 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
161673 )
161674 THEN
161675 xla_ae_lines_pkg.BflowUpgEntry
161676 (p_business_method_code => l_bflow_method_code
161677 ,p_business_class_code => l_bflow_class_code
161678 ,p_balance_type => l_balance_type_code);
161679 ELSE
161680 NULL;
161681 -- No business flow processing for business flow method of NONE.
161682 END IF;
161683
161684 --
161685 -- call analytical criteria
161686 --
161687
161688 --
161689 -- call description
161690 --
161691
161692 xla_ae_lines_pkg.SetLineDescription(
161693 p_ae_header_id => l_ae_header_id
161694 ,p_description => Description_1 (
161695 p_application_id => p_application_id
161696 , p_ae_header_id => l_ae_header_id
161697 , p_source_1 => p_source_1
161698 , p_source_2 => p_source_2
161699 , p_source_3 => p_source_3
161700 , p_source_4 => p_source_4
161701 , p_source_5 => p_source_5
161702 )
161703 );
161704
161705
161706 --
161707 -- call ADRs
161708 -- Bug 4922099
161709 --
161710 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
161711 (NVL(l_actual_upg_option, 'N') = 'O') OR
161712 (NVL(l_enc_upg_option, 'N') = 'O')
161713 )
161714 THEN
161715 NULL;
161716 --
161717 --
161718
161719 l_ccid := AcctDerRule_6(
161720 p_application_id => p_application_id
161721 , p_ae_header_id => l_ae_header_id
161722 , p_source_11 => p_source_11
161723 , x_transaction_coa_id => l_adr_transaction_coa_id
161724 , x_accounting_coa_id => l_adr_accounting_coa_id
161725 , x_value_type_code => l_adr_value_type_code
161726 , p_side => 'NA'
161727 );
161728
161729 xla_ae_lines_pkg.set_ccid(
161730 p_code_combination_id => l_ccid
161731 , p_value_type_code => l_adr_value_type_code
161732 , p_transaction_coa_id => l_adr_transaction_coa_id
161733 , p_accounting_coa_id => l_adr_accounting_coa_id
161734 , p_adr_code => 'CST_DEFAULT'
161735 , p_adr_type_code => 'S'
161736 , p_component_type => l_component_type
161737 , p_component_code => l_component_code
161738 , p_component_type_code => l_component_type_code
161739 , p_component_appl_id => l_component_appl_id
161740 , p_amb_context_code => l_amb_context_code
161741 , p_side => 'NA'
161742 );
161743
161744
161745 --
161746 --
161747 END IF;
161748 --
161749 -- Bug 4922099
161750 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
161751 (NVL(l_enc_upg_option, 'N') = 'O')
161752 ) AND
161753 (l_bflow_method_code = 'PRIOR_ENTRY')
161754 )
161755 THEN
161756 IF
161757 --
161758 1 = 2
161759 --
161760 THEN
161761 xla_accounting_err_pkg.build_message
161762 (p_appli_s_name => 'XLA'
161763 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
161764 ,p_token_1 => 'LINE_NUMBER'
161765 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
161766 ,p_token_2 => 'LINE_TYPE_NAME'
161767 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
161768 l_component_type
161769 ,l_component_code
161770 ,l_component_type_code
161771 ,l_component_appl_id
161772 ,l_amb_context_code
161773 ,l_entity_code
161774 ,l_event_class_code
161775 )
161776 ,p_token_3 => 'OWNER'
161777 ,p_value_3 => xla_lookups_pkg.get_meaning(
161778 p_lookup_type => 'XLA_OWNER_TYPE'
161779 ,p_lookup_code => l_component_type_code
161780 )
161781 ,p_token_4 => 'PRODUCT_NAME'
161782 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
161783 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
161784 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
161785 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
161786 ,p_ae_header_id => NULL
161787 );
161788
161789 IF (C_LEVEL_ERROR>= g_log_level) THEN
161790 trace
161791 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
161792 ,p_level => C_LEVEL_ERROR
161793 ,p_module => l_log_module);
161794 END IF;
161795 END IF;
161796 END IF;
161797 --
161798 --
161799 ------------------------------------------------------------------------------------------------
161800 -- 4219869 Business Flow
161801 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
161802 -- Prior Entry. Currently, the following code is always generated.
161803 ------------------------------------------------------------------------------------------------
161804 XLA_AE_LINES_PKG.ValidateCurrentLine;
161805
161806 ------------------------------------------------------------------------------------
161807 -- 4219869 Business Flow
161808 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
161809 ------------------------------------------------------------------------------------
161810 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
161811
161812 ----------------------------------------------------------------------------------
161813 -- 4219869 Business Flow
161814 -- Update journal entry status -- Need to generate this within IF <condition>
161815 ----------------------------------------------------------------------------------
161816 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
161817 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
161818 ,p_balance_type_code => l_balance_type_code
161819 );
161820
161821 -------------------------------------------------------------------------------------------
161822 -- 4262811 - Generate the Accrual Reversal lines
161823 -------------------------------------------------------------------------------------------
161824 BEGIN
161825 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
161826 (g_array_event(p_event_id).array_value_num('header_index'));
161827 IF l_acc_rev_flag IS NULL THEN
161828 l_acc_rev_flag := 'N';
161829 END IF;
161830 EXCEPTION
161831 WHEN OTHERS THEN
161832 l_acc_rev_flag := 'N';
161833 END;
161834 --
161835 IF (l_acc_rev_flag = 'Y') THEN
161836
161837 -- 4645092 ------------------------------------------------------------------------------
161838 -- To allow MPA report to determine if it should generate report process
161839 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
161840 ------------------------------------------------------------------------------------------
161841
161842 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
161843 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
161844 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
161845 -- call ADRs
161846 -- Bug 4922099
161847 --
161848 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
161849 (NVL(l_actual_upg_option, 'N') = 'O') OR
161850 (NVL(l_enc_upg_option, 'N') = 'O')
161851 )
161852 THEN
161853 NULL;
161854 --
161855 --
161856
161857 l_ccid := AcctDerRule_6(
161858 p_application_id => p_application_id
161859 , p_ae_header_id => l_ae_header_id
161860 , p_source_11 => p_source_11
161861 , x_transaction_coa_id => l_adr_transaction_coa_id
161862 , x_accounting_coa_id => l_adr_accounting_coa_id
161863 , x_value_type_code => l_adr_value_type_code
161864 , p_side => 'NA'
161865 );
161866
161867 xla_ae_lines_pkg.set_ccid(
161868 p_code_combination_id => l_ccid
161869 , p_value_type_code => l_adr_value_type_code
161870 , p_transaction_coa_id => l_adr_transaction_coa_id
161871 , p_accounting_coa_id => l_adr_accounting_coa_id
161872 , p_adr_code => 'CST_DEFAULT'
161873 , p_adr_type_code => 'S'
161874 , p_component_type => l_component_type
161875 , p_component_code => l_component_code
161876 , p_component_type_code => l_component_type_code
161877 , p_component_appl_id => l_component_appl_id
161878 , p_amb_context_code => l_amb_context_code
161879 , p_side => 'NA'
161880 );
161881
161882
161883 --
161884 --
161885 END IF;
161886
161887 --
161888 -- Update the line information that should be overwritten
161889 --
161890 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
161891 p_header_num => 1);
161892 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
161893
161894 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
161895
161896 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
161897 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
161898 END IF;
161899
161900 --
161901 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
161902 --
161903 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
161904 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
161905 ELSE
161906 ---------------------------------------------------------------------------------------------------
161907 -- 4262811a Switch Sign
161908 ---------------------------------------------------------------------------------------------------
161909 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
161910 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
161911 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161912 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
161913 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161914 -- 5132302
161915 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
161916 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
161917
161918 END IF;
161919
161920 -- 4955764
161921 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
161922 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
161923
161924
161925 XLA_AE_LINES_PKG.ValidateCurrentLine;
161926 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
161927
161928 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
161929 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
161930 ,p_balance_type_code => l_balance_type_code);
161931
161932 END IF;
161933
161934 -----------------------------------------------------------------------------------------
161935 -- 4262811 Multiperiod Accounting
161936 -----------------------------------------------------------------------------------------
161937 -- No MPA option is assigned.
161938
161939
161940 END IF;
161941 END IF;
161942 --
161943
161944 --
161945 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
161946 trace
161947 (p_msg => 'END of AcctLineType_300'
161948 ,p_level => C_LEVEL_PROCEDURE
161949 ,p_module => l_log_module);
161950 END IF;
161951 --
161952 EXCEPTION
161953 WHEN xla_exceptions_pkg.application_exception THEN
161954 RAISE;
161955 WHEN OTHERS THEN
161956 xla_exceptions_pkg.raise_message
161957 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_300');
161958 END AcctLineType_300;
161959 --
161960
161961 ---------------------------------------
161962 --
161963 -- PRIVATE FUNCTION
161964 -- AcctLineType_301
161965 --
161966 ---------------------------------------
161967 PROCEDURE AcctLineType_301 (
161968 p_application_id IN NUMBER
161969 ,p_event_id IN NUMBER
161970 ,p_calculate_acctd_flag IN VARCHAR2
161971 ,p_calculate_g_l_flag IN VARCHAR2
161972 ,p_actual_flag IN OUT VARCHAR2
161973 ,p_balance_type_code OUT VARCHAR2
161974 ,p_gain_or_loss_ref OUT VARCHAR2
161975
161976 --TRANSACTION_ID
161977 , p_source_1 IN NUMBER
161978 --Item Concatenated Segments
161979 , p_source_2 IN VARCHAR2
161980 --Transaction Quantity
161981 , p_source_3 IN NUMBER
161982 --Transaction Unit of Measure Code
161983 , p_source_4 IN VARCHAR2
161984 --Inventory Transaction Type Description
161985 , p_source_5 IN VARCHAR2
161986 --Cost Management Default Account
161987 , p_source_11 IN NUMBER
161988 --DISTRIBUTION_IDENTIFIER
161989 , p_source_84 IN NUMBER
161990 --Distribution Type
161991 , p_source_85 IN VARCHAR2
161992 , p_source_85_meaning IN VARCHAR2
161993 --Entered Currency Code
161994 , p_source_88 IN VARCHAR2
161995 --Entered Amount
161996 , p_source_91 IN NUMBER
161997 --Currency Conversion Date
161998 , p_source_92 IN DATE
161999 --Currency Conversion Rate
162000 , p_source_93 IN NUMBER
162001 --Currency Conversion Type
162002 , p_source_94 IN VARCHAR2
162003 --Accounted Amount
162004 , p_source_95 IN NUMBER
162005 --Accounting Line Type
162006 , p_source_97 IN NUMBER
162007 )
162008 IS
162009
162010 l_component_type VARCHAR2(80);
162011 l_component_code VARCHAR2(30);
162012 l_component_type_code VARCHAR2(1);
162013 l_component_appl_id INTEGER;
162014 l_amb_context_code VARCHAR2(30);
162015 l_entity_code VARCHAR2(30);
162016 l_event_class_code VARCHAR2(30);
162017 l_ae_header_id NUMBER;
162018 l_event_type_code VARCHAR2(30);
162019 l_line_definition_code VARCHAR2(30);
162020 l_line_definition_owner_code VARCHAR2(1);
162021 --
162022 -- adr variables
162023 l_segment VARCHAR2(30);
162024 l_ccid NUMBER;
162025 l_adr_transaction_coa_id NUMBER;
162026 l_adr_accounting_coa_id NUMBER;
162027 l_adr_flexfield_segment_code VARCHAR2(30);
162028 l_adr_flex_value_set_id NUMBER;
162029 l_adr_value_type_code VARCHAR2(30);
162030 l_adr_value_combination_id NUMBER;
162031 l_adr_value_segment_code VARCHAR2(30);
162032
162033 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
162034 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
162035 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
162036 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
162037
162038 -- 4262811 Variables ------------------------------------------------------------------------------------------
162039 l_entered_amt_idx NUMBER;
162040 l_accted_amt_idx NUMBER;
162041 l_acc_rev_flag VARCHAR2(1);
162042 l_accrual_line_num NUMBER;
162043 l_tmp_amt NUMBER;
162044 l_acc_rev_natural_side_code VARCHAR2(1);
162045
162046 l_num_entries NUMBER;
162047 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
162048 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
162049 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
162050 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
162051 l_recog_line_1 NUMBER;
162052 l_recog_line_2 NUMBER;
162053
162054 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
162055 l_bflow_applied_to_amt NUMBER; -- 5132302
162056 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
162057
162058 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
162059
162060 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
162061 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
162062
162063 ---------------------------------------------------------------------------------------------------------------
162064
162065
162066 --
162067 -- bulk performance
162068 --
162069 l_balance_type_code VARCHAR2(1);
162070 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
162071 l_log_module VARCHAR2(240);
162072
162073 --
162074 -- Upgrade strategy
162075 --
162076 l_actual_upg_option VARCHAR2(1);
162077 l_enc_upg_option VARCHAR2(1);
162078
162079 --
162080 BEGIN
162081 --
162082 IF g_log_enabled THEN
162083 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_301';
162084 END IF;
162085 --
162086 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
162087
162088 trace
162089 (p_msg => 'BEGIN of AcctLineType_301'
162090 ,p_level => C_LEVEL_PROCEDURE
162091 ,p_module => l_log_module);
162092
162093 END IF;
162094 --
162095 l_component_type := 'AMB_JLT';
162096 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
162097 l_component_type_code := 'S';
162098 l_component_appl_id := 707;
162099 l_amb_context_code := 'DEFAULT';
162100 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
162101 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
162102 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
162103 l_line_definition_owner_code := 'S';
162104 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
162105 --
162106 l_balance_type_code := 'A';
162107 l_segment := NULL;
162108 l_ccid := NULL;
162109 l_adr_transaction_coa_id := NULL;
162110 l_adr_accounting_coa_id := NULL;
162111 l_adr_flexfield_segment_code := NULL;
162112 l_adr_flex_value_set_id := NULL;
162113 l_adr_value_type_code := NULL;
162114 l_adr_value_combination_id := NULL;
162115 l_adr_value_segment_code := NULL;
162116
162117 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
162118 l_bflow_class_code := ''; -- 4219869 Business Flow
162119 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
162120 l_budgetary_control_flag := 'N';
162121
162122 l_bflow_applied_to_amt_idx := NULL; -- 5132302
162123 l_bflow_applied_to_amt := NULL; -- 5132302
162124 l_entered_amt_idx := NULL; -- 4262811
162125 l_accted_amt_idx := NULL; -- 4262811
162126 l_acc_rev_flag := NULL; -- 4262811
162127 l_accrual_line_num := NULL; -- 4262811
162128 l_tmp_amt := NULL; -- 4262811
162129 --
162130
162131 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
162132 l_balance_type_code <> 'B' THEN
162133 IF NVL(p_source_97,9E125) = 3
162134 THEN
162135
162136 --
162137 XLA_AE_LINES_PKG.SetNewLine;
162138
162139 p_balance_type_code := l_balance_type_code;
162140 -- set the flag so later we will know whether the gain loss line needs to be created
162141
162142 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
162143 p_actual_flag :='A';
162144 END IF;
162145
162146 --
162147 -- bulk performance
162148 --
162149 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
162150 p_header_num => 0); -- 4262811
162151 --
162152 -- set accounting line options
162153 --
162154 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
162155 p_natural_side_code => 'D'
162156 , p_gain_or_loss_flag => 'N'
162157 , p_gl_transfer_mode_code => 'S'
162158 , p_acct_entry_type_code => 'A'
162159 , p_switch_side_flag => 'Y'
162160 , p_merge_duplicate_code => 'N'
162161 );
162162 --
162163 l_acc_rev_natural_side_code := 'C'; -- 4262811
162164 --
162165 --
162166 -- set accounting line type info
162167 --
162168 xla_ae_lines_pkg.SetAcctLineType
162169 (p_component_type => l_component_type
162170 ,p_event_type_code => l_event_type_code
162171 ,p_line_definition_owner_code => l_line_definition_owner_code
162172 ,p_line_definition_code => l_line_definition_code
162173 ,p_accounting_line_code => l_component_code
162174 ,p_accounting_line_type_code => l_component_type_code
162175 ,p_accounting_line_appl_id => l_component_appl_id
162176 ,p_amb_context_code => l_amb_context_code
162177 ,p_entity_code => l_entity_code
162178 ,p_event_class_code => l_event_class_code);
162179 --
162180 -- set accounting class
162181 --
162182 xla_ae_lines_pkg.SetAcctClass(
162183 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
162184 , p_ae_header_id => l_ae_header_id
162185 );
162186
162187 --
162188 -- set rounding class
162189 --
162190 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
162191 'MATERIAL_OVERHEAD_ABSORPTION';
162192
162193 --
162194 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
162195 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
162196 --
162197 -- bulk performance
162198 --
162199 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
162200
162201 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
162202 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
162203
162204 -- 4955764
162205 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
162206 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
162207
162208 -- 4458381 Public Sector Enh
162209
162210 --
162211 -- set accounting attributes for the line type
162212 --
162213 l_entered_amt_idx := 3;
162214 l_accted_amt_idx := 8;
162215 l_bflow_applied_to_amt_idx := NULL; -- 5132302
162216 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
162217 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
162218 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
162219 l_rec_acct_attrs.array_char_value(2) := p_source_85;
162220 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
162221 l_rec_acct_attrs.array_num_value(3) := p_source_91;
162222 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
162223 l_rec_acct_attrs.array_char_value(4) := p_source_88;
162224 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
162225 l_rec_acct_attrs.array_date_value(5) := p_source_92;
162226 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
162227 l_rec_acct_attrs.array_num_value(6) := p_source_93;
162228 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
162229 l_rec_acct_attrs.array_char_value(7) := p_source_94;
162230 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
162231 l_rec_acct_attrs.array_num_value(8) := p_source_95;
162232
162233 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
162234 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
162235
162236 ---------------------------------------------------------------------------------------------------------------
162237 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
162238 ---------------------------------------------------------------------------------------------------------------
162239 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
162240
162241 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
162242 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
162243
162244 IF xla_accounting_cache_pkg.GetValueChar
162245 (p_source_code => 'LEDGER_CATEGORY_CODE'
162246 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
162247 AND l_bflow_method_code = 'PRIOR_ENTRY'
162248 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
162249 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
162250 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
162251 )
162252 THEN
162253 xla_ae_lines_pkg.BflowUpgEntry
162254 (p_business_method_code => l_bflow_method_code
162255 ,p_business_class_code => l_bflow_class_code
162256 ,p_balance_type => l_balance_type_code);
162257 ELSE
162258 NULL;
162259 -- No business flow processing for business flow method of NONE.
162260 END IF;
162261
162262 --
162263 -- call analytical criteria
162264 --
162265
162266 --
162267 -- call description
162268 --
162269
162270 xla_ae_lines_pkg.SetLineDescription(
162271 p_ae_header_id => l_ae_header_id
162272 ,p_description => Description_1 (
162273 p_application_id => p_application_id
162274 , p_ae_header_id => l_ae_header_id
162275 , p_source_1 => p_source_1
162276 , p_source_2 => p_source_2
162277 , p_source_3 => p_source_3
162278 , p_source_4 => p_source_4
162279 , p_source_5 => p_source_5
162280 )
162281 );
162282
162283
162284 --
162285 -- call ADRs
162286 -- Bug 4922099
162287 --
162288 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
162289 (NVL(l_actual_upg_option, 'N') = 'O') OR
162290 (NVL(l_enc_upg_option, 'N') = 'O')
162291 )
162292 THEN
162293 NULL;
162294 --
162295 --
162296
162297 l_ccid := AcctDerRule_6(
162298 p_application_id => p_application_id
162299 , p_ae_header_id => l_ae_header_id
162300 , p_source_11 => p_source_11
162301 , x_transaction_coa_id => l_adr_transaction_coa_id
162302 , x_accounting_coa_id => l_adr_accounting_coa_id
162303 , x_value_type_code => l_adr_value_type_code
162304 , p_side => 'NA'
162305 );
162306
162307 xla_ae_lines_pkg.set_ccid(
162308 p_code_combination_id => l_ccid
162309 , p_value_type_code => l_adr_value_type_code
162310 , p_transaction_coa_id => l_adr_transaction_coa_id
162311 , p_accounting_coa_id => l_adr_accounting_coa_id
162312 , p_adr_code => 'CST_DEFAULT'
162313 , p_adr_type_code => 'S'
162314 , p_component_type => l_component_type
162315 , p_component_code => l_component_code
162316 , p_component_type_code => l_component_type_code
162317 , p_component_appl_id => l_component_appl_id
162318 , p_amb_context_code => l_amb_context_code
162319 , p_side => 'NA'
162320 );
162321
162322
162323 --
162324 --
162325 END IF;
162326 --
162327 -- Bug 4922099
162328 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
162329 (NVL(l_enc_upg_option, 'N') = 'O')
162330 ) AND
162331 (l_bflow_method_code = 'PRIOR_ENTRY')
162332 )
162333 THEN
162334 IF
162335 --
162336 1 = 2
162337 --
162338 THEN
162339 xla_accounting_err_pkg.build_message
162340 (p_appli_s_name => 'XLA'
162341 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
162342 ,p_token_1 => 'LINE_NUMBER'
162343 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
162344 ,p_token_2 => 'LINE_TYPE_NAME'
162345 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
162346 l_component_type
162347 ,l_component_code
162348 ,l_component_type_code
162349 ,l_component_appl_id
162350 ,l_amb_context_code
162351 ,l_entity_code
162352 ,l_event_class_code
162353 )
162354 ,p_token_3 => 'OWNER'
162355 ,p_value_3 => xla_lookups_pkg.get_meaning(
162356 p_lookup_type => 'XLA_OWNER_TYPE'
162357 ,p_lookup_code => l_component_type_code
162358 )
162359 ,p_token_4 => 'PRODUCT_NAME'
162360 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
162361 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
162362 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
162363 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
162364 ,p_ae_header_id => NULL
162365 );
162366
162367 IF (C_LEVEL_ERROR>= g_log_level) THEN
162368 trace
162369 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
162370 ,p_level => C_LEVEL_ERROR
162371 ,p_module => l_log_module);
162372 END IF;
162373 END IF;
162374 END IF;
162375 --
162376 --
162377 ------------------------------------------------------------------------------------------------
162378 -- 4219869 Business Flow
162379 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
162380 -- Prior Entry. Currently, the following code is always generated.
162381 ------------------------------------------------------------------------------------------------
162382 XLA_AE_LINES_PKG.ValidateCurrentLine;
162383
162384 ------------------------------------------------------------------------------------
162385 -- 4219869 Business Flow
162386 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
162387 ------------------------------------------------------------------------------------
162388 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
162389
162390 ----------------------------------------------------------------------------------
162391 -- 4219869 Business Flow
162392 -- Update journal entry status -- Need to generate this within IF <condition>
162393 ----------------------------------------------------------------------------------
162394 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
162395 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
162396 ,p_balance_type_code => l_balance_type_code
162397 );
162398
162399 -------------------------------------------------------------------------------------------
162400 -- 4262811 - Generate the Accrual Reversal lines
162401 -------------------------------------------------------------------------------------------
162402 BEGIN
162403 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
162404 (g_array_event(p_event_id).array_value_num('header_index'));
162405 IF l_acc_rev_flag IS NULL THEN
162406 l_acc_rev_flag := 'N';
162407 END IF;
162408 EXCEPTION
162409 WHEN OTHERS THEN
162410 l_acc_rev_flag := 'N';
162411 END;
162412 --
162413 IF (l_acc_rev_flag = 'Y') THEN
162414
162415 -- 4645092 ------------------------------------------------------------------------------
162416 -- To allow MPA report to determine if it should generate report process
162417 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
162418 ------------------------------------------------------------------------------------------
162419
162420 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
162421 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
162422 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
162423 -- call ADRs
162424 -- Bug 4922099
162425 --
162426 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
162427 (NVL(l_actual_upg_option, 'N') = 'O') OR
162428 (NVL(l_enc_upg_option, 'N') = 'O')
162429 )
162430 THEN
162431 NULL;
162432 --
162433 --
162434
162435 l_ccid := AcctDerRule_6(
162436 p_application_id => p_application_id
162437 , p_ae_header_id => l_ae_header_id
162438 , p_source_11 => p_source_11
162439 , x_transaction_coa_id => l_adr_transaction_coa_id
162440 , x_accounting_coa_id => l_adr_accounting_coa_id
162441 , x_value_type_code => l_adr_value_type_code
162442 , p_side => 'NA'
162443 );
162444
162445 xla_ae_lines_pkg.set_ccid(
162446 p_code_combination_id => l_ccid
162447 , p_value_type_code => l_adr_value_type_code
162448 , p_transaction_coa_id => l_adr_transaction_coa_id
162449 , p_accounting_coa_id => l_adr_accounting_coa_id
162450 , p_adr_code => 'CST_DEFAULT'
162451 , p_adr_type_code => 'S'
162452 , p_component_type => l_component_type
162453 , p_component_code => l_component_code
162454 , p_component_type_code => l_component_type_code
162455 , p_component_appl_id => l_component_appl_id
162456 , p_amb_context_code => l_amb_context_code
162457 , p_side => 'NA'
162458 );
162459
162460
162461 --
162462 --
162463 END IF;
162464
162465 --
162466 -- Update the line information that should be overwritten
162467 --
162468 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
162469 p_header_num => 1);
162470 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
162471
162472 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
162473
162474 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
162475 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
162476 END IF;
162477
162478 --
162479 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
162480 --
162481 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
162482 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
162483 ELSE
162484 ---------------------------------------------------------------------------------------------------
162485 -- 4262811a Switch Sign
162486 ---------------------------------------------------------------------------------------------------
162487 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
162488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
162489 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
162490 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
162491 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
162492 -- 5132302
162493 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
162494 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
162495
162496 END IF;
162497
162498 -- 4955764
162499 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
162500 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
162501
162502
162503 XLA_AE_LINES_PKG.ValidateCurrentLine;
162504 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
162505
162506 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
162507 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
162508 ,p_balance_type_code => l_balance_type_code);
162509
162510 END IF;
162511
162512 -----------------------------------------------------------------------------------------
162513 -- 4262811 Multiperiod Accounting
162514 -----------------------------------------------------------------------------------------
162515 -- No MPA option is assigned.
162516
162517
162518 END IF;
162519 END IF;
162520 --
162521
162522 --
162523 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
162524 trace
162525 (p_msg => 'END of AcctLineType_301'
162526 ,p_level => C_LEVEL_PROCEDURE
162527 ,p_module => l_log_module);
162528 END IF;
162529 --
162530 EXCEPTION
162531 WHEN xla_exceptions_pkg.application_exception THEN
162532 RAISE;
162533 WHEN OTHERS THEN
162534 xla_exceptions_pkg.raise_message
162535 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_301');
162536 END AcctLineType_301;
162537 --
162538
162539 ---------------------------------------
162540 --
162541 -- PRIVATE FUNCTION
162542 -- AcctLineType_302
162543 --
162544 ---------------------------------------
162545 PROCEDURE AcctLineType_302 (
162546 p_application_id IN NUMBER
162547 ,p_event_id IN NUMBER
162548 ,p_calculate_acctd_flag IN VARCHAR2
162549 ,p_calculate_g_l_flag IN VARCHAR2
162550 ,p_actual_flag IN OUT VARCHAR2
162551 ,p_balance_type_code OUT VARCHAR2
162552 ,p_gain_or_loss_ref OUT VARCHAR2
162553
162554 --TRANSACTION_ID
162555 , p_source_1 IN NUMBER
162556 --Item Concatenated Segments
162557 , p_source_2 IN VARCHAR2
162558 --Transaction Quantity
162559 , p_source_3 IN NUMBER
162560 --Transaction Unit of Measure Code
162561 , p_source_4 IN VARCHAR2
162562 --Inventory Transaction Type Description
162563 , p_source_5 IN VARCHAR2
162564 --Cost Management Default Account
162565 , p_source_11 IN NUMBER
162566 --DISTRIBUTION_IDENTIFIER
162567 , p_source_84 IN NUMBER
162568 --Distribution Type
162569 , p_source_85 IN VARCHAR2
162570 , p_source_85_meaning IN VARCHAR2
162571 --Entered Currency Code
162572 , p_source_88 IN VARCHAR2
162573 --Entered Amount
162574 , p_source_91 IN NUMBER
162575 --Currency Conversion Date
162576 , p_source_92 IN DATE
162577 --Currency Conversion Rate
162578 , p_source_93 IN NUMBER
162579 --Currency Conversion Type
162580 , p_source_94 IN VARCHAR2
162581 --Accounted Amount
162582 , p_source_95 IN NUMBER
162583 --Accounting Line Type
162584 , p_source_97 IN NUMBER
162585 )
162586 IS
162587
162588 l_component_type VARCHAR2(80);
162589 l_component_code VARCHAR2(30);
162590 l_component_type_code VARCHAR2(1);
162591 l_component_appl_id INTEGER;
162592 l_amb_context_code VARCHAR2(30);
162593 l_entity_code VARCHAR2(30);
162594 l_event_class_code VARCHAR2(30);
162595 l_ae_header_id NUMBER;
162596 l_event_type_code VARCHAR2(30);
162597 l_line_definition_code VARCHAR2(30);
162598 l_line_definition_owner_code VARCHAR2(1);
162599 --
162600 -- adr variables
162601 l_segment VARCHAR2(30);
162602 l_ccid NUMBER;
162603 l_adr_transaction_coa_id NUMBER;
162604 l_adr_accounting_coa_id NUMBER;
162605 l_adr_flexfield_segment_code VARCHAR2(30);
162606 l_adr_flex_value_set_id NUMBER;
162607 l_adr_value_type_code VARCHAR2(30);
162608 l_adr_value_combination_id NUMBER;
162609 l_adr_value_segment_code VARCHAR2(30);
162610
162611 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
162612 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
162613 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
162614 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
162615
162616 -- 4262811 Variables ------------------------------------------------------------------------------------------
162617 l_entered_amt_idx NUMBER;
162618 l_accted_amt_idx NUMBER;
162619 l_acc_rev_flag VARCHAR2(1);
162620 l_accrual_line_num NUMBER;
162621 l_tmp_amt NUMBER;
162622 l_acc_rev_natural_side_code VARCHAR2(1);
162623
162624 l_num_entries NUMBER;
162625 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
162626 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
162627 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
162628 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
162629 l_recog_line_1 NUMBER;
162630 l_recog_line_2 NUMBER;
162631
162632 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
162633 l_bflow_applied_to_amt NUMBER; -- 5132302
162634 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
162635
162636 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
162637
162638 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
162639 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
162640
162641 ---------------------------------------------------------------------------------------------------------------
162642
162643
162644 --
162645 -- bulk performance
162646 --
162647 l_balance_type_code VARCHAR2(1);
162648 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
162649 l_log_module VARCHAR2(240);
162650
162651 --
162652 -- Upgrade strategy
162653 --
162654 l_actual_upg_option VARCHAR2(1);
162655 l_enc_upg_option VARCHAR2(1);
162656
162657 --
162658 BEGIN
162659 --
162660 IF g_log_enabled THEN
162661 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_302';
162662 END IF;
162663 --
162664 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
162665
162666 trace
162667 (p_msg => 'BEGIN of AcctLineType_302'
162668 ,p_level => C_LEVEL_PROCEDURE
162669 ,p_module => l_log_module);
162670
162671 END IF;
162672 --
162673 l_component_type := 'AMB_JLT';
162674 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
162675 l_component_type_code := 'S';
162676 l_component_appl_id := 707;
162677 l_amb_context_code := 'DEFAULT';
162678 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
162679 l_event_class_code := 'DIR_INTERORG_SHIP';
162680 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
162681 l_line_definition_owner_code := 'S';
162682 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
162683 --
162684 l_balance_type_code := 'A';
162685 l_segment := NULL;
162686 l_ccid := NULL;
162687 l_adr_transaction_coa_id := NULL;
162688 l_adr_accounting_coa_id := NULL;
162689 l_adr_flexfield_segment_code := NULL;
162690 l_adr_flex_value_set_id := NULL;
162691 l_adr_value_type_code := NULL;
162692 l_adr_value_combination_id := NULL;
162693 l_adr_value_segment_code := NULL;
162694
162695 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
162696 l_bflow_class_code := ''; -- 4219869 Business Flow
162697 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
162698 l_budgetary_control_flag := 'N';
162699
162700 l_bflow_applied_to_amt_idx := NULL; -- 5132302
162701 l_bflow_applied_to_amt := NULL; -- 5132302
162702 l_entered_amt_idx := NULL; -- 4262811
162703 l_accted_amt_idx := NULL; -- 4262811
162704 l_acc_rev_flag := NULL; -- 4262811
162705 l_accrual_line_num := NULL; -- 4262811
162706 l_tmp_amt := NULL; -- 4262811
162707 --
162708
162709 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
162710 l_balance_type_code <> 'B' THEN
162711 IF NVL(p_source_97,9E125) = 3
162712 THEN
162713
162714 --
162715 XLA_AE_LINES_PKG.SetNewLine;
162716
162717 p_balance_type_code := l_balance_type_code;
162718 -- set the flag so later we will know whether the gain loss line needs to be created
162719
162720 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
162721 p_actual_flag :='A';
162722 END IF;
162723
162724 --
162725 -- bulk performance
162726 --
162727 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
162728 p_header_num => 0); -- 4262811
162729 --
162730 -- set accounting line options
162731 --
162732 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
162733 p_natural_side_code => 'D'
162734 , p_gain_or_loss_flag => 'N'
162735 , p_gl_transfer_mode_code => 'S'
162736 , p_acct_entry_type_code => 'A'
162737 , p_switch_side_flag => 'Y'
162738 , p_merge_duplicate_code => 'N'
162739 );
162740 --
162741 l_acc_rev_natural_side_code := 'C'; -- 4262811
162742 --
162743 --
162744 -- set accounting line type info
162745 --
162746 xla_ae_lines_pkg.SetAcctLineType
162747 (p_component_type => l_component_type
162748 ,p_event_type_code => l_event_type_code
162749 ,p_line_definition_owner_code => l_line_definition_owner_code
162750 ,p_line_definition_code => l_line_definition_code
162751 ,p_accounting_line_code => l_component_code
162752 ,p_accounting_line_type_code => l_component_type_code
162753 ,p_accounting_line_appl_id => l_component_appl_id
162754 ,p_amb_context_code => l_amb_context_code
162755 ,p_entity_code => l_entity_code
162756 ,p_event_class_code => l_event_class_code);
162757 --
162758 -- set accounting class
162759 --
162760 xla_ae_lines_pkg.SetAcctClass(
162761 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
162762 , p_ae_header_id => l_ae_header_id
162763 );
162764
162765 --
162766 -- set rounding class
162767 --
162768 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
162769 'MATERIAL_OVERHEAD_ABSORPTION';
162770
162771 --
162772 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
162773 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
162774 --
162775 -- bulk performance
162776 --
162777 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
162778
162779 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
162780 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
162781
162782 -- 4955764
162783 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
162784 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
162785
162786 -- 4458381 Public Sector Enh
162787
162788 --
162789 -- set accounting attributes for the line type
162790 --
162791 l_entered_amt_idx := 3;
162792 l_accted_amt_idx := 8;
162793 l_bflow_applied_to_amt_idx := NULL; -- 5132302
162794 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
162795 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
162796 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
162797 l_rec_acct_attrs.array_char_value(2) := p_source_85;
162798 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
162799 l_rec_acct_attrs.array_num_value(3) := p_source_91;
162800 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
162801 l_rec_acct_attrs.array_char_value(4) := p_source_88;
162802 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
162803 l_rec_acct_attrs.array_date_value(5) := p_source_92;
162804 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
162805 l_rec_acct_attrs.array_num_value(6) := p_source_93;
162806 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
162807 l_rec_acct_attrs.array_char_value(7) := p_source_94;
162808 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
162809 l_rec_acct_attrs.array_num_value(8) := p_source_95;
162810
162811 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
162812 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
162813
162814 ---------------------------------------------------------------------------------------------------------------
162815 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
162816 ---------------------------------------------------------------------------------------------------------------
162817 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
162818
162819 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
162820 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
162821
162822 IF xla_accounting_cache_pkg.GetValueChar
162823 (p_source_code => 'LEDGER_CATEGORY_CODE'
162824 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
162825 AND l_bflow_method_code = 'PRIOR_ENTRY'
162826 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
162827 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
162828 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
162829 )
162830 THEN
162831 xla_ae_lines_pkg.BflowUpgEntry
162832 (p_business_method_code => l_bflow_method_code
162833 ,p_business_class_code => l_bflow_class_code
162834 ,p_balance_type => l_balance_type_code);
162835 ELSE
162836 NULL;
162837 -- No business flow processing for business flow method of NONE.
162838 END IF;
162839
162840 --
162841 -- call analytical criteria
162842 --
162843
162844 --
162845 -- call description
162846 --
162847
162848 xla_ae_lines_pkg.SetLineDescription(
162849 p_ae_header_id => l_ae_header_id
162850 ,p_description => Description_1 (
162851 p_application_id => p_application_id
162852 , p_ae_header_id => l_ae_header_id
162853 , p_source_1 => p_source_1
162854 , p_source_2 => p_source_2
162855 , p_source_3 => p_source_3
162856 , p_source_4 => p_source_4
162857 , p_source_5 => p_source_5
162858 )
162859 );
162860
162861
162862 --
162863 -- call ADRs
162864 -- Bug 4922099
162865 --
162866 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
162867 (NVL(l_actual_upg_option, 'N') = 'O') OR
162868 (NVL(l_enc_upg_option, 'N') = 'O')
162869 )
162870 THEN
162871 NULL;
162872 --
162873 --
162874
162875 l_ccid := AcctDerRule_6(
162876 p_application_id => p_application_id
162877 , p_ae_header_id => l_ae_header_id
162878 , p_source_11 => p_source_11
162879 , x_transaction_coa_id => l_adr_transaction_coa_id
162880 , x_accounting_coa_id => l_adr_accounting_coa_id
162881 , x_value_type_code => l_adr_value_type_code
162882 , p_side => 'NA'
162883 );
162884
162885 xla_ae_lines_pkg.set_ccid(
162886 p_code_combination_id => l_ccid
162887 , p_value_type_code => l_adr_value_type_code
162888 , p_transaction_coa_id => l_adr_transaction_coa_id
162889 , p_accounting_coa_id => l_adr_accounting_coa_id
162890 , p_adr_code => 'CST_DEFAULT'
162891 , p_adr_type_code => 'S'
162892 , p_component_type => l_component_type
162893 , p_component_code => l_component_code
162894 , p_component_type_code => l_component_type_code
162895 , p_component_appl_id => l_component_appl_id
162896 , p_amb_context_code => l_amb_context_code
162897 , p_side => 'NA'
162898 );
162899
162900
162901 --
162902 --
162903 END IF;
162904 --
162905 -- Bug 4922099
162906 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
162907 (NVL(l_enc_upg_option, 'N') = 'O')
162908 ) AND
162909 (l_bflow_method_code = 'PRIOR_ENTRY')
162910 )
162911 THEN
162912 IF
162913 --
162914 1 = 2
162915 --
162916 THEN
162917 xla_accounting_err_pkg.build_message
162918 (p_appli_s_name => 'XLA'
162919 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
162920 ,p_token_1 => 'LINE_NUMBER'
162921 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
162922 ,p_token_2 => 'LINE_TYPE_NAME'
162923 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
162924 l_component_type
162925 ,l_component_code
162926 ,l_component_type_code
162927 ,l_component_appl_id
162928 ,l_amb_context_code
162929 ,l_entity_code
162930 ,l_event_class_code
162931 )
162932 ,p_token_3 => 'OWNER'
162933 ,p_value_3 => xla_lookups_pkg.get_meaning(
162934 p_lookup_type => 'XLA_OWNER_TYPE'
162935 ,p_lookup_code => l_component_type_code
162936 )
162937 ,p_token_4 => 'PRODUCT_NAME'
162938 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
162939 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
162940 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
162941 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
162942 ,p_ae_header_id => NULL
162943 );
162944
162945 IF (C_LEVEL_ERROR>= g_log_level) THEN
162946 trace
162947 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
162948 ,p_level => C_LEVEL_ERROR
162949 ,p_module => l_log_module);
162950 END IF;
162951 END IF;
162952 END IF;
162953 --
162954 --
162955 ------------------------------------------------------------------------------------------------
162956 -- 4219869 Business Flow
162957 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
162958 -- Prior Entry. Currently, the following code is always generated.
162959 ------------------------------------------------------------------------------------------------
162960 XLA_AE_LINES_PKG.ValidateCurrentLine;
162961
162962 ------------------------------------------------------------------------------------
162963 -- 4219869 Business Flow
162964 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
162965 ------------------------------------------------------------------------------------
162966 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
162967
162968 ----------------------------------------------------------------------------------
162969 -- 4219869 Business Flow
162970 -- Update journal entry status -- Need to generate this within IF <condition>
162971 ----------------------------------------------------------------------------------
162972 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
162973 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
162974 ,p_balance_type_code => l_balance_type_code
162975 );
162976
162977 -------------------------------------------------------------------------------------------
162978 -- 4262811 - Generate the Accrual Reversal lines
162979 -------------------------------------------------------------------------------------------
162980 BEGIN
162981 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
162982 (g_array_event(p_event_id).array_value_num('header_index'));
162983 IF l_acc_rev_flag IS NULL THEN
162984 l_acc_rev_flag := 'N';
162985 END IF;
162986 EXCEPTION
162987 WHEN OTHERS THEN
162988 l_acc_rev_flag := 'N';
162989 END;
162990 --
162991 IF (l_acc_rev_flag = 'Y') THEN
162992
162993 -- 4645092 ------------------------------------------------------------------------------
162994 -- To allow MPA report to determine if it should generate report process
162995 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
162996 ------------------------------------------------------------------------------------------
162997
162998 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
162999 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
163000 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
163001 -- call ADRs
163002 -- Bug 4922099
163003 --
163004 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
163005 (NVL(l_actual_upg_option, 'N') = 'O') OR
163006 (NVL(l_enc_upg_option, 'N') = 'O')
163007 )
163008 THEN
163009 NULL;
163010 --
163011 --
163012
163013 l_ccid := AcctDerRule_6(
163014 p_application_id => p_application_id
163015 , p_ae_header_id => l_ae_header_id
163016 , p_source_11 => p_source_11
163017 , x_transaction_coa_id => l_adr_transaction_coa_id
163018 , x_accounting_coa_id => l_adr_accounting_coa_id
163019 , x_value_type_code => l_adr_value_type_code
163020 , p_side => 'NA'
163021 );
163022
163023 xla_ae_lines_pkg.set_ccid(
163024 p_code_combination_id => l_ccid
163025 , p_value_type_code => l_adr_value_type_code
163026 , p_transaction_coa_id => l_adr_transaction_coa_id
163027 , p_accounting_coa_id => l_adr_accounting_coa_id
163028 , p_adr_code => 'CST_DEFAULT'
163029 , p_adr_type_code => 'S'
163030 , p_component_type => l_component_type
163031 , p_component_code => l_component_code
163032 , p_component_type_code => l_component_type_code
163033 , p_component_appl_id => l_component_appl_id
163034 , p_amb_context_code => l_amb_context_code
163035 , p_side => 'NA'
163036 );
163037
163038
163039 --
163040 --
163041 END IF;
163042
163043 --
163044 -- Update the line information that should be overwritten
163045 --
163046 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
163047 p_header_num => 1);
163048 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
163049
163050 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
163051
163052 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
163053 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
163054 END IF;
163055
163056 --
163057 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
163058 --
163059 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
163060 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
163061 ELSE
163062 ---------------------------------------------------------------------------------------------------
163063 -- 4262811a Switch Sign
163064 ---------------------------------------------------------------------------------------------------
163065 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
163066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
163067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163068 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
163069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163070 -- 5132302
163071 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
163072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163073
163074 END IF;
163075
163076 -- 4955764
163077 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
163078 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
163079
163080
163081 XLA_AE_LINES_PKG.ValidateCurrentLine;
163082 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
163083
163084 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
163085 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
163086 ,p_balance_type_code => l_balance_type_code);
163087
163088 END IF;
163089
163090 -----------------------------------------------------------------------------------------
163091 -- 4262811 Multiperiod Accounting
163092 -----------------------------------------------------------------------------------------
163093 -- No MPA option is assigned.
163094
163095
163096 END IF;
163097 END IF;
163098 --
163099
163100 --
163101 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
163102 trace
163103 (p_msg => 'END of AcctLineType_302'
163104 ,p_level => C_LEVEL_PROCEDURE
163105 ,p_module => l_log_module);
163106 END IF;
163107 --
163108 EXCEPTION
163109 WHEN xla_exceptions_pkg.application_exception THEN
163110 RAISE;
163111 WHEN OTHERS THEN
163112 xla_exceptions_pkg.raise_message
163113 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_302');
163114 END AcctLineType_302;
163115 --
163116
163117 ---------------------------------------
163118 --
163119 -- PRIVATE FUNCTION
163120 -- AcctLineType_303
163121 --
163122 ---------------------------------------
163123 PROCEDURE AcctLineType_303 (
163124 p_application_id IN NUMBER
163125 ,p_event_id IN NUMBER
163126 ,p_calculate_acctd_flag IN VARCHAR2
163127 ,p_calculate_g_l_flag IN VARCHAR2
163128 ,p_actual_flag IN OUT VARCHAR2
163129 ,p_balance_type_code OUT VARCHAR2
163130 ,p_gain_or_loss_ref OUT VARCHAR2
163131
163132 --TRANSACTION_ID
163133 , p_source_1 IN NUMBER
163134 --Item Concatenated Segments
163135 , p_source_2 IN VARCHAR2
163136 --Transaction Quantity
163137 , p_source_3 IN NUMBER
163138 --Transaction Unit of Measure Code
163139 , p_source_4 IN VARCHAR2
163140 --Inventory Transaction Type Description
163141 , p_source_5 IN VARCHAR2
163142 --Cost Management Default Account
163143 , p_source_11 IN NUMBER
163144 --Applied to Application ID
163145 , p_source_79 IN NUMBER
163146 --Applied to Distribution Link Type
163147 , p_source_80 IN VARCHAR2
163148 --Applied to Entity Code
163149 , p_source_81 IN VARCHAR2
163150 --DISTRIBUTION_IDENTIFIER
163151 , p_source_84 IN NUMBER
163152 --Distribution Type
163153 , p_source_85 IN VARCHAR2
163154 , p_source_85_meaning IN VARCHAR2
163155 --Encumbrance Reversal Amount Entered
163156 , p_source_87 IN NUMBER
163157 --Entered Currency Code
163158 , p_source_88 IN VARCHAR2
163159 --Transaction Encumbrance Reversal Amount
163160 , p_source_89 IN NUMBER
163161 --Entered Amount
163162 , p_source_91 IN NUMBER
163163 --Currency Conversion Date
163164 , p_source_92 IN DATE
163165 --Currency Conversion Rate
163166 , p_source_93 IN NUMBER
163167 --Currency Conversion Type
163168 , p_source_94 IN VARCHAR2
163169 --Accounted Amount
163170 , p_source_95 IN NUMBER
163171 --Accounting Line Type
163172 , p_source_97 IN NUMBER
163173 --Costing Encumbrance Upgrade Option
163174 , p_source_100 IN VARCHAR2
163175 --TXN_PO_DISTRIBUTION_ID
163176 , p_source_101 IN NUMBER
163177 --TXN_PO_HEADER_ID
163178 , p_source_102 IN NUMBER
163179 --Requisition Budget Account
163180 , p_source_103 IN NUMBER
163181 --Requisition Encumbrance Type Identifier
163182 , p_source_104 IN NUMBER
163183 )
163184 IS
163185
163186 l_component_type VARCHAR2(80);
163187 l_component_code VARCHAR2(30);
163188 l_component_type_code VARCHAR2(1);
163189 l_component_appl_id INTEGER;
163190 l_amb_context_code VARCHAR2(30);
163191 l_entity_code VARCHAR2(30);
163192 l_event_class_code VARCHAR2(30);
163193 l_ae_header_id NUMBER;
163194 l_event_type_code VARCHAR2(30);
163195 l_line_definition_code VARCHAR2(30);
163196 l_line_definition_owner_code VARCHAR2(1);
163197 --
163198 -- adr variables
163199 l_segment VARCHAR2(30);
163200 l_ccid NUMBER;
163201 l_adr_transaction_coa_id NUMBER;
163202 l_adr_accounting_coa_id NUMBER;
163203 l_adr_flexfield_segment_code VARCHAR2(30);
163204 l_adr_flex_value_set_id NUMBER;
163205 l_adr_value_type_code VARCHAR2(30);
163206 l_adr_value_combination_id NUMBER;
163207 l_adr_value_segment_code VARCHAR2(30);
163208
163209 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
163210 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
163211 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
163212 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
163213
163214 -- 4262811 Variables ------------------------------------------------------------------------------------------
163215 l_entered_amt_idx NUMBER;
163216 l_accted_amt_idx NUMBER;
163217 l_acc_rev_flag VARCHAR2(1);
163218 l_accrual_line_num NUMBER;
163219 l_tmp_amt NUMBER;
163220 l_acc_rev_natural_side_code VARCHAR2(1);
163221
163222 l_num_entries NUMBER;
163223 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
163224 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
163225 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
163226 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
163227 l_recog_line_1 NUMBER;
163228 l_recog_line_2 NUMBER;
163229
163230 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
163231 l_bflow_applied_to_amt NUMBER; -- 5132302
163232 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
163233
163234 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
163235
163236 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
163237 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
163238
163239 ---------------------------------------------------------------------------------------------------------------
163240
163241
163242 --
163243 -- bulk performance
163244 --
163245 l_balance_type_code VARCHAR2(1);
163246 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
163247 l_log_module VARCHAR2(240);
163248
163249 --
163250 -- Upgrade strategy
163251 --
163252 l_actual_upg_option VARCHAR2(1);
163253 l_enc_upg_option VARCHAR2(1);
163254
163255 --
163256 BEGIN
163257 --
163258 IF g_log_enabled THEN
163259 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_303';
163260 END IF;
163261 --
163262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
163263
163264 trace
163265 (p_msg => 'BEGIN of AcctLineType_303'
163266 ,p_level => C_LEVEL_PROCEDURE
163267 ,p_module => l_log_module);
163268
163269 END IF;
163270 --
163271 l_component_type := 'AMB_JLT';
163272 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
163273 l_component_type_code := 'S';
163274 l_component_appl_id := 707;
163275 l_amb_context_code := 'DEFAULT';
163276 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
163277 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
163278 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
163279 l_line_definition_owner_code := 'S';
163280 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
163281 --
163282 l_balance_type_code := 'A';
163283 l_segment := NULL;
163284 l_ccid := NULL;
163285 l_adr_transaction_coa_id := NULL;
163286 l_adr_accounting_coa_id := NULL;
163287 l_adr_flexfield_segment_code := NULL;
163288 l_adr_flex_value_set_id := NULL;
163289 l_adr_value_type_code := NULL;
163290 l_adr_value_combination_id := NULL;
163291 l_adr_value_segment_code := NULL;
163292
163293 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
163294 l_bflow_class_code := ''; -- 4219869 Business Flow
163295 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
163296 l_budgetary_control_flag := 'N';
163297
163298 l_bflow_applied_to_amt_idx := NULL; -- 5132302
163299 l_bflow_applied_to_amt := NULL; -- 5132302
163300 l_entered_amt_idx := NULL; -- 4262811
163301 l_accted_amt_idx := NULL; -- 4262811
163302 l_acc_rev_flag := NULL; -- 4262811
163303 l_accrual_line_num := NULL; -- 4262811
163304 l_tmp_amt := NULL; -- 4262811
163305 --
163306
163307 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
163308 l_balance_type_code <> 'B' THEN
163309 IF NVL(p_source_97,9E125) = 3
163310 THEN
163311
163312 --
163313 XLA_AE_LINES_PKG.SetNewLine;
163314
163315 p_balance_type_code := l_balance_type_code;
163316 -- set the flag so later we will know whether the gain loss line needs to be created
163317
163318 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
163319 p_actual_flag :='A';
163320 END IF;
163321
163322 --
163323 -- bulk performance
163324 --
163325 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
163326 p_header_num => 0); -- 4262811
163327 --
163328 -- set accounting line options
163329 --
163330 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
163331 p_natural_side_code => 'D'
163332 , p_gain_or_loss_flag => 'N'
163333 , p_gl_transfer_mode_code => 'S'
163334 , p_acct_entry_type_code => 'A'
163335 , p_switch_side_flag => 'Y'
163336 , p_merge_duplicate_code => 'N'
163337 );
163338 --
163339 l_acc_rev_natural_side_code := 'C'; -- 4262811
163340 --
163341 --
163342 -- set accounting line type info
163343 --
163344 xla_ae_lines_pkg.SetAcctLineType
163345 (p_component_type => l_component_type
163346 ,p_event_type_code => l_event_type_code
163347 ,p_line_definition_owner_code => l_line_definition_owner_code
163348 ,p_line_definition_code => l_line_definition_code
163349 ,p_accounting_line_code => l_component_code
163350 ,p_accounting_line_type_code => l_component_type_code
163351 ,p_accounting_line_appl_id => l_component_appl_id
163352 ,p_amb_context_code => l_amb_context_code
163353 ,p_entity_code => l_entity_code
163354 ,p_event_class_code => l_event_class_code);
163355 --
163356 -- set accounting class
163357 --
163358 xla_ae_lines_pkg.SetAcctClass(
163359 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
163360 , p_ae_header_id => l_ae_header_id
163361 );
163362
163363 --
163364 -- set rounding class
163365 --
163366 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
163367 'MATERIAL_OVERHEAD_ABSORPTION';
163368
163369 --
163370 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
163371 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
163372 --
163373 -- bulk performance
163374 --
163375 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
163376
163377 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
163378 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
163379
163380 -- 4955764
163381 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
163382 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
163383
163384 -- 4458381 Public Sector Enh
163385
163386 --
163387 -- set accounting attributes for the line type
163388 --
163389 l_entered_amt_idx := 17;
163390 l_accted_amt_idx := 22;
163391 l_bflow_applied_to_amt_idx := NULL; -- 5132302
163392 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
163393 l_rec_acct_attrs.array_num_value(1) := p_source_79;
163394 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
163395 l_rec_acct_attrs.array_char_value(2) := p_source_80;
163396 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
163397 l_rec_acct_attrs.array_char_value(3) := p_source_81;
163398 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
163399 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
163400 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
163401 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
163402 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
163403 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
163404 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
163405 l_rec_acct_attrs.array_char_value(7) := p_source_85;
163406 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
163407 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
163408 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
163409 l_rec_acct_attrs.array_num_value(9) := p_source_87;
163410 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
163411 l_rec_acct_attrs.array_char_value(10) := p_source_88;
163412 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
163413 l_rec_acct_attrs.array_num_value(11) := p_source_89;
163414 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
163415 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
163416 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
163417 l_rec_acct_attrs.array_num_value(13) := p_source_87;
163418 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
163419 l_rec_acct_attrs.array_char_value(14) := p_source_88;
163420 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
163421 l_rec_acct_attrs.array_num_value(15) := p_source_89;
163422 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
163423 l_rec_acct_attrs.array_char_value(16) := p_source_100;
163424 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
163425 l_rec_acct_attrs.array_num_value(17) := p_source_91;
163426 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
163427 l_rec_acct_attrs.array_char_value(18) := p_source_88;
163428 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
163429 l_rec_acct_attrs.array_date_value(19) := p_source_92;
163430 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
163431 l_rec_acct_attrs.array_num_value(20) := p_source_93;
163432 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
163433 l_rec_acct_attrs.array_char_value(21) := p_source_94;
163434 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
163435 l_rec_acct_attrs.array_num_value(22) := p_source_95;
163436 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
163437 l_rec_acct_attrs.array_num_value(23) := p_source_104;
163438 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
163439 l_rec_acct_attrs.array_num_value(24) := p_source_104;
163440
163441 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
163442 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
163443
163444 ---------------------------------------------------------------------------------------------------------------
163445 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
163446 ---------------------------------------------------------------------------------------------------------------
163447 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
163448
163449 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
163450 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
163451
163452 IF xla_accounting_cache_pkg.GetValueChar
163453 (p_source_code => 'LEDGER_CATEGORY_CODE'
163454 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
163455 AND l_bflow_method_code = 'PRIOR_ENTRY'
163456 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
163457 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
163458 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
163459 )
163460 THEN
163461 xla_ae_lines_pkg.BflowUpgEntry
163462 (p_business_method_code => l_bflow_method_code
163463 ,p_business_class_code => l_bflow_class_code
163464 ,p_balance_type => l_balance_type_code);
163465 ELSE
163466 NULL;
163467 -- No business flow processing for business flow method of NONE.
163468 END IF;
163469
163470 --
163471 -- call analytical criteria
163472 --
163473
163474 --
163475 -- call description
163476 --
163477
163478 xla_ae_lines_pkg.SetLineDescription(
163479 p_ae_header_id => l_ae_header_id
163480 ,p_description => Description_1 (
163481 p_application_id => p_application_id
163482 , p_ae_header_id => l_ae_header_id
163483 , p_source_1 => p_source_1
163484 , p_source_2 => p_source_2
163485 , p_source_3 => p_source_3
163486 , p_source_4 => p_source_4
163487 , p_source_5 => p_source_5
163488 )
163489 );
163490
163491
163492 --
163493 -- call ADRs
163494 -- Bug 4922099
163495 --
163496 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
163497 (NVL(l_actual_upg_option, 'N') = 'O') OR
163498 (NVL(l_enc_upg_option, 'N') = 'O')
163499 )
163500 THEN
163501 NULL;
163502 --
163503 --
163504
163505 l_ccid := AcctDerRule_6(
163506 p_application_id => p_application_id
163507 , p_ae_header_id => l_ae_header_id
163508 , p_source_11 => p_source_11
163509 , x_transaction_coa_id => l_adr_transaction_coa_id
163510 , x_accounting_coa_id => l_adr_accounting_coa_id
163511 , x_value_type_code => l_adr_value_type_code
163512 , p_side => 'NA'
163513 );
163514
163515 xla_ae_lines_pkg.set_ccid(
163516 p_code_combination_id => l_ccid
163517 , p_value_type_code => l_adr_value_type_code
163518 , p_transaction_coa_id => l_adr_transaction_coa_id
163519 , p_accounting_coa_id => l_adr_accounting_coa_id
163520 , p_adr_code => 'CST_DEFAULT'
163521 , p_adr_type_code => 'S'
163522 , p_component_type => l_component_type
163523 , p_component_code => l_component_code
163524 , p_component_type_code => l_component_type_code
163525 , p_component_appl_id => l_component_appl_id
163526 , p_amb_context_code => l_amb_context_code
163527 , p_side => 'NA'
163528 );
163529
163530
163531 --
163532 --
163533 END IF;
163534 --
163535 -- Bug 4922099
163536 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
163537 (NVL(l_enc_upg_option, 'N') = 'O')
163538 ) AND
163539 (l_bflow_method_code = 'PRIOR_ENTRY')
163540 )
163541 THEN
163542 IF
163543 --
163544 1 = 2
163545 --
163546 THEN
163547 xla_accounting_err_pkg.build_message
163548 (p_appli_s_name => 'XLA'
163549 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
163550 ,p_token_1 => 'LINE_NUMBER'
163551 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
163552 ,p_token_2 => 'LINE_TYPE_NAME'
163553 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
163554 l_component_type
163555 ,l_component_code
163556 ,l_component_type_code
163557 ,l_component_appl_id
163558 ,l_amb_context_code
163559 ,l_entity_code
163560 ,l_event_class_code
163561 )
163562 ,p_token_3 => 'OWNER'
163563 ,p_value_3 => xla_lookups_pkg.get_meaning(
163564 p_lookup_type => 'XLA_OWNER_TYPE'
163565 ,p_lookup_code => l_component_type_code
163566 )
163567 ,p_token_4 => 'PRODUCT_NAME'
163568 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
163569 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
163570 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
163571 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
163572 ,p_ae_header_id => NULL
163573 );
163574
163575 IF (C_LEVEL_ERROR>= g_log_level) THEN
163576 trace
163577 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
163578 ,p_level => C_LEVEL_ERROR
163579 ,p_module => l_log_module);
163580 END IF;
163581 END IF;
163582 END IF;
163583 --
163584 --
163585 ------------------------------------------------------------------------------------------------
163586 -- 4219869 Business Flow
163587 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
163588 -- Prior Entry. Currently, the following code is always generated.
163589 ------------------------------------------------------------------------------------------------
163590 XLA_AE_LINES_PKG.ValidateCurrentLine;
163591
163592 ------------------------------------------------------------------------------------
163593 -- 4219869 Business Flow
163594 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
163595 ------------------------------------------------------------------------------------
163596 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
163597
163598 ----------------------------------------------------------------------------------
163599 -- 4219869 Business Flow
163600 -- Update journal entry status -- Need to generate this within IF <condition>
163601 ----------------------------------------------------------------------------------
163602 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
163603 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
163604 ,p_balance_type_code => l_balance_type_code
163605 );
163606
163607 -------------------------------------------------------------------------------------------
163608 -- 4262811 - Generate the Accrual Reversal lines
163609 -------------------------------------------------------------------------------------------
163610 BEGIN
163611 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
163612 (g_array_event(p_event_id).array_value_num('header_index'));
163613 IF l_acc_rev_flag IS NULL THEN
163614 l_acc_rev_flag := 'N';
163615 END IF;
163616 EXCEPTION
163617 WHEN OTHERS THEN
163618 l_acc_rev_flag := 'N';
163619 END;
163620 --
163621 IF (l_acc_rev_flag = 'Y') THEN
163622
163623 -- 4645092 ------------------------------------------------------------------------------
163624 -- To allow MPA report to determine if it should generate report process
163625 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
163626 ------------------------------------------------------------------------------------------
163627
163628 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
163629 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
163630 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
163631 -- call ADRs
163632 -- Bug 4922099
163633 --
163634 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
163635 (NVL(l_actual_upg_option, 'N') = 'O') OR
163636 (NVL(l_enc_upg_option, 'N') = 'O')
163637 )
163638 THEN
163639 NULL;
163640 --
163641 --
163642
163643 l_ccid := AcctDerRule_6(
163644 p_application_id => p_application_id
163645 , p_ae_header_id => l_ae_header_id
163646 , p_source_11 => p_source_11
163647 , x_transaction_coa_id => l_adr_transaction_coa_id
163648 , x_accounting_coa_id => l_adr_accounting_coa_id
163649 , x_value_type_code => l_adr_value_type_code
163650 , p_side => 'NA'
163651 );
163652
163653 xla_ae_lines_pkg.set_ccid(
163654 p_code_combination_id => l_ccid
163655 , p_value_type_code => l_adr_value_type_code
163656 , p_transaction_coa_id => l_adr_transaction_coa_id
163657 , p_accounting_coa_id => l_adr_accounting_coa_id
163658 , p_adr_code => 'CST_DEFAULT'
163659 , p_adr_type_code => 'S'
163660 , p_component_type => l_component_type
163661 , p_component_code => l_component_code
163662 , p_component_type_code => l_component_type_code
163663 , p_component_appl_id => l_component_appl_id
163664 , p_amb_context_code => l_amb_context_code
163665 , p_side => 'NA'
163666 );
163667
163668
163669 --
163670 --
163671 END IF;
163672
163673 --
163674 -- Update the line information that should be overwritten
163675 --
163676 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
163677 p_header_num => 1);
163678 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
163679
163680 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
163681
163682 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
163683 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
163684 END IF;
163685
163686 --
163687 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
163688 --
163689 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
163690 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
163691 ELSE
163692 ---------------------------------------------------------------------------------------------------
163693 -- 4262811a Switch Sign
163694 ---------------------------------------------------------------------------------------------------
163695 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
163696 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
163697 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163698 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
163699 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163700 -- 5132302
163701 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
163702 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
163703
163704 END IF;
163705
163706 -- 4955764
163707 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
163708 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
163709
163710
163711 XLA_AE_LINES_PKG.ValidateCurrentLine;
163712 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
163713
163714 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
163715 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
163716 ,p_balance_type_code => l_balance_type_code);
163717
163718 END IF;
163719
163720 -----------------------------------------------------------------------------------------
163721 -- 4262811 Multiperiod Accounting
163722 -----------------------------------------------------------------------------------------
163723 -- No MPA option is assigned.
163724
163725
163726 END IF;
163727 END IF;
163728 --
163729
163730 --
163731 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
163732 trace
163733 (p_msg => 'END of AcctLineType_303'
163734 ,p_level => C_LEVEL_PROCEDURE
163735 ,p_module => l_log_module);
163736 END IF;
163737 --
163738 EXCEPTION
163739 WHEN xla_exceptions_pkg.application_exception THEN
163740 RAISE;
163741 WHEN OTHERS THEN
163742 xla_exceptions_pkg.raise_message
163743 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_303');
163744 END AcctLineType_303;
163745 --
163746
163747 ---------------------------------------
163748 --
163749 -- PRIVATE FUNCTION
163750 -- AcctLineType_304
163751 --
163752 ---------------------------------------
163753 PROCEDURE AcctLineType_304 (
163754 p_application_id IN NUMBER
163755 ,p_event_id IN NUMBER
163756 ,p_calculate_acctd_flag IN VARCHAR2
163757 ,p_calculate_g_l_flag IN VARCHAR2
163758 ,p_actual_flag IN OUT VARCHAR2
163759 ,p_balance_type_code OUT VARCHAR2
163760 ,p_gain_or_loss_ref OUT VARCHAR2
163761
163762 --Cost Management Default Account
163763 , p_source_11 IN NUMBER
163764 --DISTRIBUTION_IDENTIFIER
163765 , p_source_84 IN NUMBER
163766 --Distribution Type
163767 , p_source_85 IN VARCHAR2
163768 , p_source_85_meaning IN VARCHAR2
163769 --Entered Currency Code
163770 , p_source_88 IN VARCHAR2
163771 --Entered Amount
163772 , p_source_91 IN NUMBER
163773 --Currency Conversion Date
163774 , p_source_92 IN DATE
163775 --Currency Conversion Rate
163776 , p_source_93 IN NUMBER
163777 --Currency Conversion Type
163778 , p_source_94 IN VARCHAR2
163779 --Accounted Amount
163780 , p_source_95 IN NUMBER
163781 --Accounting Line Type
163782 , p_source_97 IN NUMBER
163783 )
163784 IS
163785
163786 l_component_type VARCHAR2(80);
163787 l_component_code VARCHAR2(30);
163788 l_component_type_code VARCHAR2(1);
163789 l_component_appl_id INTEGER;
163790 l_amb_context_code VARCHAR2(30);
163791 l_entity_code VARCHAR2(30);
163792 l_event_class_code VARCHAR2(30);
163793 l_ae_header_id NUMBER;
163794 l_event_type_code VARCHAR2(30);
163795 l_line_definition_code VARCHAR2(30);
163796 l_line_definition_owner_code VARCHAR2(1);
163797 --
163798 -- adr variables
163799 l_segment VARCHAR2(30);
163800 l_ccid NUMBER;
163801 l_adr_transaction_coa_id NUMBER;
163802 l_adr_accounting_coa_id NUMBER;
163803 l_adr_flexfield_segment_code VARCHAR2(30);
163804 l_adr_flex_value_set_id NUMBER;
163805 l_adr_value_type_code VARCHAR2(30);
163806 l_adr_value_combination_id NUMBER;
163807 l_adr_value_segment_code VARCHAR2(30);
163808
163809 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
163810 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
163811 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
163812 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
163813
163814 -- 4262811 Variables ------------------------------------------------------------------------------------------
163815 l_entered_amt_idx NUMBER;
163816 l_accted_amt_idx NUMBER;
163817 l_acc_rev_flag VARCHAR2(1);
163818 l_accrual_line_num NUMBER;
163819 l_tmp_amt NUMBER;
163820 l_acc_rev_natural_side_code VARCHAR2(1);
163821
163822 l_num_entries NUMBER;
163823 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
163824 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
163825 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
163826 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
163827 l_recog_line_1 NUMBER;
163828 l_recog_line_2 NUMBER;
163829
163830 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
163831 l_bflow_applied_to_amt NUMBER; -- 5132302
163832 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
163833
163834 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
163835
163836 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
163837 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
163838
163839 ---------------------------------------------------------------------------------------------------------------
163840
163841
163842 --
163843 -- bulk performance
163844 --
163845 l_balance_type_code VARCHAR2(1);
163846 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
163847 l_log_module VARCHAR2(240);
163848
163849 --
163850 -- Upgrade strategy
163851 --
163852 l_actual_upg_option VARCHAR2(1);
163853 l_enc_upg_option VARCHAR2(1);
163854
163855 --
163856 BEGIN
163857 --
163858 IF g_log_enabled THEN
163859 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_304';
163860 END IF;
163861 --
163862 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
163863
163864 trace
163865 (p_msg => 'BEGIN of AcctLineType_304'
163866 ,p_level => C_LEVEL_PROCEDURE
163867 ,p_module => l_log_module);
163868
163869 END IF;
163870 --
163871 l_component_type := 'AMB_JLT';
163872 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
163873 l_component_type_code := 'S';
163874 l_component_appl_id := 707;
163875 l_amb_context_code := 'DEFAULT';
163876 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
163877 l_event_class_code := 'USER_DEFINE';
163878 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
163879 l_line_definition_owner_code := 'S';
163880 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
163881 --
163882 l_balance_type_code := 'A';
163883 l_segment := NULL;
163884 l_ccid := NULL;
163885 l_adr_transaction_coa_id := NULL;
163886 l_adr_accounting_coa_id := NULL;
163887 l_adr_flexfield_segment_code := NULL;
163888 l_adr_flex_value_set_id := NULL;
163889 l_adr_value_type_code := NULL;
163890 l_adr_value_combination_id := NULL;
163891 l_adr_value_segment_code := NULL;
163892
163893 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
163894 l_bflow_class_code := ''; -- 4219869 Business Flow
163895 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
163896 l_budgetary_control_flag := 'N';
163897
163898 l_bflow_applied_to_amt_idx := NULL; -- 5132302
163899 l_bflow_applied_to_amt := NULL; -- 5132302
163900 l_entered_amt_idx := NULL; -- 4262811
163901 l_accted_amt_idx := NULL; -- 4262811
163902 l_acc_rev_flag := NULL; -- 4262811
163903 l_accrual_line_num := NULL; -- 4262811
163904 l_tmp_amt := NULL; -- 4262811
163905 --
163906
163907 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
163908 l_balance_type_code <> 'B' THEN
163909 IF NVL(p_source_97,9E125) = 3
163910 THEN
163911
163912 --
163913 XLA_AE_LINES_PKG.SetNewLine;
163914
163915 p_balance_type_code := l_balance_type_code;
163916 -- set the flag so later we will know whether the gain loss line needs to be created
163917
163918 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
163919 p_actual_flag :='A';
163920 END IF;
163921
163922 --
163923 -- bulk performance
163924 --
163925 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
163926 p_header_num => 0); -- 4262811
163927 --
163928 -- set accounting line options
163929 --
163930 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
163931 p_natural_side_code => 'D'
163932 , p_gain_or_loss_flag => 'N'
163933 , p_gl_transfer_mode_code => 'S'
163934 , p_acct_entry_type_code => 'A'
163935 , p_switch_side_flag => 'Y'
163936 , p_merge_duplicate_code => 'N'
163937 );
163938 --
163939 l_acc_rev_natural_side_code := 'C'; -- 4262811
163940 --
163941 --
163942 -- set accounting line type info
163943 --
163944 xla_ae_lines_pkg.SetAcctLineType
163945 (p_component_type => l_component_type
163946 ,p_event_type_code => l_event_type_code
163947 ,p_line_definition_owner_code => l_line_definition_owner_code
163948 ,p_line_definition_code => l_line_definition_code
163949 ,p_accounting_line_code => l_component_code
163950 ,p_accounting_line_type_code => l_component_type_code
163951 ,p_accounting_line_appl_id => l_component_appl_id
163952 ,p_amb_context_code => l_amb_context_code
163953 ,p_entity_code => l_entity_code
163954 ,p_event_class_code => l_event_class_code);
163955 --
163956 -- set accounting class
163957 --
163958 xla_ae_lines_pkg.SetAcctClass(
163959 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
163960 , p_ae_header_id => l_ae_header_id
163961 );
163962
163963 --
163964 -- set rounding class
163965 --
163966 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
163967 'MATERIAL_OVERHEAD_ABSORPTION';
163968
163969 --
163970 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
163971 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
163972 --
163973 -- bulk performance
163974 --
163975 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
163976
163977 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
163978 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
163979
163980 -- 4955764
163981 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
163982 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
163983
163984 -- 4458381 Public Sector Enh
163985
163986 --
163987 -- set accounting attributes for the line type
163988 --
163989 l_entered_amt_idx := 3;
163990 l_accted_amt_idx := 8;
163991 l_bflow_applied_to_amt_idx := NULL; -- 5132302
163992 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
163993 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
163994 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
163995 l_rec_acct_attrs.array_char_value(2) := p_source_85;
163996 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
163997 l_rec_acct_attrs.array_num_value(3) := p_source_91;
163998 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
163999 l_rec_acct_attrs.array_char_value(4) := p_source_88;
164000 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
164001 l_rec_acct_attrs.array_date_value(5) := p_source_92;
164002 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
164003 l_rec_acct_attrs.array_num_value(6) := p_source_93;
164004 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
164005 l_rec_acct_attrs.array_char_value(7) := p_source_94;
164006 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
164007 l_rec_acct_attrs.array_num_value(8) := p_source_95;
164008
164009 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
164010 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
164011
164012 ---------------------------------------------------------------------------------------------------------------
164013 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
164014 ---------------------------------------------------------------------------------------------------------------
164015 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
164016
164017 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
164018 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
164019
164020 IF xla_accounting_cache_pkg.GetValueChar
164021 (p_source_code => 'LEDGER_CATEGORY_CODE'
164022 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
164023 AND l_bflow_method_code = 'PRIOR_ENTRY'
164024 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
164025 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
164026 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
164027 )
164028 THEN
164029 xla_ae_lines_pkg.BflowUpgEntry
164030 (p_business_method_code => l_bflow_method_code
164031 ,p_business_class_code => l_bflow_class_code
164032 ,p_balance_type => l_balance_type_code);
164033 ELSE
164034 NULL;
164035 -- No business flow processing for business flow method of NONE.
164036 END IF;
164037
164038 --
164039 -- call analytical criteria
164040 --
164041
164042 --
164043 -- call description
164044 --
164045 -- No description or it is inherited.
164046 --
164047 -- call ADRs
164048 -- Bug 4922099
164049 --
164050 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
164051 (NVL(l_actual_upg_option, 'N') = 'O') OR
164052 (NVL(l_enc_upg_option, 'N') = 'O')
164053 )
164054 THEN
164055 NULL;
164056 --
164057 --
164058
164059 l_ccid := AcctDerRule_6(
164060 p_application_id => p_application_id
164061 , p_ae_header_id => l_ae_header_id
164062 , p_source_11 => p_source_11
164063 , x_transaction_coa_id => l_adr_transaction_coa_id
164064 , x_accounting_coa_id => l_adr_accounting_coa_id
164065 , x_value_type_code => l_adr_value_type_code
164066 , p_side => 'NA'
164067 );
164068
164069 xla_ae_lines_pkg.set_ccid(
164070 p_code_combination_id => l_ccid
164071 , p_value_type_code => l_adr_value_type_code
164072 , p_transaction_coa_id => l_adr_transaction_coa_id
164073 , p_accounting_coa_id => l_adr_accounting_coa_id
164074 , p_adr_code => 'CST_DEFAULT'
164075 , p_adr_type_code => 'S'
164076 , p_component_type => l_component_type
164077 , p_component_code => l_component_code
164078 , p_component_type_code => l_component_type_code
164079 , p_component_appl_id => l_component_appl_id
164080 , p_amb_context_code => l_amb_context_code
164081 , p_side => 'NA'
164082 );
164083
164084
164085 --
164086 --
164087 END IF;
164088 --
164089 -- Bug 4922099
164090 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
164091 (NVL(l_enc_upg_option, 'N') = 'O')
164092 ) AND
164093 (l_bflow_method_code = 'PRIOR_ENTRY')
164094 )
164095 THEN
164096 IF
164097 --
164098 1 = 2
164099 --
164100 THEN
164101 xla_accounting_err_pkg.build_message
164102 (p_appli_s_name => 'XLA'
164103 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
164104 ,p_token_1 => 'LINE_NUMBER'
164105 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
164106 ,p_token_2 => 'LINE_TYPE_NAME'
164107 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
164108 l_component_type
164109 ,l_component_code
164110 ,l_component_type_code
164111 ,l_component_appl_id
164112 ,l_amb_context_code
164113 ,l_entity_code
164114 ,l_event_class_code
164115 )
164116 ,p_token_3 => 'OWNER'
164117 ,p_value_3 => xla_lookups_pkg.get_meaning(
164118 p_lookup_type => 'XLA_OWNER_TYPE'
164119 ,p_lookup_code => l_component_type_code
164120 )
164121 ,p_token_4 => 'PRODUCT_NAME'
164122 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
164123 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
164124 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
164125 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
164126 ,p_ae_header_id => NULL
164127 );
164128
164129 IF (C_LEVEL_ERROR>= g_log_level) THEN
164130 trace
164131 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
164132 ,p_level => C_LEVEL_ERROR
164133 ,p_module => l_log_module);
164134 END IF;
164135 END IF;
164136 END IF;
164137 --
164138 --
164139 ------------------------------------------------------------------------------------------------
164140 -- 4219869 Business Flow
164141 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
164142 -- Prior Entry. Currently, the following code is always generated.
164143 ------------------------------------------------------------------------------------------------
164144 XLA_AE_LINES_PKG.ValidateCurrentLine;
164145
164146 ------------------------------------------------------------------------------------
164147 -- 4219869 Business Flow
164148 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
164149 ------------------------------------------------------------------------------------
164150 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
164151
164152 ----------------------------------------------------------------------------------
164153 -- 4219869 Business Flow
164154 -- Update journal entry status -- Need to generate this within IF <condition>
164155 ----------------------------------------------------------------------------------
164156 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
164157 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
164158 ,p_balance_type_code => l_balance_type_code
164159 );
164160
164161 -------------------------------------------------------------------------------------------
164162 -- 4262811 - Generate the Accrual Reversal lines
164163 -------------------------------------------------------------------------------------------
164164 BEGIN
164165 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
164166 (g_array_event(p_event_id).array_value_num('header_index'));
164167 IF l_acc_rev_flag IS NULL THEN
164168 l_acc_rev_flag := 'N';
164169 END IF;
164170 EXCEPTION
164171 WHEN OTHERS THEN
164172 l_acc_rev_flag := 'N';
164173 END;
164174 --
164175 IF (l_acc_rev_flag = 'Y') THEN
164176
164177 -- 4645092 ------------------------------------------------------------------------------
164178 -- To allow MPA report to determine if it should generate report process
164179 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
164180 ------------------------------------------------------------------------------------------
164181
164182 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
164183 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
164184 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
164185 -- call ADRs
164186 -- Bug 4922099
164187 --
164188 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
164189 (NVL(l_actual_upg_option, 'N') = 'O') OR
164190 (NVL(l_enc_upg_option, 'N') = 'O')
164191 )
164192 THEN
164193 NULL;
164194 --
164195 --
164196
164197 l_ccid := AcctDerRule_6(
164198 p_application_id => p_application_id
164199 , p_ae_header_id => l_ae_header_id
164200 , p_source_11 => p_source_11
164201 , x_transaction_coa_id => l_adr_transaction_coa_id
164202 , x_accounting_coa_id => l_adr_accounting_coa_id
164203 , x_value_type_code => l_adr_value_type_code
164204 , p_side => 'NA'
164205 );
164206
164207 xla_ae_lines_pkg.set_ccid(
164208 p_code_combination_id => l_ccid
164209 , p_value_type_code => l_adr_value_type_code
164210 , p_transaction_coa_id => l_adr_transaction_coa_id
164211 , p_accounting_coa_id => l_adr_accounting_coa_id
164212 , p_adr_code => 'CST_DEFAULT'
164213 , p_adr_type_code => 'S'
164214 , p_component_type => l_component_type
164215 , p_component_code => l_component_code
164216 , p_component_type_code => l_component_type_code
164217 , p_component_appl_id => l_component_appl_id
164218 , p_amb_context_code => l_amb_context_code
164219 , p_side => 'NA'
164220 );
164221
164222
164223 --
164224 --
164225 END IF;
164226
164227 --
164228 -- Update the line information that should be overwritten
164229 --
164230 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
164231 p_header_num => 1);
164232 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
164233
164234 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
164235
164236 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
164237 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
164238 END IF;
164239
164240 --
164241 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
164242 --
164243 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
164244 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
164245 ELSE
164246 ---------------------------------------------------------------------------------------------------
164247 -- 4262811a Switch Sign
164248 ---------------------------------------------------------------------------------------------------
164249 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
164250 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
164251 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164252 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
164253 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164254 -- 5132302
164255 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
164256 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164257
164258 END IF;
164259
164260 -- 4955764
164261 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
164262 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
164263
164264
164265 XLA_AE_LINES_PKG.ValidateCurrentLine;
164266 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
164267
164268 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
164269 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
164270 ,p_balance_type_code => l_balance_type_code);
164271
164272 END IF;
164273
164274 -----------------------------------------------------------------------------------------
164275 -- 4262811 Multiperiod Accounting
164276 -----------------------------------------------------------------------------------------
164277 -- No MPA option is assigned.
164278
164279
164280 END IF;
164281 END IF;
164282 --
164283
164284 --
164285 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
164286 trace
164287 (p_msg => 'END of AcctLineType_304'
164288 ,p_level => C_LEVEL_PROCEDURE
164289 ,p_module => l_log_module);
164290 END IF;
164291 --
164292 EXCEPTION
164293 WHEN xla_exceptions_pkg.application_exception THEN
164294 RAISE;
164295 WHEN OTHERS THEN
164296 xla_exceptions_pkg.raise_message
164297 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_304');
164298 END AcctLineType_304;
164299 --
164300
164301 ---------------------------------------
164302 --
164303 -- PRIVATE FUNCTION
164304 -- AcctLineType_305
164305 --
164306 ---------------------------------------
164307 PROCEDURE AcctLineType_305 (
164308 p_application_id IN NUMBER
164309 ,p_event_id IN NUMBER
164310 ,p_calculate_acctd_flag IN VARCHAR2
164311 ,p_calculate_g_l_flag IN VARCHAR2
164312 ,p_actual_flag IN OUT VARCHAR2
164313 ,p_balance_type_code OUT VARCHAR2
164314 ,p_gain_or_loss_ref OUT VARCHAR2
164315
164316 --TRANSACTION_ID
164317 , p_source_1 IN NUMBER
164318 --Item Concatenated Segments
164319 , p_source_2 IN VARCHAR2
164320 --Transaction Quantity
164321 , p_source_3 IN NUMBER
164322 --Transaction Unit of Measure Code
164323 , p_source_4 IN VARCHAR2
164324 --Inventory Transaction Type Description
164325 , p_source_5 IN VARCHAR2
164326 --Cost Management Default Account
164327 , p_source_11 IN NUMBER
164328 --DISTRIBUTION_IDENTIFIER
164329 , p_source_84 IN NUMBER
164330 --Distribution Type
164331 , p_source_85 IN VARCHAR2
164332 , p_source_85_meaning IN VARCHAR2
164333 --Entered Currency Code
164334 , p_source_88 IN VARCHAR2
164335 --Entered Amount
164336 , p_source_91 IN NUMBER
164337 --Currency Conversion Date
164338 , p_source_92 IN DATE
164339 --Currency Conversion Rate
164340 , p_source_93 IN NUMBER
164341 --Currency Conversion Type
164342 , p_source_94 IN VARCHAR2
164343 --Accounted Amount
164344 , p_source_95 IN NUMBER
164345 --Accounting Line Type
164346 , p_source_97 IN NUMBER
164347 )
164348 IS
164349
164350 l_component_type VARCHAR2(80);
164351 l_component_code VARCHAR2(30);
164352 l_component_type_code VARCHAR2(1);
164353 l_component_appl_id INTEGER;
164354 l_amb_context_code VARCHAR2(30);
164355 l_entity_code VARCHAR2(30);
164356 l_event_class_code VARCHAR2(30);
164357 l_ae_header_id NUMBER;
164358 l_event_type_code VARCHAR2(30);
164359 l_line_definition_code VARCHAR2(30);
164360 l_line_definition_owner_code VARCHAR2(1);
164361 --
164362 -- adr variables
164363 l_segment VARCHAR2(30);
164364 l_ccid NUMBER;
164365 l_adr_transaction_coa_id NUMBER;
164366 l_adr_accounting_coa_id NUMBER;
164367 l_adr_flexfield_segment_code VARCHAR2(30);
164368 l_adr_flex_value_set_id NUMBER;
164369 l_adr_value_type_code VARCHAR2(30);
164370 l_adr_value_combination_id NUMBER;
164371 l_adr_value_segment_code VARCHAR2(30);
164372
164373 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
164374 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
164375 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
164376 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
164377
164378 -- 4262811 Variables ------------------------------------------------------------------------------------------
164379 l_entered_amt_idx NUMBER;
164380 l_accted_amt_idx NUMBER;
164381 l_acc_rev_flag VARCHAR2(1);
164382 l_accrual_line_num NUMBER;
164383 l_tmp_amt NUMBER;
164384 l_acc_rev_natural_side_code VARCHAR2(1);
164385
164386 l_num_entries NUMBER;
164387 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
164388 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
164389 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
164390 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
164391 l_recog_line_1 NUMBER;
164392 l_recog_line_2 NUMBER;
164393
164394 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
164395 l_bflow_applied_to_amt NUMBER; -- 5132302
164396 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
164397
164398 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
164399
164400 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
164401 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
164402
164403 ---------------------------------------------------------------------------------------------------------------
164404
164405
164406 --
164407 -- bulk performance
164408 --
164409 l_balance_type_code VARCHAR2(1);
164410 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
164411 l_log_module VARCHAR2(240);
164412
164413 --
164414 -- Upgrade strategy
164415 --
164416 l_actual_upg_option VARCHAR2(1);
164417 l_enc_upg_option VARCHAR2(1);
164418
164419 --
164420 BEGIN
164421 --
164422 IF g_log_enabled THEN
164423 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_305';
164424 END IF;
164425 --
164426 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
164427
164428 trace
164429 (p_msg => 'BEGIN of AcctLineType_305'
164430 ,p_level => C_LEVEL_PROCEDURE
164431 ,p_module => l_log_module);
164432
164433 END IF;
164434 --
164435 l_component_type := 'AMB_JLT';
164436 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
164437 l_component_type_code := 'S';
164438 l_component_appl_id := 707;
164439 l_amb_context_code := 'DEFAULT';
164440 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
164441 l_event_class_code := 'USER_DEFINE';
164442 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
164443 l_line_definition_owner_code := 'S';
164444 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
164445 --
164446 l_balance_type_code := 'A';
164447 l_segment := NULL;
164448 l_ccid := NULL;
164449 l_adr_transaction_coa_id := NULL;
164450 l_adr_accounting_coa_id := NULL;
164451 l_adr_flexfield_segment_code := NULL;
164452 l_adr_flex_value_set_id := NULL;
164453 l_adr_value_type_code := NULL;
164454 l_adr_value_combination_id := NULL;
164455 l_adr_value_segment_code := NULL;
164456
164457 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
164458 l_bflow_class_code := ''; -- 4219869 Business Flow
164459 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
164460 l_budgetary_control_flag := 'N';
164461
164462 l_bflow_applied_to_amt_idx := NULL; -- 5132302
164463 l_bflow_applied_to_amt := NULL; -- 5132302
164464 l_entered_amt_idx := NULL; -- 4262811
164465 l_accted_amt_idx := NULL; -- 4262811
164466 l_acc_rev_flag := NULL; -- 4262811
164467 l_accrual_line_num := NULL; -- 4262811
164468 l_tmp_amt := NULL; -- 4262811
164469 --
164470
164471 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
164472 l_balance_type_code <> 'B' THEN
164473 IF NVL(p_source_97,9E125) = 3
164474 THEN
164475
164476 --
164477 XLA_AE_LINES_PKG.SetNewLine;
164478
164479 p_balance_type_code := l_balance_type_code;
164480 -- set the flag so later we will know whether the gain loss line needs to be created
164481
164482 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
164483 p_actual_flag :='A';
164484 END IF;
164485
164486 --
164487 -- bulk performance
164488 --
164489 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
164490 p_header_num => 0); -- 4262811
164491 --
164492 -- set accounting line options
164493 --
164494 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
164495 p_natural_side_code => 'D'
164496 , p_gain_or_loss_flag => 'N'
164497 , p_gl_transfer_mode_code => 'S'
164498 , p_acct_entry_type_code => 'A'
164499 , p_switch_side_flag => 'Y'
164500 , p_merge_duplicate_code => 'N'
164501 );
164502 --
164503 l_acc_rev_natural_side_code := 'C'; -- 4262811
164504 --
164505 --
164506 -- set accounting line type info
164507 --
164508 xla_ae_lines_pkg.SetAcctLineType
164509 (p_component_type => l_component_type
164510 ,p_event_type_code => l_event_type_code
164511 ,p_line_definition_owner_code => l_line_definition_owner_code
164512 ,p_line_definition_code => l_line_definition_code
164513 ,p_accounting_line_code => l_component_code
164514 ,p_accounting_line_type_code => l_component_type_code
164515 ,p_accounting_line_appl_id => l_component_appl_id
164516 ,p_amb_context_code => l_amb_context_code
164517 ,p_entity_code => l_entity_code
164518 ,p_event_class_code => l_event_class_code);
164519 --
164520 -- set accounting class
164521 --
164522 xla_ae_lines_pkg.SetAcctClass(
164523 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
164524 , p_ae_header_id => l_ae_header_id
164525 );
164526
164527 --
164528 -- set rounding class
164529 --
164530 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
164531 'MATERIAL_OVERHEAD_ABSORPTION';
164532
164533 --
164534 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
164535 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
164536 --
164537 -- bulk performance
164538 --
164539 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
164540
164541 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
164542 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
164543
164544 -- 4955764
164545 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
164546 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
164547
164548 -- 4458381 Public Sector Enh
164549
164550 --
164551 -- set accounting attributes for the line type
164552 --
164553 l_entered_amt_idx := 3;
164554 l_accted_amt_idx := 8;
164555 l_bflow_applied_to_amt_idx := NULL; -- 5132302
164556 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
164557 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
164558 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
164559 l_rec_acct_attrs.array_char_value(2) := p_source_85;
164560 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
164561 l_rec_acct_attrs.array_num_value(3) := p_source_91;
164562 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
164563 l_rec_acct_attrs.array_char_value(4) := p_source_88;
164564 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
164565 l_rec_acct_attrs.array_date_value(5) := p_source_92;
164566 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
164567 l_rec_acct_attrs.array_num_value(6) := p_source_93;
164568 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
164569 l_rec_acct_attrs.array_char_value(7) := p_source_94;
164570 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
164571 l_rec_acct_attrs.array_num_value(8) := p_source_95;
164572
164573 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
164574 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
164575
164576 ---------------------------------------------------------------------------------------------------------------
164577 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
164578 ---------------------------------------------------------------------------------------------------------------
164579 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
164580
164581 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
164582 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
164583
164584 IF xla_accounting_cache_pkg.GetValueChar
164585 (p_source_code => 'LEDGER_CATEGORY_CODE'
164586 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
164587 AND l_bflow_method_code = 'PRIOR_ENTRY'
164588 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
164589 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
164590 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
164591 )
164592 THEN
164593 xla_ae_lines_pkg.BflowUpgEntry
164594 (p_business_method_code => l_bflow_method_code
164595 ,p_business_class_code => l_bflow_class_code
164596 ,p_balance_type => l_balance_type_code);
164597 ELSE
164598 NULL;
164599 -- No business flow processing for business flow method of NONE.
164600 END IF;
164601
164602 --
164603 -- call analytical criteria
164604 --
164605
164606 --
164607 -- call description
164608 --
164609
164610 xla_ae_lines_pkg.SetLineDescription(
164611 p_ae_header_id => l_ae_header_id
164612 ,p_description => Description_1 (
164613 p_application_id => p_application_id
164614 , p_ae_header_id => l_ae_header_id
164615 , p_source_1 => p_source_1
164616 , p_source_2 => p_source_2
164617 , p_source_3 => p_source_3
164618 , p_source_4 => p_source_4
164619 , p_source_5 => p_source_5
164620 )
164621 );
164622
164623
164624 --
164625 -- call ADRs
164626 -- Bug 4922099
164627 --
164628 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
164629 (NVL(l_actual_upg_option, 'N') = 'O') OR
164630 (NVL(l_enc_upg_option, 'N') = 'O')
164631 )
164632 THEN
164633 NULL;
164634 --
164635 --
164636
164637 l_ccid := AcctDerRule_6(
164638 p_application_id => p_application_id
164639 , p_ae_header_id => l_ae_header_id
164640 , p_source_11 => p_source_11
164641 , x_transaction_coa_id => l_adr_transaction_coa_id
164642 , x_accounting_coa_id => l_adr_accounting_coa_id
164643 , x_value_type_code => l_adr_value_type_code
164644 , p_side => 'NA'
164645 );
164646
164647 xla_ae_lines_pkg.set_ccid(
164648 p_code_combination_id => l_ccid
164649 , p_value_type_code => l_adr_value_type_code
164650 , p_transaction_coa_id => l_adr_transaction_coa_id
164651 , p_accounting_coa_id => l_adr_accounting_coa_id
164652 , p_adr_code => 'CST_DEFAULT'
164653 , p_adr_type_code => 'S'
164654 , p_component_type => l_component_type
164655 , p_component_code => l_component_code
164656 , p_component_type_code => l_component_type_code
164657 , p_component_appl_id => l_component_appl_id
164658 , p_amb_context_code => l_amb_context_code
164659 , p_side => 'NA'
164660 );
164661
164662
164663 --
164664 --
164665 END IF;
164666 --
164667 -- Bug 4922099
164668 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
164669 (NVL(l_enc_upg_option, 'N') = 'O')
164670 ) AND
164671 (l_bflow_method_code = 'PRIOR_ENTRY')
164672 )
164673 THEN
164674 IF
164675 --
164676 1 = 2
164677 --
164678 THEN
164679 xla_accounting_err_pkg.build_message
164680 (p_appli_s_name => 'XLA'
164681 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
164682 ,p_token_1 => 'LINE_NUMBER'
164683 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
164684 ,p_token_2 => 'LINE_TYPE_NAME'
164685 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
164686 l_component_type
164687 ,l_component_code
164688 ,l_component_type_code
164689 ,l_component_appl_id
164690 ,l_amb_context_code
164691 ,l_entity_code
164692 ,l_event_class_code
164693 )
164694 ,p_token_3 => 'OWNER'
164695 ,p_value_3 => xla_lookups_pkg.get_meaning(
164696 p_lookup_type => 'XLA_OWNER_TYPE'
164697 ,p_lookup_code => l_component_type_code
164698 )
164699 ,p_token_4 => 'PRODUCT_NAME'
164700 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
164701 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
164702 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
164703 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
164704 ,p_ae_header_id => NULL
164705 );
164706
164707 IF (C_LEVEL_ERROR>= g_log_level) THEN
164708 trace
164709 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
164710 ,p_level => C_LEVEL_ERROR
164711 ,p_module => l_log_module);
164712 END IF;
164713 END IF;
164714 END IF;
164715 --
164716 --
164717 ------------------------------------------------------------------------------------------------
164718 -- 4219869 Business Flow
164719 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
164720 -- Prior Entry. Currently, the following code is always generated.
164721 ------------------------------------------------------------------------------------------------
164722 XLA_AE_LINES_PKG.ValidateCurrentLine;
164723
164724 ------------------------------------------------------------------------------------
164725 -- 4219869 Business Flow
164726 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
164727 ------------------------------------------------------------------------------------
164728 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
164729
164730 ----------------------------------------------------------------------------------
164731 -- 4219869 Business Flow
164732 -- Update journal entry status -- Need to generate this within IF <condition>
164733 ----------------------------------------------------------------------------------
164734 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
164735 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
164736 ,p_balance_type_code => l_balance_type_code
164737 );
164738
164739 -------------------------------------------------------------------------------------------
164740 -- 4262811 - Generate the Accrual Reversal lines
164741 -------------------------------------------------------------------------------------------
164742 BEGIN
164743 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
164744 (g_array_event(p_event_id).array_value_num('header_index'));
164745 IF l_acc_rev_flag IS NULL THEN
164746 l_acc_rev_flag := 'N';
164747 END IF;
164748 EXCEPTION
164749 WHEN OTHERS THEN
164750 l_acc_rev_flag := 'N';
164751 END;
164752 --
164753 IF (l_acc_rev_flag = 'Y') THEN
164754
164755 -- 4645092 ------------------------------------------------------------------------------
164756 -- To allow MPA report to determine if it should generate report process
164757 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
164758 ------------------------------------------------------------------------------------------
164759
164760 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
164761 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
164762 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
164763 -- call ADRs
164764 -- Bug 4922099
164765 --
164766 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
164767 (NVL(l_actual_upg_option, 'N') = 'O') OR
164768 (NVL(l_enc_upg_option, 'N') = 'O')
164769 )
164770 THEN
164771 NULL;
164772 --
164773 --
164774
164775 l_ccid := AcctDerRule_6(
164776 p_application_id => p_application_id
164777 , p_ae_header_id => l_ae_header_id
164778 , p_source_11 => p_source_11
164779 , x_transaction_coa_id => l_adr_transaction_coa_id
164780 , x_accounting_coa_id => l_adr_accounting_coa_id
164781 , x_value_type_code => l_adr_value_type_code
164782 , p_side => 'NA'
164783 );
164784
164785 xla_ae_lines_pkg.set_ccid(
164786 p_code_combination_id => l_ccid
164787 , p_value_type_code => l_adr_value_type_code
164788 , p_transaction_coa_id => l_adr_transaction_coa_id
164789 , p_accounting_coa_id => l_adr_accounting_coa_id
164790 , p_adr_code => 'CST_DEFAULT'
164791 , p_adr_type_code => 'S'
164792 , p_component_type => l_component_type
164793 , p_component_code => l_component_code
164794 , p_component_type_code => l_component_type_code
164795 , p_component_appl_id => l_component_appl_id
164796 , p_amb_context_code => l_amb_context_code
164797 , p_side => 'NA'
164798 );
164799
164800
164801 --
164802 --
164803 END IF;
164804
164805 --
164806 -- Update the line information that should be overwritten
164807 --
164808 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
164809 p_header_num => 1);
164810 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
164811
164812 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
164813
164814 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
164815 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
164816 END IF;
164817
164818 --
164819 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
164820 --
164821 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
164822 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
164823 ELSE
164824 ---------------------------------------------------------------------------------------------------
164825 -- 4262811a Switch Sign
164826 ---------------------------------------------------------------------------------------------------
164827 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
164828 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
164829 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164830 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
164831 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164832 -- 5132302
164833 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
164834 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
164835
164836 END IF;
164837
164838 -- 4955764
164839 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
164840 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
164841
164842
164843 XLA_AE_LINES_PKG.ValidateCurrentLine;
164844 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
164845
164846 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
164847 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
164848 ,p_balance_type_code => l_balance_type_code);
164849
164850 END IF;
164851
164852 -----------------------------------------------------------------------------------------
164853 -- 4262811 Multiperiod Accounting
164854 -----------------------------------------------------------------------------------------
164855 -- No MPA option is assigned.
164856
164857
164858 END IF;
164859 END IF;
164860 --
164861
164862 --
164863 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
164864 trace
164865 (p_msg => 'END of AcctLineType_305'
164866 ,p_level => C_LEVEL_PROCEDURE
164867 ,p_module => l_log_module);
164868 END IF;
164869 --
164870 EXCEPTION
164871 WHEN xla_exceptions_pkg.application_exception THEN
164872 RAISE;
164873 WHEN OTHERS THEN
164874 xla_exceptions_pkg.raise_message
164875 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_305');
164876 END AcctLineType_305;
164877 --
164878
164879 ---------------------------------------
164880 --
164881 -- PRIVATE FUNCTION
164882 -- AcctLineType_306
164883 --
164884 ---------------------------------------
164885 PROCEDURE AcctLineType_306 (
164886 p_application_id IN NUMBER
164887 ,p_event_id IN NUMBER
164888 ,p_calculate_acctd_flag IN VARCHAR2
164889 ,p_calculate_g_l_flag IN VARCHAR2
164890 ,p_actual_flag IN OUT VARCHAR2
164891 ,p_balance_type_code OUT VARCHAR2
164892 ,p_gain_or_loss_ref OUT VARCHAR2
164893
164894 --TRANSACTION_ID
164895 , p_source_1 IN NUMBER
164896 --Item Concatenated Segments
164897 , p_source_2 IN VARCHAR2
164898 --Transaction Quantity
164899 , p_source_3 IN NUMBER
164900 --Transaction Unit of Measure Code
164901 , p_source_4 IN VARCHAR2
164902 --Inventory Transaction Type Description
164903 , p_source_5 IN VARCHAR2
164904 --Cost Management Default Account
164905 , p_source_11 IN NUMBER
164906 --DISTRIBUTION_IDENTIFIER
164907 , p_source_84 IN NUMBER
164908 --Distribution Type
164909 , p_source_85 IN VARCHAR2
164910 , p_source_85_meaning IN VARCHAR2
164911 --Entered Currency Code
164912 , p_source_88 IN VARCHAR2
164913 --Entered Amount
164914 , p_source_91 IN NUMBER
164915 --Currency Conversion Date
164916 , p_source_92 IN DATE
164917 --Currency Conversion Rate
164918 , p_source_93 IN NUMBER
164919 --Currency Conversion Type
164920 , p_source_94 IN VARCHAR2
164921 --Accounted Amount
164922 , p_source_95 IN NUMBER
164923 --Accounting Line Type
164924 , p_source_97 IN NUMBER
164925 )
164926 IS
164927
164928 l_component_type VARCHAR2(80);
164929 l_component_code VARCHAR2(30);
164930 l_component_type_code VARCHAR2(1);
164931 l_component_appl_id INTEGER;
164932 l_amb_context_code VARCHAR2(30);
164933 l_entity_code VARCHAR2(30);
164934 l_event_class_code VARCHAR2(30);
164935 l_ae_header_id NUMBER;
164936 l_event_type_code VARCHAR2(30);
164937 l_line_definition_code VARCHAR2(30);
164938 l_line_definition_owner_code VARCHAR2(1);
164939 --
164940 -- adr variables
164941 l_segment VARCHAR2(30);
164942 l_ccid NUMBER;
164943 l_adr_transaction_coa_id NUMBER;
164944 l_adr_accounting_coa_id NUMBER;
164945 l_adr_flexfield_segment_code VARCHAR2(30);
164946 l_adr_flex_value_set_id NUMBER;
164947 l_adr_value_type_code VARCHAR2(30);
164948 l_adr_value_combination_id NUMBER;
164949 l_adr_value_segment_code VARCHAR2(30);
164950
164951 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
164952 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
164953 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
164954 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
164955
164956 -- 4262811 Variables ------------------------------------------------------------------------------------------
164957 l_entered_amt_idx NUMBER;
164958 l_accted_amt_idx NUMBER;
164959 l_acc_rev_flag VARCHAR2(1);
164960 l_accrual_line_num NUMBER;
164961 l_tmp_amt NUMBER;
164962 l_acc_rev_natural_side_code VARCHAR2(1);
164963
164964 l_num_entries NUMBER;
164965 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
164966 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
164967 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
164968 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
164969 l_recog_line_1 NUMBER;
164970 l_recog_line_2 NUMBER;
164971
164972 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
164973 l_bflow_applied_to_amt NUMBER; -- 5132302
164974 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
164975
164976 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
164977
164978 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
164979 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
164980
164981 ---------------------------------------------------------------------------------------------------------------
164982
164983
164984 --
164985 -- bulk performance
164986 --
164987 l_balance_type_code VARCHAR2(1);
164988 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
164989 l_log_module VARCHAR2(240);
164990
164991 --
164992 -- Upgrade strategy
164993 --
164994 l_actual_upg_option VARCHAR2(1);
164995 l_enc_upg_option VARCHAR2(1);
164996
164997 --
164998 BEGIN
164999 --
165000 IF g_log_enabled THEN
165001 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_306';
165002 END IF;
165003 --
165004 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
165005
165006 trace
165007 (p_msg => 'BEGIN of AcctLineType_306'
165008 ,p_level => C_LEVEL_PROCEDURE
165009 ,p_module => l_log_module);
165010
165011 END IF;
165012 --
165013 l_component_type := 'AMB_JLT';
165014 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
165015 l_component_type_code := 'S';
165016 l_component_appl_id := 707;
165017 l_amb_context_code := 'DEFAULT';
165018 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
165019 l_event_class_code := 'USER_DEFINE';
165020 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
165021 l_line_definition_owner_code := 'S';
165022 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
165023 --
165024 l_balance_type_code := 'A';
165025 l_segment := NULL;
165026 l_ccid := NULL;
165027 l_adr_transaction_coa_id := NULL;
165028 l_adr_accounting_coa_id := NULL;
165029 l_adr_flexfield_segment_code := NULL;
165030 l_adr_flex_value_set_id := NULL;
165031 l_adr_value_type_code := NULL;
165032 l_adr_value_combination_id := NULL;
165033 l_adr_value_segment_code := NULL;
165034
165035 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
165036 l_bflow_class_code := ''; -- 4219869 Business Flow
165037 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
165038 l_budgetary_control_flag := 'N';
165039
165040 l_bflow_applied_to_amt_idx := NULL; -- 5132302
165041 l_bflow_applied_to_amt := NULL; -- 5132302
165042 l_entered_amt_idx := NULL; -- 4262811
165043 l_accted_amt_idx := NULL; -- 4262811
165044 l_acc_rev_flag := NULL; -- 4262811
165045 l_accrual_line_num := NULL; -- 4262811
165046 l_tmp_amt := NULL; -- 4262811
165047 --
165048
165049 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
165050 l_balance_type_code <> 'B' THEN
165051 IF NVL(p_source_97,9E125) = 3
165052 THEN
165053
165054 --
165055 XLA_AE_LINES_PKG.SetNewLine;
165056
165057 p_balance_type_code := l_balance_type_code;
165058 -- set the flag so later we will know whether the gain loss line needs to be created
165059
165060 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
165061 p_actual_flag :='A';
165062 END IF;
165063
165064 --
165065 -- bulk performance
165066 --
165067 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
165068 p_header_num => 0); -- 4262811
165069 --
165070 -- set accounting line options
165071 --
165072 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
165073 p_natural_side_code => 'D'
165074 , p_gain_or_loss_flag => 'N'
165075 , p_gl_transfer_mode_code => 'S'
165076 , p_acct_entry_type_code => 'A'
165077 , p_switch_side_flag => 'Y'
165078 , p_merge_duplicate_code => 'N'
165079 );
165080 --
165081 l_acc_rev_natural_side_code := 'C'; -- 4262811
165082 --
165083 --
165084 -- set accounting line type info
165085 --
165086 xla_ae_lines_pkg.SetAcctLineType
165087 (p_component_type => l_component_type
165088 ,p_event_type_code => l_event_type_code
165089 ,p_line_definition_owner_code => l_line_definition_owner_code
165090 ,p_line_definition_code => l_line_definition_code
165091 ,p_accounting_line_code => l_component_code
165092 ,p_accounting_line_type_code => l_component_type_code
165093 ,p_accounting_line_appl_id => l_component_appl_id
165094 ,p_amb_context_code => l_amb_context_code
165095 ,p_entity_code => l_entity_code
165096 ,p_event_class_code => l_event_class_code);
165097 --
165098 -- set accounting class
165099 --
165100 xla_ae_lines_pkg.SetAcctClass(
165101 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
165102 , p_ae_header_id => l_ae_header_id
165103 );
165104
165105 --
165106 -- set rounding class
165107 --
165108 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
165109 'MATERIAL_OVERHEAD_ABSORPTION';
165110
165111 --
165112 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
165113 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
165114 --
165115 -- bulk performance
165116 --
165117 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
165118
165119 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
165120 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
165121
165122 -- 4955764
165123 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
165124 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
165125
165126 -- 4458381 Public Sector Enh
165127
165128 --
165129 -- set accounting attributes for the line type
165130 --
165131 l_entered_amt_idx := 3;
165132 l_accted_amt_idx := 8;
165133 l_bflow_applied_to_amt_idx := NULL; -- 5132302
165134 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
165135 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
165136 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
165137 l_rec_acct_attrs.array_char_value(2) := p_source_85;
165138 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
165139 l_rec_acct_attrs.array_num_value(3) := p_source_91;
165140 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
165141 l_rec_acct_attrs.array_char_value(4) := p_source_88;
165142 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
165143 l_rec_acct_attrs.array_date_value(5) := p_source_92;
165144 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
165145 l_rec_acct_attrs.array_num_value(6) := p_source_93;
165146 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
165147 l_rec_acct_attrs.array_char_value(7) := p_source_94;
165148 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
165149 l_rec_acct_attrs.array_num_value(8) := p_source_95;
165150
165151 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
165152 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
165153
165154 ---------------------------------------------------------------------------------------------------------------
165155 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
165156 ---------------------------------------------------------------------------------------------------------------
165157 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
165158
165159 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
165160 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
165161
165162 IF xla_accounting_cache_pkg.GetValueChar
165163 (p_source_code => 'LEDGER_CATEGORY_CODE'
165164 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
165165 AND l_bflow_method_code = 'PRIOR_ENTRY'
165166 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
165167 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
165168 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
165169 )
165170 THEN
165171 xla_ae_lines_pkg.BflowUpgEntry
165172 (p_business_method_code => l_bflow_method_code
165173 ,p_business_class_code => l_bflow_class_code
165174 ,p_balance_type => l_balance_type_code);
165175 ELSE
165176 NULL;
165177 -- No business flow processing for business flow method of NONE.
165178 END IF;
165179
165180 --
165181 -- call analytical criteria
165182 --
165183
165184 --
165185 -- call description
165186 --
165187
165188 xla_ae_lines_pkg.SetLineDescription(
165189 p_ae_header_id => l_ae_header_id
165190 ,p_description => Description_1 (
165191 p_application_id => p_application_id
165192 , p_ae_header_id => l_ae_header_id
165193 , p_source_1 => p_source_1
165194 , p_source_2 => p_source_2
165195 , p_source_3 => p_source_3
165196 , p_source_4 => p_source_4
165197 , p_source_5 => p_source_5
165198 )
165199 );
165200
165201
165202 --
165203 -- call ADRs
165204 -- Bug 4922099
165205 --
165206 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
165207 (NVL(l_actual_upg_option, 'N') = 'O') OR
165208 (NVL(l_enc_upg_option, 'N') = 'O')
165209 )
165210 THEN
165211 NULL;
165212 --
165213 --
165214
165215 l_ccid := AcctDerRule_6(
165216 p_application_id => p_application_id
165217 , p_ae_header_id => l_ae_header_id
165218 , p_source_11 => p_source_11
165219 , x_transaction_coa_id => l_adr_transaction_coa_id
165220 , x_accounting_coa_id => l_adr_accounting_coa_id
165221 , x_value_type_code => l_adr_value_type_code
165222 , p_side => 'NA'
165223 );
165224
165225 xla_ae_lines_pkg.set_ccid(
165226 p_code_combination_id => l_ccid
165227 , p_value_type_code => l_adr_value_type_code
165228 , p_transaction_coa_id => l_adr_transaction_coa_id
165229 , p_accounting_coa_id => l_adr_accounting_coa_id
165230 , p_adr_code => 'CST_DEFAULT'
165231 , p_adr_type_code => 'S'
165232 , p_component_type => l_component_type
165233 , p_component_code => l_component_code
165234 , p_component_type_code => l_component_type_code
165235 , p_component_appl_id => l_component_appl_id
165236 , p_amb_context_code => l_amb_context_code
165237 , p_side => 'NA'
165238 );
165239
165240
165241 --
165242 --
165243 END IF;
165244 --
165245 -- Bug 4922099
165246 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
165247 (NVL(l_enc_upg_option, 'N') = 'O')
165248 ) AND
165249 (l_bflow_method_code = 'PRIOR_ENTRY')
165250 )
165251 THEN
165252 IF
165253 --
165254 1 = 2
165255 --
165256 THEN
165257 xla_accounting_err_pkg.build_message
165258 (p_appli_s_name => 'XLA'
165259 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
165260 ,p_token_1 => 'LINE_NUMBER'
165261 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
165262 ,p_token_2 => 'LINE_TYPE_NAME'
165263 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
165264 l_component_type
165265 ,l_component_code
165266 ,l_component_type_code
165267 ,l_component_appl_id
165268 ,l_amb_context_code
165269 ,l_entity_code
165270 ,l_event_class_code
165271 )
165272 ,p_token_3 => 'OWNER'
165273 ,p_value_3 => xla_lookups_pkg.get_meaning(
165274 p_lookup_type => 'XLA_OWNER_TYPE'
165275 ,p_lookup_code => l_component_type_code
165276 )
165277 ,p_token_4 => 'PRODUCT_NAME'
165278 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
165279 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
165280 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
165281 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
165282 ,p_ae_header_id => NULL
165283 );
165284
165285 IF (C_LEVEL_ERROR>= g_log_level) THEN
165286 trace
165287 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
165288 ,p_level => C_LEVEL_ERROR
165289 ,p_module => l_log_module);
165290 END IF;
165291 END IF;
165292 END IF;
165293 --
165294 --
165295 ------------------------------------------------------------------------------------------------
165296 -- 4219869 Business Flow
165297 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
165298 -- Prior Entry. Currently, the following code is always generated.
165299 ------------------------------------------------------------------------------------------------
165300 XLA_AE_LINES_PKG.ValidateCurrentLine;
165301
165302 ------------------------------------------------------------------------------------
165303 -- 4219869 Business Flow
165304 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
165305 ------------------------------------------------------------------------------------
165306 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
165307
165308 ----------------------------------------------------------------------------------
165309 -- 4219869 Business Flow
165310 -- Update journal entry status -- Need to generate this within IF <condition>
165311 ----------------------------------------------------------------------------------
165312 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
165313 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
165314 ,p_balance_type_code => l_balance_type_code
165315 );
165316
165317 -------------------------------------------------------------------------------------------
165318 -- 4262811 - Generate the Accrual Reversal lines
165319 -------------------------------------------------------------------------------------------
165320 BEGIN
165321 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
165322 (g_array_event(p_event_id).array_value_num('header_index'));
165323 IF l_acc_rev_flag IS NULL THEN
165324 l_acc_rev_flag := 'N';
165325 END IF;
165326 EXCEPTION
165327 WHEN OTHERS THEN
165328 l_acc_rev_flag := 'N';
165329 END;
165330 --
165331 IF (l_acc_rev_flag = 'Y') THEN
165332
165333 -- 4645092 ------------------------------------------------------------------------------
165334 -- To allow MPA report to determine if it should generate report process
165335 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
165336 ------------------------------------------------------------------------------------------
165337
165338 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
165339 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
165340 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
165341 -- call ADRs
165342 -- Bug 4922099
165343 --
165344 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
165345 (NVL(l_actual_upg_option, 'N') = 'O') OR
165346 (NVL(l_enc_upg_option, 'N') = 'O')
165347 )
165348 THEN
165349 NULL;
165350 --
165351 --
165352
165353 l_ccid := AcctDerRule_6(
165354 p_application_id => p_application_id
165355 , p_ae_header_id => l_ae_header_id
165356 , p_source_11 => p_source_11
165357 , x_transaction_coa_id => l_adr_transaction_coa_id
165358 , x_accounting_coa_id => l_adr_accounting_coa_id
165359 , x_value_type_code => l_adr_value_type_code
165360 , p_side => 'NA'
165361 );
165362
165363 xla_ae_lines_pkg.set_ccid(
165364 p_code_combination_id => l_ccid
165365 , p_value_type_code => l_adr_value_type_code
165366 , p_transaction_coa_id => l_adr_transaction_coa_id
165367 , p_accounting_coa_id => l_adr_accounting_coa_id
165368 , p_adr_code => 'CST_DEFAULT'
165369 , p_adr_type_code => 'S'
165370 , p_component_type => l_component_type
165371 , p_component_code => l_component_code
165372 , p_component_type_code => l_component_type_code
165373 , p_component_appl_id => l_component_appl_id
165374 , p_amb_context_code => l_amb_context_code
165375 , p_side => 'NA'
165376 );
165377
165378
165379 --
165380 --
165381 END IF;
165382
165383 --
165384 -- Update the line information that should be overwritten
165385 --
165386 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
165387 p_header_num => 1);
165388 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
165389
165390 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
165391
165392 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
165393 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
165394 END IF;
165395
165396 --
165397 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
165398 --
165399 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
165400 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
165401 ELSE
165402 ---------------------------------------------------------------------------------------------------
165403 -- 4262811a Switch Sign
165404 ---------------------------------------------------------------------------------------------------
165405 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
165406 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
165407 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165408 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
165409 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165410 -- 5132302
165411 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
165412 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165413
165414 END IF;
165415
165416 -- 4955764
165417 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
165418 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
165419
165420
165421 XLA_AE_LINES_PKG.ValidateCurrentLine;
165422 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
165423
165424 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
165425 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
165426 ,p_balance_type_code => l_balance_type_code);
165427
165428 END IF;
165429
165430 -----------------------------------------------------------------------------------------
165431 -- 4262811 Multiperiod Accounting
165432 -----------------------------------------------------------------------------------------
165433 -- No MPA option is assigned.
165434
165435
165436 END IF;
165437 END IF;
165438 --
165439
165440 --
165441 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
165442 trace
165443 (p_msg => 'END of AcctLineType_306'
165444 ,p_level => C_LEVEL_PROCEDURE
165445 ,p_module => l_log_module);
165446 END IF;
165447 --
165448 EXCEPTION
165449 WHEN xla_exceptions_pkg.application_exception THEN
165450 RAISE;
165451 WHEN OTHERS THEN
165452 xla_exceptions_pkg.raise_message
165453 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_306');
165454 END AcctLineType_306;
165455 --
165456
165457 ---------------------------------------
165458 --
165459 -- PRIVATE FUNCTION
165460 -- AcctLineType_307
165461 --
165462 ---------------------------------------
165463 PROCEDURE AcctLineType_307 (
165464 p_application_id IN NUMBER
165465 ,p_event_id IN NUMBER
165466 ,p_calculate_acctd_flag IN VARCHAR2
165467 ,p_calculate_g_l_flag IN VARCHAR2
165468 ,p_actual_flag IN OUT VARCHAR2
165469 ,p_balance_type_code OUT VARCHAR2
165470 ,p_gain_or_loss_ref OUT VARCHAR2
165471
165472 --TRANSACTION_ID
165473 , p_source_1 IN NUMBER
165474 --Item Concatenated Segments
165475 , p_source_2 IN VARCHAR2
165476 --Transaction Quantity
165477 , p_source_3 IN NUMBER
165478 --Transaction Unit of Measure Code
165479 , p_source_4 IN VARCHAR2
165480 --Inventory Transaction Type Description
165481 , p_source_5 IN VARCHAR2
165482 --Resource/ Overhead Absorption Account
165483 , p_source_13 IN NUMBER
165484 --DISTRIBUTION_IDENTIFIER
165485 , p_source_84 IN NUMBER
165486 --Distribution Type
165487 , p_source_85 IN VARCHAR2
165488 , p_source_85_meaning IN VARCHAR2
165489 --Entered Currency Code
165490 , p_source_88 IN VARCHAR2
165491 --Entered Amount
165492 , p_source_91 IN NUMBER
165493 --Currency Conversion Date
165494 , p_source_92 IN DATE
165495 --Currency Conversion Rate
165496 , p_source_93 IN NUMBER
165497 --Currency Conversion Type
165498 , p_source_94 IN VARCHAR2
165499 --Accounted Amount
165500 , p_source_95 IN NUMBER
165501 --Accounting Line Type
165502 , p_source_97 IN NUMBER
165503 )
165504 IS
165505
165506 l_component_type VARCHAR2(80);
165507 l_component_code VARCHAR2(30);
165508 l_component_type_code VARCHAR2(1);
165509 l_component_appl_id INTEGER;
165510 l_amb_context_code VARCHAR2(30);
165511 l_entity_code VARCHAR2(30);
165512 l_event_class_code VARCHAR2(30);
165513 l_ae_header_id NUMBER;
165514 l_event_type_code VARCHAR2(30);
165515 l_line_definition_code VARCHAR2(30);
165516 l_line_definition_owner_code VARCHAR2(1);
165517 --
165518 -- adr variables
165519 l_segment VARCHAR2(30);
165520 l_ccid NUMBER;
165521 l_adr_transaction_coa_id NUMBER;
165522 l_adr_accounting_coa_id NUMBER;
165523 l_adr_flexfield_segment_code VARCHAR2(30);
165524 l_adr_flex_value_set_id NUMBER;
165525 l_adr_value_type_code VARCHAR2(30);
165526 l_adr_value_combination_id NUMBER;
165527 l_adr_value_segment_code VARCHAR2(30);
165528
165529 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
165530 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
165531 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
165532 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
165533
165534 -- 4262811 Variables ------------------------------------------------------------------------------------------
165535 l_entered_amt_idx NUMBER;
165536 l_accted_amt_idx NUMBER;
165537 l_acc_rev_flag VARCHAR2(1);
165538 l_accrual_line_num NUMBER;
165539 l_tmp_amt NUMBER;
165540 l_acc_rev_natural_side_code VARCHAR2(1);
165541
165542 l_num_entries NUMBER;
165543 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
165544 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
165545 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
165546 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
165547 l_recog_line_1 NUMBER;
165548 l_recog_line_2 NUMBER;
165549
165550 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
165551 l_bflow_applied_to_amt NUMBER; -- 5132302
165552 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
165553
165554 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
165555
165556 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
165557 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
165558
165559 ---------------------------------------------------------------------------------------------------------------
165560
165561
165562 --
165563 -- bulk performance
165564 --
165565 l_balance_type_code VARCHAR2(1);
165566 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
165567 l_log_module VARCHAR2(240);
165568
165569 --
165570 -- Upgrade strategy
165571 --
165572 l_actual_upg_option VARCHAR2(1);
165573 l_enc_upg_option VARCHAR2(1);
165574
165575 --
165576 BEGIN
165577 --
165578 IF g_log_enabled THEN
165579 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_307';
165580 END IF;
165581 --
165582 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
165583
165584 trace
165585 (p_msg => 'BEGIN of AcctLineType_307'
165586 ,p_level => C_LEVEL_PROCEDURE
165587 ,p_module => l_log_module);
165588
165589 END IF;
165590 --
165591 l_component_type := 'AMB_JLT';
165592 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
165593 l_component_type_code := 'S';
165594 l_component_appl_id := 707;
165595 l_amb_context_code := 'DEFAULT';
165596 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
165597 l_event_class_code := 'WIP_MTL';
165598 l_event_type_code := 'WIP_ASSEMBLY_COMPLETION';
165599 l_line_definition_owner_code := 'S';
165600 l_line_definition_code := 'PI_WIP_ASSEMBLY_COMPLETION';
165601 --
165602 l_balance_type_code := 'A';
165603 l_segment := NULL;
165604 l_ccid := NULL;
165605 l_adr_transaction_coa_id := NULL;
165606 l_adr_accounting_coa_id := NULL;
165607 l_adr_flexfield_segment_code := NULL;
165608 l_adr_flex_value_set_id := NULL;
165609 l_adr_value_type_code := NULL;
165610 l_adr_value_combination_id := NULL;
165611 l_adr_value_segment_code := NULL;
165612
165613 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
165614 l_bflow_class_code := ''; -- 4219869 Business Flow
165615 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
165616 l_budgetary_control_flag := 'N';
165617
165618 l_bflow_applied_to_amt_idx := NULL; -- 5132302
165619 l_bflow_applied_to_amt := NULL; -- 5132302
165620 l_entered_amt_idx := NULL; -- 4262811
165621 l_accted_amt_idx := NULL; -- 4262811
165622 l_acc_rev_flag := NULL; -- 4262811
165623 l_accrual_line_num := NULL; -- 4262811
165624 l_tmp_amt := NULL; -- 4262811
165625 --
165626
165627 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
165628 l_balance_type_code <> 'B' THEN
165629 IF NVL(p_source_97,9E125) = 3
165630 THEN
165631
165632 --
165633 XLA_AE_LINES_PKG.SetNewLine;
165634
165635 p_balance_type_code := l_balance_type_code;
165636 -- set the flag so later we will know whether the gain loss line needs to be created
165637
165638 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
165639 p_actual_flag :='A';
165640 END IF;
165641
165642 --
165643 -- bulk performance
165644 --
165645 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
165646 p_header_num => 0); -- 4262811
165647 --
165648 -- set accounting line options
165649 --
165650 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
165651 p_natural_side_code => 'D'
165652 , p_gain_or_loss_flag => 'N'
165653 , p_gl_transfer_mode_code => 'S'
165654 , p_acct_entry_type_code => 'A'
165655 , p_switch_side_flag => 'Y'
165656 , p_merge_duplicate_code => 'N'
165657 );
165658 --
165659 l_acc_rev_natural_side_code := 'C'; -- 4262811
165660 --
165661 --
165662 -- set accounting line type info
165663 --
165664 xla_ae_lines_pkg.SetAcctLineType
165665 (p_component_type => l_component_type
165666 ,p_event_type_code => l_event_type_code
165667 ,p_line_definition_owner_code => l_line_definition_owner_code
165668 ,p_line_definition_code => l_line_definition_code
165669 ,p_accounting_line_code => l_component_code
165670 ,p_accounting_line_type_code => l_component_type_code
165671 ,p_accounting_line_appl_id => l_component_appl_id
165672 ,p_amb_context_code => l_amb_context_code
165673 ,p_entity_code => l_entity_code
165674 ,p_event_class_code => l_event_class_code);
165675 --
165676 -- set accounting class
165677 --
165678 xla_ae_lines_pkg.SetAcctClass(
165679 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
165680 , p_ae_header_id => l_ae_header_id
165681 );
165682
165683 --
165684 -- set rounding class
165685 --
165686 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
165687 'MATERIAL_OVERHEAD_ABSORPTION';
165688
165689 --
165690 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
165691 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
165692 --
165693 -- bulk performance
165694 --
165695 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
165696
165697 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
165698 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
165699
165700 -- 4955764
165701 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
165702 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
165703
165704 -- 4458381 Public Sector Enh
165705
165706 --
165707 -- set accounting attributes for the line type
165708 --
165709 l_entered_amt_idx := 3;
165710 l_accted_amt_idx := 8;
165711 l_bflow_applied_to_amt_idx := NULL; -- 5132302
165712 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
165713 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
165714 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
165715 l_rec_acct_attrs.array_char_value(2) := p_source_85;
165716 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
165717 l_rec_acct_attrs.array_num_value(3) := p_source_91;
165718 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
165719 l_rec_acct_attrs.array_char_value(4) := p_source_88;
165720 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
165721 l_rec_acct_attrs.array_date_value(5) := p_source_92;
165722 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
165723 l_rec_acct_attrs.array_num_value(6) := p_source_93;
165724 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
165725 l_rec_acct_attrs.array_char_value(7) := p_source_94;
165726 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
165727 l_rec_acct_attrs.array_num_value(8) := p_source_95;
165728
165729 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
165730 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
165731
165732 ---------------------------------------------------------------------------------------------------------------
165733 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
165734 ---------------------------------------------------------------------------------------------------------------
165735 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
165736
165737 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
165738 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
165739
165740 IF xla_accounting_cache_pkg.GetValueChar
165741 (p_source_code => 'LEDGER_CATEGORY_CODE'
165742 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
165743 AND l_bflow_method_code = 'PRIOR_ENTRY'
165744 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
165745 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
165746 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
165747 )
165748 THEN
165749 xla_ae_lines_pkg.BflowUpgEntry
165750 (p_business_method_code => l_bflow_method_code
165751 ,p_business_class_code => l_bflow_class_code
165752 ,p_balance_type => l_balance_type_code);
165753 ELSE
165754 NULL;
165755 -- No business flow processing for business flow method of NONE.
165756 END IF;
165757
165758 --
165759 -- call analytical criteria
165760 --
165761
165762 --
165763 -- call description
165764 --
165765
165766 xla_ae_lines_pkg.SetLineDescription(
165767 p_ae_header_id => l_ae_header_id
165768 ,p_description => Description_1 (
165769 p_application_id => p_application_id
165770 , p_ae_header_id => l_ae_header_id
165771 , p_source_1 => p_source_1
165772 , p_source_2 => p_source_2
165773 , p_source_3 => p_source_3
165774 , p_source_4 => p_source_4
165775 , p_source_5 => p_source_5
165776 )
165777 );
165778
165779
165780 --
165781 -- call ADRs
165782 -- Bug 4922099
165783 --
165784 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
165785 (NVL(l_actual_upg_option, 'N') = 'O') OR
165786 (NVL(l_enc_upg_option, 'N') = 'O')
165787 )
165788 THEN
165789 NULL;
165790 --
165791 --
165792
165793 l_ccid := AcctDerRule_8(
165794 p_application_id => p_application_id
165795 , p_ae_header_id => l_ae_header_id
165796 , p_source_13 => p_source_13
165797 , x_transaction_coa_id => l_adr_transaction_coa_id
165798 , x_accounting_coa_id => l_adr_accounting_coa_id
165799 , x_value_type_code => l_adr_value_type_code
165800 , p_side => 'NA'
165801 );
165802
165803 xla_ae_lines_pkg.set_ccid(
165804 p_code_combination_id => l_ccid
165805 , p_value_type_code => l_adr_value_type_code
165806 , p_transaction_coa_id => l_adr_transaction_coa_id
165807 , p_accounting_coa_id => l_adr_accounting_coa_id
165808 , p_adr_code => 'PI_ABSORPTION'
165809 , p_adr_type_code => 'S'
165810 , p_component_type => l_component_type
165811 , p_component_code => l_component_code
165812 , p_component_type_code => l_component_type_code
165813 , p_component_appl_id => l_component_appl_id
165814 , p_amb_context_code => l_amb_context_code
165815 , p_side => 'NA'
165816 );
165817
165818
165819 --
165820 --
165821 END IF;
165822 --
165823 -- Bug 4922099
165824 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
165825 (NVL(l_enc_upg_option, 'N') = 'O')
165826 ) AND
165827 (l_bflow_method_code = 'PRIOR_ENTRY')
165828 )
165829 THEN
165830 IF
165831 --
165832 1 = 2
165833 --
165834 THEN
165835 xla_accounting_err_pkg.build_message
165836 (p_appli_s_name => 'XLA'
165837 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
165838 ,p_token_1 => 'LINE_NUMBER'
165839 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
165840 ,p_token_2 => 'LINE_TYPE_NAME'
165841 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
165842 l_component_type
165843 ,l_component_code
165844 ,l_component_type_code
165845 ,l_component_appl_id
165846 ,l_amb_context_code
165847 ,l_entity_code
165848 ,l_event_class_code
165849 )
165850 ,p_token_3 => 'OWNER'
165851 ,p_value_3 => xla_lookups_pkg.get_meaning(
165852 p_lookup_type => 'XLA_OWNER_TYPE'
165853 ,p_lookup_code => l_component_type_code
165854 )
165855 ,p_token_4 => 'PRODUCT_NAME'
165856 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
165857 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
165858 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
165859 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
165860 ,p_ae_header_id => NULL
165861 );
165862
165863 IF (C_LEVEL_ERROR>= g_log_level) THEN
165864 trace
165865 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
165866 ,p_level => C_LEVEL_ERROR
165867 ,p_module => l_log_module);
165868 END IF;
165869 END IF;
165870 END IF;
165871 --
165872 --
165873 ------------------------------------------------------------------------------------------------
165874 -- 4219869 Business Flow
165875 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
165876 -- Prior Entry. Currently, the following code is always generated.
165877 ------------------------------------------------------------------------------------------------
165878 XLA_AE_LINES_PKG.ValidateCurrentLine;
165879
165880 ------------------------------------------------------------------------------------
165881 -- 4219869 Business Flow
165882 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
165883 ------------------------------------------------------------------------------------
165884 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
165885
165886 ----------------------------------------------------------------------------------
165887 -- 4219869 Business Flow
165888 -- Update journal entry status -- Need to generate this within IF <condition>
165889 ----------------------------------------------------------------------------------
165890 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
165891 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
165892 ,p_balance_type_code => l_balance_type_code
165893 );
165894
165895 -------------------------------------------------------------------------------------------
165896 -- 4262811 - Generate the Accrual Reversal lines
165897 -------------------------------------------------------------------------------------------
165898 BEGIN
165899 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
165900 (g_array_event(p_event_id).array_value_num('header_index'));
165901 IF l_acc_rev_flag IS NULL THEN
165902 l_acc_rev_flag := 'N';
165903 END IF;
165904 EXCEPTION
165905 WHEN OTHERS THEN
165906 l_acc_rev_flag := 'N';
165907 END;
165908 --
165909 IF (l_acc_rev_flag = 'Y') THEN
165910
165911 -- 4645092 ------------------------------------------------------------------------------
165912 -- To allow MPA report to determine if it should generate report process
165913 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
165914 ------------------------------------------------------------------------------------------
165915
165916 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
165917 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
165918 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
165919 -- call ADRs
165920 -- Bug 4922099
165921 --
165922 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
165923 (NVL(l_actual_upg_option, 'N') = 'O') OR
165924 (NVL(l_enc_upg_option, 'N') = 'O')
165925 )
165926 THEN
165927 NULL;
165928 --
165929 --
165930
165931 l_ccid := AcctDerRule_8(
165932 p_application_id => p_application_id
165933 , p_ae_header_id => l_ae_header_id
165934 , p_source_13 => p_source_13
165935 , x_transaction_coa_id => l_adr_transaction_coa_id
165936 , x_accounting_coa_id => l_adr_accounting_coa_id
165937 , x_value_type_code => l_adr_value_type_code
165938 , p_side => 'NA'
165939 );
165940
165941 xla_ae_lines_pkg.set_ccid(
165942 p_code_combination_id => l_ccid
165943 , p_value_type_code => l_adr_value_type_code
165944 , p_transaction_coa_id => l_adr_transaction_coa_id
165945 , p_accounting_coa_id => l_adr_accounting_coa_id
165946 , p_adr_code => 'PI_ABSORPTION'
165947 , p_adr_type_code => 'S'
165948 , p_component_type => l_component_type
165949 , p_component_code => l_component_code
165950 , p_component_type_code => l_component_type_code
165951 , p_component_appl_id => l_component_appl_id
165952 , p_amb_context_code => l_amb_context_code
165953 , p_side => 'NA'
165954 );
165955
165956
165957 --
165958 --
165959 END IF;
165960
165961 --
165962 -- Update the line information that should be overwritten
165963 --
165964 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
165965 p_header_num => 1);
165966 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
165967
165968 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
165969
165970 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
165971 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
165972 END IF;
165973
165974 --
165975 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
165976 --
165977 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
165978 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
165979 ELSE
165980 ---------------------------------------------------------------------------------------------------
165981 -- 4262811a Switch Sign
165982 ---------------------------------------------------------------------------------------------------
165983 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
165984 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
165985 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165986 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
165987 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165988 -- 5132302
165989 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
165990 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
165991
165992 END IF;
165993
165994 -- 4955764
165995 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
165996 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
165997
165998
165999 XLA_AE_LINES_PKG.ValidateCurrentLine;
166000 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
166001
166002 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
166003 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
166004 ,p_balance_type_code => l_balance_type_code);
166005
166006 END IF;
166007
166008 -----------------------------------------------------------------------------------------
166009 -- 4262811 Multiperiod Accounting
166010 -----------------------------------------------------------------------------------------
166011 -- No MPA option is assigned.
166012
166013
166014 END IF;
166015 END IF;
166016 --
166017
166018 --
166019 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
166020 trace
166021 (p_msg => 'END of AcctLineType_307'
166022 ,p_level => C_LEVEL_PROCEDURE
166023 ,p_module => l_log_module);
166024 END IF;
166025 --
166026 EXCEPTION
166027 WHEN xla_exceptions_pkg.application_exception THEN
166028 RAISE;
166029 WHEN OTHERS THEN
166030 xla_exceptions_pkg.raise_message
166031 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_307');
166032 END AcctLineType_307;
166033 --
166034
166035 ---------------------------------------
166036 --
166037 -- PRIVATE FUNCTION
166038 -- AcctLineType_308
166039 --
166040 ---------------------------------------
166041 PROCEDURE AcctLineType_308 (
166042 p_application_id IN NUMBER
166043 ,p_event_id IN NUMBER
166044 ,p_calculate_acctd_flag IN VARCHAR2
166045 ,p_calculate_g_l_flag IN VARCHAR2
166046 ,p_actual_flag IN OUT VARCHAR2
166047 ,p_balance_type_code OUT VARCHAR2
166048 ,p_gain_or_loss_ref OUT VARCHAR2
166049
166050 --TRANSACTION_ID
166051 , p_source_1 IN NUMBER
166052 --Item Concatenated Segments
166053 , p_source_2 IN VARCHAR2
166054 --Transaction Quantity
166055 , p_source_3 IN NUMBER
166056 --Transaction Unit of Measure Code
166057 , p_source_4 IN VARCHAR2
166058 --Inventory Transaction Type Description
166059 , p_source_5 IN VARCHAR2
166060 --Cost Management Default Account
166061 , p_source_11 IN NUMBER
166062 --DISTRIBUTION_IDENTIFIER
166063 , p_source_84 IN NUMBER
166064 --Distribution Type
166065 , p_source_85 IN VARCHAR2
166066 , p_source_85_meaning IN VARCHAR2
166067 --Entered Currency Code
166068 , p_source_88 IN VARCHAR2
166069 --Entered Amount
166070 , p_source_91 IN NUMBER
166071 --Currency Conversion Date
166072 , p_source_92 IN DATE
166073 --Currency Conversion Rate
166074 , p_source_93 IN NUMBER
166075 --Currency Conversion Type
166076 , p_source_94 IN VARCHAR2
166077 --Accounted Amount
166078 , p_source_95 IN NUMBER
166079 --Accounting Line Type
166080 , p_source_97 IN NUMBER
166081 )
166082 IS
166083
166084 l_component_type VARCHAR2(80);
166085 l_component_code VARCHAR2(30);
166086 l_component_type_code VARCHAR2(1);
166087 l_component_appl_id INTEGER;
166088 l_amb_context_code VARCHAR2(30);
166089 l_entity_code VARCHAR2(30);
166090 l_event_class_code VARCHAR2(30);
166091 l_ae_header_id NUMBER;
166092 l_event_type_code VARCHAR2(30);
166093 l_line_definition_code VARCHAR2(30);
166094 l_line_definition_owner_code VARCHAR2(1);
166095 --
166096 -- adr variables
166097 l_segment VARCHAR2(30);
166098 l_ccid NUMBER;
166099 l_adr_transaction_coa_id NUMBER;
166100 l_adr_accounting_coa_id NUMBER;
166101 l_adr_flexfield_segment_code VARCHAR2(30);
166102 l_adr_flex_value_set_id NUMBER;
166103 l_adr_value_type_code VARCHAR2(30);
166104 l_adr_value_combination_id NUMBER;
166105 l_adr_value_segment_code VARCHAR2(30);
166106
166107 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
166108 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
166109 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
166110 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
166111
166112 -- 4262811 Variables ------------------------------------------------------------------------------------------
166113 l_entered_amt_idx NUMBER;
166114 l_accted_amt_idx NUMBER;
166115 l_acc_rev_flag VARCHAR2(1);
166116 l_accrual_line_num NUMBER;
166117 l_tmp_amt NUMBER;
166118 l_acc_rev_natural_side_code VARCHAR2(1);
166119
166120 l_num_entries NUMBER;
166121 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
166122 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
166123 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
166124 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
166125 l_recog_line_1 NUMBER;
166126 l_recog_line_2 NUMBER;
166127
166128 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
166129 l_bflow_applied_to_amt NUMBER; -- 5132302
166130 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
166131
166132 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
166133
166134 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
166135 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
166136
166137 ---------------------------------------------------------------------------------------------------------------
166138
166139
166140 --
166141 -- bulk performance
166142 --
166143 l_balance_type_code VARCHAR2(1);
166144 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
166145 l_log_module VARCHAR2(240);
166146
166147 --
166148 -- Upgrade strategy
166149 --
166150 l_actual_upg_option VARCHAR2(1);
166151 l_enc_upg_option VARCHAR2(1);
166152
166153 --
166154 BEGIN
166155 --
166156 IF g_log_enabled THEN
166157 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_308';
166158 END IF;
166159 --
166160 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
166161
166162 trace
166163 (p_msg => 'BEGIN of AcctLineType_308'
166164 ,p_level => C_LEVEL_PROCEDURE
166165 ,p_module => l_log_module);
166166
166167 END IF;
166168 --
166169 l_component_type := 'AMB_JLT';
166170 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
166171 l_component_type_code := 'S';
166172 l_component_appl_id := 707;
166173 l_amb_context_code := 'DEFAULT';
166174 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
166175 l_event_class_code := 'WIP_MTL';
166176 l_event_type_code := 'WIP_COMP_RETURN';
166177 l_line_definition_owner_code := 'S';
166178 l_line_definition_code := 'PI_WIP_COMP_RETURN';
166179 --
166180 l_balance_type_code := 'A';
166181 l_segment := NULL;
166182 l_ccid := NULL;
166183 l_adr_transaction_coa_id := NULL;
166184 l_adr_accounting_coa_id := NULL;
166185 l_adr_flexfield_segment_code := NULL;
166186 l_adr_flex_value_set_id := NULL;
166187 l_adr_value_type_code := NULL;
166188 l_adr_value_combination_id := NULL;
166189 l_adr_value_segment_code := NULL;
166190
166191 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
166192 l_bflow_class_code := ''; -- 4219869 Business Flow
166193 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
166194 l_budgetary_control_flag := 'N';
166195
166196 l_bflow_applied_to_amt_idx := NULL; -- 5132302
166197 l_bflow_applied_to_amt := NULL; -- 5132302
166198 l_entered_amt_idx := NULL; -- 4262811
166199 l_accted_amt_idx := NULL; -- 4262811
166200 l_acc_rev_flag := NULL; -- 4262811
166201 l_accrual_line_num := NULL; -- 4262811
166202 l_tmp_amt := NULL; -- 4262811
166203 --
166204
166205 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
166206 l_balance_type_code <> 'B' THEN
166207 IF NVL(p_source_97,9E125) = 3
166208 THEN
166209
166210 --
166211 XLA_AE_LINES_PKG.SetNewLine;
166212
166213 p_balance_type_code := l_balance_type_code;
166214 -- set the flag so later we will know whether the gain loss line needs to be created
166215
166216 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
166217 p_actual_flag :='A';
166218 END IF;
166219
166220 --
166221 -- bulk performance
166222 --
166223 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
166224 p_header_num => 0); -- 4262811
166225 --
166226 -- set accounting line options
166227 --
166228 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
166229 p_natural_side_code => 'D'
166230 , p_gain_or_loss_flag => 'N'
166231 , p_gl_transfer_mode_code => 'S'
166232 , p_acct_entry_type_code => 'A'
166233 , p_switch_side_flag => 'Y'
166234 , p_merge_duplicate_code => 'N'
166235 );
166236 --
166237 l_acc_rev_natural_side_code := 'C'; -- 4262811
166238 --
166239 --
166240 -- set accounting line type info
166241 --
166242 xla_ae_lines_pkg.SetAcctLineType
166243 (p_component_type => l_component_type
166244 ,p_event_type_code => l_event_type_code
166245 ,p_line_definition_owner_code => l_line_definition_owner_code
166246 ,p_line_definition_code => l_line_definition_code
166247 ,p_accounting_line_code => l_component_code
166248 ,p_accounting_line_type_code => l_component_type_code
166249 ,p_accounting_line_appl_id => l_component_appl_id
166250 ,p_amb_context_code => l_amb_context_code
166251 ,p_entity_code => l_entity_code
166252 ,p_event_class_code => l_event_class_code);
166253 --
166254 -- set accounting class
166255 --
166256 xla_ae_lines_pkg.SetAcctClass(
166257 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
166258 , p_ae_header_id => l_ae_header_id
166259 );
166260
166261 --
166262 -- set rounding class
166263 --
166264 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
166265 'MATERIAL_OVERHEAD_ABSORPTION';
166266
166267 --
166268 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
166269 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
166270 --
166271 -- bulk performance
166272 --
166273 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
166274
166275 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
166276 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
166277
166278 -- 4955764
166279 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
166280 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
166281
166282 -- 4458381 Public Sector Enh
166283
166284 --
166285 -- set accounting attributes for the line type
166286 --
166287 l_entered_amt_idx := 3;
166288 l_accted_amt_idx := 8;
166289 l_bflow_applied_to_amt_idx := NULL; -- 5132302
166290 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
166291 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
166292 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
166293 l_rec_acct_attrs.array_char_value(2) := p_source_85;
166294 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
166295 l_rec_acct_attrs.array_num_value(3) := p_source_91;
166296 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
166297 l_rec_acct_attrs.array_char_value(4) := p_source_88;
166298 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
166299 l_rec_acct_attrs.array_date_value(5) := p_source_92;
166300 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
166301 l_rec_acct_attrs.array_num_value(6) := p_source_93;
166302 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
166303 l_rec_acct_attrs.array_char_value(7) := p_source_94;
166304 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
166305 l_rec_acct_attrs.array_num_value(8) := p_source_95;
166306
166307 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
166308 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
166309
166310 ---------------------------------------------------------------------------------------------------------------
166311 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
166312 ---------------------------------------------------------------------------------------------------------------
166313 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
166314
166315 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
166316 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
166317
166318 IF xla_accounting_cache_pkg.GetValueChar
166319 (p_source_code => 'LEDGER_CATEGORY_CODE'
166320 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
166321 AND l_bflow_method_code = 'PRIOR_ENTRY'
166322 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
166323 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
166324 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
166325 )
166326 THEN
166327 xla_ae_lines_pkg.BflowUpgEntry
166328 (p_business_method_code => l_bflow_method_code
166329 ,p_business_class_code => l_bflow_class_code
166330 ,p_balance_type => l_balance_type_code);
166331 ELSE
166332 NULL;
166333 -- No business flow processing for business flow method of NONE.
166334 END IF;
166335
166336 --
166337 -- call analytical criteria
166338 --
166339
166340 --
166341 -- call description
166342 --
166343
166344 xla_ae_lines_pkg.SetLineDescription(
166345 p_ae_header_id => l_ae_header_id
166346 ,p_description => Description_1 (
166347 p_application_id => p_application_id
166348 , p_ae_header_id => l_ae_header_id
166349 , p_source_1 => p_source_1
166350 , p_source_2 => p_source_2
166351 , p_source_3 => p_source_3
166352 , p_source_4 => p_source_4
166353 , p_source_5 => p_source_5
166354 )
166355 );
166356
166357
166358 --
166359 -- call ADRs
166360 -- Bug 4922099
166361 --
166362 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
166363 (NVL(l_actual_upg_option, 'N') = 'O') OR
166364 (NVL(l_enc_upg_option, 'N') = 'O')
166365 )
166366 THEN
166367 NULL;
166368 --
166369 --
166370
166371 l_ccid := AcctDerRule_6(
166372 p_application_id => p_application_id
166373 , p_ae_header_id => l_ae_header_id
166374 , p_source_11 => p_source_11
166375 , x_transaction_coa_id => l_adr_transaction_coa_id
166376 , x_accounting_coa_id => l_adr_accounting_coa_id
166377 , x_value_type_code => l_adr_value_type_code
166378 , p_side => 'NA'
166379 );
166380
166381 xla_ae_lines_pkg.set_ccid(
166382 p_code_combination_id => l_ccid
166383 , p_value_type_code => l_adr_value_type_code
166384 , p_transaction_coa_id => l_adr_transaction_coa_id
166385 , p_accounting_coa_id => l_adr_accounting_coa_id
166386 , p_adr_code => 'CST_DEFAULT'
166387 , p_adr_type_code => 'S'
166388 , p_component_type => l_component_type
166389 , p_component_code => l_component_code
166390 , p_component_type_code => l_component_type_code
166391 , p_component_appl_id => l_component_appl_id
166392 , p_amb_context_code => l_amb_context_code
166393 , p_side => 'NA'
166394 );
166395
166396
166397 --
166398 --
166399 END IF;
166400 --
166401 -- Bug 4922099
166402 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
166403 (NVL(l_enc_upg_option, 'N') = 'O')
166404 ) AND
166405 (l_bflow_method_code = 'PRIOR_ENTRY')
166406 )
166407 THEN
166408 IF
166409 --
166410 1 = 2
166411 --
166412 THEN
166413 xla_accounting_err_pkg.build_message
166414 (p_appli_s_name => 'XLA'
166415 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
166416 ,p_token_1 => 'LINE_NUMBER'
166417 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
166418 ,p_token_2 => 'LINE_TYPE_NAME'
166419 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
166420 l_component_type
166421 ,l_component_code
166422 ,l_component_type_code
166423 ,l_component_appl_id
166424 ,l_amb_context_code
166425 ,l_entity_code
166426 ,l_event_class_code
166427 )
166428 ,p_token_3 => 'OWNER'
166429 ,p_value_3 => xla_lookups_pkg.get_meaning(
166430 p_lookup_type => 'XLA_OWNER_TYPE'
166431 ,p_lookup_code => l_component_type_code
166432 )
166433 ,p_token_4 => 'PRODUCT_NAME'
166434 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
166435 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
166436 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
166437 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
166438 ,p_ae_header_id => NULL
166439 );
166440
166441 IF (C_LEVEL_ERROR>= g_log_level) THEN
166442 trace
166443 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
166444 ,p_level => C_LEVEL_ERROR
166445 ,p_module => l_log_module);
166446 END IF;
166447 END IF;
166448 END IF;
166449 --
166450 --
166451 ------------------------------------------------------------------------------------------------
166452 -- 4219869 Business Flow
166453 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
166454 -- Prior Entry. Currently, the following code is always generated.
166455 ------------------------------------------------------------------------------------------------
166456 XLA_AE_LINES_PKG.ValidateCurrentLine;
166457
166458 ------------------------------------------------------------------------------------
166459 -- 4219869 Business Flow
166460 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
166461 ------------------------------------------------------------------------------------
166462 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
166463
166464 ----------------------------------------------------------------------------------
166465 -- 4219869 Business Flow
166466 -- Update journal entry status -- Need to generate this within IF <condition>
166467 ----------------------------------------------------------------------------------
166468 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
166469 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
166470 ,p_balance_type_code => l_balance_type_code
166471 );
166472
166473 -------------------------------------------------------------------------------------------
166474 -- 4262811 - Generate the Accrual Reversal lines
166475 -------------------------------------------------------------------------------------------
166476 BEGIN
166477 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
166478 (g_array_event(p_event_id).array_value_num('header_index'));
166479 IF l_acc_rev_flag IS NULL THEN
166480 l_acc_rev_flag := 'N';
166481 END IF;
166482 EXCEPTION
166483 WHEN OTHERS THEN
166484 l_acc_rev_flag := 'N';
166485 END;
166486 --
166487 IF (l_acc_rev_flag = 'Y') THEN
166488
166489 -- 4645092 ------------------------------------------------------------------------------
166490 -- To allow MPA report to determine if it should generate report process
166491 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
166492 ------------------------------------------------------------------------------------------
166493
166494 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
166495 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
166496 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
166497 -- call ADRs
166498 -- Bug 4922099
166499 --
166500 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
166501 (NVL(l_actual_upg_option, 'N') = 'O') OR
166502 (NVL(l_enc_upg_option, 'N') = 'O')
166503 )
166504 THEN
166505 NULL;
166506 --
166507 --
166508
166509 l_ccid := AcctDerRule_6(
166510 p_application_id => p_application_id
166511 , p_ae_header_id => l_ae_header_id
166512 , p_source_11 => p_source_11
166513 , x_transaction_coa_id => l_adr_transaction_coa_id
166514 , x_accounting_coa_id => l_adr_accounting_coa_id
166515 , x_value_type_code => l_adr_value_type_code
166516 , p_side => 'NA'
166517 );
166518
166519 xla_ae_lines_pkg.set_ccid(
166520 p_code_combination_id => l_ccid
166521 , p_value_type_code => l_adr_value_type_code
166522 , p_transaction_coa_id => l_adr_transaction_coa_id
166523 , p_accounting_coa_id => l_adr_accounting_coa_id
166524 , p_adr_code => 'CST_DEFAULT'
166525 , p_adr_type_code => 'S'
166526 , p_component_type => l_component_type
166527 , p_component_code => l_component_code
166528 , p_component_type_code => l_component_type_code
166529 , p_component_appl_id => l_component_appl_id
166530 , p_amb_context_code => l_amb_context_code
166531 , p_side => 'NA'
166532 );
166533
166534
166535 --
166536 --
166537 END IF;
166538
166539 --
166540 -- Update the line information that should be overwritten
166541 --
166542 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
166543 p_header_num => 1);
166544 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
166545
166546 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
166547
166548 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
166549 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
166550 END IF;
166551
166552 --
166553 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
166554 --
166555 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
166556 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
166557 ELSE
166558 ---------------------------------------------------------------------------------------------------
166559 -- 4262811a Switch Sign
166560 ---------------------------------------------------------------------------------------------------
166561 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
166562 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
166563 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
166564 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
166565 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
166566 -- 5132302
166567 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
166568 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
166569
166570 END IF;
166571
166572 -- 4955764
166573 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
166574 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
166575
166576
166577 XLA_AE_LINES_PKG.ValidateCurrentLine;
166578 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
166579
166580 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
166581 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
166582 ,p_balance_type_code => l_balance_type_code);
166583
166584 END IF;
166585
166586 -----------------------------------------------------------------------------------------
166587 -- 4262811 Multiperiod Accounting
166588 -----------------------------------------------------------------------------------------
166589 -- No MPA option is assigned.
166590
166591
166592 END IF;
166593 END IF;
166594 --
166595
166596 --
166597 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
166598 trace
166599 (p_msg => 'END of AcctLineType_308'
166600 ,p_level => C_LEVEL_PROCEDURE
166601 ,p_module => l_log_module);
166602 END IF;
166603 --
166604 EXCEPTION
166605 WHEN xla_exceptions_pkg.application_exception THEN
166606 RAISE;
166607 WHEN OTHERS THEN
166608 xla_exceptions_pkg.raise_message
166609 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_308');
166610 END AcctLineType_308;
166611 --
166612
166613 ---------------------------------------
166614 --
166615 -- PRIVATE FUNCTION
166616 -- AcctLineType_309
166617 --
166618 ---------------------------------------
166619 PROCEDURE AcctLineType_309 (
166620 p_application_id IN NUMBER
166621 ,p_event_id IN NUMBER
166622 ,p_calculate_acctd_flag IN VARCHAR2
166623 ,p_calculate_g_l_flag IN VARCHAR2
166624 ,p_actual_flag IN OUT VARCHAR2
166625 ,p_balance_type_code OUT VARCHAR2
166626 ,p_gain_or_loss_ref OUT VARCHAR2
166627
166628 --TRANSACTION_ID
166629 , p_source_1 IN NUMBER
166630 --Item Concatenated Segments
166631 , p_source_2 IN VARCHAR2
166632 --Transaction Quantity
166633 , p_source_3 IN NUMBER
166634 --Transaction Unit of Measure Code
166635 , p_source_4 IN VARCHAR2
166636 --Inventory Transaction Type Description
166637 , p_source_5 IN VARCHAR2
166638 --Cost Management Default Account
166639 , p_source_11 IN NUMBER
166640 --DISTRIBUTION_IDENTIFIER
166641 , p_source_84 IN NUMBER
166642 --Distribution Type
166643 , p_source_85 IN VARCHAR2
166644 , p_source_85_meaning IN VARCHAR2
166645 --Entered Currency Code
166646 , p_source_88 IN VARCHAR2
166647 --Entered Amount
166648 , p_source_91 IN NUMBER
166649 --Currency Conversion Date
166650 , p_source_92 IN DATE
166651 --Currency Conversion Rate
166652 , p_source_93 IN NUMBER
166653 --Currency Conversion Type
166654 , p_source_94 IN VARCHAR2
166655 --Accounted Amount
166656 , p_source_95 IN NUMBER
166657 --Accounting Line Type
166658 , p_source_97 IN NUMBER
166659 )
166660 IS
166661
166662 l_component_type VARCHAR2(80);
166663 l_component_code VARCHAR2(30);
166664 l_component_type_code VARCHAR2(1);
166665 l_component_appl_id INTEGER;
166666 l_amb_context_code VARCHAR2(30);
166667 l_entity_code VARCHAR2(30);
166668 l_event_class_code VARCHAR2(30);
166669 l_ae_header_id NUMBER;
166670 l_event_type_code VARCHAR2(30);
166671 l_line_definition_code VARCHAR2(30);
166672 l_line_definition_owner_code VARCHAR2(1);
166673 --
166674 -- adr variables
166675 l_segment VARCHAR2(30);
166676 l_ccid NUMBER;
166677 l_adr_transaction_coa_id NUMBER;
166678 l_adr_accounting_coa_id NUMBER;
166679 l_adr_flexfield_segment_code VARCHAR2(30);
166680 l_adr_flex_value_set_id NUMBER;
166681 l_adr_value_type_code VARCHAR2(30);
166682 l_adr_value_combination_id NUMBER;
166683 l_adr_value_segment_code VARCHAR2(30);
166684
166685 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
166686 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
166687 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
166688 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
166689
166690 -- 4262811 Variables ------------------------------------------------------------------------------------------
166691 l_entered_amt_idx NUMBER;
166692 l_accted_amt_idx NUMBER;
166693 l_acc_rev_flag VARCHAR2(1);
166694 l_accrual_line_num NUMBER;
166695 l_tmp_amt NUMBER;
166696 l_acc_rev_natural_side_code VARCHAR2(1);
166697
166698 l_num_entries NUMBER;
166699 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
166700 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
166701 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
166702 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
166703 l_recog_line_1 NUMBER;
166704 l_recog_line_2 NUMBER;
166705
166706 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
166707 l_bflow_applied_to_amt NUMBER; -- 5132302
166708 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
166709
166710 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
166711
166712 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
166713 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
166714
166715 ---------------------------------------------------------------------------------------------------------------
166716
166717
166718 --
166719 -- bulk performance
166720 --
166721 l_balance_type_code VARCHAR2(1);
166722 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
166723 l_log_module VARCHAR2(240);
166724
166725 --
166726 -- Upgrade strategy
166727 --
166728 l_actual_upg_option VARCHAR2(1);
166729 l_enc_upg_option VARCHAR2(1);
166730
166731 --
166732 BEGIN
166733 --
166734 IF g_log_enabled THEN
166735 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_309';
166736 END IF;
166737 --
166738 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
166739
166740 trace
166741 (p_msg => 'BEGIN of AcctLineType_309'
166742 ,p_level => C_LEVEL_PROCEDURE
166743 ,p_module => l_log_module);
166744
166745 END IF;
166746 --
166747 l_component_type := 'AMB_JLT';
166748 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
166749 l_component_type_code := 'S';
166750 l_component_appl_id := 707;
166751 l_amb_context_code := 'DEFAULT';
166752 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
166753 l_event_class_code := 'WIP_MTL';
166754 l_event_type_code := 'WIP_NEG_COMP_ISSUE';
166755 l_line_definition_owner_code := 'S';
166756 l_line_definition_code := 'PI_WIP_NEG_COMP_ISSUE';
166757 --
166758 l_balance_type_code := 'A';
166759 l_segment := NULL;
166760 l_ccid := NULL;
166761 l_adr_transaction_coa_id := NULL;
166762 l_adr_accounting_coa_id := NULL;
166763 l_adr_flexfield_segment_code := NULL;
166764 l_adr_flex_value_set_id := NULL;
166765 l_adr_value_type_code := NULL;
166766 l_adr_value_combination_id := NULL;
166767 l_adr_value_segment_code := NULL;
166768
166769 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
166770 l_bflow_class_code := ''; -- 4219869 Business Flow
166771 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
166772 l_budgetary_control_flag := 'N';
166773
166774 l_bflow_applied_to_amt_idx := NULL; -- 5132302
166775 l_bflow_applied_to_amt := NULL; -- 5132302
166776 l_entered_amt_idx := NULL; -- 4262811
166777 l_accted_amt_idx := NULL; -- 4262811
166778 l_acc_rev_flag := NULL; -- 4262811
166779 l_accrual_line_num := NULL; -- 4262811
166780 l_tmp_amt := NULL; -- 4262811
166781 --
166782
166783 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
166784 l_balance_type_code <> 'B' THEN
166785 IF NVL(p_source_97,9E125) = 3
166786 THEN
166787
166788 --
166789 XLA_AE_LINES_PKG.SetNewLine;
166790
166791 p_balance_type_code := l_balance_type_code;
166792 -- set the flag so later we will know whether the gain loss line needs to be created
166793
166794 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
166795 p_actual_flag :='A';
166796 END IF;
166797
166798 --
166799 -- bulk performance
166800 --
166801 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
166802 p_header_num => 0); -- 4262811
166803 --
166804 -- set accounting line options
166805 --
166806 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
166807 p_natural_side_code => 'D'
166808 , p_gain_or_loss_flag => 'N'
166809 , p_gl_transfer_mode_code => 'S'
166810 , p_acct_entry_type_code => 'A'
166811 , p_switch_side_flag => 'Y'
166812 , p_merge_duplicate_code => 'N'
166813 );
166814 --
166815 l_acc_rev_natural_side_code := 'C'; -- 4262811
166816 --
166817 --
166818 -- set accounting line type info
166819 --
166820 xla_ae_lines_pkg.SetAcctLineType
166821 (p_component_type => l_component_type
166822 ,p_event_type_code => l_event_type_code
166823 ,p_line_definition_owner_code => l_line_definition_owner_code
166824 ,p_line_definition_code => l_line_definition_code
166825 ,p_accounting_line_code => l_component_code
166826 ,p_accounting_line_type_code => l_component_type_code
166827 ,p_accounting_line_appl_id => l_component_appl_id
166828 ,p_amb_context_code => l_amb_context_code
166829 ,p_entity_code => l_entity_code
166830 ,p_event_class_code => l_event_class_code);
166831 --
166832 -- set accounting class
166833 --
166834 xla_ae_lines_pkg.SetAcctClass(
166835 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
166836 , p_ae_header_id => l_ae_header_id
166837 );
166838
166839 --
166840 -- set rounding class
166841 --
166842 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
166843 'MATERIAL_OVERHEAD_ABSORPTION';
166844
166845 --
166846 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
166847 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
166848 --
166849 -- bulk performance
166850 --
166851 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
166852
166853 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
166854 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
166855
166856 -- 4955764
166857 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
166858 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
166859
166860 -- 4458381 Public Sector Enh
166861
166862 --
166863 -- set accounting attributes for the line type
166864 --
166865 l_entered_amt_idx := 3;
166866 l_accted_amt_idx := 8;
166867 l_bflow_applied_to_amt_idx := NULL; -- 5132302
166868 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
166869 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
166870 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
166871 l_rec_acct_attrs.array_char_value(2) := p_source_85;
166872 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
166873 l_rec_acct_attrs.array_num_value(3) := p_source_91;
166874 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
166875 l_rec_acct_attrs.array_char_value(4) := p_source_88;
166876 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
166877 l_rec_acct_attrs.array_date_value(5) := p_source_92;
166878 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
166879 l_rec_acct_attrs.array_num_value(6) := p_source_93;
166880 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
166881 l_rec_acct_attrs.array_char_value(7) := p_source_94;
166882 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
166883 l_rec_acct_attrs.array_num_value(8) := p_source_95;
166884
166885 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
166886 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
166887
166888 ---------------------------------------------------------------------------------------------------------------
166889 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
166890 ---------------------------------------------------------------------------------------------------------------
166891 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
166892
166893 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
166894 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
166895
166896 IF xla_accounting_cache_pkg.GetValueChar
166897 (p_source_code => 'LEDGER_CATEGORY_CODE'
166898 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
166899 AND l_bflow_method_code = 'PRIOR_ENTRY'
166900 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
166901 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
166902 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
166903 )
166904 THEN
166905 xla_ae_lines_pkg.BflowUpgEntry
166906 (p_business_method_code => l_bflow_method_code
166907 ,p_business_class_code => l_bflow_class_code
166908 ,p_balance_type => l_balance_type_code);
166909 ELSE
166910 NULL;
166911 -- No business flow processing for business flow method of NONE.
166912 END IF;
166913
166914 --
166915 -- call analytical criteria
166916 --
166917
166918 --
166919 -- call description
166920 --
166921
166922 xla_ae_lines_pkg.SetLineDescription(
166923 p_ae_header_id => l_ae_header_id
166924 ,p_description => Description_1 (
166925 p_application_id => p_application_id
166926 , p_ae_header_id => l_ae_header_id
166927 , p_source_1 => p_source_1
166928 , p_source_2 => p_source_2
166929 , p_source_3 => p_source_3
166930 , p_source_4 => p_source_4
166931 , p_source_5 => p_source_5
166932 )
166933 );
166934
166935
166936 --
166937 -- call ADRs
166938 -- Bug 4922099
166939 --
166940 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
166941 (NVL(l_actual_upg_option, 'N') = 'O') OR
166942 (NVL(l_enc_upg_option, 'N') = 'O')
166943 )
166944 THEN
166945 NULL;
166946 --
166947 --
166948
166949 l_ccid := AcctDerRule_6(
166950 p_application_id => p_application_id
166951 , p_ae_header_id => l_ae_header_id
166952 , p_source_11 => p_source_11
166953 , x_transaction_coa_id => l_adr_transaction_coa_id
166954 , x_accounting_coa_id => l_adr_accounting_coa_id
166955 , x_value_type_code => l_adr_value_type_code
166956 , p_side => 'NA'
166957 );
166958
166959 xla_ae_lines_pkg.set_ccid(
166960 p_code_combination_id => l_ccid
166961 , p_value_type_code => l_adr_value_type_code
166962 , p_transaction_coa_id => l_adr_transaction_coa_id
166963 , p_accounting_coa_id => l_adr_accounting_coa_id
166964 , p_adr_code => 'CST_DEFAULT'
166965 , p_adr_type_code => 'S'
166966 , p_component_type => l_component_type
166967 , p_component_code => l_component_code
166968 , p_component_type_code => l_component_type_code
166969 , p_component_appl_id => l_component_appl_id
166970 , p_amb_context_code => l_amb_context_code
166971 , p_side => 'NA'
166972 );
166973
166974
166975 --
166976 --
166977 END IF;
166978 --
166979 -- Bug 4922099
166980 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
166981 (NVL(l_enc_upg_option, 'N') = 'O')
166982 ) AND
166983 (l_bflow_method_code = 'PRIOR_ENTRY')
166984 )
166985 THEN
166986 IF
166987 --
166988 1 = 2
166989 --
166990 THEN
166991 xla_accounting_err_pkg.build_message
166992 (p_appli_s_name => 'XLA'
166993 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
166994 ,p_token_1 => 'LINE_NUMBER'
166995 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
166996 ,p_token_2 => 'LINE_TYPE_NAME'
166997 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
166998 l_component_type
166999 ,l_component_code
167000 ,l_component_type_code
167001 ,l_component_appl_id
167002 ,l_amb_context_code
167003 ,l_entity_code
167004 ,l_event_class_code
167005 )
167006 ,p_token_3 => 'OWNER'
167007 ,p_value_3 => xla_lookups_pkg.get_meaning(
167008 p_lookup_type => 'XLA_OWNER_TYPE'
167009 ,p_lookup_code => l_component_type_code
167010 )
167011 ,p_token_4 => 'PRODUCT_NAME'
167012 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
167013 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
167014 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
167015 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
167016 ,p_ae_header_id => NULL
167017 );
167018
167019 IF (C_LEVEL_ERROR>= g_log_level) THEN
167020 trace
167021 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
167022 ,p_level => C_LEVEL_ERROR
167023 ,p_module => l_log_module);
167024 END IF;
167025 END IF;
167026 END IF;
167027 --
167028 --
167029 ------------------------------------------------------------------------------------------------
167030 -- 4219869 Business Flow
167031 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
167032 -- Prior Entry. Currently, the following code is always generated.
167033 ------------------------------------------------------------------------------------------------
167034 XLA_AE_LINES_PKG.ValidateCurrentLine;
167035
167036 ------------------------------------------------------------------------------------
167037 -- 4219869 Business Flow
167038 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
167039 ------------------------------------------------------------------------------------
167040 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
167041
167042 ----------------------------------------------------------------------------------
167043 -- 4219869 Business Flow
167044 -- Update journal entry status -- Need to generate this within IF <condition>
167045 ----------------------------------------------------------------------------------
167046 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
167047 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
167048 ,p_balance_type_code => l_balance_type_code
167049 );
167050
167051 -------------------------------------------------------------------------------------------
167052 -- 4262811 - Generate the Accrual Reversal lines
167053 -------------------------------------------------------------------------------------------
167054 BEGIN
167055 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
167056 (g_array_event(p_event_id).array_value_num('header_index'));
167057 IF l_acc_rev_flag IS NULL THEN
167058 l_acc_rev_flag := 'N';
167059 END IF;
167060 EXCEPTION
167061 WHEN OTHERS THEN
167062 l_acc_rev_flag := 'N';
167063 END;
167064 --
167065 IF (l_acc_rev_flag = 'Y') THEN
167066
167067 -- 4645092 ------------------------------------------------------------------------------
167068 -- To allow MPA report to determine if it should generate report process
167069 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
167070 ------------------------------------------------------------------------------------------
167071
167072 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
167073 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
167074 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
167075 -- call ADRs
167076 -- Bug 4922099
167077 --
167078 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
167079 (NVL(l_actual_upg_option, 'N') = 'O') OR
167080 (NVL(l_enc_upg_option, 'N') = 'O')
167081 )
167082 THEN
167083 NULL;
167084 --
167085 --
167086
167087 l_ccid := AcctDerRule_6(
167088 p_application_id => p_application_id
167089 , p_ae_header_id => l_ae_header_id
167090 , p_source_11 => p_source_11
167091 , x_transaction_coa_id => l_adr_transaction_coa_id
167092 , x_accounting_coa_id => l_adr_accounting_coa_id
167093 , x_value_type_code => l_adr_value_type_code
167094 , p_side => 'NA'
167095 );
167096
167097 xla_ae_lines_pkg.set_ccid(
167098 p_code_combination_id => l_ccid
167099 , p_value_type_code => l_adr_value_type_code
167100 , p_transaction_coa_id => l_adr_transaction_coa_id
167101 , p_accounting_coa_id => l_adr_accounting_coa_id
167102 , p_adr_code => 'CST_DEFAULT'
167103 , p_adr_type_code => 'S'
167104 , p_component_type => l_component_type
167105 , p_component_code => l_component_code
167106 , p_component_type_code => l_component_type_code
167107 , p_component_appl_id => l_component_appl_id
167108 , p_amb_context_code => l_amb_context_code
167109 , p_side => 'NA'
167110 );
167111
167112
167113 --
167114 --
167115 END IF;
167116
167117 --
167118 -- Update the line information that should be overwritten
167119 --
167120 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
167121 p_header_num => 1);
167122 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
167123
167124 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
167125
167126 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
167127 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
167128 END IF;
167129
167130 --
167131 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
167132 --
167133 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
167134 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
167135 ELSE
167136 ---------------------------------------------------------------------------------------------------
167137 -- 4262811a Switch Sign
167138 ---------------------------------------------------------------------------------------------------
167139 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
167140 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
167141 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167142 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
167143 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167144 -- 5132302
167145 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
167146 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167147
167148 END IF;
167149
167150 -- 4955764
167151 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
167152 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
167153
167154
167155 XLA_AE_LINES_PKG.ValidateCurrentLine;
167156 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
167157
167158 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
167159 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
167160 ,p_balance_type_code => l_balance_type_code);
167161
167162 END IF;
167163
167164 -----------------------------------------------------------------------------------------
167165 -- 4262811 Multiperiod Accounting
167166 -----------------------------------------------------------------------------------------
167167 -- No MPA option is assigned.
167168
167169
167170 END IF;
167171 END IF;
167172 --
167173
167174 --
167175 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
167176 trace
167177 (p_msg => 'END of AcctLineType_309'
167178 ,p_level => C_LEVEL_PROCEDURE
167179 ,p_module => l_log_module);
167180 END IF;
167181 --
167182 EXCEPTION
167183 WHEN xla_exceptions_pkg.application_exception THEN
167184 RAISE;
167185 WHEN OTHERS THEN
167186 xla_exceptions_pkg.raise_message
167187 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_309');
167188 END AcctLineType_309;
167189 --
167190
167191 ---------------------------------------
167192 --
167193 -- PRIVATE FUNCTION
167194 -- AcctLineType_310
167195 --
167196 ---------------------------------------
167197 PROCEDURE AcctLineType_310 (
167198 p_application_id IN NUMBER
167199 ,p_event_id IN NUMBER
167200 ,p_calculate_acctd_flag IN VARCHAR2
167201 ,p_calculate_g_l_flag IN VARCHAR2
167202 ,p_actual_flag IN OUT VARCHAR2
167203 ,p_balance_type_code OUT VARCHAR2
167204 ,p_gain_or_loss_ref OUT VARCHAR2
167205
167206 --TRANSACTION_ID
167207 , p_source_1 IN NUMBER
167208 --Item Concatenated Segments
167209 , p_source_2 IN VARCHAR2
167210 --Transaction Quantity
167211 , p_source_3 IN NUMBER
167212 --Transaction Unit of Measure Code
167213 , p_source_4 IN VARCHAR2
167214 --Inventory Transaction Type Description
167215 , p_source_5 IN VARCHAR2
167216 --Cost Management Default Account
167217 , p_source_11 IN NUMBER
167218 --DISTRIBUTION_IDENTIFIER
167219 , p_source_84 IN NUMBER
167220 --Distribution Type
167221 , p_source_85 IN VARCHAR2
167222 , p_source_85_meaning IN VARCHAR2
167223 --Entered Currency Code
167224 , p_source_88 IN VARCHAR2
167225 --Entered Amount
167226 , p_source_91 IN NUMBER
167227 --Currency Conversion Date
167228 , p_source_92 IN DATE
167229 --Currency Conversion Rate
167230 , p_source_93 IN NUMBER
167231 --Currency Conversion Type
167232 , p_source_94 IN VARCHAR2
167233 --Accounted Amount
167234 , p_source_95 IN NUMBER
167235 --Accounting Line Type
167236 , p_source_97 IN NUMBER
167237 )
167238 IS
167239
167240 l_component_type VARCHAR2(80);
167241 l_component_code VARCHAR2(30);
167242 l_component_type_code VARCHAR2(1);
167243 l_component_appl_id INTEGER;
167244 l_amb_context_code VARCHAR2(30);
167245 l_entity_code VARCHAR2(30);
167246 l_event_class_code VARCHAR2(30);
167247 l_ae_header_id NUMBER;
167248 l_event_type_code VARCHAR2(30);
167249 l_line_definition_code VARCHAR2(30);
167250 l_line_definition_owner_code VARCHAR2(1);
167251 --
167252 -- adr variables
167253 l_segment VARCHAR2(30);
167254 l_ccid NUMBER;
167255 l_adr_transaction_coa_id NUMBER;
167256 l_adr_accounting_coa_id NUMBER;
167257 l_adr_flexfield_segment_code VARCHAR2(30);
167258 l_adr_flex_value_set_id NUMBER;
167259 l_adr_value_type_code VARCHAR2(30);
167260 l_adr_value_combination_id NUMBER;
167261 l_adr_value_segment_code VARCHAR2(30);
167262
167263 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
167264 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
167265 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
167266 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
167267
167268 -- 4262811 Variables ------------------------------------------------------------------------------------------
167269 l_entered_amt_idx NUMBER;
167270 l_accted_amt_idx NUMBER;
167271 l_acc_rev_flag VARCHAR2(1);
167272 l_accrual_line_num NUMBER;
167273 l_tmp_amt NUMBER;
167274 l_acc_rev_natural_side_code VARCHAR2(1);
167275
167276 l_num_entries NUMBER;
167277 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
167278 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
167279 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
167280 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
167281 l_recog_line_1 NUMBER;
167282 l_recog_line_2 NUMBER;
167283
167284 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
167285 l_bflow_applied_to_amt NUMBER; -- 5132302
167286 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
167287
167288 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
167289
167290 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
167291 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
167292
167293 ---------------------------------------------------------------------------------------------------------------
167294
167295
167296 --
167297 -- bulk performance
167298 --
167299 l_balance_type_code VARCHAR2(1);
167300 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
167301 l_log_module VARCHAR2(240);
167302
167303 --
167304 -- Upgrade strategy
167305 --
167306 l_actual_upg_option VARCHAR2(1);
167307 l_enc_upg_option VARCHAR2(1);
167308
167309 --
167310 BEGIN
167311 --
167312 IF g_log_enabled THEN
167313 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_310';
167314 END IF;
167315 --
167316 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
167317
167318 trace
167319 (p_msg => 'BEGIN of AcctLineType_310'
167320 ,p_level => C_LEVEL_PROCEDURE
167321 ,p_module => l_log_module);
167322
167323 END IF;
167324 --
167325 l_component_type := 'AMB_JLT';
167326 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
167327 l_component_type_code := 'S';
167328 l_component_appl_id := 707;
167329 l_amb_context_code := 'DEFAULT';
167330 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
167331 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
167332 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
167333 l_line_definition_owner_code := 'S';
167334 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
167335 --
167336 l_balance_type_code := 'A';
167337 l_segment := NULL;
167338 l_ccid := NULL;
167339 l_adr_transaction_coa_id := NULL;
167340 l_adr_accounting_coa_id := NULL;
167341 l_adr_flexfield_segment_code := NULL;
167342 l_adr_flex_value_set_id := NULL;
167343 l_adr_value_type_code := NULL;
167344 l_adr_value_combination_id := NULL;
167345 l_adr_value_segment_code := NULL;
167346
167347 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
167348 l_bflow_class_code := ''; -- 4219869 Business Flow
167349 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
167350 l_budgetary_control_flag := 'N';
167351
167352 l_bflow_applied_to_amt_idx := NULL; -- 5132302
167353 l_bflow_applied_to_amt := NULL; -- 5132302
167354 l_entered_amt_idx := NULL; -- 4262811
167355 l_accted_amt_idx := NULL; -- 4262811
167356 l_acc_rev_flag := NULL; -- 4262811
167357 l_accrual_line_num := NULL; -- 4262811
167358 l_tmp_amt := NULL; -- 4262811
167359 --
167360
167361 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
167362 l_balance_type_code <> 'B' THEN
167363 IF NVL(p_source_97,9E125) = 3
167364 THEN
167365
167366 --
167367 XLA_AE_LINES_PKG.SetNewLine;
167368
167369 p_balance_type_code := l_balance_type_code;
167370 -- set the flag so later we will know whether the gain loss line needs to be created
167371
167372 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
167373 p_actual_flag :='A';
167374 END IF;
167375
167376 --
167377 -- bulk performance
167378 --
167379 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
167380 p_header_num => 0); -- 4262811
167381 --
167382 -- set accounting line options
167383 --
167384 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
167385 p_natural_side_code => 'D'
167386 , p_gain_or_loss_flag => 'N'
167387 , p_gl_transfer_mode_code => 'S'
167388 , p_acct_entry_type_code => 'A'
167389 , p_switch_side_flag => 'Y'
167390 , p_merge_duplicate_code => 'N'
167391 );
167392 --
167393 l_acc_rev_natural_side_code := 'C'; -- 4262811
167394 --
167395 --
167396 -- set accounting line type info
167397 --
167398 xla_ae_lines_pkg.SetAcctLineType
167399 (p_component_type => l_component_type
167400 ,p_event_type_code => l_event_type_code
167401 ,p_line_definition_owner_code => l_line_definition_owner_code
167402 ,p_line_definition_code => l_line_definition_code
167403 ,p_accounting_line_code => l_component_code
167404 ,p_accounting_line_type_code => l_component_type_code
167405 ,p_accounting_line_appl_id => l_component_appl_id
167406 ,p_amb_context_code => l_amb_context_code
167407 ,p_entity_code => l_entity_code
167408 ,p_event_class_code => l_event_class_code);
167409 --
167410 -- set accounting class
167411 --
167412 xla_ae_lines_pkg.SetAcctClass(
167413 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
167414 , p_ae_header_id => l_ae_header_id
167415 );
167416
167417 --
167418 -- set rounding class
167419 --
167420 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
167421 'MATERIAL_OVERHEAD_ABSORPTION';
167422
167423 --
167424 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
167425 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
167426 --
167427 -- bulk performance
167428 --
167429 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
167430
167431 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
167432 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
167433
167434 -- 4955764
167435 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
167436 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
167437
167438 -- 4458381 Public Sector Enh
167439
167440 --
167441 -- set accounting attributes for the line type
167442 --
167443 l_entered_amt_idx := 3;
167444 l_accted_amt_idx := 8;
167445 l_bflow_applied_to_amt_idx := NULL; -- 5132302
167446 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
167447 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
167448 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
167449 l_rec_acct_attrs.array_char_value(2) := p_source_85;
167450 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
167451 l_rec_acct_attrs.array_num_value(3) := p_source_91;
167452 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
167453 l_rec_acct_attrs.array_char_value(4) := p_source_88;
167454 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
167455 l_rec_acct_attrs.array_date_value(5) := p_source_92;
167456 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
167457 l_rec_acct_attrs.array_num_value(6) := p_source_93;
167458 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
167459 l_rec_acct_attrs.array_char_value(7) := p_source_94;
167460 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
167461 l_rec_acct_attrs.array_num_value(8) := p_source_95;
167462
167463 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
167464 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
167465
167466 ---------------------------------------------------------------------------------------------------------------
167467 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
167468 ---------------------------------------------------------------------------------------------------------------
167469 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
167470
167471 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
167472 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
167473
167474 IF xla_accounting_cache_pkg.GetValueChar
167475 (p_source_code => 'LEDGER_CATEGORY_CODE'
167476 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
167477 AND l_bflow_method_code = 'PRIOR_ENTRY'
167478 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
167479 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
167480 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
167481 )
167482 THEN
167483 xla_ae_lines_pkg.BflowUpgEntry
167484 (p_business_method_code => l_bflow_method_code
167485 ,p_business_class_code => l_bflow_class_code
167486 ,p_balance_type => l_balance_type_code);
167487 ELSE
167488 NULL;
167489 -- No business flow processing for business flow method of NONE.
167490 END IF;
167491
167492 --
167493 -- call analytical criteria
167494 --
167495
167496 --
167497 -- call description
167498 --
167499
167500 xla_ae_lines_pkg.SetLineDescription(
167501 p_ae_header_id => l_ae_header_id
167502 ,p_description => Description_1 (
167503 p_application_id => p_application_id
167504 , p_ae_header_id => l_ae_header_id
167505 , p_source_1 => p_source_1
167506 , p_source_2 => p_source_2
167507 , p_source_3 => p_source_3
167508 , p_source_4 => p_source_4
167509 , p_source_5 => p_source_5
167510 )
167511 );
167512
167513
167514 --
167515 -- call ADRs
167516 -- Bug 4922099
167517 --
167518 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
167519 (NVL(l_actual_upg_option, 'N') = 'O') OR
167520 (NVL(l_enc_upg_option, 'N') = 'O')
167521 )
167522 THEN
167523 NULL;
167524 --
167525 --
167526
167527 l_ccid := AcctDerRule_6(
167528 p_application_id => p_application_id
167529 , p_ae_header_id => l_ae_header_id
167530 , p_source_11 => p_source_11
167531 , x_transaction_coa_id => l_adr_transaction_coa_id
167532 , x_accounting_coa_id => l_adr_accounting_coa_id
167533 , x_value_type_code => l_adr_value_type_code
167534 , p_side => 'NA'
167535 );
167536
167537 xla_ae_lines_pkg.set_ccid(
167538 p_code_combination_id => l_ccid
167539 , p_value_type_code => l_adr_value_type_code
167540 , p_transaction_coa_id => l_adr_transaction_coa_id
167541 , p_accounting_coa_id => l_adr_accounting_coa_id
167542 , p_adr_code => 'CST_DEFAULT'
167543 , p_adr_type_code => 'S'
167544 , p_component_type => l_component_type
167545 , p_component_code => l_component_code
167546 , p_component_type_code => l_component_type_code
167547 , p_component_appl_id => l_component_appl_id
167548 , p_amb_context_code => l_amb_context_code
167549 , p_side => 'NA'
167550 );
167551
167552
167553 --
167554 --
167555 END IF;
167556 --
167557 -- Bug 4922099
167558 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
167559 (NVL(l_enc_upg_option, 'N') = 'O')
167560 ) AND
167561 (l_bflow_method_code = 'PRIOR_ENTRY')
167562 )
167563 THEN
167564 IF
167565 --
167566 1 = 2
167567 --
167568 THEN
167569 xla_accounting_err_pkg.build_message
167570 (p_appli_s_name => 'XLA'
167571 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
167572 ,p_token_1 => 'LINE_NUMBER'
167573 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
167574 ,p_token_2 => 'LINE_TYPE_NAME'
167575 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
167576 l_component_type
167577 ,l_component_code
167578 ,l_component_type_code
167579 ,l_component_appl_id
167580 ,l_amb_context_code
167581 ,l_entity_code
167582 ,l_event_class_code
167583 )
167584 ,p_token_3 => 'OWNER'
167585 ,p_value_3 => xla_lookups_pkg.get_meaning(
167586 p_lookup_type => 'XLA_OWNER_TYPE'
167587 ,p_lookup_code => l_component_type_code
167588 )
167589 ,p_token_4 => 'PRODUCT_NAME'
167590 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
167591 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
167592 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
167593 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
167594 ,p_ae_header_id => NULL
167595 );
167596
167597 IF (C_LEVEL_ERROR>= g_log_level) THEN
167598 trace
167599 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
167600 ,p_level => C_LEVEL_ERROR
167601 ,p_module => l_log_module);
167602 END IF;
167603 END IF;
167604 END IF;
167605 --
167606 --
167607 ------------------------------------------------------------------------------------------------
167608 -- 4219869 Business Flow
167609 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
167610 -- Prior Entry. Currently, the following code is always generated.
167611 ------------------------------------------------------------------------------------------------
167612 XLA_AE_LINES_PKG.ValidateCurrentLine;
167613
167614 ------------------------------------------------------------------------------------
167615 -- 4219869 Business Flow
167616 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
167617 ------------------------------------------------------------------------------------
167618 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
167619
167620 ----------------------------------------------------------------------------------
167621 -- 4219869 Business Flow
167622 -- Update journal entry status -- Need to generate this within IF <condition>
167623 ----------------------------------------------------------------------------------
167624 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
167625 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
167626 ,p_balance_type_code => l_balance_type_code
167627 );
167628
167629 -------------------------------------------------------------------------------------------
167630 -- 4262811 - Generate the Accrual Reversal lines
167631 -------------------------------------------------------------------------------------------
167632 BEGIN
167633 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
167634 (g_array_event(p_event_id).array_value_num('header_index'));
167635 IF l_acc_rev_flag IS NULL THEN
167636 l_acc_rev_flag := 'N';
167637 END IF;
167638 EXCEPTION
167639 WHEN OTHERS THEN
167640 l_acc_rev_flag := 'N';
167641 END;
167642 --
167643 IF (l_acc_rev_flag = 'Y') THEN
167644
167645 -- 4645092 ------------------------------------------------------------------------------
167646 -- To allow MPA report to determine if it should generate report process
167647 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
167648 ------------------------------------------------------------------------------------------
167649
167650 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
167651 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
167652 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
167653 -- call ADRs
167654 -- Bug 4922099
167655 --
167656 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
167657 (NVL(l_actual_upg_option, 'N') = 'O') OR
167658 (NVL(l_enc_upg_option, 'N') = 'O')
167659 )
167660 THEN
167661 NULL;
167662 --
167663 --
167664
167665 l_ccid := AcctDerRule_6(
167666 p_application_id => p_application_id
167667 , p_ae_header_id => l_ae_header_id
167668 , p_source_11 => p_source_11
167669 , x_transaction_coa_id => l_adr_transaction_coa_id
167670 , x_accounting_coa_id => l_adr_accounting_coa_id
167671 , x_value_type_code => l_adr_value_type_code
167672 , p_side => 'NA'
167673 );
167674
167675 xla_ae_lines_pkg.set_ccid(
167676 p_code_combination_id => l_ccid
167677 , p_value_type_code => l_adr_value_type_code
167678 , p_transaction_coa_id => l_adr_transaction_coa_id
167679 , p_accounting_coa_id => l_adr_accounting_coa_id
167680 , p_adr_code => 'CST_DEFAULT'
167681 , p_adr_type_code => 'S'
167682 , p_component_type => l_component_type
167683 , p_component_code => l_component_code
167684 , p_component_type_code => l_component_type_code
167685 , p_component_appl_id => l_component_appl_id
167686 , p_amb_context_code => l_amb_context_code
167687 , p_side => 'NA'
167688 );
167689
167690
167691 --
167692 --
167693 END IF;
167694
167695 --
167696 -- Update the line information that should be overwritten
167697 --
167698 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
167699 p_header_num => 1);
167700 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
167701
167702 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
167703
167704 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
167705 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
167706 END IF;
167707
167708 --
167709 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
167710 --
167711 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
167712 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
167713 ELSE
167714 ---------------------------------------------------------------------------------------------------
167715 -- 4262811a Switch Sign
167716 ---------------------------------------------------------------------------------------------------
167717 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
167718 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
167719 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167720 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
167721 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167722 -- 5132302
167723 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
167724 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
167725
167726 END IF;
167727
167728 -- 4955764
167729 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
167730 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
167731
167732
167733 XLA_AE_LINES_PKG.ValidateCurrentLine;
167734 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
167735
167736 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
167737 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
167738 ,p_balance_type_code => l_balance_type_code);
167739
167740 END IF;
167741
167742 -----------------------------------------------------------------------------------------
167743 -- 4262811 Multiperiod Accounting
167744 -----------------------------------------------------------------------------------------
167745 -- No MPA option is assigned.
167746
167747
167748 END IF;
167749 END IF;
167750 --
167751
167752 --
167753 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
167754 trace
167755 (p_msg => 'END of AcctLineType_310'
167756 ,p_level => C_LEVEL_PROCEDURE
167757 ,p_module => l_log_module);
167758 END IF;
167759 --
167760 EXCEPTION
167761 WHEN xla_exceptions_pkg.application_exception THEN
167762 RAISE;
167763 WHEN OTHERS THEN
167764 xla_exceptions_pkg.raise_message
167765 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_310');
167766 END AcctLineType_310;
167767 --
167768
167769 ---------------------------------------
167770 --
167771 -- PRIVATE FUNCTION
167772 -- AcctLineType_311
167773 --
167774 ---------------------------------------
167775 PROCEDURE AcctLineType_311 (
167776 p_application_id IN NUMBER
167777 ,p_event_id IN NUMBER
167778 ,p_calculate_acctd_flag IN VARCHAR2
167779 ,p_calculate_g_l_flag IN VARCHAR2
167780 ,p_actual_flag IN OUT VARCHAR2
167781 ,p_balance_type_code OUT VARCHAR2
167782 ,p_gain_or_loss_ref OUT VARCHAR2
167783
167784 --TRANSACTION_ID
167785 , p_source_1 IN NUMBER
167786 --Item Concatenated Segments
167787 , p_source_2 IN VARCHAR2
167788 --Transaction Quantity
167789 , p_source_3 IN NUMBER
167790 --Transaction Unit of Measure Code
167791 , p_source_4 IN VARCHAR2
167792 --Inventory Transaction Type Description
167793 , p_source_5 IN VARCHAR2
167794 --Resource/ Overhead Absorption Account
167795 , p_source_13 IN NUMBER
167796 --DISTRIBUTION_IDENTIFIER
167797 , p_source_84 IN NUMBER
167798 --Distribution Type
167799 , p_source_85 IN VARCHAR2
167800 , p_source_85_meaning IN VARCHAR2
167801 --Entered Currency Code
167802 , p_source_88 IN VARCHAR2
167803 --Entered Amount
167804 , p_source_91 IN NUMBER
167805 --Currency Conversion Date
167806 , p_source_92 IN DATE
167807 --Currency Conversion Rate
167808 , p_source_93 IN NUMBER
167809 --Currency Conversion Type
167810 , p_source_94 IN VARCHAR2
167811 --Accounted Amount
167812 , p_source_95 IN NUMBER
167813 --Accounting Line Type
167814 , p_source_97 IN NUMBER
167815 )
167816 IS
167817
167818 l_component_type VARCHAR2(80);
167819 l_component_code VARCHAR2(30);
167820 l_component_type_code VARCHAR2(1);
167821 l_component_appl_id INTEGER;
167822 l_amb_context_code VARCHAR2(30);
167823 l_entity_code VARCHAR2(30);
167824 l_event_class_code VARCHAR2(30);
167825 l_ae_header_id NUMBER;
167826 l_event_type_code VARCHAR2(30);
167827 l_line_definition_code VARCHAR2(30);
167828 l_line_definition_owner_code VARCHAR2(1);
167829 --
167830 -- adr variables
167831 l_segment VARCHAR2(30);
167832 l_ccid NUMBER;
167833 l_adr_transaction_coa_id NUMBER;
167834 l_adr_accounting_coa_id NUMBER;
167835 l_adr_flexfield_segment_code VARCHAR2(30);
167836 l_adr_flex_value_set_id NUMBER;
167837 l_adr_value_type_code VARCHAR2(30);
167838 l_adr_value_combination_id NUMBER;
167839 l_adr_value_segment_code VARCHAR2(30);
167840
167841 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
167842 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
167843 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
167844 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
167845
167846 -- 4262811 Variables ------------------------------------------------------------------------------------------
167847 l_entered_amt_idx NUMBER;
167848 l_accted_amt_idx NUMBER;
167849 l_acc_rev_flag VARCHAR2(1);
167850 l_accrual_line_num NUMBER;
167851 l_tmp_amt NUMBER;
167852 l_acc_rev_natural_side_code VARCHAR2(1);
167853
167854 l_num_entries NUMBER;
167855 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
167856 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
167857 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
167858 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
167859 l_recog_line_1 NUMBER;
167860 l_recog_line_2 NUMBER;
167861
167862 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
167863 l_bflow_applied_to_amt NUMBER; -- 5132302
167864 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
167865
167866 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
167867
167868 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
167869 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
167870
167871 ---------------------------------------------------------------------------------------------------------------
167872
167873
167874 --
167875 -- bulk performance
167876 --
167877 l_balance_type_code VARCHAR2(1);
167878 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
167879 l_log_module VARCHAR2(240);
167880
167881 --
167882 -- Upgrade strategy
167883 --
167884 l_actual_upg_option VARCHAR2(1);
167885 l_enc_upg_option VARCHAR2(1);
167886
167887 --
167888 BEGIN
167889 --
167890 IF g_log_enabled THEN
167891 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_311';
167892 END IF;
167893 --
167894 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
167895
167896 trace
167897 (p_msg => 'BEGIN of AcctLineType_311'
167898 ,p_level => C_LEVEL_PROCEDURE
167899 ,p_module => l_log_module);
167900
167901 END IF;
167902 --
167903 l_component_type := 'AMB_JLT';
167904 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
167905 l_component_type_code := 'S';
167906 l_component_appl_id := 707;
167907 l_amb_context_code := 'DEFAULT';
167908 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
167909 l_event_class_code := 'WIP_MTL';
167910 l_event_type_code := 'WIP_ASSEMBLY_RETURN';
167911 l_line_definition_owner_code := 'S';
167912 l_line_definition_code := 'PI_WIP_ASSEMBLY_RETURN';
167913 --
167914 l_balance_type_code := 'A';
167915 l_segment := NULL;
167916 l_ccid := NULL;
167917 l_adr_transaction_coa_id := NULL;
167918 l_adr_accounting_coa_id := NULL;
167919 l_adr_flexfield_segment_code := NULL;
167920 l_adr_flex_value_set_id := NULL;
167921 l_adr_value_type_code := NULL;
167922 l_adr_value_combination_id := NULL;
167923 l_adr_value_segment_code := NULL;
167924
167925 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
167926 l_bflow_class_code := ''; -- 4219869 Business Flow
167927 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
167928 l_budgetary_control_flag := 'N';
167929
167930 l_bflow_applied_to_amt_idx := NULL; -- 5132302
167931 l_bflow_applied_to_amt := NULL; -- 5132302
167932 l_entered_amt_idx := NULL; -- 4262811
167933 l_accted_amt_idx := NULL; -- 4262811
167934 l_acc_rev_flag := NULL; -- 4262811
167935 l_accrual_line_num := NULL; -- 4262811
167936 l_tmp_amt := NULL; -- 4262811
167937 --
167938
167939 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
167940 l_balance_type_code <> 'B' THEN
167941 IF NVL(p_source_97,9E125) = 3
167942 THEN
167943
167944 --
167945 XLA_AE_LINES_PKG.SetNewLine;
167946
167947 p_balance_type_code := l_balance_type_code;
167948 -- set the flag so later we will know whether the gain loss line needs to be created
167949
167950 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
167951 p_actual_flag :='A';
167952 END IF;
167953
167954 --
167955 -- bulk performance
167956 --
167957 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
167958 p_header_num => 0); -- 4262811
167959 --
167960 -- set accounting line options
167961 --
167962 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
167963 p_natural_side_code => 'D'
167964 , p_gain_or_loss_flag => 'N'
167965 , p_gl_transfer_mode_code => 'S'
167966 , p_acct_entry_type_code => 'A'
167967 , p_switch_side_flag => 'Y'
167968 , p_merge_duplicate_code => 'N'
167969 );
167970 --
167971 l_acc_rev_natural_side_code := 'C'; -- 4262811
167972 --
167973 --
167974 -- set accounting line type info
167975 --
167976 xla_ae_lines_pkg.SetAcctLineType
167977 (p_component_type => l_component_type
167978 ,p_event_type_code => l_event_type_code
167979 ,p_line_definition_owner_code => l_line_definition_owner_code
167980 ,p_line_definition_code => l_line_definition_code
167981 ,p_accounting_line_code => l_component_code
167982 ,p_accounting_line_type_code => l_component_type_code
167983 ,p_accounting_line_appl_id => l_component_appl_id
167984 ,p_amb_context_code => l_amb_context_code
167985 ,p_entity_code => l_entity_code
167986 ,p_event_class_code => l_event_class_code);
167987 --
167988 -- set accounting class
167989 --
167990 xla_ae_lines_pkg.SetAcctClass(
167991 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
167992 , p_ae_header_id => l_ae_header_id
167993 );
167994
167995 --
167996 -- set rounding class
167997 --
167998 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
167999 'MATERIAL_OVERHEAD_ABSORPTION';
168000
168001 --
168002 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
168003 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
168004 --
168005 -- bulk performance
168006 --
168007 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
168008
168009 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
168010 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
168011
168012 -- 4955764
168013 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
168014 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
168015
168016 -- 4458381 Public Sector Enh
168017
168018 --
168019 -- set accounting attributes for the line type
168020 --
168021 l_entered_amt_idx := 3;
168022 l_accted_amt_idx := 8;
168023 l_bflow_applied_to_amt_idx := NULL; -- 5132302
168024 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
168025 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
168026 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
168027 l_rec_acct_attrs.array_char_value(2) := p_source_85;
168028 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
168029 l_rec_acct_attrs.array_num_value(3) := p_source_91;
168030 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
168031 l_rec_acct_attrs.array_char_value(4) := p_source_88;
168032 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
168033 l_rec_acct_attrs.array_date_value(5) := p_source_92;
168034 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
168035 l_rec_acct_attrs.array_num_value(6) := p_source_93;
168036 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
168037 l_rec_acct_attrs.array_char_value(7) := p_source_94;
168038 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
168039 l_rec_acct_attrs.array_num_value(8) := p_source_95;
168040
168041 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
168042 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
168043
168044 ---------------------------------------------------------------------------------------------------------------
168045 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
168046 ---------------------------------------------------------------------------------------------------------------
168047 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
168048
168049 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
168050 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
168051
168052 IF xla_accounting_cache_pkg.GetValueChar
168053 (p_source_code => 'LEDGER_CATEGORY_CODE'
168054 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
168055 AND l_bflow_method_code = 'PRIOR_ENTRY'
168056 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
168057 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
168058 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
168059 )
168060 THEN
168061 xla_ae_lines_pkg.BflowUpgEntry
168062 (p_business_method_code => l_bflow_method_code
168063 ,p_business_class_code => l_bflow_class_code
168064 ,p_balance_type => l_balance_type_code);
168065 ELSE
168066 NULL;
168067 -- No business flow processing for business flow method of NONE.
168068 END IF;
168069
168070 --
168071 -- call analytical criteria
168072 --
168073
168074 --
168075 -- call description
168076 --
168077
168078 xla_ae_lines_pkg.SetLineDescription(
168079 p_ae_header_id => l_ae_header_id
168080 ,p_description => Description_1 (
168081 p_application_id => p_application_id
168082 , p_ae_header_id => l_ae_header_id
168083 , p_source_1 => p_source_1
168084 , p_source_2 => p_source_2
168085 , p_source_3 => p_source_3
168086 , p_source_4 => p_source_4
168087 , p_source_5 => p_source_5
168088 )
168089 );
168090
168091
168092 --
168093 -- call ADRs
168094 -- Bug 4922099
168095 --
168096 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
168097 (NVL(l_actual_upg_option, 'N') = 'O') OR
168098 (NVL(l_enc_upg_option, 'N') = 'O')
168099 )
168100 THEN
168101 NULL;
168102 --
168103 --
168104
168105 l_ccid := AcctDerRule_8(
168106 p_application_id => p_application_id
168107 , p_ae_header_id => l_ae_header_id
168108 , p_source_13 => p_source_13
168109 , x_transaction_coa_id => l_adr_transaction_coa_id
168110 , x_accounting_coa_id => l_adr_accounting_coa_id
168111 , x_value_type_code => l_adr_value_type_code
168112 , p_side => 'NA'
168113 );
168114
168115 xla_ae_lines_pkg.set_ccid(
168116 p_code_combination_id => l_ccid
168117 , p_value_type_code => l_adr_value_type_code
168118 , p_transaction_coa_id => l_adr_transaction_coa_id
168119 , p_accounting_coa_id => l_adr_accounting_coa_id
168120 , p_adr_code => 'PI_ABSORPTION'
168121 , p_adr_type_code => 'S'
168122 , p_component_type => l_component_type
168123 , p_component_code => l_component_code
168124 , p_component_type_code => l_component_type_code
168125 , p_component_appl_id => l_component_appl_id
168126 , p_amb_context_code => l_amb_context_code
168127 , p_side => 'NA'
168128 );
168129
168130
168131 --
168132 --
168133 END IF;
168134 --
168135 -- Bug 4922099
168136 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
168137 (NVL(l_enc_upg_option, 'N') = 'O')
168138 ) AND
168139 (l_bflow_method_code = 'PRIOR_ENTRY')
168140 )
168141 THEN
168142 IF
168143 --
168144 1 = 2
168145 --
168146 THEN
168147 xla_accounting_err_pkg.build_message
168148 (p_appli_s_name => 'XLA'
168149 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
168150 ,p_token_1 => 'LINE_NUMBER'
168151 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
168152 ,p_token_2 => 'LINE_TYPE_NAME'
168153 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
168154 l_component_type
168155 ,l_component_code
168156 ,l_component_type_code
168157 ,l_component_appl_id
168158 ,l_amb_context_code
168159 ,l_entity_code
168160 ,l_event_class_code
168161 )
168162 ,p_token_3 => 'OWNER'
168163 ,p_value_3 => xla_lookups_pkg.get_meaning(
168164 p_lookup_type => 'XLA_OWNER_TYPE'
168165 ,p_lookup_code => l_component_type_code
168166 )
168167 ,p_token_4 => 'PRODUCT_NAME'
168168 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
168169 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
168170 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
168171 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
168172 ,p_ae_header_id => NULL
168173 );
168174
168175 IF (C_LEVEL_ERROR>= g_log_level) THEN
168176 trace
168177 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
168178 ,p_level => C_LEVEL_ERROR
168179 ,p_module => l_log_module);
168180 END IF;
168181 END IF;
168182 END IF;
168183 --
168184 --
168185 ------------------------------------------------------------------------------------------------
168186 -- 4219869 Business Flow
168187 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
168188 -- Prior Entry. Currently, the following code is always generated.
168189 ------------------------------------------------------------------------------------------------
168190 XLA_AE_LINES_PKG.ValidateCurrentLine;
168191
168192 ------------------------------------------------------------------------------------
168193 -- 4219869 Business Flow
168194 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
168195 ------------------------------------------------------------------------------------
168196 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
168197
168198 ----------------------------------------------------------------------------------
168199 -- 4219869 Business Flow
168200 -- Update journal entry status -- Need to generate this within IF <condition>
168201 ----------------------------------------------------------------------------------
168202 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
168203 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
168204 ,p_balance_type_code => l_balance_type_code
168205 );
168206
168207 -------------------------------------------------------------------------------------------
168208 -- 4262811 - Generate the Accrual Reversal lines
168209 -------------------------------------------------------------------------------------------
168210 BEGIN
168211 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
168212 (g_array_event(p_event_id).array_value_num('header_index'));
168213 IF l_acc_rev_flag IS NULL THEN
168214 l_acc_rev_flag := 'N';
168215 END IF;
168216 EXCEPTION
168217 WHEN OTHERS THEN
168218 l_acc_rev_flag := 'N';
168219 END;
168220 --
168221 IF (l_acc_rev_flag = 'Y') THEN
168222
168223 -- 4645092 ------------------------------------------------------------------------------
168224 -- To allow MPA report to determine if it should generate report process
168225 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
168226 ------------------------------------------------------------------------------------------
168227
168228 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
168229 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
168230 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
168231 -- call ADRs
168232 -- Bug 4922099
168233 --
168234 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
168235 (NVL(l_actual_upg_option, 'N') = 'O') OR
168236 (NVL(l_enc_upg_option, 'N') = 'O')
168237 )
168238 THEN
168239 NULL;
168240 --
168241 --
168242
168243 l_ccid := AcctDerRule_8(
168244 p_application_id => p_application_id
168245 , p_ae_header_id => l_ae_header_id
168246 , p_source_13 => p_source_13
168247 , x_transaction_coa_id => l_adr_transaction_coa_id
168248 , x_accounting_coa_id => l_adr_accounting_coa_id
168249 , x_value_type_code => l_adr_value_type_code
168250 , p_side => 'NA'
168251 );
168252
168253 xla_ae_lines_pkg.set_ccid(
168254 p_code_combination_id => l_ccid
168255 , p_value_type_code => l_adr_value_type_code
168256 , p_transaction_coa_id => l_adr_transaction_coa_id
168257 , p_accounting_coa_id => l_adr_accounting_coa_id
168258 , p_adr_code => 'PI_ABSORPTION'
168259 , p_adr_type_code => 'S'
168260 , p_component_type => l_component_type
168261 , p_component_code => l_component_code
168262 , p_component_type_code => l_component_type_code
168263 , p_component_appl_id => l_component_appl_id
168264 , p_amb_context_code => l_amb_context_code
168265 , p_side => 'NA'
168266 );
168267
168268
168269 --
168270 --
168271 END IF;
168272
168273 --
168274 -- Update the line information that should be overwritten
168275 --
168276 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
168277 p_header_num => 1);
168278 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
168279
168280 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
168281
168282 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
168283 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
168284 END IF;
168285
168286 --
168287 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
168288 --
168289 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
168290 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
168291 ELSE
168292 ---------------------------------------------------------------------------------------------------
168293 -- 4262811a Switch Sign
168294 ---------------------------------------------------------------------------------------------------
168295 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
168296 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
168297 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168298 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
168299 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168300 -- 5132302
168301 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
168302 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168303
168304 END IF;
168305
168306 -- 4955764
168307 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
168308 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
168309
168310
168311 XLA_AE_LINES_PKG.ValidateCurrentLine;
168312 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
168313
168314 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
168315 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
168316 ,p_balance_type_code => l_balance_type_code);
168317
168318 END IF;
168319
168320 -----------------------------------------------------------------------------------------
168321 -- 4262811 Multiperiod Accounting
168322 -----------------------------------------------------------------------------------------
168323 -- No MPA option is assigned.
168324
168325
168326 END IF;
168327 END IF;
168328 --
168329
168330 --
168331 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
168332 trace
168333 (p_msg => 'END of AcctLineType_311'
168334 ,p_level => C_LEVEL_PROCEDURE
168335 ,p_module => l_log_module);
168336 END IF;
168337 --
168338 EXCEPTION
168339 WHEN xla_exceptions_pkg.application_exception THEN
168340 RAISE;
168341 WHEN OTHERS THEN
168342 xla_exceptions_pkg.raise_message
168343 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_311');
168344 END AcctLineType_311;
168345 --
168346
168347 ---------------------------------------
168348 --
168349 -- PRIVATE FUNCTION
168350 -- AcctLineType_312
168351 --
168352 ---------------------------------------
168353 PROCEDURE AcctLineType_312 (
168354 p_application_id IN NUMBER
168355 ,p_event_id IN NUMBER
168356 ,p_calculate_acctd_flag IN VARCHAR2
168357 ,p_calculate_g_l_flag IN VARCHAR2
168358 ,p_actual_flag IN OUT VARCHAR2
168359 ,p_balance_type_code OUT VARCHAR2
168360 ,p_gain_or_loss_ref OUT VARCHAR2
168361
168362 --TRANSACTION_ID
168363 , p_source_1 IN NUMBER
168364 --Item Concatenated Segments
168365 , p_source_2 IN VARCHAR2
168366 --Transaction Quantity
168367 , p_source_3 IN NUMBER
168368 --Transaction Unit of Measure Code
168369 , p_source_4 IN VARCHAR2
168370 --Inventory Transaction Type Description
168371 , p_source_5 IN VARCHAR2
168372 --Cost Management Default Account
168373 , p_source_11 IN NUMBER
168374 --DISTRIBUTION_IDENTIFIER
168375 , p_source_84 IN NUMBER
168376 --Distribution Type
168377 , p_source_85 IN VARCHAR2
168378 , p_source_85_meaning IN VARCHAR2
168379 --Entered Currency Code
168380 , p_source_88 IN VARCHAR2
168381 --Entered Amount
168382 , p_source_91 IN NUMBER
168383 --Currency Conversion Date
168384 , p_source_92 IN DATE
168385 --Currency Conversion Rate
168386 , p_source_93 IN NUMBER
168387 --Currency Conversion Type
168388 , p_source_94 IN VARCHAR2
168389 --Accounted Amount
168390 , p_source_95 IN NUMBER
168391 --Accounting Line Type
168392 , p_source_97 IN NUMBER
168393 )
168394 IS
168395
168396 l_component_type VARCHAR2(80);
168397 l_component_code VARCHAR2(30);
168398 l_component_type_code VARCHAR2(1);
168399 l_component_appl_id INTEGER;
168400 l_amb_context_code VARCHAR2(30);
168401 l_entity_code VARCHAR2(30);
168402 l_event_class_code VARCHAR2(30);
168403 l_ae_header_id NUMBER;
168404 l_event_type_code VARCHAR2(30);
168405 l_line_definition_code VARCHAR2(30);
168406 l_line_definition_owner_code VARCHAR2(1);
168407 --
168408 -- adr variables
168409 l_segment VARCHAR2(30);
168410 l_ccid NUMBER;
168411 l_adr_transaction_coa_id NUMBER;
168412 l_adr_accounting_coa_id NUMBER;
168413 l_adr_flexfield_segment_code VARCHAR2(30);
168414 l_adr_flex_value_set_id NUMBER;
168415 l_adr_value_type_code VARCHAR2(30);
168416 l_adr_value_combination_id NUMBER;
168417 l_adr_value_segment_code VARCHAR2(30);
168418
168419 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
168420 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
168421 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
168422 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
168423
168424 -- 4262811 Variables ------------------------------------------------------------------------------------------
168425 l_entered_amt_idx NUMBER;
168426 l_accted_amt_idx NUMBER;
168427 l_acc_rev_flag VARCHAR2(1);
168428 l_accrual_line_num NUMBER;
168429 l_tmp_amt NUMBER;
168430 l_acc_rev_natural_side_code VARCHAR2(1);
168431
168432 l_num_entries NUMBER;
168433 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
168434 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
168435 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
168436 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
168437 l_recog_line_1 NUMBER;
168438 l_recog_line_2 NUMBER;
168439
168440 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
168441 l_bflow_applied_to_amt NUMBER; -- 5132302
168442 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
168443
168444 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
168445
168446 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
168447 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
168448
168449 ---------------------------------------------------------------------------------------------------------------
168450
168451
168452 --
168453 -- bulk performance
168454 --
168455 l_balance_type_code VARCHAR2(1);
168456 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
168457 l_log_module VARCHAR2(240);
168458
168459 --
168460 -- Upgrade strategy
168461 --
168462 l_actual_upg_option VARCHAR2(1);
168463 l_enc_upg_option VARCHAR2(1);
168464
168465 --
168466 BEGIN
168467 --
168468 IF g_log_enabled THEN
168469 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_312';
168470 END IF;
168471 --
168472 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
168473
168474 trace
168475 (p_msg => 'BEGIN of AcctLineType_312'
168476 ,p_level => C_LEVEL_PROCEDURE
168477 ,p_module => l_log_module);
168478
168479 END IF;
168480 --
168481 l_component_type := 'AMB_JLT';
168482 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
168483 l_component_type_code := 'S';
168484 l_component_appl_id := 707;
168485 l_amb_context_code := 'DEFAULT';
168486 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
168487 l_event_class_code := 'WIP_MTL';
168488 l_event_type_code := 'WIP_NEG_COMP_RETURN';
168489 l_line_definition_owner_code := 'S';
168490 l_line_definition_code := 'PI_WIP_NEG_COMP_RETURN';
168491 --
168492 l_balance_type_code := 'A';
168493 l_segment := NULL;
168494 l_ccid := NULL;
168495 l_adr_transaction_coa_id := NULL;
168496 l_adr_accounting_coa_id := NULL;
168497 l_adr_flexfield_segment_code := NULL;
168498 l_adr_flex_value_set_id := NULL;
168499 l_adr_value_type_code := NULL;
168500 l_adr_value_combination_id := NULL;
168501 l_adr_value_segment_code := NULL;
168502
168503 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
168504 l_bflow_class_code := ''; -- 4219869 Business Flow
168505 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
168506 l_budgetary_control_flag := 'N';
168507
168508 l_bflow_applied_to_amt_idx := NULL; -- 5132302
168509 l_bflow_applied_to_amt := NULL; -- 5132302
168510 l_entered_amt_idx := NULL; -- 4262811
168511 l_accted_amt_idx := NULL; -- 4262811
168512 l_acc_rev_flag := NULL; -- 4262811
168513 l_accrual_line_num := NULL; -- 4262811
168514 l_tmp_amt := NULL; -- 4262811
168515 --
168516
168517 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
168518 l_balance_type_code <> 'B' THEN
168519 IF NVL(p_source_97,9E125) = 3
168520 THEN
168521
168522 --
168523 XLA_AE_LINES_PKG.SetNewLine;
168524
168525 p_balance_type_code := l_balance_type_code;
168526 -- set the flag so later we will know whether the gain loss line needs to be created
168527
168528 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
168529 p_actual_flag :='A';
168530 END IF;
168531
168532 --
168533 -- bulk performance
168534 --
168535 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
168536 p_header_num => 0); -- 4262811
168537 --
168538 -- set accounting line options
168539 --
168540 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
168541 p_natural_side_code => 'D'
168542 , p_gain_or_loss_flag => 'N'
168543 , p_gl_transfer_mode_code => 'S'
168544 , p_acct_entry_type_code => 'A'
168545 , p_switch_side_flag => 'Y'
168546 , p_merge_duplicate_code => 'N'
168547 );
168548 --
168549 l_acc_rev_natural_side_code := 'C'; -- 4262811
168550 --
168551 --
168552 -- set accounting line type info
168553 --
168554 xla_ae_lines_pkg.SetAcctLineType
168555 (p_component_type => l_component_type
168556 ,p_event_type_code => l_event_type_code
168557 ,p_line_definition_owner_code => l_line_definition_owner_code
168558 ,p_line_definition_code => l_line_definition_code
168559 ,p_accounting_line_code => l_component_code
168560 ,p_accounting_line_type_code => l_component_type_code
168561 ,p_accounting_line_appl_id => l_component_appl_id
168562 ,p_amb_context_code => l_amb_context_code
168563 ,p_entity_code => l_entity_code
168564 ,p_event_class_code => l_event_class_code);
168565 --
168566 -- set accounting class
168567 --
168568 xla_ae_lines_pkg.SetAcctClass(
168569 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
168570 , p_ae_header_id => l_ae_header_id
168571 );
168572
168573 --
168574 -- set rounding class
168575 --
168576 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
168577 'MATERIAL_OVERHEAD_ABSORPTION';
168578
168579 --
168580 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
168581 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
168582 --
168583 -- bulk performance
168584 --
168585 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
168586
168587 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
168588 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
168589
168590 -- 4955764
168591 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
168592 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
168593
168594 -- 4458381 Public Sector Enh
168595
168596 --
168597 -- set accounting attributes for the line type
168598 --
168599 l_entered_amt_idx := 3;
168600 l_accted_amt_idx := 8;
168601 l_bflow_applied_to_amt_idx := NULL; -- 5132302
168602 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
168603 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
168604 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
168605 l_rec_acct_attrs.array_char_value(2) := p_source_85;
168606 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
168607 l_rec_acct_attrs.array_num_value(3) := p_source_91;
168608 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
168609 l_rec_acct_attrs.array_char_value(4) := p_source_88;
168610 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
168611 l_rec_acct_attrs.array_date_value(5) := p_source_92;
168612 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
168613 l_rec_acct_attrs.array_num_value(6) := p_source_93;
168614 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
168615 l_rec_acct_attrs.array_char_value(7) := p_source_94;
168616 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
168617 l_rec_acct_attrs.array_num_value(8) := p_source_95;
168618
168619 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
168620 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
168621
168622 ---------------------------------------------------------------------------------------------------------------
168623 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
168624 ---------------------------------------------------------------------------------------------------------------
168625 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
168626
168627 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
168628 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
168629
168630 IF xla_accounting_cache_pkg.GetValueChar
168631 (p_source_code => 'LEDGER_CATEGORY_CODE'
168632 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
168633 AND l_bflow_method_code = 'PRIOR_ENTRY'
168634 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
168635 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
168636 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
168637 )
168638 THEN
168639 xla_ae_lines_pkg.BflowUpgEntry
168640 (p_business_method_code => l_bflow_method_code
168641 ,p_business_class_code => l_bflow_class_code
168642 ,p_balance_type => l_balance_type_code);
168643 ELSE
168644 NULL;
168645 -- No business flow processing for business flow method of NONE.
168646 END IF;
168647
168648 --
168649 -- call analytical criteria
168650 --
168651
168652 --
168653 -- call description
168654 --
168655
168656 xla_ae_lines_pkg.SetLineDescription(
168657 p_ae_header_id => l_ae_header_id
168658 ,p_description => Description_1 (
168659 p_application_id => p_application_id
168660 , p_ae_header_id => l_ae_header_id
168661 , p_source_1 => p_source_1
168662 , p_source_2 => p_source_2
168663 , p_source_3 => p_source_3
168664 , p_source_4 => p_source_4
168665 , p_source_5 => p_source_5
168666 )
168667 );
168668
168669
168670 --
168671 -- call ADRs
168672 -- Bug 4922099
168673 --
168674 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
168675 (NVL(l_actual_upg_option, 'N') = 'O') OR
168676 (NVL(l_enc_upg_option, 'N') = 'O')
168677 )
168678 THEN
168679 NULL;
168680 --
168681 --
168682
168683 l_ccid := AcctDerRule_6(
168684 p_application_id => p_application_id
168685 , p_ae_header_id => l_ae_header_id
168686 , p_source_11 => p_source_11
168687 , x_transaction_coa_id => l_adr_transaction_coa_id
168688 , x_accounting_coa_id => l_adr_accounting_coa_id
168689 , x_value_type_code => l_adr_value_type_code
168690 , p_side => 'NA'
168691 );
168692
168693 xla_ae_lines_pkg.set_ccid(
168694 p_code_combination_id => l_ccid
168695 , p_value_type_code => l_adr_value_type_code
168696 , p_transaction_coa_id => l_adr_transaction_coa_id
168697 , p_accounting_coa_id => l_adr_accounting_coa_id
168698 , p_adr_code => 'CST_DEFAULT'
168699 , p_adr_type_code => 'S'
168700 , p_component_type => l_component_type
168701 , p_component_code => l_component_code
168702 , p_component_type_code => l_component_type_code
168703 , p_component_appl_id => l_component_appl_id
168704 , p_amb_context_code => l_amb_context_code
168705 , p_side => 'NA'
168706 );
168707
168708
168709 --
168710 --
168711 END IF;
168712 --
168713 -- Bug 4922099
168714 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
168715 (NVL(l_enc_upg_option, 'N') = 'O')
168716 ) AND
168717 (l_bflow_method_code = 'PRIOR_ENTRY')
168718 )
168719 THEN
168720 IF
168721 --
168722 1 = 2
168723 --
168724 THEN
168725 xla_accounting_err_pkg.build_message
168726 (p_appli_s_name => 'XLA'
168727 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
168728 ,p_token_1 => 'LINE_NUMBER'
168729 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
168730 ,p_token_2 => 'LINE_TYPE_NAME'
168731 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
168732 l_component_type
168733 ,l_component_code
168734 ,l_component_type_code
168735 ,l_component_appl_id
168736 ,l_amb_context_code
168737 ,l_entity_code
168738 ,l_event_class_code
168739 )
168740 ,p_token_3 => 'OWNER'
168741 ,p_value_3 => xla_lookups_pkg.get_meaning(
168742 p_lookup_type => 'XLA_OWNER_TYPE'
168743 ,p_lookup_code => l_component_type_code
168744 )
168745 ,p_token_4 => 'PRODUCT_NAME'
168746 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
168747 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
168748 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
168749 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
168750 ,p_ae_header_id => NULL
168751 );
168752
168753 IF (C_LEVEL_ERROR>= g_log_level) THEN
168754 trace
168755 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
168756 ,p_level => C_LEVEL_ERROR
168757 ,p_module => l_log_module);
168758 END IF;
168759 END IF;
168760 END IF;
168761 --
168762 --
168763 ------------------------------------------------------------------------------------------------
168764 -- 4219869 Business Flow
168765 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
168766 -- Prior Entry. Currently, the following code is always generated.
168767 ------------------------------------------------------------------------------------------------
168768 XLA_AE_LINES_PKG.ValidateCurrentLine;
168769
168770 ------------------------------------------------------------------------------------
168771 -- 4219869 Business Flow
168772 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
168773 ------------------------------------------------------------------------------------
168774 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
168775
168776 ----------------------------------------------------------------------------------
168777 -- 4219869 Business Flow
168778 -- Update journal entry status -- Need to generate this within IF <condition>
168779 ----------------------------------------------------------------------------------
168780 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
168781 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
168782 ,p_balance_type_code => l_balance_type_code
168783 );
168784
168785 -------------------------------------------------------------------------------------------
168786 -- 4262811 - Generate the Accrual Reversal lines
168787 -------------------------------------------------------------------------------------------
168788 BEGIN
168789 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
168790 (g_array_event(p_event_id).array_value_num('header_index'));
168791 IF l_acc_rev_flag IS NULL THEN
168792 l_acc_rev_flag := 'N';
168793 END IF;
168794 EXCEPTION
168795 WHEN OTHERS THEN
168796 l_acc_rev_flag := 'N';
168797 END;
168798 --
168799 IF (l_acc_rev_flag = 'Y') THEN
168800
168801 -- 4645092 ------------------------------------------------------------------------------
168802 -- To allow MPA report to determine if it should generate report process
168803 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
168804 ------------------------------------------------------------------------------------------
168805
168806 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
168807 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
168808 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
168809 -- call ADRs
168810 -- Bug 4922099
168811 --
168812 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
168813 (NVL(l_actual_upg_option, 'N') = 'O') OR
168814 (NVL(l_enc_upg_option, 'N') = 'O')
168815 )
168816 THEN
168817 NULL;
168818 --
168819 --
168820
168821 l_ccid := AcctDerRule_6(
168822 p_application_id => p_application_id
168823 , p_ae_header_id => l_ae_header_id
168824 , p_source_11 => p_source_11
168825 , x_transaction_coa_id => l_adr_transaction_coa_id
168826 , x_accounting_coa_id => l_adr_accounting_coa_id
168827 , x_value_type_code => l_adr_value_type_code
168828 , p_side => 'NA'
168829 );
168830
168831 xla_ae_lines_pkg.set_ccid(
168832 p_code_combination_id => l_ccid
168833 , p_value_type_code => l_adr_value_type_code
168834 , p_transaction_coa_id => l_adr_transaction_coa_id
168835 , p_accounting_coa_id => l_adr_accounting_coa_id
168836 , p_adr_code => 'CST_DEFAULT'
168837 , p_adr_type_code => 'S'
168838 , p_component_type => l_component_type
168839 , p_component_code => l_component_code
168840 , p_component_type_code => l_component_type_code
168841 , p_component_appl_id => l_component_appl_id
168842 , p_amb_context_code => l_amb_context_code
168843 , p_side => 'NA'
168844 );
168845
168846
168847 --
168848 --
168849 END IF;
168850
168851 --
168852 -- Update the line information that should be overwritten
168853 --
168854 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
168855 p_header_num => 1);
168856 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
168857
168858 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
168859
168860 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
168861 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
168862 END IF;
168863
168864 --
168865 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
168866 --
168867 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
168868 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
168869 ELSE
168870 ---------------------------------------------------------------------------------------------------
168871 -- 4262811a Switch Sign
168872 ---------------------------------------------------------------------------------------------------
168873 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
168874 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
168875 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168876 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
168877 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168878 -- 5132302
168879 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
168880 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
168881
168882 END IF;
168883
168884 -- 4955764
168885 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
168886 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
168887
168888
168889 XLA_AE_LINES_PKG.ValidateCurrentLine;
168890 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
168891
168892 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
168893 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
168894 ,p_balance_type_code => l_balance_type_code);
168895
168896 END IF;
168897
168898 -----------------------------------------------------------------------------------------
168899 -- 4262811 Multiperiod Accounting
168900 -----------------------------------------------------------------------------------------
168901 -- No MPA option is assigned.
168902
168903
168904 END IF;
168905 END IF;
168906 --
168907
168908 --
168909 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
168910 trace
168911 (p_msg => 'END of AcctLineType_312'
168912 ,p_level => C_LEVEL_PROCEDURE
168913 ,p_module => l_log_module);
168914 END IF;
168915 --
168916 EXCEPTION
168917 WHEN xla_exceptions_pkg.application_exception THEN
168918 RAISE;
168919 WHEN OTHERS THEN
168920 xla_exceptions_pkg.raise_message
168921 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_312');
168922 END AcctLineType_312;
168923 --
168924
168925 ---------------------------------------
168926 --
168927 -- PRIVATE FUNCTION
168928 -- AcctLineType_313
168929 --
168930 ---------------------------------------
168931 PROCEDURE AcctLineType_313 (
168932 p_application_id IN NUMBER
168933 ,p_event_id IN NUMBER
168934 ,p_calculate_acctd_flag IN VARCHAR2
168935 ,p_calculate_g_l_flag IN VARCHAR2
168936 ,p_actual_flag IN OUT VARCHAR2
168937 ,p_balance_type_code OUT VARCHAR2
168938 ,p_gain_or_loss_ref OUT VARCHAR2
168939
168940 --TRANSACTION_ID
168941 , p_source_1 IN NUMBER
168942 --Item Concatenated Segments
168943 , p_source_2 IN VARCHAR2
168944 --Transaction Quantity
168945 , p_source_3 IN NUMBER
168946 --Transaction Unit of Measure Code
168947 , p_source_4 IN VARCHAR2
168948 --Inventory Transaction Type Description
168949 , p_source_5 IN VARCHAR2
168950 --Cost Management Default Account
168951 , p_source_11 IN NUMBER
168952 --Applied to Application ID
168953 , p_source_79 IN NUMBER
168954 --Applied to Distribution Link Type
168955 , p_source_80 IN VARCHAR2
168956 --Applied to Entity Code
168957 , p_source_81 IN VARCHAR2
168958 --Applied To Purchase Document Identifier
168959 , p_source_83 IN NUMBER
168960 --DISTRIBUTION_IDENTIFIER
168961 , p_source_84 IN NUMBER
168962 --Distribution Type
168963 , p_source_85 IN VARCHAR2
168964 , p_source_85_meaning IN VARCHAR2
168965 --PO Budget Account
168966 , p_source_86 IN NUMBER
168967 --Encumbrance Reversal Amount Entered
168968 , p_source_87 IN NUMBER
168969 --Entered Currency Code
168970 , p_source_88 IN VARCHAR2
168971 --Transaction Encumbrance Reversal Amount
168972 , p_source_89 IN NUMBER
168973 --Entered Amount
168974 , p_source_91 IN NUMBER
168975 --Currency Conversion Date
168976 , p_source_92 IN DATE
168977 --Currency Conversion Rate
168978 , p_source_93 IN NUMBER
168979 --Currency Conversion Type
168980 , p_source_94 IN VARCHAR2
168981 --Accounted Amount
168982 , p_source_95 IN NUMBER
168983 --Purchasing Encumbrance Type Identifier
168984 , p_source_96 IN NUMBER
168985 --Accounting Line Type
168986 , p_source_97 IN NUMBER
168987 --Costing Encumbrance Upgrade Option
168988 , p_source_100 IN VARCHAR2
168989 --TXN_PO_DISTRIBUTION_ID
168990 , p_source_101 IN NUMBER
168991 )
168992 IS
168993
168994 l_component_type VARCHAR2(80);
168995 l_component_code VARCHAR2(30);
168996 l_component_type_code VARCHAR2(1);
168997 l_component_appl_id INTEGER;
168998 l_amb_context_code VARCHAR2(30);
168999 l_entity_code VARCHAR2(30);
169000 l_event_class_code VARCHAR2(30);
169001 l_ae_header_id NUMBER;
169002 l_event_type_code VARCHAR2(30);
169003 l_line_definition_code VARCHAR2(30);
169004 l_line_definition_owner_code VARCHAR2(1);
169005 --
169006 -- adr variables
169007 l_segment VARCHAR2(30);
169008 l_ccid NUMBER;
169009 l_adr_transaction_coa_id NUMBER;
169010 l_adr_accounting_coa_id NUMBER;
169011 l_adr_flexfield_segment_code VARCHAR2(30);
169012 l_adr_flex_value_set_id NUMBER;
169013 l_adr_value_type_code VARCHAR2(30);
169014 l_adr_value_combination_id NUMBER;
169015 l_adr_value_segment_code VARCHAR2(30);
169016
169017 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
169018 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
169019 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
169020 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
169021
169022 -- 4262811 Variables ------------------------------------------------------------------------------------------
169023 l_entered_amt_idx NUMBER;
169024 l_accted_amt_idx NUMBER;
169025 l_acc_rev_flag VARCHAR2(1);
169026 l_accrual_line_num NUMBER;
169027 l_tmp_amt NUMBER;
169028 l_acc_rev_natural_side_code VARCHAR2(1);
169029
169030 l_num_entries NUMBER;
169031 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
169032 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
169033 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
169034 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
169035 l_recog_line_1 NUMBER;
169036 l_recog_line_2 NUMBER;
169037
169038 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
169039 l_bflow_applied_to_amt NUMBER; -- 5132302
169040 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
169041
169042 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
169043
169044 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
169045 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
169046
169047 ---------------------------------------------------------------------------------------------------------------
169048
169049
169050 --
169051 -- bulk performance
169052 --
169053 l_balance_type_code VARCHAR2(1);
169054 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
169055 l_log_module VARCHAR2(240);
169056
169057 --
169058 -- Upgrade strategy
169059 --
169060 l_actual_upg_option VARCHAR2(1);
169061 l_enc_upg_option VARCHAR2(1);
169062
169063 --
169064 BEGIN
169065 --
169066 IF g_log_enabled THEN
169067 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_313';
169068 END IF;
169069 --
169070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
169071
169072 trace
169073 (p_msg => 'BEGIN of AcctLineType_313'
169074 ,p_level => C_LEVEL_PROCEDURE
169075 ,p_module => l_log_module);
169076
169077 END IF;
169078 --
169079 l_component_type := 'AMB_JLT';
169080 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
169081 l_component_type_code := 'S';
169082 l_component_appl_id := 707;
169083 l_amb_context_code := 'DEFAULT';
169084 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
169085 l_event_class_code := 'PURCHASE_ORDER';
169086 l_event_type_code := 'LOG_PO_DEL_ADJ';
169087 l_line_definition_owner_code := 'S';
169088 l_line_definition_code := 'PI_LOG_PO_DEL_ADJ';
169089 --
169090 l_balance_type_code := 'A';
169091 l_segment := NULL;
169092 l_ccid := NULL;
169093 l_adr_transaction_coa_id := NULL;
169094 l_adr_accounting_coa_id := NULL;
169095 l_adr_flexfield_segment_code := NULL;
169096 l_adr_flex_value_set_id := NULL;
169097 l_adr_value_type_code := NULL;
169098 l_adr_value_combination_id := NULL;
169099 l_adr_value_segment_code := NULL;
169100
169101 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
169102 l_bflow_class_code := ''; -- 4219869 Business Flow
169103 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
169104 l_budgetary_control_flag := 'N';
169105
169106 l_bflow_applied_to_amt_idx := NULL; -- 5132302
169107 l_bflow_applied_to_amt := NULL; -- 5132302
169108 l_entered_amt_idx := NULL; -- 4262811
169109 l_accted_amt_idx := NULL; -- 4262811
169110 l_acc_rev_flag := NULL; -- 4262811
169111 l_accrual_line_num := NULL; -- 4262811
169112 l_tmp_amt := NULL; -- 4262811
169113 --
169114
169115 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
169116 l_balance_type_code <> 'B' THEN
169117 IF NVL(p_source_97,9E125) = 3
169118 THEN
169119
169120 --
169121 XLA_AE_LINES_PKG.SetNewLine;
169122
169123 p_balance_type_code := l_balance_type_code;
169124 -- set the flag so later we will know whether the gain loss line needs to be created
169125
169126 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
169127 p_actual_flag :='A';
169128 END IF;
169129
169130 --
169131 -- bulk performance
169132 --
169133 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
169134 p_header_num => 0); -- 4262811
169135 --
169136 -- set accounting line options
169137 --
169138 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
169139 p_natural_side_code => 'D'
169140 , p_gain_or_loss_flag => 'N'
169141 , p_gl_transfer_mode_code => 'S'
169142 , p_acct_entry_type_code => 'A'
169143 , p_switch_side_flag => 'Y'
169144 , p_merge_duplicate_code => 'N'
169145 );
169146 --
169147 l_acc_rev_natural_side_code := 'C'; -- 4262811
169148 --
169149 --
169150 -- set accounting line type info
169151 --
169152 xla_ae_lines_pkg.SetAcctLineType
169153 (p_component_type => l_component_type
169154 ,p_event_type_code => l_event_type_code
169155 ,p_line_definition_owner_code => l_line_definition_owner_code
169156 ,p_line_definition_code => l_line_definition_code
169157 ,p_accounting_line_code => l_component_code
169158 ,p_accounting_line_type_code => l_component_type_code
169159 ,p_accounting_line_appl_id => l_component_appl_id
169160 ,p_amb_context_code => l_amb_context_code
169161 ,p_entity_code => l_entity_code
169162 ,p_event_class_code => l_event_class_code);
169163 --
169164 -- set accounting class
169165 --
169166 xla_ae_lines_pkg.SetAcctClass(
169167 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
169168 , p_ae_header_id => l_ae_header_id
169169 );
169170
169171 --
169172 -- set rounding class
169173 --
169174 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
169175 'MATERIAL_OVERHEAD_ABSORPTION';
169176
169177 --
169178 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
169179 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
169180 --
169181 -- bulk performance
169182 --
169183 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
169184
169185 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
169186 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
169187
169188 -- 4955764
169189 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
169190 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
169191
169192 -- 4458381 Public Sector Enh
169193
169194 --
169195 -- set accounting attributes for the line type
169196 --
169197 l_entered_amt_idx := 17;
169198 l_accted_amt_idx := 22;
169199 l_bflow_applied_to_amt_idx := NULL; -- 5132302
169200 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
169201 l_rec_acct_attrs.array_num_value(1) := p_source_79;
169202 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
169203 l_rec_acct_attrs.array_char_value(2) := p_source_80;
169204 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
169205 l_rec_acct_attrs.array_char_value(3) := p_source_81;
169206 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
169207 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
169208 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
169209 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
169210 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
169211 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
169212 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
169213 l_rec_acct_attrs.array_char_value(7) := p_source_85;
169214 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
169215 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
169216 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
169217 l_rec_acct_attrs.array_num_value(9) := p_source_87;
169218 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
169219 l_rec_acct_attrs.array_char_value(10) := p_source_88;
169220 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
169221 l_rec_acct_attrs.array_num_value(11) := p_source_89;
169222 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
169223 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
169224 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
169225 l_rec_acct_attrs.array_num_value(13) := p_source_87;
169226 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
169227 l_rec_acct_attrs.array_char_value(14) := p_source_88;
169228 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
169229 l_rec_acct_attrs.array_num_value(15) := p_source_89;
169230 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
169231 l_rec_acct_attrs.array_char_value(16) := p_source_100;
169232 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
169233 l_rec_acct_attrs.array_num_value(17) := p_source_91;
169234 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
169235 l_rec_acct_attrs.array_char_value(18) := p_source_88;
169236 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
169237 l_rec_acct_attrs.array_date_value(19) := p_source_92;
169238 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
169239 l_rec_acct_attrs.array_num_value(20) := p_source_93;
169240 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
169241 l_rec_acct_attrs.array_char_value(21) := p_source_94;
169242 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
169243 l_rec_acct_attrs.array_num_value(22) := p_source_95;
169244 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
169245 l_rec_acct_attrs.array_num_value(23) := p_source_96;
169246 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
169247 l_rec_acct_attrs.array_num_value(24) := p_source_96;
169248
169249 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
169250 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
169251
169252 ---------------------------------------------------------------------------------------------------------------
169253 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
169254 ---------------------------------------------------------------------------------------------------------------
169255 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
169256
169257 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
169258 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
169259
169260 IF xla_accounting_cache_pkg.GetValueChar
169261 (p_source_code => 'LEDGER_CATEGORY_CODE'
169262 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
169263 AND l_bflow_method_code = 'PRIOR_ENTRY'
169264 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
169265 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
169266 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
169267 )
169268 THEN
169269 xla_ae_lines_pkg.BflowUpgEntry
169270 (p_business_method_code => l_bflow_method_code
169271 ,p_business_class_code => l_bflow_class_code
169272 ,p_balance_type => l_balance_type_code);
169273 ELSE
169274 NULL;
169275 -- No business flow processing for business flow method of NONE.
169276 END IF;
169277
169278 --
169279 -- call analytical criteria
169280 --
169281
169282 --
169283 -- call description
169284 --
169285
169286 xla_ae_lines_pkg.SetLineDescription(
169287 p_ae_header_id => l_ae_header_id
169288 ,p_description => Description_1 (
169289 p_application_id => p_application_id
169290 , p_ae_header_id => l_ae_header_id
169291 , p_source_1 => p_source_1
169292 , p_source_2 => p_source_2
169293 , p_source_3 => p_source_3
169294 , p_source_4 => p_source_4
169295 , p_source_5 => p_source_5
169296 )
169297 );
169298
169299
169300 --
169301 -- call ADRs
169302 -- Bug 4922099
169303 --
169304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
169305 (NVL(l_actual_upg_option, 'N') = 'O') OR
169306 (NVL(l_enc_upg_option, 'N') = 'O')
169307 )
169308 THEN
169309 NULL;
169310 --
169311 --
169312
169313 l_ccid := AcctDerRule_6(
169314 p_application_id => p_application_id
169315 , p_ae_header_id => l_ae_header_id
169316 , p_source_11 => p_source_11
169317 , x_transaction_coa_id => l_adr_transaction_coa_id
169318 , x_accounting_coa_id => l_adr_accounting_coa_id
169319 , x_value_type_code => l_adr_value_type_code
169320 , p_side => 'NA'
169321 );
169322
169323 xla_ae_lines_pkg.set_ccid(
169324 p_code_combination_id => l_ccid
169325 , p_value_type_code => l_adr_value_type_code
169326 , p_transaction_coa_id => l_adr_transaction_coa_id
169327 , p_accounting_coa_id => l_adr_accounting_coa_id
169328 , p_adr_code => 'CST_DEFAULT'
169329 , p_adr_type_code => 'S'
169330 , p_component_type => l_component_type
169331 , p_component_code => l_component_code
169332 , p_component_type_code => l_component_type_code
169333 , p_component_appl_id => l_component_appl_id
169334 , p_amb_context_code => l_amb_context_code
169335 , p_side => 'NA'
169336 );
169337
169338
169339 --
169340 --
169341 END IF;
169342 --
169343 -- Bug 4922099
169344 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
169345 (NVL(l_enc_upg_option, 'N') = 'O')
169346 ) AND
169347 (l_bflow_method_code = 'PRIOR_ENTRY')
169348 )
169349 THEN
169350 IF
169351 --
169352 1 = 2
169353 --
169354 THEN
169355 xla_accounting_err_pkg.build_message
169356 (p_appli_s_name => 'XLA'
169357 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
169358 ,p_token_1 => 'LINE_NUMBER'
169359 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
169360 ,p_token_2 => 'LINE_TYPE_NAME'
169361 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
169362 l_component_type
169363 ,l_component_code
169364 ,l_component_type_code
169365 ,l_component_appl_id
169366 ,l_amb_context_code
169367 ,l_entity_code
169368 ,l_event_class_code
169369 )
169370 ,p_token_3 => 'OWNER'
169371 ,p_value_3 => xla_lookups_pkg.get_meaning(
169372 p_lookup_type => 'XLA_OWNER_TYPE'
169373 ,p_lookup_code => l_component_type_code
169374 )
169375 ,p_token_4 => 'PRODUCT_NAME'
169376 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
169377 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
169378 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
169379 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
169380 ,p_ae_header_id => NULL
169381 );
169382
169383 IF (C_LEVEL_ERROR>= g_log_level) THEN
169384 trace
169385 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
169386 ,p_level => C_LEVEL_ERROR
169387 ,p_module => l_log_module);
169388 END IF;
169389 END IF;
169390 END IF;
169391 --
169392 --
169393 ------------------------------------------------------------------------------------------------
169394 -- 4219869 Business Flow
169395 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
169396 -- Prior Entry. Currently, the following code is always generated.
169397 ------------------------------------------------------------------------------------------------
169398 XLA_AE_LINES_PKG.ValidateCurrentLine;
169399
169400 ------------------------------------------------------------------------------------
169401 -- 4219869 Business Flow
169402 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
169403 ------------------------------------------------------------------------------------
169404 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
169405
169406 ----------------------------------------------------------------------------------
169407 -- 4219869 Business Flow
169408 -- Update journal entry status -- Need to generate this within IF <condition>
169409 ----------------------------------------------------------------------------------
169410 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
169411 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
169412 ,p_balance_type_code => l_balance_type_code
169413 );
169414
169415 -------------------------------------------------------------------------------------------
169416 -- 4262811 - Generate the Accrual Reversal lines
169417 -------------------------------------------------------------------------------------------
169418 BEGIN
169419 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
169420 (g_array_event(p_event_id).array_value_num('header_index'));
169421 IF l_acc_rev_flag IS NULL THEN
169422 l_acc_rev_flag := 'N';
169423 END IF;
169424 EXCEPTION
169425 WHEN OTHERS THEN
169426 l_acc_rev_flag := 'N';
169427 END;
169428 --
169429 IF (l_acc_rev_flag = 'Y') THEN
169430
169431 -- 4645092 ------------------------------------------------------------------------------
169432 -- To allow MPA report to determine if it should generate report process
169433 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
169434 ------------------------------------------------------------------------------------------
169435
169436 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
169437 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
169438 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
169439 -- call ADRs
169440 -- Bug 4922099
169441 --
169442 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
169443 (NVL(l_actual_upg_option, 'N') = 'O') OR
169444 (NVL(l_enc_upg_option, 'N') = 'O')
169445 )
169446 THEN
169447 NULL;
169448 --
169449 --
169450
169451 l_ccid := AcctDerRule_6(
169452 p_application_id => p_application_id
169453 , p_ae_header_id => l_ae_header_id
169454 , p_source_11 => p_source_11
169455 , x_transaction_coa_id => l_adr_transaction_coa_id
169456 , x_accounting_coa_id => l_adr_accounting_coa_id
169457 , x_value_type_code => l_adr_value_type_code
169458 , p_side => 'NA'
169459 );
169460
169461 xla_ae_lines_pkg.set_ccid(
169462 p_code_combination_id => l_ccid
169463 , p_value_type_code => l_adr_value_type_code
169464 , p_transaction_coa_id => l_adr_transaction_coa_id
169465 , p_accounting_coa_id => l_adr_accounting_coa_id
169466 , p_adr_code => 'CST_DEFAULT'
169467 , p_adr_type_code => 'S'
169468 , p_component_type => l_component_type
169469 , p_component_code => l_component_code
169470 , p_component_type_code => l_component_type_code
169471 , p_component_appl_id => l_component_appl_id
169472 , p_amb_context_code => l_amb_context_code
169473 , p_side => 'NA'
169474 );
169475
169476
169477 --
169478 --
169479 END IF;
169480
169481 --
169482 -- Update the line information that should be overwritten
169483 --
169484 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
169485 p_header_num => 1);
169486 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
169487
169488 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
169489
169490 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
169491 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
169492 END IF;
169493
169494 --
169495 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
169496 --
169497 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
169498 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
169499 ELSE
169500 ---------------------------------------------------------------------------------------------------
169501 -- 4262811a Switch Sign
169502 ---------------------------------------------------------------------------------------------------
169503 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
169504 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
169505 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
169506 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
169507 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
169508 -- 5132302
169509 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
169510 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
169511
169512 END IF;
169513
169514 -- 4955764
169515 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
169516 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
169517
169518
169519 XLA_AE_LINES_PKG.ValidateCurrentLine;
169520 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
169521
169522 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
169523 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
169524 ,p_balance_type_code => l_balance_type_code);
169525
169526 END IF;
169527
169528 -----------------------------------------------------------------------------------------
169529 -- 4262811 Multiperiod Accounting
169530 -----------------------------------------------------------------------------------------
169531 -- No MPA option is assigned.
169532
169533
169534 END IF;
169535 END IF;
169536 --
169537
169538 --
169539 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
169540 trace
169541 (p_msg => 'END of AcctLineType_313'
169542 ,p_level => C_LEVEL_PROCEDURE
169543 ,p_module => l_log_module);
169544 END IF;
169545 --
169546 EXCEPTION
169547 WHEN xla_exceptions_pkg.application_exception THEN
169548 RAISE;
169549 WHEN OTHERS THEN
169550 xla_exceptions_pkg.raise_message
169551 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_313');
169552 END AcctLineType_313;
169553 --
169554
169555 ---------------------------------------
169556 --
169557 -- PRIVATE FUNCTION
169558 -- AcctLineType_314
169559 --
169560 ---------------------------------------
169561 PROCEDURE AcctLineType_314 (
169562 p_application_id IN NUMBER
169563 ,p_event_id IN NUMBER
169564 ,p_calculate_acctd_flag IN VARCHAR2
169565 ,p_calculate_g_l_flag IN VARCHAR2
169566 ,p_actual_flag IN OUT VARCHAR2
169567 ,p_balance_type_code OUT VARCHAR2
169568 ,p_gain_or_loss_ref OUT VARCHAR2
169569
169570 --TRANSACTION_ID
169571 , p_source_1 IN NUMBER
169572 --Item Concatenated Segments
169573 , p_source_2 IN VARCHAR2
169574 --Transaction Quantity
169575 , p_source_3 IN NUMBER
169576 --Transaction Unit of Measure Code
169577 , p_source_4 IN VARCHAR2
169578 --Inventory Transaction Type Description
169579 , p_source_5 IN VARCHAR2
169580 --Cost Management Default Account
169581 , p_source_11 IN NUMBER
169582 --Applied to Application ID
169583 , p_source_79 IN NUMBER
169584 --Applied to Distribution Link Type
169585 , p_source_80 IN VARCHAR2
169586 --Applied to Entity Code
169587 , p_source_81 IN VARCHAR2
169588 --Applied To Purchase Document Identifier
169589 , p_source_83 IN NUMBER
169590 --DISTRIBUTION_IDENTIFIER
169591 , p_source_84 IN NUMBER
169592 --Distribution Type
169593 , p_source_85 IN VARCHAR2
169594 , p_source_85_meaning IN VARCHAR2
169595 --PO Budget Account
169596 , p_source_86 IN NUMBER
169597 --Encumbrance Reversal Amount Entered
169598 , p_source_87 IN NUMBER
169599 --Entered Currency Code
169600 , p_source_88 IN VARCHAR2
169601 --Transaction Encumbrance Reversal Amount
169602 , p_source_89 IN NUMBER
169603 --Entered Amount
169604 , p_source_91 IN NUMBER
169605 --Currency Conversion Date
169606 , p_source_92 IN DATE
169607 --Currency Conversion Rate
169608 , p_source_93 IN NUMBER
169609 --Currency Conversion Type
169610 , p_source_94 IN VARCHAR2
169611 --Accounted Amount
169612 , p_source_95 IN NUMBER
169613 --Purchasing Encumbrance Type Identifier
169614 , p_source_96 IN NUMBER
169615 --Accounting Line Type
169616 , p_source_97 IN NUMBER
169617 --Costing Encumbrance Upgrade Option
169618 , p_source_100 IN VARCHAR2
169619 --TXN_PO_DISTRIBUTION_ID
169620 , p_source_101 IN NUMBER
169621 )
169622 IS
169623
169624 l_component_type VARCHAR2(80);
169625 l_component_code VARCHAR2(30);
169626 l_component_type_code VARCHAR2(1);
169627 l_component_appl_id INTEGER;
169628 l_amb_context_code VARCHAR2(30);
169629 l_entity_code VARCHAR2(30);
169630 l_event_class_code VARCHAR2(30);
169631 l_ae_header_id NUMBER;
169632 l_event_type_code VARCHAR2(30);
169633 l_line_definition_code VARCHAR2(30);
169634 l_line_definition_owner_code VARCHAR2(1);
169635 --
169636 -- adr variables
169637 l_segment VARCHAR2(30);
169638 l_ccid NUMBER;
169639 l_adr_transaction_coa_id NUMBER;
169640 l_adr_accounting_coa_id NUMBER;
169641 l_adr_flexfield_segment_code VARCHAR2(30);
169642 l_adr_flex_value_set_id NUMBER;
169643 l_adr_value_type_code VARCHAR2(30);
169644 l_adr_value_combination_id NUMBER;
169645 l_adr_value_segment_code VARCHAR2(30);
169646
169647 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
169648 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
169649 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
169650 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
169651
169652 -- 4262811 Variables ------------------------------------------------------------------------------------------
169653 l_entered_amt_idx NUMBER;
169654 l_accted_amt_idx NUMBER;
169655 l_acc_rev_flag VARCHAR2(1);
169656 l_accrual_line_num NUMBER;
169657 l_tmp_amt NUMBER;
169658 l_acc_rev_natural_side_code VARCHAR2(1);
169659
169660 l_num_entries NUMBER;
169661 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
169662 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
169663 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
169664 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
169665 l_recog_line_1 NUMBER;
169666 l_recog_line_2 NUMBER;
169667
169668 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
169669 l_bflow_applied_to_amt NUMBER; -- 5132302
169670 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
169671
169672 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
169673
169674 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
169675 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
169676
169677 ---------------------------------------------------------------------------------------------------------------
169678
169679
169680 --
169681 -- bulk performance
169682 --
169683 l_balance_type_code VARCHAR2(1);
169684 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
169685 l_log_module VARCHAR2(240);
169686
169687 --
169688 -- Upgrade strategy
169689 --
169690 l_actual_upg_option VARCHAR2(1);
169691 l_enc_upg_option VARCHAR2(1);
169692
169693 --
169694 BEGIN
169695 --
169696 IF g_log_enabled THEN
169697 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_314';
169698 END IF;
169699 --
169700 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
169701
169702 trace
169703 (p_msg => 'BEGIN of AcctLineType_314'
169704 ,p_level => C_LEVEL_PROCEDURE
169705 ,p_module => l_log_module);
169706
169707 END IF;
169708 --
169709 l_component_type := 'AMB_JLT';
169710 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
169711 l_component_type_code := 'S';
169712 l_component_appl_id := 707;
169713 l_amb_context_code := 'DEFAULT';
169714 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
169715 l_event_class_code := 'PURCHASE_ORDER';
169716 l_event_type_code := 'PO_DEL_ADJ';
169717 l_line_definition_owner_code := 'S';
169718 l_line_definition_code := 'PI_PO_DEL_ADJ';
169719 --
169720 l_balance_type_code := 'A';
169721 l_segment := NULL;
169722 l_ccid := NULL;
169723 l_adr_transaction_coa_id := NULL;
169724 l_adr_accounting_coa_id := NULL;
169725 l_adr_flexfield_segment_code := NULL;
169726 l_adr_flex_value_set_id := NULL;
169727 l_adr_value_type_code := NULL;
169728 l_adr_value_combination_id := NULL;
169729 l_adr_value_segment_code := NULL;
169730
169731 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
169732 l_bflow_class_code := ''; -- 4219869 Business Flow
169733 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
169734 l_budgetary_control_flag := 'N';
169735
169736 l_bflow_applied_to_amt_idx := NULL; -- 5132302
169737 l_bflow_applied_to_amt := NULL; -- 5132302
169738 l_entered_amt_idx := NULL; -- 4262811
169739 l_accted_amt_idx := NULL; -- 4262811
169740 l_acc_rev_flag := NULL; -- 4262811
169741 l_accrual_line_num := NULL; -- 4262811
169742 l_tmp_amt := NULL; -- 4262811
169743 --
169744
169745 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
169746 l_balance_type_code <> 'B' THEN
169747 IF NVL(p_source_97,9E125) = 3
169748 THEN
169749
169750 --
169751 XLA_AE_LINES_PKG.SetNewLine;
169752
169753 p_balance_type_code := l_balance_type_code;
169754 -- set the flag so later we will know whether the gain loss line needs to be created
169755
169756 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
169757 p_actual_flag :='A';
169758 END IF;
169759
169760 --
169761 -- bulk performance
169762 --
169763 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
169764 p_header_num => 0); -- 4262811
169765 --
169766 -- set accounting line options
169767 --
169768 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
169769 p_natural_side_code => 'D'
169770 , p_gain_or_loss_flag => 'N'
169771 , p_gl_transfer_mode_code => 'S'
169772 , p_acct_entry_type_code => 'A'
169773 , p_switch_side_flag => 'Y'
169774 , p_merge_duplicate_code => 'N'
169775 );
169776 --
169777 l_acc_rev_natural_side_code := 'C'; -- 4262811
169778 --
169779 --
169780 -- set accounting line type info
169781 --
169782 xla_ae_lines_pkg.SetAcctLineType
169783 (p_component_type => l_component_type
169784 ,p_event_type_code => l_event_type_code
169785 ,p_line_definition_owner_code => l_line_definition_owner_code
169786 ,p_line_definition_code => l_line_definition_code
169787 ,p_accounting_line_code => l_component_code
169788 ,p_accounting_line_type_code => l_component_type_code
169789 ,p_accounting_line_appl_id => l_component_appl_id
169790 ,p_amb_context_code => l_amb_context_code
169791 ,p_entity_code => l_entity_code
169792 ,p_event_class_code => l_event_class_code);
169793 --
169794 -- set accounting class
169795 --
169796 xla_ae_lines_pkg.SetAcctClass(
169797 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
169798 , p_ae_header_id => l_ae_header_id
169799 );
169800
169801 --
169802 -- set rounding class
169803 --
169804 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
169805 'MATERIAL_OVERHEAD_ABSORPTION';
169806
169807 --
169808 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
169809 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
169810 --
169811 -- bulk performance
169812 --
169813 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
169814
169815 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
169816 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
169817
169818 -- 4955764
169819 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
169820 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
169821
169822 -- 4458381 Public Sector Enh
169823
169824 --
169825 -- set accounting attributes for the line type
169826 --
169827 l_entered_amt_idx := 17;
169828 l_accted_amt_idx := 22;
169829 l_bflow_applied_to_amt_idx := NULL; -- 5132302
169830 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
169831 l_rec_acct_attrs.array_num_value(1) := p_source_79;
169832 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
169833 l_rec_acct_attrs.array_char_value(2) := p_source_80;
169834 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
169835 l_rec_acct_attrs.array_char_value(3) := p_source_81;
169836 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
169837 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
169838 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
169839 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
169840 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
169841 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
169842 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
169843 l_rec_acct_attrs.array_char_value(7) := p_source_85;
169844 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
169845 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
169846 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
169847 l_rec_acct_attrs.array_num_value(9) := p_source_87;
169848 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
169849 l_rec_acct_attrs.array_char_value(10) := p_source_88;
169850 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
169851 l_rec_acct_attrs.array_num_value(11) := p_source_89;
169852 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
169853 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
169854 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
169855 l_rec_acct_attrs.array_num_value(13) := p_source_87;
169856 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
169857 l_rec_acct_attrs.array_char_value(14) := p_source_88;
169858 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
169859 l_rec_acct_attrs.array_num_value(15) := p_source_89;
169860 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
169861 l_rec_acct_attrs.array_char_value(16) := p_source_100;
169862 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
169863 l_rec_acct_attrs.array_num_value(17) := p_source_91;
169864 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
169865 l_rec_acct_attrs.array_char_value(18) := p_source_88;
169866 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
169867 l_rec_acct_attrs.array_date_value(19) := p_source_92;
169868 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
169869 l_rec_acct_attrs.array_num_value(20) := p_source_93;
169870 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
169871 l_rec_acct_attrs.array_char_value(21) := p_source_94;
169872 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
169873 l_rec_acct_attrs.array_num_value(22) := p_source_95;
169874 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
169875 l_rec_acct_attrs.array_num_value(23) := p_source_96;
169876 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
169877 l_rec_acct_attrs.array_num_value(24) := p_source_96;
169878
169879 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
169880 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
169881
169882 ---------------------------------------------------------------------------------------------------------------
169883 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
169884 ---------------------------------------------------------------------------------------------------------------
169885 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
169886
169887 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
169888 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
169889
169890 IF xla_accounting_cache_pkg.GetValueChar
169891 (p_source_code => 'LEDGER_CATEGORY_CODE'
169892 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
169893 AND l_bflow_method_code = 'PRIOR_ENTRY'
169894 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
169895 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
169896 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
169897 )
169898 THEN
169899 xla_ae_lines_pkg.BflowUpgEntry
169900 (p_business_method_code => l_bflow_method_code
169901 ,p_business_class_code => l_bflow_class_code
169902 ,p_balance_type => l_balance_type_code);
169903 ELSE
169904 NULL;
169905 -- No business flow processing for business flow method of NONE.
169906 END IF;
169907
169908 --
169909 -- call analytical criteria
169910 --
169911
169912 --
169913 -- call description
169914 --
169915
169916 xla_ae_lines_pkg.SetLineDescription(
169917 p_ae_header_id => l_ae_header_id
169918 ,p_description => Description_1 (
169919 p_application_id => p_application_id
169920 , p_ae_header_id => l_ae_header_id
169921 , p_source_1 => p_source_1
169922 , p_source_2 => p_source_2
169923 , p_source_3 => p_source_3
169924 , p_source_4 => p_source_4
169925 , p_source_5 => p_source_5
169926 )
169927 );
169928
169929
169930 --
169931 -- call ADRs
169932 -- Bug 4922099
169933 --
169934 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
169935 (NVL(l_actual_upg_option, 'N') = 'O') OR
169936 (NVL(l_enc_upg_option, 'N') = 'O')
169937 )
169938 THEN
169939 NULL;
169940 --
169941 --
169942
169943 l_ccid := AcctDerRule_6(
169944 p_application_id => p_application_id
169945 , p_ae_header_id => l_ae_header_id
169946 , p_source_11 => p_source_11
169947 , x_transaction_coa_id => l_adr_transaction_coa_id
169948 , x_accounting_coa_id => l_adr_accounting_coa_id
169949 , x_value_type_code => l_adr_value_type_code
169950 , p_side => 'NA'
169951 );
169952
169953 xla_ae_lines_pkg.set_ccid(
169954 p_code_combination_id => l_ccid
169955 , p_value_type_code => l_adr_value_type_code
169956 , p_transaction_coa_id => l_adr_transaction_coa_id
169957 , p_accounting_coa_id => l_adr_accounting_coa_id
169958 , p_adr_code => 'CST_DEFAULT'
169959 , p_adr_type_code => 'S'
169960 , p_component_type => l_component_type
169961 , p_component_code => l_component_code
169962 , p_component_type_code => l_component_type_code
169963 , p_component_appl_id => l_component_appl_id
169964 , p_amb_context_code => l_amb_context_code
169965 , p_side => 'NA'
169966 );
169967
169968
169969 --
169970 --
169971 END IF;
169972 --
169973 -- Bug 4922099
169974 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
169975 (NVL(l_enc_upg_option, 'N') = 'O')
169976 ) AND
169977 (l_bflow_method_code = 'PRIOR_ENTRY')
169978 )
169979 THEN
169980 IF
169981 --
169982 1 = 2
169983 --
169984 THEN
169985 xla_accounting_err_pkg.build_message
169986 (p_appli_s_name => 'XLA'
169987 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
169988 ,p_token_1 => 'LINE_NUMBER'
169989 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
169990 ,p_token_2 => 'LINE_TYPE_NAME'
169991 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
169992 l_component_type
169993 ,l_component_code
169994 ,l_component_type_code
169995 ,l_component_appl_id
169996 ,l_amb_context_code
169997 ,l_entity_code
169998 ,l_event_class_code
169999 )
170000 ,p_token_3 => 'OWNER'
170001 ,p_value_3 => xla_lookups_pkg.get_meaning(
170002 p_lookup_type => 'XLA_OWNER_TYPE'
170003 ,p_lookup_code => l_component_type_code
170004 )
170005 ,p_token_4 => 'PRODUCT_NAME'
170006 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
170007 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
170008 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
170009 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
170010 ,p_ae_header_id => NULL
170011 );
170012
170013 IF (C_LEVEL_ERROR>= g_log_level) THEN
170014 trace
170015 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
170016 ,p_level => C_LEVEL_ERROR
170017 ,p_module => l_log_module);
170018 END IF;
170019 END IF;
170020 END IF;
170021 --
170022 --
170023 ------------------------------------------------------------------------------------------------
170024 -- 4219869 Business Flow
170025 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
170026 -- Prior Entry. Currently, the following code is always generated.
170027 ------------------------------------------------------------------------------------------------
170028 XLA_AE_LINES_PKG.ValidateCurrentLine;
170029
170030 ------------------------------------------------------------------------------------
170031 -- 4219869 Business Flow
170032 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
170033 ------------------------------------------------------------------------------------
170034 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
170035
170036 ----------------------------------------------------------------------------------
170037 -- 4219869 Business Flow
170038 -- Update journal entry status -- Need to generate this within IF <condition>
170039 ----------------------------------------------------------------------------------
170040 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
170041 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
170042 ,p_balance_type_code => l_balance_type_code
170043 );
170044
170045 -------------------------------------------------------------------------------------------
170046 -- 4262811 - Generate the Accrual Reversal lines
170047 -------------------------------------------------------------------------------------------
170048 BEGIN
170049 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
170050 (g_array_event(p_event_id).array_value_num('header_index'));
170051 IF l_acc_rev_flag IS NULL THEN
170052 l_acc_rev_flag := 'N';
170053 END IF;
170054 EXCEPTION
170055 WHEN OTHERS THEN
170056 l_acc_rev_flag := 'N';
170057 END;
170058 --
170059 IF (l_acc_rev_flag = 'Y') THEN
170060
170061 -- 4645092 ------------------------------------------------------------------------------
170062 -- To allow MPA report to determine if it should generate report process
170063 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
170064 ------------------------------------------------------------------------------------------
170065
170066 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
170067 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
170068 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
170069 -- call ADRs
170070 -- Bug 4922099
170071 --
170072 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
170073 (NVL(l_actual_upg_option, 'N') = 'O') OR
170074 (NVL(l_enc_upg_option, 'N') = 'O')
170075 )
170076 THEN
170077 NULL;
170078 --
170079 --
170080
170081 l_ccid := AcctDerRule_6(
170082 p_application_id => p_application_id
170083 , p_ae_header_id => l_ae_header_id
170084 , p_source_11 => p_source_11
170085 , x_transaction_coa_id => l_adr_transaction_coa_id
170086 , x_accounting_coa_id => l_adr_accounting_coa_id
170087 , x_value_type_code => l_adr_value_type_code
170088 , p_side => 'NA'
170089 );
170090
170091 xla_ae_lines_pkg.set_ccid(
170092 p_code_combination_id => l_ccid
170093 , p_value_type_code => l_adr_value_type_code
170094 , p_transaction_coa_id => l_adr_transaction_coa_id
170095 , p_accounting_coa_id => l_adr_accounting_coa_id
170096 , p_adr_code => 'CST_DEFAULT'
170097 , p_adr_type_code => 'S'
170098 , p_component_type => l_component_type
170099 , p_component_code => l_component_code
170100 , p_component_type_code => l_component_type_code
170101 , p_component_appl_id => l_component_appl_id
170102 , p_amb_context_code => l_amb_context_code
170103 , p_side => 'NA'
170104 );
170105
170106
170107 --
170108 --
170109 END IF;
170110
170111 --
170112 -- Update the line information that should be overwritten
170113 --
170114 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
170115 p_header_num => 1);
170116 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
170117
170118 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
170119
170120 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
170121 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
170122 END IF;
170123
170124 --
170125 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
170126 --
170127 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
170128 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
170129 ELSE
170130 ---------------------------------------------------------------------------------------------------
170131 -- 4262811a Switch Sign
170132 ---------------------------------------------------------------------------------------------------
170133 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
170134 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
170135 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170136 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
170137 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170138 -- 5132302
170139 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
170140 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170141
170142 END IF;
170143
170144 -- 4955764
170145 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
170146 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
170147
170148
170149 XLA_AE_LINES_PKG.ValidateCurrentLine;
170150 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
170151
170152 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
170153 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
170154 ,p_balance_type_code => l_balance_type_code);
170155
170156 END IF;
170157
170158 -----------------------------------------------------------------------------------------
170159 -- 4262811 Multiperiod Accounting
170160 -----------------------------------------------------------------------------------------
170161 -- No MPA option is assigned.
170162
170163
170164 END IF;
170165 END IF;
170166 --
170167
170168 --
170169 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
170170 trace
170171 (p_msg => 'END of AcctLineType_314'
170172 ,p_level => C_LEVEL_PROCEDURE
170173 ,p_module => l_log_module);
170174 END IF;
170175 --
170176 EXCEPTION
170177 WHEN xla_exceptions_pkg.application_exception THEN
170178 RAISE;
170179 WHEN OTHERS THEN
170180 xla_exceptions_pkg.raise_message
170181 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_314');
170182 END AcctLineType_314;
170183 --
170184
170185 ---------------------------------------
170186 --
170187 -- PRIVATE FUNCTION
170188 -- AcctLineType_315
170189 --
170190 ---------------------------------------
170191 PROCEDURE AcctLineType_315 (
170192 p_application_id IN NUMBER
170193 ,p_event_id IN NUMBER
170194 ,p_calculate_acctd_flag IN VARCHAR2
170195 ,p_calculate_g_l_flag IN VARCHAR2
170196 ,p_actual_flag IN OUT VARCHAR2
170197 ,p_balance_type_code OUT VARCHAR2
170198 ,p_gain_or_loss_ref OUT VARCHAR2
170199
170200 --TRANSACTION_ID
170201 , p_source_1 IN NUMBER
170202 --Item Concatenated Segments
170203 , p_source_2 IN VARCHAR2
170204 --Transaction Quantity
170205 , p_source_3 IN NUMBER
170206 --Transaction Unit of Measure Code
170207 , p_source_4 IN VARCHAR2
170208 --Inventory Transaction Type Description
170209 , p_source_5 IN VARCHAR2
170210 --Cost Management Default Account
170211 , p_source_11 IN NUMBER
170212 --Applied to Application ID
170213 , p_source_79 IN NUMBER
170214 --Applied to Distribution Link Type
170215 , p_source_80 IN VARCHAR2
170216 --Applied to Entity Code
170217 , p_source_81 IN VARCHAR2
170218 --Applied To Purchase Document Identifier
170219 , p_source_83 IN NUMBER
170220 --DISTRIBUTION_IDENTIFIER
170221 , p_source_84 IN NUMBER
170222 --Distribution Type
170223 , p_source_85 IN VARCHAR2
170224 , p_source_85_meaning IN VARCHAR2
170225 --PO Budget Account
170226 , p_source_86 IN NUMBER
170227 --Encumbrance Reversal Amount Entered
170228 , p_source_87 IN NUMBER
170229 --Entered Currency Code
170230 , p_source_88 IN VARCHAR2
170231 --Transaction Encumbrance Reversal Amount
170232 , p_source_89 IN NUMBER
170233 --Entered Amount
170234 , p_source_91 IN NUMBER
170235 --Currency Conversion Date
170236 , p_source_92 IN DATE
170237 --Currency Conversion Rate
170238 , p_source_93 IN NUMBER
170239 --Currency Conversion Type
170240 , p_source_94 IN VARCHAR2
170241 --Accounted Amount
170242 , p_source_95 IN NUMBER
170243 --Purchasing Encumbrance Type Identifier
170244 , p_source_96 IN NUMBER
170245 --Accounting Line Type
170246 , p_source_97 IN NUMBER
170247 --Costing Encumbrance Upgrade Option
170248 , p_source_100 IN VARCHAR2
170249 --TXN_PO_DISTRIBUTION_ID
170250 , p_source_101 IN NUMBER
170251 )
170252 IS
170253
170254 l_component_type VARCHAR2(80);
170255 l_component_code VARCHAR2(30);
170256 l_component_type_code VARCHAR2(1);
170257 l_component_appl_id INTEGER;
170258 l_amb_context_code VARCHAR2(30);
170259 l_entity_code VARCHAR2(30);
170260 l_event_class_code VARCHAR2(30);
170261 l_ae_header_id NUMBER;
170262 l_event_type_code VARCHAR2(30);
170263 l_line_definition_code VARCHAR2(30);
170264 l_line_definition_owner_code VARCHAR2(1);
170265 --
170266 -- adr variables
170267 l_segment VARCHAR2(30);
170268 l_ccid NUMBER;
170269 l_adr_transaction_coa_id NUMBER;
170270 l_adr_accounting_coa_id NUMBER;
170271 l_adr_flexfield_segment_code VARCHAR2(30);
170272 l_adr_flex_value_set_id NUMBER;
170273 l_adr_value_type_code VARCHAR2(30);
170274 l_adr_value_combination_id NUMBER;
170275 l_adr_value_segment_code VARCHAR2(30);
170276
170277 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
170278 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
170279 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
170280 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
170281
170282 -- 4262811 Variables ------------------------------------------------------------------------------------------
170283 l_entered_amt_idx NUMBER;
170284 l_accted_amt_idx NUMBER;
170285 l_acc_rev_flag VARCHAR2(1);
170286 l_accrual_line_num NUMBER;
170287 l_tmp_amt NUMBER;
170288 l_acc_rev_natural_side_code VARCHAR2(1);
170289
170290 l_num_entries NUMBER;
170291 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
170292 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
170293 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
170294 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
170295 l_recog_line_1 NUMBER;
170296 l_recog_line_2 NUMBER;
170297
170298 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
170299 l_bflow_applied_to_amt NUMBER; -- 5132302
170300 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
170301
170302 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
170303
170304 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
170305 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
170306
170307 ---------------------------------------------------------------------------------------------------------------
170308
170309
170310 --
170311 -- bulk performance
170312 --
170313 l_balance_type_code VARCHAR2(1);
170314 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
170315 l_log_module VARCHAR2(240);
170316
170317 --
170318 -- Upgrade strategy
170319 --
170320 l_actual_upg_option VARCHAR2(1);
170321 l_enc_upg_option VARCHAR2(1);
170322
170323 --
170324 BEGIN
170325 --
170326 IF g_log_enabled THEN
170327 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_315';
170328 END IF;
170329 --
170330 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
170331
170332 trace
170333 (p_msg => 'BEGIN of AcctLineType_315'
170334 ,p_level => C_LEVEL_PROCEDURE
170335 ,p_module => l_log_module);
170336
170337 END IF;
170338 --
170339 l_component_type := 'AMB_JLT';
170340 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
170341 l_component_type_code := 'S';
170342 l_component_appl_id := 707;
170343 l_amb_context_code := 'DEFAULT';
170344 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
170345 l_event_class_code := 'PURCHASE_ORDER';
170346 l_event_type_code := 'PO_DEL_INV';
170347 l_line_definition_owner_code := 'S';
170348 l_line_definition_code := 'PI_PO_DEL_INV';
170349 --
170350 l_balance_type_code := 'A';
170351 l_segment := NULL;
170352 l_ccid := NULL;
170353 l_adr_transaction_coa_id := NULL;
170354 l_adr_accounting_coa_id := NULL;
170355 l_adr_flexfield_segment_code := NULL;
170356 l_adr_flex_value_set_id := NULL;
170357 l_adr_value_type_code := NULL;
170358 l_adr_value_combination_id := NULL;
170359 l_adr_value_segment_code := NULL;
170360
170361 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
170362 l_bflow_class_code := ''; -- 4219869 Business Flow
170363 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
170364 l_budgetary_control_flag := 'N';
170365
170366 l_bflow_applied_to_amt_idx := NULL; -- 5132302
170367 l_bflow_applied_to_amt := NULL; -- 5132302
170368 l_entered_amt_idx := NULL; -- 4262811
170369 l_accted_amt_idx := NULL; -- 4262811
170370 l_acc_rev_flag := NULL; -- 4262811
170371 l_accrual_line_num := NULL; -- 4262811
170372 l_tmp_amt := NULL; -- 4262811
170373 --
170374
170375 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
170376 l_balance_type_code <> 'B' THEN
170377 IF NVL(p_source_97,9E125) = 3
170378 THEN
170379
170380 --
170381 XLA_AE_LINES_PKG.SetNewLine;
170382
170383 p_balance_type_code := l_balance_type_code;
170384 -- set the flag so later we will know whether the gain loss line needs to be created
170385
170386 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
170387 p_actual_flag :='A';
170388 END IF;
170389
170390 --
170391 -- bulk performance
170392 --
170393 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
170394 p_header_num => 0); -- 4262811
170395 --
170396 -- set accounting line options
170397 --
170398 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
170399 p_natural_side_code => 'D'
170400 , p_gain_or_loss_flag => 'N'
170401 , p_gl_transfer_mode_code => 'S'
170402 , p_acct_entry_type_code => 'A'
170403 , p_switch_side_flag => 'Y'
170404 , p_merge_duplicate_code => 'N'
170405 );
170406 --
170407 l_acc_rev_natural_side_code := 'C'; -- 4262811
170408 --
170409 --
170410 -- set accounting line type info
170411 --
170412 xla_ae_lines_pkg.SetAcctLineType
170413 (p_component_type => l_component_type
170414 ,p_event_type_code => l_event_type_code
170415 ,p_line_definition_owner_code => l_line_definition_owner_code
170416 ,p_line_definition_code => l_line_definition_code
170417 ,p_accounting_line_code => l_component_code
170418 ,p_accounting_line_type_code => l_component_type_code
170419 ,p_accounting_line_appl_id => l_component_appl_id
170420 ,p_amb_context_code => l_amb_context_code
170421 ,p_entity_code => l_entity_code
170422 ,p_event_class_code => l_event_class_code);
170423 --
170424 -- set accounting class
170425 --
170426 xla_ae_lines_pkg.SetAcctClass(
170427 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
170428 , p_ae_header_id => l_ae_header_id
170429 );
170430
170431 --
170432 -- set rounding class
170433 --
170434 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
170435 'MATERIAL_OVERHEAD_ABSORPTION';
170436
170437 --
170438 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
170439 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
170440 --
170441 -- bulk performance
170442 --
170443 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
170444
170445 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
170446 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
170447
170448 -- 4955764
170449 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
170450 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
170451
170452 -- 4458381 Public Sector Enh
170453
170454 --
170455 -- set accounting attributes for the line type
170456 --
170457 l_entered_amt_idx := 17;
170458 l_accted_amt_idx := 22;
170459 l_bflow_applied_to_amt_idx := NULL; -- 5132302
170460 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
170461 l_rec_acct_attrs.array_num_value(1) := p_source_79;
170462 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
170463 l_rec_acct_attrs.array_char_value(2) := p_source_80;
170464 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
170465 l_rec_acct_attrs.array_char_value(3) := p_source_81;
170466 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
170467 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
170468 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
170469 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
170470 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
170471 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
170472 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
170473 l_rec_acct_attrs.array_char_value(7) := p_source_85;
170474 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
170475 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
170476 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
170477 l_rec_acct_attrs.array_num_value(9) := p_source_87;
170478 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
170479 l_rec_acct_attrs.array_char_value(10) := p_source_88;
170480 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
170481 l_rec_acct_attrs.array_num_value(11) := p_source_89;
170482 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
170483 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
170484 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
170485 l_rec_acct_attrs.array_num_value(13) := p_source_87;
170486 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
170487 l_rec_acct_attrs.array_char_value(14) := p_source_88;
170488 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
170489 l_rec_acct_attrs.array_num_value(15) := p_source_89;
170490 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
170491 l_rec_acct_attrs.array_char_value(16) := p_source_100;
170492 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
170493 l_rec_acct_attrs.array_num_value(17) := p_source_91;
170494 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
170495 l_rec_acct_attrs.array_char_value(18) := p_source_88;
170496 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
170497 l_rec_acct_attrs.array_date_value(19) := p_source_92;
170498 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
170499 l_rec_acct_attrs.array_num_value(20) := p_source_93;
170500 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
170501 l_rec_acct_attrs.array_char_value(21) := p_source_94;
170502 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
170503 l_rec_acct_attrs.array_num_value(22) := p_source_95;
170504 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
170505 l_rec_acct_attrs.array_num_value(23) := p_source_96;
170506 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
170507 l_rec_acct_attrs.array_num_value(24) := p_source_96;
170508
170509 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
170510 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
170511
170512 ---------------------------------------------------------------------------------------------------------------
170513 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
170514 ---------------------------------------------------------------------------------------------------------------
170515 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
170516
170517 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
170518 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
170519
170520 IF xla_accounting_cache_pkg.GetValueChar
170521 (p_source_code => 'LEDGER_CATEGORY_CODE'
170522 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
170523 AND l_bflow_method_code = 'PRIOR_ENTRY'
170524 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
170525 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
170526 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
170527 )
170528 THEN
170529 xla_ae_lines_pkg.BflowUpgEntry
170530 (p_business_method_code => l_bflow_method_code
170531 ,p_business_class_code => l_bflow_class_code
170532 ,p_balance_type => l_balance_type_code);
170533 ELSE
170534 NULL;
170535 -- No business flow processing for business flow method of NONE.
170536 END IF;
170537
170538 --
170539 -- call analytical criteria
170540 --
170541
170542 --
170543 -- call description
170544 --
170545
170546 xla_ae_lines_pkg.SetLineDescription(
170547 p_ae_header_id => l_ae_header_id
170548 ,p_description => Description_1 (
170549 p_application_id => p_application_id
170550 , p_ae_header_id => l_ae_header_id
170551 , p_source_1 => p_source_1
170552 , p_source_2 => p_source_2
170553 , p_source_3 => p_source_3
170554 , p_source_4 => p_source_4
170555 , p_source_5 => p_source_5
170556 )
170557 );
170558
170559
170560 --
170561 -- call ADRs
170562 -- Bug 4922099
170563 --
170564 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
170565 (NVL(l_actual_upg_option, 'N') = 'O') OR
170566 (NVL(l_enc_upg_option, 'N') = 'O')
170567 )
170568 THEN
170569 NULL;
170570 --
170571 --
170572
170573 l_ccid := AcctDerRule_6(
170574 p_application_id => p_application_id
170575 , p_ae_header_id => l_ae_header_id
170576 , p_source_11 => p_source_11
170577 , x_transaction_coa_id => l_adr_transaction_coa_id
170578 , x_accounting_coa_id => l_adr_accounting_coa_id
170579 , x_value_type_code => l_adr_value_type_code
170580 , p_side => 'NA'
170581 );
170582
170583 xla_ae_lines_pkg.set_ccid(
170584 p_code_combination_id => l_ccid
170585 , p_value_type_code => l_adr_value_type_code
170586 , p_transaction_coa_id => l_adr_transaction_coa_id
170587 , p_accounting_coa_id => l_adr_accounting_coa_id
170588 , p_adr_code => 'CST_DEFAULT'
170589 , p_adr_type_code => 'S'
170590 , p_component_type => l_component_type
170591 , p_component_code => l_component_code
170592 , p_component_type_code => l_component_type_code
170593 , p_component_appl_id => l_component_appl_id
170594 , p_amb_context_code => l_amb_context_code
170595 , p_side => 'NA'
170596 );
170597
170598
170599 --
170600 --
170601 END IF;
170602 --
170603 -- Bug 4922099
170604 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
170605 (NVL(l_enc_upg_option, 'N') = 'O')
170606 ) AND
170607 (l_bflow_method_code = 'PRIOR_ENTRY')
170608 )
170609 THEN
170610 IF
170611 --
170612 1 = 2
170613 --
170614 THEN
170615 xla_accounting_err_pkg.build_message
170616 (p_appli_s_name => 'XLA'
170617 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
170618 ,p_token_1 => 'LINE_NUMBER'
170619 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
170620 ,p_token_2 => 'LINE_TYPE_NAME'
170621 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
170622 l_component_type
170623 ,l_component_code
170624 ,l_component_type_code
170625 ,l_component_appl_id
170626 ,l_amb_context_code
170627 ,l_entity_code
170628 ,l_event_class_code
170629 )
170630 ,p_token_3 => 'OWNER'
170631 ,p_value_3 => xla_lookups_pkg.get_meaning(
170632 p_lookup_type => 'XLA_OWNER_TYPE'
170633 ,p_lookup_code => l_component_type_code
170634 )
170635 ,p_token_4 => 'PRODUCT_NAME'
170636 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
170637 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
170638 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
170639 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
170640 ,p_ae_header_id => NULL
170641 );
170642
170643 IF (C_LEVEL_ERROR>= g_log_level) THEN
170644 trace
170645 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
170646 ,p_level => C_LEVEL_ERROR
170647 ,p_module => l_log_module);
170648 END IF;
170649 END IF;
170650 END IF;
170651 --
170652 --
170653 ------------------------------------------------------------------------------------------------
170654 -- 4219869 Business Flow
170655 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
170656 -- Prior Entry. Currently, the following code is always generated.
170657 ------------------------------------------------------------------------------------------------
170658 XLA_AE_LINES_PKG.ValidateCurrentLine;
170659
170660 ------------------------------------------------------------------------------------
170661 -- 4219869 Business Flow
170662 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
170663 ------------------------------------------------------------------------------------
170664 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
170665
170666 ----------------------------------------------------------------------------------
170667 -- 4219869 Business Flow
170668 -- Update journal entry status -- Need to generate this within IF <condition>
170669 ----------------------------------------------------------------------------------
170670 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
170671 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
170672 ,p_balance_type_code => l_balance_type_code
170673 );
170674
170675 -------------------------------------------------------------------------------------------
170676 -- 4262811 - Generate the Accrual Reversal lines
170677 -------------------------------------------------------------------------------------------
170678 BEGIN
170679 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
170680 (g_array_event(p_event_id).array_value_num('header_index'));
170681 IF l_acc_rev_flag IS NULL THEN
170682 l_acc_rev_flag := 'N';
170683 END IF;
170684 EXCEPTION
170685 WHEN OTHERS THEN
170686 l_acc_rev_flag := 'N';
170687 END;
170688 --
170689 IF (l_acc_rev_flag = 'Y') THEN
170690
170691 -- 4645092 ------------------------------------------------------------------------------
170692 -- To allow MPA report to determine if it should generate report process
170693 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
170694 ------------------------------------------------------------------------------------------
170695
170696 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
170697 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
170698 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
170699 -- call ADRs
170700 -- Bug 4922099
170701 --
170702 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
170703 (NVL(l_actual_upg_option, 'N') = 'O') OR
170704 (NVL(l_enc_upg_option, 'N') = 'O')
170705 )
170706 THEN
170707 NULL;
170708 --
170709 --
170710
170711 l_ccid := AcctDerRule_6(
170712 p_application_id => p_application_id
170713 , p_ae_header_id => l_ae_header_id
170714 , p_source_11 => p_source_11
170715 , x_transaction_coa_id => l_adr_transaction_coa_id
170716 , x_accounting_coa_id => l_adr_accounting_coa_id
170717 , x_value_type_code => l_adr_value_type_code
170718 , p_side => 'NA'
170719 );
170720
170721 xla_ae_lines_pkg.set_ccid(
170722 p_code_combination_id => l_ccid
170723 , p_value_type_code => l_adr_value_type_code
170724 , p_transaction_coa_id => l_adr_transaction_coa_id
170725 , p_accounting_coa_id => l_adr_accounting_coa_id
170726 , p_adr_code => 'CST_DEFAULT'
170727 , p_adr_type_code => 'S'
170728 , p_component_type => l_component_type
170729 , p_component_code => l_component_code
170730 , p_component_type_code => l_component_type_code
170731 , p_component_appl_id => l_component_appl_id
170732 , p_amb_context_code => l_amb_context_code
170733 , p_side => 'NA'
170734 );
170735
170736
170737 --
170738 --
170739 END IF;
170740
170741 --
170742 -- Update the line information that should be overwritten
170743 --
170744 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
170745 p_header_num => 1);
170746 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
170747
170748 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
170749
170750 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
170751 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
170752 END IF;
170753
170754 --
170755 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
170756 --
170757 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
170758 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
170759 ELSE
170760 ---------------------------------------------------------------------------------------------------
170761 -- 4262811a Switch Sign
170762 ---------------------------------------------------------------------------------------------------
170763 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
170764 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
170765 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170766 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
170767 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170768 -- 5132302
170769 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
170770 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
170771
170772 END IF;
170773
170774 -- 4955764
170775 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
170776 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
170777
170778
170779 XLA_AE_LINES_PKG.ValidateCurrentLine;
170780 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
170781
170782 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
170783 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
170784 ,p_balance_type_code => l_balance_type_code);
170785
170786 END IF;
170787
170788 -----------------------------------------------------------------------------------------
170789 -- 4262811 Multiperiod Accounting
170790 -----------------------------------------------------------------------------------------
170791 -- No MPA option is assigned.
170792
170793
170794 END IF;
170795 END IF;
170796 --
170797
170798 --
170799 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
170800 trace
170801 (p_msg => 'END of AcctLineType_315'
170802 ,p_level => C_LEVEL_PROCEDURE
170803 ,p_module => l_log_module);
170804 END IF;
170805 --
170806 EXCEPTION
170807 WHEN xla_exceptions_pkg.application_exception THEN
170808 RAISE;
170809 WHEN OTHERS THEN
170810 xla_exceptions_pkg.raise_message
170811 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_315');
170812 END AcctLineType_315;
170813 --
170814
170815 ---------------------------------------
170816 --
170817 -- PRIVATE FUNCTION
170818 -- AcctLineType_316
170819 --
170820 ---------------------------------------
170821 PROCEDURE AcctLineType_316 (
170822 p_application_id IN NUMBER
170823 ,p_event_id IN NUMBER
170824 ,p_calculate_acctd_flag IN VARCHAR2
170825 ,p_calculate_g_l_flag IN VARCHAR2
170826 ,p_actual_flag IN OUT VARCHAR2
170827 ,p_balance_type_code OUT VARCHAR2
170828 ,p_gain_or_loss_ref OUT VARCHAR2
170829
170830 --TRANSACTION_ID
170831 , p_source_1 IN NUMBER
170832 --Item Concatenated Segments
170833 , p_source_2 IN VARCHAR2
170834 --Transaction Quantity
170835 , p_source_3 IN NUMBER
170836 --Transaction Unit of Measure Code
170837 , p_source_4 IN VARCHAR2
170838 --Inventory Transaction Type Description
170839 , p_source_5 IN VARCHAR2
170840 --Cost Management Default Account
170841 , p_source_11 IN NUMBER
170842 --DISTRIBUTION_IDENTIFIER
170843 , p_source_84 IN NUMBER
170844 --Distribution Type
170845 , p_source_85 IN VARCHAR2
170846 , p_source_85_meaning IN VARCHAR2
170847 --Entered Currency Code
170848 , p_source_88 IN VARCHAR2
170849 --Entered Amount
170850 , p_source_91 IN NUMBER
170851 --Currency Conversion Date
170852 , p_source_92 IN DATE
170853 --Currency Conversion Rate
170854 , p_source_93 IN NUMBER
170855 --Currency Conversion Type
170856 , p_source_94 IN VARCHAR2
170857 --Accounted Amount
170858 , p_source_95 IN NUMBER
170859 --Accounting Line Type
170860 , p_source_97 IN NUMBER
170861 )
170862 IS
170863
170864 l_component_type VARCHAR2(80);
170865 l_component_code VARCHAR2(30);
170866 l_component_type_code VARCHAR2(1);
170867 l_component_appl_id INTEGER;
170868 l_amb_context_code VARCHAR2(30);
170869 l_entity_code VARCHAR2(30);
170870 l_event_class_code VARCHAR2(30);
170871 l_ae_header_id NUMBER;
170872 l_event_type_code VARCHAR2(30);
170873 l_line_definition_code VARCHAR2(30);
170874 l_line_definition_owner_code VARCHAR2(1);
170875 --
170876 -- adr variables
170877 l_segment VARCHAR2(30);
170878 l_ccid NUMBER;
170879 l_adr_transaction_coa_id NUMBER;
170880 l_adr_accounting_coa_id NUMBER;
170881 l_adr_flexfield_segment_code VARCHAR2(30);
170882 l_adr_flex_value_set_id NUMBER;
170883 l_adr_value_type_code VARCHAR2(30);
170884 l_adr_value_combination_id NUMBER;
170885 l_adr_value_segment_code VARCHAR2(30);
170886
170887 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
170888 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
170889 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
170890 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
170891
170892 -- 4262811 Variables ------------------------------------------------------------------------------------------
170893 l_entered_amt_idx NUMBER;
170894 l_accted_amt_idx NUMBER;
170895 l_acc_rev_flag VARCHAR2(1);
170896 l_accrual_line_num NUMBER;
170897 l_tmp_amt NUMBER;
170898 l_acc_rev_natural_side_code VARCHAR2(1);
170899
170900 l_num_entries NUMBER;
170901 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
170902 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
170903 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
170904 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
170905 l_recog_line_1 NUMBER;
170906 l_recog_line_2 NUMBER;
170907
170908 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
170909 l_bflow_applied_to_amt NUMBER; -- 5132302
170910 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
170911
170912 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
170913
170914 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
170915 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
170916
170917 ---------------------------------------------------------------------------------------------------------------
170918
170919
170920 --
170921 -- bulk performance
170922 --
170923 l_balance_type_code VARCHAR2(1);
170924 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
170925 l_log_module VARCHAR2(240);
170926
170927 --
170928 -- Upgrade strategy
170929 --
170930 l_actual_upg_option VARCHAR2(1);
170931 l_enc_upg_option VARCHAR2(1);
170932
170933 --
170934 BEGIN
170935 --
170936 IF g_log_enabled THEN
170937 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_316';
170938 END IF;
170939 --
170940 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
170941
170942 trace
170943 (p_msg => 'BEGIN of AcctLineType_316'
170944 ,p_level => C_LEVEL_PROCEDURE
170945 ,p_module => l_log_module);
170946
170947 END IF;
170948 --
170949 l_component_type := 'AMB_JLT';
170950 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
170951 l_component_type_code := 'S';
170952 l_component_appl_id := 707;
170953 l_amb_context_code := 'DEFAULT';
170954 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
170955 l_event_class_code := 'USER_DEFINE';
170956 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
170957 l_line_definition_owner_code := 'S';
170958 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
170959 --
170960 l_balance_type_code := 'A';
170961 l_segment := NULL;
170962 l_ccid := NULL;
170963 l_adr_transaction_coa_id := NULL;
170964 l_adr_accounting_coa_id := NULL;
170965 l_adr_flexfield_segment_code := NULL;
170966 l_adr_flex_value_set_id := NULL;
170967 l_adr_value_type_code := NULL;
170968 l_adr_value_combination_id := NULL;
170969 l_adr_value_segment_code := NULL;
170970
170971 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
170972 l_bflow_class_code := ''; -- 4219869 Business Flow
170973 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
170974 l_budgetary_control_flag := 'N';
170975
170976 l_bflow_applied_to_amt_idx := NULL; -- 5132302
170977 l_bflow_applied_to_amt := NULL; -- 5132302
170978 l_entered_amt_idx := NULL; -- 4262811
170979 l_accted_amt_idx := NULL; -- 4262811
170980 l_acc_rev_flag := NULL; -- 4262811
170981 l_accrual_line_num := NULL; -- 4262811
170982 l_tmp_amt := NULL; -- 4262811
170983 --
170984
170985 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
170986 l_balance_type_code <> 'B' THEN
170987 IF NVL(p_source_97,9E125) = 3
170988 THEN
170989
170990 --
170991 XLA_AE_LINES_PKG.SetNewLine;
170992
170993 p_balance_type_code := l_balance_type_code;
170994 -- set the flag so later we will know whether the gain loss line needs to be created
170995
170996 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
170997 p_actual_flag :='A';
170998 END IF;
170999
171000 --
171001 -- bulk performance
171002 --
171003 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
171004 p_header_num => 0); -- 4262811
171005 --
171006 -- set accounting line options
171007 --
171008 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
171009 p_natural_side_code => 'D'
171010 , p_gain_or_loss_flag => 'N'
171011 , p_gl_transfer_mode_code => 'S'
171012 , p_acct_entry_type_code => 'A'
171013 , p_switch_side_flag => 'Y'
171014 , p_merge_duplicate_code => 'N'
171015 );
171016 --
171017 l_acc_rev_natural_side_code := 'C'; -- 4262811
171018 --
171019 --
171020 -- set accounting line type info
171021 --
171022 xla_ae_lines_pkg.SetAcctLineType
171023 (p_component_type => l_component_type
171024 ,p_event_type_code => l_event_type_code
171025 ,p_line_definition_owner_code => l_line_definition_owner_code
171026 ,p_line_definition_code => l_line_definition_code
171027 ,p_accounting_line_code => l_component_code
171028 ,p_accounting_line_type_code => l_component_type_code
171029 ,p_accounting_line_appl_id => l_component_appl_id
171030 ,p_amb_context_code => l_amb_context_code
171031 ,p_entity_code => l_entity_code
171032 ,p_event_class_code => l_event_class_code);
171033 --
171034 -- set accounting class
171035 --
171036 xla_ae_lines_pkg.SetAcctClass(
171037 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
171038 , p_ae_header_id => l_ae_header_id
171039 );
171040
171041 --
171042 -- set rounding class
171043 --
171044 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
171045 'MATERIAL_OVERHEAD_ABSORPTION';
171046
171047 --
171048 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
171049 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
171050 --
171051 -- bulk performance
171052 --
171053 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
171054
171055 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
171056 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
171057
171058 -- 4955764
171059 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
171060 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
171061
171062 -- 4458381 Public Sector Enh
171063
171064 --
171065 -- set accounting attributes for the line type
171066 --
171067 l_entered_amt_idx := 3;
171068 l_accted_amt_idx := 8;
171069 l_bflow_applied_to_amt_idx := NULL; -- 5132302
171070 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
171071 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
171072 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
171073 l_rec_acct_attrs.array_char_value(2) := p_source_85;
171074 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
171075 l_rec_acct_attrs.array_num_value(3) := p_source_91;
171076 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
171077 l_rec_acct_attrs.array_char_value(4) := p_source_88;
171078 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
171079 l_rec_acct_attrs.array_date_value(5) := p_source_92;
171080 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
171081 l_rec_acct_attrs.array_num_value(6) := p_source_93;
171082 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
171083 l_rec_acct_attrs.array_char_value(7) := p_source_94;
171084 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
171085 l_rec_acct_attrs.array_num_value(8) := p_source_95;
171086
171087 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
171088 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
171089
171090 ---------------------------------------------------------------------------------------------------------------
171091 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
171092 ---------------------------------------------------------------------------------------------------------------
171093 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
171094
171095 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
171096 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
171097
171098 IF xla_accounting_cache_pkg.GetValueChar
171099 (p_source_code => 'LEDGER_CATEGORY_CODE'
171100 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
171101 AND l_bflow_method_code = 'PRIOR_ENTRY'
171102 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
171103 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
171104 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
171105 )
171106 THEN
171107 xla_ae_lines_pkg.BflowUpgEntry
171108 (p_business_method_code => l_bflow_method_code
171109 ,p_business_class_code => l_bflow_class_code
171110 ,p_balance_type => l_balance_type_code);
171111 ELSE
171112 NULL;
171113 -- No business flow processing for business flow method of NONE.
171114 END IF;
171115
171116 --
171117 -- call analytical criteria
171118 --
171119
171120 --
171121 -- call description
171122 --
171123
171124 xla_ae_lines_pkg.SetLineDescription(
171125 p_ae_header_id => l_ae_header_id
171126 ,p_description => Description_1 (
171127 p_application_id => p_application_id
171128 , p_ae_header_id => l_ae_header_id
171129 , p_source_1 => p_source_1
171130 , p_source_2 => p_source_2
171131 , p_source_3 => p_source_3
171132 , p_source_4 => p_source_4
171133 , p_source_5 => p_source_5
171134 )
171135 );
171136
171137
171138 --
171139 -- call ADRs
171140 -- Bug 4922099
171141 --
171142 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
171143 (NVL(l_actual_upg_option, 'N') = 'O') OR
171144 (NVL(l_enc_upg_option, 'N') = 'O')
171145 )
171146 THEN
171147 NULL;
171148 --
171149 --
171150
171151 l_ccid := AcctDerRule_6(
171152 p_application_id => p_application_id
171153 , p_ae_header_id => l_ae_header_id
171154 , p_source_11 => p_source_11
171155 , x_transaction_coa_id => l_adr_transaction_coa_id
171156 , x_accounting_coa_id => l_adr_accounting_coa_id
171157 , x_value_type_code => l_adr_value_type_code
171158 , p_side => 'NA'
171159 );
171160
171161 xla_ae_lines_pkg.set_ccid(
171162 p_code_combination_id => l_ccid
171163 , p_value_type_code => l_adr_value_type_code
171164 , p_transaction_coa_id => l_adr_transaction_coa_id
171165 , p_accounting_coa_id => l_adr_accounting_coa_id
171166 , p_adr_code => 'CST_DEFAULT'
171167 , p_adr_type_code => 'S'
171168 , p_component_type => l_component_type
171169 , p_component_code => l_component_code
171170 , p_component_type_code => l_component_type_code
171171 , p_component_appl_id => l_component_appl_id
171172 , p_amb_context_code => l_amb_context_code
171173 , p_side => 'NA'
171174 );
171175
171176
171177 --
171178 --
171179 END IF;
171180 --
171181 -- Bug 4922099
171182 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
171183 (NVL(l_enc_upg_option, 'N') = 'O')
171184 ) AND
171185 (l_bflow_method_code = 'PRIOR_ENTRY')
171186 )
171187 THEN
171188 IF
171189 --
171190 1 = 2
171191 --
171192 THEN
171193 xla_accounting_err_pkg.build_message
171194 (p_appli_s_name => 'XLA'
171195 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
171196 ,p_token_1 => 'LINE_NUMBER'
171197 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
171198 ,p_token_2 => 'LINE_TYPE_NAME'
171199 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
171200 l_component_type
171201 ,l_component_code
171202 ,l_component_type_code
171203 ,l_component_appl_id
171204 ,l_amb_context_code
171205 ,l_entity_code
171206 ,l_event_class_code
171207 )
171208 ,p_token_3 => 'OWNER'
171209 ,p_value_3 => xla_lookups_pkg.get_meaning(
171210 p_lookup_type => 'XLA_OWNER_TYPE'
171211 ,p_lookup_code => l_component_type_code
171212 )
171213 ,p_token_4 => 'PRODUCT_NAME'
171214 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
171215 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
171216 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
171217 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
171218 ,p_ae_header_id => NULL
171219 );
171220
171221 IF (C_LEVEL_ERROR>= g_log_level) THEN
171222 trace
171223 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
171224 ,p_level => C_LEVEL_ERROR
171225 ,p_module => l_log_module);
171226 END IF;
171227 END IF;
171228 END IF;
171229 --
171230 --
171231 ------------------------------------------------------------------------------------------------
171232 -- 4219869 Business Flow
171233 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
171234 -- Prior Entry. Currently, the following code is always generated.
171235 ------------------------------------------------------------------------------------------------
171236 XLA_AE_LINES_PKG.ValidateCurrentLine;
171237
171238 ------------------------------------------------------------------------------------
171239 -- 4219869 Business Flow
171240 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
171241 ------------------------------------------------------------------------------------
171242 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
171243
171244 ----------------------------------------------------------------------------------
171245 -- 4219869 Business Flow
171246 -- Update journal entry status -- Need to generate this within IF <condition>
171247 ----------------------------------------------------------------------------------
171248 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
171249 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
171250 ,p_balance_type_code => l_balance_type_code
171251 );
171252
171253 -------------------------------------------------------------------------------------------
171254 -- 4262811 - Generate the Accrual Reversal lines
171255 -------------------------------------------------------------------------------------------
171256 BEGIN
171257 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
171258 (g_array_event(p_event_id).array_value_num('header_index'));
171259 IF l_acc_rev_flag IS NULL THEN
171260 l_acc_rev_flag := 'N';
171261 END IF;
171262 EXCEPTION
171263 WHEN OTHERS THEN
171264 l_acc_rev_flag := 'N';
171265 END;
171266 --
171267 IF (l_acc_rev_flag = 'Y') THEN
171268
171269 -- 4645092 ------------------------------------------------------------------------------
171270 -- To allow MPA report to determine if it should generate report process
171271 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
171272 ------------------------------------------------------------------------------------------
171273
171274 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
171275 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
171276 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
171277 -- call ADRs
171278 -- Bug 4922099
171279 --
171280 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
171281 (NVL(l_actual_upg_option, 'N') = 'O') OR
171282 (NVL(l_enc_upg_option, 'N') = 'O')
171283 )
171284 THEN
171285 NULL;
171286 --
171287 --
171288
171289 l_ccid := AcctDerRule_6(
171290 p_application_id => p_application_id
171291 , p_ae_header_id => l_ae_header_id
171292 , p_source_11 => p_source_11
171293 , x_transaction_coa_id => l_adr_transaction_coa_id
171294 , x_accounting_coa_id => l_adr_accounting_coa_id
171295 , x_value_type_code => l_adr_value_type_code
171296 , p_side => 'NA'
171297 );
171298
171299 xla_ae_lines_pkg.set_ccid(
171300 p_code_combination_id => l_ccid
171301 , p_value_type_code => l_adr_value_type_code
171302 , p_transaction_coa_id => l_adr_transaction_coa_id
171303 , p_accounting_coa_id => l_adr_accounting_coa_id
171304 , p_adr_code => 'CST_DEFAULT'
171305 , p_adr_type_code => 'S'
171306 , p_component_type => l_component_type
171307 , p_component_code => l_component_code
171308 , p_component_type_code => l_component_type_code
171309 , p_component_appl_id => l_component_appl_id
171310 , p_amb_context_code => l_amb_context_code
171311 , p_side => 'NA'
171312 );
171313
171314
171315 --
171316 --
171317 END IF;
171318
171319 --
171320 -- Update the line information that should be overwritten
171321 --
171322 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
171323 p_header_num => 1);
171324 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
171325
171326 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
171327
171328 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
171329 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
171330 END IF;
171331
171332 --
171333 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
171334 --
171335 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
171336 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
171337 ELSE
171338 ---------------------------------------------------------------------------------------------------
171339 -- 4262811a Switch Sign
171340 ---------------------------------------------------------------------------------------------------
171341 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
171342 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
171343 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171344 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
171345 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171346 -- 5132302
171347 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
171348 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171349
171350 END IF;
171351
171352 -- 4955764
171353 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
171354 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
171355
171356
171357 XLA_AE_LINES_PKG.ValidateCurrentLine;
171358 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
171359
171360 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
171361 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
171362 ,p_balance_type_code => l_balance_type_code);
171363
171364 END IF;
171365
171366 -----------------------------------------------------------------------------------------
171367 -- 4262811 Multiperiod Accounting
171368 -----------------------------------------------------------------------------------------
171369 -- No MPA option is assigned.
171370
171371
171372 END IF;
171373 END IF;
171374 --
171375
171376 --
171377 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
171378 trace
171379 (p_msg => 'END of AcctLineType_316'
171380 ,p_level => C_LEVEL_PROCEDURE
171381 ,p_module => l_log_module);
171382 END IF;
171383 --
171384 EXCEPTION
171385 WHEN xla_exceptions_pkg.application_exception THEN
171386 RAISE;
171387 WHEN OTHERS THEN
171388 xla_exceptions_pkg.raise_message
171389 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_316');
171390 END AcctLineType_316;
171391 --
171392
171393 ---------------------------------------
171394 --
171395 -- PRIVATE FUNCTION
171396 -- AcctLineType_317
171397 --
171398 ---------------------------------------
171399 PROCEDURE AcctLineType_317 (
171400 p_application_id IN NUMBER
171401 ,p_event_id IN NUMBER
171402 ,p_calculate_acctd_flag IN VARCHAR2
171403 ,p_calculate_g_l_flag IN VARCHAR2
171404 ,p_actual_flag IN OUT VARCHAR2
171405 ,p_balance_type_code OUT VARCHAR2
171406 ,p_gain_or_loss_ref OUT VARCHAR2
171407
171408 --TRANSACTION_ID
171409 , p_source_1 IN NUMBER
171410 --Item Concatenated Segments
171411 , p_source_2 IN VARCHAR2
171412 --Transaction Quantity
171413 , p_source_3 IN NUMBER
171414 --Transaction Unit of Measure Code
171415 , p_source_4 IN VARCHAR2
171416 --Inventory Transaction Type Description
171417 , p_source_5 IN VARCHAR2
171418 --Cost Management Default Account
171419 , p_source_11 IN NUMBER
171420 --Applied to Application ID
171421 , p_source_79 IN NUMBER
171422 --Applied to Distribution Link Type
171423 , p_source_80 IN VARCHAR2
171424 --Applied to Entity Code
171425 , p_source_81 IN VARCHAR2
171426 --Applied To Purchase Document Identifier
171427 , p_source_83 IN NUMBER
171428 --DISTRIBUTION_IDENTIFIER
171429 , p_source_84 IN NUMBER
171430 --Distribution Type
171431 , p_source_85 IN VARCHAR2
171432 , p_source_85_meaning IN VARCHAR2
171433 --PO Budget Account
171434 , p_source_86 IN NUMBER
171435 --Encumbrance Reversal Amount Entered
171436 , p_source_87 IN NUMBER
171437 --Entered Currency Code
171438 , p_source_88 IN VARCHAR2
171439 --Transaction Encumbrance Reversal Amount
171440 , p_source_89 IN NUMBER
171441 --Entered Amount
171442 , p_source_91 IN NUMBER
171443 --Currency Conversion Date
171444 , p_source_92 IN DATE
171445 --Currency Conversion Rate
171446 , p_source_93 IN NUMBER
171447 --Currency Conversion Type
171448 , p_source_94 IN VARCHAR2
171449 --Accounted Amount
171450 , p_source_95 IN NUMBER
171451 --Purchasing Encumbrance Type Identifier
171452 , p_source_96 IN NUMBER
171453 --Accounting Line Type
171454 , p_source_97 IN NUMBER
171455 --Costing Encumbrance Upgrade Option
171456 , p_source_100 IN VARCHAR2
171457 --TXN_PO_DISTRIBUTION_ID
171458 , p_source_101 IN NUMBER
171459 )
171460 IS
171461
171462 l_component_type VARCHAR2(80);
171463 l_component_code VARCHAR2(30);
171464 l_component_type_code VARCHAR2(1);
171465 l_component_appl_id INTEGER;
171466 l_amb_context_code VARCHAR2(30);
171467 l_entity_code VARCHAR2(30);
171468 l_event_class_code VARCHAR2(30);
171469 l_ae_header_id NUMBER;
171470 l_event_type_code VARCHAR2(30);
171471 l_line_definition_code VARCHAR2(30);
171472 l_line_definition_owner_code VARCHAR2(1);
171473 --
171474 -- adr variables
171475 l_segment VARCHAR2(30);
171476 l_ccid NUMBER;
171477 l_adr_transaction_coa_id NUMBER;
171478 l_adr_accounting_coa_id NUMBER;
171479 l_adr_flexfield_segment_code VARCHAR2(30);
171480 l_adr_flex_value_set_id NUMBER;
171481 l_adr_value_type_code VARCHAR2(30);
171482 l_adr_value_combination_id NUMBER;
171483 l_adr_value_segment_code VARCHAR2(30);
171484
171485 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
171486 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
171487 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
171488 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
171489
171490 -- 4262811 Variables ------------------------------------------------------------------------------------------
171491 l_entered_amt_idx NUMBER;
171492 l_accted_amt_idx NUMBER;
171493 l_acc_rev_flag VARCHAR2(1);
171494 l_accrual_line_num NUMBER;
171495 l_tmp_amt NUMBER;
171496 l_acc_rev_natural_side_code VARCHAR2(1);
171497
171498 l_num_entries NUMBER;
171499 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
171500 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
171501 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
171502 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
171503 l_recog_line_1 NUMBER;
171504 l_recog_line_2 NUMBER;
171505
171506 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
171507 l_bflow_applied_to_amt NUMBER; -- 5132302
171508 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
171509
171510 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
171511
171512 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
171513 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
171514
171515 ---------------------------------------------------------------------------------------------------------------
171516
171517
171518 --
171519 -- bulk performance
171520 --
171521 l_balance_type_code VARCHAR2(1);
171522 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
171523 l_log_module VARCHAR2(240);
171524
171525 --
171526 -- Upgrade strategy
171527 --
171528 l_actual_upg_option VARCHAR2(1);
171529 l_enc_upg_option VARCHAR2(1);
171530
171531 --
171532 BEGIN
171533 --
171534 IF g_log_enabled THEN
171535 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_317';
171536 END IF;
171537 --
171538 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
171539
171540 trace
171541 (p_msg => 'BEGIN of AcctLineType_317'
171542 ,p_level => C_LEVEL_PROCEDURE
171543 ,p_module => l_log_module);
171544
171545 END IF;
171546 --
171547 l_component_type := 'AMB_JLT';
171548 l_component_code := 'MATERIAL_OVERHEAD_ABSORPTION';
171549 l_component_type_code := 'S';
171550 l_component_appl_id := 707;
171551 l_amb_context_code := 'DEFAULT';
171552 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
171553 l_event_class_code := 'PURCHASE_ORDER';
171554 l_event_type_code := 'RET_RI_INV';
171555 l_line_definition_owner_code := 'S';
171556 l_line_definition_code := 'PI_RET_RI_INV';
171557 --
171558 l_balance_type_code := 'A';
171559 l_segment := NULL;
171560 l_ccid := NULL;
171561 l_adr_transaction_coa_id := NULL;
171562 l_adr_accounting_coa_id := NULL;
171563 l_adr_flexfield_segment_code := NULL;
171564 l_adr_flex_value_set_id := NULL;
171565 l_adr_value_type_code := NULL;
171566 l_adr_value_combination_id := NULL;
171567 l_adr_value_segment_code := NULL;
171568
171569 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
171570 l_bflow_class_code := ''; -- 4219869 Business Flow
171571 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
171572 l_budgetary_control_flag := 'N';
171573
171574 l_bflow_applied_to_amt_idx := NULL; -- 5132302
171575 l_bflow_applied_to_amt := NULL; -- 5132302
171576 l_entered_amt_idx := NULL; -- 4262811
171577 l_accted_amt_idx := NULL; -- 4262811
171578 l_acc_rev_flag := NULL; -- 4262811
171579 l_accrual_line_num := NULL; -- 4262811
171580 l_tmp_amt := NULL; -- 4262811
171581 --
171582
171583 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
171584 l_balance_type_code <> 'B' THEN
171585 IF NVL(p_source_97,9E125) = 3
171586 THEN
171587
171588 --
171589 XLA_AE_LINES_PKG.SetNewLine;
171590
171591 p_balance_type_code := l_balance_type_code;
171592 -- set the flag so later we will know whether the gain loss line needs to be created
171593
171594 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
171595 p_actual_flag :='A';
171596 END IF;
171597
171598 --
171599 -- bulk performance
171600 --
171601 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
171602 p_header_num => 0); -- 4262811
171603 --
171604 -- set accounting line options
171605 --
171606 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
171607 p_natural_side_code => 'D'
171608 , p_gain_or_loss_flag => 'N'
171609 , p_gl_transfer_mode_code => 'S'
171610 , p_acct_entry_type_code => 'A'
171611 , p_switch_side_flag => 'Y'
171612 , p_merge_duplicate_code => 'N'
171613 );
171614 --
171615 l_acc_rev_natural_side_code := 'C'; -- 4262811
171616 --
171617 --
171618 -- set accounting line type info
171619 --
171620 xla_ae_lines_pkg.SetAcctLineType
171621 (p_component_type => l_component_type
171622 ,p_event_type_code => l_event_type_code
171623 ,p_line_definition_owner_code => l_line_definition_owner_code
171624 ,p_line_definition_code => l_line_definition_code
171625 ,p_accounting_line_code => l_component_code
171626 ,p_accounting_line_type_code => l_component_type_code
171627 ,p_accounting_line_appl_id => l_component_appl_id
171628 ,p_amb_context_code => l_amb_context_code
171629 ,p_entity_code => l_entity_code
171630 ,p_event_class_code => l_event_class_code);
171631 --
171632 -- set accounting class
171633 --
171634 xla_ae_lines_pkg.SetAcctClass(
171635 p_accounting_class_code => 'MATERIAL_OVERHEAD_ABSORPTION'
171636 , p_ae_header_id => l_ae_header_id
171637 );
171638
171639 --
171640 -- set rounding class
171641 --
171642 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
171643 'MATERIAL_OVERHEAD_ABSORPTION';
171644
171645 --
171646 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
171647 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
171648 --
171649 -- bulk performance
171650 --
171651 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
171652
171653 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
171654 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
171655
171656 -- 4955764
171657 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
171658 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
171659
171660 -- 4458381 Public Sector Enh
171661
171662 --
171663 -- set accounting attributes for the line type
171664 --
171665 l_entered_amt_idx := 17;
171666 l_accted_amt_idx := 22;
171667 l_bflow_applied_to_amt_idx := NULL; -- 5132302
171668 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
171669 l_rec_acct_attrs.array_num_value(1) := p_source_79;
171670 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
171671 l_rec_acct_attrs.array_char_value(2) := p_source_80;
171672 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
171673 l_rec_acct_attrs.array_char_value(3) := p_source_81;
171674 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
171675 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
171676 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
171677 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
171678 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
171679 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
171680 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
171681 l_rec_acct_attrs.array_char_value(7) := p_source_85;
171682 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
171683 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
171684 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
171685 l_rec_acct_attrs.array_num_value(9) := p_source_87;
171686 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
171687 l_rec_acct_attrs.array_char_value(10) := p_source_88;
171688 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
171689 l_rec_acct_attrs.array_num_value(11) := p_source_89;
171690 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
171691 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
171692 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
171693 l_rec_acct_attrs.array_num_value(13) := p_source_87;
171694 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
171695 l_rec_acct_attrs.array_char_value(14) := p_source_88;
171696 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
171697 l_rec_acct_attrs.array_num_value(15) := p_source_89;
171698 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
171699 l_rec_acct_attrs.array_char_value(16) := p_source_100;
171700 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
171701 l_rec_acct_attrs.array_num_value(17) := p_source_91;
171702 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
171703 l_rec_acct_attrs.array_char_value(18) := p_source_88;
171704 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
171705 l_rec_acct_attrs.array_date_value(19) := p_source_92;
171706 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
171707 l_rec_acct_attrs.array_num_value(20) := p_source_93;
171708 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
171709 l_rec_acct_attrs.array_char_value(21) := p_source_94;
171710 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
171711 l_rec_acct_attrs.array_num_value(22) := p_source_95;
171712 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
171713 l_rec_acct_attrs.array_num_value(23) := p_source_96;
171714 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
171715 l_rec_acct_attrs.array_num_value(24) := p_source_96;
171716
171717 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
171718 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
171719
171720 ---------------------------------------------------------------------------------------------------------------
171721 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
171722 ---------------------------------------------------------------------------------------------------------------
171723 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
171724
171725 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
171726 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
171727
171728 IF xla_accounting_cache_pkg.GetValueChar
171729 (p_source_code => 'LEDGER_CATEGORY_CODE'
171730 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
171731 AND l_bflow_method_code = 'PRIOR_ENTRY'
171732 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
171733 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
171734 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
171735 )
171736 THEN
171737 xla_ae_lines_pkg.BflowUpgEntry
171738 (p_business_method_code => l_bflow_method_code
171739 ,p_business_class_code => l_bflow_class_code
171740 ,p_balance_type => l_balance_type_code);
171741 ELSE
171742 NULL;
171743 -- No business flow processing for business flow method of NONE.
171744 END IF;
171745
171746 --
171747 -- call analytical criteria
171748 --
171749
171750 --
171751 -- call description
171752 --
171753
171754 xla_ae_lines_pkg.SetLineDescription(
171755 p_ae_header_id => l_ae_header_id
171756 ,p_description => Description_1 (
171757 p_application_id => p_application_id
171758 , p_ae_header_id => l_ae_header_id
171759 , p_source_1 => p_source_1
171760 , p_source_2 => p_source_2
171761 , p_source_3 => p_source_3
171762 , p_source_4 => p_source_4
171763 , p_source_5 => p_source_5
171764 )
171765 );
171766
171767
171768 --
171769 -- call ADRs
171770 -- Bug 4922099
171771 --
171772 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
171773 (NVL(l_actual_upg_option, 'N') = 'O') OR
171774 (NVL(l_enc_upg_option, 'N') = 'O')
171775 )
171776 THEN
171777 NULL;
171778 --
171779 --
171780
171781 l_ccid := AcctDerRule_6(
171782 p_application_id => p_application_id
171783 , p_ae_header_id => l_ae_header_id
171784 , p_source_11 => p_source_11
171785 , x_transaction_coa_id => l_adr_transaction_coa_id
171786 , x_accounting_coa_id => l_adr_accounting_coa_id
171787 , x_value_type_code => l_adr_value_type_code
171788 , p_side => 'NA'
171789 );
171790
171791 xla_ae_lines_pkg.set_ccid(
171792 p_code_combination_id => l_ccid
171793 , p_value_type_code => l_adr_value_type_code
171794 , p_transaction_coa_id => l_adr_transaction_coa_id
171795 , p_accounting_coa_id => l_adr_accounting_coa_id
171796 , p_adr_code => 'CST_DEFAULT'
171797 , p_adr_type_code => 'S'
171798 , p_component_type => l_component_type
171799 , p_component_code => l_component_code
171800 , p_component_type_code => l_component_type_code
171801 , p_component_appl_id => l_component_appl_id
171802 , p_amb_context_code => l_amb_context_code
171803 , p_side => 'NA'
171804 );
171805
171806
171807 --
171808 --
171809 END IF;
171810 --
171811 -- Bug 4922099
171812 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
171813 (NVL(l_enc_upg_option, 'N') = 'O')
171814 ) AND
171815 (l_bflow_method_code = 'PRIOR_ENTRY')
171816 )
171817 THEN
171818 IF
171819 --
171820 1 = 2
171821 --
171822 THEN
171823 xla_accounting_err_pkg.build_message
171824 (p_appli_s_name => 'XLA'
171825 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
171826 ,p_token_1 => 'LINE_NUMBER'
171827 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
171828 ,p_token_2 => 'LINE_TYPE_NAME'
171829 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
171830 l_component_type
171831 ,l_component_code
171832 ,l_component_type_code
171833 ,l_component_appl_id
171834 ,l_amb_context_code
171835 ,l_entity_code
171836 ,l_event_class_code
171837 )
171838 ,p_token_3 => 'OWNER'
171839 ,p_value_3 => xla_lookups_pkg.get_meaning(
171840 p_lookup_type => 'XLA_OWNER_TYPE'
171841 ,p_lookup_code => l_component_type_code
171842 )
171843 ,p_token_4 => 'PRODUCT_NAME'
171844 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
171845 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
171846 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
171847 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
171848 ,p_ae_header_id => NULL
171849 );
171850
171851 IF (C_LEVEL_ERROR>= g_log_level) THEN
171852 trace
171853 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
171854 ,p_level => C_LEVEL_ERROR
171855 ,p_module => l_log_module);
171856 END IF;
171857 END IF;
171858 END IF;
171859 --
171860 --
171861 ------------------------------------------------------------------------------------------------
171862 -- 4219869 Business Flow
171863 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
171864 -- Prior Entry. Currently, the following code is always generated.
171865 ------------------------------------------------------------------------------------------------
171866 XLA_AE_LINES_PKG.ValidateCurrentLine;
171867
171868 ------------------------------------------------------------------------------------
171869 -- 4219869 Business Flow
171870 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
171871 ------------------------------------------------------------------------------------
171872 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
171873
171874 ----------------------------------------------------------------------------------
171875 -- 4219869 Business Flow
171876 -- Update journal entry status -- Need to generate this within IF <condition>
171877 ----------------------------------------------------------------------------------
171878 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
171879 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
171880 ,p_balance_type_code => l_balance_type_code
171881 );
171882
171883 -------------------------------------------------------------------------------------------
171884 -- 4262811 - Generate the Accrual Reversal lines
171885 -------------------------------------------------------------------------------------------
171886 BEGIN
171887 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
171888 (g_array_event(p_event_id).array_value_num('header_index'));
171889 IF l_acc_rev_flag IS NULL THEN
171890 l_acc_rev_flag := 'N';
171891 END IF;
171892 EXCEPTION
171893 WHEN OTHERS THEN
171894 l_acc_rev_flag := 'N';
171895 END;
171896 --
171897 IF (l_acc_rev_flag = 'Y') THEN
171898
171899 -- 4645092 ------------------------------------------------------------------------------
171900 -- To allow MPA report to determine if it should generate report process
171901 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
171902 ------------------------------------------------------------------------------------------
171903
171904 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
171905 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
171906 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
171907 -- call ADRs
171908 -- Bug 4922099
171909 --
171910 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
171911 (NVL(l_actual_upg_option, 'N') = 'O') OR
171912 (NVL(l_enc_upg_option, 'N') = 'O')
171913 )
171914 THEN
171915 NULL;
171916 --
171917 --
171918
171919 l_ccid := AcctDerRule_6(
171920 p_application_id => p_application_id
171921 , p_ae_header_id => l_ae_header_id
171922 , p_source_11 => p_source_11
171923 , x_transaction_coa_id => l_adr_transaction_coa_id
171924 , x_accounting_coa_id => l_adr_accounting_coa_id
171925 , x_value_type_code => l_adr_value_type_code
171926 , p_side => 'NA'
171927 );
171928
171929 xla_ae_lines_pkg.set_ccid(
171930 p_code_combination_id => l_ccid
171931 , p_value_type_code => l_adr_value_type_code
171932 , p_transaction_coa_id => l_adr_transaction_coa_id
171933 , p_accounting_coa_id => l_adr_accounting_coa_id
171934 , p_adr_code => 'CST_DEFAULT'
171935 , p_adr_type_code => 'S'
171936 , p_component_type => l_component_type
171937 , p_component_code => l_component_code
171938 , p_component_type_code => l_component_type_code
171939 , p_component_appl_id => l_component_appl_id
171940 , p_amb_context_code => l_amb_context_code
171941 , p_side => 'NA'
171942 );
171943
171944
171945 --
171946 --
171947 END IF;
171948
171949 --
171950 -- Update the line information that should be overwritten
171951 --
171952 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
171953 p_header_num => 1);
171954 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
171955
171956 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
171957
171958 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
171959 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
171960 END IF;
171961
171962 --
171963 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
171964 --
171965 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
171966 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
171967 ELSE
171968 ---------------------------------------------------------------------------------------------------
171969 -- 4262811a Switch Sign
171970 ---------------------------------------------------------------------------------------------------
171971 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
171972 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
171973 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171974 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
171975 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171976 -- 5132302
171977 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
171978 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
171979
171980 END IF;
171981
171982 -- 4955764
171983 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
171984 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
171985
171986
171987 XLA_AE_LINES_PKG.ValidateCurrentLine;
171988 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
171989
171990 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
171991 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
171992 ,p_balance_type_code => l_balance_type_code);
171993
171994 END IF;
171995
171996 -----------------------------------------------------------------------------------------
171997 -- 4262811 Multiperiod Accounting
171998 -----------------------------------------------------------------------------------------
171999 -- No MPA option is assigned.
172000
172001
172002 END IF;
172003 END IF;
172004 --
172005
172006 --
172007 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
172008 trace
172009 (p_msg => 'END of AcctLineType_317'
172010 ,p_level => C_LEVEL_PROCEDURE
172011 ,p_module => l_log_module);
172012 END IF;
172013 --
172014 EXCEPTION
172015 WHEN xla_exceptions_pkg.application_exception THEN
172016 RAISE;
172017 WHEN OTHERS THEN
172018 xla_exceptions_pkg.raise_message
172019 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_317');
172020 END AcctLineType_317;
172021 --
172022
172023 ---------------------------------------
172024 --
172025 -- PRIVATE FUNCTION
172026 -- AcctLineType_318
172027 --
172028 ---------------------------------------
172029 PROCEDURE AcctLineType_318 (
172030 p_application_id IN NUMBER
172031 ,p_event_id IN NUMBER
172032 ,p_calculate_acctd_flag IN VARCHAR2
172033 ,p_calculate_g_l_flag IN VARCHAR2
172034 ,p_actual_flag IN OUT VARCHAR2
172035 ,p_balance_type_code OUT VARCHAR2
172036 ,p_gain_or_loss_ref OUT VARCHAR2
172037
172038 --TRANSACTION_ID
172039 , p_source_1 IN NUMBER
172040 --Item Concatenated Segments
172041 , p_source_2 IN VARCHAR2
172042 --Transaction Quantity
172043 , p_source_3 IN NUMBER
172044 --Transaction Unit of Measure Code
172045 , p_source_4 IN VARCHAR2
172046 --Inventory Transaction Type Description
172047 , p_source_5 IN VARCHAR2
172048 --Product Line Accounting Category Expense Account
172049 , p_source_24 IN NUMBER
172050 --Transfer to Subinventory or Cost Group category expense account
172051 , p_source_25 IN NUMBER
172052 --Cost Group Identifier
172053 , p_source_26 IN NUMBER
172054 --INV Header Transfer Cost Group ID
172055 , p_source_27 IN NUMBER
172056 --INV Header Cost Group ID
172057 , p_source_28 IN NUMBER
172058 --Subinventory Name
172059 , p_source_29 IN VARCHAR2
172060 --INV Header Transfer Subinventory
172061 , p_source_31 IN VARCHAR2
172062 --DISTRIBUTION_IDENTIFIER
172063 , p_source_84 IN NUMBER
172064 --Distribution Type
172065 , p_source_85 IN VARCHAR2
172066 , p_source_85_meaning IN VARCHAR2
172067 --Entered Currency Code
172068 , p_source_88 IN VARCHAR2
172069 --Entered Amount
172070 , p_source_91 IN NUMBER
172071 --Currency Conversion Date
172072 , p_source_92 IN DATE
172073 --Currency Conversion Rate
172074 , p_source_93 IN NUMBER
172075 --Currency Conversion Type
172076 , p_source_94 IN VARCHAR2
172077 --Accounted Amount
172078 , p_source_95 IN NUMBER
172079 --Accounting Line Type
172080 , p_source_97 IN NUMBER
172081 )
172082 IS
172083
172084 l_component_type VARCHAR2(80);
172085 l_component_code VARCHAR2(30);
172086 l_component_type_code VARCHAR2(1);
172087 l_component_appl_id INTEGER;
172088 l_amb_context_code VARCHAR2(30);
172089 l_entity_code VARCHAR2(30);
172090 l_event_class_code VARCHAR2(30);
172091 l_ae_header_id NUMBER;
172092 l_event_type_code VARCHAR2(30);
172093 l_line_definition_code VARCHAR2(30);
172094 l_line_definition_owner_code VARCHAR2(1);
172095 --
172096 -- adr variables
172097 l_segment VARCHAR2(30);
172098 l_ccid NUMBER;
172099 l_adr_transaction_coa_id NUMBER;
172100 l_adr_accounting_coa_id NUMBER;
172101 l_adr_flexfield_segment_code VARCHAR2(30);
172102 l_adr_flex_value_set_id NUMBER;
172103 l_adr_value_type_code VARCHAR2(30);
172104 l_adr_value_combination_id NUMBER;
172105 l_adr_value_segment_code VARCHAR2(30);
172106
172107 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
172108 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
172109 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
172110 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
172111
172112 -- 4262811 Variables ------------------------------------------------------------------------------------------
172113 l_entered_amt_idx NUMBER;
172114 l_accted_amt_idx NUMBER;
172115 l_acc_rev_flag VARCHAR2(1);
172116 l_accrual_line_num NUMBER;
172117 l_tmp_amt NUMBER;
172118 l_acc_rev_natural_side_code VARCHAR2(1);
172119
172120 l_num_entries NUMBER;
172121 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
172122 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
172123 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
172124 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
172125 l_recog_line_1 NUMBER;
172126 l_recog_line_2 NUMBER;
172127
172128 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
172129 l_bflow_applied_to_amt NUMBER; -- 5132302
172130 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
172131
172132 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
172133
172134 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
172135 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
172136
172137 ---------------------------------------------------------------------------------------------------------------
172138
172139
172140 --
172141 -- bulk performance
172142 --
172143 l_balance_type_code VARCHAR2(1);
172144 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
172145 l_log_module VARCHAR2(240);
172146
172147 --
172148 -- Upgrade strategy
172149 --
172150 l_actual_upg_option VARCHAR2(1);
172151 l_enc_upg_option VARCHAR2(1);
172152
172153 --
172154 BEGIN
172155 --
172156 IF g_log_enabled THEN
172157 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_318';
172158 END IF;
172159 --
172160 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
172161
172162 trace
172163 (p_msg => 'BEGIN of AcctLineType_318'
172164 ,p_level => C_LEVEL_PROCEDURE
172165 ,p_module => l_log_module);
172166
172167 END IF;
172168 --
172169 l_component_type := 'AMB_JLT';
172170 l_component_code := 'OFFSET';
172171 l_component_type_code := 'S';
172172 l_component_appl_id := 707;
172173 l_amb_context_code := 'DEFAULT';
172174 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
172175 l_event_class_code := 'INTRAORG_TXFR';
172176 l_event_type_code := 'INTRAORG_TXFR_ALL';
172177 l_line_definition_owner_code := 'S';
172178 l_line_definition_code := 'PI_INTRAORG_TXFR';
172179 --
172180 l_balance_type_code := 'A';
172181 l_segment := NULL;
172182 l_ccid := NULL;
172183 l_adr_transaction_coa_id := NULL;
172184 l_adr_accounting_coa_id := NULL;
172185 l_adr_flexfield_segment_code := NULL;
172186 l_adr_flex_value_set_id := NULL;
172187 l_adr_value_type_code := NULL;
172188 l_adr_value_combination_id := NULL;
172189 l_adr_value_segment_code := NULL;
172190
172191 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
172192 l_bflow_class_code := ''; -- 4219869 Business Flow
172193 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
172194 l_budgetary_control_flag := 'N';
172195
172196 l_bflow_applied_to_amt_idx := NULL; -- 5132302
172197 l_bflow_applied_to_amt := NULL; -- 5132302
172198 l_entered_amt_idx := NULL; -- 4262811
172199 l_accted_amt_idx := NULL; -- 4262811
172200 l_acc_rev_flag := NULL; -- 4262811
172201 l_accrual_line_num := NULL; -- 4262811
172202 l_tmp_amt := NULL; -- 4262811
172203 --
172204
172205 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
172206 l_balance_type_code <> 'B' THEN
172207 IF NVL(p_source_97,9E125) = 2
172208 THEN
172209
172210 --
172211 XLA_AE_LINES_PKG.SetNewLine;
172212
172213 p_balance_type_code := l_balance_type_code;
172214 -- set the flag so later we will know whether the gain loss line needs to be created
172215
172216 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
172217 p_actual_flag :='A';
172218 END IF;
172219
172220 --
172221 -- bulk performance
172222 --
172223 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
172224 p_header_num => 0); -- 4262811
172225 --
172226 -- set accounting line options
172227 --
172228 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
172229 p_natural_side_code => 'D'
172230 , p_gain_or_loss_flag => 'N'
172231 , p_gl_transfer_mode_code => 'S'
172232 , p_acct_entry_type_code => 'A'
172233 , p_switch_side_flag => 'Y'
172234 , p_merge_duplicate_code => 'N'
172235 );
172236 --
172237 l_acc_rev_natural_side_code := 'C'; -- 4262811
172238 --
172239 --
172240 -- set accounting line type info
172241 --
172242 xla_ae_lines_pkg.SetAcctLineType
172243 (p_component_type => l_component_type
172244 ,p_event_type_code => l_event_type_code
172245 ,p_line_definition_owner_code => l_line_definition_owner_code
172246 ,p_line_definition_code => l_line_definition_code
172247 ,p_accounting_line_code => l_component_code
172248 ,p_accounting_line_type_code => l_component_type_code
172249 ,p_accounting_line_appl_id => l_component_appl_id
172250 ,p_amb_context_code => l_amb_context_code
172251 ,p_entity_code => l_entity_code
172252 ,p_event_class_code => l_event_class_code);
172253 --
172254 -- set accounting class
172255 --
172256 xla_ae_lines_pkg.SetAcctClass(
172257 p_accounting_class_code => 'OFFSET'
172258 , p_ae_header_id => l_ae_header_id
172259 );
172260
172261 --
172262 -- set rounding class
172263 --
172264 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
172265 'OFFSET';
172266
172267 --
172268 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
172269 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
172270 --
172271 -- bulk performance
172272 --
172273 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
172274
172275 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
172276 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
172277
172278 -- 4955764
172279 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
172280 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
172281
172282 -- 4458381 Public Sector Enh
172283
172284 --
172285 -- set accounting attributes for the line type
172286 --
172287 l_entered_amt_idx := 3;
172288 l_accted_amt_idx := 8;
172289 l_bflow_applied_to_amt_idx := NULL; -- 5132302
172290 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
172291 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
172292 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
172293 l_rec_acct_attrs.array_char_value(2) := p_source_85;
172294 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
172295 l_rec_acct_attrs.array_num_value(3) := p_source_91;
172296 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
172297 l_rec_acct_attrs.array_char_value(4) := p_source_88;
172298 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
172299 l_rec_acct_attrs.array_date_value(5) := p_source_92;
172300 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
172301 l_rec_acct_attrs.array_num_value(6) := p_source_93;
172302 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
172303 l_rec_acct_attrs.array_char_value(7) := p_source_94;
172304 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
172305 l_rec_acct_attrs.array_num_value(8) := p_source_95;
172306
172307 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
172308 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
172309
172310 ---------------------------------------------------------------------------------------------------------------
172311 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
172312 ---------------------------------------------------------------------------------------------------------------
172313 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
172314
172315 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
172316 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
172317
172318 IF xla_accounting_cache_pkg.GetValueChar
172319 (p_source_code => 'LEDGER_CATEGORY_CODE'
172320 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
172321 AND l_bflow_method_code = 'PRIOR_ENTRY'
172322 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
172323 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
172324 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
172325 )
172326 THEN
172327 xla_ae_lines_pkg.BflowUpgEntry
172328 (p_business_method_code => l_bflow_method_code
172329 ,p_business_class_code => l_bflow_class_code
172330 ,p_balance_type => l_balance_type_code);
172331 ELSE
172332 NULL;
172333 -- No business flow processing for business flow method of NONE.
172334 END IF;
172335
172336 --
172337 -- call analytical criteria
172338 --
172339
172340 --
172341 -- call description
172342 --
172343
172344 xla_ae_lines_pkg.SetLineDescription(
172345 p_ae_header_id => l_ae_header_id
172346 ,p_description => Description_1 (
172347 p_application_id => p_application_id
172348 , p_ae_header_id => l_ae_header_id
172349 , p_source_1 => p_source_1
172350 , p_source_2 => p_source_2
172351 , p_source_3 => p_source_3
172352 , p_source_4 => p_source_4
172353 , p_source_5 => p_source_5
172354 )
172355 );
172356
172357
172358 --
172359 -- call ADRs
172360 -- Bug 4922099
172361 --
172362 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
172363 (NVL(l_actual_upg_option, 'N') = 'O') OR
172364 (NVL(l_enc_upg_option, 'N') = 'O')
172365 )
172366 THEN
172367 NULL;
172368 --
172369 --
172370
172371 l_ccid := AcctDerRule_15(
172372 p_application_id => p_application_id
172373 , p_ae_header_id => l_ae_header_id
172374 , p_source_24 => p_source_24
172375 , p_source_25 => p_source_25
172376 , p_source_26 => p_source_26
172377 , p_source_27 => p_source_27
172378 , p_source_28 => p_source_28
172379 , p_source_29 => p_source_29
172380 , p_source_31 => p_source_31
172381 , x_transaction_coa_id => l_adr_transaction_coa_id
172382 , x_accounting_coa_id => l_adr_accounting_coa_id
172383 , x_value_type_code => l_adr_value_type_code
172384 , p_side => 'NA'
172385 );
172386
172387 xla_ae_lines_pkg.set_ccid(
172388 p_code_combination_id => l_ccid
172389 , p_value_type_code => l_adr_value_type_code
172390 , p_transaction_coa_id => l_adr_transaction_coa_id
172391 , p_accounting_coa_id => l_adr_accounting_coa_id
172392 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
172393 , p_adr_type_code => 'S'
172394 , p_component_type => l_component_type
172395 , p_component_code => l_component_code
172396 , p_component_type_code => l_component_type_code
172397 , p_component_appl_id => l_component_appl_id
172398 , p_amb_context_code => l_amb_context_code
172399 , p_side => 'NA'
172400 );
172401
172402
172403 --
172404 --
172405 END IF;
172406 --
172407 -- Bug 4922099
172408 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
172409 (NVL(l_enc_upg_option, 'N') = 'O')
172410 ) AND
172411 (l_bflow_method_code = 'PRIOR_ENTRY')
172412 )
172413 THEN
172414 IF
172415 --
172416 1 = 2
172417 --
172418 THEN
172419 xla_accounting_err_pkg.build_message
172420 (p_appli_s_name => 'XLA'
172421 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
172422 ,p_token_1 => 'LINE_NUMBER'
172423 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
172424 ,p_token_2 => 'LINE_TYPE_NAME'
172425 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
172426 l_component_type
172427 ,l_component_code
172428 ,l_component_type_code
172429 ,l_component_appl_id
172430 ,l_amb_context_code
172431 ,l_entity_code
172432 ,l_event_class_code
172433 )
172434 ,p_token_3 => 'OWNER'
172435 ,p_value_3 => xla_lookups_pkg.get_meaning(
172436 p_lookup_type => 'XLA_OWNER_TYPE'
172437 ,p_lookup_code => l_component_type_code
172438 )
172439 ,p_token_4 => 'PRODUCT_NAME'
172440 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
172441 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
172442 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
172443 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
172444 ,p_ae_header_id => NULL
172445 );
172446
172447 IF (C_LEVEL_ERROR>= g_log_level) THEN
172448 trace
172449 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
172450 ,p_level => C_LEVEL_ERROR
172451 ,p_module => l_log_module);
172452 END IF;
172453 END IF;
172454 END IF;
172455 --
172456 --
172457 ------------------------------------------------------------------------------------------------
172458 -- 4219869 Business Flow
172459 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
172460 -- Prior Entry. Currently, the following code is always generated.
172461 ------------------------------------------------------------------------------------------------
172462 XLA_AE_LINES_PKG.ValidateCurrentLine;
172463
172464 ------------------------------------------------------------------------------------
172465 -- 4219869 Business Flow
172466 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
172467 ------------------------------------------------------------------------------------
172468 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
172469
172470 ----------------------------------------------------------------------------------
172471 -- 4219869 Business Flow
172472 -- Update journal entry status -- Need to generate this within IF <condition>
172473 ----------------------------------------------------------------------------------
172474 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
172475 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
172476 ,p_balance_type_code => l_balance_type_code
172477 );
172478
172479 -------------------------------------------------------------------------------------------
172480 -- 4262811 - Generate the Accrual Reversal lines
172481 -------------------------------------------------------------------------------------------
172482 BEGIN
172483 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
172484 (g_array_event(p_event_id).array_value_num('header_index'));
172485 IF l_acc_rev_flag IS NULL THEN
172486 l_acc_rev_flag := 'N';
172487 END IF;
172488 EXCEPTION
172489 WHEN OTHERS THEN
172490 l_acc_rev_flag := 'N';
172491 END;
172492 --
172493 IF (l_acc_rev_flag = 'Y') THEN
172494
172495 -- 4645092 ------------------------------------------------------------------------------
172496 -- To allow MPA report to determine if it should generate report process
172497 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
172498 ------------------------------------------------------------------------------------------
172499
172500 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
172501 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
172502 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
172503 -- call ADRs
172504 -- Bug 4922099
172505 --
172506 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
172507 (NVL(l_actual_upg_option, 'N') = 'O') OR
172508 (NVL(l_enc_upg_option, 'N') = 'O')
172509 )
172510 THEN
172511 NULL;
172512 --
172513 --
172514
172515 l_ccid := AcctDerRule_15(
172516 p_application_id => p_application_id
172517 , p_ae_header_id => l_ae_header_id
172518 , p_source_24 => p_source_24
172519 , p_source_25 => p_source_25
172520 , p_source_26 => p_source_26
172521 , p_source_27 => p_source_27
172522 , p_source_28 => p_source_28
172523 , p_source_29 => p_source_29
172524 , p_source_31 => p_source_31
172525 , x_transaction_coa_id => l_adr_transaction_coa_id
172526 , x_accounting_coa_id => l_adr_accounting_coa_id
172527 , x_value_type_code => l_adr_value_type_code
172528 , p_side => 'NA'
172529 );
172530
172531 xla_ae_lines_pkg.set_ccid(
172532 p_code_combination_id => l_ccid
172533 , p_value_type_code => l_adr_value_type_code
172534 , p_transaction_coa_id => l_adr_transaction_coa_id
172535 , p_accounting_coa_id => l_adr_accounting_coa_id
172536 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
172537 , p_adr_type_code => 'S'
172538 , p_component_type => l_component_type
172539 , p_component_code => l_component_code
172540 , p_component_type_code => l_component_type_code
172541 , p_component_appl_id => l_component_appl_id
172542 , p_amb_context_code => l_amb_context_code
172543 , p_side => 'NA'
172544 );
172545
172546
172547 --
172548 --
172549 END IF;
172550
172551 --
172552 -- Update the line information that should be overwritten
172553 --
172554 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
172555 p_header_num => 1);
172556 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
172557
172558 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
172559
172560 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
172561 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
172562 END IF;
172563
172564 --
172565 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
172566 --
172567 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
172568 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
172569 ELSE
172570 ---------------------------------------------------------------------------------------------------
172571 -- 4262811a Switch Sign
172572 ---------------------------------------------------------------------------------------------------
172573 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
172574 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
172575 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
172576 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
172577 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
172578 -- 5132302
172579 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
172580 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
172581
172582 END IF;
172583
172584 -- 4955764
172585 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
172586 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
172587
172588
172589 XLA_AE_LINES_PKG.ValidateCurrentLine;
172590 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
172591
172592 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
172593 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
172594 ,p_balance_type_code => l_balance_type_code);
172595
172596 END IF;
172597
172598 -----------------------------------------------------------------------------------------
172599 -- 4262811 Multiperiod Accounting
172600 -----------------------------------------------------------------------------------------
172601 -- No MPA option is assigned.
172602
172603
172604 END IF;
172605 END IF;
172606 --
172607
172608 --
172609 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
172610 trace
172611 (p_msg => 'END of AcctLineType_318'
172612 ,p_level => C_LEVEL_PROCEDURE
172613 ,p_module => l_log_module);
172614 END IF;
172615 --
172616 EXCEPTION
172617 WHEN xla_exceptions_pkg.application_exception THEN
172618 RAISE;
172619 WHEN OTHERS THEN
172620 xla_exceptions_pkg.raise_message
172621 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_318');
172622 END AcctLineType_318;
172623 --
172624
172625 ---------------------------------------
172626 --
172627 -- PRIVATE FUNCTION
172628 -- AcctLineType_319
172629 --
172630 ---------------------------------------
172631 PROCEDURE AcctLineType_319 (
172632 p_application_id IN NUMBER
172633 ,p_event_id IN NUMBER
172634 ,p_calculate_acctd_flag IN VARCHAR2
172635 ,p_calculate_g_l_flag IN VARCHAR2
172636 ,p_actual_flag IN OUT VARCHAR2
172637 ,p_balance_type_code OUT VARCHAR2
172638 ,p_gain_or_loss_ref OUT VARCHAR2
172639
172640 --TRANSACTION_ID
172641 , p_source_1 IN NUMBER
172642 --Transaction Unit of Measure Code
172643 , p_source_4 IN VARCHAR2
172644 --Primary Quantity of the Transaction
172645 , p_source_6 IN NUMBER
172646 --WIP Transaction Type
172647 , p_source_7 IN NUMBER
172648 , p_source_7_meaning IN VARCHAR2
172649 --Cost Management Default Account
172650 , p_source_11 IN NUMBER
172651 --DISTRIBUTION_IDENTIFIER
172652 , p_source_84 IN NUMBER
172653 --Distribution Type
172654 , p_source_85 IN VARCHAR2
172655 , p_source_85_meaning IN VARCHAR2
172656 --Entered Currency Code
172657 , p_source_88 IN VARCHAR2
172658 --Entered Amount
172659 , p_source_91 IN NUMBER
172660 --Currency Conversion Date
172661 , p_source_92 IN DATE
172662 --Currency Conversion Rate
172663 , p_source_93 IN NUMBER
172664 --Accounted Amount
172665 , p_source_95 IN NUMBER
172666 --Accounting Line Type
172667 , p_source_97 IN NUMBER
172668 )
172669 IS
172670
172671 l_component_type VARCHAR2(80);
172672 l_component_code VARCHAR2(30);
172673 l_component_type_code VARCHAR2(1);
172674 l_component_appl_id INTEGER;
172675 l_amb_context_code VARCHAR2(30);
172676 l_entity_code VARCHAR2(30);
172677 l_event_class_code VARCHAR2(30);
172678 l_ae_header_id NUMBER;
172679 l_event_type_code VARCHAR2(30);
172680 l_line_definition_code VARCHAR2(30);
172681 l_line_definition_owner_code VARCHAR2(1);
172682 --
172683 -- adr variables
172684 l_segment VARCHAR2(30);
172685 l_ccid NUMBER;
172686 l_adr_transaction_coa_id NUMBER;
172687 l_adr_accounting_coa_id NUMBER;
172688 l_adr_flexfield_segment_code VARCHAR2(30);
172689 l_adr_flex_value_set_id NUMBER;
172690 l_adr_value_type_code VARCHAR2(30);
172691 l_adr_value_combination_id NUMBER;
172692 l_adr_value_segment_code VARCHAR2(30);
172693
172694 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
172695 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
172696 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
172697 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
172698
172699 -- 4262811 Variables ------------------------------------------------------------------------------------------
172700 l_entered_amt_idx NUMBER;
172701 l_accted_amt_idx NUMBER;
172702 l_acc_rev_flag VARCHAR2(1);
172703 l_accrual_line_num NUMBER;
172704 l_tmp_amt NUMBER;
172705 l_acc_rev_natural_side_code VARCHAR2(1);
172706
172707 l_num_entries NUMBER;
172708 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
172709 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
172710 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
172711 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
172712 l_recog_line_1 NUMBER;
172713 l_recog_line_2 NUMBER;
172714
172715 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
172716 l_bflow_applied_to_amt NUMBER; -- 5132302
172717 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
172718
172719 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
172720
172721 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
172722 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
172723
172724 ---------------------------------------------------------------------------------------------------------------
172725
172726
172727 --
172728 -- bulk performance
172729 --
172730 l_balance_type_code VARCHAR2(1);
172731 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
172732 l_log_module VARCHAR2(240);
172733
172734 --
172735 -- Upgrade strategy
172736 --
172737 l_actual_upg_option VARCHAR2(1);
172738 l_enc_upg_option VARCHAR2(1);
172739
172740 --
172741 BEGIN
172742 --
172743 IF g_log_enabled THEN
172744 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_319';
172745 END IF;
172746 --
172747 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
172748
172749 trace
172750 (p_msg => 'BEGIN of AcctLineType_319'
172751 ,p_level => C_LEVEL_PROCEDURE
172752 ,p_module => l_log_module);
172753
172754 END IF;
172755 --
172756 l_component_type := 'AMB_JLT';
172757 l_component_code := 'OFFSET';
172758 l_component_type_code := 'S';
172759 l_component_appl_id := 707;
172760 l_amb_context_code := 'DEFAULT';
172761 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
172762 l_event_class_code := 'OSP';
172763 l_event_type_code := 'OSP';
172764 l_line_definition_owner_code := 'S';
172765 l_line_definition_code := 'PI_OSP';
172766 --
172767 l_balance_type_code := 'A';
172768 l_segment := NULL;
172769 l_ccid := NULL;
172770 l_adr_transaction_coa_id := NULL;
172771 l_adr_accounting_coa_id := NULL;
172772 l_adr_flexfield_segment_code := NULL;
172773 l_adr_flex_value_set_id := NULL;
172774 l_adr_value_type_code := NULL;
172775 l_adr_value_combination_id := NULL;
172776 l_adr_value_segment_code := NULL;
172777
172778 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
172779 l_bflow_class_code := ''; -- 4219869 Business Flow
172780 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
172781 l_budgetary_control_flag := 'N';
172782
172783 l_bflow_applied_to_amt_idx := NULL; -- 5132302
172784 l_bflow_applied_to_amt := NULL; -- 5132302
172785 l_entered_amt_idx := NULL; -- 4262811
172786 l_accted_amt_idx := NULL; -- 4262811
172787 l_acc_rev_flag := NULL; -- 4262811
172788 l_accrual_line_num := NULL; -- 4262811
172789 l_tmp_amt := NULL; -- 4262811
172790 --
172791
172792 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
172793 l_balance_type_code <> 'B' THEN
172794 IF NVL(p_source_97,9E125) = 2
172795 THEN
172796
172797 --
172798 XLA_AE_LINES_PKG.SetNewLine;
172799
172800 p_balance_type_code := l_balance_type_code;
172801 -- set the flag so later we will know whether the gain loss line needs to be created
172802
172803 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
172804 p_actual_flag :='A';
172805 END IF;
172806
172807 --
172808 -- bulk performance
172809 --
172810 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
172811 p_header_num => 0); -- 4262811
172812 --
172813 -- set accounting line options
172814 --
172815 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
172816 p_natural_side_code => 'D'
172817 , p_gain_or_loss_flag => 'N'
172818 , p_gl_transfer_mode_code => 'S'
172819 , p_acct_entry_type_code => 'A'
172820 , p_switch_side_flag => 'Y'
172821 , p_merge_duplicate_code => 'N'
172822 );
172823 --
172824 l_acc_rev_natural_side_code := 'C'; -- 4262811
172825 --
172826 --
172827 -- set accounting line type info
172828 --
172829 xla_ae_lines_pkg.SetAcctLineType
172830 (p_component_type => l_component_type
172831 ,p_event_type_code => l_event_type_code
172832 ,p_line_definition_owner_code => l_line_definition_owner_code
172833 ,p_line_definition_code => l_line_definition_code
172834 ,p_accounting_line_code => l_component_code
172835 ,p_accounting_line_type_code => l_component_type_code
172836 ,p_accounting_line_appl_id => l_component_appl_id
172837 ,p_amb_context_code => l_amb_context_code
172838 ,p_entity_code => l_entity_code
172839 ,p_event_class_code => l_event_class_code);
172840 --
172841 -- set accounting class
172842 --
172843 xla_ae_lines_pkg.SetAcctClass(
172844 p_accounting_class_code => 'OFFSET'
172845 , p_ae_header_id => l_ae_header_id
172846 );
172847
172848 --
172849 -- set rounding class
172850 --
172851 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
172852 'OFFSET';
172853
172854 --
172855 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
172856 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
172857 --
172858 -- bulk performance
172859 --
172860 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
172861
172862 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
172863 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
172864
172865 -- 4955764
172866 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
172867 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
172868
172869 -- 4458381 Public Sector Enh
172870
172871 --
172872 -- set accounting attributes for the line type
172873 --
172874 l_entered_amt_idx := 3;
172875 l_accted_amt_idx := 8;
172876 l_bflow_applied_to_amt_idx := NULL; -- 5132302
172877 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
172878 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
172879 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
172880 l_rec_acct_attrs.array_char_value(2) := p_source_85;
172881 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
172882 l_rec_acct_attrs.array_num_value(3) := p_source_91;
172883 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
172884 l_rec_acct_attrs.array_char_value(4) := p_source_88;
172885 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
172886 l_rec_acct_attrs.array_date_value(5) := p_source_92;
172887 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
172888 l_rec_acct_attrs.array_num_value(6) := p_source_93;
172889 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
172890 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
172891 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
172892 l_rec_acct_attrs.array_num_value(8) := p_source_95;
172893
172894 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
172895 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
172896
172897 ---------------------------------------------------------------------------------------------------------------
172898 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
172899 ---------------------------------------------------------------------------------------------------------------
172900 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
172901
172902 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
172903 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
172904
172905 IF xla_accounting_cache_pkg.GetValueChar
172906 (p_source_code => 'LEDGER_CATEGORY_CODE'
172907 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
172908 AND l_bflow_method_code = 'PRIOR_ENTRY'
172909 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
172910 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
172911 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
172912 )
172913 THEN
172914 xla_ae_lines_pkg.BflowUpgEntry
172915 (p_business_method_code => l_bflow_method_code
172916 ,p_business_class_code => l_bflow_class_code
172917 ,p_balance_type => l_balance_type_code);
172918 ELSE
172919 NULL;
172920 -- No business flow processing for business flow method of NONE.
172921 END IF;
172922
172923 --
172924 -- call analytical criteria
172925 --
172926
172927 --
172928 -- call description
172929 --
172930
172931 xla_ae_lines_pkg.SetLineDescription(
172932 p_ae_header_id => l_ae_header_id
172933 ,p_description => Description_2 (
172934 p_application_id => p_application_id
172935 , p_ae_header_id => l_ae_header_id
172936 , p_source_1 => p_source_1
172937 , p_source_4 => p_source_4
172938 , p_source_6 => p_source_6
172939 , p_source_7 => p_source_7
172940 , p_source_7_meaning => p_source_7_meaning
172941 )
172942 );
172943
172944
172945 --
172946 -- call ADRs
172947 -- Bug 4922099
172948 --
172949 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
172950 (NVL(l_actual_upg_option, 'N') = 'O') OR
172951 (NVL(l_enc_upg_option, 'N') = 'O')
172952 )
172953 THEN
172954 NULL;
172955 --
172956 --
172957
172958 l_ccid := AcctDerRule_6(
172959 p_application_id => p_application_id
172960 , p_ae_header_id => l_ae_header_id
172961 , p_source_11 => p_source_11
172962 , x_transaction_coa_id => l_adr_transaction_coa_id
172963 , x_accounting_coa_id => l_adr_accounting_coa_id
172964 , x_value_type_code => l_adr_value_type_code
172965 , p_side => 'NA'
172966 );
172967
172968 xla_ae_lines_pkg.set_ccid(
172969 p_code_combination_id => l_ccid
172970 , p_value_type_code => l_adr_value_type_code
172971 , p_transaction_coa_id => l_adr_transaction_coa_id
172972 , p_accounting_coa_id => l_adr_accounting_coa_id
172973 , p_adr_code => 'CST_DEFAULT'
172974 , p_adr_type_code => 'S'
172975 , p_component_type => l_component_type
172976 , p_component_code => l_component_code
172977 , p_component_type_code => l_component_type_code
172978 , p_component_appl_id => l_component_appl_id
172979 , p_amb_context_code => l_amb_context_code
172980 , p_side => 'NA'
172981 );
172982
172983
172984 --
172985 --
172986 END IF;
172987 --
172988 -- Bug 4922099
172989 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
172990 (NVL(l_enc_upg_option, 'N') = 'O')
172991 ) AND
172992 (l_bflow_method_code = 'PRIOR_ENTRY')
172993 )
172994 THEN
172995 IF
172996 --
172997 1 = 2
172998 --
172999 THEN
173000 xla_accounting_err_pkg.build_message
173001 (p_appli_s_name => 'XLA'
173002 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
173003 ,p_token_1 => 'LINE_NUMBER'
173004 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
173005 ,p_token_2 => 'LINE_TYPE_NAME'
173006 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
173007 l_component_type
173008 ,l_component_code
173009 ,l_component_type_code
173010 ,l_component_appl_id
173011 ,l_amb_context_code
173012 ,l_entity_code
173013 ,l_event_class_code
173014 )
173015 ,p_token_3 => 'OWNER'
173016 ,p_value_3 => xla_lookups_pkg.get_meaning(
173017 p_lookup_type => 'XLA_OWNER_TYPE'
173018 ,p_lookup_code => l_component_type_code
173019 )
173020 ,p_token_4 => 'PRODUCT_NAME'
173021 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
173022 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
173023 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
173024 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
173025 ,p_ae_header_id => NULL
173026 );
173027
173028 IF (C_LEVEL_ERROR>= g_log_level) THEN
173029 trace
173030 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
173031 ,p_level => C_LEVEL_ERROR
173032 ,p_module => l_log_module);
173033 END IF;
173034 END IF;
173035 END IF;
173036 --
173037 --
173038 ------------------------------------------------------------------------------------------------
173039 -- 4219869 Business Flow
173040 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
173041 -- Prior Entry. Currently, the following code is always generated.
173042 ------------------------------------------------------------------------------------------------
173043 XLA_AE_LINES_PKG.ValidateCurrentLine;
173044
173045 ------------------------------------------------------------------------------------
173046 -- 4219869 Business Flow
173047 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
173048 ------------------------------------------------------------------------------------
173049 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
173050
173051 ----------------------------------------------------------------------------------
173052 -- 4219869 Business Flow
173053 -- Update journal entry status -- Need to generate this within IF <condition>
173054 ----------------------------------------------------------------------------------
173055 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
173056 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
173057 ,p_balance_type_code => l_balance_type_code
173058 );
173059
173060 -------------------------------------------------------------------------------------------
173061 -- 4262811 - Generate the Accrual Reversal lines
173062 -------------------------------------------------------------------------------------------
173063 BEGIN
173064 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
173065 (g_array_event(p_event_id).array_value_num('header_index'));
173066 IF l_acc_rev_flag IS NULL THEN
173067 l_acc_rev_flag := 'N';
173068 END IF;
173069 EXCEPTION
173070 WHEN OTHERS THEN
173071 l_acc_rev_flag := 'N';
173072 END;
173073 --
173074 IF (l_acc_rev_flag = 'Y') THEN
173075
173076 -- 4645092 ------------------------------------------------------------------------------
173077 -- To allow MPA report to determine if it should generate report process
173078 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
173079 ------------------------------------------------------------------------------------------
173080
173081 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
173082 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
173083 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
173084 -- call ADRs
173085 -- Bug 4922099
173086 --
173087 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
173088 (NVL(l_actual_upg_option, 'N') = 'O') OR
173089 (NVL(l_enc_upg_option, 'N') = 'O')
173090 )
173091 THEN
173092 NULL;
173093 --
173094 --
173095
173096 l_ccid := AcctDerRule_6(
173097 p_application_id => p_application_id
173098 , p_ae_header_id => l_ae_header_id
173099 , p_source_11 => p_source_11
173100 , x_transaction_coa_id => l_adr_transaction_coa_id
173101 , x_accounting_coa_id => l_adr_accounting_coa_id
173102 , x_value_type_code => l_adr_value_type_code
173103 , p_side => 'NA'
173104 );
173105
173106 xla_ae_lines_pkg.set_ccid(
173107 p_code_combination_id => l_ccid
173108 , p_value_type_code => l_adr_value_type_code
173109 , p_transaction_coa_id => l_adr_transaction_coa_id
173110 , p_accounting_coa_id => l_adr_accounting_coa_id
173111 , p_adr_code => 'CST_DEFAULT'
173112 , p_adr_type_code => 'S'
173113 , p_component_type => l_component_type
173114 , p_component_code => l_component_code
173115 , p_component_type_code => l_component_type_code
173116 , p_component_appl_id => l_component_appl_id
173117 , p_amb_context_code => l_amb_context_code
173118 , p_side => 'NA'
173119 );
173120
173121
173122 --
173123 --
173124 END IF;
173125
173126 --
173127 -- Update the line information that should be overwritten
173128 --
173129 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
173130 p_header_num => 1);
173131 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
173132
173133 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
173134
173135 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
173136 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
173137 END IF;
173138
173139 --
173140 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
173141 --
173142 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
173143 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
173144 ELSE
173145 ---------------------------------------------------------------------------------------------------
173146 -- 4262811a Switch Sign
173147 ---------------------------------------------------------------------------------------------------
173148 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
173149 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
173150 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173151 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
173152 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173153 -- 5132302
173154 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
173155 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173156
173157 END IF;
173158
173159 -- 4955764
173160 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
173161 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
173162
173163
173164 XLA_AE_LINES_PKG.ValidateCurrentLine;
173165 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
173166
173167 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
173168 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
173169 ,p_balance_type_code => l_balance_type_code);
173170
173171 END IF;
173172
173173 -----------------------------------------------------------------------------------------
173174 -- 4262811 Multiperiod Accounting
173175 -----------------------------------------------------------------------------------------
173176 -- No MPA option is assigned.
173177
173178
173179 END IF;
173180 END IF;
173181 --
173182
173183 --
173184 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
173185 trace
173186 (p_msg => 'END of AcctLineType_319'
173187 ,p_level => C_LEVEL_PROCEDURE
173188 ,p_module => l_log_module);
173189 END IF;
173190 --
173191 EXCEPTION
173192 WHEN xla_exceptions_pkg.application_exception THEN
173193 RAISE;
173194 WHEN OTHERS THEN
173195 xla_exceptions_pkg.raise_message
173196 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_319');
173197 END AcctLineType_319;
173198 --
173199
173200 ---------------------------------------
173201 --
173202 -- PRIVATE FUNCTION
173203 -- AcctLineType_320
173204 --
173205 ---------------------------------------
173206 PROCEDURE AcctLineType_320 (
173207 p_application_id IN NUMBER
173208 ,p_event_id IN NUMBER
173209 ,p_calculate_acctd_flag IN VARCHAR2
173210 ,p_calculate_g_l_flag IN VARCHAR2
173211 ,p_actual_flag IN OUT VARCHAR2
173212 ,p_balance_type_code OUT VARCHAR2
173213 ,p_gain_or_loss_ref OUT VARCHAR2
173214
173215 --TRANSACTION_ID
173216 , p_source_1 IN NUMBER
173217 --Item Concatenated Segments
173218 , p_source_2 IN VARCHAR2
173219 --Transaction Quantity
173220 , p_source_3 IN NUMBER
173221 --Transaction Unit of Measure Code
173222 , p_source_4 IN VARCHAR2
173223 --Inventory Transaction Type Description
173224 , p_source_5 IN VARCHAR2
173225 --Transaction Distribution Account
173226 , p_source_20 IN NUMBER
173227 --DISTRIBUTION_IDENTIFIER
173228 , p_source_84 IN NUMBER
173229 --Distribution Type
173230 , p_source_85 IN VARCHAR2
173231 , p_source_85_meaning IN VARCHAR2
173232 --Entered Currency Code
173233 , p_source_88 IN VARCHAR2
173234 --Entered Amount
173235 , p_source_91 IN NUMBER
173236 --Currency Conversion Date
173237 , p_source_92 IN DATE
173238 --Currency Conversion Rate
173239 , p_source_93 IN NUMBER
173240 --Currency Conversion Type
173241 , p_source_94 IN VARCHAR2
173242 --Accounted Amount
173243 , p_source_95 IN NUMBER
173244 --Accounting Line Type
173245 , p_source_97 IN NUMBER
173246 )
173247 IS
173248
173249 l_component_type VARCHAR2(80);
173250 l_component_code VARCHAR2(30);
173251 l_component_type_code VARCHAR2(1);
173252 l_component_appl_id INTEGER;
173253 l_amb_context_code VARCHAR2(30);
173254 l_entity_code VARCHAR2(30);
173255 l_event_class_code VARCHAR2(30);
173256 l_ae_header_id NUMBER;
173257 l_event_type_code VARCHAR2(30);
173258 l_line_definition_code VARCHAR2(30);
173259 l_line_definition_owner_code VARCHAR2(1);
173260 --
173261 -- adr variables
173262 l_segment VARCHAR2(30);
173263 l_ccid NUMBER;
173264 l_adr_transaction_coa_id NUMBER;
173265 l_adr_accounting_coa_id NUMBER;
173266 l_adr_flexfield_segment_code VARCHAR2(30);
173267 l_adr_flex_value_set_id NUMBER;
173268 l_adr_value_type_code VARCHAR2(30);
173269 l_adr_value_combination_id NUMBER;
173270 l_adr_value_segment_code VARCHAR2(30);
173271
173272 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
173273 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
173274 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
173275 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
173276
173277 -- 4262811 Variables ------------------------------------------------------------------------------------------
173278 l_entered_amt_idx NUMBER;
173279 l_accted_amt_idx NUMBER;
173280 l_acc_rev_flag VARCHAR2(1);
173281 l_accrual_line_num NUMBER;
173282 l_tmp_amt NUMBER;
173283 l_acc_rev_natural_side_code VARCHAR2(1);
173284
173285 l_num_entries NUMBER;
173286 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
173287 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
173288 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
173289 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
173290 l_recog_line_1 NUMBER;
173291 l_recog_line_2 NUMBER;
173292
173293 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
173294 l_bflow_applied_to_amt NUMBER; -- 5132302
173295 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
173296
173297 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
173298
173299 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
173300 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
173301
173302 ---------------------------------------------------------------------------------------------------------------
173303
173304
173305 --
173306 -- bulk performance
173307 --
173308 l_balance_type_code VARCHAR2(1);
173309 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
173310 l_log_module VARCHAR2(240);
173311
173312 --
173313 -- Upgrade strategy
173314 --
173315 l_actual_upg_option VARCHAR2(1);
173316 l_enc_upg_option VARCHAR2(1);
173317
173318 --
173319 BEGIN
173320 --
173321 IF g_log_enabled THEN
173322 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_320';
173323 END IF;
173324 --
173325 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
173326
173327 trace
173328 (p_msg => 'BEGIN of AcctLineType_320'
173329 ,p_level => C_LEVEL_PROCEDURE
173330 ,p_module => l_log_module);
173331
173332 END IF;
173333 --
173334 l_component_type := 'AMB_JLT';
173335 l_component_code := 'OFFSET';
173336 l_component_type_code := 'S';
173337 l_component_appl_id := 707;
173338 l_amb_context_code := 'DEFAULT';
173339 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
173340 l_event_class_code := 'INT_ORDER_TO_EXP';
173341 l_event_type_code := 'EXP_REQ_RCPT_NO_TP';
173342 l_line_definition_owner_code := 'S';
173343 l_line_definition_code := 'PI_EXP_REQ_RCPT_NO_TP';
173344 --
173345 l_balance_type_code := 'A';
173346 l_segment := NULL;
173347 l_ccid := NULL;
173348 l_adr_transaction_coa_id := NULL;
173349 l_adr_accounting_coa_id := NULL;
173350 l_adr_flexfield_segment_code := NULL;
173351 l_adr_flex_value_set_id := NULL;
173352 l_adr_value_type_code := NULL;
173353 l_adr_value_combination_id := NULL;
173354 l_adr_value_segment_code := NULL;
173355
173356 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
173357 l_bflow_class_code := ''; -- 4219869 Business Flow
173358 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
173359 l_budgetary_control_flag := 'N';
173360
173361 l_bflow_applied_to_amt_idx := NULL; -- 5132302
173362 l_bflow_applied_to_amt := NULL; -- 5132302
173363 l_entered_amt_idx := NULL; -- 4262811
173364 l_accted_amt_idx := NULL; -- 4262811
173365 l_acc_rev_flag := NULL; -- 4262811
173366 l_accrual_line_num := NULL; -- 4262811
173367 l_tmp_amt := NULL; -- 4262811
173368 --
173369
173370 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
173371 l_balance_type_code <> 'B' THEN
173372 IF NVL(p_source_97,9E125) = 2
173373 THEN
173374
173375 --
173376 XLA_AE_LINES_PKG.SetNewLine;
173377
173378 p_balance_type_code := l_balance_type_code;
173379 -- set the flag so later we will know whether the gain loss line needs to be created
173380
173381 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
173382 p_actual_flag :='A';
173383 END IF;
173384
173385 --
173386 -- bulk performance
173387 --
173388 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
173389 p_header_num => 0); -- 4262811
173390 --
173391 -- set accounting line options
173392 --
173393 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
173394 p_natural_side_code => 'D'
173395 , p_gain_or_loss_flag => 'N'
173396 , p_gl_transfer_mode_code => 'S'
173397 , p_acct_entry_type_code => 'A'
173398 , p_switch_side_flag => 'Y'
173399 , p_merge_duplicate_code => 'N'
173400 );
173401 --
173402 l_acc_rev_natural_side_code := 'C'; -- 4262811
173403 --
173404 --
173405 -- set accounting line type info
173406 --
173407 xla_ae_lines_pkg.SetAcctLineType
173408 (p_component_type => l_component_type
173409 ,p_event_type_code => l_event_type_code
173410 ,p_line_definition_owner_code => l_line_definition_owner_code
173411 ,p_line_definition_code => l_line_definition_code
173412 ,p_accounting_line_code => l_component_code
173413 ,p_accounting_line_type_code => l_component_type_code
173414 ,p_accounting_line_appl_id => l_component_appl_id
173415 ,p_amb_context_code => l_amb_context_code
173416 ,p_entity_code => l_entity_code
173417 ,p_event_class_code => l_event_class_code);
173418 --
173419 -- set accounting class
173420 --
173421 xla_ae_lines_pkg.SetAcctClass(
173422 p_accounting_class_code => 'OFFSET'
173423 , p_ae_header_id => l_ae_header_id
173424 );
173425
173426 --
173427 -- set rounding class
173428 --
173429 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
173430 'OFFSET';
173431
173432 --
173433 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
173434 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
173435 --
173436 -- bulk performance
173437 --
173438 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
173439
173440 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
173441 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
173442
173443 -- 4955764
173444 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
173445 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
173446
173447 -- 4458381 Public Sector Enh
173448
173449 --
173450 -- set accounting attributes for the line type
173451 --
173452 l_entered_amt_idx := 3;
173453 l_accted_amt_idx := 8;
173454 l_bflow_applied_to_amt_idx := NULL; -- 5132302
173455 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
173456 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
173457 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
173458 l_rec_acct_attrs.array_char_value(2) := p_source_85;
173459 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
173460 l_rec_acct_attrs.array_num_value(3) := p_source_91;
173461 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
173462 l_rec_acct_attrs.array_char_value(4) := p_source_88;
173463 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
173464 l_rec_acct_attrs.array_date_value(5) := p_source_92;
173465 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
173466 l_rec_acct_attrs.array_num_value(6) := p_source_93;
173467 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
173468 l_rec_acct_attrs.array_char_value(7) := p_source_94;
173469 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
173470 l_rec_acct_attrs.array_num_value(8) := p_source_95;
173471
173472 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
173473 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
173474
173475 ---------------------------------------------------------------------------------------------------------------
173476 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
173477 ---------------------------------------------------------------------------------------------------------------
173478 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
173479
173480 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
173481 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
173482
173483 IF xla_accounting_cache_pkg.GetValueChar
173484 (p_source_code => 'LEDGER_CATEGORY_CODE'
173485 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
173486 AND l_bflow_method_code = 'PRIOR_ENTRY'
173487 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
173488 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
173489 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
173490 )
173491 THEN
173492 xla_ae_lines_pkg.BflowUpgEntry
173493 (p_business_method_code => l_bflow_method_code
173494 ,p_business_class_code => l_bflow_class_code
173495 ,p_balance_type => l_balance_type_code);
173496 ELSE
173497 NULL;
173498 -- No business flow processing for business flow method of NONE.
173499 END IF;
173500
173501 --
173502 -- call analytical criteria
173503 --
173504
173505 --
173506 -- call description
173507 --
173508
173509 xla_ae_lines_pkg.SetLineDescription(
173510 p_ae_header_id => l_ae_header_id
173511 ,p_description => Description_1 (
173512 p_application_id => p_application_id
173513 , p_ae_header_id => l_ae_header_id
173514 , p_source_1 => p_source_1
173515 , p_source_2 => p_source_2
173516 , p_source_3 => p_source_3
173517 , p_source_4 => p_source_4
173518 , p_source_5 => p_source_5
173519 )
173520 );
173521
173522
173523 --
173524 -- call ADRs
173525 -- Bug 4922099
173526 --
173527 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
173528 (NVL(l_actual_upg_option, 'N') = 'O') OR
173529 (NVL(l_enc_upg_option, 'N') = 'O')
173530 )
173531 THEN
173532 NULL;
173533 --
173534 --
173535
173536 l_ccid := AcctDerRule_16(
173537 p_application_id => p_application_id
173538 , p_ae_header_id => l_ae_header_id
173539 , p_source_20 => p_source_20
173540 , x_transaction_coa_id => l_adr_transaction_coa_id
173541 , x_accounting_coa_id => l_adr_accounting_coa_id
173542 , x_value_type_code => l_adr_value_type_code
173543 , p_side => 'NA'
173544 );
173545
173546 xla_ae_lines_pkg.set_ccid(
173547 p_code_combination_id => l_ccid
173548 , p_value_type_code => l_adr_value_type_code
173549 , p_transaction_coa_id => l_adr_transaction_coa_id
173550 , p_accounting_coa_id => l_adr_accounting_coa_id
173551 , p_adr_code => 'PI_DISTRIBUTION'
173552 , p_adr_type_code => 'S'
173553 , p_component_type => l_component_type
173554 , p_component_code => l_component_code
173555 , p_component_type_code => l_component_type_code
173556 , p_component_appl_id => l_component_appl_id
173557 , p_amb_context_code => l_amb_context_code
173558 , p_side => 'NA'
173559 );
173560
173561
173562 --
173563 --
173564 END IF;
173565 --
173566 -- Bug 4922099
173567 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
173568 (NVL(l_enc_upg_option, 'N') = 'O')
173569 ) AND
173570 (l_bflow_method_code = 'PRIOR_ENTRY')
173571 )
173572 THEN
173573 IF
173574 --
173575 1 = 2
173576 --
173577 THEN
173578 xla_accounting_err_pkg.build_message
173579 (p_appli_s_name => 'XLA'
173580 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
173581 ,p_token_1 => 'LINE_NUMBER'
173582 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
173583 ,p_token_2 => 'LINE_TYPE_NAME'
173584 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
173585 l_component_type
173586 ,l_component_code
173587 ,l_component_type_code
173588 ,l_component_appl_id
173589 ,l_amb_context_code
173590 ,l_entity_code
173591 ,l_event_class_code
173592 )
173593 ,p_token_3 => 'OWNER'
173594 ,p_value_3 => xla_lookups_pkg.get_meaning(
173595 p_lookup_type => 'XLA_OWNER_TYPE'
173596 ,p_lookup_code => l_component_type_code
173597 )
173598 ,p_token_4 => 'PRODUCT_NAME'
173599 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
173600 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
173601 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
173602 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
173603 ,p_ae_header_id => NULL
173604 );
173605
173606 IF (C_LEVEL_ERROR>= g_log_level) THEN
173607 trace
173608 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
173609 ,p_level => C_LEVEL_ERROR
173610 ,p_module => l_log_module);
173611 END IF;
173612 END IF;
173613 END IF;
173614 --
173615 --
173616 ------------------------------------------------------------------------------------------------
173617 -- 4219869 Business Flow
173618 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
173619 -- Prior Entry. Currently, the following code is always generated.
173620 ------------------------------------------------------------------------------------------------
173621 XLA_AE_LINES_PKG.ValidateCurrentLine;
173622
173623 ------------------------------------------------------------------------------------
173624 -- 4219869 Business Flow
173625 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
173626 ------------------------------------------------------------------------------------
173627 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
173628
173629 ----------------------------------------------------------------------------------
173630 -- 4219869 Business Flow
173631 -- Update journal entry status -- Need to generate this within IF <condition>
173632 ----------------------------------------------------------------------------------
173633 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
173634 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
173635 ,p_balance_type_code => l_balance_type_code
173636 );
173637
173638 -------------------------------------------------------------------------------------------
173639 -- 4262811 - Generate the Accrual Reversal lines
173640 -------------------------------------------------------------------------------------------
173641 BEGIN
173642 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
173643 (g_array_event(p_event_id).array_value_num('header_index'));
173644 IF l_acc_rev_flag IS NULL THEN
173645 l_acc_rev_flag := 'N';
173646 END IF;
173647 EXCEPTION
173648 WHEN OTHERS THEN
173649 l_acc_rev_flag := 'N';
173650 END;
173651 --
173652 IF (l_acc_rev_flag = 'Y') THEN
173653
173654 -- 4645092 ------------------------------------------------------------------------------
173655 -- To allow MPA report to determine if it should generate report process
173656 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
173657 ------------------------------------------------------------------------------------------
173658
173659 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
173660 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
173661 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
173662 -- call ADRs
173663 -- Bug 4922099
173664 --
173665 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
173666 (NVL(l_actual_upg_option, 'N') = 'O') OR
173667 (NVL(l_enc_upg_option, 'N') = 'O')
173668 )
173669 THEN
173670 NULL;
173671 --
173672 --
173673
173674 l_ccid := AcctDerRule_16(
173675 p_application_id => p_application_id
173676 , p_ae_header_id => l_ae_header_id
173677 , p_source_20 => p_source_20
173678 , x_transaction_coa_id => l_adr_transaction_coa_id
173679 , x_accounting_coa_id => l_adr_accounting_coa_id
173680 , x_value_type_code => l_adr_value_type_code
173681 , p_side => 'NA'
173682 );
173683
173684 xla_ae_lines_pkg.set_ccid(
173685 p_code_combination_id => l_ccid
173686 , p_value_type_code => l_adr_value_type_code
173687 , p_transaction_coa_id => l_adr_transaction_coa_id
173688 , p_accounting_coa_id => l_adr_accounting_coa_id
173689 , p_adr_code => 'PI_DISTRIBUTION'
173690 , p_adr_type_code => 'S'
173691 , p_component_type => l_component_type
173692 , p_component_code => l_component_code
173693 , p_component_type_code => l_component_type_code
173694 , p_component_appl_id => l_component_appl_id
173695 , p_amb_context_code => l_amb_context_code
173696 , p_side => 'NA'
173697 );
173698
173699
173700 --
173701 --
173702 END IF;
173703
173704 --
173705 -- Update the line information that should be overwritten
173706 --
173707 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
173708 p_header_num => 1);
173709 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
173710
173711 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
173712
173713 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
173714 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
173715 END IF;
173716
173717 --
173718 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
173719 --
173720 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
173721 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
173722 ELSE
173723 ---------------------------------------------------------------------------------------------------
173724 -- 4262811a Switch Sign
173725 ---------------------------------------------------------------------------------------------------
173726 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
173727 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
173728 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173729 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
173730 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173731 -- 5132302
173732 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
173733 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
173734
173735 END IF;
173736
173737 -- 4955764
173738 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
173739 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
173740
173741
173742 XLA_AE_LINES_PKG.ValidateCurrentLine;
173743 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
173744
173745 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
173746 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
173747 ,p_balance_type_code => l_balance_type_code);
173748
173749 END IF;
173750
173751 -----------------------------------------------------------------------------------------
173752 -- 4262811 Multiperiod Accounting
173753 -----------------------------------------------------------------------------------------
173754 -- No MPA option is assigned.
173755
173756
173757 END IF;
173758 END IF;
173759 --
173760
173761 --
173762 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
173763 trace
173764 (p_msg => 'END of AcctLineType_320'
173765 ,p_level => C_LEVEL_PROCEDURE
173766 ,p_module => l_log_module);
173767 END IF;
173768 --
173769 EXCEPTION
173770 WHEN xla_exceptions_pkg.application_exception THEN
173771 RAISE;
173772 WHEN OTHERS THEN
173773 xla_exceptions_pkg.raise_message
173774 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_320');
173775 END AcctLineType_320;
173776 --
173777
173778 ---------------------------------------
173779 --
173780 -- PRIVATE FUNCTION
173781 -- AcctLineType_321
173782 --
173783 ---------------------------------------
173784 PROCEDURE AcctLineType_321 (
173785 p_application_id IN NUMBER
173786 ,p_event_id IN NUMBER
173787 ,p_calculate_acctd_flag IN VARCHAR2
173788 ,p_calculate_g_l_flag IN VARCHAR2
173789 ,p_actual_flag IN OUT VARCHAR2
173790 ,p_balance_type_code OUT VARCHAR2
173791 ,p_gain_or_loss_ref OUT VARCHAR2
173792
173793 --TRANSACTION_ID
173794 , p_source_1 IN NUMBER
173795 --Item Concatenated Segments
173796 , p_source_2 IN VARCHAR2
173797 --Transaction Quantity
173798 , p_source_3 IN NUMBER
173799 --Transaction Unit of Measure Code
173800 , p_source_4 IN VARCHAR2
173801 --Inventory Transaction Type Description
173802 , p_source_5 IN VARCHAR2
173803 --Cost Management Default Account
173804 , p_source_11 IN NUMBER
173805 --DISTRIBUTION_IDENTIFIER
173806 , p_source_84 IN NUMBER
173807 --Distribution Type
173808 , p_source_85 IN VARCHAR2
173809 , p_source_85_meaning IN VARCHAR2
173810 --Entered Currency Code
173811 , p_source_88 IN VARCHAR2
173812 --Entered Amount
173813 , p_source_91 IN NUMBER
173814 --Currency Conversion Date
173815 , p_source_92 IN DATE
173816 --Currency Conversion Rate
173817 , p_source_93 IN NUMBER
173818 --Currency Conversion Type
173819 , p_source_94 IN VARCHAR2
173820 --Accounted Amount
173821 , p_source_95 IN NUMBER
173822 --Accounting Line Type
173823 , p_source_97 IN NUMBER
173824 )
173825 IS
173826
173827 l_component_type VARCHAR2(80);
173828 l_component_code VARCHAR2(30);
173829 l_component_type_code VARCHAR2(1);
173830 l_component_appl_id INTEGER;
173831 l_amb_context_code VARCHAR2(30);
173832 l_entity_code VARCHAR2(30);
173833 l_event_class_code VARCHAR2(30);
173834 l_ae_header_id NUMBER;
173835 l_event_type_code VARCHAR2(30);
173836 l_line_definition_code VARCHAR2(30);
173837 l_line_definition_owner_code VARCHAR2(1);
173838 --
173839 -- adr variables
173840 l_segment VARCHAR2(30);
173841 l_ccid NUMBER;
173842 l_adr_transaction_coa_id NUMBER;
173843 l_adr_accounting_coa_id NUMBER;
173844 l_adr_flexfield_segment_code VARCHAR2(30);
173845 l_adr_flex_value_set_id NUMBER;
173846 l_adr_value_type_code VARCHAR2(30);
173847 l_adr_value_combination_id NUMBER;
173848 l_adr_value_segment_code VARCHAR2(30);
173849
173850 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
173851 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
173852 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
173853 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
173854
173855 -- 4262811 Variables ------------------------------------------------------------------------------------------
173856 l_entered_amt_idx NUMBER;
173857 l_accted_amt_idx NUMBER;
173858 l_acc_rev_flag VARCHAR2(1);
173859 l_accrual_line_num NUMBER;
173860 l_tmp_amt NUMBER;
173861 l_acc_rev_natural_side_code VARCHAR2(1);
173862
173863 l_num_entries NUMBER;
173864 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
173865 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
173866 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
173867 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
173868 l_recog_line_1 NUMBER;
173869 l_recog_line_2 NUMBER;
173870
173871 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
173872 l_bflow_applied_to_amt NUMBER; -- 5132302
173873 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
173874
173875 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
173876
173877 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
173878 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
173879
173880 ---------------------------------------------------------------------------------------------------------------
173881
173882
173883 --
173884 -- bulk performance
173885 --
173886 l_balance_type_code VARCHAR2(1);
173887 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
173888 l_log_module VARCHAR2(240);
173889
173890 --
173891 -- Upgrade strategy
173892 --
173893 l_actual_upg_option VARCHAR2(1);
173894 l_enc_upg_option VARCHAR2(1);
173895
173896 --
173897 BEGIN
173898 --
173899 IF g_log_enabled THEN
173900 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_321';
173901 END IF;
173902 --
173903 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
173904
173905 trace
173906 (p_msg => 'BEGIN of AcctLineType_321'
173907 ,p_level => C_LEVEL_PROCEDURE
173908 ,p_module => l_log_module);
173909
173910 END IF;
173911 --
173912 l_component_type := 'AMB_JLT';
173913 l_component_code := 'OFFSET';
173914 l_component_type_code := 'S';
173915 l_component_appl_id := 707;
173916 l_amb_context_code := 'DEFAULT';
173917 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
173918 l_event_class_code := 'WIP_MTL';
173919 l_event_type_code := 'WIP_NEG_COMP_RETURN';
173920 l_line_definition_owner_code := 'S';
173921 l_line_definition_code := 'PI_WIP_NEG_COMP_RETURN';
173922 --
173923 l_balance_type_code := 'A';
173924 l_segment := NULL;
173925 l_ccid := NULL;
173926 l_adr_transaction_coa_id := NULL;
173927 l_adr_accounting_coa_id := NULL;
173928 l_adr_flexfield_segment_code := NULL;
173929 l_adr_flex_value_set_id := NULL;
173930 l_adr_value_type_code := NULL;
173931 l_adr_value_combination_id := NULL;
173932 l_adr_value_segment_code := NULL;
173933
173934 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
173935 l_bflow_class_code := ''; -- 4219869 Business Flow
173936 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
173937 l_budgetary_control_flag := 'N';
173938
173939 l_bflow_applied_to_amt_idx := NULL; -- 5132302
173940 l_bflow_applied_to_amt := NULL; -- 5132302
173941 l_entered_amt_idx := NULL; -- 4262811
173942 l_accted_amt_idx := NULL; -- 4262811
173943 l_acc_rev_flag := NULL; -- 4262811
173944 l_accrual_line_num := NULL; -- 4262811
173945 l_tmp_amt := NULL; -- 4262811
173946 --
173947
173948 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
173949 l_balance_type_code <> 'B' THEN
173950 IF NVL(p_source_97,9E125) = 2
173951 THEN
173952
173953 --
173954 XLA_AE_LINES_PKG.SetNewLine;
173955
173956 p_balance_type_code := l_balance_type_code;
173957 -- set the flag so later we will know whether the gain loss line needs to be created
173958
173959 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
173960 p_actual_flag :='A';
173961 END IF;
173962
173963 --
173964 -- bulk performance
173965 --
173966 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
173967 p_header_num => 0); -- 4262811
173968 --
173969 -- set accounting line options
173970 --
173971 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
173972 p_natural_side_code => 'D'
173973 , p_gain_or_loss_flag => 'N'
173974 , p_gl_transfer_mode_code => 'S'
173975 , p_acct_entry_type_code => 'A'
173976 , p_switch_side_flag => 'Y'
173977 , p_merge_duplicate_code => 'N'
173978 );
173979 --
173980 l_acc_rev_natural_side_code := 'C'; -- 4262811
173981 --
173982 --
173983 -- set accounting line type info
173984 --
173985 xla_ae_lines_pkg.SetAcctLineType
173986 (p_component_type => l_component_type
173987 ,p_event_type_code => l_event_type_code
173988 ,p_line_definition_owner_code => l_line_definition_owner_code
173989 ,p_line_definition_code => l_line_definition_code
173990 ,p_accounting_line_code => l_component_code
173991 ,p_accounting_line_type_code => l_component_type_code
173992 ,p_accounting_line_appl_id => l_component_appl_id
173993 ,p_amb_context_code => l_amb_context_code
173994 ,p_entity_code => l_entity_code
173995 ,p_event_class_code => l_event_class_code);
173996 --
173997 -- set accounting class
173998 --
173999 xla_ae_lines_pkg.SetAcctClass(
174000 p_accounting_class_code => 'OFFSET'
174001 , p_ae_header_id => l_ae_header_id
174002 );
174003
174004 --
174005 -- set rounding class
174006 --
174007 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
174008 'OFFSET';
174009
174010 --
174011 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
174012 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
174013 --
174014 -- bulk performance
174015 --
174016 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
174017
174018 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
174019 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
174020
174021 -- 4955764
174022 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
174023 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
174024
174025 -- 4458381 Public Sector Enh
174026
174027 --
174028 -- set accounting attributes for the line type
174029 --
174030 l_entered_amt_idx := 3;
174031 l_accted_amt_idx := 8;
174032 l_bflow_applied_to_amt_idx := NULL; -- 5132302
174033 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
174034 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
174035 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
174036 l_rec_acct_attrs.array_char_value(2) := p_source_85;
174037 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
174038 l_rec_acct_attrs.array_num_value(3) := p_source_91;
174039 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
174040 l_rec_acct_attrs.array_char_value(4) := p_source_88;
174041 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
174042 l_rec_acct_attrs.array_date_value(5) := p_source_92;
174043 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
174044 l_rec_acct_attrs.array_num_value(6) := p_source_93;
174045 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
174046 l_rec_acct_attrs.array_char_value(7) := p_source_94;
174047 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
174048 l_rec_acct_attrs.array_num_value(8) := p_source_95;
174049
174050 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
174051 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
174052
174053 ---------------------------------------------------------------------------------------------------------------
174054 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
174055 ---------------------------------------------------------------------------------------------------------------
174056 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
174057
174058 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
174059 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
174060
174061 IF xla_accounting_cache_pkg.GetValueChar
174062 (p_source_code => 'LEDGER_CATEGORY_CODE'
174063 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
174064 AND l_bflow_method_code = 'PRIOR_ENTRY'
174065 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
174066 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
174067 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
174068 )
174069 THEN
174070 xla_ae_lines_pkg.BflowUpgEntry
174071 (p_business_method_code => l_bflow_method_code
174072 ,p_business_class_code => l_bflow_class_code
174073 ,p_balance_type => l_balance_type_code);
174074 ELSE
174075 NULL;
174076 -- No business flow processing for business flow method of NONE.
174077 END IF;
174078
174079 --
174080 -- call analytical criteria
174081 --
174082
174083 --
174084 -- call description
174085 --
174086
174087 xla_ae_lines_pkg.SetLineDescription(
174088 p_ae_header_id => l_ae_header_id
174089 ,p_description => Description_1 (
174090 p_application_id => p_application_id
174091 , p_ae_header_id => l_ae_header_id
174092 , p_source_1 => p_source_1
174093 , p_source_2 => p_source_2
174094 , p_source_3 => p_source_3
174095 , p_source_4 => p_source_4
174096 , p_source_5 => p_source_5
174097 )
174098 );
174099
174100
174101 --
174102 -- call ADRs
174103 -- Bug 4922099
174104 --
174105 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
174106 (NVL(l_actual_upg_option, 'N') = 'O') OR
174107 (NVL(l_enc_upg_option, 'N') = 'O')
174108 )
174109 THEN
174110 NULL;
174111 --
174112 --
174113
174114 l_ccid := AcctDerRule_6(
174115 p_application_id => p_application_id
174116 , p_ae_header_id => l_ae_header_id
174117 , p_source_11 => p_source_11
174118 , x_transaction_coa_id => l_adr_transaction_coa_id
174119 , x_accounting_coa_id => l_adr_accounting_coa_id
174120 , x_value_type_code => l_adr_value_type_code
174121 , p_side => 'NA'
174122 );
174123
174124 xla_ae_lines_pkg.set_ccid(
174125 p_code_combination_id => l_ccid
174126 , p_value_type_code => l_adr_value_type_code
174127 , p_transaction_coa_id => l_adr_transaction_coa_id
174128 , p_accounting_coa_id => l_adr_accounting_coa_id
174129 , p_adr_code => 'CST_DEFAULT'
174130 , p_adr_type_code => 'S'
174131 , p_component_type => l_component_type
174132 , p_component_code => l_component_code
174133 , p_component_type_code => l_component_type_code
174134 , p_component_appl_id => l_component_appl_id
174135 , p_amb_context_code => l_amb_context_code
174136 , p_side => 'NA'
174137 );
174138
174139
174140 --
174141 --
174142 END IF;
174143 --
174144 -- Bug 4922099
174145 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
174146 (NVL(l_enc_upg_option, 'N') = 'O')
174147 ) AND
174148 (l_bflow_method_code = 'PRIOR_ENTRY')
174149 )
174150 THEN
174151 IF
174152 --
174153 1 = 2
174154 --
174155 THEN
174156 xla_accounting_err_pkg.build_message
174157 (p_appli_s_name => 'XLA'
174158 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
174159 ,p_token_1 => 'LINE_NUMBER'
174160 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
174161 ,p_token_2 => 'LINE_TYPE_NAME'
174162 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
174163 l_component_type
174164 ,l_component_code
174165 ,l_component_type_code
174166 ,l_component_appl_id
174167 ,l_amb_context_code
174168 ,l_entity_code
174169 ,l_event_class_code
174170 )
174171 ,p_token_3 => 'OWNER'
174172 ,p_value_3 => xla_lookups_pkg.get_meaning(
174173 p_lookup_type => 'XLA_OWNER_TYPE'
174174 ,p_lookup_code => l_component_type_code
174175 )
174176 ,p_token_4 => 'PRODUCT_NAME'
174177 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
174178 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
174179 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
174180 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
174181 ,p_ae_header_id => NULL
174182 );
174183
174184 IF (C_LEVEL_ERROR>= g_log_level) THEN
174185 trace
174186 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
174187 ,p_level => C_LEVEL_ERROR
174188 ,p_module => l_log_module);
174189 END IF;
174190 END IF;
174191 END IF;
174192 --
174193 --
174194 ------------------------------------------------------------------------------------------------
174195 -- 4219869 Business Flow
174196 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
174197 -- Prior Entry. Currently, the following code is always generated.
174198 ------------------------------------------------------------------------------------------------
174199 XLA_AE_LINES_PKG.ValidateCurrentLine;
174200
174201 ------------------------------------------------------------------------------------
174202 -- 4219869 Business Flow
174203 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
174204 ------------------------------------------------------------------------------------
174205 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
174206
174207 ----------------------------------------------------------------------------------
174208 -- 4219869 Business Flow
174209 -- Update journal entry status -- Need to generate this within IF <condition>
174210 ----------------------------------------------------------------------------------
174211 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
174212 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
174213 ,p_balance_type_code => l_balance_type_code
174214 );
174215
174216 -------------------------------------------------------------------------------------------
174217 -- 4262811 - Generate the Accrual Reversal lines
174218 -------------------------------------------------------------------------------------------
174219 BEGIN
174220 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
174221 (g_array_event(p_event_id).array_value_num('header_index'));
174222 IF l_acc_rev_flag IS NULL THEN
174223 l_acc_rev_flag := 'N';
174224 END IF;
174225 EXCEPTION
174226 WHEN OTHERS THEN
174227 l_acc_rev_flag := 'N';
174228 END;
174229 --
174230 IF (l_acc_rev_flag = 'Y') THEN
174231
174232 -- 4645092 ------------------------------------------------------------------------------
174233 -- To allow MPA report to determine if it should generate report process
174234 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
174235 ------------------------------------------------------------------------------------------
174236
174237 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
174238 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
174239 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
174240 -- call ADRs
174241 -- Bug 4922099
174242 --
174243 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
174244 (NVL(l_actual_upg_option, 'N') = 'O') OR
174245 (NVL(l_enc_upg_option, 'N') = 'O')
174246 )
174247 THEN
174248 NULL;
174249 --
174250 --
174251
174252 l_ccid := AcctDerRule_6(
174253 p_application_id => p_application_id
174254 , p_ae_header_id => l_ae_header_id
174255 , p_source_11 => p_source_11
174256 , x_transaction_coa_id => l_adr_transaction_coa_id
174257 , x_accounting_coa_id => l_adr_accounting_coa_id
174258 , x_value_type_code => l_adr_value_type_code
174259 , p_side => 'NA'
174260 );
174261
174262 xla_ae_lines_pkg.set_ccid(
174263 p_code_combination_id => l_ccid
174264 , p_value_type_code => l_adr_value_type_code
174265 , p_transaction_coa_id => l_adr_transaction_coa_id
174266 , p_accounting_coa_id => l_adr_accounting_coa_id
174267 , p_adr_code => 'CST_DEFAULT'
174268 , p_adr_type_code => 'S'
174269 , p_component_type => l_component_type
174270 , p_component_code => l_component_code
174271 , p_component_type_code => l_component_type_code
174272 , p_component_appl_id => l_component_appl_id
174273 , p_amb_context_code => l_amb_context_code
174274 , p_side => 'NA'
174275 );
174276
174277
174278 --
174279 --
174280 END IF;
174281
174282 --
174283 -- Update the line information that should be overwritten
174284 --
174285 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
174286 p_header_num => 1);
174287 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
174288
174289 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
174290
174291 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
174292 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
174293 END IF;
174294
174295 --
174296 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
174297 --
174298 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
174299 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
174300 ELSE
174301 ---------------------------------------------------------------------------------------------------
174302 -- 4262811a Switch Sign
174303 ---------------------------------------------------------------------------------------------------
174304 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
174305 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
174306 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174307 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
174308 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174309 -- 5132302
174310 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
174311 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174312
174313 END IF;
174314
174315 -- 4955764
174316 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
174317 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
174318
174319
174320 XLA_AE_LINES_PKG.ValidateCurrentLine;
174321 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
174322
174323 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
174324 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
174325 ,p_balance_type_code => l_balance_type_code);
174326
174327 END IF;
174328
174329 -----------------------------------------------------------------------------------------
174330 -- 4262811 Multiperiod Accounting
174331 -----------------------------------------------------------------------------------------
174332 -- No MPA option is assigned.
174333
174334
174335 END IF;
174336 END IF;
174337 --
174338
174339 --
174340 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
174341 trace
174342 (p_msg => 'END of AcctLineType_321'
174343 ,p_level => C_LEVEL_PROCEDURE
174344 ,p_module => l_log_module);
174345 END IF;
174346 --
174347 EXCEPTION
174348 WHEN xla_exceptions_pkg.application_exception THEN
174349 RAISE;
174350 WHEN OTHERS THEN
174351 xla_exceptions_pkg.raise_message
174352 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_321');
174353 END AcctLineType_321;
174354 --
174355
174356 ---------------------------------------
174357 --
174358 -- PRIVATE FUNCTION
174359 -- AcctLineType_322
174360 --
174361 ---------------------------------------
174362 PROCEDURE AcctLineType_322 (
174363 p_application_id IN NUMBER
174364 ,p_event_id IN NUMBER
174365 ,p_calculate_acctd_flag IN VARCHAR2
174366 ,p_calculate_g_l_flag IN VARCHAR2
174367 ,p_actual_flag IN OUT VARCHAR2
174368 ,p_balance_type_code OUT VARCHAR2
174369 ,p_gain_or_loss_ref OUT VARCHAR2
174370
174371 --TRANSACTION_ID
174372 , p_source_1 IN NUMBER
174373 --Item Concatenated Segments
174374 , p_source_2 IN VARCHAR2
174375 --Transaction Quantity
174376 , p_source_3 IN NUMBER
174377 --Transaction Unit of Measure Code
174378 , p_source_4 IN VARCHAR2
174379 --Inventory Transaction Type Description
174380 , p_source_5 IN VARCHAR2
174381 --Cost Management Default Account
174382 , p_source_11 IN NUMBER
174383 --DISTRIBUTION_IDENTIFIER
174384 , p_source_84 IN NUMBER
174385 --Distribution Type
174386 , p_source_85 IN VARCHAR2
174387 , p_source_85_meaning IN VARCHAR2
174388 --Entered Currency Code
174389 , p_source_88 IN VARCHAR2
174390 --Entered Amount
174391 , p_source_91 IN NUMBER
174392 --Currency Conversion Date
174393 , p_source_92 IN DATE
174394 --Currency Conversion Rate
174395 , p_source_93 IN NUMBER
174396 --Currency Conversion Type
174397 , p_source_94 IN VARCHAR2
174398 --Accounted Amount
174399 , p_source_95 IN NUMBER
174400 --Accounting Line Type
174401 , p_source_97 IN NUMBER
174402 )
174403 IS
174404
174405 l_component_type VARCHAR2(80);
174406 l_component_code VARCHAR2(30);
174407 l_component_type_code VARCHAR2(1);
174408 l_component_appl_id INTEGER;
174409 l_amb_context_code VARCHAR2(30);
174410 l_entity_code VARCHAR2(30);
174411 l_event_class_code VARCHAR2(30);
174412 l_ae_header_id NUMBER;
174413 l_event_type_code VARCHAR2(30);
174414 l_line_definition_code VARCHAR2(30);
174415 l_line_definition_owner_code VARCHAR2(1);
174416 --
174417 -- adr variables
174418 l_segment VARCHAR2(30);
174419 l_ccid NUMBER;
174420 l_adr_transaction_coa_id NUMBER;
174421 l_adr_accounting_coa_id NUMBER;
174422 l_adr_flexfield_segment_code VARCHAR2(30);
174423 l_adr_flex_value_set_id NUMBER;
174424 l_adr_value_type_code VARCHAR2(30);
174425 l_adr_value_combination_id NUMBER;
174426 l_adr_value_segment_code VARCHAR2(30);
174427
174428 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
174429 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
174430 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
174431 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
174432
174433 -- 4262811 Variables ------------------------------------------------------------------------------------------
174434 l_entered_amt_idx NUMBER;
174435 l_accted_amt_idx NUMBER;
174436 l_acc_rev_flag VARCHAR2(1);
174437 l_accrual_line_num NUMBER;
174438 l_tmp_amt NUMBER;
174439 l_acc_rev_natural_side_code VARCHAR2(1);
174440
174441 l_num_entries NUMBER;
174442 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
174443 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
174444 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
174445 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
174446 l_recog_line_1 NUMBER;
174447 l_recog_line_2 NUMBER;
174448
174449 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
174450 l_bflow_applied_to_amt NUMBER; -- 5132302
174451 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
174452
174453 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
174454
174455 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
174456 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
174457
174458 ---------------------------------------------------------------------------------------------------------------
174459
174460
174461 --
174462 -- bulk performance
174463 --
174464 l_balance_type_code VARCHAR2(1);
174465 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
174466 l_log_module VARCHAR2(240);
174467
174468 --
174469 -- Upgrade strategy
174470 --
174471 l_actual_upg_option VARCHAR2(1);
174472 l_enc_upg_option VARCHAR2(1);
174473
174474 --
174475 BEGIN
174476 --
174477 IF g_log_enabled THEN
174478 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_322';
174479 END IF;
174480 --
174481 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
174482
174483 trace
174484 (p_msg => 'BEGIN of AcctLineType_322'
174485 ,p_level => C_LEVEL_PROCEDURE
174486 ,p_module => l_log_module);
174487
174488 END IF;
174489 --
174490 l_component_type := 'AMB_JLT';
174491 l_component_code := 'OFFSET';
174492 l_component_type_code := 'S';
174493 l_component_appl_id := 707;
174494 l_amb_context_code := 'DEFAULT';
174495 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
174496 l_event_class_code := 'WIP_MTL';
174497 l_event_type_code := 'WIP_NEG_COMP_ISSUE';
174498 l_line_definition_owner_code := 'S';
174499 l_line_definition_code := 'PI_WIP_NEG_COMP_ISSUE';
174500 --
174501 l_balance_type_code := 'A';
174502 l_segment := NULL;
174503 l_ccid := NULL;
174504 l_adr_transaction_coa_id := NULL;
174505 l_adr_accounting_coa_id := NULL;
174506 l_adr_flexfield_segment_code := NULL;
174507 l_adr_flex_value_set_id := NULL;
174508 l_adr_value_type_code := NULL;
174509 l_adr_value_combination_id := NULL;
174510 l_adr_value_segment_code := NULL;
174511
174512 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
174513 l_bflow_class_code := ''; -- 4219869 Business Flow
174514 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
174515 l_budgetary_control_flag := 'N';
174516
174517 l_bflow_applied_to_amt_idx := NULL; -- 5132302
174518 l_bflow_applied_to_amt := NULL; -- 5132302
174519 l_entered_amt_idx := NULL; -- 4262811
174520 l_accted_amt_idx := NULL; -- 4262811
174521 l_acc_rev_flag := NULL; -- 4262811
174522 l_accrual_line_num := NULL; -- 4262811
174523 l_tmp_amt := NULL; -- 4262811
174524 --
174525
174526 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
174527 l_balance_type_code <> 'B' THEN
174528 IF NVL(p_source_97,9E125) = 2
174529 THEN
174530
174531 --
174532 XLA_AE_LINES_PKG.SetNewLine;
174533
174534 p_balance_type_code := l_balance_type_code;
174535 -- set the flag so later we will know whether the gain loss line needs to be created
174536
174537 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
174538 p_actual_flag :='A';
174539 END IF;
174540
174541 --
174542 -- bulk performance
174543 --
174544 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
174545 p_header_num => 0); -- 4262811
174546 --
174547 -- set accounting line options
174548 --
174549 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
174550 p_natural_side_code => 'D'
174551 , p_gain_or_loss_flag => 'N'
174552 , p_gl_transfer_mode_code => 'S'
174553 , p_acct_entry_type_code => 'A'
174554 , p_switch_side_flag => 'Y'
174555 , p_merge_duplicate_code => 'N'
174556 );
174557 --
174558 l_acc_rev_natural_side_code := 'C'; -- 4262811
174559 --
174560 --
174561 -- set accounting line type info
174562 --
174563 xla_ae_lines_pkg.SetAcctLineType
174564 (p_component_type => l_component_type
174565 ,p_event_type_code => l_event_type_code
174566 ,p_line_definition_owner_code => l_line_definition_owner_code
174567 ,p_line_definition_code => l_line_definition_code
174568 ,p_accounting_line_code => l_component_code
174569 ,p_accounting_line_type_code => l_component_type_code
174570 ,p_accounting_line_appl_id => l_component_appl_id
174571 ,p_amb_context_code => l_amb_context_code
174572 ,p_entity_code => l_entity_code
174573 ,p_event_class_code => l_event_class_code);
174574 --
174575 -- set accounting class
174576 --
174577 xla_ae_lines_pkg.SetAcctClass(
174578 p_accounting_class_code => 'OFFSET'
174579 , p_ae_header_id => l_ae_header_id
174580 );
174581
174582 --
174583 -- set rounding class
174584 --
174585 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
174586 'OFFSET';
174587
174588 --
174589 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
174590 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
174591 --
174592 -- bulk performance
174593 --
174594 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
174595
174596 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
174597 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
174598
174599 -- 4955764
174600 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
174601 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
174602
174603 -- 4458381 Public Sector Enh
174604
174605 --
174606 -- set accounting attributes for the line type
174607 --
174608 l_entered_amt_idx := 3;
174609 l_accted_amt_idx := 8;
174610 l_bflow_applied_to_amt_idx := NULL; -- 5132302
174611 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
174612 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
174613 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
174614 l_rec_acct_attrs.array_char_value(2) := p_source_85;
174615 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
174616 l_rec_acct_attrs.array_num_value(3) := p_source_91;
174617 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
174618 l_rec_acct_attrs.array_char_value(4) := p_source_88;
174619 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
174620 l_rec_acct_attrs.array_date_value(5) := p_source_92;
174621 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
174622 l_rec_acct_attrs.array_num_value(6) := p_source_93;
174623 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
174624 l_rec_acct_attrs.array_char_value(7) := p_source_94;
174625 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
174626 l_rec_acct_attrs.array_num_value(8) := p_source_95;
174627
174628 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
174629 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
174630
174631 ---------------------------------------------------------------------------------------------------------------
174632 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
174633 ---------------------------------------------------------------------------------------------------------------
174634 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
174635
174636 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
174637 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
174638
174639 IF xla_accounting_cache_pkg.GetValueChar
174640 (p_source_code => 'LEDGER_CATEGORY_CODE'
174641 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
174642 AND l_bflow_method_code = 'PRIOR_ENTRY'
174643 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
174644 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
174645 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
174646 )
174647 THEN
174648 xla_ae_lines_pkg.BflowUpgEntry
174649 (p_business_method_code => l_bflow_method_code
174650 ,p_business_class_code => l_bflow_class_code
174651 ,p_balance_type => l_balance_type_code);
174652 ELSE
174653 NULL;
174654 -- No business flow processing for business flow method of NONE.
174655 END IF;
174656
174657 --
174658 -- call analytical criteria
174659 --
174660
174661 --
174662 -- call description
174663 --
174664
174665 xla_ae_lines_pkg.SetLineDescription(
174666 p_ae_header_id => l_ae_header_id
174667 ,p_description => Description_1 (
174668 p_application_id => p_application_id
174669 , p_ae_header_id => l_ae_header_id
174670 , p_source_1 => p_source_1
174671 , p_source_2 => p_source_2
174672 , p_source_3 => p_source_3
174673 , p_source_4 => p_source_4
174674 , p_source_5 => p_source_5
174675 )
174676 );
174677
174678
174679 --
174680 -- call ADRs
174681 -- Bug 4922099
174682 --
174683 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
174684 (NVL(l_actual_upg_option, 'N') = 'O') OR
174685 (NVL(l_enc_upg_option, 'N') = 'O')
174686 )
174687 THEN
174688 NULL;
174689 --
174690 --
174691
174692 l_ccid := AcctDerRule_6(
174693 p_application_id => p_application_id
174694 , p_ae_header_id => l_ae_header_id
174695 , p_source_11 => p_source_11
174696 , x_transaction_coa_id => l_adr_transaction_coa_id
174697 , x_accounting_coa_id => l_adr_accounting_coa_id
174698 , x_value_type_code => l_adr_value_type_code
174699 , p_side => 'NA'
174700 );
174701
174702 xla_ae_lines_pkg.set_ccid(
174703 p_code_combination_id => l_ccid
174704 , p_value_type_code => l_adr_value_type_code
174705 , p_transaction_coa_id => l_adr_transaction_coa_id
174706 , p_accounting_coa_id => l_adr_accounting_coa_id
174707 , p_adr_code => 'CST_DEFAULT'
174708 , p_adr_type_code => 'S'
174709 , p_component_type => l_component_type
174710 , p_component_code => l_component_code
174711 , p_component_type_code => l_component_type_code
174712 , p_component_appl_id => l_component_appl_id
174713 , p_amb_context_code => l_amb_context_code
174714 , p_side => 'NA'
174715 );
174716
174717
174718 --
174719 --
174720 END IF;
174721 --
174722 -- Bug 4922099
174723 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
174724 (NVL(l_enc_upg_option, 'N') = 'O')
174725 ) AND
174726 (l_bflow_method_code = 'PRIOR_ENTRY')
174727 )
174728 THEN
174729 IF
174730 --
174731 1 = 2
174732 --
174733 THEN
174734 xla_accounting_err_pkg.build_message
174735 (p_appli_s_name => 'XLA'
174736 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
174737 ,p_token_1 => 'LINE_NUMBER'
174738 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
174739 ,p_token_2 => 'LINE_TYPE_NAME'
174740 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
174741 l_component_type
174742 ,l_component_code
174743 ,l_component_type_code
174744 ,l_component_appl_id
174745 ,l_amb_context_code
174746 ,l_entity_code
174747 ,l_event_class_code
174748 )
174749 ,p_token_3 => 'OWNER'
174750 ,p_value_3 => xla_lookups_pkg.get_meaning(
174751 p_lookup_type => 'XLA_OWNER_TYPE'
174752 ,p_lookup_code => l_component_type_code
174753 )
174754 ,p_token_4 => 'PRODUCT_NAME'
174755 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
174756 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
174757 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
174758 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
174759 ,p_ae_header_id => NULL
174760 );
174761
174762 IF (C_LEVEL_ERROR>= g_log_level) THEN
174763 trace
174764 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
174765 ,p_level => C_LEVEL_ERROR
174766 ,p_module => l_log_module);
174767 END IF;
174768 END IF;
174769 END IF;
174770 --
174771 --
174772 ------------------------------------------------------------------------------------------------
174773 -- 4219869 Business Flow
174774 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
174775 -- Prior Entry. Currently, the following code is always generated.
174776 ------------------------------------------------------------------------------------------------
174777 XLA_AE_LINES_PKG.ValidateCurrentLine;
174778
174779 ------------------------------------------------------------------------------------
174780 -- 4219869 Business Flow
174781 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
174782 ------------------------------------------------------------------------------------
174783 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
174784
174785 ----------------------------------------------------------------------------------
174786 -- 4219869 Business Flow
174787 -- Update journal entry status -- Need to generate this within IF <condition>
174788 ----------------------------------------------------------------------------------
174789 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
174790 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
174791 ,p_balance_type_code => l_balance_type_code
174792 );
174793
174794 -------------------------------------------------------------------------------------------
174795 -- 4262811 - Generate the Accrual Reversal lines
174796 -------------------------------------------------------------------------------------------
174797 BEGIN
174798 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
174799 (g_array_event(p_event_id).array_value_num('header_index'));
174800 IF l_acc_rev_flag IS NULL THEN
174801 l_acc_rev_flag := 'N';
174802 END IF;
174803 EXCEPTION
174804 WHEN OTHERS THEN
174805 l_acc_rev_flag := 'N';
174806 END;
174807 --
174808 IF (l_acc_rev_flag = 'Y') THEN
174809
174810 -- 4645092 ------------------------------------------------------------------------------
174811 -- To allow MPA report to determine if it should generate report process
174812 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
174813 ------------------------------------------------------------------------------------------
174814
174815 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
174816 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
174817 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
174818 -- call ADRs
174819 -- Bug 4922099
174820 --
174821 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
174822 (NVL(l_actual_upg_option, 'N') = 'O') OR
174823 (NVL(l_enc_upg_option, 'N') = 'O')
174824 )
174825 THEN
174826 NULL;
174827 --
174828 --
174829
174830 l_ccid := AcctDerRule_6(
174831 p_application_id => p_application_id
174832 , p_ae_header_id => l_ae_header_id
174833 , p_source_11 => p_source_11
174834 , x_transaction_coa_id => l_adr_transaction_coa_id
174835 , x_accounting_coa_id => l_adr_accounting_coa_id
174836 , x_value_type_code => l_adr_value_type_code
174837 , p_side => 'NA'
174838 );
174839
174840 xla_ae_lines_pkg.set_ccid(
174841 p_code_combination_id => l_ccid
174842 , p_value_type_code => l_adr_value_type_code
174843 , p_transaction_coa_id => l_adr_transaction_coa_id
174844 , p_accounting_coa_id => l_adr_accounting_coa_id
174845 , p_adr_code => 'CST_DEFAULT'
174846 , p_adr_type_code => 'S'
174847 , p_component_type => l_component_type
174848 , p_component_code => l_component_code
174849 , p_component_type_code => l_component_type_code
174850 , p_component_appl_id => l_component_appl_id
174851 , p_amb_context_code => l_amb_context_code
174852 , p_side => 'NA'
174853 );
174854
174855
174856 --
174857 --
174858 END IF;
174859
174860 --
174861 -- Update the line information that should be overwritten
174862 --
174863 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
174864 p_header_num => 1);
174865 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
174866
174867 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
174868
174869 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
174870 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
174871 END IF;
174872
174873 --
174874 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
174875 --
174876 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
174877 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
174878 ELSE
174879 ---------------------------------------------------------------------------------------------------
174880 -- 4262811a Switch Sign
174881 ---------------------------------------------------------------------------------------------------
174882 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
174883 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
174884 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174885 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
174886 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174887 -- 5132302
174888 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
174889 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
174890
174891 END IF;
174892
174893 -- 4955764
174894 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
174895 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
174896
174897
174898 XLA_AE_LINES_PKG.ValidateCurrentLine;
174899 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
174900
174901 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
174902 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
174903 ,p_balance_type_code => l_balance_type_code);
174904
174905 END IF;
174906
174907 -----------------------------------------------------------------------------------------
174908 -- 4262811 Multiperiod Accounting
174909 -----------------------------------------------------------------------------------------
174910 -- No MPA option is assigned.
174911
174912
174913 END IF;
174914 END IF;
174915 --
174916
174917 --
174918 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
174919 trace
174920 (p_msg => 'END of AcctLineType_322'
174921 ,p_level => C_LEVEL_PROCEDURE
174922 ,p_module => l_log_module);
174923 END IF;
174924 --
174925 EXCEPTION
174926 WHEN xla_exceptions_pkg.application_exception THEN
174927 RAISE;
174928 WHEN OTHERS THEN
174929 xla_exceptions_pkg.raise_message
174930 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_322');
174931 END AcctLineType_322;
174932 --
174933
174934 ---------------------------------------
174935 --
174936 -- PRIVATE FUNCTION
174937 -- AcctLineType_323
174938 --
174939 ---------------------------------------
174940 PROCEDURE AcctLineType_323 (
174941 p_application_id IN NUMBER
174942 ,p_event_id IN NUMBER
174943 ,p_calculate_acctd_flag IN VARCHAR2
174944 ,p_calculate_g_l_flag IN VARCHAR2
174945 ,p_actual_flag IN OUT VARCHAR2
174946 ,p_balance_type_code OUT VARCHAR2
174947 ,p_gain_or_loss_ref OUT VARCHAR2
174948
174949 --TRANSACTION_ID
174950 , p_source_1 IN NUMBER
174951 --Item Concatenated Segments
174952 , p_source_2 IN VARCHAR2
174953 --Transaction Quantity
174954 , p_source_3 IN NUMBER
174955 --Transaction Unit of Measure Code
174956 , p_source_4 IN VARCHAR2
174957 --Inventory Transaction Type Description
174958 , p_source_5 IN VARCHAR2
174959 --Cost Management Default Account
174960 , p_source_11 IN NUMBER
174961 --DISTRIBUTION_IDENTIFIER
174962 , p_source_84 IN NUMBER
174963 --Distribution Type
174964 , p_source_85 IN VARCHAR2
174965 , p_source_85_meaning IN VARCHAR2
174966 --Entered Currency Code
174967 , p_source_88 IN VARCHAR2
174968 --Entered Amount
174969 , p_source_91 IN NUMBER
174970 --Currency Conversion Date
174971 , p_source_92 IN DATE
174972 --Currency Conversion Rate
174973 , p_source_93 IN NUMBER
174974 --Currency Conversion Type
174975 , p_source_94 IN VARCHAR2
174976 --Accounted Amount
174977 , p_source_95 IN NUMBER
174978 --Accounting Line Type
174979 , p_source_97 IN NUMBER
174980 )
174981 IS
174982
174983 l_component_type VARCHAR2(80);
174984 l_component_code VARCHAR2(30);
174985 l_component_type_code VARCHAR2(1);
174986 l_component_appl_id INTEGER;
174987 l_amb_context_code VARCHAR2(30);
174988 l_entity_code VARCHAR2(30);
174989 l_event_class_code VARCHAR2(30);
174990 l_ae_header_id NUMBER;
174991 l_event_type_code VARCHAR2(30);
174992 l_line_definition_code VARCHAR2(30);
174993 l_line_definition_owner_code VARCHAR2(1);
174994 --
174995 -- adr variables
174996 l_segment VARCHAR2(30);
174997 l_ccid NUMBER;
174998 l_adr_transaction_coa_id NUMBER;
174999 l_adr_accounting_coa_id NUMBER;
175000 l_adr_flexfield_segment_code VARCHAR2(30);
175001 l_adr_flex_value_set_id NUMBER;
175002 l_adr_value_type_code VARCHAR2(30);
175003 l_adr_value_combination_id NUMBER;
175004 l_adr_value_segment_code VARCHAR2(30);
175005
175006 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
175007 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
175008 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
175009 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
175010
175011 -- 4262811 Variables ------------------------------------------------------------------------------------------
175012 l_entered_amt_idx NUMBER;
175013 l_accted_amt_idx NUMBER;
175014 l_acc_rev_flag VARCHAR2(1);
175015 l_accrual_line_num NUMBER;
175016 l_tmp_amt NUMBER;
175017 l_acc_rev_natural_side_code VARCHAR2(1);
175018
175019 l_num_entries NUMBER;
175020 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
175021 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
175022 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
175023 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
175024 l_recog_line_1 NUMBER;
175025 l_recog_line_2 NUMBER;
175026
175027 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
175028 l_bflow_applied_to_amt NUMBER; -- 5132302
175029 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
175030
175031 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
175032
175033 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
175034 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
175035
175036 ---------------------------------------------------------------------------------------------------------------
175037
175038
175039 --
175040 -- bulk performance
175041 --
175042 l_balance_type_code VARCHAR2(1);
175043 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
175044 l_log_module VARCHAR2(240);
175045
175046 --
175047 -- Upgrade strategy
175048 --
175049 l_actual_upg_option VARCHAR2(1);
175050 l_enc_upg_option VARCHAR2(1);
175051
175052 --
175053 BEGIN
175054 --
175055 IF g_log_enabled THEN
175056 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_323';
175057 END IF;
175058 --
175059 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
175060
175061 trace
175062 (p_msg => 'BEGIN of AcctLineType_323'
175063 ,p_level => C_LEVEL_PROCEDURE
175064 ,p_module => l_log_module);
175065
175066 END IF;
175067 --
175068 l_component_type := 'AMB_JLT';
175069 l_component_code := 'OFFSET';
175070 l_component_type_code := 'S';
175071 l_component_appl_id := 707;
175072 l_amb_context_code := 'DEFAULT';
175073 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
175074 l_event_class_code := 'WIP_MTL';
175075 l_event_type_code := 'WIP_EST_SCRAP_REVERSAL';
175076 l_line_definition_owner_code := 'S';
175077 l_line_definition_code := 'PI_WIP_EST_SCRAP_REVERSAL';
175078 --
175079 l_balance_type_code := 'A';
175080 l_segment := NULL;
175081 l_ccid := NULL;
175082 l_adr_transaction_coa_id := NULL;
175083 l_adr_accounting_coa_id := NULL;
175084 l_adr_flexfield_segment_code := NULL;
175085 l_adr_flex_value_set_id := NULL;
175086 l_adr_value_type_code := NULL;
175087 l_adr_value_combination_id := NULL;
175088 l_adr_value_segment_code := NULL;
175089
175090 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
175091 l_bflow_class_code := ''; -- 4219869 Business Flow
175092 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
175093 l_budgetary_control_flag := 'N';
175094
175095 l_bflow_applied_to_amt_idx := NULL; -- 5132302
175096 l_bflow_applied_to_amt := NULL; -- 5132302
175097 l_entered_amt_idx := NULL; -- 4262811
175098 l_accted_amt_idx := NULL; -- 4262811
175099 l_acc_rev_flag := NULL; -- 4262811
175100 l_accrual_line_num := NULL; -- 4262811
175101 l_tmp_amt := NULL; -- 4262811
175102 --
175103
175104 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
175105 l_balance_type_code <> 'B' THEN
175106 IF NVL(p_source_97,9E125) = 2
175107 THEN
175108
175109 --
175110 XLA_AE_LINES_PKG.SetNewLine;
175111
175112 p_balance_type_code := l_balance_type_code;
175113 -- set the flag so later we will know whether the gain loss line needs to be created
175114
175115 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
175116 p_actual_flag :='A';
175117 END IF;
175118
175119 --
175120 -- bulk performance
175121 --
175122 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
175123 p_header_num => 0); -- 4262811
175124 --
175125 -- set accounting line options
175126 --
175127 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
175128 p_natural_side_code => 'D'
175129 , p_gain_or_loss_flag => 'N'
175130 , p_gl_transfer_mode_code => 'S'
175131 , p_acct_entry_type_code => 'A'
175132 , p_switch_side_flag => 'Y'
175133 , p_merge_duplicate_code => 'N'
175134 );
175135 --
175136 l_acc_rev_natural_side_code := 'C'; -- 4262811
175137 --
175138 --
175139 -- set accounting line type info
175140 --
175141 xla_ae_lines_pkg.SetAcctLineType
175142 (p_component_type => l_component_type
175143 ,p_event_type_code => l_event_type_code
175144 ,p_line_definition_owner_code => l_line_definition_owner_code
175145 ,p_line_definition_code => l_line_definition_code
175146 ,p_accounting_line_code => l_component_code
175147 ,p_accounting_line_type_code => l_component_type_code
175148 ,p_accounting_line_appl_id => l_component_appl_id
175149 ,p_amb_context_code => l_amb_context_code
175150 ,p_entity_code => l_entity_code
175151 ,p_event_class_code => l_event_class_code);
175152 --
175153 -- set accounting class
175154 --
175155 xla_ae_lines_pkg.SetAcctClass(
175156 p_accounting_class_code => 'OFFSET'
175157 , p_ae_header_id => l_ae_header_id
175158 );
175159
175160 --
175161 -- set rounding class
175162 --
175163 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
175164 'OFFSET';
175165
175166 --
175167 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
175168 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
175169 --
175170 -- bulk performance
175171 --
175172 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
175173
175174 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
175175 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
175176
175177 -- 4955764
175178 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
175179 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
175180
175181 -- 4458381 Public Sector Enh
175182
175183 --
175184 -- set accounting attributes for the line type
175185 --
175186 l_entered_amt_idx := 3;
175187 l_accted_amt_idx := 8;
175188 l_bflow_applied_to_amt_idx := NULL; -- 5132302
175189 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
175190 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
175191 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
175192 l_rec_acct_attrs.array_char_value(2) := p_source_85;
175193 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
175194 l_rec_acct_attrs.array_num_value(3) := p_source_91;
175195 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
175196 l_rec_acct_attrs.array_char_value(4) := p_source_88;
175197 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
175198 l_rec_acct_attrs.array_date_value(5) := p_source_92;
175199 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
175200 l_rec_acct_attrs.array_num_value(6) := p_source_93;
175201 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
175202 l_rec_acct_attrs.array_char_value(7) := p_source_94;
175203 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
175204 l_rec_acct_attrs.array_num_value(8) := p_source_95;
175205
175206 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
175207 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
175208
175209 ---------------------------------------------------------------------------------------------------------------
175210 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
175211 ---------------------------------------------------------------------------------------------------------------
175212 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
175213
175214 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
175215 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
175216
175217 IF xla_accounting_cache_pkg.GetValueChar
175218 (p_source_code => 'LEDGER_CATEGORY_CODE'
175219 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
175220 AND l_bflow_method_code = 'PRIOR_ENTRY'
175221 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
175222 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
175223 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
175224 )
175225 THEN
175226 xla_ae_lines_pkg.BflowUpgEntry
175227 (p_business_method_code => l_bflow_method_code
175228 ,p_business_class_code => l_bflow_class_code
175229 ,p_balance_type => l_balance_type_code);
175230 ELSE
175231 NULL;
175232 -- No business flow processing for business flow method of NONE.
175233 END IF;
175234
175235 --
175236 -- call analytical criteria
175237 --
175238
175239 --
175240 -- call description
175241 --
175242
175243 xla_ae_lines_pkg.SetLineDescription(
175244 p_ae_header_id => l_ae_header_id
175245 ,p_description => Description_1 (
175246 p_application_id => p_application_id
175247 , p_ae_header_id => l_ae_header_id
175248 , p_source_1 => p_source_1
175249 , p_source_2 => p_source_2
175250 , p_source_3 => p_source_3
175251 , p_source_4 => p_source_4
175252 , p_source_5 => p_source_5
175253 )
175254 );
175255
175256
175257 --
175258 -- call ADRs
175259 -- Bug 4922099
175260 --
175261 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
175262 (NVL(l_actual_upg_option, 'N') = 'O') OR
175263 (NVL(l_enc_upg_option, 'N') = 'O')
175264 )
175265 THEN
175266 NULL;
175267 --
175268 --
175269
175270 l_ccid := AcctDerRule_6(
175271 p_application_id => p_application_id
175272 , p_ae_header_id => l_ae_header_id
175273 , p_source_11 => p_source_11
175274 , x_transaction_coa_id => l_adr_transaction_coa_id
175275 , x_accounting_coa_id => l_adr_accounting_coa_id
175276 , x_value_type_code => l_adr_value_type_code
175277 , p_side => 'NA'
175278 );
175279
175280 xla_ae_lines_pkg.set_ccid(
175281 p_code_combination_id => l_ccid
175282 , p_value_type_code => l_adr_value_type_code
175283 , p_transaction_coa_id => l_adr_transaction_coa_id
175284 , p_accounting_coa_id => l_adr_accounting_coa_id
175285 , p_adr_code => 'CST_DEFAULT'
175286 , p_adr_type_code => 'S'
175287 , p_component_type => l_component_type
175288 , p_component_code => l_component_code
175289 , p_component_type_code => l_component_type_code
175290 , p_component_appl_id => l_component_appl_id
175291 , p_amb_context_code => l_amb_context_code
175292 , p_side => 'NA'
175293 );
175294
175295
175296 --
175297 --
175298 END IF;
175299 --
175300 -- Bug 4922099
175301 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
175302 (NVL(l_enc_upg_option, 'N') = 'O')
175303 ) AND
175304 (l_bflow_method_code = 'PRIOR_ENTRY')
175305 )
175306 THEN
175307 IF
175308 --
175309 1 = 2
175310 --
175311 THEN
175312 xla_accounting_err_pkg.build_message
175313 (p_appli_s_name => 'XLA'
175314 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
175315 ,p_token_1 => 'LINE_NUMBER'
175316 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
175317 ,p_token_2 => 'LINE_TYPE_NAME'
175318 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
175319 l_component_type
175320 ,l_component_code
175321 ,l_component_type_code
175322 ,l_component_appl_id
175323 ,l_amb_context_code
175324 ,l_entity_code
175325 ,l_event_class_code
175326 )
175327 ,p_token_3 => 'OWNER'
175328 ,p_value_3 => xla_lookups_pkg.get_meaning(
175329 p_lookup_type => 'XLA_OWNER_TYPE'
175330 ,p_lookup_code => l_component_type_code
175331 )
175332 ,p_token_4 => 'PRODUCT_NAME'
175333 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
175334 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
175335 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
175336 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
175337 ,p_ae_header_id => NULL
175338 );
175339
175340 IF (C_LEVEL_ERROR>= g_log_level) THEN
175341 trace
175342 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
175343 ,p_level => C_LEVEL_ERROR
175344 ,p_module => l_log_module);
175345 END IF;
175346 END IF;
175347 END IF;
175348 --
175349 --
175350 ------------------------------------------------------------------------------------------------
175351 -- 4219869 Business Flow
175352 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
175353 -- Prior Entry. Currently, the following code is always generated.
175354 ------------------------------------------------------------------------------------------------
175355 XLA_AE_LINES_PKG.ValidateCurrentLine;
175356
175357 ------------------------------------------------------------------------------------
175358 -- 4219869 Business Flow
175359 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
175360 ------------------------------------------------------------------------------------
175361 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
175362
175363 ----------------------------------------------------------------------------------
175364 -- 4219869 Business Flow
175365 -- Update journal entry status -- Need to generate this within IF <condition>
175366 ----------------------------------------------------------------------------------
175367 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
175368 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
175369 ,p_balance_type_code => l_balance_type_code
175370 );
175371
175372 -------------------------------------------------------------------------------------------
175373 -- 4262811 - Generate the Accrual Reversal lines
175374 -------------------------------------------------------------------------------------------
175375 BEGIN
175376 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
175377 (g_array_event(p_event_id).array_value_num('header_index'));
175378 IF l_acc_rev_flag IS NULL THEN
175379 l_acc_rev_flag := 'N';
175380 END IF;
175381 EXCEPTION
175382 WHEN OTHERS THEN
175383 l_acc_rev_flag := 'N';
175384 END;
175385 --
175386 IF (l_acc_rev_flag = 'Y') THEN
175387
175388 -- 4645092 ------------------------------------------------------------------------------
175389 -- To allow MPA report to determine if it should generate report process
175390 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
175391 ------------------------------------------------------------------------------------------
175392
175393 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
175394 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
175395 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
175396 -- call ADRs
175397 -- Bug 4922099
175398 --
175399 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
175400 (NVL(l_actual_upg_option, 'N') = 'O') OR
175401 (NVL(l_enc_upg_option, 'N') = 'O')
175402 )
175403 THEN
175404 NULL;
175405 --
175406 --
175407
175408 l_ccid := AcctDerRule_6(
175409 p_application_id => p_application_id
175410 , p_ae_header_id => l_ae_header_id
175411 , p_source_11 => p_source_11
175412 , x_transaction_coa_id => l_adr_transaction_coa_id
175413 , x_accounting_coa_id => l_adr_accounting_coa_id
175414 , x_value_type_code => l_adr_value_type_code
175415 , p_side => 'NA'
175416 );
175417
175418 xla_ae_lines_pkg.set_ccid(
175419 p_code_combination_id => l_ccid
175420 , p_value_type_code => l_adr_value_type_code
175421 , p_transaction_coa_id => l_adr_transaction_coa_id
175422 , p_accounting_coa_id => l_adr_accounting_coa_id
175423 , p_adr_code => 'CST_DEFAULT'
175424 , p_adr_type_code => 'S'
175425 , p_component_type => l_component_type
175426 , p_component_code => l_component_code
175427 , p_component_type_code => l_component_type_code
175428 , p_component_appl_id => l_component_appl_id
175429 , p_amb_context_code => l_amb_context_code
175430 , p_side => 'NA'
175431 );
175432
175433
175434 --
175435 --
175436 END IF;
175437
175438 --
175439 -- Update the line information that should be overwritten
175440 --
175441 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
175442 p_header_num => 1);
175443 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
175444
175445 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
175446
175447 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
175448 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
175449 END IF;
175450
175451 --
175452 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
175453 --
175454 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
175455 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
175456 ELSE
175457 ---------------------------------------------------------------------------------------------------
175458 -- 4262811a Switch Sign
175459 ---------------------------------------------------------------------------------------------------
175460 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
175461 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
175462 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
175463 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
175464 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
175465 -- 5132302
175466 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
175467 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
175468
175469 END IF;
175470
175471 -- 4955764
175472 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
175473 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
175474
175475
175476 XLA_AE_LINES_PKG.ValidateCurrentLine;
175477 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
175478
175479 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
175480 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
175481 ,p_balance_type_code => l_balance_type_code);
175482
175483 END IF;
175484
175485 -----------------------------------------------------------------------------------------
175486 -- 4262811 Multiperiod Accounting
175487 -----------------------------------------------------------------------------------------
175488 -- No MPA option is assigned.
175489
175490
175491 END IF;
175492 END IF;
175493 --
175494
175495 --
175496 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
175497 trace
175498 (p_msg => 'END of AcctLineType_323'
175499 ,p_level => C_LEVEL_PROCEDURE
175500 ,p_module => l_log_module);
175501 END IF;
175502 --
175503 EXCEPTION
175504 WHEN xla_exceptions_pkg.application_exception THEN
175505 RAISE;
175506 WHEN OTHERS THEN
175507 xla_exceptions_pkg.raise_message
175508 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_323');
175509 END AcctLineType_323;
175510 --
175511
175512 ---------------------------------------
175513 --
175514 -- PRIVATE FUNCTION
175515 -- AcctLineType_324
175516 --
175517 ---------------------------------------
175518 PROCEDURE AcctLineType_324 (
175519 p_application_id IN NUMBER
175520 ,p_event_id IN NUMBER
175521 ,p_calculate_acctd_flag IN VARCHAR2
175522 ,p_calculate_g_l_flag IN VARCHAR2
175523 ,p_actual_flag IN OUT VARCHAR2
175524 ,p_balance_type_code OUT VARCHAR2
175525 ,p_gain_or_loss_ref OUT VARCHAR2
175526
175527 --Cost Management Default Account
175528 , p_source_11 IN NUMBER
175529 --DISTRIBUTION_IDENTIFIER
175530 , p_source_84 IN NUMBER
175531 --Distribution Type
175532 , p_source_85 IN VARCHAR2
175533 , p_source_85_meaning IN VARCHAR2
175534 --Entered Currency Code
175535 , p_source_88 IN VARCHAR2
175536 --Entered Amount
175537 , p_source_91 IN NUMBER
175538 --Currency Conversion Date
175539 , p_source_92 IN DATE
175540 --Currency Conversion Rate
175541 , p_source_93 IN NUMBER
175542 --Currency Conversion Type
175543 , p_source_94 IN VARCHAR2
175544 --Accounted Amount
175545 , p_source_95 IN NUMBER
175546 --Accounting Line Type
175547 , p_source_97 IN NUMBER
175548 )
175549 IS
175550
175551 l_component_type VARCHAR2(80);
175552 l_component_code VARCHAR2(30);
175553 l_component_type_code VARCHAR2(1);
175554 l_component_appl_id INTEGER;
175555 l_amb_context_code VARCHAR2(30);
175556 l_entity_code VARCHAR2(30);
175557 l_event_class_code VARCHAR2(30);
175558 l_ae_header_id NUMBER;
175559 l_event_type_code VARCHAR2(30);
175560 l_line_definition_code VARCHAR2(30);
175561 l_line_definition_owner_code VARCHAR2(1);
175562 --
175563 -- adr variables
175564 l_segment VARCHAR2(30);
175565 l_ccid NUMBER;
175566 l_adr_transaction_coa_id NUMBER;
175567 l_adr_accounting_coa_id NUMBER;
175568 l_adr_flexfield_segment_code VARCHAR2(30);
175569 l_adr_flex_value_set_id NUMBER;
175570 l_adr_value_type_code VARCHAR2(30);
175571 l_adr_value_combination_id NUMBER;
175572 l_adr_value_segment_code VARCHAR2(30);
175573
175574 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
175575 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
175576 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
175577 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
175578
175579 -- 4262811 Variables ------------------------------------------------------------------------------------------
175580 l_entered_amt_idx NUMBER;
175581 l_accted_amt_idx NUMBER;
175582 l_acc_rev_flag VARCHAR2(1);
175583 l_accrual_line_num NUMBER;
175584 l_tmp_amt NUMBER;
175585 l_acc_rev_natural_side_code VARCHAR2(1);
175586
175587 l_num_entries NUMBER;
175588 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
175589 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
175590 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
175591 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
175592 l_recog_line_1 NUMBER;
175593 l_recog_line_2 NUMBER;
175594
175595 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
175596 l_bflow_applied_to_amt NUMBER; -- 5132302
175597 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
175598
175599 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
175600
175601 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
175602 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
175603
175604 ---------------------------------------------------------------------------------------------------------------
175605
175606
175607 --
175608 -- bulk performance
175609 --
175610 l_balance_type_code VARCHAR2(1);
175611 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
175612 l_log_module VARCHAR2(240);
175613
175614 --
175615 -- Upgrade strategy
175616 --
175617 l_actual_upg_option VARCHAR2(1);
175618 l_enc_upg_option VARCHAR2(1);
175619
175620 --
175621 BEGIN
175622 --
175623 IF g_log_enabled THEN
175624 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_324';
175625 END IF;
175626 --
175627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
175628
175629 trace
175630 (p_msg => 'BEGIN of AcctLineType_324'
175631 ,p_level => C_LEVEL_PROCEDURE
175632 ,p_module => l_log_module);
175633
175634 END IF;
175635 --
175636 l_component_type := 'AMB_JLT';
175637 l_component_code := 'OFFSET';
175638 l_component_type_code := 'S';
175639 l_component_appl_id := 707;
175640 l_amb_context_code := 'DEFAULT';
175641 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
175642 l_event_class_code := 'WIP_LOT';
175643 l_event_type_code := 'WIP_LOT_ALL';
175644 l_line_definition_owner_code := 'S';
175645 l_line_definition_code := 'WIP_LOT';
175646 --
175647 l_balance_type_code := 'A';
175648 l_segment := NULL;
175649 l_ccid := NULL;
175650 l_adr_transaction_coa_id := NULL;
175651 l_adr_accounting_coa_id := NULL;
175652 l_adr_flexfield_segment_code := NULL;
175653 l_adr_flex_value_set_id := NULL;
175654 l_adr_value_type_code := NULL;
175655 l_adr_value_combination_id := NULL;
175656 l_adr_value_segment_code := NULL;
175657
175658 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
175659 l_bflow_class_code := ''; -- 4219869 Business Flow
175660 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
175661 l_budgetary_control_flag := 'N';
175662
175663 l_bflow_applied_to_amt_idx := NULL; -- 5132302
175664 l_bflow_applied_to_amt := NULL; -- 5132302
175665 l_entered_amt_idx := NULL; -- 4262811
175666 l_accted_amt_idx := NULL; -- 4262811
175667 l_acc_rev_flag := NULL; -- 4262811
175668 l_accrual_line_num := NULL; -- 4262811
175669 l_tmp_amt := NULL; -- 4262811
175670 --
175671
175672 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
175673 l_balance_type_code <> 'B' THEN
175674 IF NVL(p_source_97,9E125) = 25 OR
175675 NVL(p_source_97,9E125) = 27
175676 THEN
175677
175678 --
175679 XLA_AE_LINES_PKG.SetNewLine;
175680
175681 p_balance_type_code := l_balance_type_code;
175682 -- set the flag so later we will know whether the gain loss line needs to be created
175683
175684 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
175685 p_actual_flag :='A';
175686 END IF;
175687
175688 --
175689 -- bulk performance
175690 --
175691 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
175692 p_header_num => 0); -- 4262811
175693 --
175694 -- set accounting line options
175695 --
175696 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
175697 p_natural_side_code => 'D'
175698 , p_gain_or_loss_flag => 'N'
175699 , p_gl_transfer_mode_code => 'S'
175700 , p_acct_entry_type_code => 'A'
175701 , p_switch_side_flag => 'Y'
175702 , p_merge_duplicate_code => 'N'
175703 );
175704 --
175705 l_acc_rev_natural_side_code := 'C'; -- 4262811
175706 --
175707 --
175708 -- set accounting line type info
175709 --
175710 xla_ae_lines_pkg.SetAcctLineType
175711 (p_component_type => l_component_type
175712 ,p_event_type_code => l_event_type_code
175713 ,p_line_definition_owner_code => l_line_definition_owner_code
175714 ,p_line_definition_code => l_line_definition_code
175715 ,p_accounting_line_code => l_component_code
175716 ,p_accounting_line_type_code => l_component_type_code
175717 ,p_accounting_line_appl_id => l_component_appl_id
175718 ,p_amb_context_code => l_amb_context_code
175719 ,p_entity_code => l_entity_code
175720 ,p_event_class_code => l_event_class_code);
175721 --
175722 -- set accounting class
175723 --
175724 xla_ae_lines_pkg.SetAcctClass(
175725 p_accounting_class_code => 'OFFSET'
175726 , p_ae_header_id => l_ae_header_id
175727 );
175728
175729 --
175730 -- set rounding class
175731 --
175732 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
175733 'OFFSET';
175734
175735 --
175736 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
175737 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
175738 --
175739 -- bulk performance
175740 --
175741 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
175742
175743 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
175744 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
175745
175746 -- 4955764
175747 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
175748 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
175749
175750 -- 4458381 Public Sector Enh
175751
175752 --
175753 -- set accounting attributes for the line type
175754 --
175755 l_entered_amt_idx := 3;
175756 l_accted_amt_idx := 8;
175757 l_bflow_applied_to_amt_idx := NULL; -- 5132302
175758 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
175759 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
175760 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
175761 l_rec_acct_attrs.array_char_value(2) := p_source_85;
175762 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
175763 l_rec_acct_attrs.array_num_value(3) := p_source_91;
175764 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
175765 l_rec_acct_attrs.array_char_value(4) := p_source_88;
175766 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
175767 l_rec_acct_attrs.array_date_value(5) := p_source_92;
175768 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
175769 l_rec_acct_attrs.array_num_value(6) := p_source_93;
175770 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
175771 l_rec_acct_attrs.array_char_value(7) := p_source_94;
175772 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
175773 l_rec_acct_attrs.array_num_value(8) := p_source_95;
175774
175775 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
175776 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
175777
175778 ---------------------------------------------------------------------------------------------------------------
175779 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
175780 ---------------------------------------------------------------------------------------------------------------
175781 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
175782
175783 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
175784 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
175785
175786 IF xla_accounting_cache_pkg.GetValueChar
175787 (p_source_code => 'LEDGER_CATEGORY_CODE'
175788 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
175789 AND l_bflow_method_code = 'PRIOR_ENTRY'
175790 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
175791 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
175792 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
175793 )
175794 THEN
175795 xla_ae_lines_pkg.BflowUpgEntry
175796 (p_business_method_code => l_bflow_method_code
175797 ,p_business_class_code => l_bflow_class_code
175798 ,p_balance_type => l_balance_type_code);
175799 ELSE
175800 NULL;
175801 -- No business flow processing for business flow method of NONE.
175802 END IF;
175803
175804 --
175805 -- call analytical criteria
175806 --
175807
175808 --
175809 -- call description
175810 --
175811 -- No description or it is inherited.
175812 --
175813 -- call ADRs
175814 -- Bug 4922099
175815 --
175816 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
175817 (NVL(l_actual_upg_option, 'N') = 'O') OR
175818 (NVL(l_enc_upg_option, 'N') = 'O')
175819 )
175820 THEN
175821 NULL;
175822 --
175823 --
175824
175825 l_ccid := AcctDerRule_6(
175826 p_application_id => p_application_id
175827 , p_ae_header_id => l_ae_header_id
175828 , p_source_11 => p_source_11
175829 , x_transaction_coa_id => l_adr_transaction_coa_id
175830 , x_accounting_coa_id => l_adr_accounting_coa_id
175831 , x_value_type_code => l_adr_value_type_code
175832 , p_side => 'NA'
175833 );
175834
175835 xla_ae_lines_pkg.set_ccid(
175836 p_code_combination_id => l_ccid
175837 , p_value_type_code => l_adr_value_type_code
175838 , p_transaction_coa_id => l_adr_transaction_coa_id
175839 , p_accounting_coa_id => l_adr_accounting_coa_id
175840 , p_adr_code => 'CST_DEFAULT'
175841 , p_adr_type_code => 'S'
175842 , p_component_type => l_component_type
175843 , p_component_code => l_component_code
175844 , p_component_type_code => l_component_type_code
175845 , p_component_appl_id => l_component_appl_id
175846 , p_amb_context_code => l_amb_context_code
175847 , p_side => 'NA'
175848 );
175849
175850
175851 --
175852 --
175853 END IF;
175854 --
175855 -- Bug 4922099
175856 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
175857 (NVL(l_enc_upg_option, 'N') = 'O')
175858 ) AND
175859 (l_bflow_method_code = 'PRIOR_ENTRY')
175860 )
175861 THEN
175862 IF
175863 --
175864 1 = 2
175865 --
175866 THEN
175867 xla_accounting_err_pkg.build_message
175868 (p_appli_s_name => 'XLA'
175869 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
175870 ,p_token_1 => 'LINE_NUMBER'
175871 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
175872 ,p_token_2 => 'LINE_TYPE_NAME'
175873 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
175874 l_component_type
175875 ,l_component_code
175876 ,l_component_type_code
175877 ,l_component_appl_id
175878 ,l_amb_context_code
175879 ,l_entity_code
175880 ,l_event_class_code
175881 )
175882 ,p_token_3 => 'OWNER'
175883 ,p_value_3 => xla_lookups_pkg.get_meaning(
175884 p_lookup_type => 'XLA_OWNER_TYPE'
175885 ,p_lookup_code => l_component_type_code
175886 )
175887 ,p_token_4 => 'PRODUCT_NAME'
175888 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
175889 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
175890 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
175891 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
175892 ,p_ae_header_id => NULL
175893 );
175894
175895 IF (C_LEVEL_ERROR>= g_log_level) THEN
175896 trace
175897 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
175898 ,p_level => C_LEVEL_ERROR
175899 ,p_module => l_log_module);
175900 END IF;
175901 END IF;
175902 END IF;
175903 --
175904 --
175905 ------------------------------------------------------------------------------------------------
175906 -- 4219869 Business Flow
175907 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
175908 -- Prior Entry. Currently, the following code is always generated.
175909 ------------------------------------------------------------------------------------------------
175910 XLA_AE_LINES_PKG.ValidateCurrentLine;
175911
175912 ------------------------------------------------------------------------------------
175913 -- 4219869 Business Flow
175914 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
175915 ------------------------------------------------------------------------------------
175916 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
175917
175918 ----------------------------------------------------------------------------------
175919 -- 4219869 Business Flow
175920 -- Update journal entry status -- Need to generate this within IF <condition>
175921 ----------------------------------------------------------------------------------
175922 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
175923 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
175924 ,p_balance_type_code => l_balance_type_code
175925 );
175926
175927 -------------------------------------------------------------------------------------------
175928 -- 4262811 - Generate the Accrual Reversal lines
175929 -------------------------------------------------------------------------------------------
175930 BEGIN
175931 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
175932 (g_array_event(p_event_id).array_value_num('header_index'));
175933 IF l_acc_rev_flag IS NULL THEN
175934 l_acc_rev_flag := 'N';
175935 END IF;
175936 EXCEPTION
175937 WHEN OTHERS THEN
175938 l_acc_rev_flag := 'N';
175939 END;
175940 --
175941 IF (l_acc_rev_flag = 'Y') THEN
175942
175943 -- 4645092 ------------------------------------------------------------------------------
175944 -- To allow MPA report to determine if it should generate report process
175945 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
175946 ------------------------------------------------------------------------------------------
175947
175948 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
175949 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
175950 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
175951 -- call ADRs
175952 -- Bug 4922099
175953 --
175954 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
175955 (NVL(l_actual_upg_option, 'N') = 'O') OR
175956 (NVL(l_enc_upg_option, 'N') = 'O')
175957 )
175958 THEN
175959 NULL;
175960 --
175961 --
175962
175963 l_ccid := AcctDerRule_6(
175964 p_application_id => p_application_id
175965 , p_ae_header_id => l_ae_header_id
175966 , p_source_11 => p_source_11
175967 , x_transaction_coa_id => l_adr_transaction_coa_id
175968 , x_accounting_coa_id => l_adr_accounting_coa_id
175969 , x_value_type_code => l_adr_value_type_code
175970 , p_side => 'NA'
175971 );
175972
175973 xla_ae_lines_pkg.set_ccid(
175974 p_code_combination_id => l_ccid
175975 , p_value_type_code => l_adr_value_type_code
175976 , p_transaction_coa_id => l_adr_transaction_coa_id
175977 , p_accounting_coa_id => l_adr_accounting_coa_id
175978 , p_adr_code => 'CST_DEFAULT'
175979 , p_adr_type_code => 'S'
175980 , p_component_type => l_component_type
175981 , p_component_code => l_component_code
175982 , p_component_type_code => l_component_type_code
175983 , p_component_appl_id => l_component_appl_id
175984 , p_amb_context_code => l_amb_context_code
175985 , p_side => 'NA'
175986 );
175987
175988
175989 --
175990 --
175991 END IF;
175992
175993 --
175994 -- Update the line information that should be overwritten
175995 --
175996 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
175997 p_header_num => 1);
175998 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
175999
176000 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
176001
176002 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
176003 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
176004 END IF;
176005
176006 --
176007 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
176008 --
176009 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
176010 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
176011 ELSE
176012 ---------------------------------------------------------------------------------------------------
176013 -- 4262811a Switch Sign
176014 ---------------------------------------------------------------------------------------------------
176015 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
176016 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
176017 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176018 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
176019 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176020 -- 5132302
176021 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
176022 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176023
176024 END IF;
176025
176026 -- 4955764
176027 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
176028 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
176029
176030
176031 XLA_AE_LINES_PKG.ValidateCurrentLine;
176032 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
176033
176034 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
176035 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
176036 ,p_balance_type_code => l_balance_type_code);
176037
176038 END IF;
176039
176040 -----------------------------------------------------------------------------------------
176041 -- 4262811 Multiperiod Accounting
176042 -----------------------------------------------------------------------------------------
176043 -- No MPA option is assigned.
176044
176045
176046 END IF;
176047 END IF;
176048 --
176049
176050 --
176051 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
176052 trace
176053 (p_msg => 'END of AcctLineType_324'
176054 ,p_level => C_LEVEL_PROCEDURE
176055 ,p_module => l_log_module);
176056 END IF;
176057 --
176058 EXCEPTION
176059 WHEN xla_exceptions_pkg.application_exception THEN
176060 RAISE;
176061 WHEN OTHERS THEN
176062 xla_exceptions_pkg.raise_message
176063 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_324');
176064 END AcctLineType_324;
176065 --
176066
176067 ---------------------------------------
176068 --
176069 -- PRIVATE FUNCTION
176070 -- AcctLineType_325
176071 --
176072 ---------------------------------------
176073 PROCEDURE AcctLineType_325 (
176074 p_application_id IN NUMBER
176075 ,p_event_id IN NUMBER
176076 ,p_calculate_acctd_flag IN VARCHAR2
176077 ,p_calculate_g_l_flag IN VARCHAR2
176078 ,p_actual_flag IN OUT VARCHAR2
176079 ,p_balance_type_code OUT VARCHAR2
176080 ,p_gain_or_loss_ref OUT VARCHAR2
176081
176082 --TRANSACTION_ID
176083 , p_source_1 IN NUMBER
176084 --Item Concatenated Segments
176085 , p_source_2 IN VARCHAR2
176086 --Transaction Quantity
176087 , p_source_3 IN NUMBER
176088 --Transaction Unit of Measure Code
176089 , p_source_4 IN VARCHAR2
176090 --Inventory Transaction Type Description
176091 , p_source_5 IN VARCHAR2
176092 --Cost Management Default Account
176093 , p_source_11 IN NUMBER
176094 --DISTRIBUTION_IDENTIFIER
176095 , p_source_84 IN NUMBER
176096 --Distribution Type
176097 , p_source_85 IN VARCHAR2
176098 , p_source_85_meaning IN VARCHAR2
176099 --Entered Currency Code
176100 , p_source_88 IN VARCHAR2
176101 --Entered Amount
176102 , p_source_91 IN NUMBER
176103 --Currency Conversion Date
176104 , p_source_92 IN DATE
176105 --Currency Conversion Rate
176106 , p_source_93 IN NUMBER
176107 --Currency Conversion Type
176108 , p_source_94 IN VARCHAR2
176109 --Accounted Amount
176110 , p_source_95 IN NUMBER
176111 --Accounting Line Type
176112 , p_source_97 IN NUMBER
176113 )
176114 IS
176115
176116 l_component_type VARCHAR2(80);
176117 l_component_code VARCHAR2(30);
176118 l_component_type_code VARCHAR2(1);
176119 l_component_appl_id INTEGER;
176120 l_amb_context_code VARCHAR2(30);
176121 l_entity_code VARCHAR2(30);
176122 l_event_class_code VARCHAR2(30);
176123 l_ae_header_id NUMBER;
176124 l_event_type_code VARCHAR2(30);
176125 l_line_definition_code VARCHAR2(30);
176126 l_line_definition_owner_code VARCHAR2(1);
176127 --
176128 -- adr variables
176129 l_segment VARCHAR2(30);
176130 l_ccid NUMBER;
176131 l_adr_transaction_coa_id NUMBER;
176132 l_adr_accounting_coa_id NUMBER;
176133 l_adr_flexfield_segment_code VARCHAR2(30);
176134 l_adr_flex_value_set_id NUMBER;
176135 l_adr_value_type_code VARCHAR2(30);
176136 l_adr_value_combination_id NUMBER;
176137 l_adr_value_segment_code VARCHAR2(30);
176138
176139 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
176140 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
176141 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
176142 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
176143
176144 -- 4262811 Variables ------------------------------------------------------------------------------------------
176145 l_entered_amt_idx NUMBER;
176146 l_accted_amt_idx NUMBER;
176147 l_acc_rev_flag VARCHAR2(1);
176148 l_accrual_line_num NUMBER;
176149 l_tmp_amt NUMBER;
176150 l_acc_rev_natural_side_code VARCHAR2(1);
176151
176152 l_num_entries NUMBER;
176153 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
176154 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
176155 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
176156 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
176157 l_recog_line_1 NUMBER;
176158 l_recog_line_2 NUMBER;
176159
176160 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
176161 l_bflow_applied_to_amt NUMBER; -- 5132302
176162 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
176163
176164 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
176165
176166 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
176167 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
176168
176169 ---------------------------------------------------------------------------------------------------------------
176170
176171
176172 --
176173 -- bulk performance
176174 --
176175 l_balance_type_code VARCHAR2(1);
176176 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
176177 l_log_module VARCHAR2(240);
176178
176179 --
176180 -- Upgrade strategy
176181 --
176182 l_actual_upg_option VARCHAR2(1);
176183 l_enc_upg_option VARCHAR2(1);
176184
176185 --
176186 BEGIN
176187 --
176188 IF g_log_enabled THEN
176189 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_325';
176190 END IF;
176191 --
176192 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
176193
176194 trace
176195 (p_msg => 'BEGIN of AcctLineType_325'
176196 ,p_level => C_LEVEL_PROCEDURE
176197 ,p_module => l_log_module);
176198
176199 END IF;
176200 --
176201 l_component_type := 'AMB_JLT';
176202 l_component_code := 'OFFSET';
176203 l_component_type_code := 'S';
176204 l_component_appl_id := 707;
176205 l_amb_context_code := 'DEFAULT';
176206 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
176207 l_event_class_code := 'USER_DEFINE';
176208 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_TP';
176209 l_line_definition_owner_code := 'S';
176210 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
176211 --
176212 l_balance_type_code := 'A';
176213 l_segment := NULL;
176214 l_ccid := NULL;
176215 l_adr_transaction_coa_id := NULL;
176216 l_adr_accounting_coa_id := NULL;
176217 l_adr_flexfield_segment_code := NULL;
176218 l_adr_flex_value_set_id := NULL;
176219 l_adr_value_type_code := NULL;
176220 l_adr_value_combination_id := NULL;
176221 l_adr_value_segment_code := NULL;
176222
176223 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
176224 l_bflow_class_code := ''; -- 4219869 Business Flow
176225 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
176226 l_budgetary_control_flag := 'N';
176227
176228 l_bflow_applied_to_amt_idx := NULL; -- 5132302
176229 l_bflow_applied_to_amt := NULL; -- 5132302
176230 l_entered_amt_idx := NULL; -- 4262811
176231 l_accted_amt_idx := NULL; -- 4262811
176232 l_acc_rev_flag := NULL; -- 4262811
176233 l_accrual_line_num := NULL; -- 4262811
176234 l_tmp_amt := NULL; -- 4262811
176235 --
176236
176237 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
176238 l_balance_type_code <> 'B' THEN
176239 IF NVL(p_source_97,9E125) = 2
176240 THEN
176241
176242 --
176243 XLA_AE_LINES_PKG.SetNewLine;
176244
176245 p_balance_type_code := l_balance_type_code;
176246 -- set the flag so later we will know whether the gain loss line needs to be created
176247
176248 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
176249 p_actual_flag :='A';
176250 END IF;
176251
176252 --
176253 -- bulk performance
176254 --
176255 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
176256 p_header_num => 0); -- 4262811
176257 --
176258 -- set accounting line options
176259 --
176260 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
176261 p_natural_side_code => 'D'
176262 , p_gain_or_loss_flag => 'N'
176263 , p_gl_transfer_mode_code => 'S'
176264 , p_acct_entry_type_code => 'A'
176265 , p_switch_side_flag => 'Y'
176266 , p_merge_duplicate_code => 'N'
176267 );
176268 --
176269 l_acc_rev_natural_side_code := 'C'; -- 4262811
176270 --
176271 --
176272 -- set accounting line type info
176273 --
176274 xla_ae_lines_pkg.SetAcctLineType
176275 (p_component_type => l_component_type
176276 ,p_event_type_code => l_event_type_code
176277 ,p_line_definition_owner_code => l_line_definition_owner_code
176278 ,p_line_definition_code => l_line_definition_code
176279 ,p_accounting_line_code => l_component_code
176280 ,p_accounting_line_type_code => l_component_type_code
176281 ,p_accounting_line_appl_id => l_component_appl_id
176282 ,p_amb_context_code => l_amb_context_code
176283 ,p_entity_code => l_entity_code
176284 ,p_event_class_code => l_event_class_code);
176285 --
176286 -- set accounting class
176287 --
176288 xla_ae_lines_pkg.SetAcctClass(
176289 p_accounting_class_code => 'OFFSET'
176290 , p_ae_header_id => l_ae_header_id
176291 );
176292
176293 --
176294 -- set rounding class
176295 --
176296 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
176297 'OFFSET';
176298
176299 --
176300 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
176301 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
176302 --
176303 -- bulk performance
176304 --
176305 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
176306
176307 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
176308 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
176309
176310 -- 4955764
176311 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
176312 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
176313
176314 -- 4458381 Public Sector Enh
176315
176316 --
176317 -- set accounting attributes for the line type
176318 --
176319 l_entered_amt_idx := 3;
176320 l_accted_amt_idx := 8;
176321 l_bflow_applied_to_amt_idx := NULL; -- 5132302
176322 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
176323 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
176324 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
176325 l_rec_acct_attrs.array_char_value(2) := p_source_85;
176326 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
176327 l_rec_acct_attrs.array_num_value(3) := p_source_91;
176328 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
176329 l_rec_acct_attrs.array_char_value(4) := p_source_88;
176330 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
176331 l_rec_acct_attrs.array_date_value(5) := p_source_92;
176332 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
176333 l_rec_acct_attrs.array_num_value(6) := p_source_93;
176334 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
176335 l_rec_acct_attrs.array_char_value(7) := p_source_94;
176336 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
176337 l_rec_acct_attrs.array_num_value(8) := p_source_95;
176338
176339 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
176340 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
176341
176342 ---------------------------------------------------------------------------------------------------------------
176343 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
176344 ---------------------------------------------------------------------------------------------------------------
176345 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
176346
176347 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
176348 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
176349
176350 IF xla_accounting_cache_pkg.GetValueChar
176351 (p_source_code => 'LEDGER_CATEGORY_CODE'
176352 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
176353 AND l_bflow_method_code = 'PRIOR_ENTRY'
176354 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
176355 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
176356 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
176357 )
176358 THEN
176359 xla_ae_lines_pkg.BflowUpgEntry
176360 (p_business_method_code => l_bflow_method_code
176361 ,p_business_class_code => l_bflow_class_code
176362 ,p_balance_type => l_balance_type_code);
176363 ELSE
176364 NULL;
176365 -- No business flow processing for business flow method of NONE.
176366 END IF;
176367
176368 --
176369 -- call analytical criteria
176370 --
176371
176372 --
176373 -- call description
176374 --
176375
176376 xla_ae_lines_pkg.SetLineDescription(
176377 p_ae_header_id => l_ae_header_id
176378 ,p_description => Description_1 (
176379 p_application_id => p_application_id
176380 , p_ae_header_id => l_ae_header_id
176381 , p_source_1 => p_source_1
176382 , p_source_2 => p_source_2
176383 , p_source_3 => p_source_3
176384 , p_source_4 => p_source_4
176385 , p_source_5 => p_source_5
176386 )
176387 );
176388
176389
176390 --
176391 -- call ADRs
176392 -- Bug 4922099
176393 --
176394 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
176395 (NVL(l_actual_upg_option, 'N') = 'O') OR
176396 (NVL(l_enc_upg_option, 'N') = 'O')
176397 )
176398 THEN
176399 NULL;
176400 --
176401 --
176402
176403 l_ccid := AcctDerRule_6(
176404 p_application_id => p_application_id
176405 , p_ae_header_id => l_ae_header_id
176406 , p_source_11 => p_source_11
176407 , x_transaction_coa_id => l_adr_transaction_coa_id
176408 , x_accounting_coa_id => l_adr_accounting_coa_id
176409 , x_value_type_code => l_adr_value_type_code
176410 , p_side => 'NA'
176411 );
176412
176413 xla_ae_lines_pkg.set_ccid(
176414 p_code_combination_id => l_ccid
176415 , p_value_type_code => l_adr_value_type_code
176416 , p_transaction_coa_id => l_adr_transaction_coa_id
176417 , p_accounting_coa_id => l_adr_accounting_coa_id
176418 , p_adr_code => 'CST_DEFAULT'
176419 , p_adr_type_code => 'S'
176420 , p_component_type => l_component_type
176421 , p_component_code => l_component_code
176422 , p_component_type_code => l_component_type_code
176423 , p_component_appl_id => l_component_appl_id
176424 , p_amb_context_code => l_amb_context_code
176425 , p_side => 'NA'
176426 );
176427
176428
176429 --
176430 --
176431 END IF;
176432 --
176433 -- Bug 4922099
176434 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
176435 (NVL(l_enc_upg_option, 'N') = 'O')
176436 ) AND
176437 (l_bflow_method_code = 'PRIOR_ENTRY')
176438 )
176439 THEN
176440 IF
176441 --
176442 1 = 2
176443 --
176444 THEN
176445 xla_accounting_err_pkg.build_message
176446 (p_appli_s_name => 'XLA'
176447 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
176448 ,p_token_1 => 'LINE_NUMBER'
176449 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
176450 ,p_token_2 => 'LINE_TYPE_NAME'
176451 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
176452 l_component_type
176453 ,l_component_code
176454 ,l_component_type_code
176455 ,l_component_appl_id
176456 ,l_amb_context_code
176457 ,l_entity_code
176458 ,l_event_class_code
176459 )
176460 ,p_token_3 => 'OWNER'
176461 ,p_value_3 => xla_lookups_pkg.get_meaning(
176462 p_lookup_type => 'XLA_OWNER_TYPE'
176463 ,p_lookup_code => l_component_type_code
176464 )
176465 ,p_token_4 => 'PRODUCT_NAME'
176466 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
176467 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
176468 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
176469 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
176470 ,p_ae_header_id => NULL
176471 );
176472
176473 IF (C_LEVEL_ERROR>= g_log_level) THEN
176474 trace
176475 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
176476 ,p_level => C_LEVEL_ERROR
176477 ,p_module => l_log_module);
176478 END IF;
176479 END IF;
176480 END IF;
176481 --
176482 --
176483 ------------------------------------------------------------------------------------------------
176484 -- 4219869 Business Flow
176485 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
176486 -- Prior Entry. Currently, the following code is always generated.
176487 ------------------------------------------------------------------------------------------------
176488 XLA_AE_LINES_PKG.ValidateCurrentLine;
176489
176490 ------------------------------------------------------------------------------------
176491 -- 4219869 Business Flow
176492 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
176493 ------------------------------------------------------------------------------------
176494 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
176495
176496 ----------------------------------------------------------------------------------
176497 -- 4219869 Business Flow
176498 -- Update journal entry status -- Need to generate this within IF <condition>
176499 ----------------------------------------------------------------------------------
176500 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
176501 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
176502 ,p_balance_type_code => l_balance_type_code
176503 );
176504
176505 -------------------------------------------------------------------------------------------
176506 -- 4262811 - Generate the Accrual Reversal lines
176507 -------------------------------------------------------------------------------------------
176508 BEGIN
176509 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
176510 (g_array_event(p_event_id).array_value_num('header_index'));
176511 IF l_acc_rev_flag IS NULL THEN
176512 l_acc_rev_flag := 'N';
176513 END IF;
176514 EXCEPTION
176515 WHEN OTHERS THEN
176516 l_acc_rev_flag := 'N';
176517 END;
176518 --
176519 IF (l_acc_rev_flag = 'Y') THEN
176520
176521 -- 4645092 ------------------------------------------------------------------------------
176522 -- To allow MPA report to determine if it should generate report process
176523 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
176524 ------------------------------------------------------------------------------------------
176525
176526 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
176527 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
176528 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
176529 -- call ADRs
176530 -- Bug 4922099
176531 --
176532 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
176533 (NVL(l_actual_upg_option, 'N') = 'O') OR
176534 (NVL(l_enc_upg_option, 'N') = 'O')
176535 )
176536 THEN
176537 NULL;
176538 --
176539 --
176540
176541 l_ccid := AcctDerRule_6(
176542 p_application_id => p_application_id
176543 , p_ae_header_id => l_ae_header_id
176544 , p_source_11 => p_source_11
176545 , x_transaction_coa_id => l_adr_transaction_coa_id
176546 , x_accounting_coa_id => l_adr_accounting_coa_id
176547 , x_value_type_code => l_adr_value_type_code
176548 , p_side => 'NA'
176549 );
176550
176551 xla_ae_lines_pkg.set_ccid(
176552 p_code_combination_id => l_ccid
176553 , p_value_type_code => l_adr_value_type_code
176554 , p_transaction_coa_id => l_adr_transaction_coa_id
176555 , p_accounting_coa_id => l_adr_accounting_coa_id
176556 , p_adr_code => 'CST_DEFAULT'
176557 , p_adr_type_code => 'S'
176558 , p_component_type => l_component_type
176559 , p_component_code => l_component_code
176560 , p_component_type_code => l_component_type_code
176561 , p_component_appl_id => l_component_appl_id
176562 , p_amb_context_code => l_amb_context_code
176563 , p_side => 'NA'
176564 );
176565
176566
176567 --
176568 --
176569 END IF;
176570
176571 --
176572 -- Update the line information that should be overwritten
176573 --
176574 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
176575 p_header_num => 1);
176576 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
176577
176578 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
176579
176580 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
176581 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
176582 END IF;
176583
176584 --
176585 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
176586 --
176587 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
176588 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
176589 ELSE
176590 ---------------------------------------------------------------------------------------------------
176591 -- 4262811a Switch Sign
176592 ---------------------------------------------------------------------------------------------------
176593 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
176594 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
176595 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176596 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
176597 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176598 -- 5132302
176599 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
176600 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
176601
176602 END IF;
176603
176604 -- 4955764
176605 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
176606 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
176607
176608
176609 XLA_AE_LINES_PKG.ValidateCurrentLine;
176610 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
176611
176612 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
176613 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
176614 ,p_balance_type_code => l_balance_type_code);
176615
176616 END IF;
176617
176618 -----------------------------------------------------------------------------------------
176619 -- 4262811 Multiperiod Accounting
176620 -----------------------------------------------------------------------------------------
176621 -- No MPA option is assigned.
176622
176623
176624 END IF;
176625 END IF;
176626 --
176627
176628 --
176629 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
176630 trace
176631 (p_msg => 'END of AcctLineType_325'
176632 ,p_level => C_LEVEL_PROCEDURE
176633 ,p_module => l_log_module);
176634 END IF;
176635 --
176636 EXCEPTION
176637 WHEN xla_exceptions_pkg.application_exception THEN
176638 RAISE;
176639 WHEN OTHERS THEN
176640 xla_exceptions_pkg.raise_message
176641 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_325');
176642 END AcctLineType_325;
176643 --
176644
176645 ---------------------------------------
176646 --
176647 -- PRIVATE FUNCTION
176648 -- AcctLineType_326
176649 --
176650 ---------------------------------------
176651 PROCEDURE AcctLineType_326 (
176652 p_application_id IN NUMBER
176653 ,p_event_id IN NUMBER
176654 ,p_calculate_acctd_flag IN VARCHAR2
176655 ,p_calculate_g_l_flag IN VARCHAR2
176656 ,p_actual_flag IN OUT VARCHAR2
176657 ,p_balance_type_code OUT VARCHAR2
176658 ,p_gain_or_loss_ref OUT VARCHAR2
176659
176660 --TRANSACTION_ID
176661 , p_source_1 IN NUMBER
176662 --Item Concatenated Segments
176663 , p_source_2 IN VARCHAR2
176664 --Transaction Quantity
176665 , p_source_3 IN NUMBER
176666 --Transaction Unit of Measure Code
176667 , p_source_4 IN VARCHAR2
176668 --Inventory Transaction Type Description
176669 , p_source_5 IN VARCHAR2
176670 --Cost Management Default Account
176671 , p_source_11 IN NUMBER
176672 --DISTRIBUTION_IDENTIFIER
176673 , p_source_84 IN NUMBER
176674 --Distribution Type
176675 , p_source_85 IN VARCHAR2
176676 , p_source_85_meaning IN VARCHAR2
176677 --Entered Currency Code
176678 , p_source_88 IN VARCHAR2
176679 --Entered Amount
176680 , p_source_91 IN NUMBER
176681 --Currency Conversion Date
176682 , p_source_92 IN DATE
176683 --Currency Conversion Rate
176684 , p_source_93 IN NUMBER
176685 --Currency Conversion Type
176686 , p_source_94 IN VARCHAR2
176687 --Accounted Amount
176688 , p_source_95 IN NUMBER
176689 --Accounting Line Type
176690 , p_source_97 IN NUMBER
176691 )
176692 IS
176693
176694 l_component_type VARCHAR2(80);
176695 l_component_code VARCHAR2(30);
176696 l_component_type_code VARCHAR2(1);
176697 l_component_appl_id INTEGER;
176698 l_amb_context_code VARCHAR2(30);
176699 l_entity_code VARCHAR2(30);
176700 l_event_class_code VARCHAR2(30);
176701 l_ae_header_id NUMBER;
176702 l_event_type_code VARCHAR2(30);
176703 l_line_definition_code VARCHAR2(30);
176704 l_line_definition_owner_code VARCHAR2(1);
176705 --
176706 -- adr variables
176707 l_segment VARCHAR2(30);
176708 l_ccid NUMBER;
176709 l_adr_transaction_coa_id NUMBER;
176710 l_adr_accounting_coa_id NUMBER;
176711 l_adr_flexfield_segment_code VARCHAR2(30);
176712 l_adr_flex_value_set_id NUMBER;
176713 l_adr_value_type_code VARCHAR2(30);
176714 l_adr_value_combination_id NUMBER;
176715 l_adr_value_segment_code VARCHAR2(30);
176716
176717 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
176718 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
176719 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
176720 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
176721
176722 -- 4262811 Variables ------------------------------------------------------------------------------------------
176723 l_entered_amt_idx NUMBER;
176724 l_accted_amt_idx NUMBER;
176725 l_acc_rev_flag VARCHAR2(1);
176726 l_accrual_line_num NUMBER;
176727 l_tmp_amt NUMBER;
176728 l_acc_rev_natural_side_code VARCHAR2(1);
176729
176730 l_num_entries NUMBER;
176731 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
176732 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
176733 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
176734 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
176735 l_recog_line_1 NUMBER;
176736 l_recog_line_2 NUMBER;
176737
176738 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
176739 l_bflow_applied_to_amt NUMBER; -- 5132302
176740 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
176741
176742 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
176743
176744 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
176745 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
176746
176747 ---------------------------------------------------------------------------------------------------------------
176748
176749
176750 --
176751 -- bulk performance
176752 --
176753 l_balance_type_code VARCHAR2(1);
176754 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
176755 l_log_module VARCHAR2(240);
176756
176757 --
176758 -- Upgrade strategy
176759 --
176760 l_actual_upg_option VARCHAR2(1);
176761 l_enc_upg_option VARCHAR2(1);
176762
176763 --
176764 BEGIN
176765 --
176766 IF g_log_enabled THEN
176767 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_326';
176768 END IF;
176769 --
176770 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
176771
176772 trace
176773 (p_msg => 'BEGIN of AcctLineType_326'
176774 ,p_level => C_LEVEL_PROCEDURE
176775 ,p_module => l_log_module);
176776
176777 END IF;
176778 --
176779 l_component_type := 'AMB_JLT';
176780 l_component_code := 'OFFSET';
176781 l_component_type_code := 'S';
176782 l_component_appl_id := 707;
176783 l_amb_context_code := 'DEFAULT';
176784 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
176785 l_event_class_code := 'USER_DEFINE';
176786 l_event_type_code := 'UMISC_ISSUE';
176787 l_line_definition_owner_code := 'S';
176788 l_line_definition_code := 'PI_USER_ISSUE';
176789 --
176790 l_balance_type_code := 'A';
176791 l_segment := NULL;
176792 l_ccid := NULL;
176793 l_adr_transaction_coa_id := NULL;
176794 l_adr_accounting_coa_id := NULL;
176795 l_adr_flexfield_segment_code := NULL;
176796 l_adr_flex_value_set_id := NULL;
176797 l_adr_value_type_code := NULL;
176798 l_adr_value_combination_id := NULL;
176799 l_adr_value_segment_code := NULL;
176800
176801 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
176802 l_bflow_class_code := ''; -- 4219869 Business Flow
176803 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
176804 l_budgetary_control_flag := 'N';
176805
176806 l_bflow_applied_to_amt_idx := NULL; -- 5132302
176807 l_bflow_applied_to_amt := NULL; -- 5132302
176808 l_entered_amt_idx := NULL; -- 4262811
176809 l_accted_amt_idx := NULL; -- 4262811
176810 l_acc_rev_flag := NULL; -- 4262811
176811 l_accrual_line_num := NULL; -- 4262811
176812 l_tmp_amt := NULL; -- 4262811
176813 --
176814
176815 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
176816 l_balance_type_code <> 'B' THEN
176817 IF NVL(p_source_97,9E125) = 2
176818 THEN
176819
176820 --
176821 XLA_AE_LINES_PKG.SetNewLine;
176822
176823 p_balance_type_code := l_balance_type_code;
176824 -- set the flag so later we will know whether the gain loss line needs to be created
176825
176826 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
176827 p_actual_flag :='A';
176828 END IF;
176829
176830 --
176831 -- bulk performance
176832 --
176833 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
176834 p_header_num => 0); -- 4262811
176835 --
176836 -- set accounting line options
176837 --
176838 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
176839 p_natural_side_code => 'D'
176840 , p_gain_or_loss_flag => 'N'
176841 , p_gl_transfer_mode_code => 'S'
176842 , p_acct_entry_type_code => 'A'
176843 , p_switch_side_flag => 'Y'
176844 , p_merge_duplicate_code => 'N'
176845 );
176846 --
176847 l_acc_rev_natural_side_code := 'C'; -- 4262811
176848 --
176849 --
176850 -- set accounting line type info
176851 --
176852 xla_ae_lines_pkg.SetAcctLineType
176853 (p_component_type => l_component_type
176854 ,p_event_type_code => l_event_type_code
176855 ,p_line_definition_owner_code => l_line_definition_owner_code
176856 ,p_line_definition_code => l_line_definition_code
176857 ,p_accounting_line_code => l_component_code
176858 ,p_accounting_line_type_code => l_component_type_code
176859 ,p_accounting_line_appl_id => l_component_appl_id
176860 ,p_amb_context_code => l_amb_context_code
176861 ,p_entity_code => l_entity_code
176862 ,p_event_class_code => l_event_class_code);
176863 --
176864 -- set accounting class
176865 --
176866 xla_ae_lines_pkg.SetAcctClass(
176867 p_accounting_class_code => 'OFFSET'
176868 , p_ae_header_id => l_ae_header_id
176869 );
176870
176871 --
176872 -- set rounding class
176873 --
176874 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
176875 'OFFSET';
176876
176877 --
176878 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
176879 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
176880 --
176881 -- bulk performance
176882 --
176883 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
176884
176885 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
176886 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
176887
176888 -- 4955764
176889 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
176890 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
176891
176892 -- 4458381 Public Sector Enh
176893
176894 --
176895 -- set accounting attributes for the line type
176896 --
176897 l_entered_amt_idx := 3;
176898 l_accted_amt_idx := 8;
176899 l_bflow_applied_to_amt_idx := NULL; -- 5132302
176900 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
176901 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
176902 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
176903 l_rec_acct_attrs.array_char_value(2) := p_source_85;
176904 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
176905 l_rec_acct_attrs.array_num_value(3) := p_source_91;
176906 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
176907 l_rec_acct_attrs.array_char_value(4) := p_source_88;
176908 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
176909 l_rec_acct_attrs.array_date_value(5) := p_source_92;
176910 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
176911 l_rec_acct_attrs.array_num_value(6) := p_source_93;
176912 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
176913 l_rec_acct_attrs.array_char_value(7) := p_source_94;
176914 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
176915 l_rec_acct_attrs.array_num_value(8) := p_source_95;
176916
176917 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
176918 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
176919
176920 ---------------------------------------------------------------------------------------------------------------
176921 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
176922 ---------------------------------------------------------------------------------------------------------------
176923 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
176924
176925 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
176926 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
176927
176928 IF xla_accounting_cache_pkg.GetValueChar
176929 (p_source_code => 'LEDGER_CATEGORY_CODE'
176930 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
176931 AND l_bflow_method_code = 'PRIOR_ENTRY'
176932 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
176933 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
176934 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
176935 )
176936 THEN
176937 xla_ae_lines_pkg.BflowUpgEntry
176938 (p_business_method_code => l_bflow_method_code
176939 ,p_business_class_code => l_bflow_class_code
176940 ,p_balance_type => l_balance_type_code);
176941 ELSE
176942 NULL;
176943 -- No business flow processing for business flow method of NONE.
176944 END IF;
176945
176946 --
176947 -- call analytical criteria
176948 --
176949
176950 --
176951 -- call description
176952 --
176953
176954 xla_ae_lines_pkg.SetLineDescription(
176955 p_ae_header_id => l_ae_header_id
176956 ,p_description => Description_1 (
176957 p_application_id => p_application_id
176958 , p_ae_header_id => l_ae_header_id
176959 , p_source_1 => p_source_1
176960 , p_source_2 => p_source_2
176961 , p_source_3 => p_source_3
176962 , p_source_4 => p_source_4
176963 , p_source_5 => p_source_5
176964 )
176965 );
176966
176967
176968 --
176969 -- call ADRs
176970 -- Bug 4922099
176971 --
176972 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
176973 (NVL(l_actual_upg_option, 'N') = 'O') OR
176974 (NVL(l_enc_upg_option, 'N') = 'O')
176975 )
176976 THEN
176977 NULL;
176978 --
176979 --
176980
176981 l_ccid := AcctDerRule_6(
176982 p_application_id => p_application_id
176983 , p_ae_header_id => l_ae_header_id
176984 , p_source_11 => p_source_11
176985 , x_transaction_coa_id => l_adr_transaction_coa_id
176986 , x_accounting_coa_id => l_adr_accounting_coa_id
176987 , x_value_type_code => l_adr_value_type_code
176988 , p_side => 'NA'
176989 );
176990
176991 xla_ae_lines_pkg.set_ccid(
176992 p_code_combination_id => l_ccid
176993 , p_value_type_code => l_adr_value_type_code
176994 , p_transaction_coa_id => l_adr_transaction_coa_id
176995 , p_accounting_coa_id => l_adr_accounting_coa_id
176996 , p_adr_code => 'CST_DEFAULT'
176997 , p_adr_type_code => 'S'
176998 , p_component_type => l_component_type
176999 , p_component_code => l_component_code
177000 , p_component_type_code => l_component_type_code
177001 , p_component_appl_id => l_component_appl_id
177002 , p_amb_context_code => l_amb_context_code
177003 , p_side => 'NA'
177004 );
177005
177006
177007 --
177008 --
177009 END IF;
177010 --
177011 -- Bug 4922099
177012 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
177013 (NVL(l_enc_upg_option, 'N') = 'O')
177014 ) AND
177015 (l_bflow_method_code = 'PRIOR_ENTRY')
177016 )
177017 THEN
177018 IF
177019 --
177020 1 = 2
177021 --
177022 THEN
177023 xla_accounting_err_pkg.build_message
177024 (p_appli_s_name => 'XLA'
177025 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
177026 ,p_token_1 => 'LINE_NUMBER'
177027 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
177028 ,p_token_2 => 'LINE_TYPE_NAME'
177029 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
177030 l_component_type
177031 ,l_component_code
177032 ,l_component_type_code
177033 ,l_component_appl_id
177034 ,l_amb_context_code
177035 ,l_entity_code
177036 ,l_event_class_code
177037 )
177038 ,p_token_3 => 'OWNER'
177039 ,p_value_3 => xla_lookups_pkg.get_meaning(
177040 p_lookup_type => 'XLA_OWNER_TYPE'
177041 ,p_lookup_code => l_component_type_code
177042 )
177043 ,p_token_4 => 'PRODUCT_NAME'
177044 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
177045 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
177046 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
177047 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
177048 ,p_ae_header_id => NULL
177049 );
177050
177051 IF (C_LEVEL_ERROR>= g_log_level) THEN
177052 trace
177053 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
177054 ,p_level => C_LEVEL_ERROR
177055 ,p_module => l_log_module);
177056 END IF;
177057 END IF;
177058 END IF;
177059 --
177060 --
177061 ------------------------------------------------------------------------------------------------
177062 -- 4219869 Business Flow
177063 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
177064 -- Prior Entry. Currently, the following code is always generated.
177065 ------------------------------------------------------------------------------------------------
177066 XLA_AE_LINES_PKG.ValidateCurrentLine;
177067
177068 ------------------------------------------------------------------------------------
177069 -- 4219869 Business Flow
177070 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
177071 ------------------------------------------------------------------------------------
177072 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
177073
177074 ----------------------------------------------------------------------------------
177075 -- 4219869 Business Flow
177076 -- Update journal entry status -- Need to generate this within IF <condition>
177077 ----------------------------------------------------------------------------------
177078 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
177079 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
177080 ,p_balance_type_code => l_balance_type_code
177081 );
177082
177083 -------------------------------------------------------------------------------------------
177084 -- 4262811 - Generate the Accrual Reversal lines
177085 -------------------------------------------------------------------------------------------
177086 BEGIN
177087 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
177088 (g_array_event(p_event_id).array_value_num('header_index'));
177089 IF l_acc_rev_flag IS NULL THEN
177090 l_acc_rev_flag := 'N';
177091 END IF;
177092 EXCEPTION
177093 WHEN OTHERS THEN
177094 l_acc_rev_flag := 'N';
177095 END;
177096 --
177097 IF (l_acc_rev_flag = 'Y') THEN
177098
177099 -- 4645092 ------------------------------------------------------------------------------
177100 -- To allow MPA report to determine if it should generate report process
177101 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
177102 ------------------------------------------------------------------------------------------
177103
177104 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
177105 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
177106 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
177107 -- call ADRs
177108 -- Bug 4922099
177109 --
177110 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
177111 (NVL(l_actual_upg_option, 'N') = 'O') OR
177112 (NVL(l_enc_upg_option, 'N') = 'O')
177113 )
177114 THEN
177115 NULL;
177116 --
177117 --
177118
177119 l_ccid := AcctDerRule_6(
177120 p_application_id => p_application_id
177121 , p_ae_header_id => l_ae_header_id
177122 , p_source_11 => p_source_11
177123 , x_transaction_coa_id => l_adr_transaction_coa_id
177124 , x_accounting_coa_id => l_adr_accounting_coa_id
177125 , x_value_type_code => l_adr_value_type_code
177126 , p_side => 'NA'
177127 );
177128
177129 xla_ae_lines_pkg.set_ccid(
177130 p_code_combination_id => l_ccid
177131 , p_value_type_code => l_adr_value_type_code
177132 , p_transaction_coa_id => l_adr_transaction_coa_id
177133 , p_accounting_coa_id => l_adr_accounting_coa_id
177134 , p_adr_code => 'CST_DEFAULT'
177135 , p_adr_type_code => 'S'
177136 , p_component_type => l_component_type
177137 , p_component_code => l_component_code
177138 , p_component_type_code => l_component_type_code
177139 , p_component_appl_id => l_component_appl_id
177140 , p_amb_context_code => l_amb_context_code
177141 , p_side => 'NA'
177142 );
177143
177144
177145 --
177146 --
177147 END IF;
177148
177149 --
177150 -- Update the line information that should be overwritten
177151 --
177152 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
177153 p_header_num => 1);
177154 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
177155
177156 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
177157
177158 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
177159 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
177160 END IF;
177161
177162 --
177163 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
177164 --
177165 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
177166 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
177167 ELSE
177168 ---------------------------------------------------------------------------------------------------
177169 -- 4262811a Switch Sign
177170 ---------------------------------------------------------------------------------------------------
177171 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
177172 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
177173 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177174 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
177175 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177176 -- 5132302
177177 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
177178 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177179
177180 END IF;
177181
177182 -- 4955764
177183 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
177184 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
177185
177186
177187 XLA_AE_LINES_PKG.ValidateCurrentLine;
177188 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
177189
177190 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
177191 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
177192 ,p_balance_type_code => l_balance_type_code);
177193
177194 END IF;
177195
177196 -----------------------------------------------------------------------------------------
177197 -- 4262811 Multiperiod Accounting
177198 -----------------------------------------------------------------------------------------
177199 -- No MPA option is assigned.
177200
177201
177202 END IF;
177203 END IF;
177204 --
177205
177206 --
177207 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
177208 trace
177209 (p_msg => 'END of AcctLineType_326'
177210 ,p_level => C_LEVEL_PROCEDURE
177211 ,p_module => l_log_module);
177212 END IF;
177213 --
177214 EXCEPTION
177215 WHEN xla_exceptions_pkg.application_exception THEN
177216 RAISE;
177217 WHEN OTHERS THEN
177218 xla_exceptions_pkg.raise_message
177219 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_326');
177220 END AcctLineType_326;
177221 --
177222
177223 ---------------------------------------
177224 --
177225 -- PRIVATE FUNCTION
177226 -- AcctLineType_327
177227 --
177228 ---------------------------------------
177229 PROCEDURE AcctLineType_327 (
177230 p_application_id IN NUMBER
177231 ,p_event_id IN NUMBER
177232 ,p_calculate_acctd_flag IN VARCHAR2
177233 ,p_calculate_g_l_flag IN VARCHAR2
177234 ,p_actual_flag IN OUT VARCHAR2
177235 ,p_balance_type_code OUT VARCHAR2
177236 ,p_gain_or_loss_ref OUT VARCHAR2
177237
177238 --TRANSACTION_ID
177239 , p_source_1 IN NUMBER
177240 --Item Concatenated Segments
177241 , p_source_2 IN VARCHAR2
177242 --Transaction Quantity
177243 , p_source_3 IN NUMBER
177244 --Transaction Unit of Measure Code
177245 , p_source_4 IN VARCHAR2
177246 --Inventory Transaction Type Description
177247 , p_source_5 IN VARCHAR2
177248 --Product Line Accounting Category Expense Account
177249 , p_source_24 IN NUMBER
177250 --DISTRIBUTION_IDENTIFIER
177251 , p_source_84 IN NUMBER
177252 --Distribution Type
177253 , p_source_85 IN VARCHAR2
177254 , p_source_85_meaning IN VARCHAR2
177255 --Entered Currency Code
177256 , p_source_88 IN VARCHAR2
177257 --Entered Amount
177258 , p_source_91 IN NUMBER
177259 --Currency Conversion Date
177260 , p_source_92 IN DATE
177261 --Currency Conversion Rate
177262 , p_source_93 IN NUMBER
177263 --Currency Conversion Type
177264 , p_source_94 IN VARCHAR2
177265 --Accounted Amount
177266 , p_source_95 IN NUMBER
177267 --Accounting Line Type
177268 , p_source_97 IN NUMBER
177269 )
177270 IS
177271
177272 l_component_type VARCHAR2(80);
177273 l_component_code VARCHAR2(30);
177274 l_component_type_code VARCHAR2(1);
177275 l_component_appl_id INTEGER;
177276 l_amb_context_code VARCHAR2(30);
177277 l_entity_code VARCHAR2(30);
177278 l_event_class_code VARCHAR2(30);
177279 l_ae_header_id NUMBER;
177280 l_event_type_code VARCHAR2(30);
177281 l_line_definition_code VARCHAR2(30);
177282 l_line_definition_owner_code VARCHAR2(1);
177283 --
177284 -- adr variables
177285 l_segment VARCHAR2(30);
177286 l_ccid NUMBER;
177287 l_adr_transaction_coa_id NUMBER;
177288 l_adr_accounting_coa_id NUMBER;
177289 l_adr_flexfield_segment_code VARCHAR2(30);
177290 l_adr_flex_value_set_id NUMBER;
177291 l_adr_value_type_code VARCHAR2(30);
177292 l_adr_value_combination_id NUMBER;
177293 l_adr_value_segment_code VARCHAR2(30);
177294
177295 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
177296 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
177297 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
177298 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
177299
177300 -- 4262811 Variables ------------------------------------------------------------------------------------------
177301 l_entered_amt_idx NUMBER;
177302 l_accted_amt_idx NUMBER;
177303 l_acc_rev_flag VARCHAR2(1);
177304 l_accrual_line_num NUMBER;
177305 l_tmp_amt NUMBER;
177306 l_acc_rev_natural_side_code VARCHAR2(1);
177307
177308 l_num_entries NUMBER;
177309 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
177310 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
177311 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
177312 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
177313 l_recog_line_1 NUMBER;
177314 l_recog_line_2 NUMBER;
177315
177316 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
177317 l_bflow_applied_to_amt NUMBER; -- 5132302
177318 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
177319
177320 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
177321
177322 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
177323 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
177324
177325 ---------------------------------------------------------------------------------------------------------------
177326
177327
177328 --
177329 -- bulk performance
177330 --
177331 l_balance_type_code VARCHAR2(1);
177332 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
177333 l_log_module VARCHAR2(240);
177334
177335 --
177336 -- Upgrade strategy
177337 --
177338 l_actual_upg_option VARCHAR2(1);
177339 l_enc_upg_option VARCHAR2(1);
177340
177341 --
177342 BEGIN
177343 --
177344 IF g_log_enabled THEN
177345 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_327';
177346 END IF;
177347 --
177348 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
177349
177350 trace
177351 (p_msg => 'BEGIN of AcctLineType_327'
177352 ,p_level => C_LEVEL_PROCEDURE
177353 ,p_module => l_log_module);
177354
177355 END IF;
177356 --
177357 l_component_type := 'AMB_JLT';
177358 l_component_code := 'OFFSET';
177359 l_component_type_code := 'S';
177360 l_component_appl_id := 707;
177361 l_amb_context_code := 'DEFAULT';
177362 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
177363 l_event_class_code := 'WIP_MTL';
177364 l_event_type_code := 'WIP_COMP_ISSUE';
177365 l_line_definition_owner_code := 'S';
177366 l_line_definition_code := 'PI_WIP_COMP_ISSUE';
177367 --
177368 l_balance_type_code := 'A';
177369 l_segment := NULL;
177370 l_ccid := NULL;
177371 l_adr_transaction_coa_id := NULL;
177372 l_adr_accounting_coa_id := NULL;
177373 l_adr_flexfield_segment_code := NULL;
177374 l_adr_flex_value_set_id := NULL;
177375 l_adr_value_type_code := NULL;
177376 l_adr_value_combination_id := NULL;
177377 l_adr_value_segment_code := NULL;
177378
177379 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
177380 l_bflow_class_code := ''; -- 4219869 Business Flow
177381 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
177382 l_budgetary_control_flag := 'N';
177383
177384 l_bflow_applied_to_amt_idx := NULL; -- 5132302
177385 l_bflow_applied_to_amt := NULL; -- 5132302
177386 l_entered_amt_idx := NULL; -- 4262811
177387 l_accted_amt_idx := NULL; -- 4262811
177388 l_acc_rev_flag := NULL; -- 4262811
177389 l_accrual_line_num := NULL; -- 4262811
177390 l_tmp_amt := NULL; -- 4262811
177391 --
177392
177393 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
177394 l_balance_type_code <> 'B' THEN
177395 IF NVL(p_source_97,9E125) = 2
177396 THEN
177397
177398 --
177399 XLA_AE_LINES_PKG.SetNewLine;
177400
177401 p_balance_type_code := l_balance_type_code;
177402 -- set the flag so later we will know whether the gain loss line needs to be created
177403
177404 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
177405 p_actual_flag :='A';
177406 END IF;
177407
177408 --
177409 -- bulk performance
177410 --
177411 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
177412 p_header_num => 0); -- 4262811
177413 --
177414 -- set accounting line options
177415 --
177416 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
177417 p_natural_side_code => 'D'
177418 , p_gain_or_loss_flag => 'N'
177419 , p_gl_transfer_mode_code => 'S'
177420 , p_acct_entry_type_code => 'A'
177421 , p_switch_side_flag => 'Y'
177422 , p_merge_duplicate_code => 'N'
177423 );
177424 --
177425 l_acc_rev_natural_side_code := 'C'; -- 4262811
177426 --
177427 --
177428 -- set accounting line type info
177429 --
177430 xla_ae_lines_pkg.SetAcctLineType
177431 (p_component_type => l_component_type
177432 ,p_event_type_code => l_event_type_code
177433 ,p_line_definition_owner_code => l_line_definition_owner_code
177434 ,p_line_definition_code => l_line_definition_code
177435 ,p_accounting_line_code => l_component_code
177436 ,p_accounting_line_type_code => l_component_type_code
177437 ,p_accounting_line_appl_id => l_component_appl_id
177438 ,p_amb_context_code => l_amb_context_code
177439 ,p_entity_code => l_entity_code
177440 ,p_event_class_code => l_event_class_code);
177441 --
177442 -- set accounting class
177443 --
177444 xla_ae_lines_pkg.SetAcctClass(
177445 p_accounting_class_code => 'OFFSET'
177446 , p_ae_header_id => l_ae_header_id
177447 );
177448
177449 --
177450 -- set rounding class
177451 --
177452 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
177453 'OFFSET';
177454
177455 --
177456 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
177457 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
177458 --
177459 -- bulk performance
177460 --
177461 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
177462
177463 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
177464 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
177465
177466 -- 4955764
177467 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
177468 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
177469
177470 -- 4458381 Public Sector Enh
177471
177472 --
177473 -- set accounting attributes for the line type
177474 --
177475 l_entered_amt_idx := 3;
177476 l_accted_amt_idx := 8;
177477 l_bflow_applied_to_amt_idx := NULL; -- 5132302
177478 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
177479 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
177480 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
177481 l_rec_acct_attrs.array_char_value(2) := p_source_85;
177482 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
177483 l_rec_acct_attrs.array_num_value(3) := p_source_91;
177484 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
177485 l_rec_acct_attrs.array_char_value(4) := p_source_88;
177486 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
177487 l_rec_acct_attrs.array_date_value(5) := p_source_92;
177488 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
177489 l_rec_acct_attrs.array_num_value(6) := p_source_93;
177490 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
177491 l_rec_acct_attrs.array_char_value(7) := p_source_94;
177492 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
177493 l_rec_acct_attrs.array_num_value(8) := p_source_95;
177494
177495 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
177496 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
177497
177498 ---------------------------------------------------------------------------------------------------------------
177499 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
177500 ---------------------------------------------------------------------------------------------------------------
177501 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
177502
177503 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
177504 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
177505
177506 IF xla_accounting_cache_pkg.GetValueChar
177507 (p_source_code => 'LEDGER_CATEGORY_CODE'
177508 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
177509 AND l_bflow_method_code = 'PRIOR_ENTRY'
177510 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
177511 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
177512 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
177513 )
177514 THEN
177515 xla_ae_lines_pkg.BflowUpgEntry
177516 (p_business_method_code => l_bflow_method_code
177517 ,p_business_class_code => l_bflow_class_code
177518 ,p_balance_type => l_balance_type_code);
177519 ELSE
177520 NULL;
177521 -- No business flow processing for business flow method of NONE.
177522 END IF;
177523
177524 --
177525 -- call analytical criteria
177526 --
177527
177528 --
177529 -- call description
177530 --
177531
177532 xla_ae_lines_pkg.SetLineDescription(
177533 p_ae_header_id => l_ae_header_id
177534 ,p_description => Description_1 (
177535 p_application_id => p_application_id
177536 , p_ae_header_id => l_ae_header_id
177537 , p_source_1 => p_source_1
177538 , p_source_2 => p_source_2
177539 , p_source_3 => p_source_3
177540 , p_source_4 => p_source_4
177541 , p_source_5 => p_source_5
177542 )
177543 );
177544
177545
177546 --
177547 -- call ADRs
177548 -- Bug 4922099
177549 --
177550 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
177551 (NVL(l_actual_upg_option, 'N') = 'O') OR
177552 (NVL(l_enc_upg_option, 'N') = 'O')
177553 )
177554 THEN
177555 NULL;
177556 --
177557 --
177558
177559 l_ccid := AcctDerRule_13(
177560 p_application_id => p_application_id
177561 , p_ae_header_id => l_ae_header_id
177562 , p_source_24 => p_source_24
177563 , x_transaction_coa_id => l_adr_transaction_coa_id
177564 , x_accounting_coa_id => l_adr_accounting_coa_id
177565 , x_value_type_code => l_adr_value_type_code
177566 , p_side => 'NA'
177567 );
177568
177569 xla_ae_lines_pkg.set_ccid(
177570 p_code_combination_id => l_ccid
177571 , p_value_type_code => l_adr_value_type_code
177572 , p_transaction_coa_id => l_adr_transaction_coa_id
177573 , p_accounting_coa_id => l_adr_accounting_coa_id
177574 , p_adr_code => 'PI_CATEGORY_EXPENSE'
177575 , p_adr_type_code => 'S'
177576 , p_component_type => l_component_type
177577 , p_component_code => l_component_code
177578 , p_component_type_code => l_component_type_code
177579 , p_component_appl_id => l_component_appl_id
177580 , p_amb_context_code => l_amb_context_code
177581 , p_side => 'NA'
177582 );
177583
177584
177585 --
177586 --
177587 END IF;
177588 --
177589 -- Bug 4922099
177590 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
177591 (NVL(l_enc_upg_option, 'N') = 'O')
177592 ) AND
177593 (l_bflow_method_code = 'PRIOR_ENTRY')
177594 )
177595 THEN
177596 IF
177597 --
177598 1 = 2
177599 --
177600 THEN
177601 xla_accounting_err_pkg.build_message
177602 (p_appli_s_name => 'XLA'
177603 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
177604 ,p_token_1 => 'LINE_NUMBER'
177605 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
177606 ,p_token_2 => 'LINE_TYPE_NAME'
177607 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
177608 l_component_type
177609 ,l_component_code
177610 ,l_component_type_code
177611 ,l_component_appl_id
177612 ,l_amb_context_code
177613 ,l_entity_code
177614 ,l_event_class_code
177615 )
177616 ,p_token_3 => 'OWNER'
177617 ,p_value_3 => xla_lookups_pkg.get_meaning(
177618 p_lookup_type => 'XLA_OWNER_TYPE'
177619 ,p_lookup_code => l_component_type_code
177620 )
177621 ,p_token_4 => 'PRODUCT_NAME'
177622 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
177623 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
177624 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
177625 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
177626 ,p_ae_header_id => NULL
177627 );
177628
177629 IF (C_LEVEL_ERROR>= g_log_level) THEN
177630 trace
177631 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
177632 ,p_level => C_LEVEL_ERROR
177633 ,p_module => l_log_module);
177634 END IF;
177635 END IF;
177636 END IF;
177637 --
177638 --
177639 ------------------------------------------------------------------------------------------------
177640 -- 4219869 Business Flow
177641 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
177642 -- Prior Entry. Currently, the following code is always generated.
177643 ------------------------------------------------------------------------------------------------
177644 XLA_AE_LINES_PKG.ValidateCurrentLine;
177645
177646 ------------------------------------------------------------------------------------
177647 -- 4219869 Business Flow
177648 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
177649 ------------------------------------------------------------------------------------
177650 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
177651
177652 ----------------------------------------------------------------------------------
177653 -- 4219869 Business Flow
177654 -- Update journal entry status -- Need to generate this within IF <condition>
177655 ----------------------------------------------------------------------------------
177656 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
177657 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
177658 ,p_balance_type_code => l_balance_type_code
177659 );
177660
177661 -------------------------------------------------------------------------------------------
177662 -- 4262811 - Generate the Accrual Reversal lines
177663 -------------------------------------------------------------------------------------------
177664 BEGIN
177665 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
177666 (g_array_event(p_event_id).array_value_num('header_index'));
177667 IF l_acc_rev_flag IS NULL THEN
177668 l_acc_rev_flag := 'N';
177669 END IF;
177670 EXCEPTION
177671 WHEN OTHERS THEN
177672 l_acc_rev_flag := 'N';
177673 END;
177674 --
177675 IF (l_acc_rev_flag = 'Y') THEN
177676
177677 -- 4645092 ------------------------------------------------------------------------------
177678 -- To allow MPA report to determine if it should generate report process
177679 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
177680 ------------------------------------------------------------------------------------------
177681
177682 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
177683 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
177684 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
177685 -- call ADRs
177686 -- Bug 4922099
177687 --
177688 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
177689 (NVL(l_actual_upg_option, 'N') = 'O') OR
177690 (NVL(l_enc_upg_option, 'N') = 'O')
177691 )
177692 THEN
177693 NULL;
177694 --
177695 --
177696
177697 l_ccid := AcctDerRule_13(
177698 p_application_id => p_application_id
177699 , p_ae_header_id => l_ae_header_id
177700 , p_source_24 => p_source_24
177701 , x_transaction_coa_id => l_adr_transaction_coa_id
177702 , x_accounting_coa_id => l_adr_accounting_coa_id
177703 , x_value_type_code => l_adr_value_type_code
177704 , p_side => 'NA'
177705 );
177706
177707 xla_ae_lines_pkg.set_ccid(
177708 p_code_combination_id => l_ccid
177709 , p_value_type_code => l_adr_value_type_code
177710 , p_transaction_coa_id => l_adr_transaction_coa_id
177711 , p_accounting_coa_id => l_adr_accounting_coa_id
177712 , p_adr_code => 'PI_CATEGORY_EXPENSE'
177713 , p_adr_type_code => 'S'
177714 , p_component_type => l_component_type
177715 , p_component_code => l_component_code
177716 , p_component_type_code => l_component_type_code
177717 , p_component_appl_id => l_component_appl_id
177718 , p_amb_context_code => l_amb_context_code
177719 , p_side => 'NA'
177720 );
177721
177722
177723 --
177724 --
177725 END IF;
177726
177727 --
177728 -- Update the line information that should be overwritten
177729 --
177730 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
177731 p_header_num => 1);
177732 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
177733
177734 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
177735
177736 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
177737 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
177738 END IF;
177739
177740 --
177741 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
177742 --
177743 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
177744 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
177745 ELSE
177746 ---------------------------------------------------------------------------------------------------
177747 -- 4262811a Switch Sign
177748 ---------------------------------------------------------------------------------------------------
177749 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
177750 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
177751 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177752 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
177753 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177754 -- 5132302
177755 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
177756 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
177757
177758 END IF;
177759
177760 -- 4955764
177761 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
177762 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
177763
177764
177765 XLA_AE_LINES_PKG.ValidateCurrentLine;
177766 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
177767
177768 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
177769 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
177770 ,p_balance_type_code => l_balance_type_code);
177771
177772 END IF;
177773
177774 -----------------------------------------------------------------------------------------
177775 -- 4262811 Multiperiod Accounting
177776 -----------------------------------------------------------------------------------------
177777 -- No MPA option is assigned.
177778
177779
177780 END IF;
177781 END IF;
177782 --
177783
177784 --
177785 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
177786 trace
177787 (p_msg => 'END of AcctLineType_327'
177788 ,p_level => C_LEVEL_PROCEDURE
177789 ,p_module => l_log_module);
177790 END IF;
177791 --
177792 EXCEPTION
177793 WHEN xla_exceptions_pkg.application_exception THEN
177794 RAISE;
177795 WHEN OTHERS THEN
177796 xla_exceptions_pkg.raise_message
177797 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_327');
177798 END AcctLineType_327;
177799 --
177800
177801 ---------------------------------------
177802 --
177803 -- PRIVATE FUNCTION
177804 -- AcctLineType_328
177805 --
177806 ---------------------------------------
177807 PROCEDURE AcctLineType_328 (
177808 p_application_id IN NUMBER
177809 ,p_event_id IN NUMBER
177810 ,p_calculate_acctd_flag IN VARCHAR2
177811 ,p_calculate_g_l_flag IN VARCHAR2
177812 ,p_actual_flag IN OUT VARCHAR2
177813 ,p_balance_type_code OUT VARCHAR2
177814 ,p_gain_or_loss_ref OUT VARCHAR2
177815
177816 --Cost Management Default Account
177817 , p_source_11 IN NUMBER
177818 --DISTRIBUTION_IDENTIFIER
177819 , p_source_84 IN NUMBER
177820 --Distribution Type
177821 , p_source_85 IN VARCHAR2
177822 , p_source_85_meaning IN VARCHAR2
177823 --Entered Currency Code
177824 , p_source_88 IN VARCHAR2
177825 --Entered Amount
177826 , p_source_91 IN NUMBER
177827 --Currency Conversion Date
177828 , p_source_92 IN DATE
177829 --Currency Conversion Rate
177830 , p_source_93 IN NUMBER
177831 --Accounted Amount
177832 , p_source_95 IN NUMBER
177833 --Accounting Line Type
177834 , p_source_97 IN NUMBER
177835 )
177836 IS
177837
177838 l_component_type VARCHAR2(80);
177839 l_component_code VARCHAR2(30);
177840 l_component_type_code VARCHAR2(1);
177841 l_component_appl_id INTEGER;
177842 l_amb_context_code VARCHAR2(30);
177843 l_entity_code VARCHAR2(30);
177844 l_event_class_code VARCHAR2(30);
177845 l_ae_header_id NUMBER;
177846 l_event_type_code VARCHAR2(30);
177847 l_line_definition_code VARCHAR2(30);
177848 l_line_definition_owner_code VARCHAR2(1);
177849 --
177850 -- adr variables
177851 l_segment VARCHAR2(30);
177852 l_ccid NUMBER;
177853 l_adr_transaction_coa_id NUMBER;
177854 l_adr_accounting_coa_id NUMBER;
177855 l_adr_flexfield_segment_code VARCHAR2(30);
177856 l_adr_flex_value_set_id NUMBER;
177857 l_adr_value_type_code VARCHAR2(30);
177858 l_adr_value_combination_id NUMBER;
177859 l_adr_value_segment_code VARCHAR2(30);
177860
177861 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
177862 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
177863 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
177864 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
177865
177866 -- 4262811 Variables ------------------------------------------------------------------------------------------
177867 l_entered_amt_idx NUMBER;
177868 l_accted_amt_idx NUMBER;
177869 l_acc_rev_flag VARCHAR2(1);
177870 l_accrual_line_num NUMBER;
177871 l_tmp_amt NUMBER;
177872 l_acc_rev_natural_side_code VARCHAR2(1);
177873
177874 l_num_entries NUMBER;
177875 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
177876 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
177877 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
177878 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
177879 l_recog_line_1 NUMBER;
177880 l_recog_line_2 NUMBER;
177881
177882 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
177883 l_bflow_applied_to_amt NUMBER; -- 5132302
177884 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
177885
177886 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
177887
177888 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
177889 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
177890
177891 ---------------------------------------------------------------------------------------------------------------
177892
177893
177894 --
177895 -- bulk performance
177896 --
177897 l_balance_type_code VARCHAR2(1);
177898 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
177899 l_log_module VARCHAR2(240);
177900
177901 --
177902 -- Upgrade strategy
177903 --
177904 l_actual_upg_option VARCHAR2(1);
177905 l_enc_upg_option VARCHAR2(1);
177906
177907 --
177908 BEGIN
177909 --
177910 IF g_log_enabled THEN
177911 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_328';
177912 END IF;
177913 --
177914 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
177915
177916 trace
177917 (p_msg => 'BEGIN of AcctLineType_328'
177918 ,p_level => C_LEVEL_PROCEDURE
177919 ,p_module => l_log_module);
177920
177921 END IF;
177922 --
177923 l_component_type := 'AMB_JLT';
177924 l_component_code := 'OFFSET';
177925 l_component_type_code := 'S';
177926 l_component_appl_id := 707;
177927 l_amb_context_code := 'DEFAULT';
177928 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
177929 l_event_class_code := 'OSP';
177930 l_event_type_code := 'EAM_DIRECT_SHOP_FLOOR_DELIVER';
177931 l_line_definition_owner_code := 'S';
177932 l_line_definition_code := 'PI_EAM_DIRECT_DELIVERY';
177933 --
177934 l_balance_type_code := 'A';
177935 l_segment := NULL;
177936 l_ccid := NULL;
177937 l_adr_transaction_coa_id := NULL;
177938 l_adr_accounting_coa_id := NULL;
177939 l_adr_flexfield_segment_code := NULL;
177940 l_adr_flex_value_set_id := NULL;
177941 l_adr_value_type_code := NULL;
177942 l_adr_value_combination_id := NULL;
177943 l_adr_value_segment_code := NULL;
177944
177945 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
177946 l_bflow_class_code := ''; -- 4219869 Business Flow
177947 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
177948 l_budgetary_control_flag := 'N';
177949
177950 l_bflow_applied_to_amt_idx := NULL; -- 5132302
177951 l_bflow_applied_to_amt := NULL; -- 5132302
177952 l_entered_amt_idx := NULL; -- 4262811
177953 l_accted_amt_idx := NULL; -- 4262811
177954 l_acc_rev_flag := NULL; -- 4262811
177955 l_accrual_line_num := NULL; -- 4262811
177956 l_tmp_amt := NULL; -- 4262811
177957 --
177958
177959 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
177960 l_balance_type_code <> 'B' THEN
177961 IF NVL(p_source_97,9E125) = 2
177962 THEN
177963
177964 --
177965 XLA_AE_LINES_PKG.SetNewLine;
177966
177967 p_balance_type_code := l_balance_type_code;
177968 -- set the flag so later we will know whether the gain loss line needs to be created
177969
177970 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
177971 p_actual_flag :='A';
177972 END IF;
177973
177974 --
177975 -- bulk performance
177976 --
177977 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
177978 p_header_num => 0); -- 4262811
177979 --
177980 -- set accounting line options
177981 --
177982 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
177983 p_natural_side_code => 'D'
177984 , p_gain_or_loss_flag => 'N'
177985 , p_gl_transfer_mode_code => 'S'
177986 , p_acct_entry_type_code => 'A'
177987 , p_switch_side_flag => 'Y'
177988 , p_merge_duplicate_code => 'N'
177989 );
177990 --
177991 l_acc_rev_natural_side_code := 'C'; -- 4262811
177992 --
177993 --
177994 -- set accounting line type info
177995 --
177996 xla_ae_lines_pkg.SetAcctLineType
177997 (p_component_type => l_component_type
177998 ,p_event_type_code => l_event_type_code
177999 ,p_line_definition_owner_code => l_line_definition_owner_code
178000 ,p_line_definition_code => l_line_definition_code
178001 ,p_accounting_line_code => l_component_code
178002 ,p_accounting_line_type_code => l_component_type_code
178003 ,p_accounting_line_appl_id => l_component_appl_id
178004 ,p_amb_context_code => l_amb_context_code
178005 ,p_entity_code => l_entity_code
178006 ,p_event_class_code => l_event_class_code);
178007 --
178008 -- set accounting class
178009 --
178010 xla_ae_lines_pkg.SetAcctClass(
178011 p_accounting_class_code => 'OFFSET'
178012 , p_ae_header_id => l_ae_header_id
178013 );
178014
178015 --
178016 -- set rounding class
178017 --
178018 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
178019 'OFFSET';
178020
178021 --
178022 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
178023 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
178024 --
178025 -- bulk performance
178026 --
178027 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
178028
178029 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
178030 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
178031
178032 -- 4955764
178033 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
178034 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
178035
178036 -- 4458381 Public Sector Enh
178037
178038 --
178039 -- set accounting attributes for the line type
178040 --
178041 l_entered_amt_idx := 3;
178042 l_accted_amt_idx := 8;
178043 l_bflow_applied_to_amt_idx := NULL; -- 5132302
178044 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
178045 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
178046 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
178047 l_rec_acct_attrs.array_char_value(2) := p_source_85;
178048 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
178049 l_rec_acct_attrs.array_num_value(3) := p_source_91;
178050 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
178051 l_rec_acct_attrs.array_char_value(4) := p_source_88;
178052 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
178053 l_rec_acct_attrs.array_date_value(5) := p_source_92;
178054 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
178055 l_rec_acct_attrs.array_num_value(6) := p_source_93;
178056 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
178057 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
178058 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
178059 l_rec_acct_attrs.array_num_value(8) := p_source_95;
178060
178061 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
178062 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
178063
178064 ---------------------------------------------------------------------------------------------------------------
178065 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
178066 ---------------------------------------------------------------------------------------------------------------
178067 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
178068
178069 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
178070 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
178071
178072 IF xla_accounting_cache_pkg.GetValueChar
178073 (p_source_code => 'LEDGER_CATEGORY_CODE'
178074 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
178075 AND l_bflow_method_code = 'PRIOR_ENTRY'
178076 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
178077 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
178078 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
178079 )
178080 THEN
178081 xla_ae_lines_pkg.BflowUpgEntry
178082 (p_business_method_code => l_bflow_method_code
178083 ,p_business_class_code => l_bflow_class_code
178084 ,p_balance_type => l_balance_type_code);
178085 ELSE
178086 NULL;
178087 -- No business flow processing for business flow method of NONE.
178088 END IF;
178089
178090 --
178091 -- call analytical criteria
178092 --
178093
178094 --
178095 -- call description
178096 --
178097 -- No description or it is inherited.
178098 --
178099 -- call ADRs
178100 -- Bug 4922099
178101 --
178102 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
178103 (NVL(l_actual_upg_option, 'N') = 'O') OR
178104 (NVL(l_enc_upg_option, 'N') = 'O')
178105 )
178106 THEN
178107 NULL;
178108 --
178109 --
178110
178111 l_ccid := AcctDerRule_6(
178112 p_application_id => p_application_id
178113 , p_ae_header_id => l_ae_header_id
178114 , p_source_11 => p_source_11
178115 , x_transaction_coa_id => l_adr_transaction_coa_id
178116 , x_accounting_coa_id => l_adr_accounting_coa_id
178117 , x_value_type_code => l_adr_value_type_code
178118 , p_side => 'NA'
178119 );
178120
178121 xla_ae_lines_pkg.set_ccid(
178122 p_code_combination_id => l_ccid
178123 , p_value_type_code => l_adr_value_type_code
178124 , p_transaction_coa_id => l_adr_transaction_coa_id
178125 , p_accounting_coa_id => l_adr_accounting_coa_id
178126 , p_adr_code => 'CST_DEFAULT'
178127 , p_adr_type_code => 'S'
178128 , p_component_type => l_component_type
178129 , p_component_code => l_component_code
178130 , p_component_type_code => l_component_type_code
178131 , p_component_appl_id => l_component_appl_id
178132 , p_amb_context_code => l_amb_context_code
178133 , p_side => 'NA'
178134 );
178135
178136
178137 --
178138 --
178139 END IF;
178140 --
178141 -- Bug 4922099
178142 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
178143 (NVL(l_enc_upg_option, 'N') = 'O')
178144 ) AND
178145 (l_bflow_method_code = 'PRIOR_ENTRY')
178146 )
178147 THEN
178148 IF
178149 --
178150 1 = 2
178151 --
178152 THEN
178153 xla_accounting_err_pkg.build_message
178154 (p_appli_s_name => 'XLA'
178155 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
178156 ,p_token_1 => 'LINE_NUMBER'
178157 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
178158 ,p_token_2 => 'LINE_TYPE_NAME'
178159 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
178160 l_component_type
178161 ,l_component_code
178162 ,l_component_type_code
178163 ,l_component_appl_id
178164 ,l_amb_context_code
178165 ,l_entity_code
178166 ,l_event_class_code
178167 )
178168 ,p_token_3 => 'OWNER'
178169 ,p_value_3 => xla_lookups_pkg.get_meaning(
178170 p_lookup_type => 'XLA_OWNER_TYPE'
178171 ,p_lookup_code => l_component_type_code
178172 )
178173 ,p_token_4 => 'PRODUCT_NAME'
178174 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
178175 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
178176 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
178177 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
178178 ,p_ae_header_id => NULL
178179 );
178180
178181 IF (C_LEVEL_ERROR>= g_log_level) THEN
178182 trace
178183 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
178184 ,p_level => C_LEVEL_ERROR
178185 ,p_module => l_log_module);
178186 END IF;
178187 END IF;
178188 END IF;
178189 --
178190 --
178191 ------------------------------------------------------------------------------------------------
178192 -- 4219869 Business Flow
178193 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
178194 -- Prior Entry. Currently, the following code is always generated.
178195 ------------------------------------------------------------------------------------------------
178196 XLA_AE_LINES_PKG.ValidateCurrentLine;
178197
178198 ------------------------------------------------------------------------------------
178199 -- 4219869 Business Flow
178200 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
178201 ------------------------------------------------------------------------------------
178202 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
178203
178204 ----------------------------------------------------------------------------------
178205 -- 4219869 Business Flow
178206 -- Update journal entry status -- Need to generate this within IF <condition>
178207 ----------------------------------------------------------------------------------
178208 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
178209 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
178210 ,p_balance_type_code => l_balance_type_code
178211 );
178212
178213 -------------------------------------------------------------------------------------------
178214 -- 4262811 - Generate the Accrual Reversal lines
178215 -------------------------------------------------------------------------------------------
178216 BEGIN
178217 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
178218 (g_array_event(p_event_id).array_value_num('header_index'));
178219 IF l_acc_rev_flag IS NULL THEN
178220 l_acc_rev_flag := 'N';
178221 END IF;
178222 EXCEPTION
178223 WHEN OTHERS THEN
178224 l_acc_rev_flag := 'N';
178225 END;
178226 --
178227 IF (l_acc_rev_flag = 'Y') THEN
178228
178229 -- 4645092 ------------------------------------------------------------------------------
178230 -- To allow MPA report to determine if it should generate report process
178231 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
178232 ------------------------------------------------------------------------------------------
178233
178234 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
178235 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
178236 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
178237 -- call ADRs
178238 -- Bug 4922099
178239 --
178240 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
178241 (NVL(l_actual_upg_option, 'N') = 'O') OR
178242 (NVL(l_enc_upg_option, 'N') = 'O')
178243 )
178244 THEN
178245 NULL;
178246 --
178247 --
178248
178249 l_ccid := AcctDerRule_6(
178250 p_application_id => p_application_id
178251 , p_ae_header_id => l_ae_header_id
178252 , p_source_11 => p_source_11
178253 , x_transaction_coa_id => l_adr_transaction_coa_id
178254 , x_accounting_coa_id => l_adr_accounting_coa_id
178255 , x_value_type_code => l_adr_value_type_code
178256 , p_side => 'NA'
178257 );
178258
178259 xla_ae_lines_pkg.set_ccid(
178260 p_code_combination_id => l_ccid
178261 , p_value_type_code => l_adr_value_type_code
178262 , p_transaction_coa_id => l_adr_transaction_coa_id
178263 , p_accounting_coa_id => l_adr_accounting_coa_id
178264 , p_adr_code => 'CST_DEFAULT'
178265 , p_adr_type_code => 'S'
178266 , p_component_type => l_component_type
178267 , p_component_code => l_component_code
178268 , p_component_type_code => l_component_type_code
178269 , p_component_appl_id => l_component_appl_id
178270 , p_amb_context_code => l_amb_context_code
178271 , p_side => 'NA'
178272 );
178273
178274
178275 --
178276 --
178277 END IF;
178278
178279 --
178280 -- Update the line information that should be overwritten
178281 --
178282 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
178283 p_header_num => 1);
178284 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
178285
178286 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
178287
178288 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
178289 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
178290 END IF;
178291
178292 --
178293 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
178294 --
178295 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
178296 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
178297 ELSE
178298 ---------------------------------------------------------------------------------------------------
178299 -- 4262811a Switch Sign
178300 ---------------------------------------------------------------------------------------------------
178301 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
178302 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
178303 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178304 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
178305 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178306 -- 5132302
178307 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
178308 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178309
178310 END IF;
178311
178312 -- 4955764
178313 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
178314 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
178315
178316
178317 XLA_AE_LINES_PKG.ValidateCurrentLine;
178318 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
178319
178320 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
178321 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
178322 ,p_balance_type_code => l_balance_type_code);
178323
178324 END IF;
178325
178326 -----------------------------------------------------------------------------------------
178327 -- 4262811 Multiperiod Accounting
178328 -----------------------------------------------------------------------------------------
178329 -- No MPA option is assigned.
178330
178331
178332 END IF;
178333 END IF;
178334 --
178335
178336 --
178337 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
178338 trace
178339 (p_msg => 'END of AcctLineType_328'
178340 ,p_level => C_LEVEL_PROCEDURE
178341 ,p_module => l_log_module);
178342 END IF;
178343 --
178344 EXCEPTION
178345 WHEN xla_exceptions_pkg.application_exception THEN
178346 RAISE;
178347 WHEN OTHERS THEN
178348 xla_exceptions_pkg.raise_message
178349 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_328');
178350 END AcctLineType_328;
178351 --
178352
178353 ---------------------------------------
178354 --
178355 -- PRIVATE FUNCTION
178356 -- AcctLineType_329
178357 --
178358 ---------------------------------------
178359 PROCEDURE AcctLineType_329 (
178360 p_application_id IN NUMBER
178361 ,p_event_id IN NUMBER
178362 ,p_calculate_acctd_flag IN VARCHAR2
178363 ,p_calculate_g_l_flag IN VARCHAR2
178364 ,p_actual_flag IN OUT VARCHAR2
178365 ,p_balance_type_code OUT VARCHAR2
178366 ,p_gain_or_loss_ref OUT VARCHAR2
178367
178368 --TRANSACTION_ID
178369 , p_source_1 IN NUMBER
178370 --Item Concatenated Segments
178371 , p_source_2 IN VARCHAR2
178372 --Transaction Quantity
178373 , p_source_3 IN NUMBER
178374 --Transaction Unit of Measure Code
178375 , p_source_4 IN VARCHAR2
178376 --Inventory Transaction Type Description
178377 , p_source_5 IN VARCHAR2
178378 --Cost Management Default Account
178379 , p_source_11 IN NUMBER
178380 --Applied to Application ID
178381 , p_source_79 IN NUMBER
178382 --Applied to Distribution Link Type
178383 , p_source_80 IN VARCHAR2
178384 --Applied to Entity Code
178385 , p_source_81 IN VARCHAR2
178386 --DISTRIBUTION_IDENTIFIER
178387 , p_source_84 IN NUMBER
178388 --Distribution Type
178389 , p_source_85 IN VARCHAR2
178390 , p_source_85_meaning IN VARCHAR2
178391 --Encumbrance Reversal Amount Entered
178392 , p_source_87 IN NUMBER
178393 --Entered Currency Code
178394 , p_source_88 IN VARCHAR2
178395 --Transaction Encumbrance Reversal Amount
178396 , p_source_89 IN NUMBER
178397 --Entered Amount
178398 , p_source_91 IN NUMBER
178399 --Currency Conversion Date
178400 , p_source_92 IN DATE
178401 --Currency Conversion Rate
178402 , p_source_93 IN NUMBER
178403 --Currency Conversion Type
178404 , p_source_94 IN VARCHAR2
178405 --Accounted Amount
178406 , p_source_95 IN NUMBER
178407 --Accounting Line Type
178408 , p_source_97 IN NUMBER
178409 --Costing Encumbrance Upgrade Option
178410 , p_source_100 IN VARCHAR2
178411 --TXN_PO_DISTRIBUTION_ID
178412 , p_source_101 IN NUMBER
178413 --TXN_PO_HEADER_ID
178414 , p_source_102 IN NUMBER
178415 --Requisition Budget Account
178416 , p_source_103 IN NUMBER
178417 --Requisition Encumbrance Type Identifier
178418 , p_source_104 IN NUMBER
178419 )
178420 IS
178421
178422 l_component_type VARCHAR2(80);
178423 l_component_code VARCHAR2(30);
178424 l_component_type_code VARCHAR2(1);
178425 l_component_appl_id INTEGER;
178426 l_amb_context_code VARCHAR2(30);
178427 l_entity_code VARCHAR2(30);
178428 l_event_class_code VARCHAR2(30);
178429 l_ae_header_id NUMBER;
178430 l_event_type_code VARCHAR2(30);
178431 l_line_definition_code VARCHAR2(30);
178432 l_line_definition_owner_code VARCHAR2(1);
178433 --
178434 -- adr variables
178435 l_segment VARCHAR2(30);
178436 l_ccid NUMBER;
178437 l_adr_transaction_coa_id NUMBER;
178438 l_adr_accounting_coa_id NUMBER;
178439 l_adr_flexfield_segment_code VARCHAR2(30);
178440 l_adr_flex_value_set_id NUMBER;
178441 l_adr_value_type_code VARCHAR2(30);
178442 l_adr_value_combination_id NUMBER;
178443 l_adr_value_segment_code VARCHAR2(30);
178444
178445 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
178446 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
178447 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
178448 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
178449
178450 -- 4262811 Variables ------------------------------------------------------------------------------------------
178451 l_entered_amt_idx NUMBER;
178452 l_accted_amt_idx NUMBER;
178453 l_acc_rev_flag VARCHAR2(1);
178454 l_accrual_line_num NUMBER;
178455 l_tmp_amt NUMBER;
178456 l_acc_rev_natural_side_code VARCHAR2(1);
178457
178458 l_num_entries NUMBER;
178459 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
178460 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
178461 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
178462 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
178463 l_recog_line_1 NUMBER;
178464 l_recog_line_2 NUMBER;
178465
178466 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
178467 l_bflow_applied_to_amt NUMBER; -- 5132302
178468 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
178469
178470 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
178471
178472 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
178473 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
178474
178475 ---------------------------------------------------------------------------------------------------------------
178476
178477
178478 --
178479 -- bulk performance
178480 --
178481 l_balance_type_code VARCHAR2(1);
178482 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
178483 l_log_module VARCHAR2(240);
178484
178485 --
178486 -- Upgrade strategy
178487 --
178488 l_actual_upg_option VARCHAR2(1);
178489 l_enc_upg_option VARCHAR2(1);
178490
178491 --
178492 BEGIN
178493 --
178494 IF g_log_enabled THEN
178495 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_329';
178496 END IF;
178497 --
178498 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
178499
178500 trace
178501 (p_msg => 'BEGIN of AcctLineType_329'
178502 ,p_level => C_LEVEL_PROCEDURE
178503 ,p_module => l_log_module);
178504
178505 END IF;
178506 --
178507 l_component_type := 'AMB_JLT';
178508 l_component_code := 'OFFSET';
178509 l_component_type_code := 'S';
178510 l_component_appl_id := 707;
178511 l_amb_context_code := 'DEFAULT';
178512 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
178513 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
178514 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_NO_TP';
178515 l_line_definition_owner_code := 'S';
178516 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_NTP';
178517 --
178518 l_balance_type_code := 'A';
178519 l_segment := NULL;
178520 l_ccid := NULL;
178521 l_adr_transaction_coa_id := NULL;
178522 l_adr_accounting_coa_id := NULL;
178523 l_adr_flexfield_segment_code := NULL;
178524 l_adr_flex_value_set_id := NULL;
178525 l_adr_value_type_code := NULL;
178526 l_adr_value_combination_id := NULL;
178527 l_adr_value_segment_code := NULL;
178528
178529 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
178530 l_bflow_class_code := ''; -- 4219869 Business Flow
178531 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
178532 l_budgetary_control_flag := 'N';
178533
178534 l_bflow_applied_to_amt_idx := NULL; -- 5132302
178535 l_bflow_applied_to_amt := NULL; -- 5132302
178536 l_entered_amt_idx := NULL; -- 4262811
178537 l_accted_amt_idx := NULL; -- 4262811
178538 l_acc_rev_flag := NULL; -- 4262811
178539 l_accrual_line_num := NULL; -- 4262811
178540 l_tmp_amt := NULL; -- 4262811
178541 --
178542
178543 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
178544 l_balance_type_code <> 'B' THEN
178545 IF NVL(p_source_97,9E125) = 2 AND
178546 p_source_95 >= 0
178547 THEN
178548
178549 --
178550 XLA_AE_LINES_PKG.SetNewLine;
178551
178552 p_balance_type_code := l_balance_type_code;
178553 -- set the flag so later we will know whether the gain loss line needs to be created
178554
178555 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
178556 p_actual_flag :='A';
178557 END IF;
178558
178559 --
178560 -- bulk performance
178561 --
178562 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
178563 p_header_num => 0); -- 4262811
178564 --
178565 -- set accounting line options
178566 --
178567 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
178568 p_natural_side_code => 'D'
178569 , p_gain_or_loss_flag => 'N'
178570 , p_gl_transfer_mode_code => 'S'
178571 , p_acct_entry_type_code => 'A'
178572 , p_switch_side_flag => 'Y'
178573 , p_merge_duplicate_code => 'N'
178574 );
178575 --
178576 l_acc_rev_natural_side_code := 'C'; -- 4262811
178577 --
178578 --
178579 -- set accounting line type info
178580 --
178581 xla_ae_lines_pkg.SetAcctLineType
178582 (p_component_type => l_component_type
178583 ,p_event_type_code => l_event_type_code
178584 ,p_line_definition_owner_code => l_line_definition_owner_code
178585 ,p_line_definition_code => l_line_definition_code
178586 ,p_accounting_line_code => l_component_code
178587 ,p_accounting_line_type_code => l_component_type_code
178588 ,p_accounting_line_appl_id => l_component_appl_id
178589 ,p_amb_context_code => l_amb_context_code
178590 ,p_entity_code => l_entity_code
178591 ,p_event_class_code => l_event_class_code);
178592 --
178593 -- set accounting class
178594 --
178595 xla_ae_lines_pkg.SetAcctClass(
178596 p_accounting_class_code => 'OFFSET'
178597 , p_ae_header_id => l_ae_header_id
178598 );
178599
178600 --
178601 -- set rounding class
178602 --
178603 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
178604 'OFFSET';
178605
178606 --
178607 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
178608 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
178609 --
178610 -- bulk performance
178611 --
178612 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
178613
178614 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
178615 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
178616
178617 -- 4955764
178618 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
178619 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
178620
178621 -- 4458381 Public Sector Enh
178622
178623 --
178624 -- set accounting attributes for the line type
178625 --
178626 l_entered_amt_idx := 17;
178627 l_accted_amt_idx := 22;
178628 l_bflow_applied_to_amt_idx := NULL; -- 5132302
178629 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
178630 l_rec_acct_attrs.array_num_value(1) := p_source_79;
178631 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
178632 l_rec_acct_attrs.array_char_value(2) := p_source_80;
178633 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
178634 l_rec_acct_attrs.array_char_value(3) := p_source_81;
178635 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
178636 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
178637 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
178638 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
178639 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
178640 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
178641 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
178642 l_rec_acct_attrs.array_char_value(7) := p_source_85;
178643 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
178644 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
178645 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
178646 l_rec_acct_attrs.array_num_value(9) := p_source_87;
178647 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
178648 l_rec_acct_attrs.array_char_value(10) := p_source_88;
178649 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
178650 l_rec_acct_attrs.array_num_value(11) := p_source_89;
178651 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
178652 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
178653 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
178654 l_rec_acct_attrs.array_num_value(13) := p_source_87;
178655 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
178656 l_rec_acct_attrs.array_char_value(14) := p_source_88;
178657 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
178658 l_rec_acct_attrs.array_num_value(15) := p_source_89;
178659 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
178660 l_rec_acct_attrs.array_char_value(16) := p_source_100;
178661 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
178662 l_rec_acct_attrs.array_num_value(17) := p_source_91;
178663 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
178664 l_rec_acct_attrs.array_char_value(18) := p_source_88;
178665 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
178666 l_rec_acct_attrs.array_date_value(19) := p_source_92;
178667 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
178668 l_rec_acct_attrs.array_num_value(20) := p_source_93;
178669 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
178670 l_rec_acct_attrs.array_char_value(21) := p_source_94;
178671 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
178672 l_rec_acct_attrs.array_num_value(22) := p_source_95;
178673 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
178674 l_rec_acct_attrs.array_num_value(23) := p_source_104;
178675 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
178676 l_rec_acct_attrs.array_num_value(24) := p_source_104;
178677
178678 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
178679 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
178680
178681 ---------------------------------------------------------------------------------------------------------------
178682 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
178683 ---------------------------------------------------------------------------------------------------------------
178684 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
178685
178686 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
178687 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
178688
178689 IF xla_accounting_cache_pkg.GetValueChar
178690 (p_source_code => 'LEDGER_CATEGORY_CODE'
178691 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
178692 AND l_bflow_method_code = 'PRIOR_ENTRY'
178693 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
178694 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
178695 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
178696 )
178697 THEN
178698 xla_ae_lines_pkg.BflowUpgEntry
178699 (p_business_method_code => l_bflow_method_code
178700 ,p_business_class_code => l_bflow_class_code
178701 ,p_balance_type => l_balance_type_code);
178702 ELSE
178703 NULL;
178704 -- No business flow processing for business flow method of NONE.
178705 END IF;
178706
178707 --
178708 -- call analytical criteria
178709 --
178710
178711 --
178712 -- call description
178713 --
178714
178715 xla_ae_lines_pkg.SetLineDescription(
178716 p_ae_header_id => l_ae_header_id
178717 ,p_description => Description_1 (
178718 p_application_id => p_application_id
178719 , p_ae_header_id => l_ae_header_id
178720 , p_source_1 => p_source_1
178721 , p_source_2 => p_source_2
178722 , p_source_3 => p_source_3
178723 , p_source_4 => p_source_4
178724 , p_source_5 => p_source_5
178725 )
178726 );
178727
178728
178729 --
178730 -- call ADRs
178731 -- Bug 4922099
178732 --
178733 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
178734 (NVL(l_actual_upg_option, 'N') = 'O') OR
178735 (NVL(l_enc_upg_option, 'N') = 'O')
178736 )
178737 THEN
178738 NULL;
178739 --
178740 --
178741
178742 l_ccid := AcctDerRule_6(
178743 p_application_id => p_application_id
178744 , p_ae_header_id => l_ae_header_id
178745 , p_source_11 => p_source_11
178746 , x_transaction_coa_id => l_adr_transaction_coa_id
178747 , x_accounting_coa_id => l_adr_accounting_coa_id
178748 , x_value_type_code => l_adr_value_type_code
178749 , p_side => 'NA'
178750 );
178751
178752 xla_ae_lines_pkg.set_ccid(
178753 p_code_combination_id => l_ccid
178754 , p_value_type_code => l_adr_value_type_code
178755 , p_transaction_coa_id => l_adr_transaction_coa_id
178756 , p_accounting_coa_id => l_adr_accounting_coa_id
178757 , p_adr_code => 'CST_DEFAULT'
178758 , p_adr_type_code => 'S'
178759 , p_component_type => l_component_type
178760 , p_component_code => l_component_code
178761 , p_component_type_code => l_component_type_code
178762 , p_component_appl_id => l_component_appl_id
178763 , p_amb_context_code => l_amb_context_code
178764 , p_side => 'NA'
178765 );
178766
178767
178768 --
178769 --
178770 END IF;
178771 --
178772 -- Bug 4922099
178773 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
178774 (NVL(l_enc_upg_option, 'N') = 'O')
178775 ) AND
178776 (l_bflow_method_code = 'PRIOR_ENTRY')
178777 )
178778 THEN
178779 IF
178780 --
178781 1 = 2
178782 --
178783 THEN
178784 xla_accounting_err_pkg.build_message
178785 (p_appli_s_name => 'XLA'
178786 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
178787 ,p_token_1 => 'LINE_NUMBER'
178788 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
178789 ,p_token_2 => 'LINE_TYPE_NAME'
178790 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
178791 l_component_type
178792 ,l_component_code
178793 ,l_component_type_code
178794 ,l_component_appl_id
178795 ,l_amb_context_code
178796 ,l_entity_code
178797 ,l_event_class_code
178798 )
178799 ,p_token_3 => 'OWNER'
178800 ,p_value_3 => xla_lookups_pkg.get_meaning(
178801 p_lookup_type => 'XLA_OWNER_TYPE'
178802 ,p_lookup_code => l_component_type_code
178803 )
178804 ,p_token_4 => 'PRODUCT_NAME'
178805 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
178806 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
178807 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
178808 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
178809 ,p_ae_header_id => NULL
178810 );
178811
178812 IF (C_LEVEL_ERROR>= g_log_level) THEN
178813 trace
178814 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
178815 ,p_level => C_LEVEL_ERROR
178816 ,p_module => l_log_module);
178817 END IF;
178818 END IF;
178819 END IF;
178820 --
178821 --
178822 ------------------------------------------------------------------------------------------------
178823 -- 4219869 Business Flow
178824 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
178825 -- Prior Entry. Currently, the following code is always generated.
178826 ------------------------------------------------------------------------------------------------
178827 XLA_AE_LINES_PKG.ValidateCurrentLine;
178828
178829 ------------------------------------------------------------------------------------
178830 -- 4219869 Business Flow
178831 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
178832 ------------------------------------------------------------------------------------
178833 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
178834
178835 ----------------------------------------------------------------------------------
178836 -- 4219869 Business Flow
178837 -- Update journal entry status -- Need to generate this within IF <condition>
178838 ----------------------------------------------------------------------------------
178839 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
178840 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
178841 ,p_balance_type_code => l_balance_type_code
178842 );
178843
178844 -------------------------------------------------------------------------------------------
178845 -- 4262811 - Generate the Accrual Reversal lines
178846 -------------------------------------------------------------------------------------------
178847 BEGIN
178848 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
178849 (g_array_event(p_event_id).array_value_num('header_index'));
178850 IF l_acc_rev_flag IS NULL THEN
178851 l_acc_rev_flag := 'N';
178852 END IF;
178853 EXCEPTION
178854 WHEN OTHERS THEN
178855 l_acc_rev_flag := 'N';
178856 END;
178857 --
178858 IF (l_acc_rev_flag = 'Y') THEN
178859
178860 -- 4645092 ------------------------------------------------------------------------------
178861 -- To allow MPA report to determine if it should generate report process
178862 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
178863 ------------------------------------------------------------------------------------------
178864
178865 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
178866 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
178867 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
178868 -- call ADRs
178869 -- Bug 4922099
178870 --
178871 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
178872 (NVL(l_actual_upg_option, 'N') = 'O') OR
178873 (NVL(l_enc_upg_option, 'N') = 'O')
178874 )
178875 THEN
178876 NULL;
178877 --
178878 --
178879
178880 l_ccid := AcctDerRule_6(
178881 p_application_id => p_application_id
178882 , p_ae_header_id => l_ae_header_id
178883 , p_source_11 => p_source_11
178884 , x_transaction_coa_id => l_adr_transaction_coa_id
178885 , x_accounting_coa_id => l_adr_accounting_coa_id
178886 , x_value_type_code => l_adr_value_type_code
178887 , p_side => 'NA'
178888 );
178889
178890 xla_ae_lines_pkg.set_ccid(
178891 p_code_combination_id => l_ccid
178892 , p_value_type_code => l_adr_value_type_code
178893 , p_transaction_coa_id => l_adr_transaction_coa_id
178894 , p_accounting_coa_id => l_adr_accounting_coa_id
178895 , p_adr_code => 'CST_DEFAULT'
178896 , p_adr_type_code => 'S'
178897 , p_component_type => l_component_type
178898 , p_component_code => l_component_code
178899 , p_component_type_code => l_component_type_code
178900 , p_component_appl_id => l_component_appl_id
178901 , p_amb_context_code => l_amb_context_code
178902 , p_side => 'NA'
178903 );
178904
178905
178906 --
178907 --
178908 END IF;
178909
178910 --
178911 -- Update the line information that should be overwritten
178912 --
178913 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
178914 p_header_num => 1);
178915 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
178916
178917 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
178918
178919 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
178920 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
178921 END IF;
178922
178923 --
178924 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
178925 --
178926 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
178927 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
178928 ELSE
178929 ---------------------------------------------------------------------------------------------------
178930 -- 4262811a Switch Sign
178931 ---------------------------------------------------------------------------------------------------
178932 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
178933 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
178934 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178935 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
178936 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178937 -- 5132302
178938 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
178939 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
178940
178941 END IF;
178942
178943 -- 4955764
178944 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
178945 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
178946
178947
178948 XLA_AE_LINES_PKG.ValidateCurrentLine;
178949 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
178950
178951 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
178952 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
178953 ,p_balance_type_code => l_balance_type_code);
178954
178955 END IF;
178956
178957 -----------------------------------------------------------------------------------------
178958 -- 4262811 Multiperiod Accounting
178959 -----------------------------------------------------------------------------------------
178960 -- No MPA option is assigned.
178961
178962
178963 END IF;
178964 END IF;
178965 --
178966
178967 --
178968 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
178969 trace
178970 (p_msg => 'END of AcctLineType_329'
178971 ,p_level => C_LEVEL_PROCEDURE
178972 ,p_module => l_log_module);
178973 END IF;
178974 --
178975 EXCEPTION
178976 WHEN xla_exceptions_pkg.application_exception THEN
178977 RAISE;
178978 WHEN OTHERS THEN
178979 xla_exceptions_pkg.raise_message
178980 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_329');
178981 END AcctLineType_329;
178982 --
178983
178984 ---------------------------------------
178985 --
178986 -- PRIVATE FUNCTION
178987 -- AcctLineType_330
178988 --
178989 ---------------------------------------
178990 PROCEDURE AcctLineType_330 (
178991 p_application_id IN NUMBER
178992 ,p_event_id IN NUMBER
178993 ,p_calculate_acctd_flag IN VARCHAR2
178994 ,p_calculate_g_l_flag IN VARCHAR2
178995 ,p_actual_flag IN OUT VARCHAR2
178996 ,p_balance_type_code OUT VARCHAR2
178997 ,p_gain_or_loss_ref OUT VARCHAR2
178998
178999 --Cost Management Default Account
179000 , p_source_11 IN NUMBER
179001 --DISTRIBUTION_IDENTIFIER
179002 , p_source_84 IN NUMBER
179003 --Distribution Type
179004 , p_source_85 IN VARCHAR2
179005 , p_source_85_meaning IN VARCHAR2
179006 --Entered Currency Code
179007 , p_source_88 IN VARCHAR2
179008 --Entered Amount
179009 , p_source_91 IN NUMBER
179010 --Currency Conversion Date
179011 , p_source_92 IN DATE
179012 --Currency Conversion Rate
179013 , p_source_93 IN NUMBER
179014 --Currency Conversion Type
179015 , p_source_94 IN VARCHAR2
179016 --Accounted Amount
179017 , p_source_95 IN NUMBER
179018 --Accounting Line Type
179019 , p_source_97 IN NUMBER
179020 )
179021 IS
179022
179023 l_component_type VARCHAR2(80);
179024 l_component_code VARCHAR2(30);
179025 l_component_type_code VARCHAR2(1);
179026 l_component_appl_id INTEGER;
179027 l_amb_context_code VARCHAR2(30);
179028 l_entity_code VARCHAR2(30);
179029 l_event_class_code VARCHAR2(30);
179030 l_ae_header_id NUMBER;
179031 l_event_type_code VARCHAR2(30);
179032 l_line_definition_code VARCHAR2(30);
179033 l_line_definition_owner_code VARCHAR2(1);
179034 --
179035 -- adr variables
179036 l_segment VARCHAR2(30);
179037 l_ccid NUMBER;
179038 l_adr_transaction_coa_id NUMBER;
179039 l_adr_accounting_coa_id NUMBER;
179040 l_adr_flexfield_segment_code VARCHAR2(30);
179041 l_adr_flex_value_set_id NUMBER;
179042 l_adr_value_type_code VARCHAR2(30);
179043 l_adr_value_combination_id NUMBER;
179044 l_adr_value_segment_code VARCHAR2(30);
179045
179046 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
179047 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
179048 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
179049 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
179050
179051 -- 4262811 Variables ------------------------------------------------------------------------------------------
179052 l_entered_amt_idx NUMBER;
179053 l_accted_amt_idx NUMBER;
179054 l_acc_rev_flag VARCHAR2(1);
179055 l_accrual_line_num NUMBER;
179056 l_tmp_amt NUMBER;
179057 l_acc_rev_natural_side_code VARCHAR2(1);
179058
179059 l_num_entries NUMBER;
179060 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
179061 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
179062 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
179063 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
179064 l_recog_line_1 NUMBER;
179065 l_recog_line_2 NUMBER;
179066
179067 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
179068 l_bflow_applied_to_amt NUMBER; -- 5132302
179069 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
179070
179071 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
179072
179073 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
179074 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
179075
179076 ---------------------------------------------------------------------------------------------------------------
179077
179078
179079 --
179080 -- bulk performance
179081 --
179082 l_balance_type_code VARCHAR2(1);
179083 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
179084 l_log_module VARCHAR2(240);
179085
179086 --
179087 -- Upgrade strategy
179088 --
179089 l_actual_upg_option VARCHAR2(1);
179090 l_enc_upg_option VARCHAR2(1);
179091
179092 --
179093 BEGIN
179094 --
179095 IF g_log_enabled THEN
179096 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_330';
179097 END IF;
179098 --
179099 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
179100
179101 trace
179102 (p_msg => 'BEGIN of AcctLineType_330'
179103 ,p_level => C_LEVEL_PROCEDURE
179104 ,p_module => l_log_module);
179105
179106 END IF;
179107 --
179108 l_component_type := 'AMB_JLT';
179109 l_component_code := 'OFFSET';
179110 l_component_type_code := 'S';
179111 l_component_appl_id := 707;
179112 l_amb_context_code := 'DEFAULT';
179113 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
179114 l_event_class_code := 'FOB_SHIP_SENDER_SHIP';
179115 l_event_type_code := 'FOB_SHIP_SENDER_SHIP_NO_TP';
179116 l_line_definition_owner_code := 'S';
179117 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
179118 --
179119 l_balance_type_code := 'A';
179120 l_segment := NULL;
179121 l_ccid := NULL;
179122 l_adr_transaction_coa_id := NULL;
179123 l_adr_accounting_coa_id := NULL;
179124 l_adr_flexfield_segment_code := NULL;
179125 l_adr_flex_value_set_id := NULL;
179126 l_adr_value_type_code := NULL;
179127 l_adr_value_combination_id := NULL;
179128 l_adr_value_segment_code := NULL;
179129
179130 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
179131 l_bflow_class_code := ''; -- 4219869 Business Flow
179132 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
179133 l_budgetary_control_flag := 'N';
179134
179135 l_bflow_applied_to_amt_idx := NULL; -- 5132302
179136 l_bflow_applied_to_amt := NULL; -- 5132302
179137 l_entered_amt_idx := NULL; -- 4262811
179138 l_accted_amt_idx := NULL; -- 4262811
179139 l_acc_rev_flag := NULL; -- 4262811
179140 l_accrual_line_num := NULL; -- 4262811
179141 l_tmp_amt := NULL; -- 4262811
179142 --
179143
179144 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
179145 l_balance_type_code <> 'B' THEN
179146 IF NVL(p_source_97,9E125) = 2 AND
179147 p_source_95 <= 0
179148 THEN
179149
179150 --
179151 XLA_AE_LINES_PKG.SetNewLine;
179152
179153 p_balance_type_code := l_balance_type_code;
179154 -- set the flag so later we will know whether the gain loss line needs to be created
179155
179156 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
179157 p_actual_flag :='A';
179158 END IF;
179159
179160 --
179161 -- bulk performance
179162 --
179163 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
179164 p_header_num => 0); -- 4262811
179165 --
179166 -- set accounting line options
179167 --
179168 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
179169 p_natural_side_code => 'D'
179170 , p_gain_or_loss_flag => 'N'
179171 , p_gl_transfer_mode_code => 'S'
179172 , p_acct_entry_type_code => 'A'
179173 , p_switch_side_flag => 'Y'
179174 , p_merge_duplicate_code => 'N'
179175 );
179176 --
179177 l_acc_rev_natural_side_code := 'C'; -- 4262811
179178 --
179179 --
179180 -- set accounting line type info
179181 --
179182 xla_ae_lines_pkg.SetAcctLineType
179183 (p_component_type => l_component_type
179184 ,p_event_type_code => l_event_type_code
179185 ,p_line_definition_owner_code => l_line_definition_owner_code
179186 ,p_line_definition_code => l_line_definition_code
179187 ,p_accounting_line_code => l_component_code
179188 ,p_accounting_line_type_code => l_component_type_code
179189 ,p_accounting_line_appl_id => l_component_appl_id
179190 ,p_amb_context_code => l_amb_context_code
179191 ,p_entity_code => l_entity_code
179192 ,p_event_class_code => l_event_class_code);
179193 --
179194 -- set accounting class
179195 --
179196 xla_ae_lines_pkg.SetAcctClass(
179197 p_accounting_class_code => 'OFFSET'
179198 , p_ae_header_id => l_ae_header_id
179199 );
179200
179201 --
179202 -- set rounding class
179203 --
179204 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
179205 'OFFSET';
179206
179207 --
179208 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
179209 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
179210 --
179211 -- bulk performance
179212 --
179213 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
179214
179215 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
179216 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
179217
179218 -- 4955764
179219 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
179220 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
179221
179222 -- 4458381 Public Sector Enh
179223
179224 --
179225 -- set accounting attributes for the line type
179226 --
179227 l_entered_amt_idx := 3;
179228 l_accted_amt_idx := 8;
179229 l_bflow_applied_to_amt_idx := NULL; -- 5132302
179230 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
179231 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
179232 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
179233 l_rec_acct_attrs.array_char_value(2) := p_source_85;
179234 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
179235 l_rec_acct_attrs.array_num_value(3) := p_source_91;
179236 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
179237 l_rec_acct_attrs.array_char_value(4) := p_source_88;
179238 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
179239 l_rec_acct_attrs.array_date_value(5) := p_source_92;
179240 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
179241 l_rec_acct_attrs.array_num_value(6) := p_source_93;
179242 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
179243 l_rec_acct_attrs.array_char_value(7) := p_source_94;
179244 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
179245 l_rec_acct_attrs.array_num_value(8) := p_source_95;
179246
179247 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
179248 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
179249
179250 ---------------------------------------------------------------------------------------------------------------
179251 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
179252 ---------------------------------------------------------------------------------------------------------------
179253 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
179254
179255 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
179256 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
179257
179258 IF xla_accounting_cache_pkg.GetValueChar
179259 (p_source_code => 'LEDGER_CATEGORY_CODE'
179260 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
179261 AND l_bflow_method_code = 'PRIOR_ENTRY'
179262 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
179263 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
179264 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
179265 )
179266 THEN
179267 xla_ae_lines_pkg.BflowUpgEntry
179268 (p_business_method_code => l_bflow_method_code
179269 ,p_business_class_code => l_bflow_class_code
179270 ,p_balance_type => l_balance_type_code);
179271 ELSE
179272 NULL;
179273 -- No business flow processing for business flow method of NONE.
179274 END IF;
179275
179276 --
179277 -- call analytical criteria
179278 --
179279
179280 --
179281 -- call description
179282 --
179283 -- No description or it is inherited.
179284 --
179285 -- call ADRs
179286 -- Bug 4922099
179287 --
179288 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
179289 (NVL(l_actual_upg_option, 'N') = 'O') OR
179290 (NVL(l_enc_upg_option, 'N') = 'O')
179291 )
179292 THEN
179293 NULL;
179294 --
179295 --
179296
179297 l_ccid := AcctDerRule_6(
179298 p_application_id => p_application_id
179299 , p_ae_header_id => l_ae_header_id
179300 , p_source_11 => p_source_11
179301 , x_transaction_coa_id => l_adr_transaction_coa_id
179302 , x_accounting_coa_id => l_adr_accounting_coa_id
179303 , x_value_type_code => l_adr_value_type_code
179304 , p_side => 'NA'
179305 );
179306
179307 xla_ae_lines_pkg.set_ccid(
179308 p_code_combination_id => l_ccid
179309 , p_value_type_code => l_adr_value_type_code
179310 , p_transaction_coa_id => l_adr_transaction_coa_id
179311 , p_accounting_coa_id => l_adr_accounting_coa_id
179312 , p_adr_code => 'CST_DEFAULT'
179313 , p_adr_type_code => 'S'
179314 , p_component_type => l_component_type
179315 , p_component_code => l_component_code
179316 , p_component_type_code => l_component_type_code
179317 , p_component_appl_id => l_component_appl_id
179318 , p_amb_context_code => l_amb_context_code
179319 , p_side => 'NA'
179320 );
179321
179322
179323 --
179324 --
179325 END IF;
179326 --
179327 -- Bug 4922099
179328 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
179329 (NVL(l_enc_upg_option, 'N') = 'O')
179330 ) AND
179331 (l_bflow_method_code = 'PRIOR_ENTRY')
179332 )
179333 THEN
179334 IF
179335 --
179336 1 = 2
179337 --
179338 THEN
179339 xla_accounting_err_pkg.build_message
179340 (p_appli_s_name => 'XLA'
179341 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
179342 ,p_token_1 => 'LINE_NUMBER'
179343 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
179344 ,p_token_2 => 'LINE_TYPE_NAME'
179345 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
179346 l_component_type
179347 ,l_component_code
179348 ,l_component_type_code
179349 ,l_component_appl_id
179350 ,l_amb_context_code
179351 ,l_entity_code
179352 ,l_event_class_code
179353 )
179354 ,p_token_3 => 'OWNER'
179355 ,p_value_3 => xla_lookups_pkg.get_meaning(
179356 p_lookup_type => 'XLA_OWNER_TYPE'
179357 ,p_lookup_code => l_component_type_code
179358 )
179359 ,p_token_4 => 'PRODUCT_NAME'
179360 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
179361 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
179362 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
179363 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
179364 ,p_ae_header_id => NULL
179365 );
179366
179367 IF (C_LEVEL_ERROR>= g_log_level) THEN
179368 trace
179369 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
179370 ,p_level => C_LEVEL_ERROR
179371 ,p_module => l_log_module);
179372 END IF;
179373 END IF;
179374 END IF;
179375 --
179376 --
179377 ------------------------------------------------------------------------------------------------
179378 -- 4219869 Business Flow
179379 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
179380 -- Prior Entry. Currently, the following code is always generated.
179381 ------------------------------------------------------------------------------------------------
179382 XLA_AE_LINES_PKG.ValidateCurrentLine;
179383
179384 ------------------------------------------------------------------------------------
179385 -- 4219869 Business Flow
179386 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
179387 ------------------------------------------------------------------------------------
179388 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
179389
179390 ----------------------------------------------------------------------------------
179391 -- 4219869 Business Flow
179392 -- Update journal entry status -- Need to generate this within IF <condition>
179393 ----------------------------------------------------------------------------------
179394 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
179395 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
179396 ,p_balance_type_code => l_balance_type_code
179397 );
179398
179399 -------------------------------------------------------------------------------------------
179400 -- 4262811 - Generate the Accrual Reversal lines
179401 -------------------------------------------------------------------------------------------
179402 BEGIN
179403 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
179404 (g_array_event(p_event_id).array_value_num('header_index'));
179405 IF l_acc_rev_flag IS NULL THEN
179406 l_acc_rev_flag := 'N';
179407 END IF;
179408 EXCEPTION
179409 WHEN OTHERS THEN
179410 l_acc_rev_flag := 'N';
179411 END;
179412 --
179413 IF (l_acc_rev_flag = 'Y') THEN
179414
179415 -- 4645092 ------------------------------------------------------------------------------
179416 -- To allow MPA report to determine if it should generate report process
179417 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
179418 ------------------------------------------------------------------------------------------
179419
179420 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
179421 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
179422 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
179423 -- call ADRs
179424 -- Bug 4922099
179425 --
179426 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
179427 (NVL(l_actual_upg_option, 'N') = 'O') OR
179428 (NVL(l_enc_upg_option, 'N') = 'O')
179429 )
179430 THEN
179431 NULL;
179432 --
179433 --
179434
179435 l_ccid := AcctDerRule_6(
179436 p_application_id => p_application_id
179437 , p_ae_header_id => l_ae_header_id
179438 , p_source_11 => p_source_11
179439 , x_transaction_coa_id => l_adr_transaction_coa_id
179440 , x_accounting_coa_id => l_adr_accounting_coa_id
179441 , x_value_type_code => l_adr_value_type_code
179442 , p_side => 'NA'
179443 );
179444
179445 xla_ae_lines_pkg.set_ccid(
179446 p_code_combination_id => l_ccid
179447 , p_value_type_code => l_adr_value_type_code
179448 , p_transaction_coa_id => l_adr_transaction_coa_id
179449 , p_accounting_coa_id => l_adr_accounting_coa_id
179450 , p_adr_code => 'CST_DEFAULT'
179451 , p_adr_type_code => 'S'
179452 , p_component_type => l_component_type
179453 , p_component_code => l_component_code
179454 , p_component_type_code => l_component_type_code
179455 , p_component_appl_id => l_component_appl_id
179456 , p_amb_context_code => l_amb_context_code
179457 , p_side => 'NA'
179458 );
179459
179460
179461 --
179462 --
179463 END IF;
179464
179465 --
179466 -- Update the line information that should be overwritten
179467 --
179468 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
179469 p_header_num => 1);
179470 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
179471
179472 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
179473
179474 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
179475 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
179476 END IF;
179477
179478 --
179479 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
179480 --
179481 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
179482 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
179483 ELSE
179484 ---------------------------------------------------------------------------------------------------
179485 -- 4262811a Switch Sign
179486 ---------------------------------------------------------------------------------------------------
179487 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
179488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
179489 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
179490 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
179491 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
179492 -- 5132302
179493 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
179494 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
179495
179496 END IF;
179497
179498 -- 4955764
179499 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
179500 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
179501
179502
179503 XLA_AE_LINES_PKG.ValidateCurrentLine;
179504 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
179505
179506 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
179507 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
179508 ,p_balance_type_code => l_balance_type_code);
179509
179510 END IF;
179511
179512 -----------------------------------------------------------------------------------------
179513 -- 4262811 Multiperiod Accounting
179514 -----------------------------------------------------------------------------------------
179515 -- No MPA option is assigned.
179516
179517
179518 END IF;
179519 END IF;
179520 --
179521
179522 --
179523 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
179524 trace
179525 (p_msg => 'END of AcctLineType_330'
179526 ,p_level => C_LEVEL_PROCEDURE
179527 ,p_module => l_log_module);
179528 END IF;
179529 --
179530 EXCEPTION
179531 WHEN xla_exceptions_pkg.application_exception THEN
179532 RAISE;
179533 WHEN OTHERS THEN
179534 xla_exceptions_pkg.raise_message
179535 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_330');
179536 END AcctLineType_330;
179537 --
179538
179539 ---------------------------------------
179540 --
179541 -- PRIVATE FUNCTION
179542 -- AcctLineType_331
179543 --
179544 ---------------------------------------
179545 PROCEDURE AcctLineType_331 (
179546 p_application_id IN NUMBER
179547 ,p_event_id IN NUMBER
179548 ,p_calculate_acctd_flag IN VARCHAR2
179549 ,p_calculate_g_l_flag IN VARCHAR2
179550 ,p_actual_flag IN OUT VARCHAR2
179551 ,p_balance_type_code OUT VARCHAR2
179552 ,p_gain_or_loss_ref OUT VARCHAR2
179553
179554 --Cost Management Default Account
179555 , p_source_11 IN NUMBER
179556 --DISTRIBUTION_IDENTIFIER
179557 , p_source_84 IN NUMBER
179558 --Distribution Type
179559 , p_source_85 IN VARCHAR2
179560 , p_source_85_meaning IN VARCHAR2
179561 --Entered Currency Code
179562 , p_source_88 IN VARCHAR2
179563 --Entered Amount
179564 , p_source_91 IN NUMBER
179565 --Currency Conversion Date
179566 , p_source_92 IN DATE
179567 --Currency Conversion Rate
179568 , p_source_93 IN NUMBER
179569 --Currency Conversion Type
179570 , p_source_94 IN VARCHAR2
179571 --Accounted Amount
179572 , p_source_95 IN NUMBER
179573 --Accounting Line Type
179574 , p_source_97 IN NUMBER
179575 )
179576 IS
179577
179578 l_component_type VARCHAR2(80);
179579 l_component_code VARCHAR2(30);
179580 l_component_type_code VARCHAR2(1);
179581 l_component_appl_id INTEGER;
179582 l_amb_context_code VARCHAR2(30);
179583 l_entity_code VARCHAR2(30);
179584 l_event_class_code VARCHAR2(30);
179585 l_ae_header_id NUMBER;
179586 l_event_type_code VARCHAR2(30);
179587 l_line_definition_code VARCHAR2(30);
179588 l_line_definition_owner_code VARCHAR2(1);
179589 --
179590 -- adr variables
179591 l_segment VARCHAR2(30);
179592 l_ccid NUMBER;
179593 l_adr_transaction_coa_id NUMBER;
179594 l_adr_accounting_coa_id NUMBER;
179595 l_adr_flexfield_segment_code VARCHAR2(30);
179596 l_adr_flex_value_set_id NUMBER;
179597 l_adr_value_type_code VARCHAR2(30);
179598 l_adr_value_combination_id NUMBER;
179599 l_adr_value_segment_code VARCHAR2(30);
179600
179601 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
179602 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
179603 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
179604 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
179605
179606 -- 4262811 Variables ------------------------------------------------------------------------------------------
179607 l_entered_amt_idx NUMBER;
179608 l_accted_amt_idx NUMBER;
179609 l_acc_rev_flag VARCHAR2(1);
179610 l_accrual_line_num NUMBER;
179611 l_tmp_amt NUMBER;
179612 l_acc_rev_natural_side_code VARCHAR2(1);
179613
179614 l_num_entries NUMBER;
179615 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
179616 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
179617 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
179618 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
179619 l_recog_line_1 NUMBER;
179620 l_recog_line_2 NUMBER;
179621
179622 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
179623 l_bflow_applied_to_amt NUMBER; -- 5132302
179624 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
179625
179626 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
179627
179628 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
179629 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
179630
179631 ---------------------------------------------------------------------------------------------------------------
179632
179633
179634 --
179635 -- bulk performance
179636 --
179637 l_balance_type_code VARCHAR2(1);
179638 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
179639 l_log_module VARCHAR2(240);
179640
179641 --
179642 -- Upgrade strategy
179643 --
179644 l_actual_upg_option VARCHAR2(1);
179645 l_enc_upg_option VARCHAR2(1);
179646
179647 --
179648 BEGIN
179649 --
179650 IF g_log_enabled THEN
179651 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_331';
179652 END IF;
179653 --
179654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
179655
179656 trace
179657 (p_msg => 'BEGIN of AcctLineType_331'
179658 ,p_level => C_LEVEL_PROCEDURE
179659 ,p_module => l_log_module);
179660
179661 END IF;
179662 --
179663 l_component_type := 'AMB_JLT';
179664 l_component_code := 'OFFSET';
179665 l_component_type_code := 'S';
179666 l_component_appl_id := 707;
179667 l_amb_context_code := 'DEFAULT';
179668 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
179669 l_event_class_code := 'LOT';
179670 l_event_type_code := 'LOT_ALL';
179671 l_line_definition_owner_code := 'S';
179672 l_line_definition_code := 'WIP_MATERIAL_LOT';
179673 --
179674 l_balance_type_code := 'A';
179675 l_segment := NULL;
179676 l_ccid := NULL;
179677 l_adr_transaction_coa_id := NULL;
179678 l_adr_accounting_coa_id := NULL;
179679 l_adr_flexfield_segment_code := NULL;
179680 l_adr_flex_value_set_id := NULL;
179681 l_adr_value_type_code := NULL;
179682 l_adr_value_combination_id := NULL;
179683 l_adr_value_segment_code := NULL;
179684
179685 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
179686 l_bflow_class_code := ''; -- 4219869 Business Flow
179687 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
179688 l_budgetary_control_flag := 'N';
179689
179690 l_bflow_applied_to_amt_idx := NULL; -- 5132302
179691 l_bflow_applied_to_amt := NULL; -- 5132302
179692 l_entered_amt_idx := NULL; -- 4262811
179693 l_accted_amt_idx := NULL; -- 4262811
179694 l_acc_rev_flag := NULL; -- 4262811
179695 l_accrual_line_num := NULL; -- 4262811
179696 l_tmp_amt := NULL; -- 4262811
179697 --
179698
179699 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
179700 l_balance_type_code <> 'B' THEN
179701 IF NVL(p_source_97,9E125) = 25 OR
179702 NVL(p_source_97,9E125) = 27
179703 THEN
179704
179705 --
179706 XLA_AE_LINES_PKG.SetNewLine;
179707
179708 p_balance_type_code := l_balance_type_code;
179709 -- set the flag so later we will know whether the gain loss line needs to be created
179710
179711 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
179712 p_actual_flag :='A';
179713 END IF;
179714
179715 --
179716 -- bulk performance
179717 --
179718 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
179719 p_header_num => 0); -- 4262811
179720 --
179721 -- set accounting line options
179722 --
179723 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
179724 p_natural_side_code => 'D'
179725 , p_gain_or_loss_flag => 'N'
179726 , p_gl_transfer_mode_code => 'S'
179727 , p_acct_entry_type_code => 'A'
179728 , p_switch_side_flag => 'Y'
179729 , p_merge_duplicate_code => 'N'
179730 );
179731 --
179732 l_acc_rev_natural_side_code := 'C'; -- 4262811
179733 --
179734 --
179735 -- set accounting line type info
179736 --
179737 xla_ae_lines_pkg.SetAcctLineType
179738 (p_component_type => l_component_type
179739 ,p_event_type_code => l_event_type_code
179740 ,p_line_definition_owner_code => l_line_definition_owner_code
179741 ,p_line_definition_code => l_line_definition_code
179742 ,p_accounting_line_code => l_component_code
179743 ,p_accounting_line_type_code => l_component_type_code
179744 ,p_accounting_line_appl_id => l_component_appl_id
179745 ,p_amb_context_code => l_amb_context_code
179746 ,p_entity_code => l_entity_code
179747 ,p_event_class_code => l_event_class_code);
179748 --
179749 -- set accounting class
179750 --
179751 xla_ae_lines_pkg.SetAcctClass(
179752 p_accounting_class_code => 'OFFSET'
179753 , p_ae_header_id => l_ae_header_id
179754 );
179755
179756 --
179757 -- set rounding class
179758 --
179759 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
179760 'OFFSET';
179761
179762 --
179763 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
179764 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
179765 --
179766 -- bulk performance
179767 --
179768 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
179769
179770 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
179771 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
179772
179773 -- 4955764
179774 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
179775 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
179776
179777 -- 4458381 Public Sector Enh
179778
179779 --
179780 -- set accounting attributes for the line type
179781 --
179782 l_entered_amt_idx := 3;
179783 l_accted_amt_idx := 8;
179784 l_bflow_applied_to_amt_idx := NULL; -- 5132302
179785 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
179786 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
179787 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
179788 l_rec_acct_attrs.array_char_value(2) := p_source_85;
179789 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
179790 l_rec_acct_attrs.array_num_value(3) := p_source_91;
179791 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
179792 l_rec_acct_attrs.array_char_value(4) := p_source_88;
179793 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
179794 l_rec_acct_attrs.array_date_value(5) := p_source_92;
179795 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
179796 l_rec_acct_attrs.array_num_value(6) := p_source_93;
179797 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
179798 l_rec_acct_attrs.array_char_value(7) := p_source_94;
179799 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
179800 l_rec_acct_attrs.array_num_value(8) := p_source_95;
179801
179802 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
179803 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
179804
179805 ---------------------------------------------------------------------------------------------------------------
179806 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
179807 ---------------------------------------------------------------------------------------------------------------
179808 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
179809
179810 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
179811 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
179812
179813 IF xla_accounting_cache_pkg.GetValueChar
179814 (p_source_code => 'LEDGER_CATEGORY_CODE'
179815 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
179816 AND l_bflow_method_code = 'PRIOR_ENTRY'
179817 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
179818 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
179819 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
179820 )
179821 THEN
179822 xla_ae_lines_pkg.BflowUpgEntry
179823 (p_business_method_code => l_bflow_method_code
179824 ,p_business_class_code => l_bflow_class_code
179825 ,p_balance_type => l_balance_type_code);
179826 ELSE
179827 NULL;
179828 -- No business flow processing for business flow method of NONE.
179829 END IF;
179830
179831 --
179832 -- call analytical criteria
179833 --
179834
179835 --
179836 -- call description
179837 --
179838 -- No description or it is inherited.
179839 --
179840 -- call ADRs
179841 -- Bug 4922099
179842 --
179843 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
179844 (NVL(l_actual_upg_option, 'N') = 'O') OR
179845 (NVL(l_enc_upg_option, 'N') = 'O')
179846 )
179847 THEN
179848 NULL;
179849 --
179850 --
179851
179852 l_ccid := AcctDerRule_6(
179853 p_application_id => p_application_id
179854 , p_ae_header_id => l_ae_header_id
179855 , p_source_11 => p_source_11
179856 , x_transaction_coa_id => l_adr_transaction_coa_id
179857 , x_accounting_coa_id => l_adr_accounting_coa_id
179858 , x_value_type_code => l_adr_value_type_code
179859 , p_side => 'NA'
179860 );
179861
179862 xla_ae_lines_pkg.set_ccid(
179863 p_code_combination_id => l_ccid
179864 , p_value_type_code => l_adr_value_type_code
179865 , p_transaction_coa_id => l_adr_transaction_coa_id
179866 , p_accounting_coa_id => l_adr_accounting_coa_id
179867 , p_adr_code => 'CST_DEFAULT'
179868 , p_adr_type_code => 'S'
179869 , p_component_type => l_component_type
179870 , p_component_code => l_component_code
179871 , p_component_type_code => l_component_type_code
179872 , p_component_appl_id => l_component_appl_id
179873 , p_amb_context_code => l_amb_context_code
179874 , p_side => 'NA'
179875 );
179876
179877
179878 --
179879 --
179880 END IF;
179881 --
179882 -- Bug 4922099
179883 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
179884 (NVL(l_enc_upg_option, 'N') = 'O')
179885 ) AND
179886 (l_bflow_method_code = 'PRIOR_ENTRY')
179887 )
179888 THEN
179889 IF
179890 --
179891 1 = 2
179892 --
179893 THEN
179894 xla_accounting_err_pkg.build_message
179895 (p_appli_s_name => 'XLA'
179896 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
179897 ,p_token_1 => 'LINE_NUMBER'
179898 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
179899 ,p_token_2 => 'LINE_TYPE_NAME'
179900 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
179901 l_component_type
179902 ,l_component_code
179903 ,l_component_type_code
179904 ,l_component_appl_id
179905 ,l_amb_context_code
179906 ,l_entity_code
179907 ,l_event_class_code
179908 )
179909 ,p_token_3 => 'OWNER'
179910 ,p_value_3 => xla_lookups_pkg.get_meaning(
179911 p_lookup_type => 'XLA_OWNER_TYPE'
179912 ,p_lookup_code => l_component_type_code
179913 )
179914 ,p_token_4 => 'PRODUCT_NAME'
179915 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
179916 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
179917 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
179918 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
179919 ,p_ae_header_id => NULL
179920 );
179921
179922 IF (C_LEVEL_ERROR>= g_log_level) THEN
179923 trace
179924 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
179925 ,p_level => C_LEVEL_ERROR
179926 ,p_module => l_log_module);
179927 END IF;
179928 END IF;
179929 END IF;
179930 --
179931 --
179932 ------------------------------------------------------------------------------------------------
179933 -- 4219869 Business Flow
179934 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
179935 -- Prior Entry. Currently, the following code is always generated.
179936 ------------------------------------------------------------------------------------------------
179937 XLA_AE_LINES_PKG.ValidateCurrentLine;
179938
179939 ------------------------------------------------------------------------------------
179940 -- 4219869 Business Flow
179941 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
179942 ------------------------------------------------------------------------------------
179943 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
179944
179945 ----------------------------------------------------------------------------------
179946 -- 4219869 Business Flow
179947 -- Update journal entry status -- Need to generate this within IF <condition>
179948 ----------------------------------------------------------------------------------
179949 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
179950 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
179951 ,p_balance_type_code => l_balance_type_code
179952 );
179953
179954 -------------------------------------------------------------------------------------------
179955 -- 4262811 - Generate the Accrual Reversal lines
179956 -------------------------------------------------------------------------------------------
179957 BEGIN
179958 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
179959 (g_array_event(p_event_id).array_value_num('header_index'));
179960 IF l_acc_rev_flag IS NULL THEN
179961 l_acc_rev_flag := 'N';
179962 END IF;
179963 EXCEPTION
179964 WHEN OTHERS THEN
179965 l_acc_rev_flag := 'N';
179966 END;
179967 --
179968 IF (l_acc_rev_flag = 'Y') THEN
179969
179970 -- 4645092 ------------------------------------------------------------------------------
179971 -- To allow MPA report to determine if it should generate report process
179972 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
179973 ------------------------------------------------------------------------------------------
179974
179975 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
179976 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
179977 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
179978 -- call ADRs
179979 -- Bug 4922099
179980 --
179981 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
179982 (NVL(l_actual_upg_option, 'N') = 'O') OR
179983 (NVL(l_enc_upg_option, 'N') = 'O')
179984 )
179985 THEN
179986 NULL;
179987 --
179988 --
179989
179990 l_ccid := AcctDerRule_6(
179991 p_application_id => p_application_id
179992 , p_ae_header_id => l_ae_header_id
179993 , p_source_11 => p_source_11
179994 , x_transaction_coa_id => l_adr_transaction_coa_id
179995 , x_accounting_coa_id => l_adr_accounting_coa_id
179996 , x_value_type_code => l_adr_value_type_code
179997 , p_side => 'NA'
179998 );
179999
180000 xla_ae_lines_pkg.set_ccid(
180001 p_code_combination_id => l_ccid
180002 , p_value_type_code => l_adr_value_type_code
180003 , p_transaction_coa_id => l_adr_transaction_coa_id
180004 , p_accounting_coa_id => l_adr_accounting_coa_id
180005 , p_adr_code => 'CST_DEFAULT'
180006 , p_adr_type_code => 'S'
180007 , p_component_type => l_component_type
180008 , p_component_code => l_component_code
180009 , p_component_type_code => l_component_type_code
180010 , p_component_appl_id => l_component_appl_id
180011 , p_amb_context_code => l_amb_context_code
180012 , p_side => 'NA'
180013 );
180014
180015
180016 --
180017 --
180018 END IF;
180019
180020 --
180021 -- Update the line information that should be overwritten
180022 --
180023 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
180024 p_header_num => 1);
180025 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
180026
180027 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
180028
180029 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
180030 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
180031 END IF;
180032
180033 --
180034 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
180035 --
180036 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
180037 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
180038 ELSE
180039 ---------------------------------------------------------------------------------------------------
180040 -- 4262811a Switch Sign
180041 ---------------------------------------------------------------------------------------------------
180042 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
180043 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
180044 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180045 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
180046 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180047 -- 5132302
180048 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
180049 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180050
180051 END IF;
180052
180053 -- 4955764
180054 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
180055 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
180056
180057
180058 XLA_AE_LINES_PKG.ValidateCurrentLine;
180059 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
180060
180061 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
180062 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
180063 ,p_balance_type_code => l_balance_type_code);
180064
180065 END IF;
180066
180067 -----------------------------------------------------------------------------------------
180068 -- 4262811 Multiperiod Accounting
180069 -----------------------------------------------------------------------------------------
180070 -- No MPA option is assigned.
180071
180072
180073 END IF;
180074 END IF;
180075 --
180076
180077 --
180078 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
180079 trace
180080 (p_msg => 'END of AcctLineType_331'
180081 ,p_level => C_LEVEL_PROCEDURE
180082 ,p_module => l_log_module);
180083 END IF;
180084 --
180085 EXCEPTION
180086 WHEN xla_exceptions_pkg.application_exception THEN
180087 RAISE;
180088 WHEN OTHERS THEN
180089 xla_exceptions_pkg.raise_message
180090 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_331');
180091 END AcctLineType_331;
180092 --
180093
180094 ---------------------------------------
180095 --
180096 -- PRIVATE FUNCTION
180097 -- AcctLineType_332
180098 --
180099 ---------------------------------------
180100 PROCEDURE AcctLineType_332 (
180101 p_application_id IN NUMBER
180102 ,p_event_id IN NUMBER
180103 ,p_calculate_acctd_flag IN VARCHAR2
180104 ,p_calculate_g_l_flag IN VARCHAR2
180105 ,p_actual_flag IN OUT VARCHAR2
180106 ,p_balance_type_code OUT VARCHAR2
180107 ,p_gain_or_loss_ref OUT VARCHAR2
180108
180109 --TRANSACTION_ID
180110 , p_source_1 IN NUMBER
180111 --Item Concatenated Segments
180112 , p_source_2 IN VARCHAR2
180113 --Transaction Quantity
180114 , p_source_3 IN NUMBER
180115 --Transaction Unit of Measure Code
180116 , p_source_4 IN VARCHAR2
180117 --Inventory Transaction Type Description
180118 , p_source_5 IN VARCHAR2
180119 --Product Line Accounting Category Expense Account
180120 , p_source_24 IN NUMBER
180121 --Transfer to Subinventory or Cost Group category expense account
180122 , p_source_25 IN NUMBER
180123 --Cost Group Identifier
180124 , p_source_26 IN NUMBER
180125 --INV Header Transfer Cost Group ID
180126 , p_source_27 IN NUMBER
180127 --INV Header Cost Group ID
180128 , p_source_28 IN NUMBER
180129 --Subinventory Name
180130 , p_source_29 IN VARCHAR2
180131 --INV Header Transfer Subinventory
180132 , p_source_31 IN VARCHAR2
180133 --DISTRIBUTION_IDENTIFIER
180134 , p_source_84 IN NUMBER
180135 --Distribution Type
180136 , p_source_85 IN VARCHAR2
180137 , p_source_85_meaning IN VARCHAR2
180138 --Entered Currency Code
180139 , p_source_88 IN VARCHAR2
180140 --Entered Amount
180141 , p_source_91 IN NUMBER
180142 --Currency Conversion Date
180143 , p_source_92 IN DATE
180144 --Currency Conversion Rate
180145 , p_source_93 IN NUMBER
180146 --Currency Conversion Type
180147 , p_source_94 IN VARCHAR2
180148 --Accounted Amount
180149 , p_source_95 IN NUMBER
180150 --Accounting Line Type
180151 , p_source_97 IN NUMBER
180152 )
180153 IS
180154
180155 l_component_type VARCHAR2(80);
180156 l_component_code VARCHAR2(30);
180157 l_component_type_code VARCHAR2(1);
180158 l_component_appl_id INTEGER;
180159 l_amb_context_code VARCHAR2(30);
180160 l_entity_code VARCHAR2(30);
180161 l_event_class_code VARCHAR2(30);
180162 l_ae_header_id NUMBER;
180163 l_event_type_code VARCHAR2(30);
180164 l_line_definition_code VARCHAR2(30);
180165 l_line_definition_owner_code VARCHAR2(1);
180166 --
180167 -- adr variables
180168 l_segment VARCHAR2(30);
180169 l_ccid NUMBER;
180170 l_adr_transaction_coa_id NUMBER;
180171 l_adr_accounting_coa_id NUMBER;
180172 l_adr_flexfield_segment_code VARCHAR2(30);
180173 l_adr_flex_value_set_id NUMBER;
180174 l_adr_value_type_code VARCHAR2(30);
180175 l_adr_value_combination_id NUMBER;
180176 l_adr_value_segment_code VARCHAR2(30);
180177
180178 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
180179 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
180180 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
180181 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
180182
180183 -- 4262811 Variables ------------------------------------------------------------------------------------------
180184 l_entered_amt_idx NUMBER;
180185 l_accted_amt_idx NUMBER;
180186 l_acc_rev_flag VARCHAR2(1);
180187 l_accrual_line_num NUMBER;
180188 l_tmp_amt NUMBER;
180189 l_acc_rev_natural_side_code VARCHAR2(1);
180190
180191 l_num_entries NUMBER;
180192 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
180193 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
180194 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
180195 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
180196 l_recog_line_1 NUMBER;
180197 l_recog_line_2 NUMBER;
180198
180199 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
180200 l_bflow_applied_to_amt NUMBER; -- 5132302
180201 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
180202
180203 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
180204
180205 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
180206 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
180207
180208 ---------------------------------------------------------------------------------------------------------------
180209
180210
180211 --
180212 -- bulk performance
180213 --
180214 l_balance_type_code VARCHAR2(1);
180215 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
180216 l_log_module VARCHAR2(240);
180217
180218 --
180219 -- Upgrade strategy
180220 --
180221 l_actual_upg_option VARCHAR2(1);
180222 l_enc_upg_option VARCHAR2(1);
180223
180224 --
180225 BEGIN
180226 --
180227 IF g_log_enabled THEN
180228 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_332';
180229 END IF;
180230 --
180231 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
180232
180233 trace
180234 (p_msg => 'BEGIN of AcctLineType_332'
180235 ,p_level => C_LEVEL_PROCEDURE
180236 ,p_module => l_log_module);
180237
180238 END IF;
180239 --
180240 l_component_type := 'AMB_JLT';
180241 l_component_code := 'OFFSET';
180242 l_component_type_code := 'S';
180243 l_component_appl_id := 707;
180244 l_amb_context_code := 'DEFAULT';
180245 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
180246 l_event_class_code := 'USER_DEFINE';
180247 l_event_type_code := 'UCG_TXFR';
180248 l_line_definition_owner_code := 'S';
180249 l_line_definition_code := 'PI_CG_TXFR';
180250 --
180251 l_balance_type_code := 'A';
180252 l_segment := NULL;
180253 l_ccid := NULL;
180254 l_adr_transaction_coa_id := NULL;
180255 l_adr_accounting_coa_id := NULL;
180256 l_adr_flexfield_segment_code := NULL;
180257 l_adr_flex_value_set_id := NULL;
180258 l_adr_value_type_code := NULL;
180259 l_adr_value_combination_id := NULL;
180260 l_adr_value_segment_code := NULL;
180261
180262 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
180263 l_bflow_class_code := ''; -- 4219869 Business Flow
180264 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
180265 l_budgetary_control_flag := 'N';
180266
180267 l_bflow_applied_to_amt_idx := NULL; -- 5132302
180268 l_bflow_applied_to_amt := NULL; -- 5132302
180269 l_entered_amt_idx := NULL; -- 4262811
180270 l_accted_amt_idx := NULL; -- 4262811
180271 l_acc_rev_flag := NULL; -- 4262811
180272 l_accrual_line_num := NULL; -- 4262811
180273 l_tmp_amt := NULL; -- 4262811
180274 --
180275
180276 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
180277 l_balance_type_code <> 'B' THEN
180278 IF NVL(p_source_97,9E125) = 2
180279 THEN
180280
180281 --
180282 XLA_AE_LINES_PKG.SetNewLine;
180283
180284 p_balance_type_code := l_balance_type_code;
180285 -- set the flag so later we will know whether the gain loss line needs to be created
180286
180287 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
180288 p_actual_flag :='A';
180289 END IF;
180290
180291 --
180292 -- bulk performance
180293 --
180294 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
180295 p_header_num => 0); -- 4262811
180296 --
180297 -- set accounting line options
180298 --
180299 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
180300 p_natural_side_code => 'D'
180301 , p_gain_or_loss_flag => 'N'
180302 , p_gl_transfer_mode_code => 'S'
180303 , p_acct_entry_type_code => 'A'
180304 , p_switch_side_flag => 'Y'
180305 , p_merge_duplicate_code => 'N'
180306 );
180307 --
180308 l_acc_rev_natural_side_code := 'C'; -- 4262811
180309 --
180310 --
180311 -- set accounting line type info
180312 --
180313 xla_ae_lines_pkg.SetAcctLineType
180314 (p_component_type => l_component_type
180315 ,p_event_type_code => l_event_type_code
180316 ,p_line_definition_owner_code => l_line_definition_owner_code
180317 ,p_line_definition_code => l_line_definition_code
180318 ,p_accounting_line_code => l_component_code
180319 ,p_accounting_line_type_code => l_component_type_code
180320 ,p_accounting_line_appl_id => l_component_appl_id
180321 ,p_amb_context_code => l_amb_context_code
180322 ,p_entity_code => l_entity_code
180323 ,p_event_class_code => l_event_class_code);
180324 --
180325 -- set accounting class
180326 --
180327 xla_ae_lines_pkg.SetAcctClass(
180328 p_accounting_class_code => 'OFFSET'
180329 , p_ae_header_id => l_ae_header_id
180330 );
180331
180332 --
180333 -- set rounding class
180334 --
180335 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
180336 'OFFSET';
180337
180338 --
180339 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
180340 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
180341 --
180342 -- bulk performance
180343 --
180344 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
180345
180346 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
180347 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
180348
180349 -- 4955764
180350 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
180351 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
180352
180353 -- 4458381 Public Sector Enh
180354
180355 --
180356 -- set accounting attributes for the line type
180357 --
180358 l_entered_amt_idx := 3;
180359 l_accted_amt_idx := 8;
180360 l_bflow_applied_to_amt_idx := NULL; -- 5132302
180361 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
180362 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
180363 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
180364 l_rec_acct_attrs.array_char_value(2) := p_source_85;
180365 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
180366 l_rec_acct_attrs.array_num_value(3) := p_source_91;
180367 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
180368 l_rec_acct_attrs.array_char_value(4) := p_source_88;
180369 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
180370 l_rec_acct_attrs.array_date_value(5) := p_source_92;
180371 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
180372 l_rec_acct_attrs.array_num_value(6) := p_source_93;
180373 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
180374 l_rec_acct_attrs.array_char_value(7) := p_source_94;
180375 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
180376 l_rec_acct_attrs.array_num_value(8) := p_source_95;
180377
180378 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
180379 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
180380
180381 ---------------------------------------------------------------------------------------------------------------
180382 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
180383 ---------------------------------------------------------------------------------------------------------------
180384 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
180385
180386 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
180387 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
180388
180389 IF xla_accounting_cache_pkg.GetValueChar
180390 (p_source_code => 'LEDGER_CATEGORY_CODE'
180391 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
180392 AND l_bflow_method_code = 'PRIOR_ENTRY'
180393 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
180394 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
180395 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
180396 )
180397 THEN
180398 xla_ae_lines_pkg.BflowUpgEntry
180399 (p_business_method_code => l_bflow_method_code
180400 ,p_business_class_code => l_bflow_class_code
180401 ,p_balance_type => l_balance_type_code);
180402 ELSE
180403 NULL;
180404 -- No business flow processing for business flow method of NONE.
180405 END IF;
180406
180407 --
180408 -- call analytical criteria
180409 --
180410
180411 --
180412 -- call description
180413 --
180414
180415 xla_ae_lines_pkg.SetLineDescription(
180416 p_ae_header_id => l_ae_header_id
180417 ,p_description => Description_1 (
180418 p_application_id => p_application_id
180419 , p_ae_header_id => l_ae_header_id
180420 , p_source_1 => p_source_1
180421 , p_source_2 => p_source_2
180422 , p_source_3 => p_source_3
180423 , p_source_4 => p_source_4
180424 , p_source_5 => p_source_5
180425 )
180426 );
180427
180428
180429 --
180430 -- call ADRs
180431 -- Bug 4922099
180432 --
180433 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
180434 (NVL(l_actual_upg_option, 'N') = 'O') OR
180435 (NVL(l_enc_upg_option, 'N') = 'O')
180436 )
180437 THEN
180438 NULL;
180439 --
180440 --
180441
180442 l_ccid := AcctDerRule_15(
180443 p_application_id => p_application_id
180444 , p_ae_header_id => l_ae_header_id
180445 , p_source_24 => p_source_24
180446 , p_source_25 => p_source_25
180447 , p_source_26 => p_source_26
180448 , p_source_27 => p_source_27
180449 , p_source_28 => p_source_28
180450 , p_source_29 => p_source_29
180451 , p_source_31 => p_source_31
180452 , x_transaction_coa_id => l_adr_transaction_coa_id
180453 , x_accounting_coa_id => l_adr_accounting_coa_id
180454 , x_value_type_code => l_adr_value_type_code
180455 , p_side => 'NA'
180456 );
180457
180458 xla_ae_lines_pkg.set_ccid(
180459 p_code_combination_id => l_ccid
180460 , p_value_type_code => l_adr_value_type_code
180461 , p_transaction_coa_id => l_adr_transaction_coa_id
180462 , p_accounting_coa_id => l_adr_accounting_coa_id
180463 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
180464 , p_adr_type_code => 'S'
180465 , p_component_type => l_component_type
180466 , p_component_code => l_component_code
180467 , p_component_type_code => l_component_type_code
180468 , p_component_appl_id => l_component_appl_id
180469 , p_amb_context_code => l_amb_context_code
180470 , p_side => 'NA'
180471 );
180472
180473
180474 --
180475 --
180476 END IF;
180477 --
180478 -- Bug 4922099
180479 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
180480 (NVL(l_enc_upg_option, 'N') = 'O')
180481 ) AND
180482 (l_bflow_method_code = 'PRIOR_ENTRY')
180483 )
180484 THEN
180485 IF
180486 --
180487 1 = 2
180488 --
180489 THEN
180490 xla_accounting_err_pkg.build_message
180491 (p_appli_s_name => 'XLA'
180492 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
180493 ,p_token_1 => 'LINE_NUMBER'
180494 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
180495 ,p_token_2 => 'LINE_TYPE_NAME'
180496 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
180497 l_component_type
180498 ,l_component_code
180499 ,l_component_type_code
180500 ,l_component_appl_id
180501 ,l_amb_context_code
180502 ,l_entity_code
180503 ,l_event_class_code
180504 )
180505 ,p_token_3 => 'OWNER'
180506 ,p_value_3 => xla_lookups_pkg.get_meaning(
180507 p_lookup_type => 'XLA_OWNER_TYPE'
180508 ,p_lookup_code => l_component_type_code
180509 )
180510 ,p_token_4 => 'PRODUCT_NAME'
180511 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
180512 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
180513 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
180514 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
180515 ,p_ae_header_id => NULL
180516 );
180517
180518 IF (C_LEVEL_ERROR>= g_log_level) THEN
180519 trace
180520 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
180521 ,p_level => C_LEVEL_ERROR
180522 ,p_module => l_log_module);
180523 END IF;
180524 END IF;
180525 END IF;
180526 --
180527 --
180528 ------------------------------------------------------------------------------------------------
180529 -- 4219869 Business Flow
180530 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
180531 -- Prior Entry. Currently, the following code is always generated.
180532 ------------------------------------------------------------------------------------------------
180533 XLA_AE_LINES_PKG.ValidateCurrentLine;
180534
180535 ------------------------------------------------------------------------------------
180536 -- 4219869 Business Flow
180537 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
180538 ------------------------------------------------------------------------------------
180539 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
180540
180541 ----------------------------------------------------------------------------------
180542 -- 4219869 Business Flow
180543 -- Update journal entry status -- Need to generate this within IF <condition>
180544 ----------------------------------------------------------------------------------
180545 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
180546 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
180547 ,p_balance_type_code => l_balance_type_code
180548 );
180549
180550 -------------------------------------------------------------------------------------------
180551 -- 4262811 - Generate the Accrual Reversal lines
180552 -------------------------------------------------------------------------------------------
180553 BEGIN
180554 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
180555 (g_array_event(p_event_id).array_value_num('header_index'));
180556 IF l_acc_rev_flag IS NULL THEN
180557 l_acc_rev_flag := 'N';
180558 END IF;
180559 EXCEPTION
180560 WHEN OTHERS THEN
180561 l_acc_rev_flag := 'N';
180562 END;
180563 --
180564 IF (l_acc_rev_flag = 'Y') THEN
180565
180566 -- 4645092 ------------------------------------------------------------------------------
180567 -- To allow MPA report to determine if it should generate report process
180568 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
180569 ------------------------------------------------------------------------------------------
180570
180571 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
180572 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
180573 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
180574 -- call ADRs
180575 -- Bug 4922099
180576 --
180577 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
180578 (NVL(l_actual_upg_option, 'N') = 'O') OR
180579 (NVL(l_enc_upg_option, 'N') = 'O')
180580 )
180581 THEN
180582 NULL;
180583 --
180584 --
180585
180586 l_ccid := AcctDerRule_15(
180587 p_application_id => p_application_id
180588 , p_ae_header_id => l_ae_header_id
180589 , p_source_24 => p_source_24
180590 , p_source_25 => p_source_25
180591 , p_source_26 => p_source_26
180592 , p_source_27 => p_source_27
180593 , p_source_28 => p_source_28
180594 , p_source_29 => p_source_29
180595 , p_source_31 => p_source_31
180596 , x_transaction_coa_id => l_adr_transaction_coa_id
180597 , x_accounting_coa_id => l_adr_accounting_coa_id
180598 , x_value_type_code => l_adr_value_type_code
180599 , p_side => 'NA'
180600 );
180601
180602 xla_ae_lines_pkg.set_ccid(
180603 p_code_combination_id => l_ccid
180604 , p_value_type_code => l_adr_value_type_code
180605 , p_transaction_coa_id => l_adr_transaction_coa_id
180606 , p_accounting_coa_id => l_adr_accounting_coa_id
180607 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
180608 , p_adr_type_code => 'S'
180609 , p_component_type => l_component_type
180610 , p_component_code => l_component_code
180611 , p_component_type_code => l_component_type_code
180612 , p_component_appl_id => l_component_appl_id
180613 , p_amb_context_code => l_amb_context_code
180614 , p_side => 'NA'
180615 );
180616
180617
180618 --
180619 --
180620 END IF;
180621
180622 --
180623 -- Update the line information that should be overwritten
180624 --
180625 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
180626 p_header_num => 1);
180627 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
180628
180629 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
180630
180631 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
180632 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
180633 END IF;
180634
180635 --
180636 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
180637 --
180638 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
180639 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
180640 ELSE
180641 ---------------------------------------------------------------------------------------------------
180642 -- 4262811a Switch Sign
180643 ---------------------------------------------------------------------------------------------------
180644 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
180645 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
180646 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180647 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
180648 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180649 -- 5132302
180650 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
180651 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
180652
180653 END IF;
180654
180655 -- 4955764
180656 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
180657 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
180658
180659
180660 XLA_AE_LINES_PKG.ValidateCurrentLine;
180661 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
180662
180663 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
180664 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
180665 ,p_balance_type_code => l_balance_type_code);
180666
180667 END IF;
180668
180669 -----------------------------------------------------------------------------------------
180670 -- 4262811 Multiperiod Accounting
180671 -----------------------------------------------------------------------------------------
180672 -- No MPA option is assigned.
180673
180674
180675 END IF;
180676 END IF;
180677 --
180678
180679 --
180680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
180681 trace
180682 (p_msg => 'END of AcctLineType_332'
180683 ,p_level => C_LEVEL_PROCEDURE
180684 ,p_module => l_log_module);
180685 END IF;
180686 --
180687 EXCEPTION
180688 WHEN xla_exceptions_pkg.application_exception THEN
180689 RAISE;
180690 WHEN OTHERS THEN
180691 xla_exceptions_pkg.raise_message
180692 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_332');
180693 END AcctLineType_332;
180694 --
180695
180696 ---------------------------------------
180697 --
180698 -- PRIVATE FUNCTION
180699 -- AcctLineType_333
180700 --
180701 ---------------------------------------
180702 PROCEDURE AcctLineType_333 (
180703 p_application_id IN NUMBER
180704 ,p_event_id IN NUMBER
180705 ,p_calculate_acctd_flag IN VARCHAR2
180706 ,p_calculate_g_l_flag IN VARCHAR2
180707 ,p_actual_flag IN OUT VARCHAR2
180708 ,p_balance_type_code OUT VARCHAR2
180709 ,p_gain_or_loss_ref OUT VARCHAR2
180710
180711 --TRANSACTION_ID
180712 , p_source_1 IN NUMBER
180713 --Item Concatenated Segments
180714 , p_source_2 IN VARCHAR2
180715 --Transaction Quantity
180716 , p_source_3 IN NUMBER
180717 --Transaction Unit of Measure Code
180718 , p_source_4 IN VARCHAR2
180719 --Inventory Transaction Type Description
180720 , p_source_5 IN VARCHAR2
180721 --Cost Management Default Account
180722 , p_source_11 IN NUMBER
180723 --DISTRIBUTION_IDENTIFIER
180724 , p_source_84 IN NUMBER
180725 --Distribution Type
180726 , p_source_85 IN VARCHAR2
180727 , p_source_85_meaning IN VARCHAR2
180728 --Entered Currency Code
180729 , p_source_88 IN VARCHAR2
180730 --Entered Amount
180731 , p_source_91 IN NUMBER
180732 --Currency Conversion Date
180733 , p_source_92 IN DATE
180734 --Currency Conversion Rate
180735 , p_source_93 IN NUMBER
180736 --Currency Conversion Type
180737 , p_source_94 IN VARCHAR2
180738 --Accounted Amount
180739 , p_source_95 IN NUMBER
180740 --Accounting Line Type
180741 , p_source_97 IN NUMBER
180742 )
180743 IS
180744
180745 l_component_type VARCHAR2(80);
180746 l_component_code VARCHAR2(30);
180747 l_component_type_code VARCHAR2(1);
180748 l_component_appl_id INTEGER;
180749 l_amb_context_code VARCHAR2(30);
180750 l_entity_code VARCHAR2(30);
180751 l_event_class_code VARCHAR2(30);
180752 l_ae_header_id NUMBER;
180753 l_event_type_code VARCHAR2(30);
180754 l_line_definition_code VARCHAR2(30);
180755 l_line_definition_owner_code VARCHAR2(1);
180756 --
180757 -- adr variables
180758 l_segment VARCHAR2(30);
180759 l_ccid NUMBER;
180760 l_adr_transaction_coa_id NUMBER;
180761 l_adr_accounting_coa_id NUMBER;
180762 l_adr_flexfield_segment_code VARCHAR2(30);
180763 l_adr_flex_value_set_id NUMBER;
180764 l_adr_value_type_code VARCHAR2(30);
180765 l_adr_value_combination_id NUMBER;
180766 l_adr_value_segment_code VARCHAR2(30);
180767
180768 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
180769 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
180770 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
180771 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
180772
180773 -- 4262811 Variables ------------------------------------------------------------------------------------------
180774 l_entered_amt_idx NUMBER;
180775 l_accted_amt_idx NUMBER;
180776 l_acc_rev_flag VARCHAR2(1);
180777 l_accrual_line_num NUMBER;
180778 l_tmp_amt NUMBER;
180779 l_acc_rev_natural_side_code VARCHAR2(1);
180780
180781 l_num_entries NUMBER;
180782 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
180783 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
180784 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
180785 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
180786 l_recog_line_1 NUMBER;
180787 l_recog_line_2 NUMBER;
180788
180789 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
180790 l_bflow_applied_to_amt NUMBER; -- 5132302
180791 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
180792
180793 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
180794
180795 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
180796 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
180797
180798 ---------------------------------------------------------------------------------------------------------------
180799
180800
180801 --
180802 -- bulk performance
180803 --
180804 l_balance_type_code VARCHAR2(1);
180805 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
180806 l_log_module VARCHAR2(240);
180807
180808 --
180809 -- Upgrade strategy
180810 --
180811 l_actual_upg_option VARCHAR2(1);
180812 l_enc_upg_option VARCHAR2(1);
180813
180814 --
180815 BEGIN
180816 --
180817 IF g_log_enabled THEN
180818 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_333';
180819 END IF;
180820 --
180821 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
180822
180823 trace
180824 (p_msg => 'BEGIN of AcctLineType_333'
180825 ,p_level => C_LEVEL_PROCEDURE
180826 ,p_module => l_log_module);
180827
180828 END IF;
180829 --
180830 l_component_type := 'AMB_JLT';
180831 l_component_code := 'OFFSET';
180832 l_component_type_code := 'S';
180833 l_component_appl_id := 707;
180834 l_amb_context_code := 'DEFAULT';
180835 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
180836 l_event_class_code := 'USER_DEFINE';
180837 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
180838 l_line_definition_owner_code := 'S';
180839 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
180840 --
180841 l_balance_type_code := 'A';
180842 l_segment := NULL;
180843 l_ccid := NULL;
180844 l_adr_transaction_coa_id := NULL;
180845 l_adr_accounting_coa_id := NULL;
180846 l_adr_flexfield_segment_code := NULL;
180847 l_adr_flex_value_set_id := NULL;
180848 l_adr_value_type_code := NULL;
180849 l_adr_value_combination_id := NULL;
180850 l_adr_value_segment_code := NULL;
180851
180852 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
180853 l_bflow_class_code := ''; -- 4219869 Business Flow
180854 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
180855 l_budgetary_control_flag := 'N';
180856
180857 l_bflow_applied_to_amt_idx := NULL; -- 5132302
180858 l_bflow_applied_to_amt := NULL; -- 5132302
180859 l_entered_amt_idx := NULL; -- 4262811
180860 l_accted_amt_idx := NULL; -- 4262811
180861 l_acc_rev_flag := NULL; -- 4262811
180862 l_accrual_line_num := NULL; -- 4262811
180863 l_tmp_amt := NULL; -- 4262811
180864 --
180865
180866 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
180867 l_balance_type_code <> 'B' THEN
180868 IF NVL(p_source_97,9E125) = 2
180869 THEN
180870
180871 --
180872 XLA_AE_LINES_PKG.SetNewLine;
180873
180874 p_balance_type_code := l_balance_type_code;
180875 -- set the flag so later we will know whether the gain loss line needs to be created
180876
180877 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
180878 p_actual_flag :='A';
180879 END IF;
180880
180881 --
180882 -- bulk performance
180883 --
180884 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
180885 p_header_num => 0); -- 4262811
180886 --
180887 -- set accounting line options
180888 --
180889 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
180890 p_natural_side_code => 'D'
180891 , p_gain_or_loss_flag => 'N'
180892 , p_gl_transfer_mode_code => 'S'
180893 , p_acct_entry_type_code => 'A'
180894 , p_switch_side_flag => 'Y'
180895 , p_merge_duplicate_code => 'N'
180896 );
180897 --
180898 l_acc_rev_natural_side_code := 'C'; -- 4262811
180899 --
180900 --
180901 -- set accounting line type info
180902 --
180903 xla_ae_lines_pkg.SetAcctLineType
180904 (p_component_type => l_component_type
180905 ,p_event_type_code => l_event_type_code
180906 ,p_line_definition_owner_code => l_line_definition_owner_code
180907 ,p_line_definition_code => l_line_definition_code
180908 ,p_accounting_line_code => l_component_code
180909 ,p_accounting_line_type_code => l_component_type_code
180910 ,p_accounting_line_appl_id => l_component_appl_id
180911 ,p_amb_context_code => l_amb_context_code
180912 ,p_entity_code => l_entity_code
180913 ,p_event_class_code => l_event_class_code);
180914 --
180915 -- set accounting class
180916 --
180917 xla_ae_lines_pkg.SetAcctClass(
180918 p_accounting_class_code => 'OFFSET'
180919 , p_ae_header_id => l_ae_header_id
180920 );
180921
180922 --
180923 -- set rounding class
180924 --
180925 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
180926 'OFFSET';
180927
180928 --
180929 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
180930 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
180931 --
180932 -- bulk performance
180933 --
180934 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
180935
180936 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
180937 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
180938
180939 -- 4955764
180940 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
180941 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
180942
180943 -- 4458381 Public Sector Enh
180944
180945 --
180946 -- set accounting attributes for the line type
180947 --
180948 l_entered_amt_idx := 3;
180949 l_accted_amt_idx := 8;
180950 l_bflow_applied_to_amt_idx := NULL; -- 5132302
180951 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
180952 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
180953 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
180954 l_rec_acct_attrs.array_char_value(2) := p_source_85;
180955 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
180956 l_rec_acct_attrs.array_num_value(3) := p_source_91;
180957 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
180958 l_rec_acct_attrs.array_char_value(4) := p_source_88;
180959 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
180960 l_rec_acct_attrs.array_date_value(5) := p_source_92;
180961 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
180962 l_rec_acct_attrs.array_num_value(6) := p_source_93;
180963 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
180964 l_rec_acct_attrs.array_char_value(7) := p_source_94;
180965 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
180966 l_rec_acct_attrs.array_num_value(8) := p_source_95;
180967
180968 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
180969 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
180970
180971 ---------------------------------------------------------------------------------------------------------------
180972 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
180973 ---------------------------------------------------------------------------------------------------------------
180974 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
180975
180976 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
180977 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
180978
180979 IF xla_accounting_cache_pkg.GetValueChar
180980 (p_source_code => 'LEDGER_CATEGORY_CODE'
180981 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
180982 AND l_bflow_method_code = 'PRIOR_ENTRY'
180983 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
180984 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
180985 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
180986 )
180987 THEN
180988 xla_ae_lines_pkg.BflowUpgEntry
180989 (p_business_method_code => l_bflow_method_code
180990 ,p_business_class_code => l_bflow_class_code
180991 ,p_balance_type => l_balance_type_code);
180992 ELSE
180993 NULL;
180994 -- No business flow processing for business flow method of NONE.
180995 END IF;
180996
180997 --
180998 -- call analytical criteria
180999 --
181000
181001 --
181002 -- call description
181003 --
181004
181005 xla_ae_lines_pkg.SetLineDescription(
181006 p_ae_header_id => l_ae_header_id
181007 ,p_description => Description_1 (
181008 p_application_id => p_application_id
181009 , p_ae_header_id => l_ae_header_id
181010 , p_source_1 => p_source_1
181011 , p_source_2 => p_source_2
181012 , p_source_3 => p_source_3
181013 , p_source_4 => p_source_4
181014 , p_source_5 => p_source_5
181015 )
181016 );
181017
181018
181019 --
181020 -- call ADRs
181021 -- Bug 4922099
181022 --
181023 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
181024 (NVL(l_actual_upg_option, 'N') = 'O') OR
181025 (NVL(l_enc_upg_option, 'N') = 'O')
181026 )
181027 THEN
181028 NULL;
181029 --
181030 --
181031
181032 l_ccid := AcctDerRule_6(
181033 p_application_id => p_application_id
181034 , p_ae_header_id => l_ae_header_id
181035 , p_source_11 => p_source_11
181036 , x_transaction_coa_id => l_adr_transaction_coa_id
181037 , x_accounting_coa_id => l_adr_accounting_coa_id
181038 , x_value_type_code => l_adr_value_type_code
181039 , p_side => 'NA'
181040 );
181041
181042 xla_ae_lines_pkg.set_ccid(
181043 p_code_combination_id => l_ccid
181044 , p_value_type_code => l_adr_value_type_code
181045 , p_transaction_coa_id => l_adr_transaction_coa_id
181046 , p_accounting_coa_id => l_adr_accounting_coa_id
181047 , p_adr_code => 'CST_DEFAULT'
181048 , p_adr_type_code => 'S'
181049 , p_component_type => l_component_type
181050 , p_component_code => l_component_code
181051 , p_component_type_code => l_component_type_code
181052 , p_component_appl_id => l_component_appl_id
181053 , p_amb_context_code => l_amb_context_code
181054 , p_side => 'NA'
181055 );
181056
181057
181058 --
181059 --
181060 END IF;
181061 --
181062 -- Bug 4922099
181063 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
181064 (NVL(l_enc_upg_option, 'N') = 'O')
181065 ) AND
181066 (l_bflow_method_code = 'PRIOR_ENTRY')
181067 )
181068 THEN
181069 IF
181070 --
181071 1 = 2
181072 --
181073 THEN
181074 xla_accounting_err_pkg.build_message
181075 (p_appli_s_name => 'XLA'
181076 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
181077 ,p_token_1 => 'LINE_NUMBER'
181078 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
181079 ,p_token_2 => 'LINE_TYPE_NAME'
181080 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
181081 l_component_type
181082 ,l_component_code
181083 ,l_component_type_code
181084 ,l_component_appl_id
181085 ,l_amb_context_code
181086 ,l_entity_code
181087 ,l_event_class_code
181088 )
181089 ,p_token_3 => 'OWNER'
181090 ,p_value_3 => xla_lookups_pkg.get_meaning(
181091 p_lookup_type => 'XLA_OWNER_TYPE'
181092 ,p_lookup_code => l_component_type_code
181093 )
181094 ,p_token_4 => 'PRODUCT_NAME'
181095 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
181096 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
181097 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
181098 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
181099 ,p_ae_header_id => NULL
181100 );
181101
181102 IF (C_LEVEL_ERROR>= g_log_level) THEN
181103 trace
181104 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
181105 ,p_level => C_LEVEL_ERROR
181106 ,p_module => l_log_module);
181107 END IF;
181108 END IF;
181109 END IF;
181110 --
181111 --
181112 ------------------------------------------------------------------------------------------------
181113 -- 4219869 Business Flow
181114 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
181115 -- Prior Entry. Currently, the following code is always generated.
181116 ------------------------------------------------------------------------------------------------
181117 XLA_AE_LINES_PKG.ValidateCurrentLine;
181118
181119 ------------------------------------------------------------------------------------
181120 -- 4219869 Business Flow
181121 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
181122 ------------------------------------------------------------------------------------
181123 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
181124
181125 ----------------------------------------------------------------------------------
181126 -- 4219869 Business Flow
181127 -- Update journal entry status -- Need to generate this within IF <condition>
181128 ----------------------------------------------------------------------------------
181129 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
181130 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
181131 ,p_balance_type_code => l_balance_type_code
181132 );
181133
181134 -------------------------------------------------------------------------------------------
181135 -- 4262811 - Generate the Accrual Reversal lines
181136 -------------------------------------------------------------------------------------------
181137 BEGIN
181138 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
181139 (g_array_event(p_event_id).array_value_num('header_index'));
181140 IF l_acc_rev_flag IS NULL THEN
181141 l_acc_rev_flag := 'N';
181142 END IF;
181143 EXCEPTION
181144 WHEN OTHERS THEN
181145 l_acc_rev_flag := 'N';
181146 END;
181147 --
181148 IF (l_acc_rev_flag = 'Y') THEN
181149
181150 -- 4645092 ------------------------------------------------------------------------------
181151 -- To allow MPA report to determine if it should generate report process
181152 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
181153 ------------------------------------------------------------------------------------------
181154
181155 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
181156 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
181157 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
181158 -- call ADRs
181159 -- Bug 4922099
181160 --
181161 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
181162 (NVL(l_actual_upg_option, 'N') = 'O') OR
181163 (NVL(l_enc_upg_option, 'N') = 'O')
181164 )
181165 THEN
181166 NULL;
181167 --
181168 --
181169
181170 l_ccid := AcctDerRule_6(
181171 p_application_id => p_application_id
181172 , p_ae_header_id => l_ae_header_id
181173 , p_source_11 => p_source_11
181174 , x_transaction_coa_id => l_adr_transaction_coa_id
181175 , x_accounting_coa_id => l_adr_accounting_coa_id
181176 , x_value_type_code => l_adr_value_type_code
181177 , p_side => 'NA'
181178 );
181179
181180 xla_ae_lines_pkg.set_ccid(
181181 p_code_combination_id => l_ccid
181182 , p_value_type_code => l_adr_value_type_code
181183 , p_transaction_coa_id => l_adr_transaction_coa_id
181184 , p_accounting_coa_id => l_adr_accounting_coa_id
181185 , p_adr_code => 'CST_DEFAULT'
181186 , p_adr_type_code => 'S'
181187 , p_component_type => l_component_type
181188 , p_component_code => l_component_code
181189 , p_component_type_code => l_component_type_code
181190 , p_component_appl_id => l_component_appl_id
181191 , p_amb_context_code => l_amb_context_code
181192 , p_side => 'NA'
181193 );
181194
181195
181196 --
181197 --
181198 END IF;
181199
181200 --
181201 -- Update the line information that should be overwritten
181202 --
181203 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
181204 p_header_num => 1);
181205 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
181206
181207 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
181208
181209 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
181210 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
181211 END IF;
181212
181213 --
181214 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
181215 --
181216 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
181217 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
181218 ELSE
181219 ---------------------------------------------------------------------------------------------------
181220 -- 4262811a Switch Sign
181221 ---------------------------------------------------------------------------------------------------
181222 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
181223 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
181224 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181225 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
181226 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181227 -- 5132302
181228 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
181229 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181230
181231 END IF;
181232
181233 -- 4955764
181234 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
181235 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
181236
181237
181238 XLA_AE_LINES_PKG.ValidateCurrentLine;
181239 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
181240
181241 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
181242 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
181243 ,p_balance_type_code => l_balance_type_code);
181244
181245 END IF;
181246
181247 -----------------------------------------------------------------------------------------
181248 -- 4262811 Multiperiod Accounting
181249 -----------------------------------------------------------------------------------------
181250 -- No MPA option is assigned.
181251
181252
181253 END IF;
181254 END IF;
181255 --
181256
181257 --
181258 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
181259 trace
181260 (p_msg => 'END of AcctLineType_333'
181261 ,p_level => C_LEVEL_PROCEDURE
181262 ,p_module => l_log_module);
181263 END IF;
181264 --
181265 EXCEPTION
181266 WHEN xla_exceptions_pkg.application_exception THEN
181267 RAISE;
181268 WHEN OTHERS THEN
181269 xla_exceptions_pkg.raise_message
181270 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_333');
181271 END AcctLineType_333;
181272 --
181273
181274 ---------------------------------------
181275 --
181276 -- PRIVATE FUNCTION
181277 -- AcctLineType_334
181278 --
181279 ---------------------------------------
181280 PROCEDURE AcctLineType_334 (
181281 p_application_id IN NUMBER
181282 ,p_event_id IN NUMBER
181283 ,p_calculate_acctd_flag IN VARCHAR2
181284 ,p_calculate_g_l_flag IN VARCHAR2
181285 ,p_actual_flag IN OUT VARCHAR2
181286 ,p_balance_type_code OUT VARCHAR2
181287 ,p_gain_or_loss_ref OUT VARCHAR2
181288
181289 --TRANSACTION_ID
181290 , p_source_1 IN NUMBER
181291 --Item Concatenated Segments
181292 , p_source_2 IN VARCHAR2
181293 --Transaction Quantity
181294 , p_source_3 IN NUMBER
181295 --Transaction Unit of Measure Code
181296 , p_source_4 IN VARCHAR2
181297 --Inventory Transaction Type Description
181298 , p_source_5 IN VARCHAR2
181299 --Cost Management Default Account
181300 , p_source_11 IN NUMBER
181301 --DISTRIBUTION_IDENTIFIER
181302 , p_source_84 IN NUMBER
181303 --Distribution Type
181304 , p_source_85 IN VARCHAR2
181305 , p_source_85_meaning IN VARCHAR2
181306 --Entered Currency Code
181307 , p_source_88 IN VARCHAR2
181308 --Entered Amount
181309 , p_source_91 IN NUMBER
181310 --Currency Conversion Date
181311 , p_source_92 IN DATE
181312 --Currency Conversion Rate
181313 , p_source_93 IN NUMBER
181314 --Currency Conversion Type
181315 , p_source_94 IN VARCHAR2
181316 --Accounted Amount
181317 , p_source_95 IN NUMBER
181318 --Accounting Line Type
181319 , p_source_97 IN NUMBER
181320 )
181321 IS
181322
181323 l_component_type VARCHAR2(80);
181324 l_component_code VARCHAR2(30);
181325 l_component_type_code VARCHAR2(1);
181326 l_component_appl_id INTEGER;
181327 l_amb_context_code VARCHAR2(30);
181328 l_entity_code VARCHAR2(30);
181329 l_event_class_code VARCHAR2(30);
181330 l_ae_header_id NUMBER;
181331 l_event_type_code VARCHAR2(30);
181332 l_line_definition_code VARCHAR2(30);
181333 l_line_definition_owner_code VARCHAR2(1);
181334 --
181335 -- adr variables
181336 l_segment VARCHAR2(30);
181337 l_ccid NUMBER;
181338 l_adr_transaction_coa_id NUMBER;
181339 l_adr_accounting_coa_id NUMBER;
181340 l_adr_flexfield_segment_code VARCHAR2(30);
181341 l_adr_flex_value_set_id NUMBER;
181342 l_adr_value_type_code VARCHAR2(30);
181343 l_adr_value_combination_id NUMBER;
181344 l_adr_value_segment_code VARCHAR2(30);
181345
181346 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
181347 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
181348 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
181349 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
181350
181351 -- 4262811 Variables ------------------------------------------------------------------------------------------
181352 l_entered_amt_idx NUMBER;
181353 l_accted_amt_idx NUMBER;
181354 l_acc_rev_flag VARCHAR2(1);
181355 l_accrual_line_num NUMBER;
181356 l_tmp_amt NUMBER;
181357 l_acc_rev_natural_side_code VARCHAR2(1);
181358
181359 l_num_entries NUMBER;
181360 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
181361 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
181362 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
181363 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
181364 l_recog_line_1 NUMBER;
181365 l_recog_line_2 NUMBER;
181366
181367 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
181368 l_bflow_applied_to_amt NUMBER; -- 5132302
181369 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
181370
181371 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
181372
181373 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
181374 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
181375
181376 ---------------------------------------------------------------------------------------------------------------
181377
181378
181379 --
181380 -- bulk performance
181381 --
181382 l_balance_type_code VARCHAR2(1);
181383 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
181384 l_log_module VARCHAR2(240);
181385
181386 --
181387 -- Upgrade strategy
181388 --
181389 l_actual_upg_option VARCHAR2(1);
181390 l_enc_upg_option VARCHAR2(1);
181391
181392 --
181393 BEGIN
181394 --
181395 IF g_log_enabled THEN
181396 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_334';
181397 END IF;
181398 --
181399 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
181400
181401 trace
181402 (p_msg => 'BEGIN of AcctLineType_334'
181403 ,p_level => C_LEVEL_PROCEDURE
181404 ,p_module => l_log_module);
181405
181406 END IF;
181407 --
181408 l_component_type := 'AMB_JLT';
181409 l_component_code := 'OFFSET';
181410 l_component_type_code := 'S';
181411 l_component_appl_id := 707;
181412 l_amb_context_code := 'DEFAULT';
181413 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
181414 l_event_class_code := 'USER_DEFINE';
181415 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
181416 l_line_definition_owner_code := 'S';
181417 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
181418 --
181419 l_balance_type_code := 'A';
181420 l_segment := NULL;
181421 l_ccid := NULL;
181422 l_adr_transaction_coa_id := NULL;
181423 l_adr_accounting_coa_id := NULL;
181424 l_adr_flexfield_segment_code := NULL;
181425 l_adr_flex_value_set_id := NULL;
181426 l_adr_value_type_code := NULL;
181427 l_adr_value_combination_id := NULL;
181428 l_adr_value_segment_code := NULL;
181429
181430 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
181431 l_bflow_class_code := ''; -- 4219869 Business Flow
181432 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
181433 l_budgetary_control_flag := 'N';
181434
181435 l_bflow_applied_to_amt_idx := NULL; -- 5132302
181436 l_bflow_applied_to_amt := NULL; -- 5132302
181437 l_entered_amt_idx := NULL; -- 4262811
181438 l_accted_amt_idx := NULL; -- 4262811
181439 l_acc_rev_flag := NULL; -- 4262811
181440 l_accrual_line_num := NULL; -- 4262811
181441 l_tmp_amt := NULL; -- 4262811
181442 --
181443
181444 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
181445 l_balance_type_code <> 'B' THEN
181446 IF NVL(p_source_97,9E125) = 2
181447 THEN
181448
181449 --
181450 XLA_AE_LINES_PKG.SetNewLine;
181451
181452 p_balance_type_code := l_balance_type_code;
181453 -- set the flag so later we will know whether the gain loss line needs to be created
181454
181455 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
181456 p_actual_flag :='A';
181457 END IF;
181458
181459 --
181460 -- bulk performance
181461 --
181462 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
181463 p_header_num => 0); -- 4262811
181464 --
181465 -- set accounting line options
181466 --
181467 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
181468 p_natural_side_code => 'D'
181469 , p_gain_or_loss_flag => 'N'
181470 , p_gl_transfer_mode_code => 'S'
181471 , p_acct_entry_type_code => 'A'
181472 , p_switch_side_flag => 'Y'
181473 , p_merge_duplicate_code => 'N'
181474 );
181475 --
181476 l_acc_rev_natural_side_code := 'C'; -- 4262811
181477 --
181478 --
181479 -- set accounting line type info
181480 --
181481 xla_ae_lines_pkg.SetAcctLineType
181482 (p_component_type => l_component_type
181483 ,p_event_type_code => l_event_type_code
181484 ,p_line_definition_owner_code => l_line_definition_owner_code
181485 ,p_line_definition_code => l_line_definition_code
181486 ,p_accounting_line_code => l_component_code
181487 ,p_accounting_line_type_code => l_component_type_code
181488 ,p_accounting_line_appl_id => l_component_appl_id
181489 ,p_amb_context_code => l_amb_context_code
181490 ,p_entity_code => l_entity_code
181491 ,p_event_class_code => l_event_class_code);
181492 --
181493 -- set accounting class
181494 --
181495 xla_ae_lines_pkg.SetAcctClass(
181496 p_accounting_class_code => 'OFFSET'
181497 , p_ae_header_id => l_ae_header_id
181498 );
181499
181500 --
181501 -- set rounding class
181502 --
181503 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
181504 'OFFSET';
181505
181506 --
181507 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
181508 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
181509 --
181510 -- bulk performance
181511 --
181512 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
181513
181514 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
181515 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
181516
181517 -- 4955764
181518 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
181519 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
181520
181521 -- 4458381 Public Sector Enh
181522
181523 --
181524 -- set accounting attributes for the line type
181525 --
181526 l_entered_amt_idx := 3;
181527 l_accted_amt_idx := 8;
181528 l_bflow_applied_to_amt_idx := NULL; -- 5132302
181529 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
181530 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
181531 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
181532 l_rec_acct_attrs.array_char_value(2) := p_source_85;
181533 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
181534 l_rec_acct_attrs.array_num_value(3) := p_source_91;
181535 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
181536 l_rec_acct_attrs.array_char_value(4) := p_source_88;
181537 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
181538 l_rec_acct_attrs.array_date_value(5) := p_source_92;
181539 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
181540 l_rec_acct_attrs.array_num_value(6) := p_source_93;
181541 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
181542 l_rec_acct_attrs.array_char_value(7) := p_source_94;
181543 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
181544 l_rec_acct_attrs.array_num_value(8) := p_source_95;
181545
181546 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
181547 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
181548
181549 ---------------------------------------------------------------------------------------------------------------
181550 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
181551 ---------------------------------------------------------------------------------------------------------------
181552 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
181553
181554 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
181555 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
181556
181557 IF xla_accounting_cache_pkg.GetValueChar
181558 (p_source_code => 'LEDGER_CATEGORY_CODE'
181559 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
181560 AND l_bflow_method_code = 'PRIOR_ENTRY'
181561 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
181562 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
181563 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
181564 )
181565 THEN
181566 xla_ae_lines_pkg.BflowUpgEntry
181567 (p_business_method_code => l_bflow_method_code
181568 ,p_business_class_code => l_bflow_class_code
181569 ,p_balance_type => l_balance_type_code);
181570 ELSE
181571 NULL;
181572 -- No business flow processing for business flow method of NONE.
181573 END IF;
181574
181575 --
181576 -- call analytical criteria
181577 --
181578
181579 --
181580 -- call description
181581 --
181582
181583 xla_ae_lines_pkg.SetLineDescription(
181584 p_ae_header_id => l_ae_header_id
181585 ,p_description => Description_1 (
181586 p_application_id => p_application_id
181587 , p_ae_header_id => l_ae_header_id
181588 , p_source_1 => p_source_1
181589 , p_source_2 => p_source_2
181590 , p_source_3 => p_source_3
181591 , p_source_4 => p_source_4
181592 , p_source_5 => p_source_5
181593 )
181594 );
181595
181596
181597 --
181598 -- call ADRs
181599 -- Bug 4922099
181600 --
181601 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
181602 (NVL(l_actual_upg_option, 'N') = 'O') OR
181603 (NVL(l_enc_upg_option, 'N') = 'O')
181604 )
181605 THEN
181606 NULL;
181607 --
181608 --
181609
181610 l_ccid := AcctDerRule_6(
181611 p_application_id => p_application_id
181612 , p_ae_header_id => l_ae_header_id
181613 , p_source_11 => p_source_11
181614 , x_transaction_coa_id => l_adr_transaction_coa_id
181615 , x_accounting_coa_id => l_adr_accounting_coa_id
181616 , x_value_type_code => l_adr_value_type_code
181617 , p_side => 'NA'
181618 );
181619
181620 xla_ae_lines_pkg.set_ccid(
181621 p_code_combination_id => l_ccid
181622 , p_value_type_code => l_adr_value_type_code
181623 , p_transaction_coa_id => l_adr_transaction_coa_id
181624 , p_accounting_coa_id => l_adr_accounting_coa_id
181625 , p_adr_code => 'CST_DEFAULT'
181626 , p_adr_type_code => 'S'
181627 , p_component_type => l_component_type
181628 , p_component_code => l_component_code
181629 , p_component_type_code => l_component_type_code
181630 , p_component_appl_id => l_component_appl_id
181631 , p_amb_context_code => l_amb_context_code
181632 , p_side => 'NA'
181633 );
181634
181635
181636 --
181637 --
181638 END IF;
181639 --
181640 -- Bug 4922099
181641 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
181642 (NVL(l_enc_upg_option, 'N') = 'O')
181643 ) AND
181644 (l_bflow_method_code = 'PRIOR_ENTRY')
181645 )
181646 THEN
181647 IF
181648 --
181649 1 = 2
181650 --
181651 THEN
181652 xla_accounting_err_pkg.build_message
181653 (p_appli_s_name => 'XLA'
181654 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
181655 ,p_token_1 => 'LINE_NUMBER'
181656 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
181657 ,p_token_2 => 'LINE_TYPE_NAME'
181658 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
181659 l_component_type
181660 ,l_component_code
181661 ,l_component_type_code
181662 ,l_component_appl_id
181663 ,l_amb_context_code
181664 ,l_entity_code
181665 ,l_event_class_code
181666 )
181667 ,p_token_3 => 'OWNER'
181668 ,p_value_3 => xla_lookups_pkg.get_meaning(
181669 p_lookup_type => 'XLA_OWNER_TYPE'
181670 ,p_lookup_code => l_component_type_code
181671 )
181672 ,p_token_4 => 'PRODUCT_NAME'
181673 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
181674 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
181675 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
181676 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
181677 ,p_ae_header_id => NULL
181678 );
181679
181680 IF (C_LEVEL_ERROR>= g_log_level) THEN
181681 trace
181682 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
181683 ,p_level => C_LEVEL_ERROR
181684 ,p_module => l_log_module);
181685 END IF;
181686 END IF;
181687 END IF;
181688 --
181689 --
181690 ------------------------------------------------------------------------------------------------
181691 -- 4219869 Business Flow
181692 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
181693 -- Prior Entry. Currently, the following code is always generated.
181694 ------------------------------------------------------------------------------------------------
181695 XLA_AE_LINES_PKG.ValidateCurrentLine;
181696
181697 ------------------------------------------------------------------------------------
181698 -- 4219869 Business Flow
181699 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
181700 ------------------------------------------------------------------------------------
181701 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
181702
181703 ----------------------------------------------------------------------------------
181704 -- 4219869 Business Flow
181705 -- Update journal entry status -- Need to generate this within IF <condition>
181706 ----------------------------------------------------------------------------------
181707 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
181708 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
181709 ,p_balance_type_code => l_balance_type_code
181710 );
181711
181712 -------------------------------------------------------------------------------------------
181713 -- 4262811 - Generate the Accrual Reversal lines
181714 -------------------------------------------------------------------------------------------
181715 BEGIN
181716 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
181717 (g_array_event(p_event_id).array_value_num('header_index'));
181718 IF l_acc_rev_flag IS NULL THEN
181719 l_acc_rev_flag := 'N';
181720 END IF;
181721 EXCEPTION
181722 WHEN OTHERS THEN
181723 l_acc_rev_flag := 'N';
181724 END;
181725 --
181726 IF (l_acc_rev_flag = 'Y') THEN
181727
181728 -- 4645092 ------------------------------------------------------------------------------
181729 -- To allow MPA report to determine if it should generate report process
181730 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
181731 ------------------------------------------------------------------------------------------
181732
181733 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
181734 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
181735 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
181736 -- call ADRs
181737 -- Bug 4922099
181738 --
181739 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
181740 (NVL(l_actual_upg_option, 'N') = 'O') OR
181741 (NVL(l_enc_upg_option, 'N') = 'O')
181742 )
181743 THEN
181744 NULL;
181745 --
181746 --
181747
181748 l_ccid := AcctDerRule_6(
181749 p_application_id => p_application_id
181750 , p_ae_header_id => l_ae_header_id
181751 , p_source_11 => p_source_11
181752 , x_transaction_coa_id => l_adr_transaction_coa_id
181753 , x_accounting_coa_id => l_adr_accounting_coa_id
181754 , x_value_type_code => l_adr_value_type_code
181755 , p_side => 'NA'
181756 );
181757
181758 xla_ae_lines_pkg.set_ccid(
181759 p_code_combination_id => l_ccid
181760 , p_value_type_code => l_adr_value_type_code
181761 , p_transaction_coa_id => l_adr_transaction_coa_id
181762 , p_accounting_coa_id => l_adr_accounting_coa_id
181763 , p_adr_code => 'CST_DEFAULT'
181764 , p_adr_type_code => 'S'
181765 , p_component_type => l_component_type
181766 , p_component_code => l_component_code
181767 , p_component_type_code => l_component_type_code
181768 , p_component_appl_id => l_component_appl_id
181769 , p_amb_context_code => l_amb_context_code
181770 , p_side => 'NA'
181771 );
181772
181773
181774 --
181775 --
181776 END IF;
181777
181778 --
181779 -- Update the line information that should be overwritten
181780 --
181781 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
181782 p_header_num => 1);
181783 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
181784
181785 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
181786
181787 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
181788 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
181789 END IF;
181790
181791 --
181792 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
181793 --
181794 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
181795 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
181796 ELSE
181797 ---------------------------------------------------------------------------------------------------
181798 -- 4262811a Switch Sign
181799 ---------------------------------------------------------------------------------------------------
181800 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
181801 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
181802 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181803 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
181804 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181805 -- 5132302
181806 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
181807 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
181808
181809 END IF;
181810
181811 -- 4955764
181812 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
181813 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
181814
181815
181816 XLA_AE_LINES_PKG.ValidateCurrentLine;
181817 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
181818
181819 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
181820 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
181821 ,p_balance_type_code => l_balance_type_code);
181822
181823 END IF;
181824
181825 -----------------------------------------------------------------------------------------
181826 -- 4262811 Multiperiod Accounting
181827 -----------------------------------------------------------------------------------------
181828 -- No MPA option is assigned.
181829
181830
181831 END IF;
181832 END IF;
181833 --
181834
181835 --
181836 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
181837 trace
181838 (p_msg => 'END of AcctLineType_334'
181839 ,p_level => C_LEVEL_PROCEDURE
181840 ,p_module => l_log_module);
181841 END IF;
181842 --
181843 EXCEPTION
181844 WHEN xla_exceptions_pkg.application_exception THEN
181845 RAISE;
181846 WHEN OTHERS THEN
181847 xla_exceptions_pkg.raise_message
181848 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_334');
181849 END AcctLineType_334;
181850 --
181851
181852 ---------------------------------------
181853 --
181854 -- PRIVATE FUNCTION
181855 -- AcctLineType_335
181856 --
181857 ---------------------------------------
181858 PROCEDURE AcctLineType_335 (
181859 p_application_id IN NUMBER
181860 ,p_event_id IN NUMBER
181861 ,p_calculate_acctd_flag IN VARCHAR2
181862 ,p_calculate_g_l_flag IN VARCHAR2
181863 ,p_actual_flag IN OUT VARCHAR2
181864 ,p_balance_type_code OUT VARCHAR2
181865 ,p_gain_or_loss_ref OUT VARCHAR2
181866
181867 --TRANSACTION_ID
181868 , p_source_1 IN NUMBER
181869 --Item Concatenated Segments
181870 , p_source_2 IN VARCHAR2
181871 --Transaction Quantity
181872 , p_source_3 IN NUMBER
181873 --Transaction Unit of Measure Code
181874 , p_source_4 IN VARCHAR2
181875 --Inventory Transaction Type Description
181876 , p_source_5 IN VARCHAR2
181877 --Cost Management Default Account
181878 , p_source_11 IN NUMBER
181879 --DISTRIBUTION_IDENTIFIER
181880 , p_source_84 IN NUMBER
181881 --Distribution Type
181882 , p_source_85 IN VARCHAR2
181883 , p_source_85_meaning IN VARCHAR2
181884 --Entered Currency Code
181885 , p_source_88 IN VARCHAR2
181886 --Entered Amount
181887 , p_source_91 IN NUMBER
181888 --Currency Conversion Date
181889 , p_source_92 IN DATE
181890 --Currency Conversion Rate
181891 , p_source_93 IN NUMBER
181892 --Currency Conversion Type
181893 , p_source_94 IN VARCHAR2
181894 --Accounted Amount
181895 , p_source_95 IN NUMBER
181896 --Accounting Line Type
181897 , p_source_97 IN NUMBER
181898 )
181899 IS
181900
181901 l_component_type VARCHAR2(80);
181902 l_component_code VARCHAR2(30);
181903 l_component_type_code VARCHAR2(1);
181904 l_component_appl_id INTEGER;
181905 l_amb_context_code VARCHAR2(30);
181906 l_entity_code VARCHAR2(30);
181907 l_event_class_code VARCHAR2(30);
181908 l_ae_header_id NUMBER;
181909 l_event_type_code VARCHAR2(30);
181910 l_line_definition_code VARCHAR2(30);
181911 l_line_definition_owner_code VARCHAR2(1);
181912 --
181913 -- adr variables
181914 l_segment VARCHAR2(30);
181915 l_ccid NUMBER;
181916 l_adr_transaction_coa_id NUMBER;
181917 l_adr_accounting_coa_id NUMBER;
181918 l_adr_flexfield_segment_code VARCHAR2(30);
181919 l_adr_flex_value_set_id NUMBER;
181920 l_adr_value_type_code VARCHAR2(30);
181921 l_adr_value_combination_id NUMBER;
181922 l_adr_value_segment_code VARCHAR2(30);
181923
181924 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
181925 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
181926 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
181927 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
181928
181929 -- 4262811 Variables ------------------------------------------------------------------------------------------
181930 l_entered_amt_idx NUMBER;
181931 l_accted_amt_idx NUMBER;
181932 l_acc_rev_flag VARCHAR2(1);
181933 l_accrual_line_num NUMBER;
181934 l_tmp_amt NUMBER;
181935 l_acc_rev_natural_side_code VARCHAR2(1);
181936
181937 l_num_entries NUMBER;
181938 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
181939 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
181940 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
181941 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
181942 l_recog_line_1 NUMBER;
181943 l_recog_line_2 NUMBER;
181944
181945 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
181946 l_bflow_applied_to_amt NUMBER; -- 5132302
181947 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
181948
181949 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
181950
181951 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
181952 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
181953
181954 ---------------------------------------------------------------------------------------------------------------
181955
181956
181957 --
181958 -- bulk performance
181959 --
181960 l_balance_type_code VARCHAR2(1);
181961 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
181962 l_log_module VARCHAR2(240);
181963
181964 --
181965 -- Upgrade strategy
181966 --
181967 l_actual_upg_option VARCHAR2(1);
181968 l_enc_upg_option VARCHAR2(1);
181969
181970 --
181971 BEGIN
181972 --
181973 IF g_log_enabled THEN
181974 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_335';
181975 END IF;
181976 --
181977 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
181978
181979 trace
181980 (p_msg => 'BEGIN of AcctLineType_335'
181981 ,p_level => C_LEVEL_PROCEDURE
181982 ,p_module => l_log_module);
181983
181984 END IF;
181985 --
181986 l_component_type := 'AMB_JLT';
181987 l_component_code := 'OFFSET';
181988 l_component_type_code := 'S';
181989 l_component_appl_id := 707;
181990 l_amb_context_code := 'DEFAULT';
181991 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
181992 l_event_class_code := 'WIP_MTL';
181993 l_event_type_code := 'WIP_SCRAP';
181994 l_line_definition_owner_code := 'S';
181995 l_line_definition_code := 'PI_WIP_SCRAP';
181996 --
181997 l_balance_type_code := 'A';
181998 l_segment := NULL;
181999 l_ccid := NULL;
182000 l_adr_transaction_coa_id := NULL;
182001 l_adr_accounting_coa_id := NULL;
182002 l_adr_flexfield_segment_code := NULL;
182003 l_adr_flex_value_set_id := NULL;
182004 l_adr_value_type_code := NULL;
182005 l_adr_value_combination_id := NULL;
182006 l_adr_value_segment_code := NULL;
182007
182008 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
182009 l_bflow_class_code := ''; -- 4219869 Business Flow
182010 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
182011 l_budgetary_control_flag := 'N';
182012
182013 l_bflow_applied_to_amt_idx := NULL; -- 5132302
182014 l_bflow_applied_to_amt := NULL; -- 5132302
182015 l_entered_amt_idx := NULL; -- 4262811
182016 l_accted_amt_idx := NULL; -- 4262811
182017 l_acc_rev_flag := NULL; -- 4262811
182018 l_accrual_line_num := NULL; -- 4262811
182019 l_tmp_amt := NULL; -- 4262811
182020 --
182021
182022 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
182023 l_balance_type_code <> 'B' THEN
182024 IF NVL(p_source_97,9E125) = 2
182025 THEN
182026
182027 --
182028 XLA_AE_LINES_PKG.SetNewLine;
182029
182030 p_balance_type_code := l_balance_type_code;
182031 -- set the flag so later we will know whether the gain loss line needs to be created
182032
182033 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
182034 p_actual_flag :='A';
182035 END IF;
182036
182037 --
182038 -- bulk performance
182039 --
182040 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
182041 p_header_num => 0); -- 4262811
182042 --
182043 -- set accounting line options
182044 --
182045 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
182046 p_natural_side_code => 'D'
182047 , p_gain_or_loss_flag => 'N'
182048 , p_gl_transfer_mode_code => 'S'
182049 , p_acct_entry_type_code => 'A'
182050 , p_switch_side_flag => 'Y'
182051 , p_merge_duplicate_code => 'N'
182052 );
182053 --
182054 l_acc_rev_natural_side_code := 'C'; -- 4262811
182055 --
182056 --
182057 -- set accounting line type info
182058 --
182059 xla_ae_lines_pkg.SetAcctLineType
182060 (p_component_type => l_component_type
182061 ,p_event_type_code => l_event_type_code
182062 ,p_line_definition_owner_code => l_line_definition_owner_code
182063 ,p_line_definition_code => l_line_definition_code
182064 ,p_accounting_line_code => l_component_code
182065 ,p_accounting_line_type_code => l_component_type_code
182066 ,p_accounting_line_appl_id => l_component_appl_id
182067 ,p_amb_context_code => l_amb_context_code
182068 ,p_entity_code => l_entity_code
182069 ,p_event_class_code => l_event_class_code);
182070 --
182071 -- set accounting class
182072 --
182073 xla_ae_lines_pkg.SetAcctClass(
182074 p_accounting_class_code => 'OFFSET'
182075 , p_ae_header_id => l_ae_header_id
182076 );
182077
182078 --
182079 -- set rounding class
182080 --
182081 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
182082 'OFFSET';
182083
182084 --
182085 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
182086 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
182087 --
182088 -- bulk performance
182089 --
182090 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
182091
182092 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
182093 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
182094
182095 -- 4955764
182096 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
182097 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
182098
182099 -- 4458381 Public Sector Enh
182100
182101 --
182102 -- set accounting attributes for the line type
182103 --
182104 l_entered_amt_idx := 3;
182105 l_accted_amt_idx := 8;
182106 l_bflow_applied_to_amt_idx := NULL; -- 5132302
182107 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
182108 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
182109 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
182110 l_rec_acct_attrs.array_char_value(2) := p_source_85;
182111 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
182112 l_rec_acct_attrs.array_num_value(3) := p_source_91;
182113 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
182114 l_rec_acct_attrs.array_char_value(4) := p_source_88;
182115 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
182116 l_rec_acct_attrs.array_date_value(5) := p_source_92;
182117 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
182118 l_rec_acct_attrs.array_num_value(6) := p_source_93;
182119 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
182120 l_rec_acct_attrs.array_char_value(7) := p_source_94;
182121 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
182122 l_rec_acct_attrs.array_num_value(8) := p_source_95;
182123
182124 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
182125 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
182126
182127 ---------------------------------------------------------------------------------------------------------------
182128 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
182129 ---------------------------------------------------------------------------------------------------------------
182130 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
182131
182132 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
182133 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
182134
182135 IF xla_accounting_cache_pkg.GetValueChar
182136 (p_source_code => 'LEDGER_CATEGORY_CODE'
182137 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
182138 AND l_bflow_method_code = 'PRIOR_ENTRY'
182139 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
182140 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
182141 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
182142 )
182143 THEN
182144 xla_ae_lines_pkg.BflowUpgEntry
182145 (p_business_method_code => l_bflow_method_code
182146 ,p_business_class_code => l_bflow_class_code
182147 ,p_balance_type => l_balance_type_code);
182148 ELSE
182149 NULL;
182150 -- No business flow processing for business flow method of NONE.
182151 END IF;
182152
182153 --
182154 -- call analytical criteria
182155 --
182156
182157 --
182158 -- call description
182159 --
182160
182161 xla_ae_lines_pkg.SetLineDescription(
182162 p_ae_header_id => l_ae_header_id
182163 ,p_description => Description_1 (
182164 p_application_id => p_application_id
182165 , p_ae_header_id => l_ae_header_id
182166 , p_source_1 => p_source_1
182167 , p_source_2 => p_source_2
182168 , p_source_3 => p_source_3
182169 , p_source_4 => p_source_4
182170 , p_source_5 => p_source_5
182171 )
182172 );
182173
182174
182175 --
182176 -- call ADRs
182177 -- Bug 4922099
182178 --
182179 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
182180 (NVL(l_actual_upg_option, 'N') = 'O') OR
182181 (NVL(l_enc_upg_option, 'N') = 'O')
182182 )
182183 THEN
182184 NULL;
182185 --
182186 --
182187
182188 l_ccid := AcctDerRule_6(
182189 p_application_id => p_application_id
182190 , p_ae_header_id => l_ae_header_id
182191 , p_source_11 => p_source_11
182192 , x_transaction_coa_id => l_adr_transaction_coa_id
182193 , x_accounting_coa_id => l_adr_accounting_coa_id
182194 , x_value_type_code => l_adr_value_type_code
182195 , p_side => 'NA'
182196 );
182197
182198 xla_ae_lines_pkg.set_ccid(
182199 p_code_combination_id => l_ccid
182200 , p_value_type_code => l_adr_value_type_code
182201 , p_transaction_coa_id => l_adr_transaction_coa_id
182202 , p_accounting_coa_id => l_adr_accounting_coa_id
182203 , p_adr_code => 'CST_DEFAULT'
182204 , p_adr_type_code => 'S'
182205 , p_component_type => l_component_type
182206 , p_component_code => l_component_code
182207 , p_component_type_code => l_component_type_code
182208 , p_component_appl_id => l_component_appl_id
182209 , p_amb_context_code => l_amb_context_code
182210 , p_side => 'NA'
182211 );
182212
182213
182214 --
182215 --
182216 END IF;
182217 --
182218 -- Bug 4922099
182219 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
182220 (NVL(l_enc_upg_option, 'N') = 'O')
182221 ) AND
182222 (l_bflow_method_code = 'PRIOR_ENTRY')
182223 )
182224 THEN
182225 IF
182226 --
182227 1 = 2
182228 --
182229 THEN
182230 xla_accounting_err_pkg.build_message
182231 (p_appli_s_name => 'XLA'
182232 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
182233 ,p_token_1 => 'LINE_NUMBER'
182234 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
182235 ,p_token_2 => 'LINE_TYPE_NAME'
182236 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
182237 l_component_type
182238 ,l_component_code
182239 ,l_component_type_code
182240 ,l_component_appl_id
182241 ,l_amb_context_code
182242 ,l_entity_code
182243 ,l_event_class_code
182244 )
182245 ,p_token_3 => 'OWNER'
182246 ,p_value_3 => xla_lookups_pkg.get_meaning(
182247 p_lookup_type => 'XLA_OWNER_TYPE'
182248 ,p_lookup_code => l_component_type_code
182249 )
182250 ,p_token_4 => 'PRODUCT_NAME'
182251 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
182252 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
182253 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
182254 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
182255 ,p_ae_header_id => NULL
182256 );
182257
182258 IF (C_LEVEL_ERROR>= g_log_level) THEN
182259 trace
182260 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
182261 ,p_level => C_LEVEL_ERROR
182262 ,p_module => l_log_module);
182263 END IF;
182264 END IF;
182265 END IF;
182266 --
182267 --
182268 ------------------------------------------------------------------------------------------------
182269 -- 4219869 Business Flow
182270 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
182271 -- Prior Entry. Currently, the following code is always generated.
182272 ------------------------------------------------------------------------------------------------
182273 XLA_AE_LINES_PKG.ValidateCurrentLine;
182274
182275 ------------------------------------------------------------------------------------
182276 -- 4219869 Business Flow
182277 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
182278 ------------------------------------------------------------------------------------
182279 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
182280
182281 ----------------------------------------------------------------------------------
182282 -- 4219869 Business Flow
182283 -- Update journal entry status -- Need to generate this within IF <condition>
182284 ----------------------------------------------------------------------------------
182285 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
182286 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
182287 ,p_balance_type_code => l_balance_type_code
182288 );
182289
182290 -------------------------------------------------------------------------------------------
182291 -- 4262811 - Generate the Accrual Reversal lines
182292 -------------------------------------------------------------------------------------------
182293 BEGIN
182294 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
182295 (g_array_event(p_event_id).array_value_num('header_index'));
182296 IF l_acc_rev_flag IS NULL THEN
182297 l_acc_rev_flag := 'N';
182298 END IF;
182299 EXCEPTION
182300 WHEN OTHERS THEN
182301 l_acc_rev_flag := 'N';
182302 END;
182303 --
182304 IF (l_acc_rev_flag = 'Y') THEN
182305
182306 -- 4645092 ------------------------------------------------------------------------------
182307 -- To allow MPA report to determine if it should generate report process
182308 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
182309 ------------------------------------------------------------------------------------------
182310
182311 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
182312 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
182313 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
182314 -- call ADRs
182315 -- Bug 4922099
182316 --
182317 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
182318 (NVL(l_actual_upg_option, 'N') = 'O') OR
182319 (NVL(l_enc_upg_option, 'N') = 'O')
182320 )
182321 THEN
182322 NULL;
182323 --
182324 --
182325
182326 l_ccid := AcctDerRule_6(
182327 p_application_id => p_application_id
182328 , p_ae_header_id => l_ae_header_id
182329 , p_source_11 => p_source_11
182330 , x_transaction_coa_id => l_adr_transaction_coa_id
182331 , x_accounting_coa_id => l_adr_accounting_coa_id
182332 , x_value_type_code => l_adr_value_type_code
182333 , p_side => 'NA'
182334 );
182335
182336 xla_ae_lines_pkg.set_ccid(
182337 p_code_combination_id => l_ccid
182338 , p_value_type_code => l_adr_value_type_code
182339 , p_transaction_coa_id => l_adr_transaction_coa_id
182340 , p_accounting_coa_id => l_adr_accounting_coa_id
182341 , p_adr_code => 'CST_DEFAULT'
182342 , p_adr_type_code => 'S'
182343 , p_component_type => l_component_type
182344 , p_component_code => l_component_code
182345 , p_component_type_code => l_component_type_code
182346 , p_component_appl_id => l_component_appl_id
182347 , p_amb_context_code => l_amb_context_code
182348 , p_side => 'NA'
182349 );
182350
182351
182352 --
182353 --
182354 END IF;
182355
182356 --
182357 -- Update the line information that should be overwritten
182358 --
182359 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
182360 p_header_num => 1);
182361 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
182362
182363 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
182364
182365 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
182366 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
182367 END IF;
182368
182369 --
182370 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
182371 --
182372 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
182373 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
182374 ELSE
182375 ---------------------------------------------------------------------------------------------------
182376 -- 4262811a Switch Sign
182377 ---------------------------------------------------------------------------------------------------
182378 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
182379 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
182380 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
182381 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
182382 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
182383 -- 5132302
182384 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
182385 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
182386
182387 END IF;
182388
182389 -- 4955764
182390 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
182391 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
182392
182393
182394 XLA_AE_LINES_PKG.ValidateCurrentLine;
182395 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
182396
182397 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
182398 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
182399 ,p_balance_type_code => l_balance_type_code);
182400
182401 END IF;
182402
182403 -----------------------------------------------------------------------------------------
182404 -- 4262811 Multiperiod Accounting
182405 -----------------------------------------------------------------------------------------
182406 -- No MPA option is assigned.
182407
182408
182409 END IF;
182410 END IF;
182411 --
182412
182413 --
182414 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
182415 trace
182416 (p_msg => 'END of AcctLineType_335'
182417 ,p_level => C_LEVEL_PROCEDURE
182418 ,p_module => l_log_module);
182419 END IF;
182420 --
182421 EXCEPTION
182422 WHEN xla_exceptions_pkg.application_exception THEN
182423 RAISE;
182424 WHEN OTHERS THEN
182425 xla_exceptions_pkg.raise_message
182426 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_335');
182427 END AcctLineType_335;
182428 --
182429
182430 ---------------------------------------
182431 --
182432 -- PRIVATE FUNCTION
182433 -- AcctLineType_336
182434 --
182435 ---------------------------------------
182436 PROCEDURE AcctLineType_336 (
182437 p_application_id IN NUMBER
182438 ,p_event_id IN NUMBER
182439 ,p_calculate_acctd_flag IN VARCHAR2
182440 ,p_calculate_g_l_flag IN VARCHAR2
182441 ,p_actual_flag IN OUT VARCHAR2
182442 ,p_balance_type_code OUT VARCHAR2
182443 ,p_gain_or_loss_ref OUT VARCHAR2
182444
182445 --TRANSACTION_ID
182446 , p_source_1 IN NUMBER
182447 --Item Concatenated Segments
182448 , p_source_2 IN VARCHAR2
182449 --Transaction Quantity
182450 , p_source_3 IN NUMBER
182451 --Transaction Unit of Measure Code
182452 , p_source_4 IN VARCHAR2
182453 --Inventory Transaction Type Description
182454 , p_source_5 IN VARCHAR2
182455 --Cost Management Default Account
182456 , p_source_11 IN NUMBER
182457 --Applied to Application ID
182458 , p_source_79 IN NUMBER
182459 --Applied to Distribution Link Type
182460 , p_source_80 IN VARCHAR2
182461 --Applied to Entity Code
182462 , p_source_81 IN VARCHAR2
182463 --Applied To Purchase Document Identifier
182464 , p_source_83 IN NUMBER
182465 --DISTRIBUTION_IDENTIFIER
182466 , p_source_84 IN NUMBER
182467 --Distribution Type
182468 , p_source_85 IN VARCHAR2
182469 , p_source_85_meaning IN VARCHAR2
182470 --PO Budget Account
182471 , p_source_86 IN NUMBER
182472 --Encumbrance Reversal Amount Entered
182473 , p_source_87 IN NUMBER
182474 --Entered Currency Code
182475 , p_source_88 IN VARCHAR2
182476 --Transaction Encumbrance Reversal Amount
182477 , p_source_89 IN NUMBER
182478 --Entered Amount
182479 , p_source_91 IN NUMBER
182480 --Currency Conversion Date
182481 , p_source_92 IN DATE
182482 --Currency Conversion Rate
182483 , p_source_93 IN NUMBER
182484 --Currency Conversion Type
182485 , p_source_94 IN VARCHAR2
182486 --Accounted Amount
182487 , p_source_95 IN NUMBER
182488 --Purchasing Encumbrance Type Identifier
182489 , p_source_96 IN NUMBER
182490 --Accounting Line Type
182491 , p_source_97 IN NUMBER
182492 --Costing Encumbrance Upgrade Option
182493 , p_source_100 IN VARCHAR2
182494 --TXN_PO_DISTRIBUTION_ID
182495 , p_source_101 IN NUMBER
182496 )
182497 IS
182498
182499 l_component_type VARCHAR2(80);
182500 l_component_code VARCHAR2(30);
182501 l_component_type_code VARCHAR2(1);
182502 l_component_appl_id INTEGER;
182503 l_amb_context_code VARCHAR2(30);
182504 l_entity_code VARCHAR2(30);
182505 l_event_class_code VARCHAR2(30);
182506 l_ae_header_id NUMBER;
182507 l_event_type_code VARCHAR2(30);
182508 l_line_definition_code VARCHAR2(30);
182509 l_line_definition_owner_code VARCHAR2(1);
182510 --
182511 -- adr variables
182512 l_segment VARCHAR2(30);
182513 l_ccid NUMBER;
182514 l_adr_transaction_coa_id NUMBER;
182515 l_adr_accounting_coa_id NUMBER;
182516 l_adr_flexfield_segment_code VARCHAR2(30);
182517 l_adr_flex_value_set_id NUMBER;
182518 l_adr_value_type_code VARCHAR2(30);
182519 l_adr_value_combination_id NUMBER;
182520 l_adr_value_segment_code VARCHAR2(30);
182521
182522 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
182523 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
182524 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
182525 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
182526
182527 -- 4262811 Variables ------------------------------------------------------------------------------------------
182528 l_entered_amt_idx NUMBER;
182529 l_accted_amt_idx NUMBER;
182530 l_acc_rev_flag VARCHAR2(1);
182531 l_accrual_line_num NUMBER;
182532 l_tmp_amt NUMBER;
182533 l_acc_rev_natural_side_code VARCHAR2(1);
182534
182535 l_num_entries NUMBER;
182536 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
182537 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
182538 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
182539 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
182540 l_recog_line_1 NUMBER;
182541 l_recog_line_2 NUMBER;
182542
182543 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
182544 l_bflow_applied_to_amt NUMBER; -- 5132302
182545 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
182546
182547 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
182548
182549 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
182550 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
182551
182552 ---------------------------------------------------------------------------------------------------------------
182553
182554
182555 --
182556 -- bulk performance
182557 --
182558 l_balance_type_code VARCHAR2(1);
182559 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
182560 l_log_module VARCHAR2(240);
182561
182562 --
182563 -- Upgrade strategy
182564 --
182565 l_actual_upg_option VARCHAR2(1);
182566 l_enc_upg_option VARCHAR2(1);
182567
182568 --
182569 BEGIN
182570 --
182571 IF g_log_enabled THEN
182572 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_336';
182573 END IF;
182574 --
182575 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
182576
182577 trace
182578 (p_msg => 'BEGIN of AcctLineType_336'
182579 ,p_level => C_LEVEL_PROCEDURE
182580 ,p_module => l_log_module);
182581
182582 END IF;
182583 --
182584 l_component_type := 'AMB_JLT';
182585 l_component_code := 'OFFSET';
182586 l_component_type_code := 'S';
182587 l_component_appl_id := 707;
182588 l_amb_context_code := 'DEFAULT';
182589 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
182590 l_event_class_code := 'PURCHASE_ORDER';
182591 l_event_type_code := 'LOG_PO_DEL_ADJ';
182592 l_line_definition_owner_code := 'S';
182593 l_line_definition_code := 'PI_LOG_PO_DEL_ADJ';
182594 --
182595 l_balance_type_code := 'A';
182596 l_segment := NULL;
182597 l_ccid := NULL;
182598 l_adr_transaction_coa_id := NULL;
182599 l_adr_accounting_coa_id := NULL;
182600 l_adr_flexfield_segment_code := NULL;
182601 l_adr_flex_value_set_id := NULL;
182602 l_adr_value_type_code := NULL;
182603 l_adr_value_combination_id := NULL;
182604 l_adr_value_segment_code := NULL;
182605
182606 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
182607 l_bflow_class_code := ''; -- 4219869 Business Flow
182608 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
182609 l_budgetary_control_flag := 'N';
182610
182611 l_bflow_applied_to_amt_idx := NULL; -- 5132302
182612 l_bflow_applied_to_amt := NULL; -- 5132302
182613 l_entered_amt_idx := NULL; -- 4262811
182614 l_accted_amt_idx := NULL; -- 4262811
182615 l_acc_rev_flag := NULL; -- 4262811
182616 l_accrual_line_num := NULL; -- 4262811
182617 l_tmp_amt := NULL; -- 4262811
182618 --
182619
182620 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
182621 l_balance_type_code <> 'B' THEN
182622 IF NVL(p_source_97,9E125) = 2
182623 THEN
182624
182625 --
182626 XLA_AE_LINES_PKG.SetNewLine;
182627
182628 p_balance_type_code := l_balance_type_code;
182629 -- set the flag so later we will know whether the gain loss line needs to be created
182630
182631 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
182632 p_actual_flag :='A';
182633 END IF;
182634
182635 --
182636 -- bulk performance
182637 --
182638 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
182639 p_header_num => 0); -- 4262811
182640 --
182641 -- set accounting line options
182642 --
182643 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
182644 p_natural_side_code => 'D'
182645 , p_gain_or_loss_flag => 'N'
182646 , p_gl_transfer_mode_code => 'S'
182647 , p_acct_entry_type_code => 'A'
182648 , p_switch_side_flag => 'Y'
182649 , p_merge_duplicate_code => 'N'
182650 );
182651 --
182652 l_acc_rev_natural_side_code := 'C'; -- 4262811
182653 --
182654 --
182655 -- set accounting line type info
182656 --
182657 xla_ae_lines_pkg.SetAcctLineType
182658 (p_component_type => l_component_type
182659 ,p_event_type_code => l_event_type_code
182660 ,p_line_definition_owner_code => l_line_definition_owner_code
182661 ,p_line_definition_code => l_line_definition_code
182662 ,p_accounting_line_code => l_component_code
182663 ,p_accounting_line_type_code => l_component_type_code
182664 ,p_accounting_line_appl_id => l_component_appl_id
182665 ,p_amb_context_code => l_amb_context_code
182666 ,p_entity_code => l_entity_code
182667 ,p_event_class_code => l_event_class_code);
182668 --
182669 -- set accounting class
182670 --
182671 xla_ae_lines_pkg.SetAcctClass(
182672 p_accounting_class_code => 'OFFSET'
182673 , p_ae_header_id => l_ae_header_id
182674 );
182675
182676 --
182677 -- set rounding class
182678 --
182679 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
182680 'OFFSET';
182681
182682 --
182683 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
182684 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
182685 --
182686 -- bulk performance
182687 --
182688 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
182689
182690 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
182691 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
182692
182693 -- 4955764
182694 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
182695 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
182696
182697 -- 4458381 Public Sector Enh
182698
182699 --
182700 -- set accounting attributes for the line type
182701 --
182702 l_entered_amt_idx := 17;
182703 l_accted_amt_idx := 22;
182704 l_bflow_applied_to_amt_idx := NULL; -- 5132302
182705 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
182706 l_rec_acct_attrs.array_num_value(1) := p_source_79;
182707 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
182708 l_rec_acct_attrs.array_char_value(2) := p_source_80;
182709 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
182710 l_rec_acct_attrs.array_char_value(3) := p_source_81;
182711 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
182712 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
182713 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
182714 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
182715 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
182716 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
182717 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
182718 l_rec_acct_attrs.array_char_value(7) := p_source_85;
182719 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
182720 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
182721 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
182722 l_rec_acct_attrs.array_num_value(9) := p_source_87;
182723 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
182724 l_rec_acct_attrs.array_char_value(10) := p_source_88;
182725 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
182726 l_rec_acct_attrs.array_num_value(11) := p_source_89;
182727 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
182728 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
182729 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
182730 l_rec_acct_attrs.array_num_value(13) := p_source_87;
182731 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
182732 l_rec_acct_attrs.array_char_value(14) := p_source_88;
182733 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
182734 l_rec_acct_attrs.array_num_value(15) := p_source_89;
182735 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
182736 l_rec_acct_attrs.array_char_value(16) := p_source_100;
182737 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
182738 l_rec_acct_attrs.array_num_value(17) := p_source_91;
182739 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
182740 l_rec_acct_attrs.array_char_value(18) := p_source_88;
182741 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
182742 l_rec_acct_attrs.array_date_value(19) := p_source_92;
182743 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
182744 l_rec_acct_attrs.array_num_value(20) := p_source_93;
182745 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
182746 l_rec_acct_attrs.array_char_value(21) := p_source_94;
182747 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
182748 l_rec_acct_attrs.array_num_value(22) := p_source_95;
182749 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
182750 l_rec_acct_attrs.array_num_value(23) := p_source_96;
182751 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
182752 l_rec_acct_attrs.array_num_value(24) := p_source_96;
182753
182754 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
182755 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
182756
182757 ---------------------------------------------------------------------------------------------------------------
182758 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
182759 ---------------------------------------------------------------------------------------------------------------
182760 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
182761
182762 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
182763 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
182764
182765 IF xla_accounting_cache_pkg.GetValueChar
182766 (p_source_code => 'LEDGER_CATEGORY_CODE'
182767 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
182768 AND l_bflow_method_code = 'PRIOR_ENTRY'
182769 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
182770 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
182771 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
182772 )
182773 THEN
182774 xla_ae_lines_pkg.BflowUpgEntry
182775 (p_business_method_code => l_bflow_method_code
182776 ,p_business_class_code => l_bflow_class_code
182777 ,p_balance_type => l_balance_type_code);
182778 ELSE
182779 NULL;
182780 -- No business flow processing for business flow method of NONE.
182781 END IF;
182782
182783 --
182784 -- call analytical criteria
182785 --
182786
182787 --
182788 -- call description
182789 --
182790
182791 xla_ae_lines_pkg.SetLineDescription(
182792 p_ae_header_id => l_ae_header_id
182793 ,p_description => Description_1 (
182794 p_application_id => p_application_id
182795 , p_ae_header_id => l_ae_header_id
182796 , p_source_1 => p_source_1
182797 , p_source_2 => p_source_2
182798 , p_source_3 => p_source_3
182799 , p_source_4 => p_source_4
182800 , p_source_5 => p_source_5
182801 )
182802 );
182803
182804
182805 --
182806 -- call ADRs
182807 -- Bug 4922099
182808 --
182809 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
182810 (NVL(l_actual_upg_option, 'N') = 'O') OR
182811 (NVL(l_enc_upg_option, 'N') = 'O')
182812 )
182813 THEN
182814 NULL;
182815 --
182816 --
182817
182818 l_ccid := AcctDerRule_6(
182819 p_application_id => p_application_id
182820 , p_ae_header_id => l_ae_header_id
182821 , p_source_11 => p_source_11
182822 , x_transaction_coa_id => l_adr_transaction_coa_id
182823 , x_accounting_coa_id => l_adr_accounting_coa_id
182824 , x_value_type_code => l_adr_value_type_code
182825 , p_side => 'NA'
182826 );
182827
182828 xla_ae_lines_pkg.set_ccid(
182829 p_code_combination_id => l_ccid
182830 , p_value_type_code => l_adr_value_type_code
182831 , p_transaction_coa_id => l_adr_transaction_coa_id
182832 , p_accounting_coa_id => l_adr_accounting_coa_id
182833 , p_adr_code => 'CST_DEFAULT'
182834 , p_adr_type_code => 'S'
182835 , p_component_type => l_component_type
182836 , p_component_code => l_component_code
182837 , p_component_type_code => l_component_type_code
182838 , p_component_appl_id => l_component_appl_id
182839 , p_amb_context_code => l_amb_context_code
182840 , p_side => 'NA'
182841 );
182842
182843
182844 --
182845 --
182846 END IF;
182847 --
182848 -- Bug 4922099
182849 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
182850 (NVL(l_enc_upg_option, 'N') = 'O')
182851 ) AND
182852 (l_bflow_method_code = 'PRIOR_ENTRY')
182853 )
182854 THEN
182855 IF
182856 --
182857 1 = 2
182858 --
182859 THEN
182860 xla_accounting_err_pkg.build_message
182861 (p_appli_s_name => 'XLA'
182862 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
182863 ,p_token_1 => 'LINE_NUMBER'
182864 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
182865 ,p_token_2 => 'LINE_TYPE_NAME'
182866 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
182867 l_component_type
182868 ,l_component_code
182869 ,l_component_type_code
182870 ,l_component_appl_id
182871 ,l_amb_context_code
182872 ,l_entity_code
182873 ,l_event_class_code
182874 )
182875 ,p_token_3 => 'OWNER'
182876 ,p_value_3 => xla_lookups_pkg.get_meaning(
182877 p_lookup_type => 'XLA_OWNER_TYPE'
182878 ,p_lookup_code => l_component_type_code
182879 )
182880 ,p_token_4 => 'PRODUCT_NAME'
182881 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
182882 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
182883 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
182884 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
182885 ,p_ae_header_id => NULL
182886 );
182887
182888 IF (C_LEVEL_ERROR>= g_log_level) THEN
182889 trace
182890 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
182891 ,p_level => C_LEVEL_ERROR
182892 ,p_module => l_log_module);
182893 END IF;
182894 END IF;
182895 END IF;
182896 --
182897 --
182898 ------------------------------------------------------------------------------------------------
182899 -- 4219869 Business Flow
182900 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
182901 -- Prior Entry. Currently, the following code is always generated.
182902 ------------------------------------------------------------------------------------------------
182903 XLA_AE_LINES_PKG.ValidateCurrentLine;
182904
182905 ------------------------------------------------------------------------------------
182906 -- 4219869 Business Flow
182907 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
182908 ------------------------------------------------------------------------------------
182909 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
182910
182911 ----------------------------------------------------------------------------------
182912 -- 4219869 Business Flow
182913 -- Update journal entry status -- Need to generate this within IF <condition>
182914 ----------------------------------------------------------------------------------
182915 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
182916 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
182917 ,p_balance_type_code => l_balance_type_code
182918 );
182919
182920 -------------------------------------------------------------------------------------------
182921 -- 4262811 - Generate the Accrual Reversal lines
182922 -------------------------------------------------------------------------------------------
182923 BEGIN
182924 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
182925 (g_array_event(p_event_id).array_value_num('header_index'));
182926 IF l_acc_rev_flag IS NULL THEN
182927 l_acc_rev_flag := 'N';
182928 END IF;
182929 EXCEPTION
182930 WHEN OTHERS THEN
182931 l_acc_rev_flag := 'N';
182932 END;
182933 --
182934 IF (l_acc_rev_flag = 'Y') THEN
182935
182936 -- 4645092 ------------------------------------------------------------------------------
182937 -- To allow MPA report to determine if it should generate report process
182938 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
182939 ------------------------------------------------------------------------------------------
182940
182941 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
182942 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
182943 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
182944 -- call ADRs
182945 -- Bug 4922099
182946 --
182947 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
182948 (NVL(l_actual_upg_option, 'N') = 'O') OR
182949 (NVL(l_enc_upg_option, 'N') = 'O')
182950 )
182951 THEN
182952 NULL;
182953 --
182954 --
182955
182956 l_ccid := AcctDerRule_6(
182957 p_application_id => p_application_id
182958 , p_ae_header_id => l_ae_header_id
182959 , p_source_11 => p_source_11
182960 , x_transaction_coa_id => l_adr_transaction_coa_id
182961 , x_accounting_coa_id => l_adr_accounting_coa_id
182962 , x_value_type_code => l_adr_value_type_code
182963 , p_side => 'NA'
182964 );
182965
182966 xla_ae_lines_pkg.set_ccid(
182967 p_code_combination_id => l_ccid
182968 , p_value_type_code => l_adr_value_type_code
182969 , p_transaction_coa_id => l_adr_transaction_coa_id
182970 , p_accounting_coa_id => l_adr_accounting_coa_id
182971 , p_adr_code => 'CST_DEFAULT'
182972 , p_adr_type_code => 'S'
182973 , p_component_type => l_component_type
182974 , p_component_code => l_component_code
182975 , p_component_type_code => l_component_type_code
182976 , p_component_appl_id => l_component_appl_id
182977 , p_amb_context_code => l_amb_context_code
182978 , p_side => 'NA'
182979 );
182980
182981
182982 --
182983 --
182984 END IF;
182985
182986 --
182987 -- Update the line information that should be overwritten
182988 --
182989 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
182990 p_header_num => 1);
182991 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
182992
182993 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
182994
182995 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
182996 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
182997 END IF;
182998
182999 --
183000 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
183001 --
183002 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
183003 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
183004 ELSE
183005 ---------------------------------------------------------------------------------------------------
183006 -- 4262811a Switch Sign
183007 ---------------------------------------------------------------------------------------------------
183008 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
183009 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
183010 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183011 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
183012 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183013 -- 5132302
183014 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
183015 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183016
183017 END IF;
183018
183019 -- 4955764
183020 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
183021 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
183022
183023
183024 XLA_AE_LINES_PKG.ValidateCurrentLine;
183025 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
183026
183027 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
183028 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
183029 ,p_balance_type_code => l_balance_type_code);
183030
183031 END IF;
183032
183033 -----------------------------------------------------------------------------------------
183034 -- 4262811 Multiperiod Accounting
183035 -----------------------------------------------------------------------------------------
183036 -- No MPA option is assigned.
183037
183038
183039 END IF;
183040 END IF;
183041 --
183042
183043 --
183044 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
183045 trace
183046 (p_msg => 'END of AcctLineType_336'
183047 ,p_level => C_LEVEL_PROCEDURE
183048 ,p_module => l_log_module);
183049 END IF;
183050 --
183051 EXCEPTION
183052 WHEN xla_exceptions_pkg.application_exception THEN
183053 RAISE;
183054 WHEN OTHERS THEN
183055 xla_exceptions_pkg.raise_message
183056 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_336');
183057 END AcctLineType_336;
183058 --
183059
183060 ---------------------------------------
183061 --
183062 -- PRIVATE FUNCTION
183063 -- AcctLineType_337
183064 --
183065 ---------------------------------------
183066 PROCEDURE AcctLineType_337 (
183067 p_application_id IN NUMBER
183068 ,p_event_id IN NUMBER
183069 ,p_calculate_acctd_flag IN VARCHAR2
183070 ,p_calculate_g_l_flag IN VARCHAR2
183071 ,p_actual_flag IN OUT VARCHAR2
183072 ,p_balance_type_code OUT VARCHAR2
183073 ,p_gain_or_loss_ref OUT VARCHAR2
183074
183075 --TRANSACTION_ID
183076 , p_source_1 IN NUMBER
183077 --Item Concatenated Segments
183078 , p_source_2 IN VARCHAR2
183079 --Transaction Quantity
183080 , p_source_3 IN NUMBER
183081 --Transaction Unit of Measure Code
183082 , p_source_4 IN VARCHAR2
183083 --Inventory Transaction Type Description
183084 , p_source_5 IN VARCHAR2
183085 --Cost Management Default Account
183086 , p_source_11 IN NUMBER
183087 --DISTRIBUTION_IDENTIFIER
183088 , p_source_84 IN NUMBER
183089 --Distribution Type
183090 , p_source_85 IN VARCHAR2
183091 , p_source_85_meaning IN VARCHAR2
183092 --Entered Currency Code
183093 , p_source_88 IN VARCHAR2
183094 --Entered Amount
183095 , p_source_91 IN NUMBER
183096 --Currency Conversion Date
183097 , p_source_92 IN DATE
183098 --Currency Conversion Rate
183099 , p_source_93 IN NUMBER
183100 --Currency Conversion Type
183101 , p_source_94 IN VARCHAR2
183102 --Accounted Amount
183103 , p_source_95 IN NUMBER
183104 --Accounting Line Type
183105 , p_source_97 IN NUMBER
183106 )
183107 IS
183108
183109 l_component_type VARCHAR2(80);
183110 l_component_code VARCHAR2(30);
183111 l_component_type_code VARCHAR2(1);
183112 l_component_appl_id INTEGER;
183113 l_amb_context_code VARCHAR2(30);
183114 l_entity_code VARCHAR2(30);
183115 l_event_class_code VARCHAR2(30);
183116 l_ae_header_id NUMBER;
183117 l_event_type_code VARCHAR2(30);
183118 l_line_definition_code VARCHAR2(30);
183119 l_line_definition_owner_code VARCHAR2(1);
183120 --
183121 -- adr variables
183122 l_segment VARCHAR2(30);
183123 l_ccid NUMBER;
183124 l_adr_transaction_coa_id NUMBER;
183125 l_adr_accounting_coa_id NUMBER;
183126 l_adr_flexfield_segment_code VARCHAR2(30);
183127 l_adr_flex_value_set_id NUMBER;
183128 l_adr_value_type_code VARCHAR2(30);
183129 l_adr_value_combination_id NUMBER;
183130 l_adr_value_segment_code VARCHAR2(30);
183131
183132 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
183133 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
183134 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
183135 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
183136
183137 -- 4262811 Variables ------------------------------------------------------------------------------------------
183138 l_entered_amt_idx NUMBER;
183139 l_accted_amt_idx NUMBER;
183140 l_acc_rev_flag VARCHAR2(1);
183141 l_accrual_line_num NUMBER;
183142 l_tmp_amt NUMBER;
183143 l_acc_rev_natural_side_code VARCHAR2(1);
183144
183145 l_num_entries NUMBER;
183146 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
183147 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
183148 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
183149 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
183150 l_recog_line_1 NUMBER;
183151 l_recog_line_2 NUMBER;
183152
183153 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
183154 l_bflow_applied_to_amt NUMBER; -- 5132302
183155 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
183156
183157 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
183158
183159 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
183160 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
183161
183162 ---------------------------------------------------------------------------------------------------------------
183163
183164
183165 --
183166 -- bulk performance
183167 --
183168 l_balance_type_code VARCHAR2(1);
183169 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
183170 l_log_module VARCHAR2(240);
183171
183172 --
183173 -- Upgrade strategy
183174 --
183175 l_actual_upg_option VARCHAR2(1);
183176 l_enc_upg_option VARCHAR2(1);
183177
183178 --
183179 BEGIN
183180 --
183181 IF g_log_enabled THEN
183182 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_337';
183183 END IF;
183184 --
183185 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
183186
183187 trace
183188 (p_msg => 'BEGIN of AcctLineType_337'
183189 ,p_level => C_LEVEL_PROCEDURE
183190 ,p_module => l_log_module);
183191
183192 END IF;
183193 --
183194 l_component_type := 'AMB_JLT';
183195 l_component_code := 'OFFSET';
183196 l_component_type_code := 'S';
183197 l_component_appl_id := 707;
183198 l_amb_context_code := 'DEFAULT';
183199 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
183200 l_event_class_code := 'USER_DEFINE';
183201 l_event_type_code := 'UDIR_INTERORG_RCPT';
183202 l_line_definition_owner_code := 'S';
183203 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
183204 --
183205 l_balance_type_code := 'A';
183206 l_segment := NULL;
183207 l_ccid := NULL;
183208 l_adr_transaction_coa_id := NULL;
183209 l_adr_accounting_coa_id := NULL;
183210 l_adr_flexfield_segment_code := NULL;
183211 l_adr_flex_value_set_id := NULL;
183212 l_adr_value_type_code := NULL;
183213 l_adr_value_combination_id := NULL;
183214 l_adr_value_segment_code := NULL;
183215
183216 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
183217 l_bflow_class_code := ''; -- 4219869 Business Flow
183218 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
183219 l_budgetary_control_flag := 'N';
183220
183221 l_bflow_applied_to_amt_idx := NULL; -- 5132302
183222 l_bflow_applied_to_amt := NULL; -- 5132302
183223 l_entered_amt_idx := NULL; -- 4262811
183224 l_accted_amt_idx := NULL; -- 4262811
183225 l_acc_rev_flag := NULL; -- 4262811
183226 l_accrual_line_num := NULL; -- 4262811
183227 l_tmp_amt := NULL; -- 4262811
183228 --
183229
183230 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
183231 l_balance_type_code <> 'B' THEN
183232 IF NVL(p_source_97,9E125) = 2
183233 THEN
183234
183235 --
183236 XLA_AE_LINES_PKG.SetNewLine;
183237
183238 p_balance_type_code := l_balance_type_code;
183239 -- set the flag so later we will know whether the gain loss line needs to be created
183240
183241 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
183242 p_actual_flag :='A';
183243 END IF;
183244
183245 --
183246 -- bulk performance
183247 --
183248 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
183249 p_header_num => 0); -- 4262811
183250 --
183251 -- set accounting line options
183252 --
183253 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
183254 p_natural_side_code => 'D'
183255 , p_gain_or_loss_flag => 'N'
183256 , p_gl_transfer_mode_code => 'S'
183257 , p_acct_entry_type_code => 'A'
183258 , p_switch_side_flag => 'Y'
183259 , p_merge_duplicate_code => 'N'
183260 );
183261 --
183262 l_acc_rev_natural_side_code := 'C'; -- 4262811
183263 --
183264 --
183265 -- set accounting line type info
183266 --
183267 xla_ae_lines_pkg.SetAcctLineType
183268 (p_component_type => l_component_type
183269 ,p_event_type_code => l_event_type_code
183270 ,p_line_definition_owner_code => l_line_definition_owner_code
183271 ,p_line_definition_code => l_line_definition_code
183272 ,p_accounting_line_code => l_component_code
183273 ,p_accounting_line_type_code => l_component_type_code
183274 ,p_accounting_line_appl_id => l_component_appl_id
183275 ,p_amb_context_code => l_amb_context_code
183276 ,p_entity_code => l_entity_code
183277 ,p_event_class_code => l_event_class_code);
183278 --
183279 -- set accounting class
183280 --
183281 xla_ae_lines_pkg.SetAcctClass(
183282 p_accounting_class_code => 'OFFSET'
183283 , p_ae_header_id => l_ae_header_id
183284 );
183285
183286 --
183287 -- set rounding class
183288 --
183289 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
183290 'OFFSET';
183291
183292 --
183293 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
183294 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
183295 --
183296 -- bulk performance
183297 --
183298 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
183299
183300 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
183301 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
183302
183303 -- 4955764
183304 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
183305 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
183306
183307 -- 4458381 Public Sector Enh
183308
183309 --
183310 -- set accounting attributes for the line type
183311 --
183312 l_entered_amt_idx := 3;
183313 l_accted_amt_idx := 8;
183314 l_bflow_applied_to_amt_idx := NULL; -- 5132302
183315 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
183316 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
183317 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
183318 l_rec_acct_attrs.array_char_value(2) := p_source_85;
183319 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
183320 l_rec_acct_attrs.array_num_value(3) := p_source_91;
183321 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
183322 l_rec_acct_attrs.array_char_value(4) := p_source_88;
183323 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
183324 l_rec_acct_attrs.array_date_value(5) := p_source_92;
183325 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
183326 l_rec_acct_attrs.array_num_value(6) := p_source_93;
183327 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
183328 l_rec_acct_attrs.array_char_value(7) := p_source_94;
183329 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
183330 l_rec_acct_attrs.array_num_value(8) := p_source_95;
183331
183332 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
183333 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
183334
183335 ---------------------------------------------------------------------------------------------------------------
183336 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
183337 ---------------------------------------------------------------------------------------------------------------
183338 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
183339
183340 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
183341 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
183342
183343 IF xla_accounting_cache_pkg.GetValueChar
183344 (p_source_code => 'LEDGER_CATEGORY_CODE'
183345 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
183346 AND l_bflow_method_code = 'PRIOR_ENTRY'
183347 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
183348 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
183349 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
183350 )
183351 THEN
183352 xla_ae_lines_pkg.BflowUpgEntry
183353 (p_business_method_code => l_bflow_method_code
183354 ,p_business_class_code => l_bflow_class_code
183355 ,p_balance_type => l_balance_type_code);
183356 ELSE
183357 NULL;
183358 -- No business flow processing for business flow method of NONE.
183359 END IF;
183360
183361 --
183362 -- call analytical criteria
183363 --
183364
183365 --
183366 -- call description
183367 --
183368
183369 xla_ae_lines_pkg.SetLineDescription(
183370 p_ae_header_id => l_ae_header_id
183371 ,p_description => Description_1 (
183372 p_application_id => p_application_id
183373 , p_ae_header_id => l_ae_header_id
183374 , p_source_1 => p_source_1
183375 , p_source_2 => p_source_2
183376 , p_source_3 => p_source_3
183377 , p_source_4 => p_source_4
183378 , p_source_5 => p_source_5
183379 )
183380 );
183381
183382
183383 --
183384 -- call ADRs
183385 -- Bug 4922099
183386 --
183387 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
183388 (NVL(l_actual_upg_option, 'N') = 'O') OR
183389 (NVL(l_enc_upg_option, 'N') = 'O')
183390 )
183391 THEN
183392 NULL;
183393 --
183394 --
183395
183396 l_ccid := AcctDerRule_6(
183397 p_application_id => p_application_id
183398 , p_ae_header_id => l_ae_header_id
183399 , p_source_11 => p_source_11
183400 , x_transaction_coa_id => l_adr_transaction_coa_id
183401 , x_accounting_coa_id => l_adr_accounting_coa_id
183402 , x_value_type_code => l_adr_value_type_code
183403 , p_side => 'NA'
183404 );
183405
183406 xla_ae_lines_pkg.set_ccid(
183407 p_code_combination_id => l_ccid
183408 , p_value_type_code => l_adr_value_type_code
183409 , p_transaction_coa_id => l_adr_transaction_coa_id
183410 , p_accounting_coa_id => l_adr_accounting_coa_id
183411 , p_adr_code => 'CST_DEFAULT'
183412 , p_adr_type_code => 'S'
183413 , p_component_type => l_component_type
183414 , p_component_code => l_component_code
183415 , p_component_type_code => l_component_type_code
183416 , p_component_appl_id => l_component_appl_id
183417 , p_amb_context_code => l_amb_context_code
183418 , p_side => 'NA'
183419 );
183420
183421
183422 --
183423 --
183424 END IF;
183425 --
183426 -- Bug 4922099
183427 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
183428 (NVL(l_enc_upg_option, 'N') = 'O')
183429 ) AND
183430 (l_bflow_method_code = 'PRIOR_ENTRY')
183431 )
183432 THEN
183433 IF
183434 --
183435 1 = 2
183436 --
183437 THEN
183438 xla_accounting_err_pkg.build_message
183439 (p_appli_s_name => 'XLA'
183440 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
183441 ,p_token_1 => 'LINE_NUMBER'
183442 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
183443 ,p_token_2 => 'LINE_TYPE_NAME'
183444 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
183445 l_component_type
183446 ,l_component_code
183447 ,l_component_type_code
183448 ,l_component_appl_id
183449 ,l_amb_context_code
183450 ,l_entity_code
183451 ,l_event_class_code
183452 )
183453 ,p_token_3 => 'OWNER'
183454 ,p_value_3 => xla_lookups_pkg.get_meaning(
183455 p_lookup_type => 'XLA_OWNER_TYPE'
183456 ,p_lookup_code => l_component_type_code
183457 )
183458 ,p_token_4 => 'PRODUCT_NAME'
183459 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
183460 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
183461 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
183462 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
183463 ,p_ae_header_id => NULL
183464 );
183465
183466 IF (C_LEVEL_ERROR>= g_log_level) THEN
183467 trace
183468 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
183469 ,p_level => C_LEVEL_ERROR
183470 ,p_module => l_log_module);
183471 END IF;
183472 END IF;
183473 END IF;
183474 --
183475 --
183476 ------------------------------------------------------------------------------------------------
183477 -- 4219869 Business Flow
183478 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
183479 -- Prior Entry. Currently, the following code is always generated.
183480 ------------------------------------------------------------------------------------------------
183481 XLA_AE_LINES_PKG.ValidateCurrentLine;
183482
183483 ------------------------------------------------------------------------------------
183484 -- 4219869 Business Flow
183485 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
183486 ------------------------------------------------------------------------------------
183487 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
183488
183489 ----------------------------------------------------------------------------------
183490 -- 4219869 Business Flow
183491 -- Update journal entry status -- Need to generate this within IF <condition>
183492 ----------------------------------------------------------------------------------
183493 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
183494 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
183495 ,p_balance_type_code => l_balance_type_code
183496 );
183497
183498 -------------------------------------------------------------------------------------------
183499 -- 4262811 - Generate the Accrual Reversal lines
183500 -------------------------------------------------------------------------------------------
183501 BEGIN
183502 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
183503 (g_array_event(p_event_id).array_value_num('header_index'));
183504 IF l_acc_rev_flag IS NULL THEN
183505 l_acc_rev_flag := 'N';
183506 END IF;
183507 EXCEPTION
183508 WHEN OTHERS THEN
183509 l_acc_rev_flag := 'N';
183510 END;
183511 --
183512 IF (l_acc_rev_flag = 'Y') THEN
183513
183514 -- 4645092 ------------------------------------------------------------------------------
183515 -- To allow MPA report to determine if it should generate report process
183516 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
183517 ------------------------------------------------------------------------------------------
183518
183519 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
183520 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
183521 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
183522 -- call ADRs
183523 -- Bug 4922099
183524 --
183525 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
183526 (NVL(l_actual_upg_option, 'N') = 'O') OR
183527 (NVL(l_enc_upg_option, 'N') = 'O')
183528 )
183529 THEN
183530 NULL;
183531 --
183532 --
183533
183534 l_ccid := AcctDerRule_6(
183535 p_application_id => p_application_id
183536 , p_ae_header_id => l_ae_header_id
183537 , p_source_11 => p_source_11
183538 , x_transaction_coa_id => l_adr_transaction_coa_id
183539 , x_accounting_coa_id => l_adr_accounting_coa_id
183540 , x_value_type_code => l_adr_value_type_code
183541 , p_side => 'NA'
183542 );
183543
183544 xla_ae_lines_pkg.set_ccid(
183545 p_code_combination_id => l_ccid
183546 , p_value_type_code => l_adr_value_type_code
183547 , p_transaction_coa_id => l_adr_transaction_coa_id
183548 , p_accounting_coa_id => l_adr_accounting_coa_id
183549 , p_adr_code => 'CST_DEFAULT'
183550 , p_adr_type_code => 'S'
183551 , p_component_type => l_component_type
183552 , p_component_code => l_component_code
183553 , p_component_type_code => l_component_type_code
183554 , p_component_appl_id => l_component_appl_id
183555 , p_amb_context_code => l_amb_context_code
183556 , p_side => 'NA'
183557 );
183558
183559
183560 --
183561 --
183562 END IF;
183563
183564 --
183565 -- Update the line information that should be overwritten
183566 --
183567 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
183568 p_header_num => 1);
183569 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
183570
183571 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
183572
183573 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
183574 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
183575 END IF;
183576
183577 --
183578 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
183579 --
183580 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
183581 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
183582 ELSE
183583 ---------------------------------------------------------------------------------------------------
183584 -- 4262811a Switch Sign
183585 ---------------------------------------------------------------------------------------------------
183586 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
183587 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
183588 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183589 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
183590 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183591 -- 5132302
183592 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
183593 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
183594
183595 END IF;
183596
183597 -- 4955764
183598 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
183599 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
183600
183601
183602 XLA_AE_LINES_PKG.ValidateCurrentLine;
183603 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
183604
183605 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
183606 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
183607 ,p_balance_type_code => l_balance_type_code);
183608
183609 END IF;
183610
183611 -----------------------------------------------------------------------------------------
183612 -- 4262811 Multiperiod Accounting
183613 -----------------------------------------------------------------------------------------
183614 -- No MPA option is assigned.
183615
183616
183617 END IF;
183618 END IF;
183619 --
183620
183621 --
183622 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
183623 trace
183624 (p_msg => 'END of AcctLineType_337'
183625 ,p_level => C_LEVEL_PROCEDURE
183626 ,p_module => l_log_module);
183627 END IF;
183628 --
183629 EXCEPTION
183630 WHEN xla_exceptions_pkg.application_exception THEN
183631 RAISE;
183632 WHEN OTHERS THEN
183633 xla_exceptions_pkg.raise_message
183634 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_337');
183635 END AcctLineType_337;
183636 --
183637
183638 ---------------------------------------
183639 --
183640 -- PRIVATE FUNCTION
183641 -- AcctLineType_338
183642 --
183643 ---------------------------------------
183644 PROCEDURE AcctLineType_338 (
183645 p_application_id IN NUMBER
183646 ,p_event_id IN NUMBER
183647 ,p_calculate_acctd_flag IN VARCHAR2
183648 ,p_calculate_g_l_flag IN VARCHAR2
183649 ,p_actual_flag IN OUT VARCHAR2
183650 ,p_balance_type_code OUT VARCHAR2
183651 ,p_gain_or_loss_ref OUT VARCHAR2
183652
183653 --Cost Management Default Account
183654 , p_source_11 IN NUMBER
183655 --DISTRIBUTION_IDENTIFIER
183656 , p_source_84 IN NUMBER
183657 --Distribution Type
183658 , p_source_85 IN VARCHAR2
183659 , p_source_85_meaning IN VARCHAR2
183660 --Entered Currency Code
183661 , p_source_88 IN VARCHAR2
183662 --Entered Amount
183663 , p_source_91 IN NUMBER
183664 --Currency Conversion Date
183665 , p_source_92 IN DATE
183666 --Currency Conversion Rate
183667 , p_source_93 IN NUMBER
183668 --Currency Conversion Type
183669 , p_source_94 IN VARCHAR2
183670 --Accounted Amount
183671 , p_source_95 IN NUMBER
183672 --Accounting Line Type
183673 , p_source_97 IN NUMBER
183674 )
183675 IS
183676
183677 l_component_type VARCHAR2(80);
183678 l_component_code VARCHAR2(30);
183679 l_component_type_code VARCHAR2(1);
183680 l_component_appl_id INTEGER;
183681 l_amb_context_code VARCHAR2(30);
183682 l_entity_code VARCHAR2(30);
183683 l_event_class_code VARCHAR2(30);
183684 l_ae_header_id NUMBER;
183685 l_event_type_code VARCHAR2(30);
183686 l_line_definition_code VARCHAR2(30);
183687 l_line_definition_owner_code VARCHAR2(1);
183688 --
183689 -- adr variables
183690 l_segment VARCHAR2(30);
183691 l_ccid NUMBER;
183692 l_adr_transaction_coa_id NUMBER;
183693 l_adr_accounting_coa_id NUMBER;
183694 l_adr_flexfield_segment_code VARCHAR2(30);
183695 l_adr_flex_value_set_id NUMBER;
183696 l_adr_value_type_code VARCHAR2(30);
183697 l_adr_value_combination_id NUMBER;
183698 l_adr_value_segment_code VARCHAR2(30);
183699
183700 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
183701 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
183702 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
183703 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
183704
183705 -- 4262811 Variables ------------------------------------------------------------------------------------------
183706 l_entered_amt_idx NUMBER;
183707 l_accted_amt_idx NUMBER;
183708 l_acc_rev_flag VARCHAR2(1);
183709 l_accrual_line_num NUMBER;
183710 l_tmp_amt NUMBER;
183711 l_acc_rev_natural_side_code VARCHAR2(1);
183712
183713 l_num_entries NUMBER;
183714 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
183715 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
183716 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
183717 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
183718 l_recog_line_1 NUMBER;
183719 l_recog_line_2 NUMBER;
183720
183721 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
183722 l_bflow_applied_to_amt NUMBER; -- 5132302
183723 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
183724
183725 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
183726
183727 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
183728 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
183729
183730 ---------------------------------------------------------------------------------------------------------------
183731
183732
183733 --
183734 -- bulk performance
183735 --
183736 l_balance_type_code VARCHAR2(1);
183737 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
183738 l_log_module VARCHAR2(240);
183739
183740 --
183741 -- Upgrade strategy
183742 --
183743 l_actual_upg_option VARCHAR2(1);
183744 l_enc_upg_option VARCHAR2(1);
183745
183746 --
183747 BEGIN
183748 --
183749 IF g_log_enabled THEN
183750 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_338';
183751 END IF;
183752 --
183753 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
183754
183755 trace
183756 (p_msg => 'BEGIN of AcctLineType_338'
183757 ,p_level => C_LEVEL_PROCEDURE
183758 ,p_module => l_log_module);
183759
183760 END IF;
183761 --
183762 l_component_type := 'AMB_JLT';
183763 l_component_code := 'OFFSET';
183764 l_component_type_code := 'S';
183765 l_component_appl_id := 707;
183766 l_amb_context_code := 'DEFAULT';
183767 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
183768 l_event_class_code := 'USER_DEFINE';
183769 l_event_type_code := 'UDIR_INTERORG_RCPT_NO_TP';
183770 l_line_definition_owner_code := 'S';
183771 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_NO_TP';
183772 --
183773 l_balance_type_code := 'A';
183774 l_segment := NULL;
183775 l_ccid := NULL;
183776 l_adr_transaction_coa_id := NULL;
183777 l_adr_accounting_coa_id := NULL;
183778 l_adr_flexfield_segment_code := NULL;
183779 l_adr_flex_value_set_id := NULL;
183780 l_adr_value_type_code := NULL;
183781 l_adr_value_combination_id := NULL;
183782 l_adr_value_segment_code := NULL;
183783
183784 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
183785 l_bflow_class_code := ''; -- 4219869 Business Flow
183786 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
183787 l_budgetary_control_flag := 'N';
183788
183789 l_bflow_applied_to_amt_idx := NULL; -- 5132302
183790 l_bflow_applied_to_amt := NULL; -- 5132302
183791 l_entered_amt_idx := NULL; -- 4262811
183792 l_accted_amt_idx := NULL; -- 4262811
183793 l_acc_rev_flag := NULL; -- 4262811
183794 l_accrual_line_num := NULL; -- 4262811
183795 l_tmp_amt := NULL; -- 4262811
183796 --
183797
183798 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
183799 l_balance_type_code <> 'B' THEN
183800 IF NVL(p_source_97,9E125) = 2
183801 THEN
183802
183803 --
183804 XLA_AE_LINES_PKG.SetNewLine;
183805
183806 p_balance_type_code := l_balance_type_code;
183807 -- set the flag so later we will know whether the gain loss line needs to be created
183808
183809 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
183810 p_actual_flag :='A';
183811 END IF;
183812
183813 --
183814 -- bulk performance
183815 --
183816 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
183817 p_header_num => 0); -- 4262811
183818 --
183819 -- set accounting line options
183820 --
183821 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
183822 p_natural_side_code => 'D'
183823 , p_gain_or_loss_flag => 'N'
183824 , p_gl_transfer_mode_code => 'S'
183825 , p_acct_entry_type_code => 'A'
183826 , p_switch_side_flag => 'Y'
183827 , p_merge_duplicate_code => 'N'
183828 );
183829 --
183830 l_acc_rev_natural_side_code := 'C'; -- 4262811
183831 --
183832 --
183833 -- set accounting line type info
183834 --
183835 xla_ae_lines_pkg.SetAcctLineType
183836 (p_component_type => l_component_type
183837 ,p_event_type_code => l_event_type_code
183838 ,p_line_definition_owner_code => l_line_definition_owner_code
183839 ,p_line_definition_code => l_line_definition_code
183840 ,p_accounting_line_code => l_component_code
183841 ,p_accounting_line_type_code => l_component_type_code
183842 ,p_accounting_line_appl_id => l_component_appl_id
183843 ,p_amb_context_code => l_amb_context_code
183844 ,p_entity_code => l_entity_code
183845 ,p_event_class_code => l_event_class_code);
183846 --
183847 -- set accounting class
183848 --
183849 xla_ae_lines_pkg.SetAcctClass(
183850 p_accounting_class_code => 'OFFSET'
183851 , p_ae_header_id => l_ae_header_id
183852 );
183853
183854 --
183855 -- set rounding class
183856 --
183857 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
183858 'OFFSET';
183859
183860 --
183861 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
183862 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
183863 --
183864 -- bulk performance
183865 --
183866 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
183867
183868 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
183869 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
183870
183871 -- 4955764
183872 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
183873 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
183874
183875 -- 4458381 Public Sector Enh
183876
183877 --
183878 -- set accounting attributes for the line type
183879 --
183880 l_entered_amt_idx := 3;
183881 l_accted_amt_idx := 8;
183882 l_bflow_applied_to_amt_idx := NULL; -- 5132302
183883 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
183884 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
183885 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
183886 l_rec_acct_attrs.array_char_value(2) := p_source_85;
183887 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
183888 l_rec_acct_attrs.array_num_value(3) := p_source_91;
183889 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
183890 l_rec_acct_attrs.array_char_value(4) := p_source_88;
183891 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
183892 l_rec_acct_attrs.array_date_value(5) := p_source_92;
183893 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
183894 l_rec_acct_attrs.array_num_value(6) := p_source_93;
183895 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
183896 l_rec_acct_attrs.array_char_value(7) := p_source_94;
183897 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
183898 l_rec_acct_attrs.array_num_value(8) := p_source_95;
183899
183900 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
183901 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
183902
183903 ---------------------------------------------------------------------------------------------------------------
183904 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
183905 ---------------------------------------------------------------------------------------------------------------
183906 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
183907
183908 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
183909 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
183910
183911 IF xla_accounting_cache_pkg.GetValueChar
183912 (p_source_code => 'LEDGER_CATEGORY_CODE'
183913 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
183914 AND l_bflow_method_code = 'PRIOR_ENTRY'
183915 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
183916 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
183917 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
183918 )
183919 THEN
183920 xla_ae_lines_pkg.BflowUpgEntry
183921 (p_business_method_code => l_bflow_method_code
183922 ,p_business_class_code => l_bflow_class_code
183923 ,p_balance_type => l_balance_type_code);
183924 ELSE
183925 NULL;
183926 -- No business flow processing for business flow method of NONE.
183927 END IF;
183928
183929 --
183930 -- call analytical criteria
183931 --
183932
183933 --
183934 -- call description
183935 --
183936 -- No description or it is inherited.
183937 --
183938 -- call ADRs
183939 -- Bug 4922099
183940 --
183941 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
183942 (NVL(l_actual_upg_option, 'N') = 'O') OR
183943 (NVL(l_enc_upg_option, 'N') = 'O')
183944 )
183945 THEN
183946 NULL;
183947 --
183948 --
183949
183950 l_ccid := AcctDerRule_6(
183951 p_application_id => p_application_id
183952 , p_ae_header_id => l_ae_header_id
183953 , p_source_11 => p_source_11
183954 , x_transaction_coa_id => l_adr_transaction_coa_id
183955 , x_accounting_coa_id => l_adr_accounting_coa_id
183956 , x_value_type_code => l_adr_value_type_code
183957 , p_side => 'NA'
183958 );
183959
183960 xla_ae_lines_pkg.set_ccid(
183961 p_code_combination_id => l_ccid
183962 , p_value_type_code => l_adr_value_type_code
183963 , p_transaction_coa_id => l_adr_transaction_coa_id
183964 , p_accounting_coa_id => l_adr_accounting_coa_id
183965 , p_adr_code => 'CST_DEFAULT'
183966 , p_adr_type_code => 'S'
183967 , p_component_type => l_component_type
183968 , p_component_code => l_component_code
183969 , p_component_type_code => l_component_type_code
183970 , p_component_appl_id => l_component_appl_id
183971 , p_amb_context_code => l_amb_context_code
183972 , p_side => 'NA'
183973 );
183974
183975
183976 --
183977 --
183978 END IF;
183979 --
183980 -- Bug 4922099
183981 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
183982 (NVL(l_enc_upg_option, 'N') = 'O')
183983 ) AND
183984 (l_bflow_method_code = 'PRIOR_ENTRY')
183985 )
183986 THEN
183987 IF
183988 --
183989 1 = 2
183990 --
183991 THEN
183992 xla_accounting_err_pkg.build_message
183993 (p_appli_s_name => 'XLA'
183994 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
183995 ,p_token_1 => 'LINE_NUMBER'
183996 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
183997 ,p_token_2 => 'LINE_TYPE_NAME'
183998 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
183999 l_component_type
184000 ,l_component_code
184001 ,l_component_type_code
184002 ,l_component_appl_id
184003 ,l_amb_context_code
184004 ,l_entity_code
184005 ,l_event_class_code
184006 )
184007 ,p_token_3 => 'OWNER'
184008 ,p_value_3 => xla_lookups_pkg.get_meaning(
184009 p_lookup_type => 'XLA_OWNER_TYPE'
184010 ,p_lookup_code => l_component_type_code
184011 )
184012 ,p_token_4 => 'PRODUCT_NAME'
184013 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
184014 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
184015 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
184016 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
184017 ,p_ae_header_id => NULL
184018 );
184019
184020 IF (C_LEVEL_ERROR>= g_log_level) THEN
184021 trace
184022 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
184023 ,p_level => C_LEVEL_ERROR
184024 ,p_module => l_log_module);
184025 END IF;
184026 END IF;
184027 END IF;
184028 --
184029 --
184030 ------------------------------------------------------------------------------------------------
184031 -- 4219869 Business Flow
184032 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
184033 -- Prior Entry. Currently, the following code is always generated.
184034 ------------------------------------------------------------------------------------------------
184035 XLA_AE_LINES_PKG.ValidateCurrentLine;
184036
184037 ------------------------------------------------------------------------------------
184038 -- 4219869 Business Flow
184039 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
184040 ------------------------------------------------------------------------------------
184041 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
184042
184043 ----------------------------------------------------------------------------------
184044 -- 4219869 Business Flow
184045 -- Update journal entry status -- Need to generate this within IF <condition>
184046 ----------------------------------------------------------------------------------
184047 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
184048 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
184049 ,p_balance_type_code => l_balance_type_code
184050 );
184051
184052 -------------------------------------------------------------------------------------------
184053 -- 4262811 - Generate the Accrual Reversal lines
184054 -------------------------------------------------------------------------------------------
184055 BEGIN
184056 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
184057 (g_array_event(p_event_id).array_value_num('header_index'));
184058 IF l_acc_rev_flag IS NULL THEN
184059 l_acc_rev_flag := 'N';
184060 END IF;
184061 EXCEPTION
184062 WHEN OTHERS THEN
184063 l_acc_rev_flag := 'N';
184064 END;
184065 --
184066 IF (l_acc_rev_flag = 'Y') THEN
184067
184068 -- 4645092 ------------------------------------------------------------------------------
184069 -- To allow MPA report to determine if it should generate report process
184070 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
184071 ------------------------------------------------------------------------------------------
184072
184073 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
184074 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
184075 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
184076 -- call ADRs
184077 -- Bug 4922099
184078 --
184079 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
184080 (NVL(l_actual_upg_option, 'N') = 'O') OR
184081 (NVL(l_enc_upg_option, 'N') = 'O')
184082 )
184083 THEN
184084 NULL;
184085 --
184086 --
184087
184088 l_ccid := AcctDerRule_6(
184089 p_application_id => p_application_id
184090 , p_ae_header_id => l_ae_header_id
184091 , p_source_11 => p_source_11
184092 , x_transaction_coa_id => l_adr_transaction_coa_id
184093 , x_accounting_coa_id => l_adr_accounting_coa_id
184094 , x_value_type_code => l_adr_value_type_code
184095 , p_side => 'NA'
184096 );
184097
184098 xla_ae_lines_pkg.set_ccid(
184099 p_code_combination_id => l_ccid
184100 , p_value_type_code => l_adr_value_type_code
184101 , p_transaction_coa_id => l_adr_transaction_coa_id
184102 , p_accounting_coa_id => l_adr_accounting_coa_id
184103 , p_adr_code => 'CST_DEFAULT'
184104 , p_adr_type_code => 'S'
184105 , p_component_type => l_component_type
184106 , p_component_code => l_component_code
184107 , p_component_type_code => l_component_type_code
184108 , p_component_appl_id => l_component_appl_id
184109 , p_amb_context_code => l_amb_context_code
184110 , p_side => 'NA'
184111 );
184112
184113
184114 --
184115 --
184116 END IF;
184117
184118 --
184119 -- Update the line information that should be overwritten
184120 --
184121 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
184122 p_header_num => 1);
184123 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
184124
184125 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
184126
184127 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
184128 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
184129 END IF;
184130
184131 --
184132 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
184133 --
184134 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
184135 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
184136 ELSE
184137 ---------------------------------------------------------------------------------------------------
184138 -- 4262811a Switch Sign
184139 ---------------------------------------------------------------------------------------------------
184140 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
184141 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
184142 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184143 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
184144 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184145 -- 5132302
184146 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
184147 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184148
184149 END IF;
184150
184151 -- 4955764
184152 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
184153 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
184154
184155
184156 XLA_AE_LINES_PKG.ValidateCurrentLine;
184157 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
184158
184159 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
184160 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
184161 ,p_balance_type_code => l_balance_type_code);
184162
184163 END IF;
184164
184165 -----------------------------------------------------------------------------------------
184166 -- 4262811 Multiperiod Accounting
184167 -----------------------------------------------------------------------------------------
184168 -- No MPA option is assigned.
184169
184170
184171 END IF;
184172 END IF;
184173 --
184174
184175 --
184176 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
184177 trace
184178 (p_msg => 'END of AcctLineType_338'
184179 ,p_level => C_LEVEL_PROCEDURE
184180 ,p_module => l_log_module);
184181 END IF;
184182 --
184183 EXCEPTION
184184 WHEN xla_exceptions_pkg.application_exception THEN
184185 RAISE;
184186 WHEN OTHERS THEN
184187 xla_exceptions_pkg.raise_message
184188 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_338');
184189 END AcctLineType_338;
184190 --
184191
184192 ---------------------------------------
184193 --
184194 -- PRIVATE FUNCTION
184195 -- AcctLineType_339
184196 --
184197 ---------------------------------------
184198 PROCEDURE AcctLineType_339 (
184199 p_application_id IN NUMBER
184200 ,p_event_id IN NUMBER
184201 ,p_calculate_acctd_flag IN VARCHAR2
184202 ,p_calculate_g_l_flag IN VARCHAR2
184203 ,p_actual_flag IN OUT VARCHAR2
184204 ,p_balance_type_code OUT VARCHAR2
184205 ,p_gain_or_loss_ref OUT VARCHAR2
184206
184207 --Cost Management Default Account
184208 , p_source_11 IN NUMBER
184209 --DISTRIBUTION_IDENTIFIER
184210 , p_source_84 IN NUMBER
184211 --Distribution Type
184212 , p_source_85 IN VARCHAR2
184213 , p_source_85_meaning IN VARCHAR2
184214 --Entered Currency Code
184215 , p_source_88 IN VARCHAR2
184216 --Entered Amount
184217 , p_source_91 IN NUMBER
184218 --Currency Conversion Date
184219 , p_source_92 IN DATE
184220 --Currency Conversion Rate
184221 , p_source_93 IN NUMBER
184222 --Accounted Amount
184223 , p_source_95 IN NUMBER
184224 --Accounting Line Type
184225 , p_source_97 IN NUMBER
184226 )
184227 IS
184228
184229 l_component_type VARCHAR2(80);
184230 l_component_code VARCHAR2(30);
184231 l_component_type_code VARCHAR2(1);
184232 l_component_appl_id INTEGER;
184233 l_amb_context_code VARCHAR2(30);
184234 l_entity_code VARCHAR2(30);
184235 l_event_class_code VARCHAR2(30);
184236 l_ae_header_id NUMBER;
184237 l_event_type_code VARCHAR2(30);
184238 l_line_definition_code VARCHAR2(30);
184239 l_line_definition_owner_code VARCHAR2(1);
184240 --
184241 -- adr variables
184242 l_segment VARCHAR2(30);
184243 l_ccid NUMBER;
184244 l_adr_transaction_coa_id NUMBER;
184245 l_adr_accounting_coa_id NUMBER;
184246 l_adr_flexfield_segment_code VARCHAR2(30);
184247 l_adr_flex_value_set_id NUMBER;
184248 l_adr_value_type_code VARCHAR2(30);
184249 l_adr_value_combination_id NUMBER;
184250 l_adr_value_segment_code VARCHAR2(30);
184251
184252 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
184253 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
184254 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
184255 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
184256
184257 -- 4262811 Variables ------------------------------------------------------------------------------------------
184258 l_entered_amt_idx NUMBER;
184259 l_accted_amt_idx NUMBER;
184260 l_acc_rev_flag VARCHAR2(1);
184261 l_accrual_line_num NUMBER;
184262 l_tmp_amt NUMBER;
184263 l_acc_rev_natural_side_code VARCHAR2(1);
184264
184265 l_num_entries NUMBER;
184266 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
184267 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
184268 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
184269 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
184270 l_recog_line_1 NUMBER;
184271 l_recog_line_2 NUMBER;
184272
184273 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
184274 l_bflow_applied_to_amt NUMBER; -- 5132302
184275 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
184276
184277 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
184278
184279 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
184280 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
184281
184282 ---------------------------------------------------------------------------------------------------------------
184283
184284
184285 --
184286 -- bulk performance
184287 --
184288 l_balance_type_code VARCHAR2(1);
184289 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
184290 l_log_module VARCHAR2(240);
184291
184292 --
184293 -- Upgrade strategy
184294 --
184295 l_actual_upg_option VARCHAR2(1);
184296 l_enc_upg_option VARCHAR2(1);
184297
184298 --
184299 BEGIN
184300 --
184301 IF g_log_enabled THEN
184302 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_339';
184303 END IF;
184304 --
184305 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
184306
184307 trace
184308 (p_msg => 'BEGIN of AcctLineType_339'
184309 ,p_level => C_LEVEL_PROCEDURE
184310 ,p_module => l_log_module);
184311
184312 END IF;
184313 --
184314 l_component_type := 'AMB_JLT';
184315 l_component_code := 'OFFSET';
184316 l_component_type_code := 'S';
184317 l_component_appl_id := 707;
184318 l_amb_context_code := 'DEFAULT';
184319 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
184320 l_event_class_code := 'OSP';
184321 l_event_type_code := 'IPV_TRANSFER_WO';
184322 l_line_definition_owner_code := 'S';
184323 l_line_definition_code := 'PI_IPV_TRANSFER_WO';
184324 --
184325 l_balance_type_code := 'A';
184326 l_segment := NULL;
184327 l_ccid := NULL;
184328 l_adr_transaction_coa_id := NULL;
184329 l_adr_accounting_coa_id := NULL;
184330 l_adr_flexfield_segment_code := NULL;
184331 l_adr_flex_value_set_id := NULL;
184332 l_adr_value_type_code := NULL;
184333 l_adr_value_combination_id := NULL;
184334 l_adr_value_segment_code := NULL;
184335
184336 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
184337 l_bflow_class_code := ''; -- 4219869 Business Flow
184338 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
184339 l_budgetary_control_flag := 'N';
184340
184341 l_bflow_applied_to_amt_idx := NULL; -- 5132302
184342 l_bflow_applied_to_amt := NULL; -- 5132302
184343 l_entered_amt_idx := NULL; -- 4262811
184344 l_accted_amt_idx := NULL; -- 4262811
184345 l_acc_rev_flag := NULL; -- 4262811
184346 l_accrual_line_num := NULL; -- 4262811
184347 l_tmp_amt := NULL; -- 4262811
184348 --
184349
184350 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
184351 l_balance_type_code <> 'B' THEN
184352 IF NVL(p_source_97,9E125) = 2
184353 THEN
184354
184355 --
184356 XLA_AE_LINES_PKG.SetNewLine;
184357
184358 p_balance_type_code := l_balance_type_code;
184359 -- set the flag so later we will know whether the gain loss line needs to be created
184360
184361 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
184362 p_actual_flag :='A';
184363 END IF;
184364
184365 --
184366 -- bulk performance
184367 --
184368 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
184369 p_header_num => 0); -- 4262811
184370 --
184371 -- set accounting line options
184372 --
184373 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
184374 p_natural_side_code => 'D'
184375 , p_gain_or_loss_flag => 'N'
184376 , p_gl_transfer_mode_code => 'S'
184377 , p_acct_entry_type_code => 'A'
184378 , p_switch_side_flag => 'Y'
184379 , p_merge_duplicate_code => 'N'
184380 );
184381 --
184382 l_acc_rev_natural_side_code := 'C'; -- 4262811
184383 --
184384 --
184385 -- set accounting line type info
184386 --
184387 xla_ae_lines_pkg.SetAcctLineType
184388 (p_component_type => l_component_type
184389 ,p_event_type_code => l_event_type_code
184390 ,p_line_definition_owner_code => l_line_definition_owner_code
184391 ,p_line_definition_code => l_line_definition_code
184392 ,p_accounting_line_code => l_component_code
184393 ,p_accounting_line_type_code => l_component_type_code
184394 ,p_accounting_line_appl_id => l_component_appl_id
184395 ,p_amb_context_code => l_amb_context_code
184396 ,p_entity_code => l_entity_code
184397 ,p_event_class_code => l_event_class_code);
184398 --
184399 -- set accounting class
184400 --
184401 xla_ae_lines_pkg.SetAcctClass(
184402 p_accounting_class_code => 'OFFSET'
184403 , p_ae_header_id => l_ae_header_id
184404 );
184405
184406 --
184407 -- set rounding class
184408 --
184409 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
184410 'OFFSET';
184411
184412 --
184413 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
184414 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
184415 --
184416 -- bulk performance
184417 --
184418 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
184419
184420 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
184421 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
184422
184423 -- 4955764
184424 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
184425 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
184426
184427 -- 4458381 Public Sector Enh
184428
184429 --
184430 -- set accounting attributes for the line type
184431 --
184432 l_entered_amt_idx := 3;
184433 l_accted_amt_idx := 8;
184434 l_bflow_applied_to_amt_idx := NULL; -- 5132302
184435 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
184436 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
184437 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
184438 l_rec_acct_attrs.array_char_value(2) := p_source_85;
184439 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
184440 l_rec_acct_attrs.array_num_value(3) := p_source_91;
184441 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
184442 l_rec_acct_attrs.array_char_value(4) := p_source_88;
184443 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
184444 l_rec_acct_attrs.array_date_value(5) := p_source_92;
184445 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
184446 l_rec_acct_attrs.array_num_value(6) := p_source_93;
184447 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
184448 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
184449 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
184450 l_rec_acct_attrs.array_num_value(8) := p_source_95;
184451
184452 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
184453 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
184454
184455 ---------------------------------------------------------------------------------------------------------------
184456 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
184457 ---------------------------------------------------------------------------------------------------------------
184458 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
184459
184460 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
184461 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
184462
184463 IF xla_accounting_cache_pkg.GetValueChar
184464 (p_source_code => 'LEDGER_CATEGORY_CODE'
184465 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
184466 AND l_bflow_method_code = 'PRIOR_ENTRY'
184467 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
184468 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
184469 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
184470 )
184471 THEN
184472 xla_ae_lines_pkg.BflowUpgEntry
184473 (p_business_method_code => l_bflow_method_code
184474 ,p_business_class_code => l_bflow_class_code
184475 ,p_balance_type => l_balance_type_code);
184476 ELSE
184477 NULL;
184478 -- No business flow processing for business flow method of NONE.
184479 END IF;
184480
184481 --
184482 -- call analytical criteria
184483 --
184484
184485 --
184486 -- call description
184487 --
184488 -- No description or it is inherited.
184489 --
184490 -- call ADRs
184491 -- Bug 4922099
184492 --
184493 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
184494 (NVL(l_actual_upg_option, 'N') = 'O') OR
184495 (NVL(l_enc_upg_option, 'N') = 'O')
184496 )
184497 THEN
184498 NULL;
184499 --
184500 --
184501
184502 l_ccid := AcctDerRule_6(
184503 p_application_id => p_application_id
184504 , p_ae_header_id => l_ae_header_id
184505 , p_source_11 => p_source_11
184506 , x_transaction_coa_id => l_adr_transaction_coa_id
184507 , x_accounting_coa_id => l_adr_accounting_coa_id
184508 , x_value_type_code => l_adr_value_type_code
184509 , p_side => 'NA'
184510 );
184511
184512 xla_ae_lines_pkg.set_ccid(
184513 p_code_combination_id => l_ccid
184514 , p_value_type_code => l_adr_value_type_code
184515 , p_transaction_coa_id => l_adr_transaction_coa_id
184516 , p_accounting_coa_id => l_adr_accounting_coa_id
184517 , p_adr_code => 'CST_DEFAULT'
184518 , p_adr_type_code => 'S'
184519 , p_component_type => l_component_type
184520 , p_component_code => l_component_code
184521 , p_component_type_code => l_component_type_code
184522 , p_component_appl_id => l_component_appl_id
184523 , p_amb_context_code => l_amb_context_code
184524 , p_side => 'NA'
184525 );
184526
184527
184528 --
184529 --
184530 END IF;
184531 --
184532 -- Bug 4922099
184533 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
184534 (NVL(l_enc_upg_option, 'N') = 'O')
184535 ) AND
184536 (l_bflow_method_code = 'PRIOR_ENTRY')
184537 )
184538 THEN
184539 IF
184540 --
184541 1 = 2
184542 --
184543 THEN
184544 xla_accounting_err_pkg.build_message
184545 (p_appli_s_name => 'XLA'
184546 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
184547 ,p_token_1 => 'LINE_NUMBER'
184548 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
184549 ,p_token_2 => 'LINE_TYPE_NAME'
184550 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
184551 l_component_type
184552 ,l_component_code
184553 ,l_component_type_code
184554 ,l_component_appl_id
184555 ,l_amb_context_code
184556 ,l_entity_code
184557 ,l_event_class_code
184558 )
184559 ,p_token_3 => 'OWNER'
184560 ,p_value_3 => xla_lookups_pkg.get_meaning(
184561 p_lookup_type => 'XLA_OWNER_TYPE'
184562 ,p_lookup_code => l_component_type_code
184563 )
184564 ,p_token_4 => 'PRODUCT_NAME'
184565 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
184566 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
184567 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
184568 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
184569 ,p_ae_header_id => NULL
184570 );
184571
184572 IF (C_LEVEL_ERROR>= g_log_level) THEN
184573 trace
184574 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
184575 ,p_level => C_LEVEL_ERROR
184576 ,p_module => l_log_module);
184577 END IF;
184578 END IF;
184579 END IF;
184580 --
184581 --
184582 ------------------------------------------------------------------------------------------------
184583 -- 4219869 Business Flow
184584 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
184585 -- Prior Entry. Currently, the following code is always generated.
184586 ------------------------------------------------------------------------------------------------
184587 XLA_AE_LINES_PKG.ValidateCurrentLine;
184588
184589 ------------------------------------------------------------------------------------
184590 -- 4219869 Business Flow
184591 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
184592 ------------------------------------------------------------------------------------
184593 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
184594
184595 ----------------------------------------------------------------------------------
184596 -- 4219869 Business Flow
184597 -- Update journal entry status -- Need to generate this within IF <condition>
184598 ----------------------------------------------------------------------------------
184599 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
184600 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
184601 ,p_balance_type_code => l_balance_type_code
184602 );
184603
184604 -------------------------------------------------------------------------------------------
184605 -- 4262811 - Generate the Accrual Reversal lines
184606 -------------------------------------------------------------------------------------------
184607 BEGIN
184608 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
184609 (g_array_event(p_event_id).array_value_num('header_index'));
184610 IF l_acc_rev_flag IS NULL THEN
184611 l_acc_rev_flag := 'N';
184612 END IF;
184613 EXCEPTION
184614 WHEN OTHERS THEN
184615 l_acc_rev_flag := 'N';
184616 END;
184617 --
184618 IF (l_acc_rev_flag = 'Y') THEN
184619
184620 -- 4645092 ------------------------------------------------------------------------------
184621 -- To allow MPA report to determine if it should generate report process
184622 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
184623 ------------------------------------------------------------------------------------------
184624
184625 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
184626 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
184627 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
184628 -- call ADRs
184629 -- Bug 4922099
184630 --
184631 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
184632 (NVL(l_actual_upg_option, 'N') = 'O') OR
184633 (NVL(l_enc_upg_option, 'N') = 'O')
184634 )
184635 THEN
184636 NULL;
184637 --
184638 --
184639
184640 l_ccid := AcctDerRule_6(
184641 p_application_id => p_application_id
184642 , p_ae_header_id => l_ae_header_id
184643 , p_source_11 => p_source_11
184644 , x_transaction_coa_id => l_adr_transaction_coa_id
184645 , x_accounting_coa_id => l_adr_accounting_coa_id
184646 , x_value_type_code => l_adr_value_type_code
184647 , p_side => 'NA'
184648 );
184649
184650 xla_ae_lines_pkg.set_ccid(
184651 p_code_combination_id => l_ccid
184652 , p_value_type_code => l_adr_value_type_code
184653 , p_transaction_coa_id => l_adr_transaction_coa_id
184654 , p_accounting_coa_id => l_adr_accounting_coa_id
184655 , p_adr_code => 'CST_DEFAULT'
184656 , p_adr_type_code => 'S'
184657 , p_component_type => l_component_type
184658 , p_component_code => l_component_code
184659 , p_component_type_code => l_component_type_code
184660 , p_component_appl_id => l_component_appl_id
184661 , p_amb_context_code => l_amb_context_code
184662 , p_side => 'NA'
184663 );
184664
184665
184666 --
184667 --
184668 END IF;
184669
184670 --
184671 -- Update the line information that should be overwritten
184672 --
184673 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
184674 p_header_num => 1);
184675 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
184676
184677 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
184678
184679 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
184680 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
184681 END IF;
184682
184683 --
184684 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
184685 --
184686 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
184687 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
184688 ELSE
184689 ---------------------------------------------------------------------------------------------------
184690 -- 4262811a Switch Sign
184691 ---------------------------------------------------------------------------------------------------
184692 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
184693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
184694 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184695 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
184696 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184697 -- 5132302
184698 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
184699 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
184700
184701 END IF;
184702
184703 -- 4955764
184704 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
184705 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
184706
184707
184708 XLA_AE_LINES_PKG.ValidateCurrentLine;
184709 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
184710
184711 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
184712 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
184713 ,p_balance_type_code => l_balance_type_code);
184714
184715 END IF;
184716
184717 -----------------------------------------------------------------------------------------
184718 -- 4262811 Multiperiod Accounting
184719 -----------------------------------------------------------------------------------------
184720 -- No MPA option is assigned.
184721
184722
184723 END IF;
184724 END IF;
184725 --
184726
184727 --
184728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
184729 trace
184730 (p_msg => 'END of AcctLineType_339'
184731 ,p_level => C_LEVEL_PROCEDURE
184732 ,p_module => l_log_module);
184733 END IF;
184734 --
184735 EXCEPTION
184736 WHEN xla_exceptions_pkg.application_exception THEN
184737 RAISE;
184738 WHEN OTHERS THEN
184739 xla_exceptions_pkg.raise_message
184740 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_339');
184741 END AcctLineType_339;
184742 --
184743
184744 ---------------------------------------
184745 --
184746 -- PRIVATE FUNCTION
184747 -- AcctLineType_340
184748 --
184749 ---------------------------------------
184750 PROCEDURE AcctLineType_340 (
184751 p_application_id IN NUMBER
184752 ,p_event_id IN NUMBER
184753 ,p_calculate_acctd_flag IN VARCHAR2
184754 ,p_calculate_g_l_flag IN VARCHAR2
184755 ,p_actual_flag IN OUT VARCHAR2
184756 ,p_balance_type_code OUT VARCHAR2
184757 ,p_gain_or_loss_ref OUT VARCHAR2
184758
184759 --TRANSACTION_ID
184760 , p_source_1 IN NUMBER
184761 --Item Concatenated Segments
184762 , p_source_2 IN VARCHAR2
184763 --Transaction Quantity
184764 , p_source_3 IN NUMBER
184765 --Transaction Unit of Measure Code
184766 , p_source_4 IN VARCHAR2
184767 --Inventory Transaction Type Description
184768 , p_source_5 IN VARCHAR2
184769 --Product Line Accounting Category Expense Account
184770 , p_source_24 IN NUMBER
184771 --Applied to Application ID
184772 , p_source_79 IN NUMBER
184773 --Applied to Distribution Link Type
184774 , p_source_80 IN VARCHAR2
184775 --Applied to Entity Code
184776 , p_source_81 IN VARCHAR2
184777 --DISTRIBUTION_IDENTIFIER
184778 , p_source_84 IN NUMBER
184779 --Distribution Type
184780 , p_source_85 IN VARCHAR2
184781 , p_source_85_meaning IN VARCHAR2
184782 --Encumbrance Reversal Amount Entered
184783 , p_source_87 IN NUMBER
184784 --Entered Currency Code
184785 , p_source_88 IN VARCHAR2
184786 --Transaction Encumbrance Reversal Amount
184787 , p_source_89 IN NUMBER
184788 --Entered Amount
184789 , p_source_91 IN NUMBER
184790 --Currency Conversion Date
184791 , p_source_92 IN DATE
184792 --Currency Conversion Rate
184793 , p_source_93 IN NUMBER
184794 --Currency Conversion Type
184795 , p_source_94 IN VARCHAR2
184796 --Accounted Amount
184797 , p_source_95 IN NUMBER
184798 --Accounting Line Type
184799 , p_source_97 IN NUMBER
184800 --Costing Encumbrance Upgrade Option
184801 , p_source_100 IN VARCHAR2
184802 --TXN_PO_DISTRIBUTION_ID
184803 , p_source_101 IN NUMBER
184804 --TXN_PO_HEADER_ID
184805 , p_source_102 IN NUMBER
184806 --Requisition Budget Account
184807 , p_source_103 IN NUMBER
184808 --Requisition Encumbrance Type Identifier
184809 , p_source_104 IN NUMBER
184810 )
184811 IS
184812
184813 l_component_type VARCHAR2(80);
184814 l_component_code VARCHAR2(30);
184815 l_component_type_code VARCHAR2(1);
184816 l_component_appl_id INTEGER;
184817 l_amb_context_code VARCHAR2(30);
184818 l_entity_code VARCHAR2(30);
184819 l_event_class_code VARCHAR2(30);
184820 l_ae_header_id NUMBER;
184821 l_event_type_code VARCHAR2(30);
184822 l_line_definition_code VARCHAR2(30);
184823 l_line_definition_owner_code VARCHAR2(1);
184824 --
184825 -- adr variables
184826 l_segment VARCHAR2(30);
184827 l_ccid NUMBER;
184828 l_adr_transaction_coa_id NUMBER;
184829 l_adr_accounting_coa_id NUMBER;
184830 l_adr_flexfield_segment_code VARCHAR2(30);
184831 l_adr_flex_value_set_id NUMBER;
184832 l_adr_value_type_code VARCHAR2(30);
184833 l_adr_value_combination_id NUMBER;
184834 l_adr_value_segment_code VARCHAR2(30);
184835
184836 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
184837 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
184838 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
184839 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
184840
184841 -- 4262811 Variables ------------------------------------------------------------------------------------------
184842 l_entered_amt_idx NUMBER;
184843 l_accted_amt_idx NUMBER;
184844 l_acc_rev_flag VARCHAR2(1);
184845 l_accrual_line_num NUMBER;
184846 l_tmp_amt NUMBER;
184847 l_acc_rev_natural_side_code VARCHAR2(1);
184848
184849 l_num_entries NUMBER;
184850 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
184851 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
184852 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
184853 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
184854 l_recog_line_1 NUMBER;
184855 l_recog_line_2 NUMBER;
184856
184857 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
184858 l_bflow_applied_to_amt NUMBER; -- 5132302
184859 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
184860
184861 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
184862
184863 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
184864 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
184865
184866 ---------------------------------------------------------------------------------------------------------------
184867
184868
184869 --
184870 -- bulk performance
184871 --
184872 l_balance_type_code VARCHAR2(1);
184873 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
184874 l_log_module VARCHAR2(240);
184875
184876 --
184877 -- Upgrade strategy
184878 --
184879 l_actual_upg_option VARCHAR2(1);
184880 l_enc_upg_option VARCHAR2(1);
184881
184882 --
184883 BEGIN
184884 --
184885 IF g_log_enabled THEN
184886 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_340';
184887 END IF;
184888 --
184889 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
184890
184891 trace
184892 (p_msg => 'BEGIN of AcctLineType_340'
184893 ,p_level => C_LEVEL_PROCEDURE
184894 ,p_module => l_log_module);
184895
184896 END IF;
184897 --
184898 l_component_type := 'AMB_JLT';
184899 l_component_code := 'OFFSET';
184900 l_component_type_code := 'S';
184901 l_component_appl_id := 707;
184902 l_amb_context_code := 'DEFAULT';
184903 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
184904 l_event_class_code := 'DIR_INTERORG_RCPT';
184905 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
184906 l_line_definition_owner_code := 'S';
184907 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
184908 --
184909 l_balance_type_code := 'A';
184910 l_segment := NULL;
184911 l_ccid := NULL;
184912 l_adr_transaction_coa_id := NULL;
184913 l_adr_accounting_coa_id := NULL;
184914 l_adr_flexfield_segment_code := NULL;
184915 l_adr_flex_value_set_id := NULL;
184916 l_adr_value_type_code := NULL;
184917 l_adr_value_combination_id := NULL;
184918 l_adr_value_segment_code := NULL;
184919
184920 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
184921 l_bflow_class_code := ''; -- 4219869 Business Flow
184922 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
184923 l_budgetary_control_flag := 'N';
184924
184925 l_bflow_applied_to_amt_idx := NULL; -- 5132302
184926 l_bflow_applied_to_amt := NULL; -- 5132302
184927 l_entered_amt_idx := NULL; -- 4262811
184928 l_accted_amt_idx := NULL; -- 4262811
184929 l_acc_rev_flag := NULL; -- 4262811
184930 l_accrual_line_num := NULL; -- 4262811
184931 l_tmp_amt := NULL; -- 4262811
184932 --
184933
184934 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
184935 l_balance_type_code <> 'B' THEN
184936 IF NVL(p_source_97,9E125) = 2
184937 THEN
184938
184939 --
184940 XLA_AE_LINES_PKG.SetNewLine;
184941
184942 p_balance_type_code := l_balance_type_code;
184943 -- set the flag so later we will know whether the gain loss line needs to be created
184944
184945 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
184946 p_actual_flag :='A';
184947 END IF;
184948
184949 --
184950 -- bulk performance
184951 --
184952 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
184953 p_header_num => 0); -- 4262811
184954 --
184955 -- set accounting line options
184956 --
184957 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
184958 p_natural_side_code => 'D'
184959 , p_gain_or_loss_flag => 'N'
184960 , p_gl_transfer_mode_code => 'S'
184961 , p_acct_entry_type_code => 'A'
184962 , p_switch_side_flag => 'Y'
184963 , p_merge_duplicate_code => 'N'
184964 );
184965 --
184966 l_acc_rev_natural_side_code := 'C'; -- 4262811
184967 --
184968 --
184969 -- set accounting line type info
184970 --
184971 xla_ae_lines_pkg.SetAcctLineType
184972 (p_component_type => l_component_type
184973 ,p_event_type_code => l_event_type_code
184974 ,p_line_definition_owner_code => l_line_definition_owner_code
184975 ,p_line_definition_code => l_line_definition_code
184976 ,p_accounting_line_code => l_component_code
184977 ,p_accounting_line_type_code => l_component_type_code
184978 ,p_accounting_line_appl_id => l_component_appl_id
184979 ,p_amb_context_code => l_amb_context_code
184980 ,p_entity_code => l_entity_code
184981 ,p_event_class_code => l_event_class_code);
184982 --
184983 -- set accounting class
184984 --
184985 xla_ae_lines_pkg.SetAcctClass(
184986 p_accounting_class_code => 'OFFSET'
184987 , p_ae_header_id => l_ae_header_id
184988 );
184989
184990 --
184991 -- set rounding class
184992 --
184993 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
184994 'OFFSET';
184995
184996 --
184997 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
184998 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
184999 --
185000 -- bulk performance
185001 --
185002 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
185003
185004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
185005 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
185006
185007 -- 4955764
185008 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
185009 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
185010
185011 -- 4458381 Public Sector Enh
185012
185013 --
185014 -- set accounting attributes for the line type
185015 --
185016 l_entered_amt_idx := 17;
185017 l_accted_amt_idx := 22;
185018 l_bflow_applied_to_amt_idx := NULL; -- 5132302
185019 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
185020 l_rec_acct_attrs.array_num_value(1) := p_source_79;
185021 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
185022 l_rec_acct_attrs.array_char_value(2) := p_source_80;
185023 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
185024 l_rec_acct_attrs.array_char_value(3) := p_source_81;
185025 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
185026 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
185027 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
185028 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
185029 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
185030 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
185031 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
185032 l_rec_acct_attrs.array_char_value(7) := p_source_85;
185033 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
185034 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
185035 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
185036 l_rec_acct_attrs.array_num_value(9) := p_source_87;
185037 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
185038 l_rec_acct_attrs.array_char_value(10) := p_source_88;
185039 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
185040 l_rec_acct_attrs.array_num_value(11) := p_source_89;
185041 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
185042 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
185043 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
185044 l_rec_acct_attrs.array_num_value(13) := p_source_87;
185045 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
185046 l_rec_acct_attrs.array_char_value(14) := p_source_88;
185047 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
185048 l_rec_acct_attrs.array_num_value(15) := p_source_89;
185049 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
185050 l_rec_acct_attrs.array_char_value(16) := p_source_100;
185051 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
185052 l_rec_acct_attrs.array_num_value(17) := p_source_91;
185053 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
185054 l_rec_acct_attrs.array_char_value(18) := p_source_88;
185055 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
185056 l_rec_acct_attrs.array_date_value(19) := p_source_92;
185057 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
185058 l_rec_acct_attrs.array_num_value(20) := p_source_93;
185059 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
185060 l_rec_acct_attrs.array_char_value(21) := p_source_94;
185061 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
185062 l_rec_acct_attrs.array_num_value(22) := p_source_95;
185063 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
185064 l_rec_acct_attrs.array_num_value(23) := p_source_104;
185065 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
185066 l_rec_acct_attrs.array_num_value(24) := p_source_104;
185067
185068 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
185069 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
185070
185071 ---------------------------------------------------------------------------------------------------------------
185072 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
185073 ---------------------------------------------------------------------------------------------------------------
185074 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
185075
185076 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
185077 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
185078
185079 IF xla_accounting_cache_pkg.GetValueChar
185080 (p_source_code => 'LEDGER_CATEGORY_CODE'
185081 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
185082 AND l_bflow_method_code = 'PRIOR_ENTRY'
185083 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
185084 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
185085 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
185086 )
185087 THEN
185088 xla_ae_lines_pkg.BflowUpgEntry
185089 (p_business_method_code => l_bflow_method_code
185090 ,p_business_class_code => l_bflow_class_code
185091 ,p_balance_type => l_balance_type_code);
185092 ELSE
185093 NULL;
185094 -- No business flow processing for business flow method of NONE.
185095 END IF;
185096
185097 --
185098 -- call analytical criteria
185099 --
185100
185101 --
185102 -- call description
185103 --
185104
185105 xla_ae_lines_pkg.SetLineDescription(
185106 p_ae_header_id => l_ae_header_id
185107 ,p_description => Description_1 (
185108 p_application_id => p_application_id
185109 , p_ae_header_id => l_ae_header_id
185110 , p_source_1 => p_source_1
185111 , p_source_2 => p_source_2
185112 , p_source_3 => p_source_3
185113 , p_source_4 => p_source_4
185114 , p_source_5 => p_source_5
185115 )
185116 );
185117
185118
185119 --
185120 -- call ADRs
185121 -- Bug 4922099
185122 --
185123 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
185124 (NVL(l_actual_upg_option, 'N') = 'O') OR
185125 (NVL(l_enc_upg_option, 'N') = 'O')
185126 )
185127 THEN
185128 NULL;
185129 --
185130 --
185131
185132 l_ccid := AcctDerRule_13(
185133 p_application_id => p_application_id
185134 , p_ae_header_id => l_ae_header_id
185135 , p_source_24 => p_source_24
185136 , x_transaction_coa_id => l_adr_transaction_coa_id
185137 , x_accounting_coa_id => l_adr_accounting_coa_id
185138 , x_value_type_code => l_adr_value_type_code
185139 , p_side => 'NA'
185140 );
185141
185142 xla_ae_lines_pkg.set_ccid(
185143 p_code_combination_id => l_ccid
185144 , p_value_type_code => l_adr_value_type_code
185145 , p_transaction_coa_id => l_adr_transaction_coa_id
185146 , p_accounting_coa_id => l_adr_accounting_coa_id
185147 , p_adr_code => 'PI_CATEGORY_EXPENSE'
185148 , p_adr_type_code => 'S'
185149 , p_component_type => l_component_type
185150 , p_component_code => l_component_code
185151 , p_component_type_code => l_component_type_code
185152 , p_component_appl_id => l_component_appl_id
185153 , p_amb_context_code => l_amb_context_code
185154 , p_side => 'NA'
185155 );
185156
185157
185158 --
185159 --
185160 END IF;
185161 --
185162 -- Bug 4922099
185163 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
185164 (NVL(l_enc_upg_option, 'N') = 'O')
185165 ) AND
185166 (l_bflow_method_code = 'PRIOR_ENTRY')
185167 )
185168 THEN
185169 IF
185170 --
185171 1 = 2
185172 --
185173 THEN
185174 xla_accounting_err_pkg.build_message
185175 (p_appli_s_name => 'XLA'
185176 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
185177 ,p_token_1 => 'LINE_NUMBER'
185178 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
185179 ,p_token_2 => 'LINE_TYPE_NAME'
185180 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
185181 l_component_type
185182 ,l_component_code
185183 ,l_component_type_code
185184 ,l_component_appl_id
185185 ,l_amb_context_code
185186 ,l_entity_code
185187 ,l_event_class_code
185188 )
185189 ,p_token_3 => 'OWNER'
185190 ,p_value_3 => xla_lookups_pkg.get_meaning(
185191 p_lookup_type => 'XLA_OWNER_TYPE'
185192 ,p_lookup_code => l_component_type_code
185193 )
185194 ,p_token_4 => 'PRODUCT_NAME'
185195 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
185196 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
185197 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
185198 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
185199 ,p_ae_header_id => NULL
185200 );
185201
185202 IF (C_LEVEL_ERROR>= g_log_level) THEN
185203 trace
185204 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
185205 ,p_level => C_LEVEL_ERROR
185206 ,p_module => l_log_module);
185207 END IF;
185208 END IF;
185209 END IF;
185210 --
185211 --
185212 ------------------------------------------------------------------------------------------------
185213 -- 4219869 Business Flow
185214 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
185215 -- Prior Entry. Currently, the following code is always generated.
185216 ------------------------------------------------------------------------------------------------
185217 XLA_AE_LINES_PKG.ValidateCurrentLine;
185218
185219 ------------------------------------------------------------------------------------
185220 -- 4219869 Business Flow
185221 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
185222 ------------------------------------------------------------------------------------
185223 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
185224
185225 ----------------------------------------------------------------------------------
185226 -- 4219869 Business Flow
185227 -- Update journal entry status -- Need to generate this within IF <condition>
185228 ----------------------------------------------------------------------------------
185229 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
185230 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
185231 ,p_balance_type_code => l_balance_type_code
185232 );
185233
185234 -------------------------------------------------------------------------------------------
185235 -- 4262811 - Generate the Accrual Reversal lines
185236 -------------------------------------------------------------------------------------------
185237 BEGIN
185238 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
185239 (g_array_event(p_event_id).array_value_num('header_index'));
185240 IF l_acc_rev_flag IS NULL THEN
185241 l_acc_rev_flag := 'N';
185242 END IF;
185243 EXCEPTION
185244 WHEN OTHERS THEN
185245 l_acc_rev_flag := 'N';
185246 END;
185247 --
185248 IF (l_acc_rev_flag = 'Y') THEN
185249
185250 -- 4645092 ------------------------------------------------------------------------------
185251 -- To allow MPA report to determine if it should generate report process
185252 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
185253 ------------------------------------------------------------------------------------------
185254
185255 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
185256 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
185257 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
185258 -- call ADRs
185259 -- Bug 4922099
185260 --
185261 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
185262 (NVL(l_actual_upg_option, 'N') = 'O') OR
185263 (NVL(l_enc_upg_option, 'N') = 'O')
185264 )
185265 THEN
185266 NULL;
185267 --
185268 --
185269
185270 l_ccid := AcctDerRule_13(
185271 p_application_id => p_application_id
185272 , p_ae_header_id => l_ae_header_id
185273 , p_source_24 => p_source_24
185274 , x_transaction_coa_id => l_adr_transaction_coa_id
185275 , x_accounting_coa_id => l_adr_accounting_coa_id
185276 , x_value_type_code => l_adr_value_type_code
185277 , p_side => 'NA'
185278 );
185279
185280 xla_ae_lines_pkg.set_ccid(
185281 p_code_combination_id => l_ccid
185282 , p_value_type_code => l_adr_value_type_code
185283 , p_transaction_coa_id => l_adr_transaction_coa_id
185284 , p_accounting_coa_id => l_adr_accounting_coa_id
185285 , p_adr_code => 'PI_CATEGORY_EXPENSE'
185286 , p_adr_type_code => 'S'
185287 , p_component_type => l_component_type
185288 , p_component_code => l_component_code
185289 , p_component_type_code => l_component_type_code
185290 , p_component_appl_id => l_component_appl_id
185291 , p_amb_context_code => l_amb_context_code
185292 , p_side => 'NA'
185293 );
185294
185295
185296 --
185297 --
185298 END IF;
185299
185300 --
185301 -- Update the line information that should be overwritten
185302 --
185303 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
185304 p_header_num => 1);
185305 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
185306
185307 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
185308
185309 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
185310 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
185311 END IF;
185312
185313 --
185314 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
185315 --
185316 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
185317 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
185318 ELSE
185319 ---------------------------------------------------------------------------------------------------
185320 -- 4262811a Switch Sign
185321 ---------------------------------------------------------------------------------------------------
185322 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
185323 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
185324 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185325 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
185326 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185327 -- 5132302
185328 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
185329 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185330
185331 END IF;
185332
185333 -- 4955764
185334 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
185335 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
185336
185337
185338 XLA_AE_LINES_PKG.ValidateCurrentLine;
185339 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
185340
185341 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
185342 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
185343 ,p_balance_type_code => l_balance_type_code);
185344
185345 END IF;
185346
185347 -----------------------------------------------------------------------------------------
185348 -- 4262811 Multiperiod Accounting
185349 -----------------------------------------------------------------------------------------
185350 -- No MPA option is assigned.
185351
185352
185353 END IF;
185354 END IF;
185355 --
185356
185357 --
185358 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
185359 trace
185360 (p_msg => 'END of AcctLineType_340'
185361 ,p_level => C_LEVEL_PROCEDURE
185362 ,p_module => l_log_module);
185363 END IF;
185364 --
185365 EXCEPTION
185366 WHEN xla_exceptions_pkg.application_exception THEN
185367 RAISE;
185368 WHEN OTHERS THEN
185369 xla_exceptions_pkg.raise_message
185370 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_340');
185371 END AcctLineType_340;
185372 --
185373
185374 ---------------------------------------
185375 --
185376 -- PRIVATE FUNCTION
185377 -- AcctLineType_341
185378 --
185379 ---------------------------------------
185380 PROCEDURE AcctLineType_341 (
185381 p_application_id IN NUMBER
185382 ,p_event_id IN NUMBER
185383 ,p_calculate_acctd_flag IN VARCHAR2
185384 ,p_calculate_g_l_flag IN VARCHAR2
185385 ,p_actual_flag IN OUT VARCHAR2
185386 ,p_balance_type_code OUT VARCHAR2
185387 ,p_gain_or_loss_ref OUT VARCHAR2
185388
185389 --TRANSACTION_ID
185390 , p_source_1 IN NUMBER
185391 --Item Concatenated Segments
185392 , p_source_2 IN VARCHAR2
185393 --Transaction Quantity
185394 , p_source_3 IN NUMBER
185395 --Transaction Unit of Measure Code
185396 , p_source_4 IN VARCHAR2
185397 --Inventory Transaction Type Description
185398 , p_source_5 IN VARCHAR2
185399 --Cost Management Default Account
185400 , p_source_11 IN NUMBER
185401 --Applied to Application ID
185402 , p_source_79 IN NUMBER
185403 --Applied to Distribution Link Type
185404 , p_source_80 IN VARCHAR2
185405 --Applied to Entity Code
185406 , p_source_81 IN VARCHAR2
185407 --DISTRIBUTION_IDENTIFIER
185408 , p_source_84 IN NUMBER
185409 --Distribution Type
185410 , p_source_85 IN VARCHAR2
185411 , p_source_85_meaning IN VARCHAR2
185412 --Encumbrance Reversal Amount Entered
185413 , p_source_87 IN NUMBER
185414 --Entered Currency Code
185415 , p_source_88 IN VARCHAR2
185416 --Transaction Encumbrance Reversal Amount
185417 , p_source_89 IN NUMBER
185418 --Entered Amount
185419 , p_source_91 IN NUMBER
185420 --Currency Conversion Date
185421 , p_source_92 IN DATE
185422 --Currency Conversion Rate
185423 , p_source_93 IN NUMBER
185424 --Currency Conversion Type
185425 , p_source_94 IN VARCHAR2
185426 --Accounted Amount
185427 , p_source_95 IN NUMBER
185428 --Accounting Line Type
185429 , p_source_97 IN NUMBER
185430 --Costing Encumbrance Upgrade Option
185431 , p_source_100 IN VARCHAR2
185432 --TXN_PO_DISTRIBUTION_ID
185433 , p_source_101 IN NUMBER
185434 --TXN_PO_HEADER_ID
185435 , p_source_102 IN NUMBER
185436 --Requisition Budget Account
185437 , p_source_103 IN NUMBER
185438 --Requisition Encumbrance Type Identifier
185439 , p_source_104 IN NUMBER
185440 )
185441 IS
185442
185443 l_component_type VARCHAR2(80);
185444 l_component_code VARCHAR2(30);
185445 l_component_type_code VARCHAR2(1);
185446 l_component_appl_id INTEGER;
185447 l_amb_context_code VARCHAR2(30);
185448 l_entity_code VARCHAR2(30);
185449 l_event_class_code VARCHAR2(30);
185450 l_ae_header_id NUMBER;
185451 l_event_type_code VARCHAR2(30);
185452 l_line_definition_code VARCHAR2(30);
185453 l_line_definition_owner_code VARCHAR2(1);
185454 --
185455 -- adr variables
185456 l_segment VARCHAR2(30);
185457 l_ccid NUMBER;
185458 l_adr_transaction_coa_id NUMBER;
185459 l_adr_accounting_coa_id NUMBER;
185460 l_adr_flexfield_segment_code VARCHAR2(30);
185461 l_adr_flex_value_set_id NUMBER;
185462 l_adr_value_type_code VARCHAR2(30);
185463 l_adr_value_combination_id NUMBER;
185464 l_adr_value_segment_code VARCHAR2(30);
185465
185466 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
185467 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
185468 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
185469 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
185470
185471 -- 4262811 Variables ------------------------------------------------------------------------------------------
185472 l_entered_amt_idx NUMBER;
185473 l_accted_amt_idx NUMBER;
185474 l_acc_rev_flag VARCHAR2(1);
185475 l_accrual_line_num NUMBER;
185476 l_tmp_amt NUMBER;
185477 l_acc_rev_natural_side_code VARCHAR2(1);
185478
185479 l_num_entries NUMBER;
185480 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
185481 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
185482 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
185483 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
185484 l_recog_line_1 NUMBER;
185485 l_recog_line_2 NUMBER;
185486
185487 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
185488 l_bflow_applied_to_amt NUMBER; -- 5132302
185489 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
185490
185491 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
185492
185493 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
185494 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
185495
185496 ---------------------------------------------------------------------------------------------------------------
185497
185498
185499 --
185500 -- bulk performance
185501 --
185502 l_balance_type_code VARCHAR2(1);
185503 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
185504 l_log_module VARCHAR2(240);
185505
185506 --
185507 -- Upgrade strategy
185508 --
185509 l_actual_upg_option VARCHAR2(1);
185510 l_enc_upg_option VARCHAR2(1);
185511
185512 --
185513 BEGIN
185514 --
185515 IF g_log_enabled THEN
185516 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_341';
185517 END IF;
185518 --
185519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
185520
185521 trace
185522 (p_msg => 'BEGIN of AcctLineType_341'
185523 ,p_level => C_LEVEL_PROCEDURE
185524 ,p_module => l_log_module);
185525
185526 END IF;
185527 --
185528 l_component_type := 'AMB_JLT';
185529 l_component_code := 'OFFSET';
185530 l_component_type_code := 'S';
185531 l_component_appl_id := 707;
185532 l_amb_context_code := 'DEFAULT';
185533 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
185534 l_event_class_code := 'FOB_SHIP_RECIPIENT_RCPT';
185535 l_event_type_code := 'FOB_SHIP_RECIPIENT_RCPT';
185536 l_line_definition_owner_code := 'S';
185537 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_RCPT';
185538 --
185539 l_balance_type_code := 'A';
185540 l_segment := NULL;
185541 l_ccid := NULL;
185542 l_adr_transaction_coa_id := NULL;
185543 l_adr_accounting_coa_id := NULL;
185544 l_adr_flexfield_segment_code := NULL;
185545 l_adr_flex_value_set_id := NULL;
185546 l_adr_value_type_code := NULL;
185547 l_adr_value_combination_id := NULL;
185548 l_adr_value_segment_code := NULL;
185549
185550 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
185551 l_bflow_class_code := ''; -- 4219869 Business Flow
185552 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
185553 l_budgetary_control_flag := 'N';
185554
185555 l_bflow_applied_to_amt_idx := NULL; -- 5132302
185556 l_bflow_applied_to_amt := NULL; -- 5132302
185557 l_entered_amt_idx := NULL; -- 4262811
185558 l_accted_amt_idx := NULL; -- 4262811
185559 l_acc_rev_flag := NULL; -- 4262811
185560 l_accrual_line_num := NULL; -- 4262811
185561 l_tmp_amt := NULL; -- 4262811
185562 --
185563
185564 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
185565 l_balance_type_code <> 'B' THEN
185566 IF NVL(p_source_97,9E125) = 2
185567 THEN
185568
185569 --
185570 XLA_AE_LINES_PKG.SetNewLine;
185571
185572 p_balance_type_code := l_balance_type_code;
185573 -- set the flag so later we will know whether the gain loss line needs to be created
185574
185575 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
185576 p_actual_flag :='A';
185577 END IF;
185578
185579 --
185580 -- bulk performance
185581 --
185582 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
185583 p_header_num => 0); -- 4262811
185584 --
185585 -- set accounting line options
185586 --
185587 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
185588 p_natural_side_code => 'D'
185589 , p_gain_or_loss_flag => 'N'
185590 , p_gl_transfer_mode_code => 'S'
185591 , p_acct_entry_type_code => 'A'
185592 , p_switch_side_flag => 'Y'
185593 , p_merge_duplicate_code => 'N'
185594 );
185595 --
185596 l_acc_rev_natural_side_code := 'C'; -- 4262811
185597 --
185598 --
185599 -- set accounting line type info
185600 --
185601 xla_ae_lines_pkg.SetAcctLineType
185602 (p_component_type => l_component_type
185603 ,p_event_type_code => l_event_type_code
185604 ,p_line_definition_owner_code => l_line_definition_owner_code
185605 ,p_line_definition_code => l_line_definition_code
185606 ,p_accounting_line_code => l_component_code
185607 ,p_accounting_line_type_code => l_component_type_code
185608 ,p_accounting_line_appl_id => l_component_appl_id
185609 ,p_amb_context_code => l_amb_context_code
185610 ,p_entity_code => l_entity_code
185611 ,p_event_class_code => l_event_class_code);
185612 --
185613 -- set accounting class
185614 --
185615 xla_ae_lines_pkg.SetAcctClass(
185616 p_accounting_class_code => 'OFFSET'
185617 , p_ae_header_id => l_ae_header_id
185618 );
185619
185620 --
185621 -- set rounding class
185622 --
185623 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
185624 'OFFSET';
185625
185626 --
185627 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
185628 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
185629 --
185630 -- bulk performance
185631 --
185632 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
185633
185634 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
185635 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
185636
185637 -- 4955764
185638 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
185639 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
185640
185641 -- 4458381 Public Sector Enh
185642
185643 --
185644 -- set accounting attributes for the line type
185645 --
185646 l_entered_amt_idx := 17;
185647 l_accted_amt_idx := 22;
185648 l_bflow_applied_to_amt_idx := NULL; -- 5132302
185649 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
185650 l_rec_acct_attrs.array_num_value(1) := p_source_79;
185651 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
185652 l_rec_acct_attrs.array_char_value(2) := p_source_80;
185653 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
185654 l_rec_acct_attrs.array_char_value(3) := p_source_81;
185655 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
185656 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
185657 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
185658 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
185659 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
185660 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
185661 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
185662 l_rec_acct_attrs.array_char_value(7) := p_source_85;
185663 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
185664 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
185665 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
185666 l_rec_acct_attrs.array_num_value(9) := p_source_87;
185667 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
185668 l_rec_acct_attrs.array_char_value(10) := p_source_88;
185669 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
185670 l_rec_acct_attrs.array_num_value(11) := p_source_89;
185671 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
185672 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
185673 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
185674 l_rec_acct_attrs.array_num_value(13) := p_source_87;
185675 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
185676 l_rec_acct_attrs.array_char_value(14) := p_source_88;
185677 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
185678 l_rec_acct_attrs.array_num_value(15) := p_source_89;
185679 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
185680 l_rec_acct_attrs.array_char_value(16) := p_source_100;
185681 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
185682 l_rec_acct_attrs.array_num_value(17) := p_source_91;
185683 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
185684 l_rec_acct_attrs.array_char_value(18) := p_source_88;
185685 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
185686 l_rec_acct_attrs.array_date_value(19) := p_source_92;
185687 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
185688 l_rec_acct_attrs.array_num_value(20) := p_source_93;
185689 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
185690 l_rec_acct_attrs.array_char_value(21) := p_source_94;
185691 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
185692 l_rec_acct_attrs.array_num_value(22) := p_source_95;
185693 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
185694 l_rec_acct_attrs.array_num_value(23) := p_source_104;
185695 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
185696 l_rec_acct_attrs.array_num_value(24) := p_source_104;
185697
185698 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
185699 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
185700
185701 ---------------------------------------------------------------------------------------------------------------
185702 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
185703 ---------------------------------------------------------------------------------------------------------------
185704 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
185705
185706 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
185707 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
185708
185709 IF xla_accounting_cache_pkg.GetValueChar
185710 (p_source_code => 'LEDGER_CATEGORY_CODE'
185711 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
185712 AND l_bflow_method_code = 'PRIOR_ENTRY'
185713 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
185714 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
185715 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
185716 )
185717 THEN
185718 xla_ae_lines_pkg.BflowUpgEntry
185719 (p_business_method_code => l_bflow_method_code
185720 ,p_business_class_code => l_bflow_class_code
185721 ,p_balance_type => l_balance_type_code);
185722 ELSE
185723 NULL;
185724 -- No business flow processing for business flow method of NONE.
185725 END IF;
185726
185727 --
185728 -- call analytical criteria
185729 --
185730
185731 --
185732 -- call description
185733 --
185734
185735 xla_ae_lines_pkg.SetLineDescription(
185736 p_ae_header_id => l_ae_header_id
185737 ,p_description => Description_1 (
185738 p_application_id => p_application_id
185739 , p_ae_header_id => l_ae_header_id
185740 , p_source_1 => p_source_1
185741 , p_source_2 => p_source_2
185742 , p_source_3 => p_source_3
185743 , p_source_4 => p_source_4
185744 , p_source_5 => p_source_5
185745 )
185746 );
185747
185748
185749 --
185750 -- call ADRs
185751 -- Bug 4922099
185752 --
185753 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
185754 (NVL(l_actual_upg_option, 'N') = 'O') OR
185755 (NVL(l_enc_upg_option, 'N') = 'O')
185756 )
185757 THEN
185758 NULL;
185759 --
185760 --
185761
185762 l_ccid := AcctDerRule_6(
185763 p_application_id => p_application_id
185764 , p_ae_header_id => l_ae_header_id
185765 , p_source_11 => p_source_11
185766 , x_transaction_coa_id => l_adr_transaction_coa_id
185767 , x_accounting_coa_id => l_adr_accounting_coa_id
185768 , x_value_type_code => l_adr_value_type_code
185769 , p_side => 'NA'
185770 );
185771
185772 xla_ae_lines_pkg.set_ccid(
185773 p_code_combination_id => l_ccid
185774 , p_value_type_code => l_adr_value_type_code
185775 , p_transaction_coa_id => l_adr_transaction_coa_id
185776 , p_accounting_coa_id => l_adr_accounting_coa_id
185777 , p_adr_code => 'CST_DEFAULT'
185778 , p_adr_type_code => 'S'
185779 , p_component_type => l_component_type
185780 , p_component_code => l_component_code
185781 , p_component_type_code => l_component_type_code
185782 , p_component_appl_id => l_component_appl_id
185783 , p_amb_context_code => l_amb_context_code
185784 , p_side => 'NA'
185785 );
185786
185787
185788 --
185789 --
185790 END IF;
185791 --
185792 -- Bug 4922099
185793 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
185794 (NVL(l_enc_upg_option, 'N') = 'O')
185795 ) AND
185796 (l_bflow_method_code = 'PRIOR_ENTRY')
185797 )
185798 THEN
185799 IF
185800 --
185801 1 = 2
185802 --
185803 THEN
185804 xla_accounting_err_pkg.build_message
185805 (p_appli_s_name => 'XLA'
185806 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
185807 ,p_token_1 => 'LINE_NUMBER'
185808 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
185809 ,p_token_2 => 'LINE_TYPE_NAME'
185810 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
185811 l_component_type
185812 ,l_component_code
185813 ,l_component_type_code
185814 ,l_component_appl_id
185815 ,l_amb_context_code
185816 ,l_entity_code
185817 ,l_event_class_code
185818 )
185819 ,p_token_3 => 'OWNER'
185820 ,p_value_3 => xla_lookups_pkg.get_meaning(
185821 p_lookup_type => 'XLA_OWNER_TYPE'
185822 ,p_lookup_code => l_component_type_code
185823 )
185824 ,p_token_4 => 'PRODUCT_NAME'
185825 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
185826 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
185827 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
185828 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
185829 ,p_ae_header_id => NULL
185830 );
185831
185832 IF (C_LEVEL_ERROR>= g_log_level) THEN
185833 trace
185834 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
185835 ,p_level => C_LEVEL_ERROR
185836 ,p_module => l_log_module);
185837 END IF;
185838 END IF;
185839 END IF;
185840 --
185841 --
185842 ------------------------------------------------------------------------------------------------
185843 -- 4219869 Business Flow
185844 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
185845 -- Prior Entry. Currently, the following code is always generated.
185846 ------------------------------------------------------------------------------------------------
185847 XLA_AE_LINES_PKG.ValidateCurrentLine;
185848
185849 ------------------------------------------------------------------------------------
185850 -- 4219869 Business Flow
185851 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
185852 ------------------------------------------------------------------------------------
185853 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
185854
185855 ----------------------------------------------------------------------------------
185856 -- 4219869 Business Flow
185857 -- Update journal entry status -- Need to generate this within IF <condition>
185858 ----------------------------------------------------------------------------------
185859 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
185860 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
185861 ,p_balance_type_code => l_balance_type_code
185862 );
185863
185864 -------------------------------------------------------------------------------------------
185865 -- 4262811 - Generate the Accrual Reversal lines
185866 -------------------------------------------------------------------------------------------
185867 BEGIN
185868 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
185869 (g_array_event(p_event_id).array_value_num('header_index'));
185870 IF l_acc_rev_flag IS NULL THEN
185871 l_acc_rev_flag := 'N';
185872 END IF;
185873 EXCEPTION
185874 WHEN OTHERS THEN
185875 l_acc_rev_flag := 'N';
185876 END;
185877 --
185878 IF (l_acc_rev_flag = 'Y') THEN
185879
185880 -- 4645092 ------------------------------------------------------------------------------
185881 -- To allow MPA report to determine if it should generate report process
185882 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
185883 ------------------------------------------------------------------------------------------
185884
185885 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
185886 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
185887 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
185888 -- call ADRs
185889 -- Bug 4922099
185890 --
185891 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
185892 (NVL(l_actual_upg_option, 'N') = 'O') OR
185893 (NVL(l_enc_upg_option, 'N') = 'O')
185894 )
185895 THEN
185896 NULL;
185897 --
185898 --
185899
185900 l_ccid := AcctDerRule_6(
185901 p_application_id => p_application_id
185902 , p_ae_header_id => l_ae_header_id
185903 , p_source_11 => p_source_11
185904 , x_transaction_coa_id => l_adr_transaction_coa_id
185905 , x_accounting_coa_id => l_adr_accounting_coa_id
185906 , x_value_type_code => l_adr_value_type_code
185907 , p_side => 'NA'
185908 );
185909
185910 xla_ae_lines_pkg.set_ccid(
185911 p_code_combination_id => l_ccid
185912 , p_value_type_code => l_adr_value_type_code
185913 , p_transaction_coa_id => l_adr_transaction_coa_id
185914 , p_accounting_coa_id => l_adr_accounting_coa_id
185915 , p_adr_code => 'CST_DEFAULT'
185916 , p_adr_type_code => 'S'
185917 , p_component_type => l_component_type
185918 , p_component_code => l_component_code
185919 , p_component_type_code => l_component_type_code
185920 , p_component_appl_id => l_component_appl_id
185921 , p_amb_context_code => l_amb_context_code
185922 , p_side => 'NA'
185923 );
185924
185925
185926 --
185927 --
185928 END IF;
185929
185930 --
185931 -- Update the line information that should be overwritten
185932 --
185933 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
185934 p_header_num => 1);
185935 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
185936
185937 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
185938
185939 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
185940 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
185941 END IF;
185942
185943 --
185944 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
185945 --
185946 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
185947 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
185948 ELSE
185949 ---------------------------------------------------------------------------------------------------
185950 -- 4262811a Switch Sign
185951 ---------------------------------------------------------------------------------------------------
185952 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
185953 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
185954 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185955 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
185956 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185957 -- 5132302
185958 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
185959 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
185960
185961 END IF;
185962
185963 -- 4955764
185964 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
185965 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
185966
185967
185968 XLA_AE_LINES_PKG.ValidateCurrentLine;
185969 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
185970
185971 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
185972 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
185973 ,p_balance_type_code => l_balance_type_code);
185974
185975 END IF;
185976
185977 -----------------------------------------------------------------------------------------
185978 -- 4262811 Multiperiod Accounting
185979 -----------------------------------------------------------------------------------------
185980 -- No MPA option is assigned.
185981
185982
185983 END IF;
185984 END IF;
185985 --
185986
185987 --
185988 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
185989 trace
185990 (p_msg => 'END of AcctLineType_341'
185991 ,p_level => C_LEVEL_PROCEDURE
185992 ,p_module => l_log_module);
185993 END IF;
185994 --
185995 EXCEPTION
185996 WHEN xla_exceptions_pkg.application_exception THEN
185997 RAISE;
185998 WHEN OTHERS THEN
185999 xla_exceptions_pkg.raise_message
186000 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_341');
186001 END AcctLineType_341;
186002 --
186003
186004 ---------------------------------------
186005 --
186006 -- PRIVATE FUNCTION
186007 -- AcctLineType_342
186008 --
186009 ---------------------------------------
186010 PROCEDURE AcctLineType_342 (
186011 p_application_id IN NUMBER
186012 ,p_event_id IN NUMBER
186013 ,p_calculate_acctd_flag IN VARCHAR2
186014 ,p_calculate_g_l_flag IN VARCHAR2
186015 ,p_actual_flag IN OUT VARCHAR2
186016 ,p_balance_type_code OUT VARCHAR2
186017 ,p_gain_or_loss_ref OUT VARCHAR2
186018
186019 --TRANSACTION_ID
186020 , p_source_1 IN NUMBER
186021 --Item Concatenated Segments
186022 , p_source_2 IN VARCHAR2
186023 --Transaction Quantity
186024 , p_source_3 IN NUMBER
186025 --Transaction Unit of Measure Code
186026 , p_source_4 IN VARCHAR2
186027 --Inventory Transaction Type Description
186028 , p_source_5 IN VARCHAR2
186029 --Cost Management Default Account
186030 , p_source_11 IN NUMBER
186031 --DISTRIBUTION_IDENTIFIER
186032 , p_source_84 IN NUMBER
186033 --Distribution Type
186034 , p_source_85 IN VARCHAR2
186035 , p_source_85_meaning IN VARCHAR2
186036 --Entered Currency Code
186037 , p_source_88 IN VARCHAR2
186038 --Entered Amount
186039 , p_source_91 IN NUMBER
186040 --Currency Conversion Date
186041 , p_source_92 IN DATE
186042 --Currency Conversion Rate
186043 , p_source_93 IN NUMBER
186044 --Currency Conversion Type
186045 , p_source_94 IN VARCHAR2
186046 --Accounted Amount
186047 , p_source_95 IN NUMBER
186048 --Accounting Line Type
186049 , p_source_97 IN NUMBER
186050 )
186051 IS
186052
186053 l_component_type VARCHAR2(80);
186054 l_component_code VARCHAR2(30);
186055 l_component_type_code VARCHAR2(1);
186056 l_component_appl_id INTEGER;
186057 l_amb_context_code VARCHAR2(30);
186058 l_entity_code VARCHAR2(30);
186059 l_event_class_code VARCHAR2(30);
186060 l_ae_header_id NUMBER;
186061 l_event_type_code VARCHAR2(30);
186062 l_line_definition_code VARCHAR2(30);
186063 l_line_definition_owner_code VARCHAR2(1);
186064 --
186065 -- adr variables
186066 l_segment VARCHAR2(30);
186067 l_ccid NUMBER;
186068 l_adr_transaction_coa_id NUMBER;
186069 l_adr_accounting_coa_id NUMBER;
186070 l_adr_flexfield_segment_code VARCHAR2(30);
186071 l_adr_flex_value_set_id NUMBER;
186072 l_adr_value_type_code VARCHAR2(30);
186073 l_adr_value_combination_id NUMBER;
186074 l_adr_value_segment_code VARCHAR2(30);
186075
186076 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
186077 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
186078 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
186079 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
186080
186081 -- 4262811 Variables ------------------------------------------------------------------------------------------
186082 l_entered_amt_idx NUMBER;
186083 l_accted_amt_idx NUMBER;
186084 l_acc_rev_flag VARCHAR2(1);
186085 l_accrual_line_num NUMBER;
186086 l_tmp_amt NUMBER;
186087 l_acc_rev_natural_side_code VARCHAR2(1);
186088
186089 l_num_entries NUMBER;
186090 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
186091 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
186092 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
186093 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
186094 l_recog_line_1 NUMBER;
186095 l_recog_line_2 NUMBER;
186096
186097 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
186098 l_bflow_applied_to_amt NUMBER; -- 5132302
186099 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
186100
186101 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
186102
186103 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
186104 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
186105
186106 ---------------------------------------------------------------------------------------------------------------
186107
186108
186109 --
186110 -- bulk performance
186111 --
186112 l_balance_type_code VARCHAR2(1);
186113 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
186114 l_log_module VARCHAR2(240);
186115
186116 --
186117 -- Upgrade strategy
186118 --
186119 l_actual_upg_option VARCHAR2(1);
186120 l_enc_upg_option VARCHAR2(1);
186121
186122 --
186123 BEGIN
186124 --
186125 IF g_log_enabled THEN
186126 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_342';
186127 END IF;
186128 --
186129 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
186130
186131 trace
186132 (p_msg => 'BEGIN of AcctLineType_342'
186133 ,p_level => C_LEVEL_PROCEDURE
186134 ,p_module => l_log_module);
186135
186136 END IF;
186137 --
186138 l_component_type := 'AMB_JLT';
186139 l_component_code := 'OFFSET';
186140 l_component_type_code := 'S';
186141 l_component_appl_id := 707;
186142 l_amb_context_code := 'DEFAULT';
186143 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
186144 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
186145 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_NO_TP';
186146 l_line_definition_owner_code := 'S';
186147 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
186148 --
186149 l_balance_type_code := 'A';
186150 l_segment := NULL;
186151 l_ccid := NULL;
186152 l_adr_transaction_coa_id := NULL;
186153 l_adr_accounting_coa_id := NULL;
186154 l_adr_flexfield_segment_code := NULL;
186155 l_adr_flex_value_set_id := NULL;
186156 l_adr_value_type_code := NULL;
186157 l_adr_value_combination_id := NULL;
186158 l_adr_value_segment_code := NULL;
186159
186160 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
186161 l_bflow_class_code := ''; -- 4219869 Business Flow
186162 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
186163 l_budgetary_control_flag := 'N';
186164
186165 l_bflow_applied_to_amt_idx := NULL; -- 5132302
186166 l_bflow_applied_to_amt := NULL; -- 5132302
186167 l_entered_amt_idx := NULL; -- 4262811
186168 l_accted_amt_idx := NULL; -- 4262811
186169 l_acc_rev_flag := NULL; -- 4262811
186170 l_accrual_line_num := NULL; -- 4262811
186171 l_tmp_amt := NULL; -- 4262811
186172 --
186173
186174 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
186175 l_balance_type_code <> 'B' THEN
186176 IF NVL(p_source_97,9E125) = 2 AND
186177 p_source_95 >= 0
186178 THEN
186179
186180 --
186181 XLA_AE_LINES_PKG.SetNewLine;
186182
186183 p_balance_type_code := l_balance_type_code;
186184 -- set the flag so later we will know whether the gain loss line needs to be created
186185
186186 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
186187 p_actual_flag :='A';
186188 END IF;
186189
186190 --
186191 -- bulk performance
186192 --
186193 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
186194 p_header_num => 0); -- 4262811
186195 --
186196 -- set accounting line options
186197 --
186198 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
186199 p_natural_side_code => 'D'
186200 , p_gain_or_loss_flag => 'N'
186201 , p_gl_transfer_mode_code => 'S'
186202 , p_acct_entry_type_code => 'A'
186203 , p_switch_side_flag => 'Y'
186204 , p_merge_duplicate_code => 'N'
186205 );
186206 --
186207 l_acc_rev_natural_side_code := 'C'; -- 4262811
186208 --
186209 --
186210 -- set accounting line type info
186211 --
186212 xla_ae_lines_pkg.SetAcctLineType
186213 (p_component_type => l_component_type
186214 ,p_event_type_code => l_event_type_code
186215 ,p_line_definition_owner_code => l_line_definition_owner_code
186216 ,p_line_definition_code => l_line_definition_code
186217 ,p_accounting_line_code => l_component_code
186218 ,p_accounting_line_type_code => l_component_type_code
186219 ,p_accounting_line_appl_id => l_component_appl_id
186220 ,p_amb_context_code => l_amb_context_code
186221 ,p_entity_code => l_entity_code
186222 ,p_event_class_code => l_event_class_code);
186223 --
186224 -- set accounting class
186225 --
186226 xla_ae_lines_pkg.SetAcctClass(
186227 p_accounting_class_code => 'OFFSET'
186228 , p_ae_header_id => l_ae_header_id
186229 );
186230
186231 --
186232 -- set rounding class
186233 --
186234 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
186235 'OFFSET';
186236
186237 --
186238 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
186239 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
186240 --
186241 -- bulk performance
186242 --
186243 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
186244
186245 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
186246 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
186247
186248 -- 4955764
186249 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
186250 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
186251
186252 -- 4458381 Public Sector Enh
186253
186254 --
186255 -- set accounting attributes for the line type
186256 --
186257 l_entered_amt_idx := 3;
186258 l_accted_amt_idx := 8;
186259 l_bflow_applied_to_amt_idx := NULL; -- 5132302
186260 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
186261 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
186262 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
186263 l_rec_acct_attrs.array_char_value(2) := p_source_85;
186264 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
186265 l_rec_acct_attrs.array_num_value(3) := p_source_91;
186266 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
186267 l_rec_acct_attrs.array_char_value(4) := p_source_88;
186268 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
186269 l_rec_acct_attrs.array_date_value(5) := p_source_92;
186270 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
186271 l_rec_acct_attrs.array_num_value(6) := p_source_93;
186272 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
186273 l_rec_acct_attrs.array_char_value(7) := p_source_94;
186274 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
186275 l_rec_acct_attrs.array_num_value(8) := p_source_95;
186276
186277 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
186278 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
186279
186280 ---------------------------------------------------------------------------------------------------------------
186281 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
186282 ---------------------------------------------------------------------------------------------------------------
186283 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
186284
186285 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
186286 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
186287
186288 IF xla_accounting_cache_pkg.GetValueChar
186289 (p_source_code => 'LEDGER_CATEGORY_CODE'
186290 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
186291 AND l_bflow_method_code = 'PRIOR_ENTRY'
186292 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
186293 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
186294 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
186295 )
186296 THEN
186297 xla_ae_lines_pkg.BflowUpgEntry
186298 (p_business_method_code => l_bflow_method_code
186299 ,p_business_class_code => l_bflow_class_code
186300 ,p_balance_type => l_balance_type_code);
186301 ELSE
186302 NULL;
186303 -- No business flow processing for business flow method of NONE.
186304 END IF;
186305
186306 --
186307 -- call analytical criteria
186308 --
186309
186310 --
186311 -- call description
186312 --
186313
186314 xla_ae_lines_pkg.SetLineDescription(
186315 p_ae_header_id => l_ae_header_id
186316 ,p_description => Description_1 (
186317 p_application_id => p_application_id
186318 , p_ae_header_id => l_ae_header_id
186319 , p_source_1 => p_source_1
186320 , p_source_2 => p_source_2
186321 , p_source_3 => p_source_3
186322 , p_source_4 => p_source_4
186323 , p_source_5 => p_source_5
186324 )
186325 );
186326
186327
186328 --
186329 -- call ADRs
186330 -- Bug 4922099
186331 --
186332 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
186333 (NVL(l_actual_upg_option, 'N') = 'O') OR
186334 (NVL(l_enc_upg_option, 'N') = 'O')
186335 )
186336 THEN
186337 NULL;
186338 --
186339 --
186340
186341 l_ccid := AcctDerRule_6(
186342 p_application_id => p_application_id
186343 , p_ae_header_id => l_ae_header_id
186344 , p_source_11 => p_source_11
186345 , x_transaction_coa_id => l_adr_transaction_coa_id
186346 , x_accounting_coa_id => l_adr_accounting_coa_id
186347 , x_value_type_code => l_adr_value_type_code
186348 , p_side => 'NA'
186349 );
186350
186351 xla_ae_lines_pkg.set_ccid(
186352 p_code_combination_id => l_ccid
186353 , p_value_type_code => l_adr_value_type_code
186354 , p_transaction_coa_id => l_adr_transaction_coa_id
186355 , p_accounting_coa_id => l_adr_accounting_coa_id
186356 , p_adr_code => 'CST_DEFAULT'
186357 , p_adr_type_code => 'S'
186358 , p_component_type => l_component_type
186359 , p_component_code => l_component_code
186360 , p_component_type_code => l_component_type_code
186361 , p_component_appl_id => l_component_appl_id
186362 , p_amb_context_code => l_amb_context_code
186363 , p_side => 'NA'
186364 );
186365
186366
186367 --
186368 --
186369 END IF;
186370 --
186371 -- Bug 4922099
186372 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
186373 (NVL(l_enc_upg_option, 'N') = 'O')
186374 ) AND
186375 (l_bflow_method_code = 'PRIOR_ENTRY')
186376 )
186377 THEN
186378 IF
186379 --
186380 1 = 2
186381 --
186382 THEN
186383 xla_accounting_err_pkg.build_message
186384 (p_appli_s_name => 'XLA'
186385 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
186386 ,p_token_1 => 'LINE_NUMBER'
186387 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
186388 ,p_token_2 => 'LINE_TYPE_NAME'
186389 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
186390 l_component_type
186391 ,l_component_code
186392 ,l_component_type_code
186393 ,l_component_appl_id
186394 ,l_amb_context_code
186395 ,l_entity_code
186396 ,l_event_class_code
186397 )
186398 ,p_token_3 => 'OWNER'
186399 ,p_value_3 => xla_lookups_pkg.get_meaning(
186400 p_lookup_type => 'XLA_OWNER_TYPE'
186401 ,p_lookup_code => l_component_type_code
186402 )
186403 ,p_token_4 => 'PRODUCT_NAME'
186404 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
186405 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
186406 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
186407 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
186408 ,p_ae_header_id => NULL
186409 );
186410
186411 IF (C_LEVEL_ERROR>= g_log_level) THEN
186412 trace
186413 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
186414 ,p_level => C_LEVEL_ERROR
186415 ,p_module => l_log_module);
186416 END IF;
186417 END IF;
186418 END IF;
186419 --
186420 --
186421 ------------------------------------------------------------------------------------------------
186422 -- 4219869 Business Flow
186423 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
186424 -- Prior Entry. Currently, the following code is always generated.
186425 ------------------------------------------------------------------------------------------------
186426 XLA_AE_LINES_PKG.ValidateCurrentLine;
186427
186428 ------------------------------------------------------------------------------------
186429 -- 4219869 Business Flow
186430 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
186431 ------------------------------------------------------------------------------------
186432 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
186433
186434 ----------------------------------------------------------------------------------
186435 -- 4219869 Business Flow
186436 -- Update journal entry status -- Need to generate this within IF <condition>
186437 ----------------------------------------------------------------------------------
186438 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
186439 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
186440 ,p_balance_type_code => l_balance_type_code
186441 );
186442
186443 -------------------------------------------------------------------------------------------
186444 -- 4262811 - Generate the Accrual Reversal lines
186445 -------------------------------------------------------------------------------------------
186446 BEGIN
186447 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
186448 (g_array_event(p_event_id).array_value_num('header_index'));
186449 IF l_acc_rev_flag IS NULL THEN
186450 l_acc_rev_flag := 'N';
186451 END IF;
186452 EXCEPTION
186453 WHEN OTHERS THEN
186454 l_acc_rev_flag := 'N';
186455 END;
186456 --
186457 IF (l_acc_rev_flag = 'Y') THEN
186458
186459 -- 4645092 ------------------------------------------------------------------------------
186460 -- To allow MPA report to determine if it should generate report process
186461 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
186462 ------------------------------------------------------------------------------------------
186463
186464 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
186465 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
186466 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
186467 -- call ADRs
186468 -- Bug 4922099
186469 --
186470 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
186471 (NVL(l_actual_upg_option, 'N') = 'O') OR
186472 (NVL(l_enc_upg_option, 'N') = 'O')
186473 )
186474 THEN
186475 NULL;
186476 --
186477 --
186478
186479 l_ccid := AcctDerRule_6(
186480 p_application_id => p_application_id
186481 , p_ae_header_id => l_ae_header_id
186482 , p_source_11 => p_source_11
186483 , x_transaction_coa_id => l_adr_transaction_coa_id
186484 , x_accounting_coa_id => l_adr_accounting_coa_id
186485 , x_value_type_code => l_adr_value_type_code
186486 , p_side => 'NA'
186487 );
186488
186489 xla_ae_lines_pkg.set_ccid(
186490 p_code_combination_id => l_ccid
186491 , p_value_type_code => l_adr_value_type_code
186492 , p_transaction_coa_id => l_adr_transaction_coa_id
186493 , p_accounting_coa_id => l_adr_accounting_coa_id
186494 , p_adr_code => 'CST_DEFAULT'
186495 , p_adr_type_code => 'S'
186496 , p_component_type => l_component_type
186497 , p_component_code => l_component_code
186498 , p_component_type_code => l_component_type_code
186499 , p_component_appl_id => l_component_appl_id
186500 , p_amb_context_code => l_amb_context_code
186501 , p_side => 'NA'
186502 );
186503
186504
186505 --
186506 --
186507 END IF;
186508
186509 --
186510 -- Update the line information that should be overwritten
186511 --
186512 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
186513 p_header_num => 1);
186514 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
186515
186516 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
186517
186518 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
186519 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
186520 END IF;
186521
186522 --
186523 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
186524 --
186525 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
186526 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
186527 ELSE
186528 ---------------------------------------------------------------------------------------------------
186529 -- 4262811a Switch Sign
186530 ---------------------------------------------------------------------------------------------------
186531 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
186532 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
186533 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
186534 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
186535 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
186536 -- 5132302
186537 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
186538 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
186539
186540 END IF;
186541
186542 -- 4955764
186543 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
186544 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
186545
186546
186547 XLA_AE_LINES_PKG.ValidateCurrentLine;
186548 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
186549
186550 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
186551 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
186552 ,p_balance_type_code => l_balance_type_code);
186553
186554 END IF;
186555
186556 -----------------------------------------------------------------------------------------
186557 -- 4262811 Multiperiod Accounting
186558 -----------------------------------------------------------------------------------------
186559 -- No MPA option is assigned.
186560
186561
186562 END IF;
186563 END IF;
186564 --
186565
186566 --
186567 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
186568 trace
186569 (p_msg => 'END of AcctLineType_342'
186570 ,p_level => C_LEVEL_PROCEDURE
186571 ,p_module => l_log_module);
186572 END IF;
186573 --
186574 EXCEPTION
186575 WHEN xla_exceptions_pkg.application_exception THEN
186576 RAISE;
186577 WHEN OTHERS THEN
186578 xla_exceptions_pkg.raise_message
186579 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_342');
186580 END AcctLineType_342;
186581 --
186582
186583 ---------------------------------------
186584 --
186585 -- PRIVATE FUNCTION
186586 -- AcctLineType_343
186587 --
186588 ---------------------------------------
186589 PROCEDURE AcctLineType_343 (
186590 p_application_id IN NUMBER
186591 ,p_event_id IN NUMBER
186592 ,p_calculate_acctd_flag IN VARCHAR2
186593 ,p_calculate_g_l_flag IN VARCHAR2
186594 ,p_actual_flag IN OUT VARCHAR2
186595 ,p_balance_type_code OUT VARCHAR2
186596 ,p_gain_or_loss_ref OUT VARCHAR2
186597
186598 --TRANSACTION_ID
186599 , p_source_1 IN NUMBER
186600 --Item Concatenated Segments
186601 , p_source_2 IN VARCHAR2
186602 --Transaction Quantity
186603 , p_source_3 IN NUMBER
186604 --Transaction Unit of Measure Code
186605 , p_source_4 IN VARCHAR2
186606 --Inventory Transaction Type Description
186607 , p_source_5 IN VARCHAR2
186608 --Cost Management Default Account
186609 , p_source_11 IN NUMBER
186610 --DISTRIBUTION_IDENTIFIER
186611 , p_source_84 IN NUMBER
186612 --Distribution Type
186613 , p_source_85 IN VARCHAR2
186614 , p_source_85_meaning IN VARCHAR2
186615 --Entered Currency Code
186616 , p_source_88 IN VARCHAR2
186617 --Entered Amount
186618 , p_source_91 IN NUMBER
186619 --Currency Conversion Date
186620 , p_source_92 IN DATE
186621 --Currency Conversion Rate
186622 , p_source_93 IN NUMBER
186623 --Currency Conversion Type
186624 , p_source_94 IN VARCHAR2
186625 --Accounted Amount
186626 , p_source_95 IN NUMBER
186627 --Accounting Line Type
186628 , p_source_97 IN NUMBER
186629 )
186630 IS
186631
186632 l_component_type VARCHAR2(80);
186633 l_component_code VARCHAR2(30);
186634 l_component_type_code VARCHAR2(1);
186635 l_component_appl_id INTEGER;
186636 l_amb_context_code VARCHAR2(30);
186637 l_entity_code VARCHAR2(30);
186638 l_event_class_code VARCHAR2(30);
186639 l_ae_header_id NUMBER;
186640 l_event_type_code VARCHAR2(30);
186641 l_line_definition_code VARCHAR2(30);
186642 l_line_definition_owner_code VARCHAR2(1);
186643 --
186644 -- adr variables
186645 l_segment VARCHAR2(30);
186646 l_ccid NUMBER;
186647 l_adr_transaction_coa_id NUMBER;
186648 l_adr_accounting_coa_id NUMBER;
186649 l_adr_flexfield_segment_code VARCHAR2(30);
186650 l_adr_flex_value_set_id NUMBER;
186651 l_adr_value_type_code VARCHAR2(30);
186652 l_adr_value_combination_id NUMBER;
186653 l_adr_value_segment_code VARCHAR2(30);
186654
186655 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
186656 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
186657 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
186658 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
186659
186660 -- 4262811 Variables ------------------------------------------------------------------------------------------
186661 l_entered_amt_idx NUMBER;
186662 l_accted_amt_idx NUMBER;
186663 l_acc_rev_flag VARCHAR2(1);
186664 l_accrual_line_num NUMBER;
186665 l_tmp_amt NUMBER;
186666 l_acc_rev_natural_side_code VARCHAR2(1);
186667
186668 l_num_entries NUMBER;
186669 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
186670 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
186671 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
186672 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
186673 l_recog_line_1 NUMBER;
186674 l_recog_line_2 NUMBER;
186675
186676 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
186677 l_bflow_applied_to_amt NUMBER; -- 5132302
186678 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
186679
186680 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
186681
186682 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
186683 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
186684
186685 ---------------------------------------------------------------------------------------------------------------
186686
186687
186688 --
186689 -- bulk performance
186690 --
186691 l_balance_type_code VARCHAR2(1);
186692 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
186693 l_log_module VARCHAR2(240);
186694
186695 --
186696 -- Upgrade strategy
186697 --
186698 l_actual_upg_option VARCHAR2(1);
186699 l_enc_upg_option VARCHAR2(1);
186700
186701 --
186702 BEGIN
186703 --
186704 IF g_log_enabled THEN
186705 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_343';
186706 END IF;
186707 --
186708 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
186709
186710 trace
186711 (p_msg => 'BEGIN of AcctLineType_343'
186712 ,p_level => C_LEVEL_PROCEDURE
186713 ,p_module => l_log_module);
186714
186715 END IF;
186716 --
186717 l_component_type := 'AMB_JLT';
186718 l_component_code := 'OFFSET';
186719 l_component_type_code := 'S';
186720 l_component_appl_id := 707;
186721 l_amb_context_code := 'DEFAULT';
186722 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
186723 l_event_class_code := 'FOB_SHIP_RECIPIENT_SHIP';
186724 l_event_type_code := 'FOB_SHIP_RECIPIENT_SHIP_TP';
186725 l_line_definition_owner_code := 'S';
186726 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_TP';
186727 --
186728 l_balance_type_code := 'A';
186729 l_segment := NULL;
186730 l_ccid := NULL;
186731 l_adr_transaction_coa_id := NULL;
186732 l_adr_accounting_coa_id := NULL;
186733 l_adr_flexfield_segment_code := NULL;
186734 l_adr_flex_value_set_id := NULL;
186735 l_adr_value_type_code := NULL;
186736 l_adr_value_combination_id := NULL;
186737 l_adr_value_segment_code := NULL;
186738
186739 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
186740 l_bflow_class_code := ''; -- 4219869 Business Flow
186741 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
186742 l_budgetary_control_flag := 'N';
186743
186744 l_bflow_applied_to_amt_idx := NULL; -- 5132302
186745 l_bflow_applied_to_amt := NULL; -- 5132302
186746 l_entered_amt_idx := NULL; -- 4262811
186747 l_accted_amt_idx := NULL; -- 4262811
186748 l_acc_rev_flag := NULL; -- 4262811
186749 l_accrual_line_num := NULL; -- 4262811
186750 l_tmp_amt := NULL; -- 4262811
186751 --
186752
186753 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
186754 l_balance_type_code <> 'B' THEN
186755 IF NVL(p_source_97,9E125) = 2 AND
186756 p_source_95 >= 0
186757 THEN
186758
186759 --
186760 XLA_AE_LINES_PKG.SetNewLine;
186761
186762 p_balance_type_code := l_balance_type_code;
186763 -- set the flag so later we will know whether the gain loss line needs to be created
186764
186765 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
186766 p_actual_flag :='A';
186767 END IF;
186768
186769 --
186770 -- bulk performance
186771 --
186772 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
186773 p_header_num => 0); -- 4262811
186774 --
186775 -- set accounting line options
186776 --
186777 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
186778 p_natural_side_code => 'D'
186779 , p_gain_or_loss_flag => 'N'
186780 , p_gl_transfer_mode_code => 'S'
186781 , p_acct_entry_type_code => 'A'
186782 , p_switch_side_flag => 'Y'
186783 , p_merge_duplicate_code => 'N'
186784 );
186785 --
186786 l_acc_rev_natural_side_code := 'C'; -- 4262811
186787 --
186788 --
186789 -- set accounting line type info
186790 --
186791 xla_ae_lines_pkg.SetAcctLineType
186792 (p_component_type => l_component_type
186793 ,p_event_type_code => l_event_type_code
186794 ,p_line_definition_owner_code => l_line_definition_owner_code
186795 ,p_line_definition_code => l_line_definition_code
186796 ,p_accounting_line_code => l_component_code
186797 ,p_accounting_line_type_code => l_component_type_code
186798 ,p_accounting_line_appl_id => l_component_appl_id
186799 ,p_amb_context_code => l_amb_context_code
186800 ,p_entity_code => l_entity_code
186801 ,p_event_class_code => l_event_class_code);
186802 --
186803 -- set accounting class
186804 --
186805 xla_ae_lines_pkg.SetAcctClass(
186806 p_accounting_class_code => 'OFFSET'
186807 , p_ae_header_id => l_ae_header_id
186808 );
186809
186810 --
186811 -- set rounding class
186812 --
186813 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
186814 'OFFSET';
186815
186816 --
186817 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
186818 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
186819 --
186820 -- bulk performance
186821 --
186822 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
186823
186824 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
186825 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
186826
186827 -- 4955764
186828 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
186829 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
186830
186831 -- 4458381 Public Sector Enh
186832
186833 --
186834 -- set accounting attributes for the line type
186835 --
186836 l_entered_amt_idx := 3;
186837 l_accted_amt_idx := 8;
186838 l_bflow_applied_to_amt_idx := NULL; -- 5132302
186839 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
186840 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
186841 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
186842 l_rec_acct_attrs.array_char_value(2) := p_source_85;
186843 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
186844 l_rec_acct_attrs.array_num_value(3) := p_source_91;
186845 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
186846 l_rec_acct_attrs.array_char_value(4) := p_source_88;
186847 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
186848 l_rec_acct_attrs.array_date_value(5) := p_source_92;
186849 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
186850 l_rec_acct_attrs.array_num_value(6) := p_source_93;
186851 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
186852 l_rec_acct_attrs.array_char_value(7) := p_source_94;
186853 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
186854 l_rec_acct_attrs.array_num_value(8) := p_source_95;
186855
186856 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
186857 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
186858
186859 ---------------------------------------------------------------------------------------------------------------
186860 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
186861 ---------------------------------------------------------------------------------------------------------------
186862 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
186863
186864 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
186865 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
186866
186867 IF xla_accounting_cache_pkg.GetValueChar
186868 (p_source_code => 'LEDGER_CATEGORY_CODE'
186869 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
186870 AND l_bflow_method_code = 'PRIOR_ENTRY'
186871 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
186872 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
186873 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
186874 )
186875 THEN
186876 xla_ae_lines_pkg.BflowUpgEntry
186877 (p_business_method_code => l_bflow_method_code
186878 ,p_business_class_code => l_bflow_class_code
186879 ,p_balance_type => l_balance_type_code);
186880 ELSE
186881 NULL;
186882 -- No business flow processing for business flow method of NONE.
186883 END IF;
186884
186885 --
186886 -- call analytical criteria
186887 --
186888
186889 --
186890 -- call description
186891 --
186892
186893 xla_ae_lines_pkg.SetLineDescription(
186894 p_ae_header_id => l_ae_header_id
186895 ,p_description => Description_1 (
186896 p_application_id => p_application_id
186897 , p_ae_header_id => l_ae_header_id
186898 , p_source_1 => p_source_1
186899 , p_source_2 => p_source_2
186900 , p_source_3 => p_source_3
186901 , p_source_4 => p_source_4
186902 , p_source_5 => p_source_5
186903 )
186904 );
186905
186906
186907 --
186908 -- call ADRs
186909 -- Bug 4922099
186910 --
186911 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
186912 (NVL(l_actual_upg_option, 'N') = 'O') OR
186913 (NVL(l_enc_upg_option, 'N') = 'O')
186914 )
186915 THEN
186916 NULL;
186917 --
186918 --
186919
186920 l_ccid := AcctDerRule_6(
186921 p_application_id => p_application_id
186922 , p_ae_header_id => l_ae_header_id
186923 , p_source_11 => p_source_11
186924 , x_transaction_coa_id => l_adr_transaction_coa_id
186925 , x_accounting_coa_id => l_adr_accounting_coa_id
186926 , x_value_type_code => l_adr_value_type_code
186927 , p_side => 'NA'
186928 );
186929
186930 xla_ae_lines_pkg.set_ccid(
186931 p_code_combination_id => l_ccid
186932 , p_value_type_code => l_adr_value_type_code
186933 , p_transaction_coa_id => l_adr_transaction_coa_id
186934 , p_accounting_coa_id => l_adr_accounting_coa_id
186935 , p_adr_code => 'CST_DEFAULT'
186936 , p_adr_type_code => 'S'
186937 , p_component_type => l_component_type
186938 , p_component_code => l_component_code
186939 , p_component_type_code => l_component_type_code
186940 , p_component_appl_id => l_component_appl_id
186941 , p_amb_context_code => l_amb_context_code
186942 , p_side => 'NA'
186943 );
186944
186945
186946 --
186947 --
186948 END IF;
186949 --
186950 -- Bug 4922099
186951 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
186952 (NVL(l_enc_upg_option, 'N') = 'O')
186953 ) AND
186954 (l_bflow_method_code = 'PRIOR_ENTRY')
186955 )
186956 THEN
186957 IF
186958 --
186959 1 = 2
186960 --
186961 THEN
186962 xla_accounting_err_pkg.build_message
186963 (p_appli_s_name => 'XLA'
186964 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
186965 ,p_token_1 => 'LINE_NUMBER'
186966 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
186967 ,p_token_2 => 'LINE_TYPE_NAME'
186968 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
186969 l_component_type
186970 ,l_component_code
186971 ,l_component_type_code
186972 ,l_component_appl_id
186973 ,l_amb_context_code
186974 ,l_entity_code
186975 ,l_event_class_code
186976 )
186977 ,p_token_3 => 'OWNER'
186978 ,p_value_3 => xla_lookups_pkg.get_meaning(
186979 p_lookup_type => 'XLA_OWNER_TYPE'
186980 ,p_lookup_code => l_component_type_code
186981 )
186982 ,p_token_4 => 'PRODUCT_NAME'
186983 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
186984 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
186985 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
186986 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
186987 ,p_ae_header_id => NULL
186988 );
186989
186990 IF (C_LEVEL_ERROR>= g_log_level) THEN
186991 trace
186992 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
186993 ,p_level => C_LEVEL_ERROR
186994 ,p_module => l_log_module);
186995 END IF;
186996 END IF;
186997 END IF;
186998 --
186999 --
187000 ------------------------------------------------------------------------------------------------
187001 -- 4219869 Business Flow
187002 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
187003 -- Prior Entry. Currently, the following code is always generated.
187004 ------------------------------------------------------------------------------------------------
187005 XLA_AE_LINES_PKG.ValidateCurrentLine;
187006
187007 ------------------------------------------------------------------------------------
187008 -- 4219869 Business Flow
187009 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
187010 ------------------------------------------------------------------------------------
187011 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
187012
187013 ----------------------------------------------------------------------------------
187014 -- 4219869 Business Flow
187015 -- Update journal entry status -- Need to generate this within IF <condition>
187016 ----------------------------------------------------------------------------------
187017 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
187018 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
187019 ,p_balance_type_code => l_balance_type_code
187020 );
187021
187022 -------------------------------------------------------------------------------------------
187023 -- 4262811 - Generate the Accrual Reversal lines
187024 -------------------------------------------------------------------------------------------
187025 BEGIN
187026 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
187027 (g_array_event(p_event_id).array_value_num('header_index'));
187028 IF l_acc_rev_flag IS NULL THEN
187029 l_acc_rev_flag := 'N';
187030 END IF;
187031 EXCEPTION
187032 WHEN OTHERS THEN
187033 l_acc_rev_flag := 'N';
187034 END;
187035 --
187036 IF (l_acc_rev_flag = 'Y') THEN
187037
187038 -- 4645092 ------------------------------------------------------------------------------
187039 -- To allow MPA report to determine if it should generate report process
187040 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
187041 ------------------------------------------------------------------------------------------
187042
187043 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
187044 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
187045 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
187046 -- call ADRs
187047 -- Bug 4922099
187048 --
187049 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
187050 (NVL(l_actual_upg_option, 'N') = 'O') OR
187051 (NVL(l_enc_upg_option, 'N') = 'O')
187052 )
187053 THEN
187054 NULL;
187055 --
187056 --
187057
187058 l_ccid := AcctDerRule_6(
187059 p_application_id => p_application_id
187060 , p_ae_header_id => l_ae_header_id
187061 , p_source_11 => p_source_11
187062 , x_transaction_coa_id => l_adr_transaction_coa_id
187063 , x_accounting_coa_id => l_adr_accounting_coa_id
187064 , x_value_type_code => l_adr_value_type_code
187065 , p_side => 'NA'
187066 );
187067
187068 xla_ae_lines_pkg.set_ccid(
187069 p_code_combination_id => l_ccid
187070 , p_value_type_code => l_adr_value_type_code
187071 , p_transaction_coa_id => l_adr_transaction_coa_id
187072 , p_accounting_coa_id => l_adr_accounting_coa_id
187073 , p_adr_code => 'CST_DEFAULT'
187074 , p_adr_type_code => 'S'
187075 , p_component_type => l_component_type
187076 , p_component_code => l_component_code
187077 , p_component_type_code => l_component_type_code
187078 , p_component_appl_id => l_component_appl_id
187079 , p_amb_context_code => l_amb_context_code
187080 , p_side => 'NA'
187081 );
187082
187083
187084 --
187085 --
187086 END IF;
187087
187088 --
187089 -- Update the line information that should be overwritten
187090 --
187091 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
187092 p_header_num => 1);
187093 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
187094
187095 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
187096
187097 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
187098 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
187099 END IF;
187100
187101 --
187102 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
187103 --
187104 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
187105 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
187106 ELSE
187107 ---------------------------------------------------------------------------------------------------
187108 -- 4262811a Switch Sign
187109 ---------------------------------------------------------------------------------------------------
187110 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
187111 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
187112 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187113 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
187114 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187115 -- 5132302
187116 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
187117 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187118
187119 END IF;
187120
187121 -- 4955764
187122 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
187123 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
187124
187125
187126 XLA_AE_LINES_PKG.ValidateCurrentLine;
187127 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
187128
187129 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
187130 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
187131 ,p_balance_type_code => l_balance_type_code);
187132
187133 END IF;
187134
187135 -----------------------------------------------------------------------------------------
187136 -- 4262811 Multiperiod Accounting
187137 -----------------------------------------------------------------------------------------
187138 -- No MPA option is assigned.
187139
187140
187141 END IF;
187142 END IF;
187143 --
187144
187145 --
187146 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
187147 trace
187148 (p_msg => 'END of AcctLineType_343'
187149 ,p_level => C_LEVEL_PROCEDURE
187150 ,p_module => l_log_module);
187151 END IF;
187152 --
187153 EXCEPTION
187154 WHEN xla_exceptions_pkg.application_exception THEN
187155 RAISE;
187156 WHEN OTHERS THEN
187157 xla_exceptions_pkg.raise_message
187158 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_343');
187159 END AcctLineType_343;
187160 --
187161
187162 ---------------------------------------
187163 --
187164 -- PRIVATE FUNCTION
187165 -- AcctLineType_344
187166 --
187167 ---------------------------------------
187168 PROCEDURE AcctLineType_344 (
187169 p_application_id IN NUMBER
187170 ,p_event_id IN NUMBER
187171 ,p_calculate_acctd_flag IN VARCHAR2
187172 ,p_calculate_g_l_flag IN VARCHAR2
187173 ,p_actual_flag IN OUT VARCHAR2
187174 ,p_balance_type_code OUT VARCHAR2
187175 ,p_gain_or_loss_ref OUT VARCHAR2
187176
187177 --TRANSACTION_ID
187178 , p_source_1 IN NUMBER
187179 --Item Concatenated Segments
187180 , p_source_2 IN VARCHAR2
187181 --Transaction Quantity
187182 , p_source_3 IN NUMBER
187183 --Transaction Unit of Measure Code
187184 , p_source_4 IN VARCHAR2
187185 --Inventory Transaction Type Description
187186 , p_source_5 IN VARCHAR2
187187 --Product Line Accounting Category Expense Account
187188 , p_source_24 IN NUMBER
187189 --Applied to Application ID
187190 , p_source_79 IN NUMBER
187191 --Applied to Distribution Link Type
187192 , p_source_80 IN VARCHAR2
187193 --Applied to Entity Code
187194 , p_source_81 IN VARCHAR2
187195 --Applied To Purchase Document Identifier
187196 , p_source_83 IN NUMBER
187197 --DISTRIBUTION_IDENTIFIER
187198 , p_source_84 IN NUMBER
187199 --Distribution Type
187200 , p_source_85 IN VARCHAR2
187201 , p_source_85_meaning IN VARCHAR2
187202 --PO Budget Account
187203 , p_source_86 IN NUMBER
187204 --Encumbrance Reversal Amount Entered
187205 , p_source_87 IN NUMBER
187206 --Entered Currency Code
187207 , p_source_88 IN VARCHAR2
187208 --Transaction Encumbrance Reversal Amount
187209 , p_source_89 IN NUMBER
187210 --Entered Amount
187211 , p_source_91 IN NUMBER
187212 --Currency Conversion Date
187213 , p_source_92 IN DATE
187214 --Currency Conversion Rate
187215 , p_source_93 IN NUMBER
187216 --Currency Conversion Type
187217 , p_source_94 IN VARCHAR2
187218 --Accounted Amount
187219 , p_source_95 IN NUMBER
187220 --Purchasing Encumbrance Type Identifier
187221 , p_source_96 IN NUMBER
187222 --Accounting Line Type
187223 , p_source_97 IN NUMBER
187224 --Costing Encumbrance Upgrade Option
187225 , p_source_100 IN VARCHAR2
187226 --TXN_PO_DISTRIBUTION_ID
187227 , p_source_101 IN NUMBER
187228 )
187229 IS
187230
187231 l_component_type VARCHAR2(80);
187232 l_component_code VARCHAR2(30);
187233 l_component_type_code VARCHAR2(1);
187234 l_component_appl_id INTEGER;
187235 l_amb_context_code VARCHAR2(30);
187236 l_entity_code VARCHAR2(30);
187237 l_event_class_code VARCHAR2(30);
187238 l_ae_header_id NUMBER;
187239 l_event_type_code VARCHAR2(30);
187240 l_line_definition_code VARCHAR2(30);
187241 l_line_definition_owner_code VARCHAR2(1);
187242 --
187243 -- adr variables
187244 l_segment VARCHAR2(30);
187245 l_ccid NUMBER;
187246 l_adr_transaction_coa_id NUMBER;
187247 l_adr_accounting_coa_id NUMBER;
187248 l_adr_flexfield_segment_code VARCHAR2(30);
187249 l_adr_flex_value_set_id NUMBER;
187250 l_adr_value_type_code VARCHAR2(30);
187251 l_adr_value_combination_id NUMBER;
187252 l_adr_value_segment_code VARCHAR2(30);
187253
187254 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
187255 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
187256 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
187257 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
187258
187259 -- 4262811 Variables ------------------------------------------------------------------------------------------
187260 l_entered_amt_idx NUMBER;
187261 l_accted_amt_idx NUMBER;
187262 l_acc_rev_flag VARCHAR2(1);
187263 l_accrual_line_num NUMBER;
187264 l_tmp_amt NUMBER;
187265 l_acc_rev_natural_side_code VARCHAR2(1);
187266
187267 l_num_entries NUMBER;
187268 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
187269 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
187270 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
187271 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
187272 l_recog_line_1 NUMBER;
187273 l_recog_line_2 NUMBER;
187274
187275 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
187276 l_bflow_applied_to_amt NUMBER; -- 5132302
187277 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
187278
187279 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
187280
187281 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
187282 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
187283
187284 ---------------------------------------------------------------------------------------------------------------
187285
187286
187287 --
187288 -- bulk performance
187289 --
187290 l_balance_type_code VARCHAR2(1);
187291 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
187292 l_log_module VARCHAR2(240);
187293
187294 --
187295 -- Upgrade strategy
187296 --
187297 l_actual_upg_option VARCHAR2(1);
187298 l_enc_upg_option VARCHAR2(1);
187299
187300 --
187301 BEGIN
187302 --
187303 IF g_log_enabled THEN
187304 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_344';
187305 END IF;
187306 --
187307 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
187308
187309 trace
187310 (p_msg => 'BEGIN of AcctLineType_344'
187311 ,p_level => C_LEVEL_PROCEDURE
187312 ,p_module => l_log_module);
187313
187314 END IF;
187315 --
187316 l_component_type := 'AMB_JLT';
187317 l_component_code := 'OFFSET';
187318 l_component_type_code := 'S';
187319 l_component_appl_id := 707;
187320 l_amb_context_code := 'DEFAULT';
187321 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
187322 l_event_class_code := 'PURCHASE_ORDER';
187323 l_event_type_code := 'PO_DEL_INV';
187324 l_line_definition_owner_code := 'S';
187325 l_line_definition_code := 'PI_PO_DEL_INV';
187326 --
187327 l_balance_type_code := 'A';
187328 l_segment := NULL;
187329 l_ccid := NULL;
187330 l_adr_transaction_coa_id := NULL;
187331 l_adr_accounting_coa_id := NULL;
187332 l_adr_flexfield_segment_code := NULL;
187333 l_adr_flex_value_set_id := NULL;
187334 l_adr_value_type_code := NULL;
187335 l_adr_value_combination_id := NULL;
187336 l_adr_value_segment_code := NULL;
187337
187338 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
187339 l_bflow_class_code := ''; -- 4219869 Business Flow
187340 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
187341 l_budgetary_control_flag := 'N';
187342
187343 l_bflow_applied_to_amt_idx := NULL; -- 5132302
187344 l_bflow_applied_to_amt := NULL; -- 5132302
187345 l_entered_amt_idx := NULL; -- 4262811
187346 l_accted_amt_idx := NULL; -- 4262811
187347 l_acc_rev_flag := NULL; -- 4262811
187348 l_accrual_line_num := NULL; -- 4262811
187349 l_tmp_amt := NULL; -- 4262811
187350 --
187351
187352 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
187353 l_balance_type_code <> 'B' THEN
187354 IF NVL(p_source_97,9E125) = 2
187355 THEN
187356
187357 --
187358 XLA_AE_LINES_PKG.SetNewLine;
187359
187360 p_balance_type_code := l_balance_type_code;
187361 -- set the flag so later we will know whether the gain loss line needs to be created
187362
187363 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
187364 p_actual_flag :='A';
187365 END IF;
187366
187367 --
187368 -- bulk performance
187369 --
187370 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
187371 p_header_num => 0); -- 4262811
187372 --
187373 -- set accounting line options
187374 --
187375 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
187376 p_natural_side_code => 'D'
187377 , p_gain_or_loss_flag => 'N'
187378 , p_gl_transfer_mode_code => 'S'
187379 , p_acct_entry_type_code => 'A'
187380 , p_switch_side_flag => 'Y'
187381 , p_merge_duplicate_code => 'N'
187382 );
187383 --
187384 l_acc_rev_natural_side_code := 'C'; -- 4262811
187385 --
187386 --
187387 -- set accounting line type info
187388 --
187389 xla_ae_lines_pkg.SetAcctLineType
187390 (p_component_type => l_component_type
187391 ,p_event_type_code => l_event_type_code
187392 ,p_line_definition_owner_code => l_line_definition_owner_code
187393 ,p_line_definition_code => l_line_definition_code
187394 ,p_accounting_line_code => l_component_code
187395 ,p_accounting_line_type_code => l_component_type_code
187396 ,p_accounting_line_appl_id => l_component_appl_id
187397 ,p_amb_context_code => l_amb_context_code
187398 ,p_entity_code => l_entity_code
187399 ,p_event_class_code => l_event_class_code);
187400 --
187401 -- set accounting class
187402 --
187403 xla_ae_lines_pkg.SetAcctClass(
187404 p_accounting_class_code => 'OFFSET'
187405 , p_ae_header_id => l_ae_header_id
187406 );
187407
187408 --
187409 -- set rounding class
187410 --
187411 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
187412 'OFFSET';
187413
187414 --
187415 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
187416 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
187417 --
187418 -- bulk performance
187419 --
187420 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
187421
187422 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
187423 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
187424
187425 -- 4955764
187426 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
187427 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
187428
187429 -- 4458381 Public Sector Enh
187430
187431 --
187432 -- set accounting attributes for the line type
187433 --
187434 l_entered_amt_idx := 17;
187435 l_accted_amt_idx := 22;
187436 l_bflow_applied_to_amt_idx := NULL; -- 5132302
187437 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
187438 l_rec_acct_attrs.array_num_value(1) := p_source_79;
187439 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
187440 l_rec_acct_attrs.array_char_value(2) := p_source_80;
187441 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
187442 l_rec_acct_attrs.array_char_value(3) := p_source_81;
187443 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
187444 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
187445 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
187446 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
187447 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
187448 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
187449 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
187450 l_rec_acct_attrs.array_char_value(7) := p_source_85;
187451 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
187452 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
187453 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
187454 l_rec_acct_attrs.array_num_value(9) := p_source_87;
187455 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
187456 l_rec_acct_attrs.array_char_value(10) := p_source_88;
187457 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
187458 l_rec_acct_attrs.array_num_value(11) := p_source_89;
187459 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
187460 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
187461 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
187462 l_rec_acct_attrs.array_num_value(13) := p_source_87;
187463 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
187464 l_rec_acct_attrs.array_char_value(14) := p_source_88;
187465 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
187466 l_rec_acct_attrs.array_num_value(15) := p_source_89;
187467 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
187468 l_rec_acct_attrs.array_char_value(16) := p_source_100;
187469 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
187470 l_rec_acct_attrs.array_num_value(17) := p_source_91;
187471 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
187472 l_rec_acct_attrs.array_char_value(18) := p_source_88;
187473 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
187474 l_rec_acct_attrs.array_date_value(19) := p_source_92;
187475 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
187476 l_rec_acct_attrs.array_num_value(20) := p_source_93;
187477 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
187478 l_rec_acct_attrs.array_char_value(21) := p_source_94;
187479 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
187480 l_rec_acct_attrs.array_num_value(22) := p_source_95;
187481 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
187482 l_rec_acct_attrs.array_num_value(23) := p_source_96;
187483 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
187484 l_rec_acct_attrs.array_num_value(24) := p_source_96;
187485
187486 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
187487 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
187488
187489 ---------------------------------------------------------------------------------------------------------------
187490 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
187491 ---------------------------------------------------------------------------------------------------------------
187492 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
187493
187494 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
187495 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
187496
187497 IF xla_accounting_cache_pkg.GetValueChar
187498 (p_source_code => 'LEDGER_CATEGORY_CODE'
187499 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
187500 AND l_bflow_method_code = 'PRIOR_ENTRY'
187501 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
187502 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
187503 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
187504 )
187505 THEN
187506 xla_ae_lines_pkg.BflowUpgEntry
187507 (p_business_method_code => l_bflow_method_code
187508 ,p_business_class_code => l_bflow_class_code
187509 ,p_balance_type => l_balance_type_code);
187510 ELSE
187511 NULL;
187512 -- No business flow processing for business flow method of NONE.
187513 END IF;
187514
187515 --
187516 -- call analytical criteria
187517 --
187518
187519 --
187520 -- call description
187521 --
187522
187523 xla_ae_lines_pkg.SetLineDescription(
187524 p_ae_header_id => l_ae_header_id
187525 ,p_description => Description_1 (
187526 p_application_id => p_application_id
187527 , p_ae_header_id => l_ae_header_id
187528 , p_source_1 => p_source_1
187529 , p_source_2 => p_source_2
187530 , p_source_3 => p_source_3
187531 , p_source_4 => p_source_4
187532 , p_source_5 => p_source_5
187533 )
187534 );
187535
187536
187537 --
187538 -- call ADRs
187539 -- Bug 4922099
187540 --
187541 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
187542 (NVL(l_actual_upg_option, 'N') = 'O') OR
187543 (NVL(l_enc_upg_option, 'N') = 'O')
187544 )
187545 THEN
187546 NULL;
187547 --
187548 --
187549
187550 l_ccid := AcctDerRule_13(
187551 p_application_id => p_application_id
187552 , p_ae_header_id => l_ae_header_id
187553 , p_source_24 => p_source_24
187554 , x_transaction_coa_id => l_adr_transaction_coa_id
187555 , x_accounting_coa_id => l_adr_accounting_coa_id
187556 , x_value_type_code => l_adr_value_type_code
187557 , p_side => 'NA'
187558 );
187559
187560 xla_ae_lines_pkg.set_ccid(
187561 p_code_combination_id => l_ccid
187562 , p_value_type_code => l_adr_value_type_code
187563 , p_transaction_coa_id => l_adr_transaction_coa_id
187564 , p_accounting_coa_id => l_adr_accounting_coa_id
187565 , p_adr_code => 'PI_CATEGORY_EXPENSE'
187566 , p_adr_type_code => 'S'
187567 , p_component_type => l_component_type
187568 , p_component_code => l_component_code
187569 , p_component_type_code => l_component_type_code
187570 , p_component_appl_id => l_component_appl_id
187571 , p_amb_context_code => l_amb_context_code
187572 , p_side => 'NA'
187573 );
187574
187575
187576 --
187577 --
187578 END IF;
187579 --
187580 -- Bug 4922099
187581 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
187582 (NVL(l_enc_upg_option, 'N') = 'O')
187583 ) AND
187584 (l_bflow_method_code = 'PRIOR_ENTRY')
187585 )
187586 THEN
187587 IF
187588 --
187589 1 = 2
187590 --
187591 THEN
187592 xla_accounting_err_pkg.build_message
187593 (p_appli_s_name => 'XLA'
187594 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
187595 ,p_token_1 => 'LINE_NUMBER'
187596 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
187597 ,p_token_2 => 'LINE_TYPE_NAME'
187598 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
187599 l_component_type
187600 ,l_component_code
187601 ,l_component_type_code
187602 ,l_component_appl_id
187603 ,l_amb_context_code
187604 ,l_entity_code
187605 ,l_event_class_code
187606 )
187607 ,p_token_3 => 'OWNER'
187608 ,p_value_3 => xla_lookups_pkg.get_meaning(
187609 p_lookup_type => 'XLA_OWNER_TYPE'
187610 ,p_lookup_code => l_component_type_code
187611 )
187612 ,p_token_4 => 'PRODUCT_NAME'
187613 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
187614 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
187615 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
187616 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
187617 ,p_ae_header_id => NULL
187618 );
187619
187620 IF (C_LEVEL_ERROR>= g_log_level) THEN
187621 trace
187622 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
187623 ,p_level => C_LEVEL_ERROR
187624 ,p_module => l_log_module);
187625 END IF;
187626 END IF;
187627 END IF;
187628 --
187629 --
187630 ------------------------------------------------------------------------------------------------
187631 -- 4219869 Business Flow
187632 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
187633 -- Prior Entry. Currently, the following code is always generated.
187634 ------------------------------------------------------------------------------------------------
187635 XLA_AE_LINES_PKG.ValidateCurrentLine;
187636
187637 ------------------------------------------------------------------------------------
187638 -- 4219869 Business Flow
187639 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
187640 ------------------------------------------------------------------------------------
187641 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
187642
187643 ----------------------------------------------------------------------------------
187644 -- 4219869 Business Flow
187645 -- Update journal entry status -- Need to generate this within IF <condition>
187646 ----------------------------------------------------------------------------------
187647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
187648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
187649 ,p_balance_type_code => l_balance_type_code
187650 );
187651
187652 -------------------------------------------------------------------------------------------
187653 -- 4262811 - Generate the Accrual Reversal lines
187654 -------------------------------------------------------------------------------------------
187655 BEGIN
187656 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
187657 (g_array_event(p_event_id).array_value_num('header_index'));
187658 IF l_acc_rev_flag IS NULL THEN
187659 l_acc_rev_flag := 'N';
187660 END IF;
187661 EXCEPTION
187662 WHEN OTHERS THEN
187663 l_acc_rev_flag := 'N';
187664 END;
187665 --
187666 IF (l_acc_rev_flag = 'Y') THEN
187667
187668 -- 4645092 ------------------------------------------------------------------------------
187669 -- To allow MPA report to determine if it should generate report process
187670 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
187671 ------------------------------------------------------------------------------------------
187672
187673 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
187674 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
187675 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
187676 -- call ADRs
187677 -- Bug 4922099
187678 --
187679 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
187680 (NVL(l_actual_upg_option, 'N') = 'O') OR
187681 (NVL(l_enc_upg_option, 'N') = 'O')
187682 )
187683 THEN
187684 NULL;
187685 --
187686 --
187687
187688 l_ccid := AcctDerRule_13(
187689 p_application_id => p_application_id
187690 , p_ae_header_id => l_ae_header_id
187691 , p_source_24 => p_source_24
187692 , x_transaction_coa_id => l_adr_transaction_coa_id
187693 , x_accounting_coa_id => l_adr_accounting_coa_id
187694 , x_value_type_code => l_adr_value_type_code
187695 , p_side => 'NA'
187696 );
187697
187698 xla_ae_lines_pkg.set_ccid(
187699 p_code_combination_id => l_ccid
187700 , p_value_type_code => l_adr_value_type_code
187701 , p_transaction_coa_id => l_adr_transaction_coa_id
187702 , p_accounting_coa_id => l_adr_accounting_coa_id
187703 , p_adr_code => 'PI_CATEGORY_EXPENSE'
187704 , p_adr_type_code => 'S'
187705 , p_component_type => l_component_type
187706 , p_component_code => l_component_code
187707 , p_component_type_code => l_component_type_code
187708 , p_component_appl_id => l_component_appl_id
187709 , p_amb_context_code => l_amb_context_code
187710 , p_side => 'NA'
187711 );
187712
187713
187714 --
187715 --
187716 END IF;
187717
187718 --
187719 -- Update the line information that should be overwritten
187720 --
187721 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
187722 p_header_num => 1);
187723 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
187724
187725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
187726
187727 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
187728 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
187729 END IF;
187730
187731 --
187732 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
187733 --
187734 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
187735 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
187736 ELSE
187737 ---------------------------------------------------------------------------------------------------
187738 -- 4262811a Switch Sign
187739 ---------------------------------------------------------------------------------------------------
187740 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
187741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
187742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
187744 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187745 -- 5132302
187746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
187747 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
187748
187749 END IF;
187750
187751 -- 4955764
187752 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
187753 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
187754
187755
187756 XLA_AE_LINES_PKG.ValidateCurrentLine;
187757 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
187758
187759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
187760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
187761 ,p_balance_type_code => l_balance_type_code);
187762
187763 END IF;
187764
187765 -----------------------------------------------------------------------------------------
187766 -- 4262811 Multiperiod Accounting
187767 -----------------------------------------------------------------------------------------
187768 -- No MPA option is assigned.
187769
187770
187771 END IF;
187772 END IF;
187773 --
187774
187775 --
187776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
187777 trace
187778 (p_msg => 'END of AcctLineType_344'
187779 ,p_level => C_LEVEL_PROCEDURE
187780 ,p_module => l_log_module);
187781 END IF;
187782 --
187783 EXCEPTION
187784 WHEN xla_exceptions_pkg.application_exception THEN
187785 RAISE;
187786 WHEN OTHERS THEN
187787 xla_exceptions_pkg.raise_message
187788 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_344');
187789 END AcctLineType_344;
187790 --
187791
187792 ---------------------------------------
187793 --
187794 -- PRIVATE FUNCTION
187795 -- AcctLineType_345
187796 --
187797 ---------------------------------------
187798 PROCEDURE AcctLineType_345 (
187799 p_application_id IN NUMBER
187800 ,p_event_id IN NUMBER
187801 ,p_calculate_acctd_flag IN VARCHAR2
187802 ,p_calculate_g_l_flag IN VARCHAR2
187803 ,p_actual_flag IN OUT VARCHAR2
187804 ,p_balance_type_code OUT VARCHAR2
187805 ,p_gain_or_loss_ref OUT VARCHAR2
187806
187807 --TRANSACTION_ID
187808 , p_source_1 IN NUMBER
187809 --Item Concatenated Segments
187810 , p_source_2 IN VARCHAR2
187811 --Transaction Quantity
187812 , p_source_3 IN NUMBER
187813 --Transaction Unit of Measure Code
187814 , p_source_4 IN VARCHAR2
187815 --Inventory Transaction Type Description
187816 , p_source_5 IN VARCHAR2
187817 --Cost Management Default Account
187818 , p_source_11 IN NUMBER
187819 --DISTRIBUTION_IDENTIFIER
187820 , p_source_84 IN NUMBER
187821 --Distribution Type
187822 , p_source_85 IN VARCHAR2
187823 , p_source_85_meaning IN VARCHAR2
187824 --Entered Currency Code
187825 , p_source_88 IN VARCHAR2
187826 --Entered Amount
187827 , p_source_91 IN NUMBER
187828 --Currency Conversion Date
187829 , p_source_92 IN DATE
187830 --Currency Conversion Rate
187831 , p_source_93 IN NUMBER
187832 --Currency Conversion Type
187833 , p_source_94 IN VARCHAR2
187834 --Accounted Amount
187835 , p_source_95 IN NUMBER
187836 --Accounting Line Type
187837 , p_source_97 IN NUMBER
187838 )
187839 IS
187840
187841 l_component_type VARCHAR2(80);
187842 l_component_code VARCHAR2(30);
187843 l_component_type_code VARCHAR2(1);
187844 l_component_appl_id INTEGER;
187845 l_amb_context_code VARCHAR2(30);
187846 l_entity_code VARCHAR2(30);
187847 l_event_class_code VARCHAR2(30);
187848 l_ae_header_id NUMBER;
187849 l_event_type_code VARCHAR2(30);
187850 l_line_definition_code VARCHAR2(30);
187851 l_line_definition_owner_code VARCHAR2(1);
187852 --
187853 -- adr variables
187854 l_segment VARCHAR2(30);
187855 l_ccid NUMBER;
187856 l_adr_transaction_coa_id NUMBER;
187857 l_adr_accounting_coa_id NUMBER;
187858 l_adr_flexfield_segment_code VARCHAR2(30);
187859 l_adr_flex_value_set_id NUMBER;
187860 l_adr_value_type_code VARCHAR2(30);
187861 l_adr_value_combination_id NUMBER;
187862 l_adr_value_segment_code VARCHAR2(30);
187863
187864 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
187865 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
187866 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
187867 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
187868
187869 -- 4262811 Variables ------------------------------------------------------------------------------------------
187870 l_entered_amt_idx NUMBER;
187871 l_accted_amt_idx NUMBER;
187872 l_acc_rev_flag VARCHAR2(1);
187873 l_accrual_line_num NUMBER;
187874 l_tmp_amt NUMBER;
187875 l_acc_rev_natural_side_code VARCHAR2(1);
187876
187877 l_num_entries NUMBER;
187878 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
187879 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
187880 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
187881 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
187882 l_recog_line_1 NUMBER;
187883 l_recog_line_2 NUMBER;
187884
187885 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
187886 l_bflow_applied_to_amt NUMBER; -- 5132302
187887 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
187888
187889 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
187890
187891 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
187892 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
187893
187894 ---------------------------------------------------------------------------------------------------------------
187895
187896
187897 --
187898 -- bulk performance
187899 --
187900 l_balance_type_code VARCHAR2(1);
187901 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
187902 l_log_module VARCHAR2(240);
187903
187904 --
187905 -- Upgrade strategy
187906 --
187907 l_actual_upg_option VARCHAR2(1);
187908 l_enc_upg_option VARCHAR2(1);
187909
187910 --
187911 BEGIN
187912 --
187913 IF g_log_enabled THEN
187914 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_345';
187915 END IF;
187916 --
187917 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
187918
187919 trace
187920 (p_msg => 'BEGIN of AcctLineType_345'
187921 ,p_level => C_LEVEL_PROCEDURE
187922 ,p_module => l_log_module);
187923
187924 END IF;
187925 --
187926 l_component_type := 'AMB_JLT';
187927 l_component_code := 'OFFSET';
187928 l_component_type_code := 'S';
187929 l_component_appl_id := 707;
187930 l_amb_context_code := 'DEFAULT';
187931 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
187932 l_event_class_code := 'USER_DEFINE';
187933 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
187934 l_line_definition_owner_code := 'S';
187935 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
187936 --
187937 l_balance_type_code := 'A';
187938 l_segment := NULL;
187939 l_ccid := NULL;
187940 l_adr_transaction_coa_id := NULL;
187941 l_adr_accounting_coa_id := NULL;
187942 l_adr_flexfield_segment_code := NULL;
187943 l_adr_flex_value_set_id := NULL;
187944 l_adr_value_type_code := NULL;
187945 l_adr_value_combination_id := NULL;
187946 l_adr_value_segment_code := NULL;
187947
187948 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
187949 l_bflow_class_code := ''; -- 4219869 Business Flow
187950 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
187951 l_budgetary_control_flag := 'N';
187952
187953 l_bflow_applied_to_amt_idx := NULL; -- 5132302
187954 l_bflow_applied_to_amt := NULL; -- 5132302
187955 l_entered_amt_idx := NULL; -- 4262811
187956 l_accted_amt_idx := NULL; -- 4262811
187957 l_acc_rev_flag := NULL; -- 4262811
187958 l_accrual_line_num := NULL; -- 4262811
187959 l_tmp_amt := NULL; -- 4262811
187960 --
187961
187962 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
187963 l_balance_type_code <> 'B' THEN
187964 IF NVL(p_source_97,9E125) = 2
187965 THEN
187966
187967 --
187968 XLA_AE_LINES_PKG.SetNewLine;
187969
187970 p_balance_type_code := l_balance_type_code;
187971 -- set the flag so later we will know whether the gain loss line needs to be created
187972
187973 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
187974 p_actual_flag :='A';
187975 END IF;
187976
187977 --
187978 -- bulk performance
187979 --
187980 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
187981 p_header_num => 0); -- 4262811
187982 --
187983 -- set accounting line options
187984 --
187985 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
187986 p_natural_side_code => 'D'
187987 , p_gain_or_loss_flag => 'N'
187988 , p_gl_transfer_mode_code => 'S'
187989 , p_acct_entry_type_code => 'A'
187990 , p_switch_side_flag => 'Y'
187991 , p_merge_duplicate_code => 'N'
187992 );
187993 --
187994 l_acc_rev_natural_side_code := 'C'; -- 4262811
187995 --
187996 --
187997 -- set accounting line type info
187998 --
187999 xla_ae_lines_pkg.SetAcctLineType
188000 (p_component_type => l_component_type
188001 ,p_event_type_code => l_event_type_code
188002 ,p_line_definition_owner_code => l_line_definition_owner_code
188003 ,p_line_definition_code => l_line_definition_code
188004 ,p_accounting_line_code => l_component_code
188005 ,p_accounting_line_type_code => l_component_type_code
188006 ,p_accounting_line_appl_id => l_component_appl_id
188007 ,p_amb_context_code => l_amb_context_code
188008 ,p_entity_code => l_entity_code
188009 ,p_event_class_code => l_event_class_code);
188010 --
188011 -- set accounting class
188012 --
188013 xla_ae_lines_pkg.SetAcctClass(
188014 p_accounting_class_code => 'OFFSET'
188015 , p_ae_header_id => l_ae_header_id
188016 );
188017
188018 --
188019 -- set rounding class
188020 --
188021 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
188022 'OFFSET';
188023
188024 --
188025 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
188026 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
188027 --
188028 -- bulk performance
188029 --
188030 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
188031
188032 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
188033 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
188034
188035 -- 4955764
188036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
188037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
188038
188039 -- 4458381 Public Sector Enh
188040
188041 --
188042 -- set accounting attributes for the line type
188043 --
188044 l_entered_amt_idx := 3;
188045 l_accted_amt_idx := 8;
188046 l_bflow_applied_to_amt_idx := NULL; -- 5132302
188047 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
188048 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
188049 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
188050 l_rec_acct_attrs.array_char_value(2) := p_source_85;
188051 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
188052 l_rec_acct_attrs.array_num_value(3) := p_source_91;
188053 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
188054 l_rec_acct_attrs.array_char_value(4) := p_source_88;
188055 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
188056 l_rec_acct_attrs.array_date_value(5) := p_source_92;
188057 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
188058 l_rec_acct_attrs.array_num_value(6) := p_source_93;
188059 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
188060 l_rec_acct_attrs.array_char_value(7) := p_source_94;
188061 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
188062 l_rec_acct_attrs.array_num_value(8) := p_source_95;
188063
188064 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
188065 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
188066
188067 ---------------------------------------------------------------------------------------------------------------
188068 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
188069 ---------------------------------------------------------------------------------------------------------------
188070 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
188071
188072 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
188073 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
188074
188075 IF xla_accounting_cache_pkg.GetValueChar
188076 (p_source_code => 'LEDGER_CATEGORY_CODE'
188077 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
188078 AND l_bflow_method_code = 'PRIOR_ENTRY'
188079 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
188080 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
188081 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
188082 )
188083 THEN
188084 xla_ae_lines_pkg.BflowUpgEntry
188085 (p_business_method_code => l_bflow_method_code
188086 ,p_business_class_code => l_bflow_class_code
188087 ,p_balance_type => l_balance_type_code);
188088 ELSE
188089 NULL;
188090 -- No business flow processing for business flow method of NONE.
188091 END IF;
188092
188093 --
188094 -- call analytical criteria
188095 --
188096
188097 --
188098 -- call description
188099 --
188100
188101 xla_ae_lines_pkg.SetLineDescription(
188102 p_ae_header_id => l_ae_header_id
188103 ,p_description => Description_1 (
188104 p_application_id => p_application_id
188105 , p_ae_header_id => l_ae_header_id
188106 , p_source_1 => p_source_1
188107 , p_source_2 => p_source_2
188108 , p_source_3 => p_source_3
188109 , p_source_4 => p_source_4
188110 , p_source_5 => p_source_5
188111 )
188112 );
188113
188114
188115 --
188116 -- call ADRs
188117 -- Bug 4922099
188118 --
188119 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
188120 (NVL(l_actual_upg_option, 'N') = 'O') OR
188121 (NVL(l_enc_upg_option, 'N') = 'O')
188122 )
188123 THEN
188124 NULL;
188125 --
188126 --
188127
188128 l_ccid := AcctDerRule_6(
188129 p_application_id => p_application_id
188130 , p_ae_header_id => l_ae_header_id
188131 , p_source_11 => p_source_11
188132 , x_transaction_coa_id => l_adr_transaction_coa_id
188133 , x_accounting_coa_id => l_adr_accounting_coa_id
188134 , x_value_type_code => l_adr_value_type_code
188135 , p_side => 'NA'
188136 );
188137
188138 xla_ae_lines_pkg.set_ccid(
188139 p_code_combination_id => l_ccid
188140 , p_value_type_code => l_adr_value_type_code
188141 , p_transaction_coa_id => l_adr_transaction_coa_id
188142 , p_accounting_coa_id => l_adr_accounting_coa_id
188143 , p_adr_code => 'CST_DEFAULT'
188144 , p_adr_type_code => 'S'
188145 , p_component_type => l_component_type
188146 , p_component_code => l_component_code
188147 , p_component_type_code => l_component_type_code
188148 , p_component_appl_id => l_component_appl_id
188149 , p_amb_context_code => l_amb_context_code
188150 , p_side => 'NA'
188151 );
188152
188153
188154 --
188155 --
188156 END IF;
188157 --
188158 -- Bug 4922099
188159 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
188160 (NVL(l_enc_upg_option, 'N') = 'O')
188161 ) AND
188162 (l_bflow_method_code = 'PRIOR_ENTRY')
188163 )
188164 THEN
188165 IF
188166 --
188167 1 = 2
188168 --
188169 THEN
188170 xla_accounting_err_pkg.build_message
188171 (p_appli_s_name => 'XLA'
188172 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
188173 ,p_token_1 => 'LINE_NUMBER'
188174 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
188175 ,p_token_2 => 'LINE_TYPE_NAME'
188176 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
188177 l_component_type
188178 ,l_component_code
188179 ,l_component_type_code
188180 ,l_component_appl_id
188181 ,l_amb_context_code
188182 ,l_entity_code
188183 ,l_event_class_code
188184 )
188185 ,p_token_3 => 'OWNER'
188186 ,p_value_3 => xla_lookups_pkg.get_meaning(
188187 p_lookup_type => 'XLA_OWNER_TYPE'
188188 ,p_lookup_code => l_component_type_code
188189 )
188190 ,p_token_4 => 'PRODUCT_NAME'
188191 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
188192 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
188193 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
188194 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
188195 ,p_ae_header_id => NULL
188196 );
188197
188198 IF (C_LEVEL_ERROR>= g_log_level) THEN
188199 trace
188200 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
188201 ,p_level => C_LEVEL_ERROR
188202 ,p_module => l_log_module);
188203 END IF;
188204 END IF;
188205 END IF;
188206 --
188207 --
188208 ------------------------------------------------------------------------------------------------
188209 -- 4219869 Business Flow
188210 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
188211 -- Prior Entry. Currently, the following code is always generated.
188212 ------------------------------------------------------------------------------------------------
188213 XLA_AE_LINES_PKG.ValidateCurrentLine;
188214
188215 ------------------------------------------------------------------------------------
188216 -- 4219869 Business Flow
188217 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
188218 ------------------------------------------------------------------------------------
188219 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
188220
188221 ----------------------------------------------------------------------------------
188222 -- 4219869 Business Flow
188223 -- Update journal entry status -- Need to generate this within IF <condition>
188224 ----------------------------------------------------------------------------------
188225 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
188226 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
188227 ,p_balance_type_code => l_balance_type_code
188228 );
188229
188230 -------------------------------------------------------------------------------------------
188231 -- 4262811 - Generate the Accrual Reversal lines
188232 -------------------------------------------------------------------------------------------
188233 BEGIN
188234 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
188235 (g_array_event(p_event_id).array_value_num('header_index'));
188236 IF l_acc_rev_flag IS NULL THEN
188237 l_acc_rev_flag := 'N';
188238 END IF;
188239 EXCEPTION
188240 WHEN OTHERS THEN
188241 l_acc_rev_flag := 'N';
188242 END;
188243 --
188244 IF (l_acc_rev_flag = 'Y') THEN
188245
188246 -- 4645092 ------------------------------------------------------------------------------
188247 -- To allow MPA report to determine if it should generate report process
188248 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
188249 ------------------------------------------------------------------------------------------
188250
188251 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
188252 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
188253 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
188254 -- call ADRs
188255 -- Bug 4922099
188256 --
188257 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
188258 (NVL(l_actual_upg_option, 'N') = 'O') OR
188259 (NVL(l_enc_upg_option, 'N') = 'O')
188260 )
188261 THEN
188262 NULL;
188263 --
188264 --
188265
188266 l_ccid := AcctDerRule_6(
188267 p_application_id => p_application_id
188268 , p_ae_header_id => l_ae_header_id
188269 , p_source_11 => p_source_11
188270 , x_transaction_coa_id => l_adr_transaction_coa_id
188271 , x_accounting_coa_id => l_adr_accounting_coa_id
188272 , x_value_type_code => l_adr_value_type_code
188273 , p_side => 'NA'
188274 );
188275
188276 xla_ae_lines_pkg.set_ccid(
188277 p_code_combination_id => l_ccid
188278 , p_value_type_code => l_adr_value_type_code
188279 , p_transaction_coa_id => l_adr_transaction_coa_id
188280 , p_accounting_coa_id => l_adr_accounting_coa_id
188281 , p_adr_code => 'CST_DEFAULT'
188282 , p_adr_type_code => 'S'
188283 , p_component_type => l_component_type
188284 , p_component_code => l_component_code
188285 , p_component_type_code => l_component_type_code
188286 , p_component_appl_id => l_component_appl_id
188287 , p_amb_context_code => l_amb_context_code
188288 , p_side => 'NA'
188289 );
188290
188291
188292 --
188293 --
188294 END IF;
188295
188296 --
188297 -- Update the line information that should be overwritten
188298 --
188299 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
188300 p_header_num => 1);
188301 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
188302
188303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
188304
188305 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
188306 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
188307 END IF;
188308
188309 --
188310 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
188311 --
188312 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
188313 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
188314 ELSE
188315 ---------------------------------------------------------------------------------------------------
188316 -- 4262811a Switch Sign
188317 ---------------------------------------------------------------------------------------------------
188318 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
188319 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
188320 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188321 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
188322 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188323 -- 5132302
188324 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
188325 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188326
188327 END IF;
188328
188329 -- 4955764
188330 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
188331 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
188332
188333
188334 XLA_AE_LINES_PKG.ValidateCurrentLine;
188335 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
188336
188337 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
188338 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
188339 ,p_balance_type_code => l_balance_type_code);
188340
188341 END IF;
188342
188343 -----------------------------------------------------------------------------------------
188344 -- 4262811 Multiperiod Accounting
188345 -----------------------------------------------------------------------------------------
188346 -- No MPA option is assigned.
188347
188348
188349 END IF;
188350 END IF;
188351 --
188352
188353 --
188354 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
188355 trace
188356 (p_msg => 'END of AcctLineType_345'
188357 ,p_level => C_LEVEL_PROCEDURE
188358 ,p_module => l_log_module);
188359 END IF;
188360 --
188361 EXCEPTION
188362 WHEN xla_exceptions_pkg.application_exception THEN
188363 RAISE;
188364 WHEN OTHERS THEN
188365 xla_exceptions_pkg.raise_message
188366 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_345');
188367 END AcctLineType_345;
188368 --
188369
188370 ---------------------------------------
188371 --
188372 -- PRIVATE FUNCTION
188373 -- AcctLineType_346
188374 --
188375 ---------------------------------------
188376 PROCEDURE AcctLineType_346 (
188377 p_application_id IN NUMBER
188378 ,p_event_id IN NUMBER
188379 ,p_calculate_acctd_flag IN VARCHAR2
188380 ,p_calculate_g_l_flag IN VARCHAR2
188381 ,p_actual_flag IN OUT VARCHAR2
188382 ,p_balance_type_code OUT VARCHAR2
188383 ,p_gain_or_loss_ref OUT VARCHAR2
188384
188385 --TRANSACTION_ID
188386 , p_source_1 IN NUMBER
188387 --Item Concatenated Segments
188388 , p_source_2 IN VARCHAR2
188389 --Transaction Quantity
188390 , p_source_3 IN NUMBER
188391 --Transaction Unit of Measure Code
188392 , p_source_4 IN VARCHAR2
188393 --Inventory Transaction Type Description
188394 , p_source_5 IN VARCHAR2
188395 --Cost Management Default Account
188396 , p_source_11 IN NUMBER
188397 --DISTRIBUTION_IDENTIFIER
188398 , p_source_84 IN NUMBER
188399 --Distribution Type
188400 , p_source_85 IN VARCHAR2
188401 , p_source_85_meaning IN VARCHAR2
188402 --Entered Currency Code
188403 , p_source_88 IN VARCHAR2
188404 --Entered Amount
188405 , p_source_91 IN NUMBER
188406 --Currency Conversion Date
188407 , p_source_92 IN DATE
188408 --Currency Conversion Rate
188409 , p_source_93 IN NUMBER
188410 --Currency Conversion Type
188411 , p_source_94 IN VARCHAR2
188412 --Accounted Amount
188413 , p_source_95 IN NUMBER
188414 --Accounting Line Type
188415 , p_source_97 IN NUMBER
188416 )
188417 IS
188418
188419 l_component_type VARCHAR2(80);
188420 l_component_code VARCHAR2(30);
188421 l_component_type_code VARCHAR2(1);
188422 l_component_appl_id INTEGER;
188423 l_amb_context_code VARCHAR2(30);
188424 l_entity_code VARCHAR2(30);
188425 l_event_class_code VARCHAR2(30);
188426 l_ae_header_id NUMBER;
188427 l_event_type_code VARCHAR2(30);
188428 l_line_definition_code VARCHAR2(30);
188429 l_line_definition_owner_code VARCHAR2(1);
188430 --
188431 -- adr variables
188432 l_segment VARCHAR2(30);
188433 l_ccid NUMBER;
188434 l_adr_transaction_coa_id NUMBER;
188435 l_adr_accounting_coa_id NUMBER;
188436 l_adr_flexfield_segment_code VARCHAR2(30);
188437 l_adr_flex_value_set_id NUMBER;
188438 l_adr_value_type_code VARCHAR2(30);
188439 l_adr_value_combination_id NUMBER;
188440 l_adr_value_segment_code VARCHAR2(30);
188441
188442 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
188443 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
188444 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
188445 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
188446
188447 -- 4262811 Variables ------------------------------------------------------------------------------------------
188448 l_entered_amt_idx NUMBER;
188449 l_accted_amt_idx NUMBER;
188450 l_acc_rev_flag VARCHAR2(1);
188451 l_accrual_line_num NUMBER;
188452 l_tmp_amt NUMBER;
188453 l_acc_rev_natural_side_code VARCHAR2(1);
188454
188455 l_num_entries NUMBER;
188456 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
188457 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
188458 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
188459 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
188460 l_recog_line_1 NUMBER;
188461 l_recog_line_2 NUMBER;
188462
188463 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
188464 l_bflow_applied_to_amt NUMBER; -- 5132302
188465 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
188466
188467 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
188468
188469 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
188470 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
188471
188472 ---------------------------------------------------------------------------------------------------------------
188473
188474
188475 --
188476 -- bulk performance
188477 --
188478 l_balance_type_code VARCHAR2(1);
188479 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
188480 l_log_module VARCHAR2(240);
188481
188482 --
188483 -- Upgrade strategy
188484 --
188485 l_actual_upg_option VARCHAR2(1);
188486 l_enc_upg_option VARCHAR2(1);
188487
188488 --
188489 BEGIN
188490 --
188491 IF g_log_enabled THEN
188492 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_346';
188493 END IF;
188494 --
188495 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
188496
188497 trace
188498 (p_msg => 'BEGIN of AcctLineType_346'
188499 ,p_level => C_LEVEL_PROCEDURE
188500 ,p_module => l_log_module);
188501
188502 END IF;
188503 --
188504 l_component_type := 'AMB_JLT';
188505 l_component_code := 'OFFSET';
188506 l_component_type_code := 'S';
188507 l_component_appl_id := 707;
188508 l_amb_context_code := 'DEFAULT';
188509 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
188510 l_event_class_code := 'USER_DEFINE';
188511 l_event_type_code := 'UFOB_RCPT_SENDER_SHIP';
188512 l_line_definition_owner_code := 'S';
188513 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
188514 --
188515 l_balance_type_code := 'A';
188516 l_segment := NULL;
188517 l_ccid := NULL;
188518 l_adr_transaction_coa_id := NULL;
188519 l_adr_accounting_coa_id := NULL;
188520 l_adr_flexfield_segment_code := NULL;
188521 l_adr_flex_value_set_id := NULL;
188522 l_adr_value_type_code := NULL;
188523 l_adr_value_combination_id := NULL;
188524 l_adr_value_segment_code := NULL;
188525
188526 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
188527 l_bflow_class_code := ''; -- 4219869 Business Flow
188528 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
188529 l_budgetary_control_flag := 'N';
188530
188531 l_bflow_applied_to_amt_idx := NULL; -- 5132302
188532 l_bflow_applied_to_amt := NULL; -- 5132302
188533 l_entered_amt_idx := NULL; -- 4262811
188534 l_accted_amt_idx := NULL; -- 4262811
188535 l_acc_rev_flag := NULL; -- 4262811
188536 l_accrual_line_num := NULL; -- 4262811
188537 l_tmp_amt := NULL; -- 4262811
188538 --
188539
188540 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
188541 l_balance_type_code <> 'B' THEN
188542 IF NVL(p_source_97,9E125) = 2
188543 THEN
188544
188545 --
188546 XLA_AE_LINES_PKG.SetNewLine;
188547
188548 p_balance_type_code := l_balance_type_code;
188549 -- set the flag so later we will know whether the gain loss line needs to be created
188550
188551 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
188552 p_actual_flag :='A';
188553 END IF;
188554
188555 --
188556 -- bulk performance
188557 --
188558 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
188559 p_header_num => 0); -- 4262811
188560 --
188561 -- set accounting line options
188562 --
188563 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
188564 p_natural_side_code => 'D'
188565 , p_gain_or_loss_flag => 'N'
188566 , p_gl_transfer_mode_code => 'S'
188567 , p_acct_entry_type_code => 'A'
188568 , p_switch_side_flag => 'Y'
188569 , p_merge_duplicate_code => 'N'
188570 );
188571 --
188572 l_acc_rev_natural_side_code := 'C'; -- 4262811
188573 --
188574 --
188575 -- set accounting line type info
188576 --
188577 xla_ae_lines_pkg.SetAcctLineType
188578 (p_component_type => l_component_type
188579 ,p_event_type_code => l_event_type_code
188580 ,p_line_definition_owner_code => l_line_definition_owner_code
188581 ,p_line_definition_code => l_line_definition_code
188582 ,p_accounting_line_code => l_component_code
188583 ,p_accounting_line_type_code => l_component_type_code
188584 ,p_accounting_line_appl_id => l_component_appl_id
188585 ,p_amb_context_code => l_amb_context_code
188586 ,p_entity_code => l_entity_code
188587 ,p_event_class_code => l_event_class_code);
188588 --
188589 -- set accounting class
188590 --
188591 xla_ae_lines_pkg.SetAcctClass(
188592 p_accounting_class_code => 'OFFSET'
188593 , p_ae_header_id => l_ae_header_id
188594 );
188595
188596 --
188597 -- set rounding class
188598 --
188599 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
188600 'OFFSET';
188601
188602 --
188603 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
188604 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
188605 --
188606 -- bulk performance
188607 --
188608 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
188609
188610 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
188611 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
188612
188613 -- 4955764
188614 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
188615 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
188616
188617 -- 4458381 Public Sector Enh
188618
188619 --
188620 -- set accounting attributes for the line type
188621 --
188622 l_entered_amt_idx := 3;
188623 l_accted_amt_idx := 8;
188624 l_bflow_applied_to_amt_idx := NULL; -- 5132302
188625 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
188626 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
188627 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
188628 l_rec_acct_attrs.array_char_value(2) := p_source_85;
188629 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
188630 l_rec_acct_attrs.array_num_value(3) := p_source_91;
188631 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
188632 l_rec_acct_attrs.array_char_value(4) := p_source_88;
188633 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
188634 l_rec_acct_attrs.array_date_value(5) := p_source_92;
188635 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
188636 l_rec_acct_attrs.array_num_value(6) := p_source_93;
188637 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
188638 l_rec_acct_attrs.array_char_value(7) := p_source_94;
188639 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
188640 l_rec_acct_attrs.array_num_value(8) := p_source_95;
188641
188642 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
188643 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
188644
188645 ---------------------------------------------------------------------------------------------------------------
188646 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
188647 ---------------------------------------------------------------------------------------------------------------
188648 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
188649
188650 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
188651 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
188652
188653 IF xla_accounting_cache_pkg.GetValueChar
188654 (p_source_code => 'LEDGER_CATEGORY_CODE'
188655 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
188656 AND l_bflow_method_code = 'PRIOR_ENTRY'
188657 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
188658 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
188659 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
188660 )
188661 THEN
188662 xla_ae_lines_pkg.BflowUpgEntry
188663 (p_business_method_code => l_bflow_method_code
188664 ,p_business_class_code => l_bflow_class_code
188665 ,p_balance_type => l_balance_type_code);
188666 ELSE
188667 NULL;
188668 -- No business flow processing for business flow method of NONE.
188669 END IF;
188670
188671 --
188672 -- call analytical criteria
188673 --
188674
188675 --
188676 -- call description
188677 --
188678
188679 xla_ae_lines_pkg.SetLineDescription(
188680 p_ae_header_id => l_ae_header_id
188681 ,p_description => Description_1 (
188682 p_application_id => p_application_id
188683 , p_ae_header_id => l_ae_header_id
188684 , p_source_1 => p_source_1
188685 , p_source_2 => p_source_2
188686 , p_source_3 => p_source_3
188687 , p_source_4 => p_source_4
188688 , p_source_5 => p_source_5
188689 )
188690 );
188691
188692
188693 --
188694 -- call ADRs
188695 -- Bug 4922099
188696 --
188697 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
188698 (NVL(l_actual_upg_option, 'N') = 'O') OR
188699 (NVL(l_enc_upg_option, 'N') = 'O')
188700 )
188701 THEN
188702 NULL;
188703 --
188704 --
188705
188706 l_ccid := AcctDerRule_6(
188707 p_application_id => p_application_id
188708 , p_ae_header_id => l_ae_header_id
188709 , p_source_11 => p_source_11
188710 , x_transaction_coa_id => l_adr_transaction_coa_id
188711 , x_accounting_coa_id => l_adr_accounting_coa_id
188712 , x_value_type_code => l_adr_value_type_code
188713 , p_side => 'NA'
188714 );
188715
188716 xla_ae_lines_pkg.set_ccid(
188717 p_code_combination_id => l_ccid
188718 , p_value_type_code => l_adr_value_type_code
188719 , p_transaction_coa_id => l_adr_transaction_coa_id
188720 , p_accounting_coa_id => l_adr_accounting_coa_id
188721 , p_adr_code => 'CST_DEFAULT'
188722 , p_adr_type_code => 'S'
188723 , p_component_type => l_component_type
188724 , p_component_code => l_component_code
188725 , p_component_type_code => l_component_type_code
188726 , p_component_appl_id => l_component_appl_id
188727 , p_amb_context_code => l_amb_context_code
188728 , p_side => 'NA'
188729 );
188730
188731
188732 --
188733 --
188734 END IF;
188735 --
188736 -- Bug 4922099
188737 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
188738 (NVL(l_enc_upg_option, 'N') = 'O')
188739 ) AND
188740 (l_bflow_method_code = 'PRIOR_ENTRY')
188741 )
188742 THEN
188743 IF
188744 --
188745 1 = 2
188746 --
188747 THEN
188748 xla_accounting_err_pkg.build_message
188749 (p_appli_s_name => 'XLA'
188750 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
188751 ,p_token_1 => 'LINE_NUMBER'
188752 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
188753 ,p_token_2 => 'LINE_TYPE_NAME'
188754 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
188755 l_component_type
188756 ,l_component_code
188757 ,l_component_type_code
188758 ,l_component_appl_id
188759 ,l_amb_context_code
188760 ,l_entity_code
188761 ,l_event_class_code
188762 )
188763 ,p_token_3 => 'OWNER'
188764 ,p_value_3 => xla_lookups_pkg.get_meaning(
188765 p_lookup_type => 'XLA_OWNER_TYPE'
188766 ,p_lookup_code => l_component_type_code
188767 )
188768 ,p_token_4 => 'PRODUCT_NAME'
188769 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
188770 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
188771 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
188772 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
188773 ,p_ae_header_id => NULL
188774 );
188775
188776 IF (C_LEVEL_ERROR>= g_log_level) THEN
188777 trace
188778 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
188779 ,p_level => C_LEVEL_ERROR
188780 ,p_module => l_log_module);
188781 END IF;
188782 END IF;
188783 END IF;
188784 --
188785 --
188786 ------------------------------------------------------------------------------------------------
188787 -- 4219869 Business Flow
188788 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
188789 -- Prior Entry. Currently, the following code is always generated.
188790 ------------------------------------------------------------------------------------------------
188791 XLA_AE_LINES_PKG.ValidateCurrentLine;
188792
188793 ------------------------------------------------------------------------------------
188794 -- 4219869 Business Flow
188795 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
188796 ------------------------------------------------------------------------------------
188797 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
188798
188799 ----------------------------------------------------------------------------------
188800 -- 4219869 Business Flow
188801 -- Update journal entry status -- Need to generate this within IF <condition>
188802 ----------------------------------------------------------------------------------
188803 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
188804 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
188805 ,p_balance_type_code => l_balance_type_code
188806 );
188807
188808 -------------------------------------------------------------------------------------------
188809 -- 4262811 - Generate the Accrual Reversal lines
188810 -------------------------------------------------------------------------------------------
188811 BEGIN
188812 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
188813 (g_array_event(p_event_id).array_value_num('header_index'));
188814 IF l_acc_rev_flag IS NULL THEN
188815 l_acc_rev_flag := 'N';
188816 END IF;
188817 EXCEPTION
188818 WHEN OTHERS THEN
188819 l_acc_rev_flag := 'N';
188820 END;
188821 --
188822 IF (l_acc_rev_flag = 'Y') THEN
188823
188824 -- 4645092 ------------------------------------------------------------------------------
188825 -- To allow MPA report to determine if it should generate report process
188826 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
188827 ------------------------------------------------------------------------------------------
188828
188829 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
188830 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
188831 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
188832 -- call ADRs
188833 -- Bug 4922099
188834 --
188835 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
188836 (NVL(l_actual_upg_option, 'N') = 'O') OR
188837 (NVL(l_enc_upg_option, 'N') = 'O')
188838 )
188839 THEN
188840 NULL;
188841 --
188842 --
188843
188844 l_ccid := AcctDerRule_6(
188845 p_application_id => p_application_id
188846 , p_ae_header_id => l_ae_header_id
188847 , p_source_11 => p_source_11
188848 , x_transaction_coa_id => l_adr_transaction_coa_id
188849 , x_accounting_coa_id => l_adr_accounting_coa_id
188850 , x_value_type_code => l_adr_value_type_code
188851 , p_side => 'NA'
188852 );
188853
188854 xla_ae_lines_pkg.set_ccid(
188855 p_code_combination_id => l_ccid
188856 , p_value_type_code => l_adr_value_type_code
188857 , p_transaction_coa_id => l_adr_transaction_coa_id
188858 , p_accounting_coa_id => l_adr_accounting_coa_id
188859 , p_adr_code => 'CST_DEFAULT'
188860 , p_adr_type_code => 'S'
188861 , p_component_type => l_component_type
188862 , p_component_code => l_component_code
188863 , p_component_type_code => l_component_type_code
188864 , p_component_appl_id => l_component_appl_id
188865 , p_amb_context_code => l_amb_context_code
188866 , p_side => 'NA'
188867 );
188868
188869
188870 --
188871 --
188872 END IF;
188873
188874 --
188875 -- Update the line information that should be overwritten
188876 --
188877 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
188878 p_header_num => 1);
188879 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
188880
188881 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
188882
188883 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
188884 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
188885 END IF;
188886
188887 --
188888 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
188889 --
188890 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
188891 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
188892 ELSE
188893 ---------------------------------------------------------------------------------------------------
188894 -- 4262811a Switch Sign
188895 ---------------------------------------------------------------------------------------------------
188896 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
188897 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
188898 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188899 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
188900 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188901 -- 5132302
188902 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
188903 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
188904
188905 END IF;
188906
188907 -- 4955764
188908 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
188909 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
188910
188911
188912 XLA_AE_LINES_PKG.ValidateCurrentLine;
188913 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
188914
188915 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
188916 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
188917 ,p_balance_type_code => l_balance_type_code);
188918
188919 END IF;
188920
188921 -----------------------------------------------------------------------------------------
188922 -- 4262811 Multiperiod Accounting
188923 -----------------------------------------------------------------------------------------
188924 -- No MPA option is assigned.
188925
188926
188927 END IF;
188928 END IF;
188929 --
188930
188931 --
188932 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
188933 trace
188934 (p_msg => 'END of AcctLineType_346'
188935 ,p_level => C_LEVEL_PROCEDURE
188936 ,p_module => l_log_module);
188937 END IF;
188938 --
188939 EXCEPTION
188940 WHEN xla_exceptions_pkg.application_exception THEN
188941 RAISE;
188942 WHEN OTHERS THEN
188943 xla_exceptions_pkg.raise_message
188944 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_346');
188945 END AcctLineType_346;
188946 --
188947
188948 ---------------------------------------
188949 --
188950 -- PRIVATE FUNCTION
188951 -- AcctLineType_347
188952 --
188953 ---------------------------------------
188954 PROCEDURE AcctLineType_347 (
188955 p_application_id IN NUMBER
188956 ,p_event_id IN NUMBER
188957 ,p_calculate_acctd_flag IN VARCHAR2
188958 ,p_calculate_g_l_flag IN VARCHAR2
188959 ,p_actual_flag IN OUT VARCHAR2
188960 ,p_balance_type_code OUT VARCHAR2
188961 ,p_gain_or_loss_ref OUT VARCHAR2
188962
188963 --TRANSACTION_ID
188964 , p_source_1 IN NUMBER
188965 --Item Concatenated Segments
188966 , p_source_2 IN VARCHAR2
188967 --Transaction Quantity
188968 , p_source_3 IN NUMBER
188969 --Transaction Unit of Measure Code
188970 , p_source_4 IN VARCHAR2
188971 --Inventory Transaction Type Description
188972 , p_source_5 IN VARCHAR2
188973 --Cost Management Default Account
188974 , p_source_11 IN NUMBER
188975 --DISTRIBUTION_IDENTIFIER
188976 , p_source_84 IN NUMBER
188977 --Distribution Type
188978 , p_source_85 IN VARCHAR2
188979 , p_source_85_meaning IN VARCHAR2
188980 --Entered Currency Code
188981 , p_source_88 IN VARCHAR2
188982 --Entered Amount
188983 , p_source_91 IN NUMBER
188984 --Currency Conversion Date
188985 , p_source_92 IN DATE
188986 --Currency Conversion Rate
188987 , p_source_93 IN NUMBER
188988 --Currency Conversion Type
188989 , p_source_94 IN VARCHAR2
188990 --Accounted Amount
188991 , p_source_95 IN NUMBER
188992 --Accounting Line Type
188993 , p_source_97 IN NUMBER
188994 )
188995 IS
188996
188997 l_component_type VARCHAR2(80);
188998 l_component_code VARCHAR2(30);
188999 l_component_type_code VARCHAR2(1);
189000 l_component_appl_id INTEGER;
189001 l_amb_context_code VARCHAR2(30);
189002 l_entity_code VARCHAR2(30);
189003 l_event_class_code VARCHAR2(30);
189004 l_ae_header_id NUMBER;
189005 l_event_type_code VARCHAR2(30);
189006 l_line_definition_code VARCHAR2(30);
189007 l_line_definition_owner_code VARCHAR2(1);
189008 --
189009 -- adr variables
189010 l_segment VARCHAR2(30);
189011 l_ccid NUMBER;
189012 l_adr_transaction_coa_id NUMBER;
189013 l_adr_accounting_coa_id NUMBER;
189014 l_adr_flexfield_segment_code VARCHAR2(30);
189015 l_adr_flex_value_set_id NUMBER;
189016 l_adr_value_type_code VARCHAR2(30);
189017 l_adr_value_combination_id NUMBER;
189018 l_adr_value_segment_code VARCHAR2(30);
189019
189020 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
189021 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
189022 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
189023 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
189024
189025 -- 4262811 Variables ------------------------------------------------------------------------------------------
189026 l_entered_amt_idx NUMBER;
189027 l_accted_amt_idx NUMBER;
189028 l_acc_rev_flag VARCHAR2(1);
189029 l_accrual_line_num NUMBER;
189030 l_tmp_amt NUMBER;
189031 l_acc_rev_natural_side_code VARCHAR2(1);
189032
189033 l_num_entries NUMBER;
189034 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
189035 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
189036 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
189037 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
189038 l_recog_line_1 NUMBER;
189039 l_recog_line_2 NUMBER;
189040
189041 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
189042 l_bflow_applied_to_amt NUMBER; -- 5132302
189043 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
189044
189045 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
189046
189047 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
189048 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
189049
189050 ---------------------------------------------------------------------------------------------------------------
189051
189052
189053 --
189054 -- bulk performance
189055 --
189056 l_balance_type_code VARCHAR2(1);
189057 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
189058 l_log_module VARCHAR2(240);
189059
189060 --
189061 -- Upgrade strategy
189062 --
189063 l_actual_upg_option VARCHAR2(1);
189064 l_enc_upg_option VARCHAR2(1);
189065
189066 --
189067 BEGIN
189068 --
189069 IF g_log_enabled THEN
189070 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_347';
189071 END IF;
189072 --
189073 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
189074
189075 trace
189076 (p_msg => 'BEGIN of AcctLineType_347'
189077 ,p_level => C_LEVEL_PROCEDURE
189078 ,p_module => l_log_module);
189079
189080 END IF;
189081 --
189082 l_component_type := 'AMB_JLT';
189083 l_component_code := 'OFFSET';
189084 l_component_type_code := 'S';
189085 l_component_appl_id := 707;
189086 l_amb_context_code := 'DEFAULT';
189087 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
189088 l_event_class_code := 'FOB_RCPT_SENDER_RCPT';
189089 l_event_type_code := 'FOB_RCPT_SENDER_RCPT_NO_TP';
189090 l_line_definition_owner_code := 'S';
189091 l_line_definition_code := 'PI_FOB_RCPT_SENDER_RCPT_NTP';
189092 --
189093 l_balance_type_code := 'A';
189094 l_segment := NULL;
189095 l_ccid := NULL;
189096 l_adr_transaction_coa_id := NULL;
189097 l_adr_accounting_coa_id := NULL;
189098 l_adr_flexfield_segment_code := NULL;
189099 l_adr_flex_value_set_id := NULL;
189100 l_adr_value_type_code := NULL;
189101 l_adr_value_combination_id := NULL;
189102 l_adr_value_segment_code := NULL;
189103
189104 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
189105 l_bflow_class_code := ''; -- 4219869 Business Flow
189106 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
189107 l_budgetary_control_flag := 'N';
189108
189109 l_bflow_applied_to_amt_idx := NULL; -- 5132302
189110 l_bflow_applied_to_amt := NULL; -- 5132302
189111 l_entered_amt_idx := NULL; -- 4262811
189112 l_accted_amt_idx := NULL; -- 4262811
189113 l_acc_rev_flag := NULL; -- 4262811
189114 l_accrual_line_num := NULL; -- 4262811
189115 l_tmp_amt := NULL; -- 4262811
189116 --
189117
189118 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
189119 l_balance_type_code <> 'B' THEN
189120 IF NVL(p_source_97,9E125) = 2 AND
189121 p_source_95 <= 0
189122 THEN
189123
189124 --
189125 XLA_AE_LINES_PKG.SetNewLine;
189126
189127 p_balance_type_code := l_balance_type_code;
189128 -- set the flag so later we will know whether the gain loss line needs to be created
189129
189130 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
189131 p_actual_flag :='A';
189132 END IF;
189133
189134 --
189135 -- bulk performance
189136 --
189137 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
189138 p_header_num => 0); -- 4262811
189139 --
189140 -- set accounting line options
189141 --
189142 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
189143 p_natural_side_code => 'D'
189144 , p_gain_or_loss_flag => 'N'
189145 , p_gl_transfer_mode_code => 'S'
189146 , p_acct_entry_type_code => 'A'
189147 , p_switch_side_flag => 'Y'
189148 , p_merge_duplicate_code => 'N'
189149 );
189150 --
189151 l_acc_rev_natural_side_code := 'C'; -- 4262811
189152 --
189153 --
189154 -- set accounting line type info
189155 --
189156 xla_ae_lines_pkg.SetAcctLineType
189157 (p_component_type => l_component_type
189158 ,p_event_type_code => l_event_type_code
189159 ,p_line_definition_owner_code => l_line_definition_owner_code
189160 ,p_line_definition_code => l_line_definition_code
189161 ,p_accounting_line_code => l_component_code
189162 ,p_accounting_line_type_code => l_component_type_code
189163 ,p_accounting_line_appl_id => l_component_appl_id
189164 ,p_amb_context_code => l_amb_context_code
189165 ,p_entity_code => l_entity_code
189166 ,p_event_class_code => l_event_class_code);
189167 --
189168 -- set accounting class
189169 --
189170 xla_ae_lines_pkg.SetAcctClass(
189171 p_accounting_class_code => 'OFFSET'
189172 , p_ae_header_id => l_ae_header_id
189173 );
189174
189175 --
189176 -- set rounding class
189177 --
189178 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
189179 'OFFSET';
189180
189181 --
189182 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
189183 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
189184 --
189185 -- bulk performance
189186 --
189187 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
189188
189189 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
189190 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
189191
189192 -- 4955764
189193 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
189194 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
189195
189196 -- 4458381 Public Sector Enh
189197
189198 --
189199 -- set accounting attributes for the line type
189200 --
189201 l_entered_amt_idx := 3;
189202 l_accted_amt_idx := 8;
189203 l_bflow_applied_to_amt_idx := NULL; -- 5132302
189204 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
189205 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
189206 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
189207 l_rec_acct_attrs.array_char_value(2) := p_source_85;
189208 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
189209 l_rec_acct_attrs.array_num_value(3) := p_source_91;
189210 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
189211 l_rec_acct_attrs.array_char_value(4) := p_source_88;
189212 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
189213 l_rec_acct_attrs.array_date_value(5) := p_source_92;
189214 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
189215 l_rec_acct_attrs.array_num_value(6) := p_source_93;
189216 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
189217 l_rec_acct_attrs.array_char_value(7) := p_source_94;
189218 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
189219 l_rec_acct_attrs.array_num_value(8) := p_source_95;
189220
189221 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
189222 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
189223
189224 ---------------------------------------------------------------------------------------------------------------
189225 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
189226 ---------------------------------------------------------------------------------------------------------------
189227 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
189228
189229 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
189230 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
189231
189232 IF xla_accounting_cache_pkg.GetValueChar
189233 (p_source_code => 'LEDGER_CATEGORY_CODE'
189234 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
189235 AND l_bflow_method_code = 'PRIOR_ENTRY'
189236 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
189237 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
189238 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
189239 )
189240 THEN
189241 xla_ae_lines_pkg.BflowUpgEntry
189242 (p_business_method_code => l_bflow_method_code
189243 ,p_business_class_code => l_bflow_class_code
189244 ,p_balance_type => l_balance_type_code);
189245 ELSE
189246 NULL;
189247 -- No business flow processing for business flow method of NONE.
189248 END IF;
189249
189250 --
189251 -- call analytical criteria
189252 --
189253
189254 --
189255 -- call description
189256 --
189257
189258 xla_ae_lines_pkg.SetLineDescription(
189259 p_ae_header_id => l_ae_header_id
189260 ,p_description => Description_1 (
189261 p_application_id => p_application_id
189262 , p_ae_header_id => l_ae_header_id
189263 , p_source_1 => p_source_1
189264 , p_source_2 => p_source_2
189265 , p_source_3 => p_source_3
189266 , p_source_4 => p_source_4
189267 , p_source_5 => p_source_5
189268 )
189269 );
189270
189271
189272 --
189273 -- call ADRs
189274 -- Bug 4922099
189275 --
189276 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
189277 (NVL(l_actual_upg_option, 'N') = 'O') OR
189278 (NVL(l_enc_upg_option, 'N') = 'O')
189279 )
189280 THEN
189281 NULL;
189282 --
189283 --
189284
189285 l_ccid := AcctDerRule_6(
189286 p_application_id => p_application_id
189287 , p_ae_header_id => l_ae_header_id
189288 , p_source_11 => p_source_11
189289 , x_transaction_coa_id => l_adr_transaction_coa_id
189290 , x_accounting_coa_id => l_adr_accounting_coa_id
189291 , x_value_type_code => l_adr_value_type_code
189292 , p_side => 'NA'
189293 );
189294
189295 xla_ae_lines_pkg.set_ccid(
189296 p_code_combination_id => l_ccid
189297 , p_value_type_code => l_adr_value_type_code
189298 , p_transaction_coa_id => l_adr_transaction_coa_id
189299 , p_accounting_coa_id => l_adr_accounting_coa_id
189300 , p_adr_code => 'CST_DEFAULT'
189301 , p_adr_type_code => 'S'
189302 , p_component_type => l_component_type
189303 , p_component_code => l_component_code
189304 , p_component_type_code => l_component_type_code
189305 , p_component_appl_id => l_component_appl_id
189306 , p_amb_context_code => l_amb_context_code
189307 , p_side => 'NA'
189308 );
189309
189310
189311 --
189312 --
189313 END IF;
189314 --
189315 -- Bug 4922099
189316 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
189317 (NVL(l_enc_upg_option, 'N') = 'O')
189318 ) AND
189319 (l_bflow_method_code = 'PRIOR_ENTRY')
189320 )
189321 THEN
189322 IF
189323 --
189324 1 = 2
189325 --
189326 THEN
189327 xla_accounting_err_pkg.build_message
189328 (p_appli_s_name => 'XLA'
189329 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
189330 ,p_token_1 => 'LINE_NUMBER'
189331 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
189332 ,p_token_2 => 'LINE_TYPE_NAME'
189333 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
189334 l_component_type
189335 ,l_component_code
189336 ,l_component_type_code
189337 ,l_component_appl_id
189338 ,l_amb_context_code
189339 ,l_entity_code
189340 ,l_event_class_code
189341 )
189342 ,p_token_3 => 'OWNER'
189343 ,p_value_3 => xla_lookups_pkg.get_meaning(
189344 p_lookup_type => 'XLA_OWNER_TYPE'
189345 ,p_lookup_code => l_component_type_code
189346 )
189347 ,p_token_4 => 'PRODUCT_NAME'
189348 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
189349 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
189350 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
189351 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
189352 ,p_ae_header_id => NULL
189353 );
189354
189355 IF (C_LEVEL_ERROR>= g_log_level) THEN
189356 trace
189357 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
189358 ,p_level => C_LEVEL_ERROR
189359 ,p_module => l_log_module);
189360 END IF;
189361 END IF;
189362 END IF;
189363 --
189364 --
189365 ------------------------------------------------------------------------------------------------
189366 -- 4219869 Business Flow
189367 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
189368 -- Prior Entry. Currently, the following code is always generated.
189369 ------------------------------------------------------------------------------------------------
189370 XLA_AE_LINES_PKG.ValidateCurrentLine;
189371
189372 ------------------------------------------------------------------------------------
189373 -- 4219869 Business Flow
189374 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
189375 ------------------------------------------------------------------------------------
189376 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
189377
189378 ----------------------------------------------------------------------------------
189379 -- 4219869 Business Flow
189380 -- Update journal entry status -- Need to generate this within IF <condition>
189381 ----------------------------------------------------------------------------------
189382 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
189383 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
189384 ,p_balance_type_code => l_balance_type_code
189385 );
189386
189387 -------------------------------------------------------------------------------------------
189388 -- 4262811 - Generate the Accrual Reversal lines
189389 -------------------------------------------------------------------------------------------
189390 BEGIN
189391 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
189392 (g_array_event(p_event_id).array_value_num('header_index'));
189393 IF l_acc_rev_flag IS NULL THEN
189394 l_acc_rev_flag := 'N';
189395 END IF;
189396 EXCEPTION
189397 WHEN OTHERS THEN
189398 l_acc_rev_flag := 'N';
189399 END;
189400 --
189401 IF (l_acc_rev_flag = 'Y') THEN
189402
189403 -- 4645092 ------------------------------------------------------------------------------
189404 -- To allow MPA report to determine if it should generate report process
189405 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
189406 ------------------------------------------------------------------------------------------
189407
189408 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
189409 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
189410 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
189411 -- call ADRs
189412 -- Bug 4922099
189413 --
189414 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
189415 (NVL(l_actual_upg_option, 'N') = 'O') OR
189416 (NVL(l_enc_upg_option, 'N') = 'O')
189417 )
189418 THEN
189419 NULL;
189420 --
189421 --
189422
189423 l_ccid := AcctDerRule_6(
189424 p_application_id => p_application_id
189425 , p_ae_header_id => l_ae_header_id
189426 , p_source_11 => p_source_11
189427 , x_transaction_coa_id => l_adr_transaction_coa_id
189428 , x_accounting_coa_id => l_adr_accounting_coa_id
189429 , x_value_type_code => l_adr_value_type_code
189430 , p_side => 'NA'
189431 );
189432
189433 xla_ae_lines_pkg.set_ccid(
189434 p_code_combination_id => l_ccid
189435 , p_value_type_code => l_adr_value_type_code
189436 , p_transaction_coa_id => l_adr_transaction_coa_id
189437 , p_accounting_coa_id => l_adr_accounting_coa_id
189438 , p_adr_code => 'CST_DEFAULT'
189439 , p_adr_type_code => 'S'
189440 , p_component_type => l_component_type
189441 , p_component_code => l_component_code
189442 , p_component_type_code => l_component_type_code
189443 , p_component_appl_id => l_component_appl_id
189444 , p_amb_context_code => l_amb_context_code
189445 , p_side => 'NA'
189446 );
189447
189448
189449 --
189450 --
189451 END IF;
189452
189453 --
189454 -- Update the line information that should be overwritten
189455 --
189456 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
189457 p_header_num => 1);
189458 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
189459
189460 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
189461
189462 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
189463 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
189464 END IF;
189465
189466 --
189467 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
189468 --
189469 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
189470 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
189471 ELSE
189472 ---------------------------------------------------------------------------------------------------
189473 -- 4262811a Switch Sign
189474 ---------------------------------------------------------------------------------------------------
189475 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
189476 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
189477 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
189478 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
189479 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
189480 -- 5132302
189481 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
189482 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
189483
189484 END IF;
189485
189486 -- 4955764
189487 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
189488 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
189489
189490
189491 XLA_AE_LINES_PKG.ValidateCurrentLine;
189492 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
189493
189494 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
189495 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
189496 ,p_balance_type_code => l_balance_type_code);
189497
189498 END IF;
189499
189500 -----------------------------------------------------------------------------------------
189501 -- 4262811 Multiperiod Accounting
189502 -----------------------------------------------------------------------------------------
189503 -- No MPA option is assigned.
189504
189505
189506 END IF;
189507 END IF;
189508 --
189509
189510 --
189511 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
189512 trace
189513 (p_msg => 'END of AcctLineType_347'
189514 ,p_level => C_LEVEL_PROCEDURE
189515 ,p_module => l_log_module);
189516 END IF;
189517 --
189518 EXCEPTION
189519 WHEN xla_exceptions_pkg.application_exception THEN
189520 RAISE;
189521 WHEN OTHERS THEN
189522 xla_exceptions_pkg.raise_message
189523 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_347');
189524 END AcctLineType_347;
189525 --
189526
189527 ---------------------------------------
189528 --
189529 -- PRIVATE FUNCTION
189530 -- AcctLineType_348
189531 --
189532 ---------------------------------------
189533 PROCEDURE AcctLineType_348 (
189534 p_application_id IN NUMBER
189535 ,p_event_id IN NUMBER
189536 ,p_calculate_acctd_flag IN VARCHAR2
189537 ,p_calculate_g_l_flag IN VARCHAR2
189538 ,p_actual_flag IN OUT VARCHAR2
189539 ,p_balance_type_code OUT VARCHAR2
189540 ,p_gain_or_loss_ref OUT VARCHAR2
189541
189542 --TRANSACTION_ID
189543 , p_source_1 IN NUMBER
189544 --Item Concatenated Segments
189545 , p_source_2 IN VARCHAR2
189546 --Transaction Quantity
189547 , p_source_3 IN NUMBER
189548 --Transaction Unit of Measure Code
189549 , p_source_4 IN VARCHAR2
189550 --Inventory Transaction Type Description
189551 , p_source_5 IN VARCHAR2
189552 --Cost Management Default Account
189553 , p_source_11 IN NUMBER
189554 --DISTRIBUTION_IDENTIFIER
189555 , p_source_84 IN NUMBER
189556 --Distribution Type
189557 , p_source_85 IN VARCHAR2
189558 , p_source_85_meaning IN VARCHAR2
189559 --Entered Currency Code
189560 , p_source_88 IN VARCHAR2
189561 --Entered Amount
189562 , p_source_91 IN NUMBER
189563 --Currency Conversion Date
189564 , p_source_92 IN DATE
189565 --Currency Conversion Rate
189566 , p_source_93 IN NUMBER
189567 --Currency Conversion Type
189568 , p_source_94 IN VARCHAR2
189569 --Accounted Amount
189570 , p_source_95 IN NUMBER
189571 --Accounting Line Type
189572 , p_source_97 IN NUMBER
189573 )
189574 IS
189575
189576 l_component_type VARCHAR2(80);
189577 l_component_code VARCHAR2(30);
189578 l_component_type_code VARCHAR2(1);
189579 l_component_appl_id INTEGER;
189580 l_amb_context_code VARCHAR2(30);
189581 l_entity_code VARCHAR2(30);
189582 l_event_class_code VARCHAR2(30);
189583 l_ae_header_id NUMBER;
189584 l_event_type_code VARCHAR2(30);
189585 l_line_definition_code VARCHAR2(30);
189586 l_line_definition_owner_code VARCHAR2(1);
189587 --
189588 -- adr variables
189589 l_segment VARCHAR2(30);
189590 l_ccid NUMBER;
189591 l_adr_transaction_coa_id NUMBER;
189592 l_adr_accounting_coa_id NUMBER;
189593 l_adr_flexfield_segment_code VARCHAR2(30);
189594 l_adr_flex_value_set_id NUMBER;
189595 l_adr_value_type_code VARCHAR2(30);
189596 l_adr_value_combination_id NUMBER;
189597 l_adr_value_segment_code VARCHAR2(30);
189598
189599 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
189600 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
189601 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
189602 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
189603
189604 -- 4262811 Variables ------------------------------------------------------------------------------------------
189605 l_entered_amt_idx NUMBER;
189606 l_accted_amt_idx NUMBER;
189607 l_acc_rev_flag VARCHAR2(1);
189608 l_accrual_line_num NUMBER;
189609 l_tmp_amt NUMBER;
189610 l_acc_rev_natural_side_code VARCHAR2(1);
189611
189612 l_num_entries NUMBER;
189613 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
189614 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
189615 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
189616 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
189617 l_recog_line_1 NUMBER;
189618 l_recog_line_2 NUMBER;
189619
189620 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
189621 l_bflow_applied_to_amt NUMBER; -- 5132302
189622 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
189623
189624 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
189625
189626 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
189627 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
189628
189629 ---------------------------------------------------------------------------------------------------------------
189630
189631
189632 --
189633 -- bulk performance
189634 --
189635 l_balance_type_code VARCHAR2(1);
189636 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
189637 l_log_module VARCHAR2(240);
189638
189639 --
189640 -- Upgrade strategy
189641 --
189642 l_actual_upg_option VARCHAR2(1);
189643 l_enc_upg_option VARCHAR2(1);
189644
189645 --
189646 BEGIN
189647 --
189648 IF g_log_enabled THEN
189649 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_348';
189650 END IF;
189651 --
189652 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
189653
189654 trace
189655 (p_msg => 'BEGIN of AcctLineType_348'
189656 ,p_level => C_LEVEL_PROCEDURE
189657 ,p_module => l_log_module);
189658
189659 END IF;
189660 --
189661 l_component_type := 'AMB_JLT';
189662 l_component_code := 'OFFSET';
189663 l_component_type_code := 'S';
189664 l_component_appl_id := 707;
189665 l_amb_context_code := 'DEFAULT';
189666 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
189667 l_event_class_code := 'FOB_RCPT_SENDER_SHIP';
189668 l_event_type_code := 'FOB_RCPT_SENDER_SHIP';
189669 l_line_definition_owner_code := 'S';
189670 l_line_definition_code := 'PI_FOB_RCPT_SENDER_SHIP';
189671 --
189672 l_balance_type_code := 'A';
189673 l_segment := NULL;
189674 l_ccid := NULL;
189675 l_adr_transaction_coa_id := NULL;
189676 l_adr_accounting_coa_id := NULL;
189677 l_adr_flexfield_segment_code := NULL;
189678 l_adr_flex_value_set_id := NULL;
189679 l_adr_value_type_code := NULL;
189680 l_adr_value_combination_id := NULL;
189681 l_adr_value_segment_code := NULL;
189682
189683 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
189684 l_bflow_class_code := ''; -- 4219869 Business Flow
189685 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
189686 l_budgetary_control_flag := 'N';
189687
189688 l_bflow_applied_to_amt_idx := NULL; -- 5132302
189689 l_bflow_applied_to_amt := NULL; -- 5132302
189690 l_entered_amt_idx := NULL; -- 4262811
189691 l_accted_amt_idx := NULL; -- 4262811
189692 l_acc_rev_flag := NULL; -- 4262811
189693 l_accrual_line_num := NULL; -- 4262811
189694 l_tmp_amt := NULL; -- 4262811
189695 --
189696
189697 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
189698 l_balance_type_code <> 'B' THEN
189699 IF NVL(p_source_97,9E125) = 2
189700 THEN
189701
189702 --
189703 XLA_AE_LINES_PKG.SetNewLine;
189704
189705 p_balance_type_code := l_balance_type_code;
189706 -- set the flag so later we will know whether the gain loss line needs to be created
189707
189708 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
189709 p_actual_flag :='A';
189710 END IF;
189711
189712 --
189713 -- bulk performance
189714 --
189715 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
189716 p_header_num => 0); -- 4262811
189717 --
189718 -- set accounting line options
189719 --
189720 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
189721 p_natural_side_code => 'D'
189722 , p_gain_or_loss_flag => 'N'
189723 , p_gl_transfer_mode_code => 'S'
189724 , p_acct_entry_type_code => 'A'
189725 , p_switch_side_flag => 'Y'
189726 , p_merge_duplicate_code => 'N'
189727 );
189728 --
189729 l_acc_rev_natural_side_code := 'C'; -- 4262811
189730 --
189731 --
189732 -- set accounting line type info
189733 --
189734 xla_ae_lines_pkg.SetAcctLineType
189735 (p_component_type => l_component_type
189736 ,p_event_type_code => l_event_type_code
189737 ,p_line_definition_owner_code => l_line_definition_owner_code
189738 ,p_line_definition_code => l_line_definition_code
189739 ,p_accounting_line_code => l_component_code
189740 ,p_accounting_line_type_code => l_component_type_code
189741 ,p_accounting_line_appl_id => l_component_appl_id
189742 ,p_amb_context_code => l_amb_context_code
189743 ,p_entity_code => l_entity_code
189744 ,p_event_class_code => l_event_class_code);
189745 --
189746 -- set accounting class
189747 --
189748 xla_ae_lines_pkg.SetAcctClass(
189749 p_accounting_class_code => 'OFFSET'
189750 , p_ae_header_id => l_ae_header_id
189751 );
189752
189753 --
189754 -- set rounding class
189755 --
189756 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
189757 'OFFSET';
189758
189759 --
189760 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
189761 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
189762 --
189763 -- bulk performance
189764 --
189765 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
189766
189767 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
189768 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
189769
189770 -- 4955764
189771 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
189772 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
189773
189774 -- 4458381 Public Sector Enh
189775
189776 --
189777 -- set accounting attributes for the line type
189778 --
189779 l_entered_amt_idx := 3;
189780 l_accted_amt_idx := 8;
189781 l_bflow_applied_to_amt_idx := NULL; -- 5132302
189782 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
189783 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
189784 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
189785 l_rec_acct_attrs.array_char_value(2) := p_source_85;
189786 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
189787 l_rec_acct_attrs.array_num_value(3) := p_source_91;
189788 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
189789 l_rec_acct_attrs.array_char_value(4) := p_source_88;
189790 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
189791 l_rec_acct_attrs.array_date_value(5) := p_source_92;
189792 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
189793 l_rec_acct_attrs.array_num_value(6) := p_source_93;
189794 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
189795 l_rec_acct_attrs.array_char_value(7) := p_source_94;
189796 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
189797 l_rec_acct_attrs.array_num_value(8) := p_source_95;
189798
189799 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
189800 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
189801
189802 ---------------------------------------------------------------------------------------------------------------
189803 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
189804 ---------------------------------------------------------------------------------------------------------------
189805 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
189806
189807 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
189808 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
189809
189810 IF xla_accounting_cache_pkg.GetValueChar
189811 (p_source_code => 'LEDGER_CATEGORY_CODE'
189812 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
189813 AND l_bflow_method_code = 'PRIOR_ENTRY'
189814 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
189815 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
189816 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
189817 )
189818 THEN
189819 xla_ae_lines_pkg.BflowUpgEntry
189820 (p_business_method_code => l_bflow_method_code
189821 ,p_business_class_code => l_bflow_class_code
189822 ,p_balance_type => l_balance_type_code);
189823 ELSE
189824 NULL;
189825 -- No business flow processing for business flow method of NONE.
189826 END IF;
189827
189828 --
189829 -- call analytical criteria
189830 --
189831
189832 --
189833 -- call description
189834 --
189835
189836 xla_ae_lines_pkg.SetLineDescription(
189837 p_ae_header_id => l_ae_header_id
189838 ,p_description => Description_1 (
189839 p_application_id => p_application_id
189840 , p_ae_header_id => l_ae_header_id
189841 , p_source_1 => p_source_1
189842 , p_source_2 => p_source_2
189843 , p_source_3 => p_source_3
189844 , p_source_4 => p_source_4
189845 , p_source_5 => p_source_5
189846 )
189847 );
189848
189849
189850 --
189851 -- call ADRs
189852 -- Bug 4922099
189853 --
189854 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
189855 (NVL(l_actual_upg_option, 'N') = 'O') OR
189856 (NVL(l_enc_upg_option, 'N') = 'O')
189857 )
189858 THEN
189859 NULL;
189860 --
189861 --
189862
189863 l_ccid := AcctDerRule_6(
189864 p_application_id => p_application_id
189865 , p_ae_header_id => l_ae_header_id
189866 , p_source_11 => p_source_11
189867 , x_transaction_coa_id => l_adr_transaction_coa_id
189868 , x_accounting_coa_id => l_adr_accounting_coa_id
189869 , x_value_type_code => l_adr_value_type_code
189870 , p_side => 'NA'
189871 );
189872
189873 xla_ae_lines_pkg.set_ccid(
189874 p_code_combination_id => l_ccid
189875 , p_value_type_code => l_adr_value_type_code
189876 , p_transaction_coa_id => l_adr_transaction_coa_id
189877 , p_accounting_coa_id => l_adr_accounting_coa_id
189878 , p_adr_code => 'CST_DEFAULT'
189879 , p_adr_type_code => 'S'
189880 , p_component_type => l_component_type
189881 , p_component_code => l_component_code
189882 , p_component_type_code => l_component_type_code
189883 , p_component_appl_id => l_component_appl_id
189884 , p_amb_context_code => l_amb_context_code
189885 , p_side => 'NA'
189886 );
189887
189888
189889 --
189890 --
189891 END IF;
189892 --
189893 -- Bug 4922099
189894 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
189895 (NVL(l_enc_upg_option, 'N') = 'O')
189896 ) AND
189897 (l_bflow_method_code = 'PRIOR_ENTRY')
189898 )
189899 THEN
189900 IF
189901 --
189902 1 = 2
189903 --
189904 THEN
189905 xla_accounting_err_pkg.build_message
189906 (p_appli_s_name => 'XLA'
189907 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
189908 ,p_token_1 => 'LINE_NUMBER'
189909 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
189910 ,p_token_2 => 'LINE_TYPE_NAME'
189911 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
189912 l_component_type
189913 ,l_component_code
189914 ,l_component_type_code
189915 ,l_component_appl_id
189916 ,l_amb_context_code
189917 ,l_entity_code
189918 ,l_event_class_code
189919 )
189920 ,p_token_3 => 'OWNER'
189921 ,p_value_3 => xla_lookups_pkg.get_meaning(
189922 p_lookup_type => 'XLA_OWNER_TYPE'
189923 ,p_lookup_code => l_component_type_code
189924 )
189925 ,p_token_4 => 'PRODUCT_NAME'
189926 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
189927 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
189928 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
189929 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
189930 ,p_ae_header_id => NULL
189931 );
189932
189933 IF (C_LEVEL_ERROR>= g_log_level) THEN
189934 trace
189935 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
189936 ,p_level => C_LEVEL_ERROR
189937 ,p_module => l_log_module);
189938 END IF;
189939 END IF;
189940 END IF;
189941 --
189942 --
189943 ------------------------------------------------------------------------------------------------
189944 -- 4219869 Business Flow
189945 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
189946 -- Prior Entry. Currently, the following code is always generated.
189947 ------------------------------------------------------------------------------------------------
189948 XLA_AE_LINES_PKG.ValidateCurrentLine;
189949
189950 ------------------------------------------------------------------------------------
189951 -- 4219869 Business Flow
189952 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
189953 ------------------------------------------------------------------------------------
189954 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
189955
189956 ----------------------------------------------------------------------------------
189957 -- 4219869 Business Flow
189958 -- Update journal entry status -- Need to generate this within IF <condition>
189959 ----------------------------------------------------------------------------------
189960 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
189961 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
189962 ,p_balance_type_code => l_balance_type_code
189963 );
189964
189965 -------------------------------------------------------------------------------------------
189966 -- 4262811 - Generate the Accrual Reversal lines
189967 -------------------------------------------------------------------------------------------
189968 BEGIN
189969 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
189970 (g_array_event(p_event_id).array_value_num('header_index'));
189971 IF l_acc_rev_flag IS NULL THEN
189972 l_acc_rev_flag := 'N';
189973 END IF;
189974 EXCEPTION
189975 WHEN OTHERS THEN
189976 l_acc_rev_flag := 'N';
189977 END;
189978 --
189979 IF (l_acc_rev_flag = 'Y') THEN
189980
189981 -- 4645092 ------------------------------------------------------------------------------
189982 -- To allow MPA report to determine if it should generate report process
189983 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
189984 ------------------------------------------------------------------------------------------
189985
189986 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
189987 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
189988 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
189989 -- call ADRs
189990 -- Bug 4922099
189991 --
189992 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
189993 (NVL(l_actual_upg_option, 'N') = 'O') OR
189994 (NVL(l_enc_upg_option, 'N') = 'O')
189995 )
189996 THEN
189997 NULL;
189998 --
189999 --
190000
190001 l_ccid := AcctDerRule_6(
190002 p_application_id => p_application_id
190003 , p_ae_header_id => l_ae_header_id
190004 , p_source_11 => p_source_11
190005 , x_transaction_coa_id => l_adr_transaction_coa_id
190006 , x_accounting_coa_id => l_adr_accounting_coa_id
190007 , x_value_type_code => l_adr_value_type_code
190008 , p_side => 'NA'
190009 );
190010
190011 xla_ae_lines_pkg.set_ccid(
190012 p_code_combination_id => l_ccid
190013 , p_value_type_code => l_adr_value_type_code
190014 , p_transaction_coa_id => l_adr_transaction_coa_id
190015 , p_accounting_coa_id => l_adr_accounting_coa_id
190016 , p_adr_code => 'CST_DEFAULT'
190017 , p_adr_type_code => 'S'
190018 , p_component_type => l_component_type
190019 , p_component_code => l_component_code
190020 , p_component_type_code => l_component_type_code
190021 , p_component_appl_id => l_component_appl_id
190022 , p_amb_context_code => l_amb_context_code
190023 , p_side => 'NA'
190024 );
190025
190026
190027 --
190028 --
190029 END IF;
190030
190031 --
190032 -- Update the line information that should be overwritten
190033 --
190034 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
190035 p_header_num => 1);
190036 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
190037
190038 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
190039
190040 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
190041 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
190042 END IF;
190043
190044 --
190045 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
190046 --
190047 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
190048 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
190049 ELSE
190050 ---------------------------------------------------------------------------------------------------
190051 -- 4262811a Switch Sign
190052 ---------------------------------------------------------------------------------------------------
190053 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
190054 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
190055 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190056 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
190057 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190058 -- 5132302
190059 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
190060 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190061
190062 END IF;
190063
190064 -- 4955764
190065 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
190066 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
190067
190068
190069 XLA_AE_LINES_PKG.ValidateCurrentLine;
190070 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
190071
190072 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
190073 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
190074 ,p_balance_type_code => l_balance_type_code);
190075
190076 END IF;
190077
190078 -----------------------------------------------------------------------------------------
190079 -- 4262811 Multiperiod Accounting
190080 -----------------------------------------------------------------------------------------
190081 -- No MPA option is assigned.
190082
190083
190084 END IF;
190085 END IF;
190086 --
190087
190088 --
190089 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
190090 trace
190091 (p_msg => 'END of AcctLineType_348'
190092 ,p_level => C_LEVEL_PROCEDURE
190093 ,p_module => l_log_module);
190094 END IF;
190095 --
190096 EXCEPTION
190097 WHEN xla_exceptions_pkg.application_exception THEN
190098 RAISE;
190099 WHEN OTHERS THEN
190100 xla_exceptions_pkg.raise_message
190101 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_348');
190102 END AcctLineType_348;
190103 --
190104
190105 ---------------------------------------
190106 --
190107 -- PRIVATE FUNCTION
190108 -- AcctLineType_349
190109 --
190110 ---------------------------------------
190111 PROCEDURE AcctLineType_349 (
190112 p_application_id IN NUMBER
190113 ,p_event_id IN NUMBER
190114 ,p_calculate_acctd_flag IN VARCHAR2
190115 ,p_calculate_g_l_flag IN VARCHAR2
190116 ,p_actual_flag IN OUT VARCHAR2
190117 ,p_balance_type_code OUT VARCHAR2
190118 ,p_gain_or_loss_ref OUT VARCHAR2
190119
190120 --TRANSACTION_ID
190121 , p_source_1 IN NUMBER
190122 --Item Concatenated Segments
190123 , p_source_2 IN VARCHAR2
190124 --Transaction Quantity
190125 , p_source_3 IN NUMBER
190126 --Transaction Unit of Measure Code
190127 , p_source_4 IN VARCHAR2
190128 --Inventory Transaction Type Description
190129 , p_source_5 IN VARCHAR2
190130 --Transaction Distribution Account
190131 , p_source_20 IN NUMBER
190132 --Transaction Action Name
190133 , p_source_62 IN NUMBER
190134 , p_source_62_meaning IN VARCHAR2
190135 --DISTRIBUTION_IDENTIFIER
190136 , p_source_84 IN NUMBER
190137 --Distribution Type
190138 , p_source_85 IN VARCHAR2
190139 , p_source_85_meaning IN VARCHAR2
190140 --Entered Currency Code
190141 , p_source_88 IN VARCHAR2
190142 --Entered Amount
190143 , p_source_91 IN NUMBER
190144 --Currency Conversion Date
190145 , p_source_92 IN DATE
190146 --Currency Conversion Rate
190147 , p_source_93 IN NUMBER
190148 --Currency Conversion Type
190149 , p_source_94 IN VARCHAR2
190150 --Accounted Amount
190151 , p_source_95 IN NUMBER
190152 --Accounting Line Type
190153 , p_source_97 IN NUMBER
190154 )
190155 IS
190156
190157 l_component_type VARCHAR2(80);
190158 l_component_code VARCHAR2(30);
190159 l_component_type_code VARCHAR2(1);
190160 l_component_appl_id INTEGER;
190161 l_amb_context_code VARCHAR2(30);
190162 l_entity_code VARCHAR2(30);
190163 l_event_class_code VARCHAR2(30);
190164 l_ae_header_id NUMBER;
190165 l_event_type_code VARCHAR2(30);
190166 l_line_definition_code VARCHAR2(30);
190167 l_line_definition_owner_code VARCHAR2(1);
190168 --
190169 -- adr variables
190170 l_segment VARCHAR2(30);
190171 l_ccid NUMBER;
190172 l_adr_transaction_coa_id NUMBER;
190173 l_adr_accounting_coa_id NUMBER;
190174 l_adr_flexfield_segment_code VARCHAR2(30);
190175 l_adr_flex_value_set_id NUMBER;
190176 l_adr_value_type_code VARCHAR2(30);
190177 l_adr_value_combination_id NUMBER;
190178 l_adr_value_segment_code VARCHAR2(30);
190179
190180 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
190181 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
190182 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
190183 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
190184
190185 -- 4262811 Variables ------------------------------------------------------------------------------------------
190186 l_entered_amt_idx NUMBER;
190187 l_accted_amt_idx NUMBER;
190188 l_acc_rev_flag VARCHAR2(1);
190189 l_accrual_line_num NUMBER;
190190 l_tmp_amt NUMBER;
190191 l_acc_rev_natural_side_code VARCHAR2(1);
190192
190193 l_num_entries NUMBER;
190194 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
190195 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
190196 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
190197 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
190198 l_recog_line_1 NUMBER;
190199 l_recog_line_2 NUMBER;
190200
190201 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
190202 l_bflow_applied_to_amt NUMBER; -- 5132302
190203 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
190204
190205 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
190206
190207 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
190208 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
190209
190210 ---------------------------------------------------------------------------------------------------------------
190211
190212
190213 --
190214 -- bulk performance
190215 --
190216 l_balance_type_code VARCHAR2(1);
190217 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
190218 l_log_module VARCHAR2(240);
190219
190220 --
190221 -- Upgrade strategy
190222 --
190223 l_actual_upg_option VARCHAR2(1);
190224 l_enc_upg_option VARCHAR2(1);
190225
190226 --
190227 BEGIN
190228 --
190229 IF g_log_enabled THEN
190230 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_349';
190231 END IF;
190232 --
190233 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
190234
190235 trace
190236 (p_msg => 'BEGIN of AcctLineType_349'
190237 ,p_level => C_LEVEL_PROCEDURE
190238 ,p_module => l_log_module);
190239
190240 END IF;
190241 --
190242 l_component_type := 'AMB_JLT';
190243 l_component_code := 'OFFSET';
190244 l_component_type_code := 'S';
190245 l_component_appl_id := 707;
190246 l_amb_context_code := 'DEFAULT';
190247 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
190248 l_event_class_code := 'LOG_INTERCOMPANY';
190249 l_event_type_code := 'LOG_IC_RCPT_RETURN';
190250 l_line_definition_owner_code := 'S';
190251 l_line_definition_code := 'PI_LOG_IC_RCPT_RETURN';
190252 --
190253 l_balance_type_code := 'A';
190254 l_segment := NULL;
190255 l_ccid := NULL;
190256 l_adr_transaction_coa_id := NULL;
190257 l_adr_accounting_coa_id := NULL;
190258 l_adr_flexfield_segment_code := NULL;
190259 l_adr_flex_value_set_id := NULL;
190260 l_adr_value_type_code := NULL;
190261 l_adr_value_combination_id := NULL;
190262 l_adr_value_segment_code := NULL;
190263
190264 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
190265 l_bflow_class_code := ''; -- 4219869 Business Flow
190266 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
190267 l_budgetary_control_flag := 'N';
190268
190269 l_bflow_applied_to_amt_idx := NULL; -- 5132302
190270 l_bflow_applied_to_amt := NULL; -- 5132302
190271 l_entered_amt_idx := NULL; -- 4262811
190272 l_accted_amt_idx := NULL; -- 4262811
190273 l_acc_rev_flag := NULL; -- 4262811
190274 l_accrual_line_num := NULL; -- 4262811
190275 l_tmp_amt := NULL; -- 4262811
190276 --
190277
190278 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
190279 l_balance_type_code <> 'B' THEN
190280 IF NVL(p_source_97,9E125) = 2 AND
190281 ((p_source_95 <= 0 AND
190282 NVL(p_source_62,9E125) = 13) OR
190283 (p_source_95 <= 0 AND
190284 NVL(p_source_62,9E125) = 9) OR
190285 (p_source_95 >= 0 AND
190286 NVL(p_source_62,9E125) = 10) OR
190287 NVL(p_source_62,9E125) = 10 OR
190288 NVL(p_source_62,9E125) = 13)
190289 THEN
190290
190291 --
190292 XLA_AE_LINES_PKG.SetNewLine;
190293
190294 p_balance_type_code := l_balance_type_code;
190295 -- set the flag so later we will know whether the gain loss line needs to be created
190296
190297 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
190298 p_actual_flag :='A';
190299 END IF;
190300
190301 --
190302 -- bulk performance
190303 --
190304 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
190305 p_header_num => 0); -- 4262811
190306 --
190307 -- set accounting line options
190308 --
190309 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
190310 p_natural_side_code => 'D'
190311 , p_gain_or_loss_flag => 'N'
190312 , p_gl_transfer_mode_code => 'S'
190313 , p_acct_entry_type_code => 'A'
190314 , p_switch_side_flag => 'Y'
190315 , p_merge_duplicate_code => 'N'
190316 );
190317 --
190318 l_acc_rev_natural_side_code := 'C'; -- 4262811
190319 --
190320 --
190321 -- set accounting line type info
190322 --
190323 xla_ae_lines_pkg.SetAcctLineType
190324 (p_component_type => l_component_type
190325 ,p_event_type_code => l_event_type_code
190326 ,p_line_definition_owner_code => l_line_definition_owner_code
190327 ,p_line_definition_code => l_line_definition_code
190328 ,p_accounting_line_code => l_component_code
190329 ,p_accounting_line_type_code => l_component_type_code
190330 ,p_accounting_line_appl_id => l_component_appl_id
190331 ,p_amb_context_code => l_amb_context_code
190332 ,p_entity_code => l_entity_code
190333 ,p_event_class_code => l_event_class_code);
190334 --
190335 -- set accounting class
190336 --
190337 xla_ae_lines_pkg.SetAcctClass(
190338 p_accounting_class_code => 'OFFSET'
190339 , p_ae_header_id => l_ae_header_id
190340 );
190341
190342 --
190343 -- set rounding class
190344 --
190345 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
190346 'OFFSET';
190347
190348 --
190349 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
190350 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
190351 --
190352 -- bulk performance
190353 --
190354 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
190355
190356 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
190357 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
190358
190359 -- 4955764
190360 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
190361 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
190362
190363 -- 4458381 Public Sector Enh
190364
190365 --
190366 -- set accounting attributes for the line type
190367 --
190368 l_entered_amt_idx := 3;
190369 l_accted_amt_idx := 8;
190370 l_bflow_applied_to_amt_idx := NULL; -- 5132302
190371 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
190372 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
190373 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
190374 l_rec_acct_attrs.array_char_value(2) := p_source_85;
190375 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
190376 l_rec_acct_attrs.array_num_value(3) := p_source_91;
190377 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
190378 l_rec_acct_attrs.array_char_value(4) := p_source_88;
190379 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
190380 l_rec_acct_attrs.array_date_value(5) := p_source_92;
190381 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
190382 l_rec_acct_attrs.array_num_value(6) := p_source_93;
190383 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
190384 l_rec_acct_attrs.array_char_value(7) := p_source_94;
190385 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
190386 l_rec_acct_attrs.array_num_value(8) := p_source_95;
190387
190388 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
190389 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
190390
190391 ---------------------------------------------------------------------------------------------------------------
190392 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
190393 ---------------------------------------------------------------------------------------------------------------
190394 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
190395
190396 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
190397 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
190398
190399 IF xla_accounting_cache_pkg.GetValueChar
190400 (p_source_code => 'LEDGER_CATEGORY_CODE'
190401 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
190402 AND l_bflow_method_code = 'PRIOR_ENTRY'
190403 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
190404 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
190405 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
190406 )
190407 THEN
190408 xla_ae_lines_pkg.BflowUpgEntry
190409 (p_business_method_code => l_bflow_method_code
190410 ,p_business_class_code => l_bflow_class_code
190411 ,p_balance_type => l_balance_type_code);
190412 ELSE
190413 NULL;
190414 -- No business flow processing for business flow method of NONE.
190415 END IF;
190416
190417 --
190418 -- call analytical criteria
190419 --
190420
190421 --
190422 -- call description
190423 --
190424
190425 xla_ae_lines_pkg.SetLineDescription(
190426 p_ae_header_id => l_ae_header_id
190427 ,p_description => Description_1 (
190428 p_application_id => p_application_id
190429 , p_ae_header_id => l_ae_header_id
190430 , p_source_1 => p_source_1
190431 , p_source_2 => p_source_2
190432 , p_source_3 => p_source_3
190433 , p_source_4 => p_source_4
190434 , p_source_5 => p_source_5
190435 )
190436 );
190437
190438
190439 --
190440 -- call ADRs
190441 -- Bug 4922099
190442 --
190443 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
190444 (NVL(l_actual_upg_option, 'N') = 'O') OR
190445 (NVL(l_enc_upg_option, 'N') = 'O')
190446 )
190447 THEN
190448 NULL;
190449 --
190450 --
190451
190452 l_ccid := AcctDerRule_16(
190453 p_application_id => p_application_id
190454 , p_ae_header_id => l_ae_header_id
190455 , p_source_20 => p_source_20
190456 , x_transaction_coa_id => l_adr_transaction_coa_id
190457 , x_accounting_coa_id => l_adr_accounting_coa_id
190458 , x_value_type_code => l_adr_value_type_code
190459 , p_side => 'NA'
190460 );
190461
190462 xla_ae_lines_pkg.set_ccid(
190463 p_code_combination_id => l_ccid
190464 , p_value_type_code => l_adr_value_type_code
190465 , p_transaction_coa_id => l_adr_transaction_coa_id
190466 , p_accounting_coa_id => l_adr_accounting_coa_id
190467 , p_adr_code => 'PI_DISTRIBUTION'
190468 , p_adr_type_code => 'S'
190469 , p_component_type => l_component_type
190470 , p_component_code => l_component_code
190471 , p_component_type_code => l_component_type_code
190472 , p_component_appl_id => l_component_appl_id
190473 , p_amb_context_code => l_amb_context_code
190474 , p_side => 'NA'
190475 );
190476
190477
190478 --
190479 --
190480 END IF;
190481 --
190482 -- Bug 4922099
190483 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
190484 (NVL(l_enc_upg_option, 'N') = 'O')
190485 ) AND
190486 (l_bflow_method_code = 'PRIOR_ENTRY')
190487 )
190488 THEN
190489 IF
190490 --
190491 1 = 2
190492 --
190493 THEN
190494 xla_accounting_err_pkg.build_message
190495 (p_appli_s_name => 'XLA'
190496 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
190497 ,p_token_1 => 'LINE_NUMBER'
190498 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
190499 ,p_token_2 => 'LINE_TYPE_NAME'
190500 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
190501 l_component_type
190502 ,l_component_code
190503 ,l_component_type_code
190504 ,l_component_appl_id
190505 ,l_amb_context_code
190506 ,l_entity_code
190507 ,l_event_class_code
190508 )
190509 ,p_token_3 => 'OWNER'
190510 ,p_value_3 => xla_lookups_pkg.get_meaning(
190511 p_lookup_type => 'XLA_OWNER_TYPE'
190512 ,p_lookup_code => l_component_type_code
190513 )
190514 ,p_token_4 => 'PRODUCT_NAME'
190515 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
190516 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
190517 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
190518 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
190519 ,p_ae_header_id => NULL
190520 );
190521
190522 IF (C_LEVEL_ERROR>= g_log_level) THEN
190523 trace
190524 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
190525 ,p_level => C_LEVEL_ERROR
190526 ,p_module => l_log_module);
190527 END IF;
190528 END IF;
190529 END IF;
190530 --
190531 --
190532 ------------------------------------------------------------------------------------------------
190533 -- 4219869 Business Flow
190534 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
190535 -- Prior Entry. Currently, the following code is always generated.
190536 ------------------------------------------------------------------------------------------------
190537 XLA_AE_LINES_PKG.ValidateCurrentLine;
190538
190539 ------------------------------------------------------------------------------------
190540 -- 4219869 Business Flow
190541 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
190542 ------------------------------------------------------------------------------------
190543 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
190544
190545 ----------------------------------------------------------------------------------
190546 -- 4219869 Business Flow
190547 -- Update journal entry status -- Need to generate this within IF <condition>
190548 ----------------------------------------------------------------------------------
190549 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
190550 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
190551 ,p_balance_type_code => l_balance_type_code
190552 );
190553
190554 -------------------------------------------------------------------------------------------
190555 -- 4262811 - Generate the Accrual Reversal lines
190556 -------------------------------------------------------------------------------------------
190557 BEGIN
190558 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
190559 (g_array_event(p_event_id).array_value_num('header_index'));
190560 IF l_acc_rev_flag IS NULL THEN
190561 l_acc_rev_flag := 'N';
190562 END IF;
190563 EXCEPTION
190564 WHEN OTHERS THEN
190565 l_acc_rev_flag := 'N';
190566 END;
190567 --
190568 IF (l_acc_rev_flag = 'Y') THEN
190569
190570 -- 4645092 ------------------------------------------------------------------------------
190571 -- To allow MPA report to determine if it should generate report process
190572 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
190573 ------------------------------------------------------------------------------------------
190574
190575 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
190576 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
190577 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
190578 -- call ADRs
190579 -- Bug 4922099
190580 --
190581 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
190582 (NVL(l_actual_upg_option, 'N') = 'O') OR
190583 (NVL(l_enc_upg_option, 'N') = 'O')
190584 )
190585 THEN
190586 NULL;
190587 --
190588 --
190589
190590 l_ccid := AcctDerRule_16(
190591 p_application_id => p_application_id
190592 , p_ae_header_id => l_ae_header_id
190593 , p_source_20 => p_source_20
190594 , x_transaction_coa_id => l_adr_transaction_coa_id
190595 , x_accounting_coa_id => l_adr_accounting_coa_id
190596 , x_value_type_code => l_adr_value_type_code
190597 , p_side => 'NA'
190598 );
190599
190600 xla_ae_lines_pkg.set_ccid(
190601 p_code_combination_id => l_ccid
190602 , p_value_type_code => l_adr_value_type_code
190603 , p_transaction_coa_id => l_adr_transaction_coa_id
190604 , p_accounting_coa_id => l_adr_accounting_coa_id
190605 , p_adr_code => 'PI_DISTRIBUTION'
190606 , p_adr_type_code => 'S'
190607 , p_component_type => l_component_type
190608 , p_component_code => l_component_code
190609 , p_component_type_code => l_component_type_code
190610 , p_component_appl_id => l_component_appl_id
190611 , p_amb_context_code => l_amb_context_code
190612 , p_side => 'NA'
190613 );
190614
190615
190616 --
190617 --
190618 END IF;
190619
190620 --
190621 -- Update the line information that should be overwritten
190622 --
190623 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
190624 p_header_num => 1);
190625 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
190626
190627 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
190628
190629 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
190630 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
190631 END IF;
190632
190633 --
190634 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
190635 --
190636 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
190637 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
190638 ELSE
190639 ---------------------------------------------------------------------------------------------------
190640 -- 4262811a Switch Sign
190641 ---------------------------------------------------------------------------------------------------
190642 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
190643 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
190644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190645 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
190646 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190647 -- 5132302
190648 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
190649 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
190650
190651 END IF;
190652
190653 -- 4955764
190654 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
190655 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
190656
190657
190658 XLA_AE_LINES_PKG.ValidateCurrentLine;
190659 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
190660
190661 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
190662 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
190663 ,p_balance_type_code => l_balance_type_code);
190664
190665 END IF;
190666
190667 -----------------------------------------------------------------------------------------
190668 -- 4262811 Multiperiod Accounting
190669 -----------------------------------------------------------------------------------------
190670 -- No MPA option is assigned.
190671
190672
190673 END IF;
190674 END IF;
190675 --
190676
190677 --
190678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
190679 trace
190680 (p_msg => 'END of AcctLineType_349'
190681 ,p_level => C_LEVEL_PROCEDURE
190682 ,p_module => l_log_module);
190683 END IF;
190684 --
190685 EXCEPTION
190686 WHEN xla_exceptions_pkg.application_exception THEN
190687 RAISE;
190688 WHEN OTHERS THEN
190689 xla_exceptions_pkg.raise_message
190690 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_349');
190691 END AcctLineType_349;
190692 --
190693
190694 ---------------------------------------
190695 --
190696 -- PRIVATE FUNCTION
190697 -- AcctLineType_350
190698 --
190699 ---------------------------------------
190700 PROCEDURE AcctLineType_350 (
190701 p_application_id IN NUMBER
190702 ,p_event_id IN NUMBER
190703 ,p_calculate_acctd_flag IN VARCHAR2
190704 ,p_calculate_g_l_flag IN VARCHAR2
190705 ,p_actual_flag IN OUT VARCHAR2
190706 ,p_balance_type_code OUT VARCHAR2
190707 ,p_gain_or_loss_ref OUT VARCHAR2
190708
190709 --TRANSACTION_ID
190710 , p_source_1 IN NUMBER
190711 --Item Concatenated Segments
190712 , p_source_2 IN VARCHAR2
190713 --Transaction Quantity
190714 , p_source_3 IN NUMBER
190715 --Transaction Unit of Measure Code
190716 , p_source_4 IN VARCHAR2
190717 --Inventory Transaction Type Description
190718 , p_source_5 IN VARCHAR2
190719 --Cost Management Default Account
190720 , p_source_11 IN NUMBER
190721 --Applied to Application ID
190722 , p_source_79 IN NUMBER
190723 --Applied to Distribution Link Type
190724 , p_source_80 IN VARCHAR2
190725 --Applied to Entity Code
190726 , p_source_81 IN VARCHAR2
190727 --Applied To Purchase Document Identifier
190728 , p_source_83 IN NUMBER
190729 --DISTRIBUTION_IDENTIFIER
190730 , p_source_84 IN NUMBER
190731 --Distribution Type
190732 , p_source_85 IN VARCHAR2
190733 , p_source_85_meaning IN VARCHAR2
190734 --PO Budget Account
190735 , p_source_86 IN NUMBER
190736 --Encumbrance Reversal Amount Entered
190737 , p_source_87 IN NUMBER
190738 --Entered Currency Code
190739 , p_source_88 IN VARCHAR2
190740 --Transaction Encumbrance Reversal Amount
190741 , p_source_89 IN NUMBER
190742 --Entered Amount
190743 , p_source_91 IN NUMBER
190744 --Currency Conversion Date
190745 , p_source_92 IN DATE
190746 --Currency Conversion Rate
190747 , p_source_93 IN NUMBER
190748 --Currency Conversion Type
190749 , p_source_94 IN VARCHAR2
190750 --Accounted Amount
190751 , p_source_95 IN NUMBER
190752 --Purchasing Encumbrance Type Identifier
190753 , p_source_96 IN NUMBER
190754 --Accounting Line Type
190755 , p_source_97 IN NUMBER
190756 --Costing Encumbrance Upgrade Option
190757 , p_source_100 IN VARCHAR2
190758 --TXN_PO_DISTRIBUTION_ID
190759 , p_source_101 IN NUMBER
190760 )
190761 IS
190762
190763 l_component_type VARCHAR2(80);
190764 l_component_code VARCHAR2(30);
190765 l_component_type_code VARCHAR2(1);
190766 l_component_appl_id INTEGER;
190767 l_amb_context_code VARCHAR2(30);
190768 l_entity_code VARCHAR2(30);
190769 l_event_class_code VARCHAR2(30);
190770 l_ae_header_id NUMBER;
190771 l_event_type_code VARCHAR2(30);
190772 l_line_definition_code VARCHAR2(30);
190773 l_line_definition_owner_code VARCHAR2(1);
190774 --
190775 -- adr variables
190776 l_segment VARCHAR2(30);
190777 l_ccid NUMBER;
190778 l_adr_transaction_coa_id NUMBER;
190779 l_adr_accounting_coa_id NUMBER;
190780 l_adr_flexfield_segment_code VARCHAR2(30);
190781 l_adr_flex_value_set_id NUMBER;
190782 l_adr_value_type_code VARCHAR2(30);
190783 l_adr_value_combination_id NUMBER;
190784 l_adr_value_segment_code VARCHAR2(30);
190785
190786 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
190787 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
190788 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
190789 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
190790
190791 -- 4262811 Variables ------------------------------------------------------------------------------------------
190792 l_entered_amt_idx NUMBER;
190793 l_accted_amt_idx NUMBER;
190794 l_acc_rev_flag VARCHAR2(1);
190795 l_accrual_line_num NUMBER;
190796 l_tmp_amt NUMBER;
190797 l_acc_rev_natural_side_code VARCHAR2(1);
190798
190799 l_num_entries NUMBER;
190800 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
190801 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
190802 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
190803 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
190804 l_recog_line_1 NUMBER;
190805 l_recog_line_2 NUMBER;
190806
190807 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
190808 l_bflow_applied_to_amt NUMBER; -- 5132302
190809 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
190810
190811 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
190812
190813 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
190814 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
190815
190816 ---------------------------------------------------------------------------------------------------------------
190817
190818
190819 --
190820 -- bulk performance
190821 --
190822 l_balance_type_code VARCHAR2(1);
190823 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
190824 l_log_module VARCHAR2(240);
190825
190826 --
190827 -- Upgrade strategy
190828 --
190829 l_actual_upg_option VARCHAR2(1);
190830 l_enc_upg_option VARCHAR2(1);
190831
190832 --
190833 BEGIN
190834 --
190835 IF g_log_enabled THEN
190836 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_350';
190837 END IF;
190838 --
190839 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
190840
190841 trace
190842 (p_msg => 'BEGIN of AcctLineType_350'
190843 ,p_level => C_LEVEL_PROCEDURE
190844 ,p_module => l_log_module);
190845
190846 END IF;
190847 --
190848 l_component_type := 'AMB_JLT';
190849 l_component_code := 'OFFSET';
190850 l_component_type_code := 'S';
190851 l_component_appl_id := 707;
190852 l_amb_context_code := 'DEFAULT';
190853 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
190854 l_event_class_code := 'PURCHASE_ORDER';
190855 l_event_type_code := 'LOG_PO_DEL_INV';
190856 l_line_definition_owner_code := 'S';
190857 l_line_definition_code := 'PI_LOG_DEL_INV';
190858 --
190859 l_balance_type_code := 'A';
190860 l_segment := NULL;
190861 l_ccid := NULL;
190862 l_adr_transaction_coa_id := NULL;
190863 l_adr_accounting_coa_id := NULL;
190864 l_adr_flexfield_segment_code := NULL;
190865 l_adr_flex_value_set_id := NULL;
190866 l_adr_value_type_code := NULL;
190867 l_adr_value_combination_id := NULL;
190868 l_adr_value_segment_code := NULL;
190869
190870 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
190871 l_bflow_class_code := ''; -- 4219869 Business Flow
190872 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
190873 l_budgetary_control_flag := 'N';
190874
190875 l_bflow_applied_to_amt_idx := NULL; -- 5132302
190876 l_bflow_applied_to_amt := NULL; -- 5132302
190877 l_entered_amt_idx := NULL; -- 4262811
190878 l_accted_amt_idx := NULL; -- 4262811
190879 l_acc_rev_flag := NULL; -- 4262811
190880 l_accrual_line_num := NULL; -- 4262811
190881 l_tmp_amt := NULL; -- 4262811
190882 --
190883
190884 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
190885 l_balance_type_code <> 'B' THEN
190886 IF NVL(p_source_97,9E125) = 2
190887 THEN
190888
190889 --
190890 XLA_AE_LINES_PKG.SetNewLine;
190891
190892 p_balance_type_code := l_balance_type_code;
190893 -- set the flag so later we will know whether the gain loss line needs to be created
190894
190895 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
190896 p_actual_flag :='A';
190897 END IF;
190898
190899 --
190900 -- bulk performance
190901 --
190902 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
190903 p_header_num => 0); -- 4262811
190904 --
190905 -- set accounting line options
190906 --
190907 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
190908 p_natural_side_code => 'D'
190909 , p_gain_or_loss_flag => 'N'
190910 , p_gl_transfer_mode_code => 'S'
190911 , p_acct_entry_type_code => 'A'
190912 , p_switch_side_flag => 'Y'
190913 , p_merge_duplicate_code => 'N'
190914 );
190915 --
190916 l_acc_rev_natural_side_code := 'C'; -- 4262811
190917 --
190918 --
190919 -- set accounting line type info
190920 --
190921 xla_ae_lines_pkg.SetAcctLineType
190922 (p_component_type => l_component_type
190923 ,p_event_type_code => l_event_type_code
190924 ,p_line_definition_owner_code => l_line_definition_owner_code
190925 ,p_line_definition_code => l_line_definition_code
190926 ,p_accounting_line_code => l_component_code
190927 ,p_accounting_line_type_code => l_component_type_code
190928 ,p_accounting_line_appl_id => l_component_appl_id
190929 ,p_amb_context_code => l_amb_context_code
190930 ,p_entity_code => l_entity_code
190931 ,p_event_class_code => l_event_class_code);
190932 --
190933 -- set accounting class
190934 --
190935 xla_ae_lines_pkg.SetAcctClass(
190936 p_accounting_class_code => 'OFFSET'
190937 , p_ae_header_id => l_ae_header_id
190938 );
190939
190940 --
190941 -- set rounding class
190942 --
190943 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
190944 'OFFSET';
190945
190946 --
190947 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
190948 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
190949 --
190950 -- bulk performance
190951 --
190952 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
190953
190954 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
190955 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
190956
190957 -- 4955764
190958 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
190959 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
190960
190961 -- 4458381 Public Sector Enh
190962
190963 --
190964 -- set accounting attributes for the line type
190965 --
190966 l_entered_amt_idx := 17;
190967 l_accted_amt_idx := 22;
190968 l_bflow_applied_to_amt_idx := NULL; -- 5132302
190969 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
190970 l_rec_acct_attrs.array_num_value(1) := p_source_79;
190971 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
190972 l_rec_acct_attrs.array_char_value(2) := p_source_80;
190973 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
190974 l_rec_acct_attrs.array_char_value(3) := p_source_81;
190975 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
190976 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
190977 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
190978 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
190979 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
190980 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
190981 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
190982 l_rec_acct_attrs.array_char_value(7) := p_source_85;
190983 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
190984 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
190985 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
190986 l_rec_acct_attrs.array_num_value(9) := p_source_87;
190987 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
190988 l_rec_acct_attrs.array_char_value(10) := p_source_88;
190989 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
190990 l_rec_acct_attrs.array_num_value(11) := p_source_89;
190991 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
190992 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
190993 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
190994 l_rec_acct_attrs.array_num_value(13) := p_source_87;
190995 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
190996 l_rec_acct_attrs.array_char_value(14) := p_source_88;
190997 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
190998 l_rec_acct_attrs.array_num_value(15) := p_source_89;
190999 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
191000 l_rec_acct_attrs.array_char_value(16) := p_source_100;
191001 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
191002 l_rec_acct_attrs.array_num_value(17) := p_source_91;
191003 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
191004 l_rec_acct_attrs.array_char_value(18) := p_source_88;
191005 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
191006 l_rec_acct_attrs.array_date_value(19) := p_source_92;
191007 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
191008 l_rec_acct_attrs.array_num_value(20) := p_source_93;
191009 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
191010 l_rec_acct_attrs.array_char_value(21) := p_source_94;
191011 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
191012 l_rec_acct_attrs.array_num_value(22) := p_source_95;
191013 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
191014 l_rec_acct_attrs.array_num_value(23) := p_source_96;
191015 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
191016 l_rec_acct_attrs.array_num_value(24) := p_source_96;
191017
191018 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
191019 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
191020
191021 ---------------------------------------------------------------------------------------------------------------
191022 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
191023 ---------------------------------------------------------------------------------------------------------------
191024 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
191025
191026 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
191027 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
191028
191029 IF xla_accounting_cache_pkg.GetValueChar
191030 (p_source_code => 'LEDGER_CATEGORY_CODE'
191031 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
191032 AND l_bflow_method_code = 'PRIOR_ENTRY'
191033 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
191034 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
191035 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
191036 )
191037 THEN
191038 xla_ae_lines_pkg.BflowUpgEntry
191039 (p_business_method_code => l_bflow_method_code
191040 ,p_business_class_code => l_bflow_class_code
191041 ,p_balance_type => l_balance_type_code);
191042 ELSE
191043 NULL;
191044 -- No business flow processing for business flow method of NONE.
191045 END IF;
191046
191047 --
191048 -- call analytical criteria
191049 --
191050
191051 --
191052 -- call description
191053 --
191054
191055 xla_ae_lines_pkg.SetLineDescription(
191056 p_ae_header_id => l_ae_header_id
191057 ,p_description => Description_1 (
191058 p_application_id => p_application_id
191059 , p_ae_header_id => l_ae_header_id
191060 , p_source_1 => p_source_1
191061 , p_source_2 => p_source_2
191062 , p_source_3 => p_source_3
191063 , p_source_4 => p_source_4
191064 , p_source_5 => p_source_5
191065 )
191066 );
191067
191068
191069 --
191070 -- call ADRs
191071 -- Bug 4922099
191072 --
191073 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
191074 (NVL(l_actual_upg_option, 'N') = 'O') OR
191075 (NVL(l_enc_upg_option, 'N') = 'O')
191076 )
191077 THEN
191078 NULL;
191079 --
191080 --
191081
191082 l_ccid := AcctDerRule_6(
191083 p_application_id => p_application_id
191084 , p_ae_header_id => l_ae_header_id
191085 , p_source_11 => p_source_11
191086 , x_transaction_coa_id => l_adr_transaction_coa_id
191087 , x_accounting_coa_id => l_adr_accounting_coa_id
191088 , x_value_type_code => l_adr_value_type_code
191089 , p_side => 'NA'
191090 );
191091
191092 xla_ae_lines_pkg.set_ccid(
191093 p_code_combination_id => l_ccid
191094 , p_value_type_code => l_adr_value_type_code
191095 , p_transaction_coa_id => l_adr_transaction_coa_id
191096 , p_accounting_coa_id => l_adr_accounting_coa_id
191097 , p_adr_code => 'CST_DEFAULT'
191098 , p_adr_type_code => 'S'
191099 , p_component_type => l_component_type
191100 , p_component_code => l_component_code
191101 , p_component_type_code => l_component_type_code
191102 , p_component_appl_id => l_component_appl_id
191103 , p_amb_context_code => l_amb_context_code
191104 , p_side => 'NA'
191105 );
191106
191107
191108 --
191109 --
191110 END IF;
191111 --
191112 -- Bug 4922099
191113 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
191114 (NVL(l_enc_upg_option, 'N') = 'O')
191115 ) AND
191116 (l_bflow_method_code = 'PRIOR_ENTRY')
191117 )
191118 THEN
191119 IF
191120 --
191121 1 = 2
191122 --
191123 THEN
191124 xla_accounting_err_pkg.build_message
191125 (p_appli_s_name => 'XLA'
191126 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
191127 ,p_token_1 => 'LINE_NUMBER'
191128 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
191129 ,p_token_2 => 'LINE_TYPE_NAME'
191130 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
191131 l_component_type
191132 ,l_component_code
191133 ,l_component_type_code
191134 ,l_component_appl_id
191135 ,l_amb_context_code
191136 ,l_entity_code
191137 ,l_event_class_code
191138 )
191139 ,p_token_3 => 'OWNER'
191140 ,p_value_3 => xla_lookups_pkg.get_meaning(
191141 p_lookup_type => 'XLA_OWNER_TYPE'
191142 ,p_lookup_code => l_component_type_code
191143 )
191144 ,p_token_4 => 'PRODUCT_NAME'
191145 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
191146 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
191147 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
191148 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
191149 ,p_ae_header_id => NULL
191150 );
191151
191152 IF (C_LEVEL_ERROR>= g_log_level) THEN
191153 trace
191154 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
191155 ,p_level => C_LEVEL_ERROR
191156 ,p_module => l_log_module);
191157 END IF;
191158 END IF;
191159 END IF;
191160 --
191161 --
191162 ------------------------------------------------------------------------------------------------
191163 -- 4219869 Business Flow
191164 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
191165 -- Prior Entry. Currently, the following code is always generated.
191166 ------------------------------------------------------------------------------------------------
191167 XLA_AE_LINES_PKG.ValidateCurrentLine;
191168
191169 ------------------------------------------------------------------------------------
191170 -- 4219869 Business Flow
191171 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
191172 ------------------------------------------------------------------------------------
191173 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
191174
191175 ----------------------------------------------------------------------------------
191176 -- 4219869 Business Flow
191177 -- Update journal entry status -- Need to generate this within IF <condition>
191178 ----------------------------------------------------------------------------------
191179 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
191180 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
191181 ,p_balance_type_code => l_balance_type_code
191182 );
191183
191184 -------------------------------------------------------------------------------------------
191185 -- 4262811 - Generate the Accrual Reversal lines
191186 -------------------------------------------------------------------------------------------
191187 BEGIN
191188 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
191189 (g_array_event(p_event_id).array_value_num('header_index'));
191190 IF l_acc_rev_flag IS NULL THEN
191191 l_acc_rev_flag := 'N';
191192 END IF;
191193 EXCEPTION
191194 WHEN OTHERS THEN
191195 l_acc_rev_flag := 'N';
191196 END;
191197 --
191198 IF (l_acc_rev_flag = 'Y') THEN
191199
191200 -- 4645092 ------------------------------------------------------------------------------
191201 -- To allow MPA report to determine if it should generate report process
191202 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
191203 ------------------------------------------------------------------------------------------
191204
191205 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
191206 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
191207 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
191208 -- call ADRs
191209 -- Bug 4922099
191210 --
191211 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
191212 (NVL(l_actual_upg_option, 'N') = 'O') OR
191213 (NVL(l_enc_upg_option, 'N') = 'O')
191214 )
191215 THEN
191216 NULL;
191217 --
191218 --
191219
191220 l_ccid := AcctDerRule_6(
191221 p_application_id => p_application_id
191222 , p_ae_header_id => l_ae_header_id
191223 , p_source_11 => p_source_11
191224 , x_transaction_coa_id => l_adr_transaction_coa_id
191225 , x_accounting_coa_id => l_adr_accounting_coa_id
191226 , x_value_type_code => l_adr_value_type_code
191227 , p_side => 'NA'
191228 );
191229
191230 xla_ae_lines_pkg.set_ccid(
191231 p_code_combination_id => l_ccid
191232 , p_value_type_code => l_adr_value_type_code
191233 , p_transaction_coa_id => l_adr_transaction_coa_id
191234 , p_accounting_coa_id => l_adr_accounting_coa_id
191235 , p_adr_code => 'CST_DEFAULT'
191236 , p_adr_type_code => 'S'
191237 , p_component_type => l_component_type
191238 , p_component_code => l_component_code
191239 , p_component_type_code => l_component_type_code
191240 , p_component_appl_id => l_component_appl_id
191241 , p_amb_context_code => l_amb_context_code
191242 , p_side => 'NA'
191243 );
191244
191245
191246 --
191247 --
191248 END IF;
191249
191250 --
191251 -- Update the line information that should be overwritten
191252 --
191253 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
191254 p_header_num => 1);
191255 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
191256
191257 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
191258
191259 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
191260 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
191261 END IF;
191262
191263 --
191264 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
191265 --
191266 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
191267 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
191268 ELSE
191269 ---------------------------------------------------------------------------------------------------
191270 -- 4262811a Switch Sign
191271 ---------------------------------------------------------------------------------------------------
191272 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
191273 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
191274 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191275 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
191276 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191277 -- 5132302
191278 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
191279 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191280
191281 END IF;
191282
191283 -- 4955764
191284 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
191285 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
191286
191287
191288 XLA_AE_LINES_PKG.ValidateCurrentLine;
191289 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
191290
191291 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
191292 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
191293 ,p_balance_type_code => l_balance_type_code);
191294
191295 END IF;
191296
191297 -----------------------------------------------------------------------------------------
191298 -- 4262811 Multiperiod Accounting
191299 -----------------------------------------------------------------------------------------
191300 -- No MPA option is assigned.
191301
191302
191303 END IF;
191304 END IF;
191305 --
191306
191307 --
191308 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
191309 trace
191310 (p_msg => 'END of AcctLineType_350'
191311 ,p_level => C_LEVEL_PROCEDURE
191312 ,p_module => l_log_module);
191313 END IF;
191314 --
191315 EXCEPTION
191316 WHEN xla_exceptions_pkg.application_exception THEN
191317 RAISE;
191318 WHEN OTHERS THEN
191319 xla_exceptions_pkg.raise_message
191320 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_350');
191321 END AcctLineType_350;
191322 --
191323
191324 ---------------------------------------
191325 --
191326 -- PRIVATE FUNCTION
191327 -- AcctLineType_351
191328 --
191329 ---------------------------------------
191330 PROCEDURE AcctLineType_351 (
191331 p_application_id IN NUMBER
191332 ,p_event_id IN NUMBER
191333 ,p_calculate_acctd_flag IN VARCHAR2
191334 ,p_calculate_g_l_flag IN VARCHAR2
191335 ,p_actual_flag IN OUT VARCHAR2
191336 ,p_balance_type_code OUT VARCHAR2
191337 ,p_gain_or_loss_ref OUT VARCHAR2
191338
191339 --TRANSACTION_ID
191340 , p_source_1 IN NUMBER
191341 --Item Concatenated Segments
191342 , p_source_2 IN VARCHAR2
191343 --Transaction Quantity
191344 , p_source_3 IN NUMBER
191345 --Transaction Unit of Measure Code
191346 , p_source_4 IN VARCHAR2
191347 --Inventory Transaction Type Description
191348 , p_source_5 IN VARCHAR2
191349 --Transaction Distribution Account
191350 , p_source_20 IN NUMBER
191351 --Applied to Application ID
191352 , p_source_79 IN NUMBER
191353 --Applied to Distribution Link Type
191354 , p_source_80 IN VARCHAR2
191355 --Applied to Entity Code
191356 , p_source_81 IN VARCHAR2
191357 --Applied To Purchase Document Identifier
191358 , p_source_83 IN NUMBER
191359 --DISTRIBUTION_IDENTIFIER
191360 , p_source_84 IN NUMBER
191361 --Distribution Type
191362 , p_source_85 IN VARCHAR2
191363 , p_source_85_meaning IN VARCHAR2
191364 --PO Budget Account
191365 , p_source_86 IN NUMBER
191366 --Encumbrance Reversal Amount Entered
191367 , p_source_87 IN NUMBER
191368 --Entered Currency Code
191369 , p_source_88 IN VARCHAR2
191370 --Transaction Encumbrance Reversal Amount
191371 , p_source_89 IN NUMBER
191372 --Entered Amount
191373 , p_source_91 IN NUMBER
191374 --Currency Conversion Date
191375 , p_source_92 IN DATE
191376 --Currency Conversion Rate
191377 , p_source_93 IN NUMBER
191378 --Currency Conversion Type
191379 , p_source_94 IN VARCHAR2
191380 --Accounted Amount
191381 , p_source_95 IN NUMBER
191382 --Purchasing Encumbrance Type Identifier
191383 , p_source_96 IN NUMBER
191384 --Accounting Line Type
191385 , p_source_97 IN NUMBER
191386 --Costing Encumbrance Upgrade Option
191387 , p_source_100 IN VARCHAR2
191388 --TXN_PO_DISTRIBUTION_ID
191389 , p_source_101 IN NUMBER
191390 )
191391 IS
191392
191393 l_component_type VARCHAR2(80);
191394 l_component_code VARCHAR2(30);
191395 l_component_type_code VARCHAR2(1);
191396 l_component_appl_id INTEGER;
191397 l_amb_context_code VARCHAR2(30);
191398 l_entity_code VARCHAR2(30);
191399 l_event_class_code VARCHAR2(30);
191400 l_ae_header_id NUMBER;
191401 l_event_type_code VARCHAR2(30);
191402 l_line_definition_code VARCHAR2(30);
191403 l_line_definition_owner_code VARCHAR2(1);
191404 --
191405 -- adr variables
191406 l_segment VARCHAR2(30);
191407 l_ccid NUMBER;
191408 l_adr_transaction_coa_id NUMBER;
191409 l_adr_accounting_coa_id NUMBER;
191410 l_adr_flexfield_segment_code VARCHAR2(30);
191411 l_adr_flex_value_set_id NUMBER;
191412 l_adr_value_type_code VARCHAR2(30);
191413 l_adr_value_combination_id NUMBER;
191414 l_adr_value_segment_code VARCHAR2(30);
191415
191416 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
191417 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
191418 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
191419 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
191420
191421 -- 4262811 Variables ------------------------------------------------------------------------------------------
191422 l_entered_amt_idx NUMBER;
191423 l_accted_amt_idx NUMBER;
191424 l_acc_rev_flag VARCHAR2(1);
191425 l_accrual_line_num NUMBER;
191426 l_tmp_amt NUMBER;
191427 l_acc_rev_natural_side_code VARCHAR2(1);
191428
191429 l_num_entries NUMBER;
191430 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
191431 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
191432 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
191433 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
191434 l_recog_line_1 NUMBER;
191435 l_recog_line_2 NUMBER;
191436
191437 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
191438 l_bflow_applied_to_amt NUMBER; -- 5132302
191439 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
191440
191441 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
191442
191443 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
191444 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
191445
191446 ---------------------------------------------------------------------------------------------------------------
191447
191448
191449 --
191450 -- bulk performance
191451 --
191452 l_balance_type_code VARCHAR2(1);
191453 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
191454 l_log_module VARCHAR2(240);
191455
191456 --
191457 -- Upgrade strategy
191458 --
191459 l_actual_upg_option VARCHAR2(1);
191460 l_enc_upg_option VARCHAR2(1);
191461
191462 --
191463 BEGIN
191464 --
191465 IF g_log_enabled THEN
191466 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_351';
191467 END IF;
191468 --
191469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
191470
191471 trace
191472 (p_msg => 'BEGIN of AcctLineType_351'
191473 ,p_level => C_LEVEL_PROCEDURE
191474 ,p_module => l_log_module);
191475
191476 END IF;
191477 --
191478 l_component_type := 'AMB_JLT';
191479 l_component_code := 'OFFSET';
191480 l_component_type_code := 'S';
191481 l_component_appl_id := 707;
191482 l_amb_context_code := 'DEFAULT';
191483 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
191484 l_event_class_code := 'PURCHASE_ORDER';
191485 l_event_type_code := 'LOG_RET_RI_INV';
191486 l_line_definition_owner_code := 'S';
191487 l_line_definition_code := 'PI_LOG_RET_RI_INV';
191488 --
191489 l_balance_type_code := 'A';
191490 l_segment := NULL;
191491 l_ccid := NULL;
191492 l_adr_transaction_coa_id := NULL;
191493 l_adr_accounting_coa_id := NULL;
191494 l_adr_flexfield_segment_code := NULL;
191495 l_adr_flex_value_set_id := NULL;
191496 l_adr_value_type_code := NULL;
191497 l_adr_value_combination_id := NULL;
191498 l_adr_value_segment_code := NULL;
191499
191500 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
191501 l_bflow_class_code := ''; -- 4219869 Business Flow
191502 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
191503 l_budgetary_control_flag := 'N';
191504
191505 l_bflow_applied_to_amt_idx := NULL; -- 5132302
191506 l_bflow_applied_to_amt := NULL; -- 5132302
191507 l_entered_amt_idx := NULL; -- 4262811
191508 l_accted_amt_idx := NULL; -- 4262811
191509 l_acc_rev_flag := NULL; -- 4262811
191510 l_accrual_line_num := NULL; -- 4262811
191511 l_tmp_amt := NULL; -- 4262811
191512 --
191513
191514 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
191515 l_balance_type_code <> 'B' THEN
191516 IF NVL(p_source_97,9E125) = 2
191517 THEN
191518
191519 --
191520 XLA_AE_LINES_PKG.SetNewLine;
191521
191522 p_balance_type_code := l_balance_type_code;
191523 -- set the flag so later we will know whether the gain loss line needs to be created
191524
191525 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
191526 p_actual_flag :='A';
191527 END IF;
191528
191529 --
191530 -- bulk performance
191531 --
191532 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
191533 p_header_num => 0); -- 4262811
191534 --
191535 -- set accounting line options
191536 --
191537 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
191538 p_natural_side_code => 'D'
191539 , p_gain_or_loss_flag => 'N'
191540 , p_gl_transfer_mode_code => 'S'
191541 , p_acct_entry_type_code => 'A'
191542 , p_switch_side_flag => 'Y'
191543 , p_merge_duplicate_code => 'N'
191544 );
191545 --
191546 l_acc_rev_natural_side_code := 'C'; -- 4262811
191547 --
191548 --
191549 -- set accounting line type info
191550 --
191551 xla_ae_lines_pkg.SetAcctLineType
191552 (p_component_type => l_component_type
191553 ,p_event_type_code => l_event_type_code
191554 ,p_line_definition_owner_code => l_line_definition_owner_code
191555 ,p_line_definition_code => l_line_definition_code
191556 ,p_accounting_line_code => l_component_code
191557 ,p_accounting_line_type_code => l_component_type_code
191558 ,p_accounting_line_appl_id => l_component_appl_id
191559 ,p_amb_context_code => l_amb_context_code
191560 ,p_entity_code => l_entity_code
191561 ,p_event_class_code => l_event_class_code);
191562 --
191563 -- set accounting class
191564 --
191565 xla_ae_lines_pkg.SetAcctClass(
191566 p_accounting_class_code => 'OFFSET'
191567 , p_ae_header_id => l_ae_header_id
191568 );
191569
191570 --
191571 -- set rounding class
191572 --
191573 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
191574 'OFFSET';
191575
191576 --
191577 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
191578 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
191579 --
191580 -- bulk performance
191581 --
191582 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
191583
191584 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
191585 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
191586
191587 -- 4955764
191588 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
191589 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
191590
191591 -- 4458381 Public Sector Enh
191592
191593 --
191594 -- set accounting attributes for the line type
191595 --
191596 l_entered_amt_idx := 17;
191597 l_accted_amt_idx := 22;
191598 l_bflow_applied_to_amt_idx := NULL; -- 5132302
191599 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
191600 l_rec_acct_attrs.array_num_value(1) := p_source_79;
191601 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
191602 l_rec_acct_attrs.array_char_value(2) := p_source_80;
191603 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
191604 l_rec_acct_attrs.array_char_value(3) := p_source_81;
191605 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
191606 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
191607 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
191608 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
191609 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
191610 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
191611 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
191612 l_rec_acct_attrs.array_char_value(7) := p_source_85;
191613 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
191614 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
191615 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
191616 l_rec_acct_attrs.array_num_value(9) := p_source_87;
191617 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
191618 l_rec_acct_attrs.array_char_value(10) := p_source_88;
191619 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
191620 l_rec_acct_attrs.array_num_value(11) := p_source_89;
191621 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
191622 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
191623 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
191624 l_rec_acct_attrs.array_num_value(13) := p_source_87;
191625 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
191626 l_rec_acct_attrs.array_char_value(14) := p_source_88;
191627 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
191628 l_rec_acct_attrs.array_num_value(15) := p_source_89;
191629 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
191630 l_rec_acct_attrs.array_char_value(16) := p_source_100;
191631 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
191632 l_rec_acct_attrs.array_num_value(17) := p_source_91;
191633 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
191634 l_rec_acct_attrs.array_char_value(18) := p_source_88;
191635 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
191636 l_rec_acct_attrs.array_date_value(19) := p_source_92;
191637 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
191638 l_rec_acct_attrs.array_num_value(20) := p_source_93;
191639 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
191640 l_rec_acct_attrs.array_char_value(21) := p_source_94;
191641 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
191642 l_rec_acct_attrs.array_num_value(22) := p_source_95;
191643 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
191644 l_rec_acct_attrs.array_num_value(23) := p_source_96;
191645 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
191646 l_rec_acct_attrs.array_num_value(24) := p_source_96;
191647
191648 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
191649 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
191650
191651 ---------------------------------------------------------------------------------------------------------------
191652 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
191653 ---------------------------------------------------------------------------------------------------------------
191654 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
191655
191656 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
191657 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
191658
191659 IF xla_accounting_cache_pkg.GetValueChar
191660 (p_source_code => 'LEDGER_CATEGORY_CODE'
191661 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
191662 AND l_bflow_method_code = 'PRIOR_ENTRY'
191663 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
191664 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
191665 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
191666 )
191667 THEN
191668 xla_ae_lines_pkg.BflowUpgEntry
191669 (p_business_method_code => l_bflow_method_code
191670 ,p_business_class_code => l_bflow_class_code
191671 ,p_balance_type => l_balance_type_code);
191672 ELSE
191673 NULL;
191674 -- No business flow processing for business flow method of NONE.
191675 END IF;
191676
191677 --
191678 -- call analytical criteria
191679 --
191680
191681 --
191682 -- call description
191683 --
191684
191685 xla_ae_lines_pkg.SetLineDescription(
191686 p_ae_header_id => l_ae_header_id
191687 ,p_description => Description_1 (
191688 p_application_id => p_application_id
191689 , p_ae_header_id => l_ae_header_id
191690 , p_source_1 => p_source_1
191691 , p_source_2 => p_source_2
191692 , p_source_3 => p_source_3
191693 , p_source_4 => p_source_4
191694 , p_source_5 => p_source_5
191695 )
191696 );
191697
191698
191699 --
191700 -- call ADRs
191701 -- Bug 4922099
191702 --
191703 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
191704 (NVL(l_actual_upg_option, 'N') = 'O') OR
191705 (NVL(l_enc_upg_option, 'N') = 'O')
191706 )
191707 THEN
191708 NULL;
191709 --
191710 --
191711
191712 l_ccid := AcctDerRule_16(
191713 p_application_id => p_application_id
191714 , p_ae_header_id => l_ae_header_id
191715 , p_source_20 => p_source_20
191716 , x_transaction_coa_id => l_adr_transaction_coa_id
191717 , x_accounting_coa_id => l_adr_accounting_coa_id
191718 , x_value_type_code => l_adr_value_type_code
191719 , p_side => 'NA'
191720 );
191721
191722 xla_ae_lines_pkg.set_ccid(
191723 p_code_combination_id => l_ccid
191724 , p_value_type_code => l_adr_value_type_code
191725 , p_transaction_coa_id => l_adr_transaction_coa_id
191726 , p_accounting_coa_id => l_adr_accounting_coa_id
191727 , p_adr_code => 'PI_DISTRIBUTION'
191728 , p_adr_type_code => 'S'
191729 , p_component_type => l_component_type
191730 , p_component_code => l_component_code
191731 , p_component_type_code => l_component_type_code
191732 , p_component_appl_id => l_component_appl_id
191733 , p_amb_context_code => l_amb_context_code
191734 , p_side => 'NA'
191735 );
191736
191737
191738 --
191739 --
191740 END IF;
191741 --
191742 -- Bug 4922099
191743 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
191744 (NVL(l_enc_upg_option, 'N') = 'O')
191745 ) AND
191746 (l_bflow_method_code = 'PRIOR_ENTRY')
191747 )
191748 THEN
191749 IF
191750 --
191751 1 = 2
191752 --
191753 THEN
191754 xla_accounting_err_pkg.build_message
191755 (p_appli_s_name => 'XLA'
191756 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
191757 ,p_token_1 => 'LINE_NUMBER'
191758 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
191759 ,p_token_2 => 'LINE_TYPE_NAME'
191760 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
191761 l_component_type
191762 ,l_component_code
191763 ,l_component_type_code
191764 ,l_component_appl_id
191765 ,l_amb_context_code
191766 ,l_entity_code
191767 ,l_event_class_code
191768 )
191769 ,p_token_3 => 'OWNER'
191770 ,p_value_3 => xla_lookups_pkg.get_meaning(
191771 p_lookup_type => 'XLA_OWNER_TYPE'
191772 ,p_lookup_code => l_component_type_code
191773 )
191774 ,p_token_4 => 'PRODUCT_NAME'
191775 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
191776 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
191777 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
191778 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
191779 ,p_ae_header_id => NULL
191780 );
191781
191782 IF (C_LEVEL_ERROR>= g_log_level) THEN
191783 trace
191784 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
191785 ,p_level => C_LEVEL_ERROR
191786 ,p_module => l_log_module);
191787 END IF;
191788 END IF;
191789 END IF;
191790 --
191791 --
191792 ------------------------------------------------------------------------------------------------
191793 -- 4219869 Business Flow
191794 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
191795 -- Prior Entry. Currently, the following code is always generated.
191796 ------------------------------------------------------------------------------------------------
191797 XLA_AE_LINES_PKG.ValidateCurrentLine;
191798
191799 ------------------------------------------------------------------------------------
191800 -- 4219869 Business Flow
191801 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
191802 ------------------------------------------------------------------------------------
191803 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
191804
191805 ----------------------------------------------------------------------------------
191806 -- 4219869 Business Flow
191807 -- Update journal entry status -- Need to generate this within IF <condition>
191808 ----------------------------------------------------------------------------------
191809 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
191810 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
191811 ,p_balance_type_code => l_balance_type_code
191812 );
191813
191814 -------------------------------------------------------------------------------------------
191815 -- 4262811 - Generate the Accrual Reversal lines
191816 -------------------------------------------------------------------------------------------
191817 BEGIN
191818 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
191819 (g_array_event(p_event_id).array_value_num('header_index'));
191820 IF l_acc_rev_flag IS NULL THEN
191821 l_acc_rev_flag := 'N';
191822 END IF;
191823 EXCEPTION
191824 WHEN OTHERS THEN
191825 l_acc_rev_flag := 'N';
191826 END;
191827 --
191828 IF (l_acc_rev_flag = 'Y') THEN
191829
191830 -- 4645092 ------------------------------------------------------------------------------
191831 -- To allow MPA report to determine if it should generate report process
191832 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
191833 ------------------------------------------------------------------------------------------
191834
191835 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
191836 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
191837 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
191838 -- call ADRs
191839 -- Bug 4922099
191840 --
191841 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
191842 (NVL(l_actual_upg_option, 'N') = 'O') OR
191843 (NVL(l_enc_upg_option, 'N') = 'O')
191844 )
191845 THEN
191846 NULL;
191847 --
191848 --
191849
191850 l_ccid := AcctDerRule_16(
191851 p_application_id => p_application_id
191852 , p_ae_header_id => l_ae_header_id
191853 , p_source_20 => p_source_20
191854 , x_transaction_coa_id => l_adr_transaction_coa_id
191855 , x_accounting_coa_id => l_adr_accounting_coa_id
191856 , x_value_type_code => l_adr_value_type_code
191857 , p_side => 'NA'
191858 );
191859
191860 xla_ae_lines_pkg.set_ccid(
191861 p_code_combination_id => l_ccid
191862 , p_value_type_code => l_adr_value_type_code
191863 , p_transaction_coa_id => l_adr_transaction_coa_id
191864 , p_accounting_coa_id => l_adr_accounting_coa_id
191865 , p_adr_code => 'PI_DISTRIBUTION'
191866 , p_adr_type_code => 'S'
191867 , p_component_type => l_component_type
191868 , p_component_code => l_component_code
191869 , p_component_type_code => l_component_type_code
191870 , p_component_appl_id => l_component_appl_id
191871 , p_amb_context_code => l_amb_context_code
191872 , p_side => 'NA'
191873 );
191874
191875
191876 --
191877 --
191878 END IF;
191879
191880 --
191881 -- Update the line information that should be overwritten
191882 --
191883 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
191884 p_header_num => 1);
191885 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
191886
191887 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
191888
191889 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
191890 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
191891 END IF;
191892
191893 --
191894 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
191895 --
191896 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
191897 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
191898 ELSE
191899 ---------------------------------------------------------------------------------------------------
191900 -- 4262811a Switch Sign
191901 ---------------------------------------------------------------------------------------------------
191902 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
191903 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
191904 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191905 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
191906 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191907 -- 5132302
191908 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
191909 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
191910
191911 END IF;
191912
191913 -- 4955764
191914 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
191915 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
191916
191917
191918 XLA_AE_LINES_PKG.ValidateCurrentLine;
191919 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
191920
191921 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
191922 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
191923 ,p_balance_type_code => l_balance_type_code);
191924
191925 END IF;
191926
191927 -----------------------------------------------------------------------------------------
191928 -- 4262811 Multiperiod Accounting
191929 -----------------------------------------------------------------------------------------
191930 -- No MPA option is assigned.
191931
191932
191933 END IF;
191934 END IF;
191935 --
191936
191937 --
191938 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
191939 trace
191940 (p_msg => 'END of AcctLineType_351'
191941 ,p_level => C_LEVEL_PROCEDURE
191942 ,p_module => l_log_module);
191943 END IF;
191944 --
191945 EXCEPTION
191946 WHEN xla_exceptions_pkg.application_exception THEN
191947 RAISE;
191948 WHEN OTHERS THEN
191949 xla_exceptions_pkg.raise_message
191950 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_351');
191951 END AcctLineType_351;
191952 --
191953
191954 ---------------------------------------
191955 --
191956 -- PRIVATE FUNCTION
191957 -- AcctLineType_352
191958 --
191959 ---------------------------------------
191960 PROCEDURE AcctLineType_352 (
191961 p_application_id IN NUMBER
191962 ,p_event_id IN NUMBER
191963 ,p_calculate_acctd_flag IN VARCHAR2
191964 ,p_calculate_g_l_flag IN VARCHAR2
191965 ,p_actual_flag IN OUT VARCHAR2
191966 ,p_balance_type_code OUT VARCHAR2
191967 ,p_gain_or_loss_ref OUT VARCHAR2
191968
191969 --TRANSACTION_ID
191970 , p_source_1 IN NUMBER
191971 --Item Concatenated Segments
191972 , p_source_2 IN VARCHAR2
191973 --Transaction Quantity
191974 , p_source_3 IN NUMBER
191975 --Transaction Unit of Measure Code
191976 , p_source_4 IN VARCHAR2
191977 --Inventory Transaction Type Description
191978 , p_source_5 IN VARCHAR2
191979 --Cost Management Default Account
191980 , p_source_11 IN NUMBER
191981 --DISTRIBUTION_IDENTIFIER
191982 , p_source_84 IN NUMBER
191983 --Distribution Type
191984 , p_source_85 IN VARCHAR2
191985 , p_source_85_meaning IN VARCHAR2
191986 --Entered Currency Code
191987 , p_source_88 IN VARCHAR2
191988 --Entered Amount
191989 , p_source_91 IN NUMBER
191990 --Currency Conversion Date
191991 , p_source_92 IN DATE
191992 --Currency Conversion Rate
191993 , p_source_93 IN NUMBER
191994 --Currency Conversion Type
191995 , p_source_94 IN VARCHAR2
191996 --Accounted Amount
191997 , p_source_95 IN NUMBER
191998 --Accounting Line Type
191999 , p_source_97 IN NUMBER
192000 )
192001 IS
192002
192003 l_component_type VARCHAR2(80);
192004 l_component_code VARCHAR2(30);
192005 l_component_type_code VARCHAR2(1);
192006 l_component_appl_id INTEGER;
192007 l_amb_context_code VARCHAR2(30);
192008 l_entity_code VARCHAR2(30);
192009 l_event_class_code VARCHAR2(30);
192010 l_ae_header_id NUMBER;
192011 l_event_type_code VARCHAR2(30);
192012 l_line_definition_code VARCHAR2(30);
192013 l_line_definition_owner_code VARCHAR2(1);
192014 --
192015 -- adr variables
192016 l_segment VARCHAR2(30);
192017 l_ccid NUMBER;
192018 l_adr_transaction_coa_id NUMBER;
192019 l_adr_accounting_coa_id NUMBER;
192020 l_adr_flexfield_segment_code VARCHAR2(30);
192021 l_adr_flex_value_set_id NUMBER;
192022 l_adr_value_type_code VARCHAR2(30);
192023 l_adr_value_combination_id NUMBER;
192024 l_adr_value_segment_code VARCHAR2(30);
192025
192026 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
192027 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
192028 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
192029 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
192030
192031 -- 4262811 Variables ------------------------------------------------------------------------------------------
192032 l_entered_amt_idx NUMBER;
192033 l_accted_amt_idx NUMBER;
192034 l_acc_rev_flag VARCHAR2(1);
192035 l_accrual_line_num NUMBER;
192036 l_tmp_amt NUMBER;
192037 l_acc_rev_natural_side_code VARCHAR2(1);
192038
192039 l_num_entries NUMBER;
192040 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
192041 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
192042 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
192043 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
192044 l_recog_line_1 NUMBER;
192045 l_recog_line_2 NUMBER;
192046
192047 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
192048 l_bflow_applied_to_amt NUMBER; -- 5132302
192049 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
192050
192051 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
192052
192053 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
192054 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
192055
192056 ---------------------------------------------------------------------------------------------------------------
192057
192058
192059 --
192060 -- bulk performance
192061 --
192062 l_balance_type_code VARCHAR2(1);
192063 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
192064 l_log_module VARCHAR2(240);
192065
192066 --
192067 -- Upgrade strategy
192068 --
192069 l_actual_upg_option VARCHAR2(1);
192070 l_enc_upg_option VARCHAR2(1);
192071
192072 --
192073 BEGIN
192074 --
192075 IF g_log_enabled THEN
192076 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_352';
192077 END IF;
192078 --
192079 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192080
192081 trace
192082 (p_msg => 'BEGIN of AcctLineType_352'
192083 ,p_level => C_LEVEL_PROCEDURE
192084 ,p_module => l_log_module);
192085
192086 END IF;
192087 --
192088 l_component_type := 'AMB_JLT';
192089 l_component_code := 'OFFSET';
192090 l_component_type_code := 'S';
192091 l_component_appl_id := 707;
192092 l_amb_context_code := 'DEFAULT';
192093 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
192094 l_event_class_code := 'USER_DEFINE';
192095 l_event_type_code := 'UFOB_SHIP_RECIPIENT_SHIP_NO_TP';
192096 l_line_definition_owner_code := 'S';
192097 l_line_definition_code := 'PI_FOB_SHIP_RECIPIENT_SHIP_NTP';
192098 --
192099 l_balance_type_code := 'A';
192100 l_segment := NULL;
192101 l_ccid := NULL;
192102 l_adr_transaction_coa_id := NULL;
192103 l_adr_accounting_coa_id := NULL;
192104 l_adr_flexfield_segment_code := NULL;
192105 l_adr_flex_value_set_id := NULL;
192106 l_adr_value_type_code := NULL;
192107 l_adr_value_combination_id := NULL;
192108 l_adr_value_segment_code := NULL;
192109
192110 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
192111 l_bflow_class_code := ''; -- 4219869 Business Flow
192112 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
192113 l_budgetary_control_flag := 'N';
192114
192115 l_bflow_applied_to_amt_idx := NULL; -- 5132302
192116 l_bflow_applied_to_amt := NULL; -- 5132302
192117 l_entered_amt_idx := NULL; -- 4262811
192118 l_accted_amt_idx := NULL; -- 4262811
192119 l_acc_rev_flag := NULL; -- 4262811
192120 l_accrual_line_num := NULL; -- 4262811
192121 l_tmp_amt := NULL; -- 4262811
192122 --
192123
192124 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
192125 l_balance_type_code <> 'B' THEN
192126 IF NVL(p_source_97,9E125) = 2
192127 THEN
192128
192129 --
192130 XLA_AE_LINES_PKG.SetNewLine;
192131
192132 p_balance_type_code := l_balance_type_code;
192133 -- set the flag so later we will know whether the gain loss line needs to be created
192134
192135 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
192136 p_actual_flag :='A';
192137 END IF;
192138
192139 --
192140 -- bulk performance
192141 --
192142 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
192143 p_header_num => 0); -- 4262811
192144 --
192145 -- set accounting line options
192146 --
192147 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
192148 p_natural_side_code => 'D'
192149 , p_gain_or_loss_flag => 'N'
192150 , p_gl_transfer_mode_code => 'S'
192151 , p_acct_entry_type_code => 'A'
192152 , p_switch_side_flag => 'Y'
192153 , p_merge_duplicate_code => 'N'
192154 );
192155 --
192156 l_acc_rev_natural_side_code := 'C'; -- 4262811
192157 --
192158 --
192159 -- set accounting line type info
192160 --
192161 xla_ae_lines_pkg.SetAcctLineType
192162 (p_component_type => l_component_type
192163 ,p_event_type_code => l_event_type_code
192164 ,p_line_definition_owner_code => l_line_definition_owner_code
192165 ,p_line_definition_code => l_line_definition_code
192166 ,p_accounting_line_code => l_component_code
192167 ,p_accounting_line_type_code => l_component_type_code
192168 ,p_accounting_line_appl_id => l_component_appl_id
192169 ,p_amb_context_code => l_amb_context_code
192170 ,p_entity_code => l_entity_code
192171 ,p_event_class_code => l_event_class_code);
192172 --
192173 -- set accounting class
192174 --
192175 xla_ae_lines_pkg.SetAcctClass(
192176 p_accounting_class_code => 'OFFSET'
192177 , p_ae_header_id => l_ae_header_id
192178 );
192179
192180 --
192181 -- set rounding class
192182 --
192183 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
192184 'OFFSET';
192185
192186 --
192187 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
192188 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
192189 --
192190 -- bulk performance
192191 --
192192 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
192193
192194 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
192195 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
192196
192197 -- 4955764
192198 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
192199 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
192200
192201 -- 4458381 Public Sector Enh
192202
192203 --
192204 -- set accounting attributes for the line type
192205 --
192206 l_entered_amt_idx := 3;
192207 l_accted_amt_idx := 8;
192208 l_bflow_applied_to_amt_idx := NULL; -- 5132302
192209 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
192210 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
192211 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
192212 l_rec_acct_attrs.array_char_value(2) := p_source_85;
192213 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
192214 l_rec_acct_attrs.array_num_value(3) := p_source_91;
192215 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
192216 l_rec_acct_attrs.array_char_value(4) := p_source_88;
192217 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
192218 l_rec_acct_attrs.array_date_value(5) := p_source_92;
192219 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
192220 l_rec_acct_attrs.array_num_value(6) := p_source_93;
192221 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
192222 l_rec_acct_attrs.array_char_value(7) := p_source_94;
192223 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
192224 l_rec_acct_attrs.array_num_value(8) := p_source_95;
192225
192226 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
192227 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
192228
192229 ---------------------------------------------------------------------------------------------------------------
192230 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
192231 ---------------------------------------------------------------------------------------------------------------
192232 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
192233
192234 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
192235 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
192236
192237 IF xla_accounting_cache_pkg.GetValueChar
192238 (p_source_code => 'LEDGER_CATEGORY_CODE'
192239 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
192240 AND l_bflow_method_code = 'PRIOR_ENTRY'
192241 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
192242 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
192243 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
192244 )
192245 THEN
192246 xla_ae_lines_pkg.BflowUpgEntry
192247 (p_business_method_code => l_bflow_method_code
192248 ,p_business_class_code => l_bflow_class_code
192249 ,p_balance_type => l_balance_type_code);
192250 ELSE
192251 NULL;
192252 -- No business flow processing for business flow method of NONE.
192253 END IF;
192254
192255 --
192256 -- call analytical criteria
192257 --
192258
192259 --
192260 -- call description
192261 --
192262
192263 xla_ae_lines_pkg.SetLineDescription(
192264 p_ae_header_id => l_ae_header_id
192265 ,p_description => Description_1 (
192266 p_application_id => p_application_id
192267 , p_ae_header_id => l_ae_header_id
192268 , p_source_1 => p_source_1
192269 , p_source_2 => p_source_2
192270 , p_source_3 => p_source_3
192271 , p_source_4 => p_source_4
192272 , p_source_5 => p_source_5
192273 )
192274 );
192275
192276
192277 --
192278 -- call ADRs
192279 -- Bug 4922099
192280 --
192281 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
192282 (NVL(l_actual_upg_option, 'N') = 'O') OR
192283 (NVL(l_enc_upg_option, 'N') = 'O')
192284 )
192285 THEN
192286 NULL;
192287 --
192288 --
192289
192290 l_ccid := AcctDerRule_6(
192291 p_application_id => p_application_id
192292 , p_ae_header_id => l_ae_header_id
192293 , p_source_11 => p_source_11
192294 , x_transaction_coa_id => l_adr_transaction_coa_id
192295 , x_accounting_coa_id => l_adr_accounting_coa_id
192296 , x_value_type_code => l_adr_value_type_code
192297 , p_side => 'NA'
192298 );
192299
192300 xla_ae_lines_pkg.set_ccid(
192301 p_code_combination_id => l_ccid
192302 , p_value_type_code => l_adr_value_type_code
192303 , p_transaction_coa_id => l_adr_transaction_coa_id
192304 , p_accounting_coa_id => l_adr_accounting_coa_id
192305 , p_adr_code => 'CST_DEFAULT'
192306 , p_adr_type_code => 'S'
192307 , p_component_type => l_component_type
192308 , p_component_code => l_component_code
192309 , p_component_type_code => l_component_type_code
192310 , p_component_appl_id => l_component_appl_id
192311 , p_amb_context_code => l_amb_context_code
192312 , p_side => 'NA'
192313 );
192314
192315
192316 --
192317 --
192318 END IF;
192319 --
192320 -- Bug 4922099
192321 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
192322 (NVL(l_enc_upg_option, 'N') = 'O')
192323 ) AND
192324 (l_bflow_method_code = 'PRIOR_ENTRY')
192325 )
192326 THEN
192327 IF
192328 --
192329 1 = 2
192330 --
192331 THEN
192332 xla_accounting_err_pkg.build_message
192333 (p_appli_s_name => 'XLA'
192334 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
192335 ,p_token_1 => 'LINE_NUMBER'
192336 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
192337 ,p_token_2 => 'LINE_TYPE_NAME'
192338 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
192339 l_component_type
192340 ,l_component_code
192341 ,l_component_type_code
192342 ,l_component_appl_id
192343 ,l_amb_context_code
192344 ,l_entity_code
192345 ,l_event_class_code
192346 )
192347 ,p_token_3 => 'OWNER'
192348 ,p_value_3 => xla_lookups_pkg.get_meaning(
192349 p_lookup_type => 'XLA_OWNER_TYPE'
192350 ,p_lookup_code => l_component_type_code
192351 )
192352 ,p_token_4 => 'PRODUCT_NAME'
192353 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
192354 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
192355 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
192356 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
192357 ,p_ae_header_id => NULL
192358 );
192359
192360 IF (C_LEVEL_ERROR>= g_log_level) THEN
192361 trace
192362 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
192363 ,p_level => C_LEVEL_ERROR
192364 ,p_module => l_log_module);
192365 END IF;
192366 END IF;
192367 END IF;
192368 --
192369 --
192370 ------------------------------------------------------------------------------------------------
192371 -- 4219869 Business Flow
192372 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
192373 -- Prior Entry. Currently, the following code is always generated.
192374 ------------------------------------------------------------------------------------------------
192375 XLA_AE_LINES_PKG.ValidateCurrentLine;
192376
192377 ------------------------------------------------------------------------------------
192378 -- 4219869 Business Flow
192379 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
192380 ------------------------------------------------------------------------------------
192381 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
192382
192383 ----------------------------------------------------------------------------------
192384 -- 4219869 Business Flow
192385 -- Update journal entry status -- Need to generate this within IF <condition>
192386 ----------------------------------------------------------------------------------
192387 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
192388 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
192389 ,p_balance_type_code => l_balance_type_code
192390 );
192391
192392 -------------------------------------------------------------------------------------------
192393 -- 4262811 - Generate the Accrual Reversal lines
192394 -------------------------------------------------------------------------------------------
192395 BEGIN
192396 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
192397 (g_array_event(p_event_id).array_value_num('header_index'));
192398 IF l_acc_rev_flag IS NULL THEN
192399 l_acc_rev_flag := 'N';
192400 END IF;
192401 EXCEPTION
192402 WHEN OTHERS THEN
192403 l_acc_rev_flag := 'N';
192404 END;
192405 --
192406 IF (l_acc_rev_flag = 'Y') THEN
192407
192408 -- 4645092 ------------------------------------------------------------------------------
192409 -- To allow MPA report to determine if it should generate report process
192410 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
192411 ------------------------------------------------------------------------------------------
192412
192413 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
192414 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
192415 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
192416 -- call ADRs
192417 -- Bug 4922099
192418 --
192419 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
192420 (NVL(l_actual_upg_option, 'N') = 'O') OR
192421 (NVL(l_enc_upg_option, 'N') = 'O')
192422 )
192423 THEN
192424 NULL;
192425 --
192426 --
192427
192428 l_ccid := AcctDerRule_6(
192429 p_application_id => p_application_id
192430 , p_ae_header_id => l_ae_header_id
192431 , p_source_11 => p_source_11
192432 , x_transaction_coa_id => l_adr_transaction_coa_id
192433 , x_accounting_coa_id => l_adr_accounting_coa_id
192434 , x_value_type_code => l_adr_value_type_code
192435 , p_side => 'NA'
192436 );
192437
192438 xla_ae_lines_pkg.set_ccid(
192439 p_code_combination_id => l_ccid
192440 , p_value_type_code => l_adr_value_type_code
192441 , p_transaction_coa_id => l_adr_transaction_coa_id
192442 , p_accounting_coa_id => l_adr_accounting_coa_id
192443 , p_adr_code => 'CST_DEFAULT'
192444 , p_adr_type_code => 'S'
192445 , p_component_type => l_component_type
192446 , p_component_code => l_component_code
192447 , p_component_type_code => l_component_type_code
192448 , p_component_appl_id => l_component_appl_id
192449 , p_amb_context_code => l_amb_context_code
192450 , p_side => 'NA'
192451 );
192452
192453
192454 --
192455 --
192456 END IF;
192457
192458 --
192459 -- Update the line information that should be overwritten
192460 --
192461 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
192462 p_header_num => 1);
192463 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
192464
192465 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
192466
192467 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
192468 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
192469 END IF;
192470
192471 --
192472 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
192473 --
192474 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
192475 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
192476 ELSE
192477 ---------------------------------------------------------------------------------------------------
192478 -- 4262811a Switch Sign
192479 ---------------------------------------------------------------------------------------------------
192480 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
192481 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
192482 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
192483 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
192484 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
192485 -- 5132302
192486 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
192487 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
192488
192489 END IF;
192490
192491 -- 4955764
192492 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
192493 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
192494
192495
192496 XLA_AE_LINES_PKG.ValidateCurrentLine;
192497 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
192498
192499 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
192500 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
192501 ,p_balance_type_code => l_balance_type_code);
192502
192503 END IF;
192504
192505 -----------------------------------------------------------------------------------------
192506 -- 4262811 Multiperiod Accounting
192507 -----------------------------------------------------------------------------------------
192508 -- No MPA option is assigned.
192509
192510
192511 END IF;
192512 END IF;
192513 --
192514
192515 --
192516 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192517 trace
192518 (p_msg => 'END of AcctLineType_352'
192519 ,p_level => C_LEVEL_PROCEDURE
192520 ,p_module => l_log_module);
192521 END IF;
192522 --
192523 EXCEPTION
192524 WHEN xla_exceptions_pkg.application_exception THEN
192525 RAISE;
192526 WHEN OTHERS THEN
192527 xla_exceptions_pkg.raise_message
192528 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_352');
192529 END AcctLineType_352;
192530 --
192531
192532 ---------------------------------------
192533 --
192534 -- PRIVATE FUNCTION
192535 -- AcctLineType_353
192536 --
192537 ---------------------------------------
192538 PROCEDURE AcctLineType_353 (
192539 p_application_id IN NUMBER
192540 ,p_event_id IN NUMBER
192541 ,p_calculate_acctd_flag IN VARCHAR2
192542 ,p_calculate_g_l_flag IN VARCHAR2
192543 ,p_actual_flag IN OUT VARCHAR2
192544 ,p_balance_type_code OUT VARCHAR2
192545 ,p_gain_or_loss_ref OUT VARCHAR2
192546
192547 --TRANSACTION_ID
192548 , p_source_1 IN NUMBER
192549 --Item Concatenated Segments
192550 , p_source_2 IN VARCHAR2
192551 --Transaction Quantity
192552 , p_source_3 IN NUMBER
192553 --Transaction Unit of Measure Code
192554 , p_source_4 IN VARCHAR2
192555 --Inventory Transaction Type Description
192556 , p_source_5 IN VARCHAR2
192557 --Cost Management Default Account
192558 , p_source_11 IN NUMBER
192559 --DISTRIBUTION_IDENTIFIER
192560 , p_source_84 IN NUMBER
192561 --Distribution Type
192562 , p_source_85 IN VARCHAR2
192563 , p_source_85_meaning IN VARCHAR2
192564 --Entered Currency Code
192565 , p_source_88 IN VARCHAR2
192566 --Entered Amount
192567 , p_source_91 IN NUMBER
192568 --Currency Conversion Date
192569 , p_source_92 IN DATE
192570 --Currency Conversion Rate
192571 , p_source_93 IN NUMBER
192572 --Currency Conversion Type
192573 , p_source_94 IN VARCHAR2
192574 --Accounted Amount
192575 , p_source_95 IN NUMBER
192576 --Accounting Line Type
192577 , p_source_97 IN NUMBER
192578 )
192579 IS
192580
192581 l_component_type VARCHAR2(80);
192582 l_component_code VARCHAR2(30);
192583 l_component_type_code VARCHAR2(1);
192584 l_component_appl_id INTEGER;
192585 l_amb_context_code VARCHAR2(30);
192586 l_entity_code VARCHAR2(30);
192587 l_event_class_code VARCHAR2(30);
192588 l_ae_header_id NUMBER;
192589 l_event_type_code VARCHAR2(30);
192590 l_line_definition_code VARCHAR2(30);
192591 l_line_definition_owner_code VARCHAR2(1);
192592 --
192593 -- adr variables
192594 l_segment VARCHAR2(30);
192595 l_ccid NUMBER;
192596 l_adr_transaction_coa_id NUMBER;
192597 l_adr_accounting_coa_id NUMBER;
192598 l_adr_flexfield_segment_code VARCHAR2(30);
192599 l_adr_flex_value_set_id NUMBER;
192600 l_adr_value_type_code VARCHAR2(30);
192601 l_adr_value_combination_id NUMBER;
192602 l_adr_value_segment_code VARCHAR2(30);
192603
192604 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
192605 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
192606 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
192607 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
192608
192609 -- 4262811 Variables ------------------------------------------------------------------------------------------
192610 l_entered_amt_idx NUMBER;
192611 l_accted_amt_idx NUMBER;
192612 l_acc_rev_flag VARCHAR2(1);
192613 l_accrual_line_num NUMBER;
192614 l_tmp_amt NUMBER;
192615 l_acc_rev_natural_side_code VARCHAR2(1);
192616
192617 l_num_entries NUMBER;
192618 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
192619 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
192620 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
192621 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
192622 l_recog_line_1 NUMBER;
192623 l_recog_line_2 NUMBER;
192624
192625 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
192626 l_bflow_applied_to_amt NUMBER; -- 5132302
192627 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
192628
192629 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
192630
192631 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
192632 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
192633
192634 ---------------------------------------------------------------------------------------------------------------
192635
192636
192637 --
192638 -- bulk performance
192639 --
192640 l_balance_type_code VARCHAR2(1);
192641 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
192642 l_log_module VARCHAR2(240);
192643
192644 --
192645 -- Upgrade strategy
192646 --
192647 l_actual_upg_option VARCHAR2(1);
192648 l_enc_upg_option VARCHAR2(1);
192649
192650 --
192651 BEGIN
192652 --
192653 IF g_log_enabled THEN
192654 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_353';
192655 END IF;
192656 --
192657 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192658
192659 trace
192660 (p_msg => 'BEGIN of AcctLineType_353'
192661 ,p_level => C_LEVEL_PROCEDURE
192662 ,p_module => l_log_module);
192663
192664 END IF;
192665 --
192666 l_component_type := 'AMB_JLT';
192667 l_component_code := 'OFFSET';
192668 l_component_type_code := 'S';
192669 l_component_appl_id := 707;
192670 l_amb_context_code := 'DEFAULT';
192671 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
192672 l_event_class_code := 'WIP_MTL';
192673 l_event_type_code := 'WIP_ASSEMBLY_RETURN';
192674 l_line_definition_owner_code := 'S';
192675 l_line_definition_code := 'PI_WIP_ASSEMBLY_RETURN';
192676 --
192677 l_balance_type_code := 'A';
192678 l_segment := NULL;
192679 l_ccid := NULL;
192680 l_adr_transaction_coa_id := NULL;
192681 l_adr_accounting_coa_id := NULL;
192682 l_adr_flexfield_segment_code := NULL;
192683 l_adr_flex_value_set_id := NULL;
192684 l_adr_value_type_code := NULL;
192685 l_adr_value_combination_id := NULL;
192686 l_adr_value_segment_code := NULL;
192687
192688 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
192689 l_bflow_class_code := ''; -- 4219869 Business Flow
192690 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
192691 l_budgetary_control_flag := 'N';
192692
192693 l_bflow_applied_to_amt_idx := NULL; -- 5132302
192694 l_bflow_applied_to_amt := NULL; -- 5132302
192695 l_entered_amt_idx := NULL; -- 4262811
192696 l_accted_amt_idx := NULL; -- 4262811
192697 l_acc_rev_flag := NULL; -- 4262811
192698 l_accrual_line_num := NULL; -- 4262811
192699 l_tmp_amt := NULL; -- 4262811
192700 --
192701
192702 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
192703 l_balance_type_code <> 'B' THEN
192704 IF NVL(p_source_97,9E125) = 2
192705 THEN
192706
192707 --
192708 XLA_AE_LINES_PKG.SetNewLine;
192709
192710 p_balance_type_code := l_balance_type_code;
192711 -- set the flag so later we will know whether the gain loss line needs to be created
192712
192713 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
192714 p_actual_flag :='A';
192715 END IF;
192716
192717 --
192718 -- bulk performance
192719 --
192720 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
192721 p_header_num => 0); -- 4262811
192722 --
192723 -- set accounting line options
192724 --
192725 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
192726 p_natural_side_code => 'D'
192727 , p_gain_or_loss_flag => 'N'
192728 , p_gl_transfer_mode_code => 'S'
192729 , p_acct_entry_type_code => 'A'
192730 , p_switch_side_flag => 'Y'
192731 , p_merge_duplicate_code => 'N'
192732 );
192733 --
192734 l_acc_rev_natural_side_code := 'C'; -- 4262811
192735 --
192736 --
192737 -- set accounting line type info
192738 --
192739 xla_ae_lines_pkg.SetAcctLineType
192740 (p_component_type => l_component_type
192741 ,p_event_type_code => l_event_type_code
192742 ,p_line_definition_owner_code => l_line_definition_owner_code
192743 ,p_line_definition_code => l_line_definition_code
192744 ,p_accounting_line_code => l_component_code
192745 ,p_accounting_line_type_code => l_component_type_code
192746 ,p_accounting_line_appl_id => l_component_appl_id
192747 ,p_amb_context_code => l_amb_context_code
192748 ,p_entity_code => l_entity_code
192749 ,p_event_class_code => l_event_class_code);
192750 --
192751 -- set accounting class
192752 --
192753 xla_ae_lines_pkg.SetAcctClass(
192754 p_accounting_class_code => 'OFFSET'
192755 , p_ae_header_id => l_ae_header_id
192756 );
192757
192758 --
192759 -- set rounding class
192760 --
192761 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
192762 'OFFSET';
192763
192764 --
192765 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
192766 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
192767 --
192768 -- bulk performance
192769 --
192770 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
192771
192772 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
192773 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
192774
192775 -- 4955764
192776 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
192777 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
192778
192779 -- 4458381 Public Sector Enh
192780
192781 --
192782 -- set accounting attributes for the line type
192783 --
192784 l_entered_amt_idx := 3;
192785 l_accted_amt_idx := 8;
192786 l_bflow_applied_to_amt_idx := NULL; -- 5132302
192787 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
192788 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
192789 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
192790 l_rec_acct_attrs.array_char_value(2) := p_source_85;
192791 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
192792 l_rec_acct_attrs.array_num_value(3) := p_source_91;
192793 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
192794 l_rec_acct_attrs.array_char_value(4) := p_source_88;
192795 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
192796 l_rec_acct_attrs.array_date_value(5) := p_source_92;
192797 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
192798 l_rec_acct_attrs.array_num_value(6) := p_source_93;
192799 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
192800 l_rec_acct_attrs.array_char_value(7) := p_source_94;
192801 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
192802 l_rec_acct_attrs.array_num_value(8) := p_source_95;
192803
192804 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
192805 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
192806
192807 ---------------------------------------------------------------------------------------------------------------
192808 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
192809 ---------------------------------------------------------------------------------------------------------------
192810 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
192811
192812 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
192813 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
192814
192815 IF xla_accounting_cache_pkg.GetValueChar
192816 (p_source_code => 'LEDGER_CATEGORY_CODE'
192817 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
192818 AND l_bflow_method_code = 'PRIOR_ENTRY'
192819 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
192820 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
192821 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
192822 )
192823 THEN
192824 xla_ae_lines_pkg.BflowUpgEntry
192825 (p_business_method_code => l_bflow_method_code
192826 ,p_business_class_code => l_bflow_class_code
192827 ,p_balance_type => l_balance_type_code);
192828 ELSE
192829 NULL;
192830 -- No business flow processing for business flow method of NONE.
192831 END IF;
192832
192833 --
192834 -- call analytical criteria
192835 --
192836
192837 --
192838 -- call description
192839 --
192840
192841 xla_ae_lines_pkg.SetLineDescription(
192842 p_ae_header_id => l_ae_header_id
192843 ,p_description => Description_1 (
192844 p_application_id => p_application_id
192845 , p_ae_header_id => l_ae_header_id
192846 , p_source_1 => p_source_1
192847 , p_source_2 => p_source_2
192848 , p_source_3 => p_source_3
192849 , p_source_4 => p_source_4
192850 , p_source_5 => p_source_5
192851 )
192852 );
192853
192854
192855 --
192856 -- call ADRs
192857 -- Bug 4922099
192858 --
192859 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
192860 (NVL(l_actual_upg_option, 'N') = 'O') OR
192861 (NVL(l_enc_upg_option, 'N') = 'O')
192862 )
192863 THEN
192864 NULL;
192865 --
192866 --
192867
192868 l_ccid := AcctDerRule_6(
192869 p_application_id => p_application_id
192870 , p_ae_header_id => l_ae_header_id
192871 , p_source_11 => p_source_11
192872 , x_transaction_coa_id => l_adr_transaction_coa_id
192873 , x_accounting_coa_id => l_adr_accounting_coa_id
192874 , x_value_type_code => l_adr_value_type_code
192875 , p_side => 'NA'
192876 );
192877
192878 xla_ae_lines_pkg.set_ccid(
192879 p_code_combination_id => l_ccid
192880 , p_value_type_code => l_adr_value_type_code
192881 , p_transaction_coa_id => l_adr_transaction_coa_id
192882 , p_accounting_coa_id => l_adr_accounting_coa_id
192883 , p_adr_code => 'CST_DEFAULT'
192884 , p_adr_type_code => 'S'
192885 , p_component_type => l_component_type
192886 , p_component_code => l_component_code
192887 , p_component_type_code => l_component_type_code
192888 , p_component_appl_id => l_component_appl_id
192889 , p_amb_context_code => l_amb_context_code
192890 , p_side => 'NA'
192891 );
192892
192893
192894 --
192895 --
192896 END IF;
192897 --
192898 -- Bug 4922099
192899 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
192900 (NVL(l_enc_upg_option, 'N') = 'O')
192901 ) AND
192902 (l_bflow_method_code = 'PRIOR_ENTRY')
192903 )
192904 THEN
192905 IF
192906 --
192907 1 = 2
192908 --
192909 THEN
192910 xla_accounting_err_pkg.build_message
192911 (p_appli_s_name => 'XLA'
192912 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
192913 ,p_token_1 => 'LINE_NUMBER'
192914 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
192915 ,p_token_2 => 'LINE_TYPE_NAME'
192916 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
192917 l_component_type
192918 ,l_component_code
192919 ,l_component_type_code
192920 ,l_component_appl_id
192921 ,l_amb_context_code
192922 ,l_entity_code
192923 ,l_event_class_code
192924 )
192925 ,p_token_3 => 'OWNER'
192926 ,p_value_3 => xla_lookups_pkg.get_meaning(
192927 p_lookup_type => 'XLA_OWNER_TYPE'
192928 ,p_lookup_code => l_component_type_code
192929 )
192930 ,p_token_4 => 'PRODUCT_NAME'
192931 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
192932 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
192933 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
192934 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
192935 ,p_ae_header_id => NULL
192936 );
192937
192938 IF (C_LEVEL_ERROR>= g_log_level) THEN
192939 trace
192940 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
192941 ,p_level => C_LEVEL_ERROR
192942 ,p_module => l_log_module);
192943 END IF;
192944 END IF;
192945 END IF;
192946 --
192947 --
192948 ------------------------------------------------------------------------------------------------
192949 -- 4219869 Business Flow
192950 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
192951 -- Prior Entry. Currently, the following code is always generated.
192952 ------------------------------------------------------------------------------------------------
192953 XLA_AE_LINES_PKG.ValidateCurrentLine;
192954
192955 ------------------------------------------------------------------------------------
192956 -- 4219869 Business Flow
192957 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
192958 ------------------------------------------------------------------------------------
192959 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
192960
192961 ----------------------------------------------------------------------------------
192962 -- 4219869 Business Flow
192963 -- Update journal entry status -- Need to generate this within IF <condition>
192964 ----------------------------------------------------------------------------------
192965 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
192966 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
192967 ,p_balance_type_code => l_balance_type_code
192968 );
192969
192970 -------------------------------------------------------------------------------------------
192971 -- 4262811 - Generate the Accrual Reversal lines
192972 -------------------------------------------------------------------------------------------
192973 BEGIN
192974 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
192975 (g_array_event(p_event_id).array_value_num('header_index'));
192976 IF l_acc_rev_flag IS NULL THEN
192977 l_acc_rev_flag := 'N';
192978 END IF;
192979 EXCEPTION
192980 WHEN OTHERS THEN
192981 l_acc_rev_flag := 'N';
192982 END;
192983 --
192984 IF (l_acc_rev_flag = 'Y') THEN
192985
192986 -- 4645092 ------------------------------------------------------------------------------
192987 -- To allow MPA report to determine if it should generate report process
192988 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
192989 ------------------------------------------------------------------------------------------
192990
192991 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
192992 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
192993 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
192994 -- call ADRs
192995 -- Bug 4922099
192996 --
192997 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
192998 (NVL(l_actual_upg_option, 'N') = 'O') OR
192999 (NVL(l_enc_upg_option, 'N') = 'O')
193000 )
193001 THEN
193002 NULL;
193003 --
193004 --
193005
193006 l_ccid := AcctDerRule_6(
193007 p_application_id => p_application_id
193008 , p_ae_header_id => l_ae_header_id
193009 , p_source_11 => p_source_11
193010 , x_transaction_coa_id => l_adr_transaction_coa_id
193011 , x_accounting_coa_id => l_adr_accounting_coa_id
193012 , x_value_type_code => l_adr_value_type_code
193013 , p_side => 'NA'
193014 );
193015
193016 xla_ae_lines_pkg.set_ccid(
193017 p_code_combination_id => l_ccid
193018 , p_value_type_code => l_adr_value_type_code
193019 , p_transaction_coa_id => l_adr_transaction_coa_id
193020 , p_accounting_coa_id => l_adr_accounting_coa_id
193021 , p_adr_code => 'CST_DEFAULT'
193022 , p_adr_type_code => 'S'
193023 , p_component_type => l_component_type
193024 , p_component_code => l_component_code
193025 , p_component_type_code => l_component_type_code
193026 , p_component_appl_id => l_component_appl_id
193027 , p_amb_context_code => l_amb_context_code
193028 , p_side => 'NA'
193029 );
193030
193031
193032 --
193033 --
193034 END IF;
193035
193036 --
193037 -- Update the line information that should be overwritten
193038 --
193039 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
193040 p_header_num => 1);
193041 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
193042
193043 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
193044
193045 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
193046 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
193047 END IF;
193048
193049 --
193050 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
193051 --
193052 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
193053 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
193054 ELSE
193055 ---------------------------------------------------------------------------------------------------
193056 -- 4262811a Switch Sign
193057 ---------------------------------------------------------------------------------------------------
193058 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
193059 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
193060 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193061 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
193062 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193063 -- 5132302
193064 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
193065 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193066
193067 END IF;
193068
193069 -- 4955764
193070 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
193071 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
193072
193073
193074 XLA_AE_LINES_PKG.ValidateCurrentLine;
193075 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
193076
193077 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
193078 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
193079 ,p_balance_type_code => l_balance_type_code);
193080
193081 END IF;
193082
193083 -----------------------------------------------------------------------------------------
193084 -- 4262811 Multiperiod Accounting
193085 -----------------------------------------------------------------------------------------
193086 -- No MPA option is assigned.
193087
193088
193089 END IF;
193090 END IF;
193091 --
193092
193093 --
193094 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
193095 trace
193096 (p_msg => 'END of AcctLineType_353'
193097 ,p_level => C_LEVEL_PROCEDURE
193098 ,p_module => l_log_module);
193099 END IF;
193100 --
193101 EXCEPTION
193102 WHEN xla_exceptions_pkg.application_exception THEN
193103 RAISE;
193104 WHEN OTHERS THEN
193105 xla_exceptions_pkg.raise_message
193106 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_353');
193107 END AcctLineType_353;
193108 --
193109
193110 ---------------------------------------
193111 --
193112 -- PRIVATE FUNCTION
193113 -- AcctLineType_354
193114 --
193115 ---------------------------------------
193116 PROCEDURE AcctLineType_354 (
193117 p_application_id IN NUMBER
193118 ,p_event_id IN NUMBER
193119 ,p_calculate_acctd_flag IN VARCHAR2
193120 ,p_calculate_g_l_flag IN VARCHAR2
193121 ,p_actual_flag IN OUT VARCHAR2
193122 ,p_balance_type_code OUT VARCHAR2
193123 ,p_gain_or_loss_ref OUT VARCHAR2
193124
193125 --TRANSACTION_ID
193126 , p_source_1 IN NUMBER
193127 --Item Concatenated Segments
193128 , p_source_2 IN VARCHAR2
193129 --Transaction Quantity
193130 , p_source_3 IN NUMBER
193131 --Transaction Unit of Measure Code
193132 , p_source_4 IN VARCHAR2
193133 --Inventory Transaction Type Description
193134 , p_source_5 IN VARCHAR2
193135 --Cost Management Default Account
193136 , p_source_11 IN NUMBER
193137 --DISTRIBUTION_IDENTIFIER
193138 , p_source_84 IN NUMBER
193139 --Distribution Type
193140 , p_source_85 IN VARCHAR2
193141 , p_source_85_meaning IN VARCHAR2
193142 --Entered Currency Code
193143 , p_source_88 IN VARCHAR2
193144 --Entered Amount
193145 , p_source_91 IN NUMBER
193146 --Currency Conversion Date
193147 , p_source_92 IN DATE
193148 --Currency Conversion Rate
193149 , p_source_93 IN NUMBER
193150 --Currency Conversion Type
193151 , p_source_94 IN VARCHAR2
193152 --Accounted Amount
193153 , p_source_95 IN NUMBER
193154 --Accounting Line Type
193155 , p_source_97 IN NUMBER
193156 )
193157 IS
193158
193159 l_component_type VARCHAR2(80);
193160 l_component_code VARCHAR2(30);
193161 l_component_type_code VARCHAR2(1);
193162 l_component_appl_id INTEGER;
193163 l_amb_context_code VARCHAR2(30);
193164 l_entity_code VARCHAR2(30);
193165 l_event_class_code VARCHAR2(30);
193166 l_ae_header_id NUMBER;
193167 l_event_type_code VARCHAR2(30);
193168 l_line_definition_code VARCHAR2(30);
193169 l_line_definition_owner_code VARCHAR2(1);
193170 --
193171 -- adr variables
193172 l_segment VARCHAR2(30);
193173 l_ccid NUMBER;
193174 l_adr_transaction_coa_id NUMBER;
193175 l_adr_accounting_coa_id NUMBER;
193176 l_adr_flexfield_segment_code VARCHAR2(30);
193177 l_adr_flex_value_set_id NUMBER;
193178 l_adr_value_type_code VARCHAR2(30);
193179 l_adr_value_combination_id NUMBER;
193180 l_adr_value_segment_code VARCHAR2(30);
193181
193182 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
193183 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
193184 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
193185 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
193186
193187 -- 4262811 Variables ------------------------------------------------------------------------------------------
193188 l_entered_amt_idx NUMBER;
193189 l_accted_amt_idx NUMBER;
193190 l_acc_rev_flag VARCHAR2(1);
193191 l_accrual_line_num NUMBER;
193192 l_tmp_amt NUMBER;
193193 l_acc_rev_natural_side_code VARCHAR2(1);
193194
193195 l_num_entries NUMBER;
193196 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
193197 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
193198 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
193199 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
193200 l_recog_line_1 NUMBER;
193201 l_recog_line_2 NUMBER;
193202
193203 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
193204 l_bflow_applied_to_amt NUMBER; -- 5132302
193205 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
193206
193207 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
193208
193209 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
193210 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
193211
193212 ---------------------------------------------------------------------------------------------------------------
193213
193214
193215 --
193216 -- bulk performance
193217 --
193218 l_balance_type_code VARCHAR2(1);
193219 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
193220 l_log_module VARCHAR2(240);
193221
193222 --
193223 -- Upgrade strategy
193224 --
193225 l_actual_upg_option VARCHAR2(1);
193226 l_enc_upg_option VARCHAR2(1);
193227
193228 --
193229 BEGIN
193230 --
193231 IF g_log_enabled THEN
193232 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_354';
193233 END IF;
193234 --
193235 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
193236
193237 trace
193238 (p_msg => 'BEGIN of AcctLineType_354'
193239 ,p_level => C_LEVEL_PROCEDURE
193240 ,p_module => l_log_module);
193241
193242 END IF;
193243 --
193244 l_component_type := 'AMB_JLT';
193245 l_component_code := 'OFFSET';
193246 l_component_type_code := 'S';
193247 l_component_appl_id := 707;
193248 l_amb_context_code := 'DEFAULT';
193249 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
193250 l_event_class_code := 'WIP_MTL';
193251 l_event_type_code := 'WIP_COMP_RETURN';
193252 l_line_definition_owner_code := 'S';
193253 l_line_definition_code := 'PI_WIP_COMP_RETURN';
193254 --
193255 l_balance_type_code := 'A';
193256 l_segment := NULL;
193257 l_ccid := NULL;
193258 l_adr_transaction_coa_id := NULL;
193259 l_adr_accounting_coa_id := NULL;
193260 l_adr_flexfield_segment_code := NULL;
193261 l_adr_flex_value_set_id := NULL;
193262 l_adr_value_type_code := NULL;
193263 l_adr_value_combination_id := NULL;
193264 l_adr_value_segment_code := NULL;
193265
193266 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
193267 l_bflow_class_code := ''; -- 4219869 Business Flow
193268 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
193269 l_budgetary_control_flag := 'N';
193270
193271 l_bflow_applied_to_amt_idx := NULL; -- 5132302
193272 l_bflow_applied_to_amt := NULL; -- 5132302
193273 l_entered_amt_idx := NULL; -- 4262811
193274 l_accted_amt_idx := NULL; -- 4262811
193275 l_acc_rev_flag := NULL; -- 4262811
193276 l_accrual_line_num := NULL; -- 4262811
193277 l_tmp_amt := NULL; -- 4262811
193278 --
193279
193280 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
193281 l_balance_type_code <> 'B' THEN
193282 IF NVL(p_source_97,9E125) = 2
193283 THEN
193284
193285 --
193286 XLA_AE_LINES_PKG.SetNewLine;
193287
193288 p_balance_type_code := l_balance_type_code;
193289 -- set the flag so later we will know whether the gain loss line needs to be created
193290
193291 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
193292 p_actual_flag :='A';
193293 END IF;
193294
193295 --
193296 -- bulk performance
193297 --
193298 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
193299 p_header_num => 0); -- 4262811
193300 --
193301 -- set accounting line options
193302 --
193303 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
193304 p_natural_side_code => 'D'
193305 , p_gain_or_loss_flag => 'N'
193306 , p_gl_transfer_mode_code => 'S'
193307 , p_acct_entry_type_code => 'A'
193308 , p_switch_side_flag => 'Y'
193309 , p_merge_duplicate_code => 'N'
193310 );
193311 --
193312 l_acc_rev_natural_side_code := 'C'; -- 4262811
193313 --
193314 --
193315 -- set accounting line type info
193316 --
193317 xla_ae_lines_pkg.SetAcctLineType
193318 (p_component_type => l_component_type
193319 ,p_event_type_code => l_event_type_code
193320 ,p_line_definition_owner_code => l_line_definition_owner_code
193321 ,p_line_definition_code => l_line_definition_code
193322 ,p_accounting_line_code => l_component_code
193323 ,p_accounting_line_type_code => l_component_type_code
193324 ,p_accounting_line_appl_id => l_component_appl_id
193325 ,p_amb_context_code => l_amb_context_code
193326 ,p_entity_code => l_entity_code
193327 ,p_event_class_code => l_event_class_code);
193328 --
193329 -- set accounting class
193330 --
193331 xla_ae_lines_pkg.SetAcctClass(
193332 p_accounting_class_code => 'OFFSET'
193333 , p_ae_header_id => l_ae_header_id
193334 );
193335
193336 --
193337 -- set rounding class
193338 --
193339 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
193340 'OFFSET';
193341
193342 --
193343 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
193344 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
193345 --
193346 -- bulk performance
193347 --
193348 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
193349
193350 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
193351 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
193352
193353 -- 4955764
193354 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
193355 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
193356
193357 -- 4458381 Public Sector Enh
193358
193359 --
193360 -- set accounting attributes for the line type
193361 --
193362 l_entered_amt_idx := 3;
193363 l_accted_amt_idx := 8;
193364 l_bflow_applied_to_amt_idx := NULL; -- 5132302
193365 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
193366 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
193367 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
193368 l_rec_acct_attrs.array_char_value(2) := p_source_85;
193369 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
193370 l_rec_acct_attrs.array_num_value(3) := p_source_91;
193371 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
193372 l_rec_acct_attrs.array_char_value(4) := p_source_88;
193373 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
193374 l_rec_acct_attrs.array_date_value(5) := p_source_92;
193375 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
193376 l_rec_acct_attrs.array_num_value(6) := p_source_93;
193377 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
193378 l_rec_acct_attrs.array_char_value(7) := p_source_94;
193379 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
193380 l_rec_acct_attrs.array_num_value(8) := p_source_95;
193381
193382 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
193383 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
193384
193385 ---------------------------------------------------------------------------------------------------------------
193386 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
193387 ---------------------------------------------------------------------------------------------------------------
193388 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
193389
193390 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
193391 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
193392
193393 IF xla_accounting_cache_pkg.GetValueChar
193394 (p_source_code => 'LEDGER_CATEGORY_CODE'
193395 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
193396 AND l_bflow_method_code = 'PRIOR_ENTRY'
193397 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
193398 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
193399 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
193400 )
193401 THEN
193402 xla_ae_lines_pkg.BflowUpgEntry
193403 (p_business_method_code => l_bflow_method_code
193404 ,p_business_class_code => l_bflow_class_code
193405 ,p_balance_type => l_balance_type_code);
193406 ELSE
193407 NULL;
193408 -- No business flow processing for business flow method of NONE.
193409 END IF;
193410
193411 --
193412 -- call analytical criteria
193413 --
193414
193415 --
193416 -- call description
193417 --
193418
193419 xla_ae_lines_pkg.SetLineDescription(
193420 p_ae_header_id => l_ae_header_id
193421 ,p_description => Description_1 (
193422 p_application_id => p_application_id
193423 , p_ae_header_id => l_ae_header_id
193424 , p_source_1 => p_source_1
193425 , p_source_2 => p_source_2
193426 , p_source_3 => p_source_3
193427 , p_source_4 => p_source_4
193428 , p_source_5 => p_source_5
193429 )
193430 );
193431
193432
193433 --
193434 -- call ADRs
193435 -- Bug 4922099
193436 --
193437 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
193438 (NVL(l_actual_upg_option, 'N') = 'O') OR
193439 (NVL(l_enc_upg_option, 'N') = 'O')
193440 )
193441 THEN
193442 NULL;
193443 --
193444 --
193445
193446 l_ccid := AcctDerRule_6(
193447 p_application_id => p_application_id
193448 , p_ae_header_id => l_ae_header_id
193449 , p_source_11 => p_source_11
193450 , x_transaction_coa_id => l_adr_transaction_coa_id
193451 , x_accounting_coa_id => l_adr_accounting_coa_id
193452 , x_value_type_code => l_adr_value_type_code
193453 , p_side => 'NA'
193454 );
193455
193456 xla_ae_lines_pkg.set_ccid(
193457 p_code_combination_id => l_ccid
193458 , p_value_type_code => l_adr_value_type_code
193459 , p_transaction_coa_id => l_adr_transaction_coa_id
193460 , p_accounting_coa_id => l_adr_accounting_coa_id
193461 , p_adr_code => 'CST_DEFAULT'
193462 , p_adr_type_code => 'S'
193463 , p_component_type => l_component_type
193464 , p_component_code => l_component_code
193465 , p_component_type_code => l_component_type_code
193466 , p_component_appl_id => l_component_appl_id
193467 , p_amb_context_code => l_amb_context_code
193468 , p_side => 'NA'
193469 );
193470
193471
193472 --
193473 --
193474 END IF;
193475 --
193476 -- Bug 4922099
193477 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
193478 (NVL(l_enc_upg_option, 'N') = 'O')
193479 ) AND
193480 (l_bflow_method_code = 'PRIOR_ENTRY')
193481 )
193482 THEN
193483 IF
193484 --
193485 1 = 2
193486 --
193487 THEN
193488 xla_accounting_err_pkg.build_message
193489 (p_appli_s_name => 'XLA'
193490 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
193491 ,p_token_1 => 'LINE_NUMBER'
193492 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
193493 ,p_token_2 => 'LINE_TYPE_NAME'
193494 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
193495 l_component_type
193496 ,l_component_code
193497 ,l_component_type_code
193498 ,l_component_appl_id
193499 ,l_amb_context_code
193500 ,l_entity_code
193501 ,l_event_class_code
193502 )
193503 ,p_token_3 => 'OWNER'
193504 ,p_value_3 => xla_lookups_pkg.get_meaning(
193505 p_lookup_type => 'XLA_OWNER_TYPE'
193506 ,p_lookup_code => l_component_type_code
193507 )
193508 ,p_token_4 => 'PRODUCT_NAME'
193509 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
193510 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
193511 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
193512 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
193513 ,p_ae_header_id => NULL
193514 );
193515
193516 IF (C_LEVEL_ERROR>= g_log_level) THEN
193517 trace
193518 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
193519 ,p_level => C_LEVEL_ERROR
193520 ,p_module => l_log_module);
193521 END IF;
193522 END IF;
193523 END IF;
193524 --
193525 --
193526 ------------------------------------------------------------------------------------------------
193527 -- 4219869 Business Flow
193528 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
193529 -- Prior Entry. Currently, the following code is always generated.
193530 ------------------------------------------------------------------------------------------------
193531 XLA_AE_LINES_PKG.ValidateCurrentLine;
193532
193533 ------------------------------------------------------------------------------------
193534 -- 4219869 Business Flow
193535 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
193536 ------------------------------------------------------------------------------------
193537 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
193538
193539 ----------------------------------------------------------------------------------
193540 -- 4219869 Business Flow
193541 -- Update journal entry status -- Need to generate this within IF <condition>
193542 ----------------------------------------------------------------------------------
193543 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
193544 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
193545 ,p_balance_type_code => l_balance_type_code
193546 );
193547
193548 -------------------------------------------------------------------------------------------
193549 -- 4262811 - Generate the Accrual Reversal lines
193550 -------------------------------------------------------------------------------------------
193551 BEGIN
193552 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
193553 (g_array_event(p_event_id).array_value_num('header_index'));
193554 IF l_acc_rev_flag IS NULL THEN
193555 l_acc_rev_flag := 'N';
193556 END IF;
193557 EXCEPTION
193558 WHEN OTHERS THEN
193559 l_acc_rev_flag := 'N';
193560 END;
193561 --
193562 IF (l_acc_rev_flag = 'Y') THEN
193563
193564 -- 4645092 ------------------------------------------------------------------------------
193565 -- To allow MPA report to determine if it should generate report process
193566 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
193567 ------------------------------------------------------------------------------------------
193568
193569 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
193570 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
193571 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
193572 -- call ADRs
193573 -- Bug 4922099
193574 --
193575 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
193576 (NVL(l_actual_upg_option, 'N') = 'O') OR
193577 (NVL(l_enc_upg_option, 'N') = 'O')
193578 )
193579 THEN
193580 NULL;
193581 --
193582 --
193583
193584 l_ccid := AcctDerRule_6(
193585 p_application_id => p_application_id
193586 , p_ae_header_id => l_ae_header_id
193587 , p_source_11 => p_source_11
193588 , x_transaction_coa_id => l_adr_transaction_coa_id
193589 , x_accounting_coa_id => l_adr_accounting_coa_id
193590 , x_value_type_code => l_adr_value_type_code
193591 , p_side => 'NA'
193592 );
193593
193594 xla_ae_lines_pkg.set_ccid(
193595 p_code_combination_id => l_ccid
193596 , p_value_type_code => l_adr_value_type_code
193597 , p_transaction_coa_id => l_adr_transaction_coa_id
193598 , p_accounting_coa_id => l_adr_accounting_coa_id
193599 , p_adr_code => 'CST_DEFAULT'
193600 , p_adr_type_code => 'S'
193601 , p_component_type => l_component_type
193602 , p_component_code => l_component_code
193603 , p_component_type_code => l_component_type_code
193604 , p_component_appl_id => l_component_appl_id
193605 , p_amb_context_code => l_amb_context_code
193606 , p_side => 'NA'
193607 );
193608
193609
193610 --
193611 --
193612 END IF;
193613
193614 --
193615 -- Update the line information that should be overwritten
193616 --
193617 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
193618 p_header_num => 1);
193619 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
193620
193621 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
193622
193623 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
193624 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
193625 END IF;
193626
193627 --
193628 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
193629 --
193630 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
193631 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
193632 ELSE
193633 ---------------------------------------------------------------------------------------------------
193634 -- 4262811a Switch Sign
193635 ---------------------------------------------------------------------------------------------------
193636 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
193637 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
193638 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193639 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
193640 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193641 -- 5132302
193642 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
193643 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
193644
193645 END IF;
193646
193647 -- 4955764
193648 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
193649 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
193650
193651
193652 XLA_AE_LINES_PKG.ValidateCurrentLine;
193653 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
193654
193655 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
193656 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
193657 ,p_balance_type_code => l_balance_type_code);
193658
193659 END IF;
193660
193661 -----------------------------------------------------------------------------------------
193662 -- 4262811 Multiperiod Accounting
193663 -----------------------------------------------------------------------------------------
193664 -- No MPA option is assigned.
193665
193666
193667 END IF;
193668 END IF;
193669 --
193670
193671 --
193672 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
193673 trace
193674 (p_msg => 'END of AcctLineType_354'
193675 ,p_level => C_LEVEL_PROCEDURE
193676 ,p_module => l_log_module);
193677 END IF;
193678 --
193679 EXCEPTION
193680 WHEN xla_exceptions_pkg.application_exception THEN
193681 RAISE;
193682 WHEN OTHERS THEN
193683 xla_exceptions_pkg.raise_message
193684 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_354');
193685 END AcctLineType_354;
193686 --
193687
193688 ---------------------------------------
193689 --
193690 -- PRIVATE FUNCTION
193691 -- AcctLineType_355
193692 --
193693 ---------------------------------------
193694 PROCEDURE AcctLineType_355 (
193695 p_application_id IN NUMBER
193696 ,p_event_id IN NUMBER
193697 ,p_calculate_acctd_flag IN VARCHAR2
193698 ,p_calculate_g_l_flag IN VARCHAR2
193699 ,p_actual_flag IN OUT VARCHAR2
193700 ,p_balance_type_code OUT VARCHAR2
193701 ,p_gain_or_loss_ref OUT VARCHAR2
193702
193703 --TRANSACTION_ID
193704 , p_source_1 IN NUMBER
193705 --Item Concatenated Segments
193706 , p_source_2 IN VARCHAR2
193707 --Transaction Quantity
193708 , p_source_3 IN NUMBER
193709 --Transaction Unit of Measure Code
193710 , p_source_4 IN VARCHAR2
193711 --Inventory Transaction Type Description
193712 , p_source_5 IN VARCHAR2
193713 --Cost Management Default Account
193714 , p_source_11 IN NUMBER
193715 --DISTRIBUTION_IDENTIFIER
193716 , p_source_84 IN NUMBER
193717 --Distribution Type
193718 , p_source_85 IN VARCHAR2
193719 , p_source_85_meaning IN VARCHAR2
193720 --Entered Currency Code
193721 , p_source_88 IN VARCHAR2
193722 --Entered Amount
193723 , p_source_91 IN NUMBER
193724 --Currency Conversion Date
193725 , p_source_92 IN DATE
193726 --Currency Conversion Rate
193727 , p_source_93 IN NUMBER
193728 --Currency Conversion Type
193729 , p_source_94 IN VARCHAR2
193730 --Accounted Amount
193731 , p_source_95 IN NUMBER
193732 --Accounting Line Type
193733 , p_source_97 IN NUMBER
193734 )
193735 IS
193736
193737 l_component_type VARCHAR2(80);
193738 l_component_code VARCHAR2(30);
193739 l_component_type_code VARCHAR2(1);
193740 l_component_appl_id INTEGER;
193741 l_amb_context_code VARCHAR2(30);
193742 l_entity_code VARCHAR2(30);
193743 l_event_class_code VARCHAR2(30);
193744 l_ae_header_id NUMBER;
193745 l_event_type_code VARCHAR2(30);
193746 l_line_definition_code VARCHAR2(30);
193747 l_line_definition_owner_code VARCHAR2(1);
193748 --
193749 -- adr variables
193750 l_segment VARCHAR2(30);
193751 l_ccid NUMBER;
193752 l_adr_transaction_coa_id NUMBER;
193753 l_adr_accounting_coa_id NUMBER;
193754 l_adr_flexfield_segment_code VARCHAR2(30);
193755 l_adr_flex_value_set_id NUMBER;
193756 l_adr_value_type_code VARCHAR2(30);
193757 l_adr_value_combination_id NUMBER;
193758 l_adr_value_segment_code VARCHAR2(30);
193759
193760 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
193761 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
193762 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
193763 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
193764
193765 -- 4262811 Variables ------------------------------------------------------------------------------------------
193766 l_entered_amt_idx NUMBER;
193767 l_accted_amt_idx NUMBER;
193768 l_acc_rev_flag VARCHAR2(1);
193769 l_accrual_line_num NUMBER;
193770 l_tmp_amt NUMBER;
193771 l_acc_rev_natural_side_code VARCHAR2(1);
193772
193773 l_num_entries NUMBER;
193774 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
193775 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
193776 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
193777 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
193778 l_recog_line_1 NUMBER;
193779 l_recog_line_2 NUMBER;
193780
193781 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
193782 l_bflow_applied_to_amt NUMBER; -- 5132302
193783 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
193784
193785 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
193786
193787 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
193788 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
193789
193790 ---------------------------------------------------------------------------------------------------------------
193791
193792
193793 --
193794 -- bulk performance
193795 --
193796 l_balance_type_code VARCHAR2(1);
193797 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
193798 l_log_module VARCHAR2(240);
193799
193800 --
193801 -- Upgrade strategy
193802 --
193803 l_actual_upg_option VARCHAR2(1);
193804 l_enc_upg_option VARCHAR2(1);
193805
193806 --
193807 BEGIN
193808 --
193809 IF g_log_enabled THEN
193810 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_355';
193811 END IF;
193812 --
193813 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
193814
193815 trace
193816 (p_msg => 'BEGIN of AcctLineType_355'
193817 ,p_level => C_LEVEL_PROCEDURE
193818 ,p_module => l_log_module);
193819
193820 END IF;
193821 --
193822 l_component_type := 'AMB_JLT';
193823 l_component_code := 'OFFSET';
193824 l_component_type_code := 'S';
193825 l_component_appl_id := 707;
193826 l_amb_context_code := 'DEFAULT';
193827 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
193828 l_event_class_code := 'MISC_ISSUE_RCPT';
193829 l_event_type_code := 'MISC_ISSUE_RCPT_ALL';
193830 l_line_definition_owner_code := 'S';
193831 l_line_definition_code := 'PI_MISC_ISSUE_RCPT';
193832 --
193833 l_balance_type_code := 'A';
193834 l_segment := NULL;
193835 l_ccid := NULL;
193836 l_adr_transaction_coa_id := NULL;
193837 l_adr_accounting_coa_id := NULL;
193838 l_adr_flexfield_segment_code := NULL;
193839 l_adr_flex_value_set_id := NULL;
193840 l_adr_value_type_code := NULL;
193841 l_adr_value_combination_id := NULL;
193842 l_adr_value_segment_code := NULL;
193843
193844 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
193845 l_bflow_class_code := ''; -- 4219869 Business Flow
193846 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
193847 l_budgetary_control_flag := 'N';
193848
193849 l_bflow_applied_to_amt_idx := NULL; -- 5132302
193850 l_bflow_applied_to_amt := NULL; -- 5132302
193851 l_entered_amt_idx := NULL; -- 4262811
193852 l_accted_amt_idx := NULL; -- 4262811
193853 l_acc_rev_flag := NULL; -- 4262811
193854 l_accrual_line_num := NULL; -- 4262811
193855 l_tmp_amt := NULL; -- 4262811
193856 --
193857
193858 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
193859 l_balance_type_code <> 'B' THEN
193860 IF NVL(p_source_97,9E125) = 2
193861 THEN
193862
193863 --
193864 XLA_AE_LINES_PKG.SetNewLine;
193865
193866 p_balance_type_code := l_balance_type_code;
193867 -- set the flag so later we will know whether the gain loss line needs to be created
193868
193869 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
193870 p_actual_flag :='A';
193871 END IF;
193872
193873 --
193874 -- bulk performance
193875 --
193876 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
193877 p_header_num => 0); -- 4262811
193878 --
193879 -- set accounting line options
193880 --
193881 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
193882 p_natural_side_code => 'D'
193883 , p_gain_or_loss_flag => 'N'
193884 , p_gl_transfer_mode_code => 'S'
193885 , p_acct_entry_type_code => 'A'
193886 , p_switch_side_flag => 'Y'
193887 , p_merge_duplicate_code => 'N'
193888 );
193889 --
193890 l_acc_rev_natural_side_code := 'C'; -- 4262811
193891 --
193892 --
193893 -- set accounting line type info
193894 --
193895 xla_ae_lines_pkg.SetAcctLineType
193896 (p_component_type => l_component_type
193897 ,p_event_type_code => l_event_type_code
193898 ,p_line_definition_owner_code => l_line_definition_owner_code
193899 ,p_line_definition_code => l_line_definition_code
193900 ,p_accounting_line_code => l_component_code
193901 ,p_accounting_line_type_code => l_component_type_code
193902 ,p_accounting_line_appl_id => l_component_appl_id
193903 ,p_amb_context_code => l_amb_context_code
193904 ,p_entity_code => l_entity_code
193905 ,p_event_class_code => l_event_class_code);
193906 --
193907 -- set accounting class
193908 --
193909 xla_ae_lines_pkg.SetAcctClass(
193910 p_accounting_class_code => 'OFFSET'
193911 , p_ae_header_id => l_ae_header_id
193912 );
193913
193914 --
193915 -- set rounding class
193916 --
193917 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
193918 'OFFSET';
193919
193920 --
193921 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
193922 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
193923 --
193924 -- bulk performance
193925 --
193926 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
193927
193928 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
193929 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
193930
193931 -- 4955764
193932 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
193933 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
193934
193935 -- 4458381 Public Sector Enh
193936
193937 --
193938 -- set accounting attributes for the line type
193939 --
193940 l_entered_amt_idx := 3;
193941 l_accted_amt_idx := 8;
193942 l_bflow_applied_to_amt_idx := NULL; -- 5132302
193943 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
193944 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
193945 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
193946 l_rec_acct_attrs.array_char_value(2) := p_source_85;
193947 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
193948 l_rec_acct_attrs.array_num_value(3) := p_source_91;
193949 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
193950 l_rec_acct_attrs.array_char_value(4) := p_source_88;
193951 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
193952 l_rec_acct_attrs.array_date_value(5) := p_source_92;
193953 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
193954 l_rec_acct_attrs.array_num_value(6) := p_source_93;
193955 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
193956 l_rec_acct_attrs.array_char_value(7) := p_source_94;
193957 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
193958 l_rec_acct_attrs.array_num_value(8) := p_source_95;
193959
193960 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
193961 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
193962
193963 ---------------------------------------------------------------------------------------------------------------
193964 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
193965 ---------------------------------------------------------------------------------------------------------------
193966 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
193967
193968 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
193969 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
193970
193971 IF xla_accounting_cache_pkg.GetValueChar
193972 (p_source_code => 'LEDGER_CATEGORY_CODE'
193973 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
193974 AND l_bflow_method_code = 'PRIOR_ENTRY'
193975 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
193976 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
193977 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
193978 )
193979 THEN
193980 xla_ae_lines_pkg.BflowUpgEntry
193981 (p_business_method_code => l_bflow_method_code
193982 ,p_business_class_code => l_bflow_class_code
193983 ,p_balance_type => l_balance_type_code);
193984 ELSE
193985 NULL;
193986 -- No business flow processing for business flow method of NONE.
193987 END IF;
193988
193989 --
193990 -- call analytical criteria
193991 --
193992
193993 --
193994 -- call description
193995 --
193996
193997 xla_ae_lines_pkg.SetLineDescription(
193998 p_ae_header_id => l_ae_header_id
193999 ,p_description => Description_1 (
194000 p_application_id => p_application_id
194001 , p_ae_header_id => l_ae_header_id
194002 , p_source_1 => p_source_1
194003 , p_source_2 => p_source_2
194004 , p_source_3 => p_source_3
194005 , p_source_4 => p_source_4
194006 , p_source_5 => p_source_5
194007 )
194008 );
194009
194010
194011 --
194012 -- call ADRs
194013 -- Bug 4922099
194014 --
194015 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
194016 (NVL(l_actual_upg_option, 'N') = 'O') OR
194017 (NVL(l_enc_upg_option, 'N') = 'O')
194018 )
194019 THEN
194020 NULL;
194021 --
194022 --
194023
194024 l_ccid := AcctDerRule_6(
194025 p_application_id => p_application_id
194026 , p_ae_header_id => l_ae_header_id
194027 , p_source_11 => p_source_11
194028 , x_transaction_coa_id => l_adr_transaction_coa_id
194029 , x_accounting_coa_id => l_adr_accounting_coa_id
194030 , x_value_type_code => l_adr_value_type_code
194031 , p_side => 'NA'
194032 );
194033
194034 xla_ae_lines_pkg.set_ccid(
194035 p_code_combination_id => l_ccid
194036 , p_value_type_code => l_adr_value_type_code
194037 , p_transaction_coa_id => l_adr_transaction_coa_id
194038 , p_accounting_coa_id => l_adr_accounting_coa_id
194039 , p_adr_code => 'CST_DEFAULT'
194040 , p_adr_type_code => 'S'
194041 , p_component_type => l_component_type
194042 , p_component_code => l_component_code
194043 , p_component_type_code => l_component_type_code
194044 , p_component_appl_id => l_component_appl_id
194045 , p_amb_context_code => l_amb_context_code
194046 , p_side => 'NA'
194047 );
194048
194049
194050 --
194051 --
194052 END IF;
194053 --
194054 -- Bug 4922099
194055 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
194056 (NVL(l_enc_upg_option, 'N') = 'O')
194057 ) AND
194058 (l_bflow_method_code = 'PRIOR_ENTRY')
194059 )
194060 THEN
194061 IF
194062 --
194063 1 = 2
194064 --
194065 THEN
194066 xla_accounting_err_pkg.build_message
194067 (p_appli_s_name => 'XLA'
194068 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
194069 ,p_token_1 => 'LINE_NUMBER'
194070 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
194071 ,p_token_2 => 'LINE_TYPE_NAME'
194072 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
194073 l_component_type
194074 ,l_component_code
194075 ,l_component_type_code
194076 ,l_component_appl_id
194077 ,l_amb_context_code
194078 ,l_entity_code
194079 ,l_event_class_code
194080 )
194081 ,p_token_3 => 'OWNER'
194082 ,p_value_3 => xla_lookups_pkg.get_meaning(
194083 p_lookup_type => 'XLA_OWNER_TYPE'
194084 ,p_lookup_code => l_component_type_code
194085 )
194086 ,p_token_4 => 'PRODUCT_NAME'
194087 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
194088 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
194089 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
194090 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
194091 ,p_ae_header_id => NULL
194092 );
194093
194094 IF (C_LEVEL_ERROR>= g_log_level) THEN
194095 trace
194096 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
194097 ,p_level => C_LEVEL_ERROR
194098 ,p_module => l_log_module);
194099 END IF;
194100 END IF;
194101 END IF;
194102 --
194103 --
194104 ------------------------------------------------------------------------------------------------
194105 -- 4219869 Business Flow
194106 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
194107 -- Prior Entry. Currently, the following code is always generated.
194108 ------------------------------------------------------------------------------------------------
194109 XLA_AE_LINES_PKG.ValidateCurrentLine;
194110
194111 ------------------------------------------------------------------------------------
194112 -- 4219869 Business Flow
194113 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
194114 ------------------------------------------------------------------------------------
194115 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
194116
194117 ----------------------------------------------------------------------------------
194118 -- 4219869 Business Flow
194119 -- Update journal entry status -- Need to generate this within IF <condition>
194120 ----------------------------------------------------------------------------------
194121 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
194122 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
194123 ,p_balance_type_code => l_balance_type_code
194124 );
194125
194126 -------------------------------------------------------------------------------------------
194127 -- 4262811 - Generate the Accrual Reversal lines
194128 -------------------------------------------------------------------------------------------
194129 BEGIN
194130 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
194131 (g_array_event(p_event_id).array_value_num('header_index'));
194132 IF l_acc_rev_flag IS NULL THEN
194133 l_acc_rev_flag := 'N';
194134 END IF;
194135 EXCEPTION
194136 WHEN OTHERS THEN
194137 l_acc_rev_flag := 'N';
194138 END;
194139 --
194140 IF (l_acc_rev_flag = 'Y') THEN
194141
194142 -- 4645092 ------------------------------------------------------------------------------
194143 -- To allow MPA report to determine if it should generate report process
194144 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
194145 ------------------------------------------------------------------------------------------
194146
194147 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
194148 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
194149 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
194150 -- call ADRs
194151 -- Bug 4922099
194152 --
194153 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
194154 (NVL(l_actual_upg_option, 'N') = 'O') OR
194155 (NVL(l_enc_upg_option, 'N') = 'O')
194156 )
194157 THEN
194158 NULL;
194159 --
194160 --
194161
194162 l_ccid := AcctDerRule_6(
194163 p_application_id => p_application_id
194164 , p_ae_header_id => l_ae_header_id
194165 , p_source_11 => p_source_11
194166 , x_transaction_coa_id => l_adr_transaction_coa_id
194167 , x_accounting_coa_id => l_adr_accounting_coa_id
194168 , x_value_type_code => l_adr_value_type_code
194169 , p_side => 'NA'
194170 );
194171
194172 xla_ae_lines_pkg.set_ccid(
194173 p_code_combination_id => l_ccid
194174 , p_value_type_code => l_adr_value_type_code
194175 , p_transaction_coa_id => l_adr_transaction_coa_id
194176 , p_accounting_coa_id => l_adr_accounting_coa_id
194177 , p_adr_code => 'CST_DEFAULT'
194178 , p_adr_type_code => 'S'
194179 , p_component_type => l_component_type
194180 , p_component_code => l_component_code
194181 , p_component_type_code => l_component_type_code
194182 , p_component_appl_id => l_component_appl_id
194183 , p_amb_context_code => l_amb_context_code
194184 , p_side => 'NA'
194185 );
194186
194187
194188 --
194189 --
194190 END IF;
194191
194192 --
194193 -- Update the line information that should be overwritten
194194 --
194195 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
194196 p_header_num => 1);
194197 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
194198
194199 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
194200
194201 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
194202 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
194203 END IF;
194204
194205 --
194206 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
194207 --
194208 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
194209 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
194210 ELSE
194211 ---------------------------------------------------------------------------------------------------
194212 -- 4262811a Switch Sign
194213 ---------------------------------------------------------------------------------------------------
194214 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
194215 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
194216 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194217 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
194218 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194219 -- 5132302
194220 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
194221 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194222
194223 END IF;
194224
194225 -- 4955764
194226 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
194227 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
194228
194229
194230 XLA_AE_LINES_PKG.ValidateCurrentLine;
194231 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
194232
194233 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
194234 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
194235 ,p_balance_type_code => l_balance_type_code);
194236
194237 END IF;
194238
194239 -----------------------------------------------------------------------------------------
194240 -- 4262811 Multiperiod Accounting
194241 -----------------------------------------------------------------------------------------
194242 -- No MPA option is assigned.
194243
194244
194245 END IF;
194246 END IF;
194247 --
194248
194249 --
194250 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
194251 trace
194252 (p_msg => 'END of AcctLineType_355'
194253 ,p_level => C_LEVEL_PROCEDURE
194254 ,p_module => l_log_module);
194255 END IF;
194256 --
194257 EXCEPTION
194258 WHEN xla_exceptions_pkg.application_exception THEN
194259 RAISE;
194260 WHEN OTHERS THEN
194261 xla_exceptions_pkg.raise_message
194262 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_355');
194263 END AcctLineType_355;
194264 --
194265
194266 ---------------------------------------
194267 --
194268 -- PRIVATE FUNCTION
194269 -- AcctLineType_356
194270 --
194271 ---------------------------------------
194272 PROCEDURE AcctLineType_356 (
194273 p_application_id IN NUMBER
194274 ,p_event_id IN NUMBER
194275 ,p_calculate_acctd_flag IN VARCHAR2
194276 ,p_calculate_g_l_flag IN VARCHAR2
194277 ,p_actual_flag IN OUT VARCHAR2
194278 ,p_balance_type_code OUT VARCHAR2
194279 ,p_gain_or_loss_ref OUT VARCHAR2
194280
194281 --TRANSACTION_ID
194282 , p_source_1 IN NUMBER
194283 --Item Concatenated Segments
194284 , p_source_2 IN VARCHAR2
194285 --Transaction Quantity
194286 , p_source_3 IN NUMBER
194287 --Transaction Unit of Measure Code
194288 , p_source_4 IN VARCHAR2
194289 --Inventory Transaction Type Description
194290 , p_source_5 IN VARCHAR2
194291 --Cost Management Default Account
194292 , p_source_11 IN NUMBER
194293 --Applied to Application ID
194294 , p_source_79 IN NUMBER
194295 --Applied to Distribution Link Type
194296 , p_source_80 IN VARCHAR2
194297 --Applied to Entity Code
194298 , p_source_81 IN VARCHAR2
194299 --Applied To Purchase Document Identifier
194300 , p_source_83 IN NUMBER
194301 --DISTRIBUTION_IDENTIFIER
194302 , p_source_84 IN NUMBER
194303 --Distribution Type
194304 , p_source_85 IN VARCHAR2
194305 , p_source_85_meaning IN VARCHAR2
194306 --PO Budget Account
194307 , p_source_86 IN NUMBER
194308 --Encumbrance Reversal Amount Entered
194309 , p_source_87 IN NUMBER
194310 --Entered Currency Code
194311 , p_source_88 IN VARCHAR2
194312 --Transaction Encumbrance Reversal Amount
194313 , p_source_89 IN NUMBER
194314 --Entered Amount
194315 , p_source_91 IN NUMBER
194316 --Currency Conversion Date
194317 , p_source_92 IN DATE
194318 --Currency Conversion Rate
194319 , p_source_93 IN NUMBER
194320 --Currency Conversion Type
194321 , p_source_94 IN VARCHAR2
194322 --Accounted Amount
194323 , p_source_95 IN NUMBER
194324 --Purchasing Encumbrance Type Identifier
194325 , p_source_96 IN NUMBER
194326 --Accounting Line Type
194327 , p_source_97 IN NUMBER
194328 --Costing Encumbrance Upgrade Option
194329 , p_source_100 IN VARCHAR2
194330 --TXN_PO_DISTRIBUTION_ID
194331 , p_source_101 IN NUMBER
194332 )
194333 IS
194334
194335 l_component_type VARCHAR2(80);
194336 l_component_code VARCHAR2(30);
194337 l_component_type_code VARCHAR2(1);
194338 l_component_appl_id INTEGER;
194339 l_amb_context_code VARCHAR2(30);
194340 l_entity_code VARCHAR2(30);
194341 l_event_class_code VARCHAR2(30);
194342 l_ae_header_id NUMBER;
194343 l_event_type_code VARCHAR2(30);
194344 l_line_definition_code VARCHAR2(30);
194345 l_line_definition_owner_code VARCHAR2(1);
194346 --
194347 -- adr variables
194348 l_segment VARCHAR2(30);
194349 l_ccid NUMBER;
194350 l_adr_transaction_coa_id NUMBER;
194351 l_adr_accounting_coa_id NUMBER;
194352 l_adr_flexfield_segment_code VARCHAR2(30);
194353 l_adr_flex_value_set_id NUMBER;
194354 l_adr_value_type_code VARCHAR2(30);
194355 l_adr_value_combination_id NUMBER;
194356 l_adr_value_segment_code VARCHAR2(30);
194357
194358 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
194359 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
194360 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
194361 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
194362
194363 -- 4262811 Variables ------------------------------------------------------------------------------------------
194364 l_entered_amt_idx NUMBER;
194365 l_accted_amt_idx NUMBER;
194366 l_acc_rev_flag VARCHAR2(1);
194367 l_accrual_line_num NUMBER;
194368 l_tmp_amt NUMBER;
194369 l_acc_rev_natural_side_code VARCHAR2(1);
194370
194371 l_num_entries NUMBER;
194372 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
194373 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
194374 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
194375 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
194376 l_recog_line_1 NUMBER;
194377 l_recog_line_2 NUMBER;
194378
194379 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
194380 l_bflow_applied_to_amt NUMBER; -- 5132302
194381 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
194382
194383 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
194384
194385 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
194386 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
194387
194388 ---------------------------------------------------------------------------------------------------------------
194389
194390
194391 --
194392 -- bulk performance
194393 --
194394 l_balance_type_code VARCHAR2(1);
194395 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
194396 l_log_module VARCHAR2(240);
194397
194398 --
194399 -- Upgrade strategy
194400 --
194401 l_actual_upg_option VARCHAR2(1);
194402 l_enc_upg_option VARCHAR2(1);
194403
194404 --
194405 BEGIN
194406 --
194407 IF g_log_enabled THEN
194408 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_356';
194409 END IF;
194410 --
194411 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
194412
194413 trace
194414 (p_msg => 'BEGIN of AcctLineType_356'
194415 ,p_level => C_LEVEL_PROCEDURE
194416 ,p_module => l_log_module);
194417
194418 END IF;
194419 --
194420 l_component_type := 'AMB_JLT';
194421 l_component_code := 'OFFSET';
194422 l_component_type_code := 'S';
194423 l_component_appl_id := 707;
194424 l_amb_context_code := 'DEFAULT';
194425 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
194426 l_event_class_code := 'PURCHASE_ORDER';
194427 l_event_type_code := 'PO_DEL_ADJ';
194428 l_line_definition_owner_code := 'S';
194429 l_line_definition_code := 'PI_PO_DEL_ADJ';
194430 --
194431 l_balance_type_code := 'A';
194432 l_segment := NULL;
194433 l_ccid := NULL;
194434 l_adr_transaction_coa_id := NULL;
194435 l_adr_accounting_coa_id := NULL;
194436 l_adr_flexfield_segment_code := NULL;
194437 l_adr_flex_value_set_id := NULL;
194438 l_adr_value_type_code := NULL;
194439 l_adr_value_combination_id := NULL;
194440 l_adr_value_segment_code := NULL;
194441
194442 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
194443 l_bflow_class_code := ''; -- 4219869 Business Flow
194444 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
194445 l_budgetary_control_flag := 'N';
194446
194447 l_bflow_applied_to_amt_idx := NULL; -- 5132302
194448 l_bflow_applied_to_amt := NULL; -- 5132302
194449 l_entered_amt_idx := NULL; -- 4262811
194450 l_accted_amt_idx := NULL; -- 4262811
194451 l_acc_rev_flag := NULL; -- 4262811
194452 l_accrual_line_num := NULL; -- 4262811
194453 l_tmp_amt := NULL; -- 4262811
194454 --
194455
194456 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
194457 l_balance_type_code <> 'B' THEN
194458 IF NVL(p_source_97,9E125) = 2
194459 THEN
194460
194461 --
194462 XLA_AE_LINES_PKG.SetNewLine;
194463
194464 p_balance_type_code := l_balance_type_code;
194465 -- set the flag so later we will know whether the gain loss line needs to be created
194466
194467 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
194468 p_actual_flag :='A';
194469 END IF;
194470
194471 --
194472 -- bulk performance
194473 --
194474 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
194475 p_header_num => 0); -- 4262811
194476 --
194477 -- set accounting line options
194478 --
194479 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
194480 p_natural_side_code => 'D'
194481 , p_gain_or_loss_flag => 'N'
194482 , p_gl_transfer_mode_code => 'S'
194483 , p_acct_entry_type_code => 'A'
194484 , p_switch_side_flag => 'Y'
194485 , p_merge_duplicate_code => 'N'
194486 );
194487 --
194488 l_acc_rev_natural_side_code := 'C'; -- 4262811
194489 --
194490 --
194491 -- set accounting line type info
194492 --
194493 xla_ae_lines_pkg.SetAcctLineType
194494 (p_component_type => l_component_type
194495 ,p_event_type_code => l_event_type_code
194496 ,p_line_definition_owner_code => l_line_definition_owner_code
194497 ,p_line_definition_code => l_line_definition_code
194498 ,p_accounting_line_code => l_component_code
194499 ,p_accounting_line_type_code => l_component_type_code
194500 ,p_accounting_line_appl_id => l_component_appl_id
194501 ,p_amb_context_code => l_amb_context_code
194502 ,p_entity_code => l_entity_code
194503 ,p_event_class_code => l_event_class_code);
194504 --
194505 -- set accounting class
194506 --
194507 xla_ae_lines_pkg.SetAcctClass(
194508 p_accounting_class_code => 'OFFSET'
194509 , p_ae_header_id => l_ae_header_id
194510 );
194511
194512 --
194513 -- set rounding class
194514 --
194515 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
194516 'OFFSET';
194517
194518 --
194519 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
194520 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
194521 --
194522 -- bulk performance
194523 --
194524 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
194525
194526 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
194527 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
194528
194529 -- 4955764
194530 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
194531 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
194532
194533 -- 4458381 Public Sector Enh
194534
194535 --
194536 -- set accounting attributes for the line type
194537 --
194538 l_entered_amt_idx := 17;
194539 l_accted_amt_idx := 22;
194540 l_bflow_applied_to_amt_idx := NULL; -- 5132302
194541 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
194542 l_rec_acct_attrs.array_num_value(1) := p_source_79;
194543 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
194544 l_rec_acct_attrs.array_char_value(2) := p_source_80;
194545 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
194546 l_rec_acct_attrs.array_char_value(3) := p_source_81;
194547 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
194548 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
194549 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
194550 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
194551 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
194552 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
194553 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
194554 l_rec_acct_attrs.array_char_value(7) := p_source_85;
194555 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
194556 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
194557 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
194558 l_rec_acct_attrs.array_num_value(9) := p_source_87;
194559 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
194560 l_rec_acct_attrs.array_char_value(10) := p_source_88;
194561 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
194562 l_rec_acct_attrs.array_num_value(11) := p_source_89;
194563 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
194564 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
194565 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
194566 l_rec_acct_attrs.array_num_value(13) := p_source_87;
194567 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
194568 l_rec_acct_attrs.array_char_value(14) := p_source_88;
194569 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
194570 l_rec_acct_attrs.array_num_value(15) := p_source_89;
194571 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
194572 l_rec_acct_attrs.array_char_value(16) := p_source_100;
194573 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
194574 l_rec_acct_attrs.array_num_value(17) := p_source_91;
194575 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
194576 l_rec_acct_attrs.array_char_value(18) := p_source_88;
194577 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
194578 l_rec_acct_attrs.array_date_value(19) := p_source_92;
194579 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
194580 l_rec_acct_attrs.array_num_value(20) := p_source_93;
194581 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
194582 l_rec_acct_attrs.array_char_value(21) := p_source_94;
194583 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
194584 l_rec_acct_attrs.array_num_value(22) := p_source_95;
194585 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
194586 l_rec_acct_attrs.array_num_value(23) := p_source_96;
194587 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
194588 l_rec_acct_attrs.array_num_value(24) := p_source_96;
194589
194590 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
194591 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
194592
194593 ---------------------------------------------------------------------------------------------------------------
194594 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
194595 ---------------------------------------------------------------------------------------------------------------
194596 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
194597
194598 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
194599 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
194600
194601 IF xla_accounting_cache_pkg.GetValueChar
194602 (p_source_code => 'LEDGER_CATEGORY_CODE'
194603 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
194604 AND l_bflow_method_code = 'PRIOR_ENTRY'
194605 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
194606 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
194607 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
194608 )
194609 THEN
194610 xla_ae_lines_pkg.BflowUpgEntry
194611 (p_business_method_code => l_bflow_method_code
194612 ,p_business_class_code => l_bflow_class_code
194613 ,p_balance_type => l_balance_type_code);
194614 ELSE
194615 NULL;
194616 -- No business flow processing for business flow method of NONE.
194617 END IF;
194618
194619 --
194620 -- call analytical criteria
194621 --
194622
194623 --
194624 -- call description
194625 --
194626
194627 xla_ae_lines_pkg.SetLineDescription(
194628 p_ae_header_id => l_ae_header_id
194629 ,p_description => Description_1 (
194630 p_application_id => p_application_id
194631 , p_ae_header_id => l_ae_header_id
194632 , p_source_1 => p_source_1
194633 , p_source_2 => p_source_2
194634 , p_source_3 => p_source_3
194635 , p_source_4 => p_source_4
194636 , p_source_5 => p_source_5
194637 )
194638 );
194639
194640
194641 --
194642 -- call ADRs
194643 -- Bug 4922099
194644 --
194645 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
194646 (NVL(l_actual_upg_option, 'N') = 'O') OR
194647 (NVL(l_enc_upg_option, 'N') = 'O')
194648 )
194649 THEN
194650 NULL;
194651 --
194652 --
194653
194654 l_ccid := AcctDerRule_6(
194655 p_application_id => p_application_id
194656 , p_ae_header_id => l_ae_header_id
194657 , p_source_11 => p_source_11
194658 , x_transaction_coa_id => l_adr_transaction_coa_id
194659 , x_accounting_coa_id => l_adr_accounting_coa_id
194660 , x_value_type_code => l_adr_value_type_code
194661 , p_side => 'NA'
194662 );
194663
194664 xla_ae_lines_pkg.set_ccid(
194665 p_code_combination_id => l_ccid
194666 , p_value_type_code => l_adr_value_type_code
194667 , p_transaction_coa_id => l_adr_transaction_coa_id
194668 , p_accounting_coa_id => l_adr_accounting_coa_id
194669 , p_adr_code => 'CST_DEFAULT'
194670 , p_adr_type_code => 'S'
194671 , p_component_type => l_component_type
194672 , p_component_code => l_component_code
194673 , p_component_type_code => l_component_type_code
194674 , p_component_appl_id => l_component_appl_id
194675 , p_amb_context_code => l_amb_context_code
194676 , p_side => 'NA'
194677 );
194678
194679
194680 --
194681 --
194682 END IF;
194683 --
194684 -- Bug 4922099
194685 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
194686 (NVL(l_enc_upg_option, 'N') = 'O')
194687 ) AND
194688 (l_bflow_method_code = 'PRIOR_ENTRY')
194689 )
194690 THEN
194691 IF
194692 --
194693 1 = 2
194694 --
194695 THEN
194696 xla_accounting_err_pkg.build_message
194697 (p_appli_s_name => 'XLA'
194698 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
194699 ,p_token_1 => 'LINE_NUMBER'
194700 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
194701 ,p_token_2 => 'LINE_TYPE_NAME'
194702 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
194703 l_component_type
194704 ,l_component_code
194705 ,l_component_type_code
194706 ,l_component_appl_id
194707 ,l_amb_context_code
194708 ,l_entity_code
194709 ,l_event_class_code
194710 )
194711 ,p_token_3 => 'OWNER'
194712 ,p_value_3 => xla_lookups_pkg.get_meaning(
194713 p_lookup_type => 'XLA_OWNER_TYPE'
194714 ,p_lookup_code => l_component_type_code
194715 )
194716 ,p_token_4 => 'PRODUCT_NAME'
194717 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
194718 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
194719 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
194720 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
194721 ,p_ae_header_id => NULL
194722 );
194723
194724 IF (C_LEVEL_ERROR>= g_log_level) THEN
194725 trace
194726 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
194727 ,p_level => C_LEVEL_ERROR
194728 ,p_module => l_log_module);
194729 END IF;
194730 END IF;
194731 END IF;
194732 --
194733 --
194734 ------------------------------------------------------------------------------------------------
194735 -- 4219869 Business Flow
194736 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
194737 -- Prior Entry. Currently, the following code is always generated.
194738 ------------------------------------------------------------------------------------------------
194739 XLA_AE_LINES_PKG.ValidateCurrentLine;
194740
194741 ------------------------------------------------------------------------------------
194742 -- 4219869 Business Flow
194743 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
194744 ------------------------------------------------------------------------------------
194745 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
194746
194747 ----------------------------------------------------------------------------------
194748 -- 4219869 Business Flow
194749 -- Update journal entry status -- Need to generate this within IF <condition>
194750 ----------------------------------------------------------------------------------
194751 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
194752 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
194753 ,p_balance_type_code => l_balance_type_code
194754 );
194755
194756 -------------------------------------------------------------------------------------------
194757 -- 4262811 - Generate the Accrual Reversal lines
194758 -------------------------------------------------------------------------------------------
194759 BEGIN
194760 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
194761 (g_array_event(p_event_id).array_value_num('header_index'));
194762 IF l_acc_rev_flag IS NULL THEN
194763 l_acc_rev_flag := 'N';
194764 END IF;
194765 EXCEPTION
194766 WHEN OTHERS THEN
194767 l_acc_rev_flag := 'N';
194768 END;
194769 --
194770 IF (l_acc_rev_flag = 'Y') THEN
194771
194772 -- 4645092 ------------------------------------------------------------------------------
194773 -- To allow MPA report to determine if it should generate report process
194774 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
194775 ------------------------------------------------------------------------------------------
194776
194777 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
194778 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
194779 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
194780 -- call ADRs
194781 -- Bug 4922099
194782 --
194783 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
194784 (NVL(l_actual_upg_option, 'N') = 'O') OR
194785 (NVL(l_enc_upg_option, 'N') = 'O')
194786 )
194787 THEN
194788 NULL;
194789 --
194790 --
194791
194792 l_ccid := AcctDerRule_6(
194793 p_application_id => p_application_id
194794 , p_ae_header_id => l_ae_header_id
194795 , p_source_11 => p_source_11
194796 , x_transaction_coa_id => l_adr_transaction_coa_id
194797 , x_accounting_coa_id => l_adr_accounting_coa_id
194798 , x_value_type_code => l_adr_value_type_code
194799 , p_side => 'NA'
194800 );
194801
194802 xla_ae_lines_pkg.set_ccid(
194803 p_code_combination_id => l_ccid
194804 , p_value_type_code => l_adr_value_type_code
194805 , p_transaction_coa_id => l_adr_transaction_coa_id
194806 , p_accounting_coa_id => l_adr_accounting_coa_id
194807 , p_adr_code => 'CST_DEFAULT'
194808 , p_adr_type_code => 'S'
194809 , p_component_type => l_component_type
194810 , p_component_code => l_component_code
194811 , p_component_type_code => l_component_type_code
194812 , p_component_appl_id => l_component_appl_id
194813 , p_amb_context_code => l_amb_context_code
194814 , p_side => 'NA'
194815 );
194816
194817
194818 --
194819 --
194820 END IF;
194821
194822 --
194823 -- Update the line information that should be overwritten
194824 --
194825 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
194826 p_header_num => 1);
194827 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
194828
194829 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
194830
194831 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
194832 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
194833 END IF;
194834
194835 --
194836 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
194837 --
194838 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
194839 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
194840 ELSE
194841 ---------------------------------------------------------------------------------------------------
194842 -- 4262811a Switch Sign
194843 ---------------------------------------------------------------------------------------------------
194844 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
194845 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
194846 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194847 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
194848 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194849 -- 5132302
194850 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
194851 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
194852
194853 END IF;
194854
194855 -- 4955764
194856 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
194857 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
194858
194859
194860 XLA_AE_LINES_PKG.ValidateCurrentLine;
194861 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
194862
194863 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
194864 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
194865 ,p_balance_type_code => l_balance_type_code);
194866
194867 END IF;
194868
194869 -----------------------------------------------------------------------------------------
194870 -- 4262811 Multiperiod Accounting
194871 -----------------------------------------------------------------------------------------
194872 -- No MPA option is assigned.
194873
194874
194875 END IF;
194876 END IF;
194877 --
194878
194879 --
194880 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
194881 trace
194882 (p_msg => 'END of AcctLineType_356'
194883 ,p_level => C_LEVEL_PROCEDURE
194884 ,p_module => l_log_module);
194885 END IF;
194886 --
194887 EXCEPTION
194888 WHEN xla_exceptions_pkg.application_exception THEN
194889 RAISE;
194890 WHEN OTHERS THEN
194891 xla_exceptions_pkg.raise_message
194892 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_356');
194893 END AcctLineType_356;
194894 --
194895
194896 ---------------------------------------
194897 --
194898 -- PRIVATE FUNCTION
194899 -- AcctLineType_357
194900 --
194901 ---------------------------------------
194902 PROCEDURE AcctLineType_357 (
194903 p_application_id IN NUMBER
194904 ,p_event_id IN NUMBER
194905 ,p_calculate_acctd_flag IN VARCHAR2
194906 ,p_calculate_g_l_flag IN VARCHAR2
194907 ,p_actual_flag IN OUT VARCHAR2
194908 ,p_balance_type_code OUT VARCHAR2
194909 ,p_gain_or_loss_ref OUT VARCHAR2
194910
194911 --TRANSACTION_ID
194912 , p_source_1 IN NUMBER
194913 --Item Concatenated Segments
194914 , p_source_2 IN VARCHAR2
194915 --Transaction Quantity
194916 , p_source_3 IN NUMBER
194917 --Transaction Unit of Measure Code
194918 , p_source_4 IN VARCHAR2
194919 --Inventory Transaction Type Description
194920 , p_source_5 IN VARCHAR2
194921 --Product Line Accounting Category Expense Account
194922 , p_source_24 IN NUMBER
194923 --Transfer to Subinventory or Cost Group category expense account
194924 , p_source_25 IN NUMBER
194925 --Cost Group Identifier
194926 , p_source_26 IN NUMBER
194927 --INV Header Transfer Cost Group ID
194928 , p_source_27 IN NUMBER
194929 --INV Header Cost Group ID
194930 , p_source_28 IN NUMBER
194931 --Subinventory Name
194932 , p_source_29 IN VARCHAR2
194933 --INV Header Transfer Subinventory
194934 , p_source_31 IN VARCHAR2
194935 --DISTRIBUTION_IDENTIFIER
194936 , p_source_84 IN NUMBER
194937 --Distribution Type
194938 , p_source_85 IN VARCHAR2
194939 , p_source_85_meaning IN VARCHAR2
194940 --Entered Currency Code
194941 , p_source_88 IN VARCHAR2
194942 --Entered Amount
194943 , p_source_91 IN NUMBER
194944 --Currency Conversion Date
194945 , p_source_92 IN DATE
194946 --Currency Conversion Rate
194947 , p_source_93 IN NUMBER
194948 --Currency Conversion Type
194949 , p_source_94 IN VARCHAR2
194950 --Accounted Amount
194951 , p_source_95 IN NUMBER
194952 --Accounting Line Type
194953 , p_source_97 IN NUMBER
194954 )
194955 IS
194956
194957 l_component_type VARCHAR2(80);
194958 l_component_code VARCHAR2(30);
194959 l_component_type_code VARCHAR2(1);
194960 l_component_appl_id INTEGER;
194961 l_amb_context_code VARCHAR2(30);
194962 l_entity_code VARCHAR2(30);
194963 l_event_class_code VARCHAR2(30);
194964 l_ae_header_id NUMBER;
194965 l_event_type_code VARCHAR2(30);
194966 l_line_definition_code VARCHAR2(30);
194967 l_line_definition_owner_code VARCHAR2(1);
194968 --
194969 -- adr variables
194970 l_segment VARCHAR2(30);
194971 l_ccid NUMBER;
194972 l_adr_transaction_coa_id NUMBER;
194973 l_adr_accounting_coa_id NUMBER;
194974 l_adr_flexfield_segment_code VARCHAR2(30);
194975 l_adr_flex_value_set_id NUMBER;
194976 l_adr_value_type_code VARCHAR2(30);
194977 l_adr_value_combination_id NUMBER;
194978 l_adr_value_segment_code VARCHAR2(30);
194979
194980 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
194981 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
194982 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
194983 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
194984
194985 -- 4262811 Variables ------------------------------------------------------------------------------------------
194986 l_entered_amt_idx NUMBER;
194987 l_accted_amt_idx NUMBER;
194988 l_acc_rev_flag VARCHAR2(1);
194989 l_accrual_line_num NUMBER;
194990 l_tmp_amt NUMBER;
194991 l_acc_rev_natural_side_code VARCHAR2(1);
194992
194993 l_num_entries NUMBER;
194994 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
194995 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
194996 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
194997 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
194998 l_recog_line_1 NUMBER;
194999 l_recog_line_2 NUMBER;
195000
195001 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
195002 l_bflow_applied_to_amt NUMBER; -- 5132302
195003 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
195004
195005 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
195006
195007 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
195008 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
195009
195010 ---------------------------------------------------------------------------------------------------------------
195011
195012
195013 --
195014 -- bulk performance
195015 --
195016 l_balance_type_code VARCHAR2(1);
195017 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
195018 l_log_module VARCHAR2(240);
195019
195020 --
195021 -- Upgrade strategy
195022 --
195023 l_actual_upg_option VARCHAR2(1);
195024 l_enc_upg_option VARCHAR2(1);
195025
195026 --
195027 BEGIN
195028 --
195029 IF g_log_enabled THEN
195030 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_357';
195031 END IF;
195032 --
195033 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
195034
195035 trace
195036 (p_msg => 'BEGIN of AcctLineType_357'
195037 ,p_level => C_LEVEL_PROCEDURE
195038 ,p_module => l_log_module);
195039
195040 END IF;
195041 --
195042 l_component_type := 'AMB_JLT';
195043 l_component_code := 'OFFSET';
195044 l_component_type_code := 'S';
195045 l_component_appl_id := 707;
195046 l_amb_context_code := 'DEFAULT';
195047 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
195048 l_event_class_code := 'USER_DEFINE';
195049 l_event_type_code := 'USUB_TXFR';
195050 l_line_definition_owner_code := 'S';
195051 l_line_definition_code := 'PI_INTRAORG_TXFR';
195052 --
195053 l_balance_type_code := 'A';
195054 l_segment := NULL;
195055 l_ccid := NULL;
195056 l_adr_transaction_coa_id := NULL;
195057 l_adr_accounting_coa_id := NULL;
195058 l_adr_flexfield_segment_code := NULL;
195059 l_adr_flex_value_set_id := NULL;
195060 l_adr_value_type_code := NULL;
195061 l_adr_value_combination_id := NULL;
195062 l_adr_value_segment_code := NULL;
195063
195064 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
195065 l_bflow_class_code := ''; -- 4219869 Business Flow
195066 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
195067 l_budgetary_control_flag := 'N';
195068
195069 l_bflow_applied_to_amt_idx := NULL; -- 5132302
195070 l_bflow_applied_to_amt := NULL; -- 5132302
195071 l_entered_amt_idx := NULL; -- 4262811
195072 l_accted_amt_idx := NULL; -- 4262811
195073 l_acc_rev_flag := NULL; -- 4262811
195074 l_accrual_line_num := NULL; -- 4262811
195075 l_tmp_amt := NULL; -- 4262811
195076 --
195077
195078 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
195079 l_balance_type_code <> 'B' THEN
195080 IF NVL(p_source_97,9E125) = 2
195081 THEN
195082
195083 --
195084 XLA_AE_LINES_PKG.SetNewLine;
195085
195086 p_balance_type_code := l_balance_type_code;
195087 -- set the flag so later we will know whether the gain loss line needs to be created
195088
195089 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
195090 p_actual_flag :='A';
195091 END IF;
195092
195093 --
195094 -- bulk performance
195095 --
195096 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
195097 p_header_num => 0); -- 4262811
195098 --
195099 -- set accounting line options
195100 --
195101 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
195102 p_natural_side_code => 'D'
195103 , p_gain_or_loss_flag => 'N'
195104 , p_gl_transfer_mode_code => 'S'
195105 , p_acct_entry_type_code => 'A'
195106 , p_switch_side_flag => 'Y'
195107 , p_merge_duplicate_code => 'N'
195108 );
195109 --
195110 l_acc_rev_natural_side_code := 'C'; -- 4262811
195111 --
195112 --
195113 -- set accounting line type info
195114 --
195115 xla_ae_lines_pkg.SetAcctLineType
195116 (p_component_type => l_component_type
195117 ,p_event_type_code => l_event_type_code
195118 ,p_line_definition_owner_code => l_line_definition_owner_code
195119 ,p_line_definition_code => l_line_definition_code
195120 ,p_accounting_line_code => l_component_code
195121 ,p_accounting_line_type_code => l_component_type_code
195122 ,p_accounting_line_appl_id => l_component_appl_id
195123 ,p_amb_context_code => l_amb_context_code
195124 ,p_entity_code => l_entity_code
195125 ,p_event_class_code => l_event_class_code);
195126 --
195127 -- set accounting class
195128 --
195129 xla_ae_lines_pkg.SetAcctClass(
195130 p_accounting_class_code => 'OFFSET'
195131 , p_ae_header_id => l_ae_header_id
195132 );
195133
195134 --
195135 -- set rounding class
195136 --
195137 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
195138 'OFFSET';
195139
195140 --
195141 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
195142 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
195143 --
195144 -- bulk performance
195145 --
195146 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
195147
195148 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
195149 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
195150
195151 -- 4955764
195152 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
195153 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
195154
195155 -- 4458381 Public Sector Enh
195156
195157 --
195158 -- set accounting attributes for the line type
195159 --
195160 l_entered_amt_idx := 3;
195161 l_accted_amt_idx := 8;
195162 l_bflow_applied_to_amt_idx := NULL; -- 5132302
195163 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
195164 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
195165 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
195166 l_rec_acct_attrs.array_char_value(2) := p_source_85;
195167 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
195168 l_rec_acct_attrs.array_num_value(3) := p_source_91;
195169 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
195170 l_rec_acct_attrs.array_char_value(4) := p_source_88;
195171 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
195172 l_rec_acct_attrs.array_date_value(5) := p_source_92;
195173 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
195174 l_rec_acct_attrs.array_num_value(6) := p_source_93;
195175 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
195176 l_rec_acct_attrs.array_char_value(7) := p_source_94;
195177 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
195178 l_rec_acct_attrs.array_num_value(8) := p_source_95;
195179
195180 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
195181 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
195182
195183 ---------------------------------------------------------------------------------------------------------------
195184 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
195185 ---------------------------------------------------------------------------------------------------------------
195186 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
195187
195188 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
195189 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
195190
195191 IF xla_accounting_cache_pkg.GetValueChar
195192 (p_source_code => 'LEDGER_CATEGORY_CODE'
195193 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
195194 AND l_bflow_method_code = 'PRIOR_ENTRY'
195195 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
195196 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
195197 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
195198 )
195199 THEN
195200 xla_ae_lines_pkg.BflowUpgEntry
195201 (p_business_method_code => l_bflow_method_code
195202 ,p_business_class_code => l_bflow_class_code
195203 ,p_balance_type => l_balance_type_code);
195204 ELSE
195205 NULL;
195206 -- No business flow processing for business flow method of NONE.
195207 END IF;
195208
195209 --
195210 -- call analytical criteria
195211 --
195212
195213 --
195214 -- call description
195215 --
195216
195217 xla_ae_lines_pkg.SetLineDescription(
195218 p_ae_header_id => l_ae_header_id
195219 ,p_description => Description_1 (
195220 p_application_id => p_application_id
195221 , p_ae_header_id => l_ae_header_id
195222 , p_source_1 => p_source_1
195223 , p_source_2 => p_source_2
195224 , p_source_3 => p_source_3
195225 , p_source_4 => p_source_4
195226 , p_source_5 => p_source_5
195227 )
195228 );
195229
195230
195231 --
195232 -- call ADRs
195233 -- Bug 4922099
195234 --
195235 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
195236 (NVL(l_actual_upg_option, 'N') = 'O') OR
195237 (NVL(l_enc_upg_option, 'N') = 'O')
195238 )
195239 THEN
195240 NULL;
195241 --
195242 --
195243
195244 l_ccid := AcctDerRule_15(
195245 p_application_id => p_application_id
195246 , p_ae_header_id => l_ae_header_id
195247 , p_source_24 => p_source_24
195248 , p_source_25 => p_source_25
195249 , p_source_26 => p_source_26
195250 , p_source_27 => p_source_27
195251 , p_source_28 => p_source_28
195252 , p_source_29 => p_source_29
195253 , p_source_31 => p_source_31
195254 , x_transaction_coa_id => l_adr_transaction_coa_id
195255 , x_accounting_coa_id => l_adr_accounting_coa_id
195256 , x_value_type_code => l_adr_value_type_code
195257 , p_side => 'NA'
195258 );
195259
195260 xla_ae_lines_pkg.set_ccid(
195261 p_code_combination_id => l_ccid
195262 , p_value_type_code => l_adr_value_type_code
195263 , p_transaction_coa_id => l_adr_transaction_coa_id
195264 , p_accounting_coa_id => l_adr_accounting_coa_id
195265 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
195266 , p_adr_type_code => 'S'
195267 , p_component_type => l_component_type
195268 , p_component_code => l_component_code
195269 , p_component_type_code => l_component_type_code
195270 , p_component_appl_id => l_component_appl_id
195271 , p_amb_context_code => l_amb_context_code
195272 , p_side => 'NA'
195273 );
195274
195275
195276 --
195277 --
195278 END IF;
195279 --
195280 -- Bug 4922099
195281 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
195282 (NVL(l_enc_upg_option, 'N') = 'O')
195283 ) AND
195284 (l_bflow_method_code = 'PRIOR_ENTRY')
195285 )
195286 THEN
195287 IF
195288 --
195289 1 = 2
195290 --
195291 THEN
195292 xla_accounting_err_pkg.build_message
195293 (p_appli_s_name => 'XLA'
195294 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
195295 ,p_token_1 => 'LINE_NUMBER'
195296 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
195297 ,p_token_2 => 'LINE_TYPE_NAME'
195298 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
195299 l_component_type
195300 ,l_component_code
195301 ,l_component_type_code
195302 ,l_component_appl_id
195303 ,l_amb_context_code
195304 ,l_entity_code
195305 ,l_event_class_code
195306 )
195307 ,p_token_3 => 'OWNER'
195308 ,p_value_3 => xla_lookups_pkg.get_meaning(
195309 p_lookup_type => 'XLA_OWNER_TYPE'
195310 ,p_lookup_code => l_component_type_code
195311 )
195312 ,p_token_4 => 'PRODUCT_NAME'
195313 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
195314 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
195315 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
195316 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
195317 ,p_ae_header_id => NULL
195318 );
195319
195320 IF (C_LEVEL_ERROR>= g_log_level) THEN
195321 trace
195322 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
195323 ,p_level => C_LEVEL_ERROR
195324 ,p_module => l_log_module);
195325 END IF;
195326 END IF;
195327 END IF;
195328 --
195329 --
195330 ------------------------------------------------------------------------------------------------
195331 -- 4219869 Business Flow
195332 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
195333 -- Prior Entry. Currently, the following code is always generated.
195334 ------------------------------------------------------------------------------------------------
195335 XLA_AE_LINES_PKG.ValidateCurrentLine;
195336
195337 ------------------------------------------------------------------------------------
195338 -- 4219869 Business Flow
195339 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
195340 ------------------------------------------------------------------------------------
195341 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
195342
195343 ----------------------------------------------------------------------------------
195344 -- 4219869 Business Flow
195345 -- Update journal entry status -- Need to generate this within IF <condition>
195346 ----------------------------------------------------------------------------------
195347 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
195348 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
195349 ,p_balance_type_code => l_balance_type_code
195350 );
195351
195352 -------------------------------------------------------------------------------------------
195353 -- 4262811 - Generate the Accrual Reversal lines
195354 -------------------------------------------------------------------------------------------
195355 BEGIN
195356 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
195357 (g_array_event(p_event_id).array_value_num('header_index'));
195358 IF l_acc_rev_flag IS NULL THEN
195359 l_acc_rev_flag := 'N';
195360 END IF;
195361 EXCEPTION
195362 WHEN OTHERS THEN
195363 l_acc_rev_flag := 'N';
195364 END;
195365 --
195366 IF (l_acc_rev_flag = 'Y') THEN
195367
195368 -- 4645092 ------------------------------------------------------------------------------
195369 -- To allow MPA report to determine if it should generate report process
195370 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
195371 ------------------------------------------------------------------------------------------
195372
195373 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
195374 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
195375 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
195376 -- call ADRs
195377 -- Bug 4922099
195378 --
195379 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
195380 (NVL(l_actual_upg_option, 'N') = 'O') OR
195381 (NVL(l_enc_upg_option, 'N') = 'O')
195382 )
195383 THEN
195384 NULL;
195385 --
195386 --
195387
195388 l_ccid := AcctDerRule_15(
195389 p_application_id => p_application_id
195390 , p_ae_header_id => l_ae_header_id
195391 , p_source_24 => p_source_24
195392 , p_source_25 => p_source_25
195393 , p_source_26 => p_source_26
195394 , p_source_27 => p_source_27
195395 , p_source_28 => p_source_28
195396 , p_source_29 => p_source_29
195397 , p_source_31 => p_source_31
195398 , x_transaction_coa_id => l_adr_transaction_coa_id
195399 , x_accounting_coa_id => l_adr_accounting_coa_id
195400 , x_value_type_code => l_adr_value_type_code
195401 , p_side => 'NA'
195402 );
195403
195404 xla_ae_lines_pkg.set_ccid(
195405 p_code_combination_id => l_ccid
195406 , p_value_type_code => l_adr_value_type_code
195407 , p_transaction_coa_id => l_adr_transaction_coa_id
195408 , p_accounting_coa_id => l_adr_accounting_coa_id
195409 , p_adr_code => 'PI_CATEGORY_OFFSET_ADR'
195410 , p_adr_type_code => 'S'
195411 , p_component_type => l_component_type
195412 , p_component_code => l_component_code
195413 , p_component_type_code => l_component_type_code
195414 , p_component_appl_id => l_component_appl_id
195415 , p_amb_context_code => l_amb_context_code
195416 , p_side => 'NA'
195417 );
195418
195419
195420 --
195421 --
195422 END IF;
195423
195424 --
195425 -- Update the line information that should be overwritten
195426 --
195427 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
195428 p_header_num => 1);
195429 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
195430
195431 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
195432
195433 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
195434 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
195435 END IF;
195436
195437 --
195438 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
195439 --
195440 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
195441 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
195442 ELSE
195443 ---------------------------------------------------------------------------------------------------
195444 -- 4262811a Switch Sign
195445 ---------------------------------------------------------------------------------------------------
195446 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
195447 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
195448 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
195449 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
195450 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
195451 -- 5132302
195452 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
195453 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
195454
195455 END IF;
195456
195457 -- 4955764
195458 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
195459 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
195460
195461
195462 XLA_AE_LINES_PKG.ValidateCurrentLine;
195463 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
195464
195465 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
195466 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
195467 ,p_balance_type_code => l_balance_type_code);
195468
195469 END IF;
195470
195471 -----------------------------------------------------------------------------------------
195472 -- 4262811 Multiperiod Accounting
195473 -----------------------------------------------------------------------------------------
195474 -- No MPA option is assigned.
195475
195476
195477 END IF;
195478 END IF;
195479 --
195480
195481 --
195482 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
195483 trace
195484 (p_msg => 'END of AcctLineType_357'
195485 ,p_level => C_LEVEL_PROCEDURE
195486 ,p_module => l_log_module);
195487 END IF;
195488 --
195489 EXCEPTION
195490 WHEN xla_exceptions_pkg.application_exception THEN
195491 RAISE;
195492 WHEN OTHERS THEN
195493 xla_exceptions_pkg.raise_message
195494 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_357');
195495 END AcctLineType_357;
195496 --
195497
195498 ---------------------------------------
195499 --
195500 -- PRIVATE FUNCTION
195501 -- AcctLineType_358
195502 --
195503 ---------------------------------------
195504 PROCEDURE AcctLineType_358 (
195505 p_application_id IN NUMBER
195506 ,p_event_id IN NUMBER
195507 ,p_calculate_acctd_flag IN VARCHAR2
195508 ,p_calculate_g_l_flag IN VARCHAR2
195509 ,p_actual_flag IN OUT VARCHAR2
195510 ,p_balance_type_code OUT VARCHAR2
195511 ,p_gain_or_loss_ref OUT VARCHAR2
195512
195513 --Offset Account for the Write Off
195514 , p_source_10 IN NUMBER
195515 --Distribution Type
195516 , p_source_85 IN VARCHAR2
195517 , p_source_85_meaning IN VARCHAR2
195518 --Entered Currency Code
195519 , p_source_88 IN VARCHAR2
195520 --Entered Amount
195521 , p_source_91 IN NUMBER
195522 --Currency Conversion Date
195523 , p_source_92 IN DATE
195524 --Currency Conversion Rate
195525 , p_source_93 IN NUMBER
195526 --Currency Conversion Type
195527 , p_source_94 IN VARCHAR2
195528 --Accounted Amount
195529 , p_source_95 IN NUMBER
195530 --Line Number
195531 , p_source_98 IN NUMBER
195532 --WRITE_OFF_ID
195533 , p_source_99 IN NUMBER
195534 )
195535 IS
195536
195537 l_component_type VARCHAR2(80);
195538 l_component_code VARCHAR2(30);
195539 l_component_type_code VARCHAR2(1);
195540 l_component_appl_id INTEGER;
195541 l_amb_context_code VARCHAR2(30);
195542 l_entity_code VARCHAR2(30);
195543 l_event_class_code VARCHAR2(30);
195544 l_ae_header_id NUMBER;
195545 l_event_type_code VARCHAR2(30);
195546 l_line_definition_code VARCHAR2(30);
195547 l_line_definition_owner_code VARCHAR2(1);
195548 --
195549 -- adr variables
195550 l_segment VARCHAR2(30);
195551 l_ccid NUMBER;
195552 l_adr_transaction_coa_id NUMBER;
195553 l_adr_accounting_coa_id NUMBER;
195554 l_adr_flexfield_segment_code VARCHAR2(30);
195555 l_adr_flex_value_set_id NUMBER;
195556 l_adr_value_type_code VARCHAR2(30);
195557 l_adr_value_combination_id NUMBER;
195558 l_adr_value_segment_code VARCHAR2(30);
195559
195560 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
195561 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
195562 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
195563 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
195564
195565 -- 4262811 Variables ------------------------------------------------------------------------------------------
195566 l_entered_amt_idx NUMBER;
195567 l_accted_amt_idx NUMBER;
195568 l_acc_rev_flag VARCHAR2(1);
195569 l_accrual_line_num NUMBER;
195570 l_tmp_amt NUMBER;
195571 l_acc_rev_natural_side_code VARCHAR2(1);
195572
195573 l_num_entries NUMBER;
195574 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
195575 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
195576 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
195577 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
195578 l_recog_line_1 NUMBER;
195579 l_recog_line_2 NUMBER;
195580
195581 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
195582 l_bflow_applied_to_amt NUMBER; -- 5132302
195583 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
195584
195585 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
195586
195587 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
195588 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
195589
195590 ---------------------------------------------------------------------------------------------------------------
195591
195592
195593 --
195594 -- bulk performance
195595 --
195596 l_balance_type_code VARCHAR2(1);
195597 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
195598 l_log_module VARCHAR2(240);
195599
195600 --
195601 -- Upgrade strategy
195602 --
195603 l_actual_upg_option VARCHAR2(1);
195604 l_enc_upg_option VARCHAR2(1);
195605
195606 --
195607 BEGIN
195608 --
195609 IF g_log_enabled THEN
195610 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_358';
195611 END IF;
195612 --
195613 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
195614
195615 trace
195616 (p_msg => 'BEGIN of AcctLineType_358'
195617 ,p_level => C_LEVEL_PROCEDURE
195618 ,p_module => l_log_module);
195619
195620 END IF;
195621 --
195622 l_component_type := 'AMB_JLT';
195623 l_component_code := 'OFFSET';
195624 l_component_type_code := 'S';
195625 l_component_appl_id := 707;
195626 l_amb_context_code := 'DEFAULT';
195627 l_entity_code := 'WO_ACCOUNTING_EVENTS';
195628 l_event_class_code := 'ACCRUAL_WRITE_OFF';
195629 l_event_type_code := 'ACCRUAL_WRITE_OFF_ALL';
195630 l_line_definition_owner_code := 'S';
195631 l_line_definition_code := 'ACCRUAL_WRITE_OFF';
195632 --
195633 l_balance_type_code := 'A';
195634 l_segment := NULL;
195635 l_ccid := NULL;
195636 l_adr_transaction_coa_id := NULL;
195637 l_adr_accounting_coa_id := NULL;
195638 l_adr_flexfield_segment_code := NULL;
195639 l_adr_flex_value_set_id := NULL;
195640 l_adr_value_type_code := NULL;
195641 l_adr_value_combination_id := NULL;
195642 l_adr_value_segment_code := NULL;
195643
195644 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
195645 l_bflow_class_code := ''; -- 4219869 Business Flow
195646 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
195647 l_budgetary_control_flag := 'N';
195648
195649 l_bflow_applied_to_amt_idx := NULL; -- 5132302
195650 l_bflow_applied_to_amt := NULL; -- 5132302
195651 l_entered_amt_idx := NULL; -- 4262811
195652 l_accted_amt_idx := NULL; -- 4262811
195653 l_acc_rev_flag := NULL; -- 4262811
195654 l_accrual_line_num := NULL; -- 4262811
195655 l_tmp_amt := NULL; -- 4262811
195656 --
195657
195658 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
195659 l_balance_type_code <> 'B' THEN
195660 IF NVL(p_source_98,9E125) = 1
195661 THEN
195662
195663 --
195664 XLA_AE_LINES_PKG.SetNewLine;
195665
195666 p_balance_type_code := l_balance_type_code;
195667 -- set the flag so later we will know whether the gain loss line needs to be created
195668
195669 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
195670 p_actual_flag :='A';
195671 END IF;
195672
195673 --
195674 -- bulk performance
195675 --
195676 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
195677 p_header_num => 0); -- 4262811
195678 --
195679 -- set accounting line options
195680 --
195681 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
195682 p_natural_side_code => 'C'
195683 , p_gain_or_loss_flag => 'N'
195684 , p_gl_transfer_mode_code => 'S'
195685 , p_acct_entry_type_code => 'A'
195686 , p_switch_side_flag => 'Y'
195687 , p_merge_duplicate_code => 'N'
195688 );
195689 --
195690 l_acc_rev_natural_side_code := 'D'; -- 4262811
195691 --
195692 --
195693 -- set accounting line type info
195694 --
195695 xla_ae_lines_pkg.SetAcctLineType
195696 (p_component_type => l_component_type
195697 ,p_event_type_code => l_event_type_code
195698 ,p_line_definition_owner_code => l_line_definition_owner_code
195699 ,p_line_definition_code => l_line_definition_code
195700 ,p_accounting_line_code => l_component_code
195701 ,p_accounting_line_type_code => l_component_type_code
195702 ,p_accounting_line_appl_id => l_component_appl_id
195703 ,p_amb_context_code => l_amb_context_code
195704 ,p_entity_code => l_entity_code
195705 ,p_event_class_code => l_event_class_code);
195706 --
195707 -- set accounting class
195708 --
195709 xla_ae_lines_pkg.SetAcctClass(
195710 p_accounting_class_code => 'OFFSET'
195711 , p_ae_header_id => l_ae_header_id
195712 );
195713
195714 --
195715 -- set rounding class
195716 --
195717 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
195718 'OFFSET';
195719
195720 --
195721 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
195722 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
195723 --
195724 -- bulk performance
195725 --
195726 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
195727
195728 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
195729 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
195730
195731 -- 4955764
195732 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
195733 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
195734
195735 -- 4458381 Public Sector Enh
195736
195737 --
195738 -- set accounting attributes for the line type
195739 --
195740 l_entered_amt_idx := 3;
195741 l_accted_amt_idx := 8;
195742 l_bflow_applied_to_amt_idx := NULL; -- 5132302
195743 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
195744 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_99);
195745 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
195746 l_rec_acct_attrs.array_char_value(2) := p_source_85;
195747 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
195748 l_rec_acct_attrs.array_num_value(3) := p_source_91;
195749 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
195750 l_rec_acct_attrs.array_char_value(4) := p_source_88;
195751 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
195752 l_rec_acct_attrs.array_date_value(5) := p_source_92;
195753 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
195754 l_rec_acct_attrs.array_num_value(6) := p_source_93;
195755 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
195756 l_rec_acct_attrs.array_char_value(7) := p_source_94;
195757 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
195758 l_rec_acct_attrs.array_num_value(8) := p_source_95;
195759
195760 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
195761 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
195762
195763 ---------------------------------------------------------------------------------------------------------------
195764 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
195765 ---------------------------------------------------------------------------------------------------------------
195766 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
195767
195768 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
195769 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
195770
195771 IF xla_accounting_cache_pkg.GetValueChar
195772 (p_source_code => 'LEDGER_CATEGORY_CODE'
195773 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
195774 AND l_bflow_method_code = 'PRIOR_ENTRY'
195775 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
195776 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
195777 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
195778 )
195779 THEN
195780 xla_ae_lines_pkg.BflowUpgEntry
195781 (p_business_method_code => l_bflow_method_code
195782 ,p_business_class_code => l_bflow_class_code
195783 ,p_balance_type => l_balance_type_code);
195784 ELSE
195785 NULL;
195786 -- No business flow processing for business flow method of NONE.
195787 END IF;
195788
195789 --
195790 -- call analytical criteria
195791 --
195792
195793 --
195794 -- call description
195795 --
195796 -- No description or it is inherited.
195797 --
195798 -- call ADRs
195799 -- Bug 4922099
195800 --
195801 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
195802 (NVL(l_actual_upg_option, 'N') = 'O') OR
195803 (NVL(l_enc_upg_option, 'N') = 'O')
195804 )
195805 THEN
195806 NULL;
195807 --
195808 --
195809
195810 l_ccid := AcctDerRule_5(
195811 p_application_id => p_application_id
195812 , p_ae_header_id => l_ae_header_id
195813 , p_source_10 => p_source_10
195814 , x_transaction_coa_id => l_adr_transaction_coa_id
195815 , x_accounting_coa_id => l_adr_accounting_coa_id
195816 , x_value_type_code => l_adr_value_type_code
195817 , p_side => 'NA'
195818 );
195819
195820 xla_ae_lines_pkg.set_ccid(
195821 p_code_combination_id => l_ccid
195822 , p_value_type_code => l_adr_value_type_code
195823 , p_transaction_coa_id => l_adr_transaction_coa_id
195824 , p_accounting_coa_id => l_adr_accounting_coa_id
195825 , p_adr_code => 'CST_AWO_OFFSET'
195826 , p_adr_type_code => 'S'
195827 , p_component_type => l_component_type
195828 , p_component_code => l_component_code
195829 , p_component_type_code => l_component_type_code
195830 , p_component_appl_id => l_component_appl_id
195831 , p_amb_context_code => l_amb_context_code
195832 , p_side => 'NA'
195833 );
195834
195835
195836 --
195837 --
195838 END IF;
195839 --
195840 -- Bug 4922099
195841 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
195842 (NVL(l_enc_upg_option, 'N') = 'O')
195843 ) AND
195844 (l_bflow_method_code = 'PRIOR_ENTRY')
195845 )
195846 THEN
195847 IF
195848 --
195849 1 = 2
195850 --
195851 THEN
195852 xla_accounting_err_pkg.build_message
195853 (p_appli_s_name => 'XLA'
195854 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
195855 ,p_token_1 => 'LINE_NUMBER'
195856 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
195857 ,p_token_2 => 'LINE_TYPE_NAME'
195858 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
195859 l_component_type
195860 ,l_component_code
195861 ,l_component_type_code
195862 ,l_component_appl_id
195863 ,l_amb_context_code
195864 ,l_entity_code
195865 ,l_event_class_code
195866 )
195867 ,p_token_3 => 'OWNER'
195868 ,p_value_3 => xla_lookups_pkg.get_meaning(
195869 p_lookup_type => 'XLA_OWNER_TYPE'
195870 ,p_lookup_code => l_component_type_code
195871 )
195872 ,p_token_4 => 'PRODUCT_NAME'
195873 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
195874 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
195875 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
195876 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
195877 ,p_ae_header_id => NULL
195878 );
195879
195880 IF (C_LEVEL_ERROR>= g_log_level) THEN
195881 trace
195882 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
195883 ,p_level => C_LEVEL_ERROR
195884 ,p_module => l_log_module);
195885 END IF;
195886 END IF;
195887 END IF;
195888 --
195889 --
195890 ------------------------------------------------------------------------------------------------
195891 -- 4219869 Business Flow
195892 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
195893 -- Prior Entry. Currently, the following code is always generated.
195894 ------------------------------------------------------------------------------------------------
195895 XLA_AE_LINES_PKG.ValidateCurrentLine;
195896
195897 ------------------------------------------------------------------------------------
195898 -- 4219869 Business Flow
195899 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
195900 ------------------------------------------------------------------------------------
195901 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
195902
195903 ----------------------------------------------------------------------------------
195904 -- 4219869 Business Flow
195905 -- Update journal entry status -- Need to generate this within IF <condition>
195906 ----------------------------------------------------------------------------------
195907 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
195908 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
195909 ,p_balance_type_code => l_balance_type_code
195910 );
195911
195912 -------------------------------------------------------------------------------------------
195913 -- 4262811 - Generate the Accrual Reversal lines
195914 -------------------------------------------------------------------------------------------
195915 BEGIN
195916 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
195917 (g_array_event(p_event_id).array_value_num('header_index'));
195918 IF l_acc_rev_flag IS NULL THEN
195919 l_acc_rev_flag := 'N';
195920 END IF;
195921 EXCEPTION
195922 WHEN OTHERS THEN
195923 l_acc_rev_flag := 'N';
195924 END;
195925 --
195926 IF (l_acc_rev_flag = 'Y') THEN
195927
195928 -- 4645092 ------------------------------------------------------------------------------
195929 -- To allow MPA report to determine if it should generate report process
195930 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
195931 ------------------------------------------------------------------------------------------
195932
195933 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
195934 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
195935 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
195936 -- call ADRs
195937 -- Bug 4922099
195938 --
195939 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
195940 (NVL(l_actual_upg_option, 'N') = 'O') OR
195941 (NVL(l_enc_upg_option, 'N') = 'O')
195942 )
195943 THEN
195944 NULL;
195945 --
195946 --
195947
195948 l_ccid := AcctDerRule_5(
195949 p_application_id => p_application_id
195950 , p_ae_header_id => l_ae_header_id
195951 , p_source_10 => p_source_10
195952 , x_transaction_coa_id => l_adr_transaction_coa_id
195953 , x_accounting_coa_id => l_adr_accounting_coa_id
195954 , x_value_type_code => l_adr_value_type_code
195955 , p_side => 'NA'
195956 );
195957
195958 xla_ae_lines_pkg.set_ccid(
195959 p_code_combination_id => l_ccid
195960 , p_value_type_code => l_adr_value_type_code
195961 , p_transaction_coa_id => l_adr_transaction_coa_id
195962 , p_accounting_coa_id => l_adr_accounting_coa_id
195963 , p_adr_code => 'CST_AWO_OFFSET'
195964 , p_adr_type_code => 'S'
195965 , p_component_type => l_component_type
195966 , p_component_code => l_component_code
195967 , p_component_type_code => l_component_type_code
195968 , p_component_appl_id => l_component_appl_id
195969 , p_amb_context_code => l_amb_context_code
195970 , p_side => 'NA'
195971 );
195972
195973
195974 --
195975 --
195976 END IF;
195977
195978 --
195979 -- Update the line information that should be overwritten
195980 --
195981 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
195982 p_header_num => 1);
195983 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
195984
195985 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
195986
195987 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
195988 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
195989 END IF;
195990
195991 --
195992 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
195993 --
195994 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
195995 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
195996 ELSE
195997 ---------------------------------------------------------------------------------------------------
195998 -- 4262811a Switch Sign
195999 ---------------------------------------------------------------------------------------------------
196000 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
196001 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
196002 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196003 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
196004 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196005 -- 5132302
196006 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
196007 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196008
196009 END IF;
196010
196011 -- 4955764
196012 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
196013 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
196014
196015
196016 XLA_AE_LINES_PKG.ValidateCurrentLine;
196017 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
196018
196019 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
196020 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
196021 ,p_balance_type_code => l_balance_type_code);
196022
196023 END IF;
196024
196025 -----------------------------------------------------------------------------------------
196026 -- 4262811 Multiperiod Accounting
196027 -----------------------------------------------------------------------------------------
196028 -- No MPA option is assigned.
196029
196030
196031 END IF;
196032 END IF;
196033 --
196034
196035 --
196036 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
196037 trace
196038 (p_msg => 'END of AcctLineType_358'
196039 ,p_level => C_LEVEL_PROCEDURE
196040 ,p_module => l_log_module);
196041 END IF;
196042 --
196043 EXCEPTION
196044 WHEN xla_exceptions_pkg.application_exception THEN
196045 RAISE;
196046 WHEN OTHERS THEN
196047 xla_exceptions_pkg.raise_message
196048 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_358');
196049 END AcctLineType_358;
196050 --
196051
196052 ---------------------------------------
196053 --
196054 -- PRIVATE FUNCTION
196055 -- AcctLineType_359
196056 --
196057 ---------------------------------------
196058 PROCEDURE AcctLineType_359 (
196059 p_application_id IN NUMBER
196060 ,p_event_id IN NUMBER
196061 ,p_calculate_acctd_flag IN VARCHAR2
196062 ,p_calculate_g_l_flag IN VARCHAR2
196063 ,p_actual_flag IN OUT VARCHAR2
196064 ,p_balance_type_code OUT VARCHAR2
196065 ,p_gain_or_loss_ref OUT VARCHAR2
196066
196067 --TRANSACTION_ID
196068 , p_source_1 IN NUMBER
196069 --Item Concatenated Segments
196070 , p_source_2 IN VARCHAR2
196071 --Transaction Quantity
196072 , p_source_3 IN NUMBER
196073 --Transaction Unit of Measure Code
196074 , p_source_4 IN VARCHAR2
196075 --Inventory Transaction Type Description
196076 , p_source_5 IN VARCHAR2
196077 --Cost Management Default Account
196078 , p_source_11 IN NUMBER
196079 --DISTRIBUTION_IDENTIFIER
196080 , p_source_84 IN NUMBER
196081 --Distribution Type
196082 , p_source_85 IN VARCHAR2
196083 , p_source_85_meaning IN VARCHAR2
196084 --Entered Currency Code
196085 , p_source_88 IN VARCHAR2
196086 --Entered Amount
196087 , p_source_91 IN NUMBER
196088 --Currency Conversion Date
196089 , p_source_92 IN DATE
196090 --Currency Conversion Rate
196091 , p_source_93 IN NUMBER
196092 --Currency Conversion Type
196093 , p_source_94 IN VARCHAR2
196094 --Accounted Amount
196095 , p_source_95 IN NUMBER
196096 --Accounting Line Type
196097 , p_source_97 IN NUMBER
196098 )
196099 IS
196100
196101 l_component_type VARCHAR2(80);
196102 l_component_code VARCHAR2(30);
196103 l_component_type_code VARCHAR2(1);
196104 l_component_appl_id INTEGER;
196105 l_amb_context_code VARCHAR2(30);
196106 l_entity_code VARCHAR2(30);
196107 l_event_class_code VARCHAR2(30);
196108 l_ae_header_id NUMBER;
196109 l_event_type_code VARCHAR2(30);
196110 l_line_definition_code VARCHAR2(30);
196111 l_line_definition_owner_code VARCHAR2(1);
196112 --
196113 -- adr variables
196114 l_segment VARCHAR2(30);
196115 l_ccid NUMBER;
196116 l_adr_transaction_coa_id NUMBER;
196117 l_adr_accounting_coa_id NUMBER;
196118 l_adr_flexfield_segment_code VARCHAR2(30);
196119 l_adr_flex_value_set_id NUMBER;
196120 l_adr_value_type_code VARCHAR2(30);
196121 l_adr_value_combination_id NUMBER;
196122 l_adr_value_segment_code VARCHAR2(30);
196123
196124 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
196125 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
196126 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
196127 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
196128
196129 -- 4262811 Variables ------------------------------------------------------------------------------------------
196130 l_entered_amt_idx NUMBER;
196131 l_accted_amt_idx NUMBER;
196132 l_acc_rev_flag VARCHAR2(1);
196133 l_accrual_line_num NUMBER;
196134 l_tmp_amt NUMBER;
196135 l_acc_rev_natural_side_code VARCHAR2(1);
196136
196137 l_num_entries NUMBER;
196138 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
196139 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
196140 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
196141 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
196142 l_recog_line_1 NUMBER;
196143 l_recog_line_2 NUMBER;
196144
196145 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
196146 l_bflow_applied_to_amt NUMBER; -- 5132302
196147 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
196148
196149 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
196150
196151 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
196152 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
196153
196154 ---------------------------------------------------------------------------------------------------------------
196155
196156
196157 --
196158 -- bulk performance
196159 --
196160 l_balance_type_code VARCHAR2(1);
196161 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
196162 l_log_module VARCHAR2(240);
196163
196164 --
196165 -- Upgrade strategy
196166 --
196167 l_actual_upg_option VARCHAR2(1);
196168 l_enc_upg_option VARCHAR2(1);
196169
196170 --
196171 BEGIN
196172 --
196173 IF g_log_enabled THEN
196174 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_359';
196175 END IF;
196176 --
196177 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
196178
196179 trace
196180 (p_msg => 'BEGIN of AcctLineType_359'
196181 ,p_level => C_LEVEL_PROCEDURE
196182 ,p_module => l_log_module);
196183
196184 END IF;
196185 --
196186 l_component_type := 'AMB_JLT';
196187 l_component_code := 'OFFSET';
196188 l_component_type_code := 'S';
196189 l_component_appl_id := 707;
196190 l_amb_context_code := 'DEFAULT';
196191 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
196192 l_event_class_code := 'DIR_INTERORG_SHIP';
196193 l_event_type_code := 'DIR_INTERORG_SHIP_ALL';
196194 l_line_definition_owner_code := 'S';
196195 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
196196 --
196197 l_balance_type_code := 'A';
196198 l_segment := NULL;
196199 l_ccid := NULL;
196200 l_adr_transaction_coa_id := NULL;
196201 l_adr_accounting_coa_id := NULL;
196202 l_adr_flexfield_segment_code := NULL;
196203 l_adr_flex_value_set_id := NULL;
196204 l_adr_value_type_code := NULL;
196205 l_adr_value_combination_id := NULL;
196206 l_adr_value_segment_code := NULL;
196207
196208 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
196209 l_bflow_class_code := ''; -- 4219869 Business Flow
196210 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
196211 l_budgetary_control_flag := 'N';
196212
196213 l_bflow_applied_to_amt_idx := NULL; -- 5132302
196214 l_bflow_applied_to_amt := NULL; -- 5132302
196215 l_entered_amt_idx := NULL; -- 4262811
196216 l_accted_amt_idx := NULL; -- 4262811
196217 l_acc_rev_flag := NULL; -- 4262811
196218 l_accrual_line_num := NULL; -- 4262811
196219 l_tmp_amt := NULL; -- 4262811
196220 --
196221
196222 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
196223 l_balance_type_code <> 'B' THEN
196224 IF NVL(p_source_97,9E125) = 2
196225 THEN
196226
196227 --
196228 XLA_AE_LINES_PKG.SetNewLine;
196229
196230 p_balance_type_code := l_balance_type_code;
196231 -- set the flag so later we will know whether the gain loss line needs to be created
196232
196233 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
196234 p_actual_flag :='A';
196235 END IF;
196236
196237 --
196238 -- bulk performance
196239 --
196240 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
196241 p_header_num => 0); -- 4262811
196242 --
196243 -- set accounting line options
196244 --
196245 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
196246 p_natural_side_code => 'D'
196247 , p_gain_or_loss_flag => 'N'
196248 , p_gl_transfer_mode_code => 'S'
196249 , p_acct_entry_type_code => 'A'
196250 , p_switch_side_flag => 'Y'
196251 , p_merge_duplicate_code => 'N'
196252 );
196253 --
196254 l_acc_rev_natural_side_code := 'C'; -- 4262811
196255 --
196256 --
196257 -- set accounting line type info
196258 --
196259 xla_ae_lines_pkg.SetAcctLineType
196260 (p_component_type => l_component_type
196261 ,p_event_type_code => l_event_type_code
196262 ,p_line_definition_owner_code => l_line_definition_owner_code
196263 ,p_line_definition_code => l_line_definition_code
196264 ,p_accounting_line_code => l_component_code
196265 ,p_accounting_line_type_code => l_component_type_code
196266 ,p_accounting_line_appl_id => l_component_appl_id
196267 ,p_amb_context_code => l_amb_context_code
196268 ,p_entity_code => l_entity_code
196269 ,p_event_class_code => l_event_class_code);
196270 --
196271 -- set accounting class
196272 --
196273 xla_ae_lines_pkg.SetAcctClass(
196274 p_accounting_class_code => 'OFFSET'
196275 , p_ae_header_id => l_ae_header_id
196276 );
196277
196278 --
196279 -- set rounding class
196280 --
196281 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
196282 'OFFSET';
196283
196284 --
196285 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
196286 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
196287 --
196288 -- bulk performance
196289 --
196290 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
196291
196292 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
196293 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
196294
196295 -- 4955764
196296 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
196297 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
196298
196299 -- 4458381 Public Sector Enh
196300
196301 --
196302 -- set accounting attributes for the line type
196303 --
196304 l_entered_amt_idx := 3;
196305 l_accted_amt_idx := 8;
196306 l_bflow_applied_to_amt_idx := NULL; -- 5132302
196307 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
196308 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
196309 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
196310 l_rec_acct_attrs.array_char_value(2) := p_source_85;
196311 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
196312 l_rec_acct_attrs.array_num_value(3) := p_source_91;
196313 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
196314 l_rec_acct_attrs.array_char_value(4) := p_source_88;
196315 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
196316 l_rec_acct_attrs.array_date_value(5) := p_source_92;
196317 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
196318 l_rec_acct_attrs.array_num_value(6) := p_source_93;
196319 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
196320 l_rec_acct_attrs.array_char_value(7) := p_source_94;
196321 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
196322 l_rec_acct_attrs.array_num_value(8) := p_source_95;
196323
196324 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
196325 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
196326
196327 ---------------------------------------------------------------------------------------------------------------
196328 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
196329 ---------------------------------------------------------------------------------------------------------------
196330 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
196331
196332 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
196333 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
196334
196335 IF xla_accounting_cache_pkg.GetValueChar
196336 (p_source_code => 'LEDGER_CATEGORY_CODE'
196337 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
196338 AND l_bflow_method_code = 'PRIOR_ENTRY'
196339 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
196340 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
196341 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
196342 )
196343 THEN
196344 xla_ae_lines_pkg.BflowUpgEntry
196345 (p_business_method_code => l_bflow_method_code
196346 ,p_business_class_code => l_bflow_class_code
196347 ,p_balance_type => l_balance_type_code);
196348 ELSE
196349 NULL;
196350 -- No business flow processing for business flow method of NONE.
196351 END IF;
196352
196353 --
196354 -- call analytical criteria
196355 --
196356
196357 --
196358 -- call description
196359 --
196360
196361 xla_ae_lines_pkg.SetLineDescription(
196362 p_ae_header_id => l_ae_header_id
196363 ,p_description => Description_1 (
196364 p_application_id => p_application_id
196365 , p_ae_header_id => l_ae_header_id
196366 , p_source_1 => p_source_1
196367 , p_source_2 => p_source_2
196368 , p_source_3 => p_source_3
196369 , p_source_4 => p_source_4
196370 , p_source_5 => p_source_5
196371 )
196372 );
196373
196374
196375 --
196376 -- call ADRs
196377 -- Bug 4922099
196378 --
196379 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
196380 (NVL(l_actual_upg_option, 'N') = 'O') OR
196381 (NVL(l_enc_upg_option, 'N') = 'O')
196382 )
196383 THEN
196384 NULL;
196385 --
196386 --
196387
196388 l_ccid := AcctDerRule_6(
196389 p_application_id => p_application_id
196390 , p_ae_header_id => l_ae_header_id
196391 , p_source_11 => p_source_11
196392 , x_transaction_coa_id => l_adr_transaction_coa_id
196393 , x_accounting_coa_id => l_adr_accounting_coa_id
196394 , x_value_type_code => l_adr_value_type_code
196395 , p_side => 'NA'
196396 );
196397
196398 xla_ae_lines_pkg.set_ccid(
196399 p_code_combination_id => l_ccid
196400 , p_value_type_code => l_adr_value_type_code
196401 , p_transaction_coa_id => l_adr_transaction_coa_id
196402 , p_accounting_coa_id => l_adr_accounting_coa_id
196403 , p_adr_code => 'CST_DEFAULT'
196404 , p_adr_type_code => 'S'
196405 , p_component_type => l_component_type
196406 , p_component_code => l_component_code
196407 , p_component_type_code => l_component_type_code
196408 , p_component_appl_id => l_component_appl_id
196409 , p_amb_context_code => l_amb_context_code
196410 , p_side => 'NA'
196411 );
196412
196413
196414 --
196415 --
196416 END IF;
196417 --
196418 -- Bug 4922099
196419 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
196420 (NVL(l_enc_upg_option, 'N') = 'O')
196421 ) AND
196422 (l_bflow_method_code = 'PRIOR_ENTRY')
196423 )
196424 THEN
196425 IF
196426 --
196427 1 = 2
196428 --
196429 THEN
196430 xla_accounting_err_pkg.build_message
196431 (p_appli_s_name => 'XLA'
196432 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
196433 ,p_token_1 => 'LINE_NUMBER'
196434 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
196435 ,p_token_2 => 'LINE_TYPE_NAME'
196436 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
196437 l_component_type
196438 ,l_component_code
196439 ,l_component_type_code
196440 ,l_component_appl_id
196441 ,l_amb_context_code
196442 ,l_entity_code
196443 ,l_event_class_code
196444 )
196445 ,p_token_3 => 'OWNER'
196446 ,p_value_3 => xla_lookups_pkg.get_meaning(
196447 p_lookup_type => 'XLA_OWNER_TYPE'
196448 ,p_lookup_code => l_component_type_code
196449 )
196450 ,p_token_4 => 'PRODUCT_NAME'
196451 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
196452 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
196453 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
196454 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
196455 ,p_ae_header_id => NULL
196456 );
196457
196458 IF (C_LEVEL_ERROR>= g_log_level) THEN
196459 trace
196460 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
196461 ,p_level => C_LEVEL_ERROR
196462 ,p_module => l_log_module);
196463 END IF;
196464 END IF;
196465 END IF;
196466 --
196467 --
196468 ------------------------------------------------------------------------------------------------
196469 -- 4219869 Business Flow
196470 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
196471 -- Prior Entry. Currently, the following code is always generated.
196472 ------------------------------------------------------------------------------------------------
196473 XLA_AE_LINES_PKG.ValidateCurrentLine;
196474
196475 ------------------------------------------------------------------------------------
196476 -- 4219869 Business Flow
196477 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
196478 ------------------------------------------------------------------------------------
196479 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
196480
196481 ----------------------------------------------------------------------------------
196482 -- 4219869 Business Flow
196483 -- Update journal entry status -- Need to generate this within IF <condition>
196484 ----------------------------------------------------------------------------------
196485 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
196486 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
196487 ,p_balance_type_code => l_balance_type_code
196488 );
196489
196490 -------------------------------------------------------------------------------------------
196491 -- 4262811 - Generate the Accrual Reversal lines
196492 -------------------------------------------------------------------------------------------
196493 BEGIN
196494 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
196495 (g_array_event(p_event_id).array_value_num('header_index'));
196496 IF l_acc_rev_flag IS NULL THEN
196497 l_acc_rev_flag := 'N';
196498 END IF;
196499 EXCEPTION
196500 WHEN OTHERS THEN
196501 l_acc_rev_flag := 'N';
196502 END;
196503 --
196504 IF (l_acc_rev_flag = 'Y') THEN
196505
196506 -- 4645092 ------------------------------------------------------------------------------
196507 -- To allow MPA report to determine if it should generate report process
196508 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
196509 ------------------------------------------------------------------------------------------
196510
196511 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
196512 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
196513 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
196514 -- call ADRs
196515 -- Bug 4922099
196516 --
196517 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
196518 (NVL(l_actual_upg_option, 'N') = 'O') OR
196519 (NVL(l_enc_upg_option, 'N') = 'O')
196520 )
196521 THEN
196522 NULL;
196523 --
196524 --
196525
196526 l_ccid := AcctDerRule_6(
196527 p_application_id => p_application_id
196528 , p_ae_header_id => l_ae_header_id
196529 , p_source_11 => p_source_11
196530 , x_transaction_coa_id => l_adr_transaction_coa_id
196531 , x_accounting_coa_id => l_adr_accounting_coa_id
196532 , x_value_type_code => l_adr_value_type_code
196533 , p_side => 'NA'
196534 );
196535
196536 xla_ae_lines_pkg.set_ccid(
196537 p_code_combination_id => l_ccid
196538 , p_value_type_code => l_adr_value_type_code
196539 , p_transaction_coa_id => l_adr_transaction_coa_id
196540 , p_accounting_coa_id => l_adr_accounting_coa_id
196541 , p_adr_code => 'CST_DEFAULT'
196542 , p_adr_type_code => 'S'
196543 , p_component_type => l_component_type
196544 , p_component_code => l_component_code
196545 , p_component_type_code => l_component_type_code
196546 , p_component_appl_id => l_component_appl_id
196547 , p_amb_context_code => l_amb_context_code
196548 , p_side => 'NA'
196549 );
196550
196551
196552 --
196553 --
196554 END IF;
196555
196556 --
196557 -- Update the line information that should be overwritten
196558 --
196559 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
196560 p_header_num => 1);
196561 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
196562
196563 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
196564
196565 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
196566 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
196567 END IF;
196568
196569 --
196570 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
196571 --
196572 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
196573 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
196574 ELSE
196575 ---------------------------------------------------------------------------------------------------
196576 -- 4262811a Switch Sign
196577 ---------------------------------------------------------------------------------------------------
196578 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
196579 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
196580 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196581 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
196582 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196583 -- 5132302
196584 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
196585 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
196586
196587 END IF;
196588
196589 -- 4955764
196590 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
196591 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
196592
196593
196594 XLA_AE_LINES_PKG.ValidateCurrentLine;
196595 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
196596
196597 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
196598 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
196599 ,p_balance_type_code => l_balance_type_code);
196600
196601 END IF;
196602
196603 -----------------------------------------------------------------------------------------
196604 -- 4262811 Multiperiod Accounting
196605 -----------------------------------------------------------------------------------------
196606 -- No MPA option is assigned.
196607
196608
196609 END IF;
196610 END IF;
196611 --
196612
196613 --
196614 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
196615 trace
196616 (p_msg => 'END of AcctLineType_359'
196617 ,p_level => C_LEVEL_PROCEDURE
196618 ,p_module => l_log_module);
196619 END IF;
196620 --
196621 EXCEPTION
196622 WHEN xla_exceptions_pkg.application_exception THEN
196623 RAISE;
196624 WHEN OTHERS THEN
196625 xla_exceptions_pkg.raise_message
196626 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_359');
196627 END AcctLineType_359;
196628 --
196629
196630 ---------------------------------------
196631 --
196632 -- PRIVATE FUNCTION
196633 -- AcctLineType_360
196634 --
196635 ---------------------------------------
196636 PROCEDURE AcctLineType_360 (
196637 p_application_id IN NUMBER
196638 ,p_event_id IN NUMBER
196639 ,p_calculate_acctd_flag IN VARCHAR2
196640 ,p_calculate_g_l_flag IN VARCHAR2
196641 ,p_actual_flag IN OUT VARCHAR2
196642 ,p_balance_type_code OUT VARCHAR2
196643 ,p_gain_or_loss_ref OUT VARCHAR2
196644
196645 --TRANSACTION_ID
196646 , p_source_1 IN NUMBER
196647 --Item Concatenated Segments
196648 , p_source_2 IN VARCHAR2
196649 --Transaction Quantity
196650 , p_source_3 IN NUMBER
196651 --Transaction Unit of Measure Code
196652 , p_source_4 IN VARCHAR2
196653 --Inventory Transaction Type Description
196654 , p_source_5 IN VARCHAR2
196655 --Cost Management Default Account
196656 , p_source_11 IN NUMBER
196657 --Applied to Application ID
196658 , p_source_79 IN NUMBER
196659 --Applied to Distribution Link Type
196660 , p_source_80 IN VARCHAR2
196661 --Applied to Entity Code
196662 , p_source_81 IN VARCHAR2
196663 --DISTRIBUTION_IDENTIFIER
196664 , p_source_84 IN NUMBER
196665 --Distribution Type
196666 , p_source_85 IN VARCHAR2
196667 , p_source_85_meaning IN VARCHAR2
196668 --Encumbrance Reversal Amount Entered
196669 , p_source_87 IN NUMBER
196670 --Entered Currency Code
196671 , p_source_88 IN VARCHAR2
196672 --Transaction Encumbrance Reversal Amount
196673 , p_source_89 IN NUMBER
196674 --Entered Amount
196675 , p_source_91 IN NUMBER
196676 --Currency Conversion Date
196677 , p_source_92 IN DATE
196678 --Currency Conversion Rate
196679 , p_source_93 IN NUMBER
196680 --Currency Conversion Type
196681 , p_source_94 IN VARCHAR2
196682 --Accounted Amount
196683 , p_source_95 IN NUMBER
196684 --Accounting Line Type
196685 , p_source_97 IN NUMBER
196686 --Costing Encumbrance Upgrade Option
196687 , p_source_100 IN VARCHAR2
196688 --TXN_PO_DISTRIBUTION_ID
196689 , p_source_101 IN NUMBER
196690 --TXN_PO_HEADER_ID
196691 , p_source_102 IN NUMBER
196692 --Requisition Budget Account
196693 , p_source_103 IN NUMBER
196694 --Requisition Encumbrance Type Identifier
196695 , p_source_104 IN NUMBER
196696 )
196697 IS
196698
196699 l_component_type VARCHAR2(80);
196700 l_component_code VARCHAR2(30);
196701 l_component_type_code VARCHAR2(1);
196702 l_component_appl_id INTEGER;
196703 l_amb_context_code VARCHAR2(30);
196704 l_entity_code VARCHAR2(30);
196705 l_event_class_code VARCHAR2(30);
196706 l_ae_header_id NUMBER;
196707 l_event_type_code VARCHAR2(30);
196708 l_line_definition_code VARCHAR2(30);
196709 l_line_definition_owner_code VARCHAR2(1);
196710 --
196711 -- adr variables
196712 l_segment VARCHAR2(30);
196713 l_ccid NUMBER;
196714 l_adr_transaction_coa_id NUMBER;
196715 l_adr_accounting_coa_id NUMBER;
196716 l_adr_flexfield_segment_code VARCHAR2(30);
196717 l_adr_flex_value_set_id NUMBER;
196718 l_adr_value_type_code VARCHAR2(30);
196719 l_adr_value_combination_id NUMBER;
196720 l_adr_value_segment_code VARCHAR2(30);
196721
196722 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
196723 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
196724 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
196725 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
196726
196727 -- 4262811 Variables ------------------------------------------------------------------------------------------
196728 l_entered_amt_idx NUMBER;
196729 l_accted_amt_idx NUMBER;
196730 l_acc_rev_flag VARCHAR2(1);
196731 l_accrual_line_num NUMBER;
196732 l_tmp_amt NUMBER;
196733 l_acc_rev_natural_side_code VARCHAR2(1);
196734
196735 l_num_entries NUMBER;
196736 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
196737 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
196738 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
196739 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
196740 l_recog_line_1 NUMBER;
196741 l_recog_line_2 NUMBER;
196742
196743 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
196744 l_bflow_applied_to_amt NUMBER; -- 5132302
196745 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
196746
196747 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
196748
196749 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
196750 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
196751
196752 ---------------------------------------------------------------------------------------------------------------
196753
196754
196755 --
196756 -- bulk performance
196757 --
196758 l_balance_type_code VARCHAR2(1);
196759 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
196760 l_log_module VARCHAR2(240);
196761
196762 --
196763 -- Upgrade strategy
196764 --
196765 l_actual_upg_option VARCHAR2(1);
196766 l_enc_upg_option VARCHAR2(1);
196767
196768 --
196769 BEGIN
196770 --
196771 IF g_log_enabled THEN
196772 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_360';
196773 END IF;
196774 --
196775 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
196776
196777 trace
196778 (p_msg => 'BEGIN of AcctLineType_360'
196779 ,p_level => C_LEVEL_PROCEDURE
196780 ,p_module => l_log_module);
196781
196782 END IF;
196783 --
196784 l_component_type := 'AMB_JLT';
196785 l_component_code := 'OFFSET';
196786 l_component_type_code := 'S';
196787 l_component_appl_id := 707;
196788 l_amb_context_code := 'DEFAULT';
196789 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
196790 l_event_class_code := 'FOB_RCPT_RECIPIENT_RCPT';
196791 l_event_type_code := 'FOB_RCPT_RECIPIENT_RCPT_TP';
196792 l_line_definition_owner_code := 'S';
196793 l_line_definition_code := 'PI_FOB_RCPT_RECIPIENT_RCPT_TP';
196794 --
196795 l_balance_type_code := 'A';
196796 l_segment := NULL;
196797 l_ccid := NULL;
196798 l_adr_transaction_coa_id := NULL;
196799 l_adr_accounting_coa_id := NULL;
196800 l_adr_flexfield_segment_code := NULL;
196801 l_adr_flex_value_set_id := NULL;
196802 l_adr_value_type_code := NULL;
196803 l_adr_value_combination_id := NULL;
196804 l_adr_value_segment_code := NULL;
196805
196806 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
196807 l_bflow_class_code := ''; -- 4219869 Business Flow
196808 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
196809 l_budgetary_control_flag := 'N';
196810
196811 l_bflow_applied_to_amt_idx := NULL; -- 5132302
196812 l_bflow_applied_to_amt := NULL; -- 5132302
196813 l_entered_amt_idx := NULL; -- 4262811
196814 l_accted_amt_idx := NULL; -- 4262811
196815 l_acc_rev_flag := NULL; -- 4262811
196816 l_accrual_line_num := NULL; -- 4262811
196817 l_tmp_amt := NULL; -- 4262811
196818 --
196819
196820 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
196821 l_balance_type_code <> 'B' THEN
196822 IF NVL(p_source_97,9E125) = 2 AND
196823 p_source_95 >= 0
196824 THEN
196825
196826 --
196827 XLA_AE_LINES_PKG.SetNewLine;
196828
196829 p_balance_type_code := l_balance_type_code;
196830 -- set the flag so later we will know whether the gain loss line needs to be created
196831
196832 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
196833 p_actual_flag :='A';
196834 END IF;
196835
196836 --
196837 -- bulk performance
196838 --
196839 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
196840 p_header_num => 0); -- 4262811
196841 --
196842 -- set accounting line options
196843 --
196844 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
196845 p_natural_side_code => 'D'
196846 , p_gain_or_loss_flag => 'N'
196847 , p_gl_transfer_mode_code => 'S'
196848 , p_acct_entry_type_code => 'A'
196849 , p_switch_side_flag => 'Y'
196850 , p_merge_duplicate_code => 'N'
196851 );
196852 --
196853 l_acc_rev_natural_side_code := 'C'; -- 4262811
196854 --
196855 --
196856 -- set accounting line type info
196857 --
196858 xla_ae_lines_pkg.SetAcctLineType
196859 (p_component_type => l_component_type
196860 ,p_event_type_code => l_event_type_code
196861 ,p_line_definition_owner_code => l_line_definition_owner_code
196862 ,p_line_definition_code => l_line_definition_code
196863 ,p_accounting_line_code => l_component_code
196864 ,p_accounting_line_type_code => l_component_type_code
196865 ,p_accounting_line_appl_id => l_component_appl_id
196866 ,p_amb_context_code => l_amb_context_code
196867 ,p_entity_code => l_entity_code
196868 ,p_event_class_code => l_event_class_code);
196869 --
196870 -- set accounting class
196871 --
196872 xla_ae_lines_pkg.SetAcctClass(
196873 p_accounting_class_code => 'OFFSET'
196874 , p_ae_header_id => l_ae_header_id
196875 );
196876
196877 --
196878 -- set rounding class
196879 --
196880 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
196881 'OFFSET';
196882
196883 --
196884 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
196885 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
196886 --
196887 -- bulk performance
196888 --
196889 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
196890
196891 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
196892 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
196893
196894 -- 4955764
196895 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
196896 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
196897
196898 -- 4458381 Public Sector Enh
196899
196900 --
196901 -- set accounting attributes for the line type
196902 --
196903 l_entered_amt_idx := 17;
196904 l_accted_amt_idx := 22;
196905 l_bflow_applied_to_amt_idx := NULL; -- 5132302
196906 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
196907 l_rec_acct_attrs.array_num_value(1) := p_source_79;
196908 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
196909 l_rec_acct_attrs.array_char_value(2) := p_source_80;
196910 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
196911 l_rec_acct_attrs.array_char_value(3) := p_source_81;
196912 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
196913 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
196914 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
196915 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
196916 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
196917 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
196918 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
196919 l_rec_acct_attrs.array_char_value(7) := p_source_85;
196920 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
196921 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
196922 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
196923 l_rec_acct_attrs.array_num_value(9) := p_source_87;
196924 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
196925 l_rec_acct_attrs.array_char_value(10) := p_source_88;
196926 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
196927 l_rec_acct_attrs.array_num_value(11) := p_source_89;
196928 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
196929 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
196930 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
196931 l_rec_acct_attrs.array_num_value(13) := p_source_87;
196932 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
196933 l_rec_acct_attrs.array_char_value(14) := p_source_88;
196934 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
196935 l_rec_acct_attrs.array_num_value(15) := p_source_89;
196936 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
196937 l_rec_acct_attrs.array_char_value(16) := p_source_100;
196938 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
196939 l_rec_acct_attrs.array_num_value(17) := p_source_91;
196940 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
196941 l_rec_acct_attrs.array_char_value(18) := p_source_88;
196942 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
196943 l_rec_acct_attrs.array_date_value(19) := p_source_92;
196944 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
196945 l_rec_acct_attrs.array_num_value(20) := p_source_93;
196946 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
196947 l_rec_acct_attrs.array_char_value(21) := p_source_94;
196948 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
196949 l_rec_acct_attrs.array_num_value(22) := p_source_95;
196950 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
196951 l_rec_acct_attrs.array_num_value(23) := p_source_104;
196952 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
196953 l_rec_acct_attrs.array_num_value(24) := p_source_104;
196954
196955 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
196956 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
196957
196958 ---------------------------------------------------------------------------------------------------------------
196959 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
196960 ---------------------------------------------------------------------------------------------------------------
196961 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
196962
196963 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
196964 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
196965
196966 IF xla_accounting_cache_pkg.GetValueChar
196967 (p_source_code => 'LEDGER_CATEGORY_CODE'
196968 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
196969 AND l_bflow_method_code = 'PRIOR_ENTRY'
196970 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
196971 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
196972 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
196973 )
196974 THEN
196975 xla_ae_lines_pkg.BflowUpgEntry
196976 (p_business_method_code => l_bflow_method_code
196977 ,p_business_class_code => l_bflow_class_code
196978 ,p_balance_type => l_balance_type_code);
196979 ELSE
196980 NULL;
196981 -- No business flow processing for business flow method of NONE.
196982 END IF;
196983
196984 --
196985 -- call analytical criteria
196986 --
196987
196988 --
196989 -- call description
196990 --
196991
196992 xla_ae_lines_pkg.SetLineDescription(
196993 p_ae_header_id => l_ae_header_id
196994 ,p_description => Description_1 (
196995 p_application_id => p_application_id
196996 , p_ae_header_id => l_ae_header_id
196997 , p_source_1 => p_source_1
196998 , p_source_2 => p_source_2
196999 , p_source_3 => p_source_3
197000 , p_source_4 => p_source_4
197001 , p_source_5 => p_source_5
197002 )
197003 );
197004
197005
197006 --
197007 -- call ADRs
197008 -- Bug 4922099
197009 --
197010 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
197011 (NVL(l_actual_upg_option, 'N') = 'O') OR
197012 (NVL(l_enc_upg_option, 'N') = 'O')
197013 )
197014 THEN
197015 NULL;
197016 --
197017 --
197018
197019 l_ccid := AcctDerRule_6(
197020 p_application_id => p_application_id
197021 , p_ae_header_id => l_ae_header_id
197022 , p_source_11 => p_source_11
197023 , x_transaction_coa_id => l_adr_transaction_coa_id
197024 , x_accounting_coa_id => l_adr_accounting_coa_id
197025 , x_value_type_code => l_adr_value_type_code
197026 , p_side => 'NA'
197027 );
197028
197029 xla_ae_lines_pkg.set_ccid(
197030 p_code_combination_id => l_ccid
197031 , p_value_type_code => l_adr_value_type_code
197032 , p_transaction_coa_id => l_adr_transaction_coa_id
197033 , p_accounting_coa_id => l_adr_accounting_coa_id
197034 , p_adr_code => 'CST_DEFAULT'
197035 , p_adr_type_code => 'S'
197036 , p_component_type => l_component_type
197037 , p_component_code => l_component_code
197038 , p_component_type_code => l_component_type_code
197039 , p_component_appl_id => l_component_appl_id
197040 , p_amb_context_code => l_amb_context_code
197041 , p_side => 'NA'
197042 );
197043
197044
197045 --
197046 --
197047 END IF;
197048 --
197049 -- Bug 4922099
197050 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
197051 (NVL(l_enc_upg_option, 'N') = 'O')
197052 ) AND
197053 (l_bflow_method_code = 'PRIOR_ENTRY')
197054 )
197055 THEN
197056 IF
197057 --
197058 1 = 2
197059 --
197060 THEN
197061 xla_accounting_err_pkg.build_message
197062 (p_appli_s_name => 'XLA'
197063 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
197064 ,p_token_1 => 'LINE_NUMBER'
197065 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
197066 ,p_token_2 => 'LINE_TYPE_NAME'
197067 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
197068 l_component_type
197069 ,l_component_code
197070 ,l_component_type_code
197071 ,l_component_appl_id
197072 ,l_amb_context_code
197073 ,l_entity_code
197074 ,l_event_class_code
197075 )
197076 ,p_token_3 => 'OWNER'
197077 ,p_value_3 => xla_lookups_pkg.get_meaning(
197078 p_lookup_type => 'XLA_OWNER_TYPE'
197079 ,p_lookup_code => l_component_type_code
197080 )
197081 ,p_token_4 => 'PRODUCT_NAME'
197082 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
197083 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
197084 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
197085 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
197086 ,p_ae_header_id => NULL
197087 );
197088
197089 IF (C_LEVEL_ERROR>= g_log_level) THEN
197090 trace
197091 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
197092 ,p_level => C_LEVEL_ERROR
197093 ,p_module => l_log_module);
197094 END IF;
197095 END IF;
197096 END IF;
197097 --
197098 --
197099 ------------------------------------------------------------------------------------------------
197100 -- 4219869 Business Flow
197101 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
197102 -- Prior Entry. Currently, the following code is always generated.
197103 ------------------------------------------------------------------------------------------------
197104 XLA_AE_LINES_PKG.ValidateCurrentLine;
197105
197106 ------------------------------------------------------------------------------------
197107 -- 4219869 Business Flow
197108 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
197109 ------------------------------------------------------------------------------------
197110 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
197111
197112 ----------------------------------------------------------------------------------
197113 -- 4219869 Business Flow
197114 -- Update journal entry status -- Need to generate this within IF <condition>
197115 ----------------------------------------------------------------------------------
197116 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
197117 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
197118 ,p_balance_type_code => l_balance_type_code
197119 );
197120
197121 -------------------------------------------------------------------------------------------
197122 -- 4262811 - Generate the Accrual Reversal lines
197123 -------------------------------------------------------------------------------------------
197124 BEGIN
197125 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
197126 (g_array_event(p_event_id).array_value_num('header_index'));
197127 IF l_acc_rev_flag IS NULL THEN
197128 l_acc_rev_flag := 'N';
197129 END IF;
197130 EXCEPTION
197131 WHEN OTHERS THEN
197132 l_acc_rev_flag := 'N';
197133 END;
197134 --
197135 IF (l_acc_rev_flag = 'Y') THEN
197136
197137 -- 4645092 ------------------------------------------------------------------------------
197138 -- To allow MPA report to determine if it should generate report process
197139 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
197140 ------------------------------------------------------------------------------------------
197141
197142 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
197143 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
197144 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
197145 -- call ADRs
197146 -- Bug 4922099
197147 --
197148 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
197149 (NVL(l_actual_upg_option, 'N') = 'O') OR
197150 (NVL(l_enc_upg_option, 'N') = 'O')
197151 )
197152 THEN
197153 NULL;
197154 --
197155 --
197156
197157 l_ccid := AcctDerRule_6(
197158 p_application_id => p_application_id
197159 , p_ae_header_id => l_ae_header_id
197160 , p_source_11 => p_source_11
197161 , x_transaction_coa_id => l_adr_transaction_coa_id
197162 , x_accounting_coa_id => l_adr_accounting_coa_id
197163 , x_value_type_code => l_adr_value_type_code
197164 , p_side => 'NA'
197165 );
197166
197167 xla_ae_lines_pkg.set_ccid(
197168 p_code_combination_id => l_ccid
197169 , p_value_type_code => l_adr_value_type_code
197170 , p_transaction_coa_id => l_adr_transaction_coa_id
197171 , p_accounting_coa_id => l_adr_accounting_coa_id
197172 , p_adr_code => 'CST_DEFAULT'
197173 , p_adr_type_code => 'S'
197174 , p_component_type => l_component_type
197175 , p_component_code => l_component_code
197176 , p_component_type_code => l_component_type_code
197177 , p_component_appl_id => l_component_appl_id
197178 , p_amb_context_code => l_amb_context_code
197179 , p_side => 'NA'
197180 );
197181
197182
197183 --
197184 --
197185 END IF;
197186
197187 --
197188 -- Update the line information that should be overwritten
197189 --
197190 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
197191 p_header_num => 1);
197192 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
197193
197194 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
197195
197196 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
197197 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
197198 END IF;
197199
197200 --
197201 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
197202 --
197203 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
197204 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
197205 ELSE
197206 ---------------------------------------------------------------------------------------------------
197207 -- 4262811a Switch Sign
197208 ---------------------------------------------------------------------------------------------------
197209 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
197210 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
197211 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197212 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
197213 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197214 -- 5132302
197215 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
197216 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197217
197218 END IF;
197219
197220 -- 4955764
197221 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
197222 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
197223
197224
197225 XLA_AE_LINES_PKG.ValidateCurrentLine;
197226 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
197227
197228 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
197229 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
197230 ,p_balance_type_code => l_balance_type_code);
197231
197232 END IF;
197233
197234 -----------------------------------------------------------------------------------------
197235 -- 4262811 Multiperiod Accounting
197236 -----------------------------------------------------------------------------------------
197237 -- No MPA option is assigned.
197238
197239
197240 END IF;
197241 END IF;
197242 --
197243
197244 --
197245 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
197246 trace
197247 (p_msg => 'END of AcctLineType_360'
197248 ,p_level => C_LEVEL_PROCEDURE
197249 ,p_module => l_log_module);
197250 END IF;
197251 --
197252 EXCEPTION
197253 WHEN xla_exceptions_pkg.application_exception THEN
197254 RAISE;
197255 WHEN OTHERS THEN
197256 xla_exceptions_pkg.raise_message
197257 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_360');
197258 END AcctLineType_360;
197259 --
197260
197261 ---------------------------------------
197262 --
197263 -- PRIVATE FUNCTION
197264 -- AcctLineType_361
197265 --
197266 ---------------------------------------
197267 PROCEDURE AcctLineType_361 (
197268 p_application_id IN NUMBER
197269 ,p_event_id IN NUMBER
197270 ,p_calculate_acctd_flag IN VARCHAR2
197271 ,p_calculate_g_l_flag IN VARCHAR2
197272 ,p_actual_flag IN OUT VARCHAR2
197273 ,p_balance_type_code OUT VARCHAR2
197274 ,p_gain_or_loss_ref OUT VARCHAR2
197275
197276 --TRANSACTION_ID
197277 , p_source_1 IN NUMBER
197278 --Item Concatenated Segments
197279 , p_source_2 IN VARCHAR2
197280 --Transaction Quantity
197281 , p_source_3 IN NUMBER
197282 --Transaction Unit of Measure Code
197283 , p_source_4 IN VARCHAR2
197284 --Inventory Transaction Type Description
197285 , p_source_5 IN VARCHAR2
197286 --Transaction Distribution Account
197287 , p_source_20 IN NUMBER
197288 --DISTRIBUTION_IDENTIFIER
197289 , p_source_84 IN NUMBER
197290 --Distribution Type
197291 , p_source_85 IN VARCHAR2
197292 , p_source_85_meaning IN VARCHAR2
197293 --Entered Currency Code
197294 , p_source_88 IN VARCHAR2
197295 --Entered Amount
197296 , p_source_91 IN NUMBER
197297 --Currency Conversion Date
197298 , p_source_92 IN DATE
197299 --Currency Conversion Rate
197300 , p_source_93 IN NUMBER
197301 --Currency Conversion Type
197302 , p_source_94 IN VARCHAR2
197303 --Accounted Amount
197304 , p_source_95 IN NUMBER
197305 --Accounting Line Type
197306 , p_source_97 IN NUMBER
197307 )
197308 IS
197309
197310 l_component_type VARCHAR2(80);
197311 l_component_code VARCHAR2(30);
197312 l_component_type_code VARCHAR2(1);
197313 l_component_appl_id INTEGER;
197314 l_amb_context_code VARCHAR2(30);
197315 l_entity_code VARCHAR2(30);
197316 l_event_class_code VARCHAR2(30);
197317 l_ae_header_id NUMBER;
197318 l_event_type_code VARCHAR2(30);
197319 l_line_definition_code VARCHAR2(30);
197320 l_line_definition_owner_code VARCHAR2(1);
197321 --
197322 -- adr variables
197323 l_segment VARCHAR2(30);
197324 l_ccid NUMBER;
197325 l_adr_transaction_coa_id NUMBER;
197326 l_adr_accounting_coa_id NUMBER;
197327 l_adr_flexfield_segment_code VARCHAR2(30);
197328 l_adr_flex_value_set_id NUMBER;
197329 l_adr_value_type_code VARCHAR2(30);
197330 l_adr_value_combination_id NUMBER;
197331 l_adr_value_segment_code VARCHAR2(30);
197332
197333 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
197334 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
197335 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
197336 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
197337
197338 -- 4262811 Variables ------------------------------------------------------------------------------------------
197339 l_entered_amt_idx NUMBER;
197340 l_accted_amt_idx NUMBER;
197341 l_acc_rev_flag VARCHAR2(1);
197342 l_accrual_line_num NUMBER;
197343 l_tmp_amt NUMBER;
197344 l_acc_rev_natural_side_code VARCHAR2(1);
197345
197346 l_num_entries NUMBER;
197347 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
197348 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
197349 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
197350 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
197351 l_recog_line_1 NUMBER;
197352 l_recog_line_2 NUMBER;
197353
197354 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
197355 l_bflow_applied_to_amt NUMBER; -- 5132302
197356 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
197357
197358 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
197359
197360 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
197361 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
197362
197363 ---------------------------------------------------------------------------------------------------------------
197364
197365
197366 --
197367 -- bulk performance
197368 --
197369 l_balance_type_code VARCHAR2(1);
197370 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
197371 l_log_module VARCHAR2(240);
197372
197373 --
197374 -- Upgrade strategy
197375 --
197376 l_actual_upg_option VARCHAR2(1);
197377 l_enc_upg_option VARCHAR2(1);
197378
197379 --
197380 BEGIN
197381 --
197382 IF g_log_enabled THEN
197383 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_361';
197384 END IF;
197385 --
197386 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
197387
197388 trace
197389 (p_msg => 'BEGIN of AcctLineType_361'
197390 ,p_level => C_LEVEL_PROCEDURE
197391 ,p_module => l_log_module);
197392
197393 END IF;
197394 --
197395 l_component_type := 'AMB_JLT';
197396 l_component_code := 'OFFSET';
197397 l_component_type_code := 'S';
197398 l_component_appl_id := 707;
197399 l_amb_context_code := 'DEFAULT';
197400 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
197401 l_event_class_code := 'INT_ORDER_TO_EXP';
197402 l_event_type_code := 'EXP_REQ_RCPT_TP';
197403 l_line_definition_owner_code := 'S';
197404 l_line_definition_code := 'PI_EXP_REQ_RCPT_TP';
197405 --
197406 l_balance_type_code := 'A';
197407 l_segment := NULL;
197408 l_ccid := NULL;
197409 l_adr_transaction_coa_id := NULL;
197410 l_adr_accounting_coa_id := NULL;
197411 l_adr_flexfield_segment_code := NULL;
197412 l_adr_flex_value_set_id := NULL;
197413 l_adr_value_type_code := NULL;
197414 l_adr_value_combination_id := NULL;
197415 l_adr_value_segment_code := NULL;
197416
197417 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
197418 l_bflow_class_code := ''; -- 4219869 Business Flow
197419 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
197420 l_budgetary_control_flag := 'N';
197421
197422 l_bflow_applied_to_amt_idx := NULL; -- 5132302
197423 l_bflow_applied_to_amt := NULL; -- 5132302
197424 l_entered_amt_idx := NULL; -- 4262811
197425 l_accted_amt_idx := NULL; -- 4262811
197426 l_acc_rev_flag := NULL; -- 4262811
197427 l_accrual_line_num := NULL; -- 4262811
197428 l_tmp_amt := NULL; -- 4262811
197429 --
197430
197431 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
197432 l_balance_type_code <> 'B' THEN
197433 IF NVL(p_source_97,9E125) = 2
197434 THEN
197435
197436 --
197437 XLA_AE_LINES_PKG.SetNewLine;
197438
197439 p_balance_type_code := l_balance_type_code;
197440 -- set the flag so later we will know whether the gain loss line needs to be created
197441
197442 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
197443 p_actual_flag :='A';
197444 END IF;
197445
197446 --
197447 -- bulk performance
197448 --
197449 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
197450 p_header_num => 0); -- 4262811
197451 --
197452 -- set accounting line options
197453 --
197454 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
197455 p_natural_side_code => 'D'
197456 , p_gain_or_loss_flag => 'N'
197457 , p_gl_transfer_mode_code => 'S'
197458 , p_acct_entry_type_code => 'A'
197459 , p_switch_side_flag => 'Y'
197460 , p_merge_duplicate_code => 'N'
197461 );
197462 --
197463 l_acc_rev_natural_side_code := 'C'; -- 4262811
197464 --
197465 --
197466 -- set accounting line type info
197467 --
197468 xla_ae_lines_pkg.SetAcctLineType
197469 (p_component_type => l_component_type
197470 ,p_event_type_code => l_event_type_code
197471 ,p_line_definition_owner_code => l_line_definition_owner_code
197472 ,p_line_definition_code => l_line_definition_code
197473 ,p_accounting_line_code => l_component_code
197474 ,p_accounting_line_type_code => l_component_type_code
197475 ,p_accounting_line_appl_id => l_component_appl_id
197476 ,p_amb_context_code => l_amb_context_code
197477 ,p_entity_code => l_entity_code
197478 ,p_event_class_code => l_event_class_code);
197479 --
197480 -- set accounting class
197481 --
197482 xla_ae_lines_pkg.SetAcctClass(
197483 p_accounting_class_code => 'OFFSET'
197484 , p_ae_header_id => l_ae_header_id
197485 );
197486
197487 --
197488 -- set rounding class
197489 --
197490 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
197491 'OFFSET';
197492
197493 --
197494 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
197495 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
197496 --
197497 -- bulk performance
197498 --
197499 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
197500
197501 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
197502 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
197503
197504 -- 4955764
197505 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
197506 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
197507
197508 -- 4458381 Public Sector Enh
197509
197510 --
197511 -- set accounting attributes for the line type
197512 --
197513 l_entered_amt_idx := 3;
197514 l_accted_amt_idx := 8;
197515 l_bflow_applied_to_amt_idx := NULL; -- 5132302
197516 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
197517 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
197518 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
197519 l_rec_acct_attrs.array_char_value(2) := p_source_85;
197520 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
197521 l_rec_acct_attrs.array_num_value(3) := p_source_91;
197522 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
197523 l_rec_acct_attrs.array_char_value(4) := p_source_88;
197524 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
197525 l_rec_acct_attrs.array_date_value(5) := p_source_92;
197526 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
197527 l_rec_acct_attrs.array_num_value(6) := p_source_93;
197528 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
197529 l_rec_acct_attrs.array_char_value(7) := p_source_94;
197530 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
197531 l_rec_acct_attrs.array_num_value(8) := p_source_95;
197532
197533 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
197534 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
197535
197536 ---------------------------------------------------------------------------------------------------------------
197537 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
197538 ---------------------------------------------------------------------------------------------------------------
197539 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
197540
197541 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
197542 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
197543
197544 IF xla_accounting_cache_pkg.GetValueChar
197545 (p_source_code => 'LEDGER_CATEGORY_CODE'
197546 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
197547 AND l_bflow_method_code = 'PRIOR_ENTRY'
197548 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
197549 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
197550 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
197551 )
197552 THEN
197553 xla_ae_lines_pkg.BflowUpgEntry
197554 (p_business_method_code => l_bflow_method_code
197555 ,p_business_class_code => l_bflow_class_code
197556 ,p_balance_type => l_balance_type_code);
197557 ELSE
197558 NULL;
197559 -- No business flow processing for business flow method of NONE.
197560 END IF;
197561
197562 --
197563 -- call analytical criteria
197564 --
197565
197566 --
197567 -- call description
197568 --
197569
197570 xla_ae_lines_pkg.SetLineDescription(
197571 p_ae_header_id => l_ae_header_id
197572 ,p_description => Description_1 (
197573 p_application_id => p_application_id
197574 , p_ae_header_id => l_ae_header_id
197575 , p_source_1 => p_source_1
197576 , p_source_2 => p_source_2
197577 , p_source_3 => p_source_3
197578 , p_source_4 => p_source_4
197579 , p_source_5 => p_source_5
197580 )
197581 );
197582
197583
197584 --
197585 -- call ADRs
197586 -- Bug 4922099
197587 --
197588 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
197589 (NVL(l_actual_upg_option, 'N') = 'O') OR
197590 (NVL(l_enc_upg_option, 'N') = 'O')
197591 )
197592 THEN
197593 NULL;
197594 --
197595 --
197596
197597 l_ccid := AcctDerRule_16(
197598 p_application_id => p_application_id
197599 , p_ae_header_id => l_ae_header_id
197600 , p_source_20 => p_source_20
197601 , x_transaction_coa_id => l_adr_transaction_coa_id
197602 , x_accounting_coa_id => l_adr_accounting_coa_id
197603 , x_value_type_code => l_adr_value_type_code
197604 , p_side => 'NA'
197605 );
197606
197607 xla_ae_lines_pkg.set_ccid(
197608 p_code_combination_id => l_ccid
197609 , p_value_type_code => l_adr_value_type_code
197610 , p_transaction_coa_id => l_adr_transaction_coa_id
197611 , p_accounting_coa_id => l_adr_accounting_coa_id
197612 , p_adr_code => 'PI_DISTRIBUTION'
197613 , p_adr_type_code => 'S'
197614 , p_component_type => l_component_type
197615 , p_component_code => l_component_code
197616 , p_component_type_code => l_component_type_code
197617 , p_component_appl_id => l_component_appl_id
197618 , p_amb_context_code => l_amb_context_code
197619 , p_side => 'NA'
197620 );
197621
197622
197623 --
197624 --
197625 END IF;
197626 --
197627 -- Bug 4922099
197628 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
197629 (NVL(l_enc_upg_option, 'N') = 'O')
197630 ) AND
197631 (l_bflow_method_code = 'PRIOR_ENTRY')
197632 )
197633 THEN
197634 IF
197635 --
197636 1 = 2
197637 --
197638 THEN
197639 xla_accounting_err_pkg.build_message
197640 (p_appli_s_name => 'XLA'
197641 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
197642 ,p_token_1 => 'LINE_NUMBER'
197643 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
197644 ,p_token_2 => 'LINE_TYPE_NAME'
197645 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
197646 l_component_type
197647 ,l_component_code
197648 ,l_component_type_code
197649 ,l_component_appl_id
197650 ,l_amb_context_code
197651 ,l_entity_code
197652 ,l_event_class_code
197653 )
197654 ,p_token_3 => 'OWNER'
197655 ,p_value_3 => xla_lookups_pkg.get_meaning(
197656 p_lookup_type => 'XLA_OWNER_TYPE'
197657 ,p_lookup_code => l_component_type_code
197658 )
197659 ,p_token_4 => 'PRODUCT_NAME'
197660 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
197661 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
197662 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
197663 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
197664 ,p_ae_header_id => NULL
197665 );
197666
197667 IF (C_LEVEL_ERROR>= g_log_level) THEN
197668 trace
197669 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
197670 ,p_level => C_LEVEL_ERROR
197671 ,p_module => l_log_module);
197672 END IF;
197673 END IF;
197674 END IF;
197675 --
197676 --
197677 ------------------------------------------------------------------------------------------------
197678 -- 4219869 Business Flow
197679 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
197680 -- Prior Entry. Currently, the following code is always generated.
197681 ------------------------------------------------------------------------------------------------
197682 XLA_AE_LINES_PKG.ValidateCurrentLine;
197683
197684 ------------------------------------------------------------------------------------
197685 -- 4219869 Business Flow
197686 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
197687 ------------------------------------------------------------------------------------
197688 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
197689
197690 ----------------------------------------------------------------------------------
197691 -- 4219869 Business Flow
197692 -- Update journal entry status -- Need to generate this within IF <condition>
197693 ----------------------------------------------------------------------------------
197694 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
197695 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
197696 ,p_balance_type_code => l_balance_type_code
197697 );
197698
197699 -------------------------------------------------------------------------------------------
197700 -- 4262811 - Generate the Accrual Reversal lines
197701 -------------------------------------------------------------------------------------------
197702 BEGIN
197703 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
197704 (g_array_event(p_event_id).array_value_num('header_index'));
197705 IF l_acc_rev_flag IS NULL THEN
197706 l_acc_rev_flag := 'N';
197707 END IF;
197708 EXCEPTION
197709 WHEN OTHERS THEN
197710 l_acc_rev_flag := 'N';
197711 END;
197712 --
197713 IF (l_acc_rev_flag = 'Y') THEN
197714
197715 -- 4645092 ------------------------------------------------------------------------------
197716 -- To allow MPA report to determine if it should generate report process
197717 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
197718 ------------------------------------------------------------------------------------------
197719
197720 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
197721 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
197722 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
197723 -- call ADRs
197724 -- Bug 4922099
197725 --
197726 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
197727 (NVL(l_actual_upg_option, 'N') = 'O') OR
197728 (NVL(l_enc_upg_option, 'N') = 'O')
197729 )
197730 THEN
197731 NULL;
197732 --
197733 --
197734
197735 l_ccid := AcctDerRule_16(
197736 p_application_id => p_application_id
197737 , p_ae_header_id => l_ae_header_id
197738 , p_source_20 => p_source_20
197739 , x_transaction_coa_id => l_adr_transaction_coa_id
197740 , x_accounting_coa_id => l_adr_accounting_coa_id
197741 , x_value_type_code => l_adr_value_type_code
197742 , p_side => 'NA'
197743 );
197744
197745 xla_ae_lines_pkg.set_ccid(
197746 p_code_combination_id => l_ccid
197747 , p_value_type_code => l_adr_value_type_code
197748 , p_transaction_coa_id => l_adr_transaction_coa_id
197749 , p_accounting_coa_id => l_adr_accounting_coa_id
197750 , p_adr_code => 'PI_DISTRIBUTION'
197751 , p_adr_type_code => 'S'
197752 , p_component_type => l_component_type
197753 , p_component_code => l_component_code
197754 , p_component_type_code => l_component_type_code
197755 , p_component_appl_id => l_component_appl_id
197756 , p_amb_context_code => l_amb_context_code
197757 , p_side => 'NA'
197758 );
197759
197760
197761 --
197762 --
197763 END IF;
197764
197765 --
197766 -- Update the line information that should be overwritten
197767 --
197768 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
197769 p_header_num => 1);
197770 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
197771
197772 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
197773
197774 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
197775 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
197776 END IF;
197777
197778 --
197779 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
197780 --
197781 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
197782 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
197783 ELSE
197784 ---------------------------------------------------------------------------------------------------
197785 -- 4262811a Switch Sign
197786 ---------------------------------------------------------------------------------------------------
197787 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
197788 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
197789 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197790 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
197791 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197792 -- 5132302
197793 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
197794 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
197795
197796 END IF;
197797
197798 -- 4955764
197799 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
197800 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
197801
197802
197803 XLA_AE_LINES_PKG.ValidateCurrentLine;
197804 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
197805
197806 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
197807 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
197808 ,p_balance_type_code => l_balance_type_code);
197809
197810 END IF;
197811
197812 -----------------------------------------------------------------------------------------
197813 -- 4262811 Multiperiod Accounting
197814 -----------------------------------------------------------------------------------------
197815 -- No MPA option is assigned.
197816
197817
197818 END IF;
197819 END IF;
197820 --
197821
197822 --
197823 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
197824 trace
197825 (p_msg => 'END of AcctLineType_361'
197826 ,p_level => C_LEVEL_PROCEDURE
197827 ,p_module => l_log_module);
197828 END IF;
197829 --
197830 EXCEPTION
197831 WHEN xla_exceptions_pkg.application_exception THEN
197832 RAISE;
197833 WHEN OTHERS THEN
197834 xla_exceptions_pkg.raise_message
197835 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_361');
197836 END AcctLineType_361;
197837 --
197838
197839 ---------------------------------------
197840 --
197841 -- PRIVATE FUNCTION
197842 -- AcctLineType_362
197843 --
197844 ---------------------------------------
197845 PROCEDURE AcctLineType_362 (
197846 p_application_id IN NUMBER
197847 ,p_event_id IN NUMBER
197848 ,p_calculate_acctd_flag IN VARCHAR2
197849 ,p_calculate_g_l_flag IN VARCHAR2
197850 ,p_actual_flag IN OUT VARCHAR2
197851 ,p_balance_type_code OUT VARCHAR2
197852 ,p_gain_or_loss_ref OUT VARCHAR2
197853
197854 --TRANSACTION_ID
197855 , p_source_1 IN NUMBER
197856 --Item Concatenated Segments
197857 , p_source_2 IN VARCHAR2
197858 --Transaction Quantity
197859 , p_source_3 IN NUMBER
197860 --Transaction Unit of Measure Code
197861 , p_source_4 IN VARCHAR2
197862 --Inventory Transaction Type Description
197863 , p_source_5 IN VARCHAR2
197864 --Cost Management Default Account
197865 , p_source_11 IN NUMBER
197866 --DISTRIBUTION_IDENTIFIER
197867 , p_source_84 IN NUMBER
197868 --Distribution Type
197869 , p_source_85 IN VARCHAR2
197870 , p_source_85_meaning IN VARCHAR2
197871 --Entered Currency Code
197872 , p_source_88 IN VARCHAR2
197873 --Entered Amount
197874 , p_source_91 IN NUMBER
197875 --Currency Conversion Date
197876 , p_source_92 IN DATE
197877 --Currency Conversion Rate
197878 , p_source_93 IN NUMBER
197879 --Currency Conversion Type
197880 , p_source_94 IN VARCHAR2
197881 --Accounted Amount
197882 , p_source_95 IN NUMBER
197883 --Accounting Line Type
197884 , p_source_97 IN NUMBER
197885 )
197886 IS
197887
197888 l_component_type VARCHAR2(80);
197889 l_component_code VARCHAR2(30);
197890 l_component_type_code VARCHAR2(1);
197891 l_component_appl_id INTEGER;
197892 l_amb_context_code VARCHAR2(30);
197893 l_entity_code VARCHAR2(30);
197894 l_event_class_code VARCHAR2(30);
197895 l_ae_header_id NUMBER;
197896 l_event_type_code VARCHAR2(30);
197897 l_line_definition_code VARCHAR2(30);
197898 l_line_definition_owner_code VARCHAR2(1);
197899 --
197900 -- adr variables
197901 l_segment VARCHAR2(30);
197902 l_ccid NUMBER;
197903 l_adr_transaction_coa_id NUMBER;
197904 l_adr_accounting_coa_id NUMBER;
197905 l_adr_flexfield_segment_code VARCHAR2(30);
197906 l_adr_flex_value_set_id NUMBER;
197907 l_adr_value_type_code VARCHAR2(30);
197908 l_adr_value_combination_id NUMBER;
197909 l_adr_value_segment_code VARCHAR2(30);
197910
197911 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
197912 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
197913 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
197914 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
197915
197916 -- 4262811 Variables ------------------------------------------------------------------------------------------
197917 l_entered_amt_idx NUMBER;
197918 l_accted_amt_idx NUMBER;
197919 l_acc_rev_flag VARCHAR2(1);
197920 l_accrual_line_num NUMBER;
197921 l_tmp_amt NUMBER;
197922 l_acc_rev_natural_side_code VARCHAR2(1);
197923
197924 l_num_entries NUMBER;
197925 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
197926 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
197927 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
197928 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
197929 l_recog_line_1 NUMBER;
197930 l_recog_line_2 NUMBER;
197931
197932 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
197933 l_bflow_applied_to_amt NUMBER; -- 5132302
197934 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
197935
197936 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
197937
197938 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
197939 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
197940
197941 ---------------------------------------------------------------------------------------------------------------
197942
197943
197944 --
197945 -- bulk performance
197946 --
197947 l_balance_type_code VARCHAR2(1);
197948 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
197949 l_log_module VARCHAR2(240);
197950
197951 --
197952 -- Upgrade strategy
197953 --
197954 l_actual_upg_option VARCHAR2(1);
197955 l_enc_upg_option VARCHAR2(1);
197956
197957 --
197958 BEGIN
197959 --
197960 IF g_log_enabled THEN
197961 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_362';
197962 END IF;
197963 --
197964 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
197965
197966 trace
197967 (p_msg => 'BEGIN of AcctLineType_362'
197968 ,p_level => C_LEVEL_PROCEDURE
197969 ,p_module => l_log_module);
197970
197971 END IF;
197972 --
197973 l_component_type := 'AMB_JLT';
197974 l_component_code := 'OFFSET';
197975 l_component_type_code := 'S';
197976 l_component_appl_id := 707;
197977 l_amb_context_code := 'DEFAULT';
197978 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
197979 l_event_class_code := 'INT_ORDER_TO_EXP';
197980 l_event_type_code := 'INT_ORDER_ISSUE_NO_TP';
197981 l_line_definition_owner_code := 'S';
197982 l_line_definition_code := 'PI_INT_ORDER_ISSUE_NO_TP';
197983 --
197984 l_balance_type_code := 'A';
197985 l_segment := NULL;
197986 l_ccid := NULL;
197987 l_adr_transaction_coa_id := NULL;
197988 l_adr_accounting_coa_id := NULL;
197989 l_adr_flexfield_segment_code := NULL;
197990 l_adr_flex_value_set_id := NULL;
197991 l_adr_value_type_code := NULL;
197992 l_adr_value_combination_id := NULL;
197993 l_adr_value_segment_code := NULL;
197994
197995 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
197996 l_bflow_class_code := ''; -- 4219869 Business Flow
197997 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
197998 l_budgetary_control_flag := 'N';
197999
198000 l_bflow_applied_to_amt_idx := NULL; -- 5132302
198001 l_bflow_applied_to_amt := NULL; -- 5132302
198002 l_entered_amt_idx := NULL; -- 4262811
198003 l_accted_amt_idx := NULL; -- 4262811
198004 l_acc_rev_flag := NULL; -- 4262811
198005 l_accrual_line_num := NULL; -- 4262811
198006 l_tmp_amt := NULL; -- 4262811
198007 --
198008
198009 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
198010 l_balance_type_code <> 'B' THEN
198011 IF NVL(p_source_97,9E125) = 2
198012 THEN
198013
198014 --
198015 XLA_AE_LINES_PKG.SetNewLine;
198016
198017 p_balance_type_code := l_balance_type_code;
198018 -- set the flag so later we will know whether the gain loss line needs to be created
198019
198020 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
198021 p_actual_flag :='A';
198022 END IF;
198023
198024 --
198025 -- bulk performance
198026 --
198027 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
198028 p_header_num => 0); -- 4262811
198029 --
198030 -- set accounting line options
198031 --
198032 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
198033 p_natural_side_code => 'D'
198034 , p_gain_or_loss_flag => 'N'
198035 , p_gl_transfer_mode_code => 'S'
198036 , p_acct_entry_type_code => 'A'
198037 , p_switch_side_flag => 'Y'
198038 , p_merge_duplicate_code => 'N'
198039 );
198040 --
198041 l_acc_rev_natural_side_code := 'C'; -- 4262811
198042 --
198043 --
198044 -- set accounting line type info
198045 --
198046 xla_ae_lines_pkg.SetAcctLineType
198047 (p_component_type => l_component_type
198048 ,p_event_type_code => l_event_type_code
198049 ,p_line_definition_owner_code => l_line_definition_owner_code
198050 ,p_line_definition_code => l_line_definition_code
198051 ,p_accounting_line_code => l_component_code
198052 ,p_accounting_line_type_code => l_component_type_code
198053 ,p_accounting_line_appl_id => l_component_appl_id
198054 ,p_amb_context_code => l_amb_context_code
198055 ,p_entity_code => l_entity_code
198056 ,p_event_class_code => l_event_class_code);
198057 --
198058 -- set accounting class
198059 --
198060 xla_ae_lines_pkg.SetAcctClass(
198061 p_accounting_class_code => 'OFFSET'
198062 , p_ae_header_id => l_ae_header_id
198063 );
198064
198065 --
198066 -- set rounding class
198067 --
198068 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
198069 'OFFSET';
198070
198071 --
198072 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
198073 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
198074 --
198075 -- bulk performance
198076 --
198077 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
198078
198079 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
198080 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
198081
198082 -- 4955764
198083 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
198084 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
198085
198086 -- 4458381 Public Sector Enh
198087
198088 --
198089 -- set accounting attributes for the line type
198090 --
198091 l_entered_amt_idx := 3;
198092 l_accted_amt_idx := 8;
198093 l_bflow_applied_to_amt_idx := NULL; -- 5132302
198094 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
198095 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
198096 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
198097 l_rec_acct_attrs.array_char_value(2) := p_source_85;
198098 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
198099 l_rec_acct_attrs.array_num_value(3) := p_source_91;
198100 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
198101 l_rec_acct_attrs.array_char_value(4) := p_source_88;
198102 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
198103 l_rec_acct_attrs.array_date_value(5) := p_source_92;
198104 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
198105 l_rec_acct_attrs.array_num_value(6) := p_source_93;
198106 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
198107 l_rec_acct_attrs.array_char_value(7) := p_source_94;
198108 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
198109 l_rec_acct_attrs.array_num_value(8) := p_source_95;
198110
198111 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
198112 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
198113
198114 ---------------------------------------------------------------------------------------------------------------
198115 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
198116 ---------------------------------------------------------------------------------------------------------------
198117 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
198118
198119 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
198120 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
198121
198122 IF xla_accounting_cache_pkg.GetValueChar
198123 (p_source_code => 'LEDGER_CATEGORY_CODE'
198124 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
198125 AND l_bflow_method_code = 'PRIOR_ENTRY'
198126 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
198127 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
198128 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
198129 )
198130 THEN
198131 xla_ae_lines_pkg.BflowUpgEntry
198132 (p_business_method_code => l_bflow_method_code
198133 ,p_business_class_code => l_bflow_class_code
198134 ,p_balance_type => l_balance_type_code);
198135 ELSE
198136 NULL;
198137 -- No business flow processing for business flow method of NONE.
198138 END IF;
198139
198140 --
198141 -- call analytical criteria
198142 --
198143
198144 --
198145 -- call description
198146 --
198147
198148 xla_ae_lines_pkg.SetLineDescription(
198149 p_ae_header_id => l_ae_header_id
198150 ,p_description => Description_1 (
198151 p_application_id => p_application_id
198152 , p_ae_header_id => l_ae_header_id
198153 , p_source_1 => p_source_1
198154 , p_source_2 => p_source_2
198155 , p_source_3 => p_source_3
198156 , p_source_4 => p_source_4
198157 , p_source_5 => p_source_5
198158 )
198159 );
198160
198161
198162 --
198163 -- call ADRs
198164 -- Bug 4922099
198165 --
198166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
198167 (NVL(l_actual_upg_option, 'N') = 'O') OR
198168 (NVL(l_enc_upg_option, 'N') = 'O')
198169 )
198170 THEN
198171 NULL;
198172 --
198173 --
198174
198175 l_ccid := AcctDerRule_6(
198176 p_application_id => p_application_id
198177 , p_ae_header_id => l_ae_header_id
198178 , p_source_11 => p_source_11
198179 , x_transaction_coa_id => l_adr_transaction_coa_id
198180 , x_accounting_coa_id => l_adr_accounting_coa_id
198181 , x_value_type_code => l_adr_value_type_code
198182 , p_side => 'NA'
198183 );
198184
198185 xla_ae_lines_pkg.set_ccid(
198186 p_code_combination_id => l_ccid
198187 , p_value_type_code => l_adr_value_type_code
198188 , p_transaction_coa_id => l_adr_transaction_coa_id
198189 , p_accounting_coa_id => l_adr_accounting_coa_id
198190 , p_adr_code => 'CST_DEFAULT'
198191 , p_adr_type_code => 'S'
198192 , p_component_type => l_component_type
198193 , p_component_code => l_component_code
198194 , p_component_type_code => l_component_type_code
198195 , p_component_appl_id => l_component_appl_id
198196 , p_amb_context_code => l_amb_context_code
198197 , p_side => 'NA'
198198 );
198199
198200
198201 --
198202 --
198203 END IF;
198204 --
198205 -- Bug 4922099
198206 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
198207 (NVL(l_enc_upg_option, 'N') = 'O')
198208 ) AND
198209 (l_bflow_method_code = 'PRIOR_ENTRY')
198210 )
198211 THEN
198212 IF
198213 --
198214 1 = 2
198215 --
198216 THEN
198217 xla_accounting_err_pkg.build_message
198218 (p_appli_s_name => 'XLA'
198219 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
198220 ,p_token_1 => 'LINE_NUMBER'
198221 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
198222 ,p_token_2 => 'LINE_TYPE_NAME'
198223 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
198224 l_component_type
198225 ,l_component_code
198226 ,l_component_type_code
198227 ,l_component_appl_id
198228 ,l_amb_context_code
198229 ,l_entity_code
198230 ,l_event_class_code
198231 )
198232 ,p_token_3 => 'OWNER'
198233 ,p_value_3 => xla_lookups_pkg.get_meaning(
198234 p_lookup_type => 'XLA_OWNER_TYPE'
198235 ,p_lookup_code => l_component_type_code
198236 )
198237 ,p_token_4 => 'PRODUCT_NAME'
198238 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
198239 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
198240 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
198241 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
198242 ,p_ae_header_id => NULL
198243 );
198244
198245 IF (C_LEVEL_ERROR>= g_log_level) THEN
198246 trace
198247 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
198248 ,p_level => C_LEVEL_ERROR
198249 ,p_module => l_log_module);
198250 END IF;
198251 END IF;
198252 END IF;
198253 --
198254 --
198255 ------------------------------------------------------------------------------------------------
198256 -- 4219869 Business Flow
198257 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
198258 -- Prior Entry. Currently, the following code is always generated.
198259 ------------------------------------------------------------------------------------------------
198260 XLA_AE_LINES_PKG.ValidateCurrentLine;
198261
198262 ------------------------------------------------------------------------------------
198263 -- 4219869 Business Flow
198264 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
198265 ------------------------------------------------------------------------------------
198266 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
198267
198268 ----------------------------------------------------------------------------------
198269 -- 4219869 Business Flow
198270 -- Update journal entry status -- Need to generate this within IF <condition>
198271 ----------------------------------------------------------------------------------
198272 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
198273 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
198274 ,p_balance_type_code => l_balance_type_code
198275 );
198276
198277 -------------------------------------------------------------------------------------------
198278 -- 4262811 - Generate the Accrual Reversal lines
198279 -------------------------------------------------------------------------------------------
198280 BEGIN
198281 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
198282 (g_array_event(p_event_id).array_value_num('header_index'));
198283 IF l_acc_rev_flag IS NULL THEN
198284 l_acc_rev_flag := 'N';
198285 END IF;
198286 EXCEPTION
198287 WHEN OTHERS THEN
198288 l_acc_rev_flag := 'N';
198289 END;
198290 --
198291 IF (l_acc_rev_flag = 'Y') THEN
198292
198293 -- 4645092 ------------------------------------------------------------------------------
198294 -- To allow MPA report to determine if it should generate report process
198295 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
198296 ------------------------------------------------------------------------------------------
198297
198298 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
198299 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
198300 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
198301 -- call ADRs
198302 -- Bug 4922099
198303 --
198304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
198305 (NVL(l_actual_upg_option, 'N') = 'O') OR
198306 (NVL(l_enc_upg_option, 'N') = 'O')
198307 )
198308 THEN
198309 NULL;
198310 --
198311 --
198312
198313 l_ccid := AcctDerRule_6(
198314 p_application_id => p_application_id
198315 , p_ae_header_id => l_ae_header_id
198316 , p_source_11 => p_source_11
198317 , x_transaction_coa_id => l_adr_transaction_coa_id
198318 , x_accounting_coa_id => l_adr_accounting_coa_id
198319 , x_value_type_code => l_adr_value_type_code
198320 , p_side => 'NA'
198321 );
198322
198323 xla_ae_lines_pkg.set_ccid(
198324 p_code_combination_id => l_ccid
198325 , p_value_type_code => l_adr_value_type_code
198326 , p_transaction_coa_id => l_adr_transaction_coa_id
198327 , p_accounting_coa_id => l_adr_accounting_coa_id
198328 , p_adr_code => 'CST_DEFAULT'
198329 , p_adr_type_code => 'S'
198330 , p_component_type => l_component_type
198331 , p_component_code => l_component_code
198332 , p_component_type_code => l_component_type_code
198333 , p_component_appl_id => l_component_appl_id
198334 , p_amb_context_code => l_amb_context_code
198335 , p_side => 'NA'
198336 );
198337
198338
198339 --
198340 --
198341 END IF;
198342
198343 --
198344 -- Update the line information that should be overwritten
198345 --
198346 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
198347 p_header_num => 1);
198348 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
198349
198350 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
198351
198352 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
198353 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
198354 END IF;
198355
198356 --
198357 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
198358 --
198359 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
198360 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
198361 ELSE
198362 ---------------------------------------------------------------------------------------------------
198363 -- 4262811a Switch Sign
198364 ---------------------------------------------------------------------------------------------------
198365 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
198366 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
198367 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198368 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
198369 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198370 -- 5132302
198371 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
198372 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198373
198374 END IF;
198375
198376 -- 4955764
198377 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
198378 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
198379
198380
198381 XLA_AE_LINES_PKG.ValidateCurrentLine;
198382 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
198383
198384 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
198385 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
198386 ,p_balance_type_code => l_balance_type_code);
198387
198388 END IF;
198389
198390 -----------------------------------------------------------------------------------------
198391 -- 4262811 Multiperiod Accounting
198392 -----------------------------------------------------------------------------------------
198393 -- No MPA option is assigned.
198394
198395
198396 END IF;
198397 END IF;
198398 --
198399
198400 --
198401 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
198402 trace
198403 (p_msg => 'END of AcctLineType_362'
198404 ,p_level => C_LEVEL_PROCEDURE
198405 ,p_module => l_log_module);
198406 END IF;
198407 --
198408 EXCEPTION
198409 WHEN xla_exceptions_pkg.application_exception THEN
198410 RAISE;
198411 WHEN OTHERS THEN
198412 xla_exceptions_pkg.raise_message
198413 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_362');
198414 END AcctLineType_362;
198415 --
198416
198417 ---------------------------------------
198418 --
198419 -- PRIVATE FUNCTION
198420 -- AcctLineType_363
198421 --
198422 ---------------------------------------
198423 PROCEDURE AcctLineType_363 (
198424 p_application_id IN NUMBER
198425 ,p_event_id IN NUMBER
198426 ,p_calculate_acctd_flag IN VARCHAR2
198427 ,p_calculate_g_l_flag IN VARCHAR2
198428 ,p_actual_flag IN OUT VARCHAR2
198429 ,p_balance_type_code OUT VARCHAR2
198430 ,p_gain_or_loss_ref OUT VARCHAR2
198431
198432 --TRANSACTION_ID
198433 , p_source_1 IN NUMBER
198434 --Item Concatenated Segments
198435 , p_source_2 IN VARCHAR2
198436 --Transaction Quantity
198437 , p_source_3 IN NUMBER
198438 --Transaction Unit of Measure Code
198439 , p_source_4 IN VARCHAR2
198440 --Inventory Transaction Type Description
198441 , p_source_5 IN VARCHAR2
198442 --Cost Management Default Account
198443 , p_source_11 IN NUMBER
198444 --DISTRIBUTION_IDENTIFIER
198445 , p_source_84 IN NUMBER
198446 --Distribution Type
198447 , p_source_85 IN VARCHAR2
198448 , p_source_85_meaning IN VARCHAR2
198449 --Entered Currency Code
198450 , p_source_88 IN VARCHAR2
198451 --Entered Amount
198452 , p_source_91 IN NUMBER
198453 --Currency Conversion Date
198454 , p_source_92 IN DATE
198455 --Currency Conversion Rate
198456 , p_source_93 IN NUMBER
198457 --Currency Conversion Type
198458 , p_source_94 IN VARCHAR2
198459 --Accounted Amount
198460 , p_source_95 IN NUMBER
198461 --Accounting Line Type
198462 , p_source_97 IN NUMBER
198463 )
198464 IS
198465
198466 l_component_type VARCHAR2(80);
198467 l_component_code VARCHAR2(30);
198468 l_component_type_code VARCHAR2(1);
198469 l_component_appl_id INTEGER;
198470 l_amb_context_code VARCHAR2(30);
198471 l_entity_code VARCHAR2(30);
198472 l_event_class_code VARCHAR2(30);
198473 l_ae_header_id NUMBER;
198474 l_event_type_code VARCHAR2(30);
198475 l_line_definition_code VARCHAR2(30);
198476 l_line_definition_owner_code VARCHAR2(1);
198477 --
198478 -- adr variables
198479 l_segment VARCHAR2(30);
198480 l_ccid NUMBER;
198481 l_adr_transaction_coa_id NUMBER;
198482 l_adr_accounting_coa_id NUMBER;
198483 l_adr_flexfield_segment_code VARCHAR2(30);
198484 l_adr_flex_value_set_id NUMBER;
198485 l_adr_value_type_code VARCHAR2(30);
198486 l_adr_value_combination_id NUMBER;
198487 l_adr_value_segment_code VARCHAR2(30);
198488
198489 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
198490 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
198491 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
198492 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
198493
198494 -- 4262811 Variables ------------------------------------------------------------------------------------------
198495 l_entered_amt_idx NUMBER;
198496 l_accted_amt_idx NUMBER;
198497 l_acc_rev_flag VARCHAR2(1);
198498 l_accrual_line_num NUMBER;
198499 l_tmp_amt NUMBER;
198500 l_acc_rev_natural_side_code VARCHAR2(1);
198501
198502 l_num_entries NUMBER;
198503 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
198504 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
198505 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
198506 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
198507 l_recog_line_1 NUMBER;
198508 l_recog_line_2 NUMBER;
198509
198510 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
198511 l_bflow_applied_to_amt NUMBER; -- 5132302
198512 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
198513
198514 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
198515
198516 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
198517 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
198518
198519 ---------------------------------------------------------------------------------------------------------------
198520
198521
198522 --
198523 -- bulk performance
198524 --
198525 l_balance_type_code VARCHAR2(1);
198526 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
198527 l_log_module VARCHAR2(240);
198528
198529 --
198530 -- Upgrade strategy
198531 --
198532 l_actual_upg_option VARCHAR2(1);
198533 l_enc_upg_option VARCHAR2(1);
198534
198535 --
198536 BEGIN
198537 --
198538 IF g_log_enabled THEN
198539 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_363';
198540 END IF;
198541 --
198542 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
198543
198544 trace
198545 (p_msg => 'BEGIN of AcctLineType_363'
198546 ,p_level => C_LEVEL_PROCEDURE
198547 ,p_module => l_log_module);
198548
198549 END IF;
198550 --
198551 l_component_type := 'AMB_JLT';
198552 l_component_code := 'OFFSET';
198553 l_component_type_code := 'S';
198554 l_component_appl_id := 707;
198555 l_amb_context_code := 'DEFAULT';
198556 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
198557 l_event_class_code := 'INT_ORDER_TO_EXP';
198558 l_event_type_code := 'INT_ORDER_ISSUE_TP';
198559 l_line_definition_owner_code := 'S';
198560 l_line_definition_code := 'PI_INT_ORDER_ISSUE_TP';
198561 --
198562 l_balance_type_code := 'A';
198563 l_segment := NULL;
198564 l_ccid := NULL;
198565 l_adr_transaction_coa_id := NULL;
198566 l_adr_accounting_coa_id := NULL;
198567 l_adr_flexfield_segment_code := NULL;
198568 l_adr_flex_value_set_id := NULL;
198569 l_adr_value_type_code := NULL;
198570 l_adr_value_combination_id := NULL;
198571 l_adr_value_segment_code := NULL;
198572
198573 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
198574 l_bflow_class_code := ''; -- 4219869 Business Flow
198575 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
198576 l_budgetary_control_flag := 'N';
198577
198578 l_bflow_applied_to_amt_idx := NULL; -- 5132302
198579 l_bflow_applied_to_amt := NULL; -- 5132302
198580 l_entered_amt_idx := NULL; -- 4262811
198581 l_accted_amt_idx := NULL; -- 4262811
198582 l_acc_rev_flag := NULL; -- 4262811
198583 l_accrual_line_num := NULL; -- 4262811
198584 l_tmp_amt := NULL; -- 4262811
198585 --
198586
198587 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
198588 l_balance_type_code <> 'B' THEN
198589 IF NVL(p_source_97,9E125) = 2
198590 THEN
198591
198592 --
198593 XLA_AE_LINES_PKG.SetNewLine;
198594
198595 p_balance_type_code := l_balance_type_code;
198596 -- set the flag so later we will know whether the gain loss line needs to be created
198597
198598 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
198599 p_actual_flag :='A';
198600 END IF;
198601
198602 --
198603 -- bulk performance
198604 --
198605 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
198606 p_header_num => 0); -- 4262811
198607 --
198608 -- set accounting line options
198609 --
198610 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
198611 p_natural_side_code => 'D'
198612 , p_gain_or_loss_flag => 'N'
198613 , p_gl_transfer_mode_code => 'S'
198614 , p_acct_entry_type_code => 'A'
198615 , p_switch_side_flag => 'Y'
198616 , p_merge_duplicate_code => 'N'
198617 );
198618 --
198619 l_acc_rev_natural_side_code := 'C'; -- 4262811
198620 --
198621 --
198622 -- set accounting line type info
198623 --
198624 xla_ae_lines_pkg.SetAcctLineType
198625 (p_component_type => l_component_type
198626 ,p_event_type_code => l_event_type_code
198627 ,p_line_definition_owner_code => l_line_definition_owner_code
198628 ,p_line_definition_code => l_line_definition_code
198629 ,p_accounting_line_code => l_component_code
198630 ,p_accounting_line_type_code => l_component_type_code
198631 ,p_accounting_line_appl_id => l_component_appl_id
198632 ,p_amb_context_code => l_amb_context_code
198633 ,p_entity_code => l_entity_code
198634 ,p_event_class_code => l_event_class_code);
198635 --
198636 -- set accounting class
198637 --
198638 xla_ae_lines_pkg.SetAcctClass(
198639 p_accounting_class_code => 'OFFSET'
198640 , p_ae_header_id => l_ae_header_id
198641 );
198642
198643 --
198644 -- set rounding class
198645 --
198646 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
198647 'OFFSET';
198648
198649 --
198650 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
198651 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
198652 --
198653 -- bulk performance
198654 --
198655 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
198656
198657 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
198658 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
198659
198660 -- 4955764
198661 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
198662 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
198663
198664 -- 4458381 Public Sector Enh
198665
198666 --
198667 -- set accounting attributes for the line type
198668 --
198669 l_entered_amt_idx := 3;
198670 l_accted_amt_idx := 8;
198671 l_bflow_applied_to_amt_idx := NULL; -- 5132302
198672 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
198673 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
198674 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
198675 l_rec_acct_attrs.array_char_value(2) := p_source_85;
198676 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
198677 l_rec_acct_attrs.array_num_value(3) := p_source_91;
198678 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
198679 l_rec_acct_attrs.array_char_value(4) := p_source_88;
198680 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
198681 l_rec_acct_attrs.array_date_value(5) := p_source_92;
198682 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
198683 l_rec_acct_attrs.array_num_value(6) := p_source_93;
198684 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
198685 l_rec_acct_attrs.array_char_value(7) := p_source_94;
198686 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
198687 l_rec_acct_attrs.array_num_value(8) := p_source_95;
198688
198689 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
198690 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
198691
198692 ---------------------------------------------------------------------------------------------------------------
198693 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
198694 ---------------------------------------------------------------------------------------------------------------
198695 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
198696
198697 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
198698 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
198699
198700 IF xla_accounting_cache_pkg.GetValueChar
198701 (p_source_code => 'LEDGER_CATEGORY_CODE'
198702 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
198703 AND l_bflow_method_code = 'PRIOR_ENTRY'
198704 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
198705 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
198706 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
198707 )
198708 THEN
198709 xla_ae_lines_pkg.BflowUpgEntry
198710 (p_business_method_code => l_bflow_method_code
198711 ,p_business_class_code => l_bflow_class_code
198712 ,p_balance_type => l_balance_type_code);
198713 ELSE
198714 NULL;
198715 -- No business flow processing for business flow method of NONE.
198716 END IF;
198717
198718 --
198719 -- call analytical criteria
198720 --
198721
198722 --
198723 -- call description
198724 --
198725
198726 xla_ae_lines_pkg.SetLineDescription(
198727 p_ae_header_id => l_ae_header_id
198728 ,p_description => Description_1 (
198729 p_application_id => p_application_id
198730 , p_ae_header_id => l_ae_header_id
198731 , p_source_1 => p_source_1
198732 , p_source_2 => p_source_2
198733 , p_source_3 => p_source_3
198734 , p_source_4 => p_source_4
198735 , p_source_5 => p_source_5
198736 )
198737 );
198738
198739
198740 --
198741 -- call ADRs
198742 -- Bug 4922099
198743 --
198744 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
198745 (NVL(l_actual_upg_option, 'N') = 'O') OR
198746 (NVL(l_enc_upg_option, 'N') = 'O')
198747 )
198748 THEN
198749 NULL;
198750 --
198751 --
198752
198753 l_ccid := AcctDerRule_6(
198754 p_application_id => p_application_id
198755 , p_ae_header_id => l_ae_header_id
198756 , p_source_11 => p_source_11
198757 , x_transaction_coa_id => l_adr_transaction_coa_id
198758 , x_accounting_coa_id => l_adr_accounting_coa_id
198759 , x_value_type_code => l_adr_value_type_code
198760 , p_side => 'NA'
198761 );
198762
198763 xla_ae_lines_pkg.set_ccid(
198764 p_code_combination_id => l_ccid
198765 , p_value_type_code => l_adr_value_type_code
198766 , p_transaction_coa_id => l_adr_transaction_coa_id
198767 , p_accounting_coa_id => l_adr_accounting_coa_id
198768 , p_adr_code => 'CST_DEFAULT'
198769 , p_adr_type_code => 'S'
198770 , p_component_type => l_component_type
198771 , p_component_code => l_component_code
198772 , p_component_type_code => l_component_type_code
198773 , p_component_appl_id => l_component_appl_id
198774 , p_amb_context_code => l_amb_context_code
198775 , p_side => 'NA'
198776 );
198777
198778
198779 --
198780 --
198781 END IF;
198782 --
198783 -- Bug 4922099
198784 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
198785 (NVL(l_enc_upg_option, 'N') = 'O')
198786 ) AND
198787 (l_bflow_method_code = 'PRIOR_ENTRY')
198788 )
198789 THEN
198790 IF
198791 --
198792 1 = 2
198793 --
198794 THEN
198795 xla_accounting_err_pkg.build_message
198796 (p_appli_s_name => 'XLA'
198797 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
198798 ,p_token_1 => 'LINE_NUMBER'
198799 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
198800 ,p_token_2 => 'LINE_TYPE_NAME'
198801 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
198802 l_component_type
198803 ,l_component_code
198804 ,l_component_type_code
198805 ,l_component_appl_id
198806 ,l_amb_context_code
198807 ,l_entity_code
198808 ,l_event_class_code
198809 )
198810 ,p_token_3 => 'OWNER'
198811 ,p_value_3 => xla_lookups_pkg.get_meaning(
198812 p_lookup_type => 'XLA_OWNER_TYPE'
198813 ,p_lookup_code => l_component_type_code
198814 )
198815 ,p_token_4 => 'PRODUCT_NAME'
198816 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
198817 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
198818 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
198819 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
198820 ,p_ae_header_id => NULL
198821 );
198822
198823 IF (C_LEVEL_ERROR>= g_log_level) THEN
198824 trace
198825 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
198826 ,p_level => C_LEVEL_ERROR
198827 ,p_module => l_log_module);
198828 END IF;
198829 END IF;
198830 END IF;
198831 --
198832 --
198833 ------------------------------------------------------------------------------------------------
198834 -- 4219869 Business Flow
198835 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
198836 -- Prior Entry. Currently, the following code is always generated.
198837 ------------------------------------------------------------------------------------------------
198838 XLA_AE_LINES_PKG.ValidateCurrentLine;
198839
198840 ------------------------------------------------------------------------------------
198841 -- 4219869 Business Flow
198842 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
198843 ------------------------------------------------------------------------------------
198844 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
198845
198846 ----------------------------------------------------------------------------------
198847 -- 4219869 Business Flow
198848 -- Update journal entry status -- Need to generate this within IF <condition>
198849 ----------------------------------------------------------------------------------
198850 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
198851 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
198852 ,p_balance_type_code => l_balance_type_code
198853 );
198854
198855 -------------------------------------------------------------------------------------------
198856 -- 4262811 - Generate the Accrual Reversal lines
198857 -------------------------------------------------------------------------------------------
198858 BEGIN
198859 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
198860 (g_array_event(p_event_id).array_value_num('header_index'));
198861 IF l_acc_rev_flag IS NULL THEN
198862 l_acc_rev_flag := 'N';
198863 END IF;
198864 EXCEPTION
198865 WHEN OTHERS THEN
198866 l_acc_rev_flag := 'N';
198867 END;
198868 --
198869 IF (l_acc_rev_flag = 'Y') THEN
198870
198871 -- 4645092 ------------------------------------------------------------------------------
198872 -- To allow MPA report to determine if it should generate report process
198873 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
198874 ------------------------------------------------------------------------------------------
198875
198876 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
198877 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
198878 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
198879 -- call ADRs
198880 -- Bug 4922099
198881 --
198882 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
198883 (NVL(l_actual_upg_option, 'N') = 'O') OR
198884 (NVL(l_enc_upg_option, 'N') = 'O')
198885 )
198886 THEN
198887 NULL;
198888 --
198889 --
198890
198891 l_ccid := AcctDerRule_6(
198892 p_application_id => p_application_id
198893 , p_ae_header_id => l_ae_header_id
198894 , p_source_11 => p_source_11
198895 , x_transaction_coa_id => l_adr_transaction_coa_id
198896 , x_accounting_coa_id => l_adr_accounting_coa_id
198897 , x_value_type_code => l_adr_value_type_code
198898 , p_side => 'NA'
198899 );
198900
198901 xla_ae_lines_pkg.set_ccid(
198902 p_code_combination_id => l_ccid
198903 , p_value_type_code => l_adr_value_type_code
198904 , p_transaction_coa_id => l_adr_transaction_coa_id
198905 , p_accounting_coa_id => l_adr_accounting_coa_id
198906 , p_adr_code => 'CST_DEFAULT'
198907 , p_adr_type_code => 'S'
198908 , p_component_type => l_component_type
198909 , p_component_code => l_component_code
198910 , p_component_type_code => l_component_type_code
198911 , p_component_appl_id => l_component_appl_id
198912 , p_amb_context_code => l_amb_context_code
198913 , p_side => 'NA'
198914 );
198915
198916
198917 --
198918 --
198919 END IF;
198920
198921 --
198922 -- Update the line information that should be overwritten
198923 --
198924 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
198925 p_header_num => 1);
198926 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
198927
198928 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
198929
198930 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
198931 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
198932 END IF;
198933
198934 --
198935 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
198936 --
198937 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
198938 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
198939 ELSE
198940 ---------------------------------------------------------------------------------------------------
198941 -- 4262811a Switch Sign
198942 ---------------------------------------------------------------------------------------------------
198943 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
198944 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
198945 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198946 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
198947 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198948 -- 5132302
198949 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
198950 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
198951
198952 END IF;
198953
198954 -- 4955764
198955 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
198956 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
198957
198958
198959 XLA_AE_LINES_PKG.ValidateCurrentLine;
198960 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
198961
198962 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
198963 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
198964 ,p_balance_type_code => l_balance_type_code);
198965
198966 END IF;
198967
198968 -----------------------------------------------------------------------------------------
198969 -- 4262811 Multiperiod Accounting
198970 -----------------------------------------------------------------------------------------
198971 -- No MPA option is assigned.
198972
198973
198974 END IF;
198975 END IF;
198976 --
198977
198978 --
198979 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
198980 trace
198981 (p_msg => 'END of AcctLineType_363'
198982 ,p_level => C_LEVEL_PROCEDURE
198983 ,p_module => l_log_module);
198984 END IF;
198985 --
198986 EXCEPTION
198987 WHEN xla_exceptions_pkg.application_exception THEN
198988 RAISE;
198989 WHEN OTHERS THEN
198990 xla_exceptions_pkg.raise_message
198991 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_363');
198992 END AcctLineType_363;
198993 --
198994
198995 ---------------------------------------
198996 --
198997 -- PRIVATE FUNCTION
198998 -- AcctLineType_364
198999 --
199000 ---------------------------------------
199001 PROCEDURE AcctLineType_364 (
199002 p_application_id IN NUMBER
199003 ,p_event_id IN NUMBER
199004 ,p_calculate_acctd_flag IN VARCHAR2
199005 ,p_calculate_g_l_flag IN VARCHAR2
199006 ,p_actual_flag IN OUT VARCHAR2
199007 ,p_balance_type_code OUT VARCHAR2
199008 ,p_gain_or_loss_ref OUT VARCHAR2
199009
199010 --TRANSACTION_ID
199011 , p_source_1 IN NUMBER
199012 --Item Concatenated Segments
199013 , p_source_2 IN VARCHAR2
199014 --Transaction Quantity
199015 , p_source_3 IN NUMBER
199016 --Transaction Unit of Measure Code
199017 , p_source_4 IN VARCHAR2
199018 --Inventory Transaction Type Description
199019 , p_source_5 IN VARCHAR2
199020 --Transaction Distribution Account
199021 , p_source_20 IN NUMBER
199022 --Transaction Action Name
199023 , p_source_62 IN NUMBER
199024 , p_source_62_meaning IN VARCHAR2
199025 --DISTRIBUTION_IDENTIFIER
199026 , p_source_84 IN NUMBER
199027 --Distribution Type
199028 , p_source_85 IN VARCHAR2
199029 , p_source_85_meaning IN VARCHAR2
199030 --Entered Currency Code
199031 , p_source_88 IN VARCHAR2
199032 --Entered Amount
199033 , p_source_91 IN NUMBER
199034 --Currency Conversion Date
199035 , p_source_92 IN DATE
199036 --Currency Conversion Rate
199037 , p_source_93 IN NUMBER
199038 --Currency Conversion Type
199039 , p_source_94 IN VARCHAR2
199040 --Accounted Amount
199041 , p_source_95 IN NUMBER
199042 --Accounting Line Type
199043 , p_source_97 IN NUMBER
199044 )
199045 IS
199046
199047 l_component_type VARCHAR2(80);
199048 l_component_code VARCHAR2(30);
199049 l_component_type_code VARCHAR2(1);
199050 l_component_appl_id INTEGER;
199051 l_amb_context_code VARCHAR2(30);
199052 l_entity_code VARCHAR2(30);
199053 l_event_class_code VARCHAR2(30);
199054 l_ae_header_id NUMBER;
199055 l_event_type_code VARCHAR2(30);
199056 l_line_definition_code VARCHAR2(30);
199057 l_line_definition_owner_code VARCHAR2(1);
199058 --
199059 -- adr variables
199060 l_segment VARCHAR2(30);
199061 l_ccid NUMBER;
199062 l_adr_transaction_coa_id NUMBER;
199063 l_adr_accounting_coa_id NUMBER;
199064 l_adr_flexfield_segment_code VARCHAR2(30);
199065 l_adr_flex_value_set_id NUMBER;
199066 l_adr_value_type_code VARCHAR2(30);
199067 l_adr_value_combination_id NUMBER;
199068 l_adr_value_segment_code VARCHAR2(30);
199069
199070 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
199071 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
199072 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
199073 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
199074
199075 -- 4262811 Variables ------------------------------------------------------------------------------------------
199076 l_entered_amt_idx NUMBER;
199077 l_accted_amt_idx NUMBER;
199078 l_acc_rev_flag VARCHAR2(1);
199079 l_accrual_line_num NUMBER;
199080 l_tmp_amt NUMBER;
199081 l_acc_rev_natural_side_code VARCHAR2(1);
199082
199083 l_num_entries NUMBER;
199084 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
199085 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
199086 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
199087 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
199088 l_recog_line_1 NUMBER;
199089 l_recog_line_2 NUMBER;
199090
199091 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
199092 l_bflow_applied_to_amt NUMBER; -- 5132302
199093 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
199094
199095 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
199096
199097 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
199098 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
199099
199100 ---------------------------------------------------------------------------------------------------------------
199101
199102
199103 --
199104 -- bulk performance
199105 --
199106 l_balance_type_code VARCHAR2(1);
199107 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
199108 l_log_module VARCHAR2(240);
199109
199110 --
199111 -- Upgrade strategy
199112 --
199113 l_actual_upg_option VARCHAR2(1);
199114 l_enc_upg_option VARCHAR2(1);
199115
199116 --
199117 BEGIN
199118 --
199119 IF g_log_enabled THEN
199120 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_364';
199121 END IF;
199122 --
199123 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
199124
199125 trace
199126 (p_msg => 'BEGIN of AcctLineType_364'
199127 ,p_level => C_LEVEL_PROCEDURE
199128 ,p_module => l_log_module);
199129
199130 END IF;
199131 --
199132 l_component_type := 'AMB_JLT';
199133 l_component_code := 'OFFSET';
199134 l_component_type_code := 'S';
199135 l_component_appl_id := 707;
199136 l_amb_context_code := 'DEFAULT';
199137 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
199138 l_event_class_code := 'LOG_INTERCOMPANY';
199139 l_event_type_code := 'LOG_IC_SHIPMENT_RCPT';
199140 l_line_definition_owner_code := 'S';
199141 l_line_definition_code := 'PI_LOG_IC_SHIPMENT_RCPT';
199142 --
199143 l_balance_type_code := 'A';
199144 l_segment := NULL;
199145 l_ccid := NULL;
199146 l_adr_transaction_coa_id := NULL;
199147 l_adr_accounting_coa_id := NULL;
199148 l_adr_flexfield_segment_code := NULL;
199149 l_adr_flex_value_set_id := NULL;
199150 l_adr_value_type_code := NULL;
199151 l_adr_value_combination_id := NULL;
199152 l_adr_value_segment_code := NULL;
199153
199154 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
199155 l_bflow_class_code := ''; -- 4219869 Business Flow
199156 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
199157 l_budgetary_control_flag := 'N';
199158
199159 l_bflow_applied_to_amt_idx := NULL; -- 5132302
199160 l_bflow_applied_to_amt := NULL; -- 5132302
199161 l_entered_amt_idx := NULL; -- 4262811
199162 l_accted_amt_idx := NULL; -- 4262811
199163 l_acc_rev_flag := NULL; -- 4262811
199164 l_accrual_line_num := NULL; -- 4262811
199165 l_tmp_amt := NULL; -- 4262811
199166 --
199167
199168 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
199169 l_balance_type_code <> 'B' THEN
199170 IF NVL(p_source_97,9E125) = 2 AND
199171 ((p_source_95 <= 0 AND
199172 NVL(p_source_62,9E125) = 13) OR
199173 (p_source_95 <= 0 AND
199174 NVL(p_source_62,9E125) = 9) OR
199175 (p_source_95 >= 0 AND
199176 NVL(p_source_62,9E125) = 10) OR
199177 NVL(p_source_62,9E125) = 10 OR
199178 NVL(p_source_62,9E125) = 13)
199179 THEN
199180
199181 --
199182 XLA_AE_LINES_PKG.SetNewLine;
199183
199184 p_balance_type_code := l_balance_type_code;
199185 -- set the flag so later we will know whether the gain loss line needs to be created
199186
199187 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
199188 p_actual_flag :='A';
199189 END IF;
199190
199191 --
199192 -- bulk performance
199193 --
199194 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
199195 p_header_num => 0); -- 4262811
199196 --
199197 -- set accounting line options
199198 --
199199 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
199200 p_natural_side_code => 'D'
199201 , p_gain_or_loss_flag => 'N'
199202 , p_gl_transfer_mode_code => 'S'
199203 , p_acct_entry_type_code => 'A'
199204 , p_switch_side_flag => 'Y'
199205 , p_merge_duplicate_code => 'N'
199206 );
199207 --
199208 l_acc_rev_natural_side_code := 'C'; -- 4262811
199209 --
199210 --
199211 -- set accounting line type info
199212 --
199213 xla_ae_lines_pkg.SetAcctLineType
199214 (p_component_type => l_component_type
199215 ,p_event_type_code => l_event_type_code
199216 ,p_line_definition_owner_code => l_line_definition_owner_code
199217 ,p_line_definition_code => l_line_definition_code
199218 ,p_accounting_line_code => l_component_code
199219 ,p_accounting_line_type_code => l_component_type_code
199220 ,p_accounting_line_appl_id => l_component_appl_id
199221 ,p_amb_context_code => l_amb_context_code
199222 ,p_entity_code => l_entity_code
199223 ,p_event_class_code => l_event_class_code);
199224 --
199225 -- set accounting class
199226 --
199227 xla_ae_lines_pkg.SetAcctClass(
199228 p_accounting_class_code => 'OFFSET'
199229 , p_ae_header_id => l_ae_header_id
199230 );
199231
199232 --
199233 -- set rounding class
199234 --
199235 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
199236 'OFFSET';
199237
199238 --
199239 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
199240 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
199241 --
199242 -- bulk performance
199243 --
199244 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
199245
199246 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
199247 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
199248
199249 -- 4955764
199250 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
199251 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
199252
199253 -- 4458381 Public Sector Enh
199254
199255 --
199256 -- set accounting attributes for the line type
199257 --
199258 l_entered_amt_idx := 3;
199259 l_accted_amt_idx := 8;
199260 l_bflow_applied_to_amt_idx := NULL; -- 5132302
199261 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
199262 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
199263 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
199264 l_rec_acct_attrs.array_char_value(2) := p_source_85;
199265 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
199266 l_rec_acct_attrs.array_num_value(3) := p_source_91;
199267 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
199268 l_rec_acct_attrs.array_char_value(4) := p_source_88;
199269 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
199270 l_rec_acct_attrs.array_date_value(5) := p_source_92;
199271 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
199272 l_rec_acct_attrs.array_num_value(6) := p_source_93;
199273 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
199274 l_rec_acct_attrs.array_char_value(7) := p_source_94;
199275 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
199276 l_rec_acct_attrs.array_num_value(8) := p_source_95;
199277
199278 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
199279 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
199280
199281 ---------------------------------------------------------------------------------------------------------------
199282 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
199283 ---------------------------------------------------------------------------------------------------------------
199284 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
199285
199286 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
199287 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
199288
199289 IF xla_accounting_cache_pkg.GetValueChar
199290 (p_source_code => 'LEDGER_CATEGORY_CODE'
199291 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
199292 AND l_bflow_method_code = 'PRIOR_ENTRY'
199293 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
199294 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
199295 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
199296 )
199297 THEN
199298 xla_ae_lines_pkg.BflowUpgEntry
199299 (p_business_method_code => l_bflow_method_code
199300 ,p_business_class_code => l_bflow_class_code
199301 ,p_balance_type => l_balance_type_code);
199302 ELSE
199303 NULL;
199304 -- No business flow processing for business flow method of NONE.
199305 END IF;
199306
199307 --
199308 -- call analytical criteria
199309 --
199310
199311 --
199312 -- call description
199313 --
199314
199315 xla_ae_lines_pkg.SetLineDescription(
199316 p_ae_header_id => l_ae_header_id
199317 ,p_description => Description_1 (
199318 p_application_id => p_application_id
199319 , p_ae_header_id => l_ae_header_id
199320 , p_source_1 => p_source_1
199321 , p_source_2 => p_source_2
199322 , p_source_3 => p_source_3
199323 , p_source_4 => p_source_4
199324 , p_source_5 => p_source_5
199325 )
199326 );
199327
199328
199329 --
199330 -- call ADRs
199331 -- Bug 4922099
199332 --
199333 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
199334 (NVL(l_actual_upg_option, 'N') = 'O') OR
199335 (NVL(l_enc_upg_option, 'N') = 'O')
199336 )
199337 THEN
199338 NULL;
199339 --
199340 --
199341
199342 l_ccid := AcctDerRule_16(
199343 p_application_id => p_application_id
199344 , p_ae_header_id => l_ae_header_id
199345 , p_source_20 => p_source_20
199346 , x_transaction_coa_id => l_adr_transaction_coa_id
199347 , x_accounting_coa_id => l_adr_accounting_coa_id
199348 , x_value_type_code => l_adr_value_type_code
199349 , p_side => 'NA'
199350 );
199351
199352 xla_ae_lines_pkg.set_ccid(
199353 p_code_combination_id => l_ccid
199354 , p_value_type_code => l_adr_value_type_code
199355 , p_transaction_coa_id => l_adr_transaction_coa_id
199356 , p_accounting_coa_id => l_adr_accounting_coa_id
199357 , p_adr_code => 'PI_DISTRIBUTION'
199358 , p_adr_type_code => 'S'
199359 , p_component_type => l_component_type
199360 , p_component_code => l_component_code
199361 , p_component_type_code => l_component_type_code
199362 , p_component_appl_id => l_component_appl_id
199363 , p_amb_context_code => l_amb_context_code
199364 , p_side => 'NA'
199365 );
199366
199367
199368 --
199369 --
199370 END IF;
199371 --
199372 -- Bug 4922099
199373 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
199374 (NVL(l_enc_upg_option, 'N') = 'O')
199375 ) AND
199376 (l_bflow_method_code = 'PRIOR_ENTRY')
199377 )
199378 THEN
199379 IF
199380 --
199381 1 = 2
199382 --
199383 THEN
199384 xla_accounting_err_pkg.build_message
199385 (p_appli_s_name => 'XLA'
199386 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
199387 ,p_token_1 => 'LINE_NUMBER'
199388 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
199389 ,p_token_2 => 'LINE_TYPE_NAME'
199390 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
199391 l_component_type
199392 ,l_component_code
199393 ,l_component_type_code
199394 ,l_component_appl_id
199395 ,l_amb_context_code
199396 ,l_entity_code
199397 ,l_event_class_code
199398 )
199399 ,p_token_3 => 'OWNER'
199400 ,p_value_3 => xla_lookups_pkg.get_meaning(
199401 p_lookup_type => 'XLA_OWNER_TYPE'
199402 ,p_lookup_code => l_component_type_code
199403 )
199404 ,p_token_4 => 'PRODUCT_NAME'
199405 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
199406 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
199407 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
199408 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
199409 ,p_ae_header_id => NULL
199410 );
199411
199412 IF (C_LEVEL_ERROR>= g_log_level) THEN
199413 trace
199414 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
199415 ,p_level => C_LEVEL_ERROR
199416 ,p_module => l_log_module);
199417 END IF;
199418 END IF;
199419 END IF;
199420 --
199421 --
199422 ------------------------------------------------------------------------------------------------
199423 -- 4219869 Business Flow
199424 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
199425 -- Prior Entry. Currently, the following code is always generated.
199426 ------------------------------------------------------------------------------------------------
199427 XLA_AE_LINES_PKG.ValidateCurrentLine;
199428
199429 ------------------------------------------------------------------------------------
199430 -- 4219869 Business Flow
199431 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
199432 ------------------------------------------------------------------------------------
199433 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
199434
199435 ----------------------------------------------------------------------------------
199436 -- 4219869 Business Flow
199437 -- Update journal entry status -- Need to generate this within IF <condition>
199438 ----------------------------------------------------------------------------------
199439 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
199440 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
199441 ,p_balance_type_code => l_balance_type_code
199442 );
199443
199444 -------------------------------------------------------------------------------------------
199445 -- 4262811 - Generate the Accrual Reversal lines
199446 -------------------------------------------------------------------------------------------
199447 BEGIN
199448 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
199449 (g_array_event(p_event_id).array_value_num('header_index'));
199450 IF l_acc_rev_flag IS NULL THEN
199451 l_acc_rev_flag := 'N';
199452 END IF;
199453 EXCEPTION
199454 WHEN OTHERS THEN
199455 l_acc_rev_flag := 'N';
199456 END;
199457 --
199458 IF (l_acc_rev_flag = 'Y') THEN
199459
199460 -- 4645092 ------------------------------------------------------------------------------
199461 -- To allow MPA report to determine if it should generate report process
199462 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
199463 ------------------------------------------------------------------------------------------
199464
199465 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
199466 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
199467 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
199468 -- call ADRs
199469 -- Bug 4922099
199470 --
199471 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
199472 (NVL(l_actual_upg_option, 'N') = 'O') OR
199473 (NVL(l_enc_upg_option, 'N') = 'O')
199474 )
199475 THEN
199476 NULL;
199477 --
199478 --
199479
199480 l_ccid := AcctDerRule_16(
199481 p_application_id => p_application_id
199482 , p_ae_header_id => l_ae_header_id
199483 , p_source_20 => p_source_20
199484 , x_transaction_coa_id => l_adr_transaction_coa_id
199485 , x_accounting_coa_id => l_adr_accounting_coa_id
199486 , x_value_type_code => l_adr_value_type_code
199487 , p_side => 'NA'
199488 );
199489
199490 xla_ae_lines_pkg.set_ccid(
199491 p_code_combination_id => l_ccid
199492 , p_value_type_code => l_adr_value_type_code
199493 , p_transaction_coa_id => l_adr_transaction_coa_id
199494 , p_accounting_coa_id => l_adr_accounting_coa_id
199495 , p_adr_code => 'PI_DISTRIBUTION'
199496 , p_adr_type_code => 'S'
199497 , p_component_type => l_component_type
199498 , p_component_code => l_component_code
199499 , p_component_type_code => l_component_type_code
199500 , p_component_appl_id => l_component_appl_id
199501 , p_amb_context_code => l_amb_context_code
199502 , p_side => 'NA'
199503 );
199504
199505
199506 --
199507 --
199508 END IF;
199509
199510 --
199511 -- Update the line information that should be overwritten
199512 --
199513 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
199514 p_header_num => 1);
199515 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
199516
199517 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
199518
199519 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
199520 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
199521 END IF;
199522
199523 --
199524 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
199525 --
199526 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
199527 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
199528 ELSE
199529 ---------------------------------------------------------------------------------------------------
199530 -- 4262811a Switch Sign
199531 ---------------------------------------------------------------------------------------------------
199532 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
199533 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
199534 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
199535 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
199536 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
199537 -- 5132302
199538 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
199539 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
199540
199541 END IF;
199542
199543 -- 4955764
199544 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
199545 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
199546
199547
199548 XLA_AE_LINES_PKG.ValidateCurrentLine;
199549 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
199550
199551 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
199552 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
199553 ,p_balance_type_code => l_balance_type_code);
199554
199555 END IF;
199556
199557 -----------------------------------------------------------------------------------------
199558 -- 4262811 Multiperiod Accounting
199559 -----------------------------------------------------------------------------------------
199560 -- No MPA option is assigned.
199561
199562
199563 END IF;
199564 END IF;
199565 --
199566
199567 --
199568 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
199569 trace
199570 (p_msg => 'END of AcctLineType_364'
199571 ,p_level => C_LEVEL_PROCEDURE
199572 ,p_module => l_log_module);
199573 END IF;
199574 --
199575 EXCEPTION
199576 WHEN xla_exceptions_pkg.application_exception THEN
199577 RAISE;
199578 WHEN OTHERS THEN
199579 xla_exceptions_pkg.raise_message
199580 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_364');
199581 END AcctLineType_364;
199582 --
199583
199584 ---------------------------------------
199585 --
199586 -- PRIVATE FUNCTION
199587 -- AcctLineType_365
199588 --
199589 ---------------------------------------
199590 PROCEDURE AcctLineType_365 (
199591 p_application_id IN NUMBER
199592 ,p_event_id IN NUMBER
199593 ,p_calculate_acctd_flag IN VARCHAR2
199594 ,p_calculate_g_l_flag IN VARCHAR2
199595 ,p_actual_flag IN OUT VARCHAR2
199596 ,p_balance_type_code OUT VARCHAR2
199597 ,p_gain_or_loss_ref OUT VARCHAR2
199598
199599 --TRANSACTION_ID
199600 , p_source_1 IN NUMBER
199601 --Item Concatenated Segments
199602 , p_source_2 IN VARCHAR2
199603 --Transaction Quantity
199604 , p_source_3 IN NUMBER
199605 --Transaction Unit of Measure Code
199606 , p_source_4 IN VARCHAR2
199607 --Inventory Transaction Type Description
199608 , p_source_5 IN VARCHAR2
199609 --Cost Management Default Account
199610 , p_source_11 IN NUMBER
199611 --Applied to Application ID
199612 , p_source_79 IN NUMBER
199613 --Applied to Distribution Link Type
199614 , p_source_80 IN VARCHAR2
199615 --Applied to Entity Code
199616 , p_source_81 IN VARCHAR2
199617 --Applied To Purchase Document Identifier
199618 , p_source_83 IN NUMBER
199619 --DISTRIBUTION_IDENTIFIER
199620 , p_source_84 IN NUMBER
199621 --Distribution Type
199622 , p_source_85 IN VARCHAR2
199623 , p_source_85_meaning IN VARCHAR2
199624 --PO Budget Account
199625 , p_source_86 IN NUMBER
199626 --Encumbrance Reversal Amount Entered
199627 , p_source_87 IN NUMBER
199628 --Entered Currency Code
199629 , p_source_88 IN VARCHAR2
199630 --Transaction Encumbrance Reversal Amount
199631 , p_source_89 IN NUMBER
199632 --Entered Amount
199633 , p_source_91 IN NUMBER
199634 --Currency Conversion Date
199635 , p_source_92 IN DATE
199636 --Currency Conversion Rate
199637 , p_source_93 IN NUMBER
199638 --Currency Conversion Type
199639 , p_source_94 IN VARCHAR2
199640 --Accounted Amount
199641 , p_source_95 IN NUMBER
199642 --Purchasing Encumbrance Type Identifier
199643 , p_source_96 IN NUMBER
199644 --Accounting Line Type
199645 , p_source_97 IN NUMBER
199646 --Costing Encumbrance Upgrade Option
199647 , p_source_100 IN VARCHAR2
199648 --TXN_PO_DISTRIBUTION_ID
199649 , p_source_101 IN NUMBER
199650 )
199651 IS
199652
199653 l_component_type VARCHAR2(80);
199654 l_component_code VARCHAR2(30);
199655 l_component_type_code VARCHAR2(1);
199656 l_component_appl_id INTEGER;
199657 l_amb_context_code VARCHAR2(30);
199658 l_entity_code VARCHAR2(30);
199659 l_event_class_code VARCHAR2(30);
199660 l_ae_header_id NUMBER;
199661 l_event_type_code VARCHAR2(30);
199662 l_line_definition_code VARCHAR2(30);
199663 l_line_definition_owner_code VARCHAR2(1);
199664 --
199665 -- adr variables
199666 l_segment VARCHAR2(30);
199667 l_ccid NUMBER;
199668 l_adr_transaction_coa_id NUMBER;
199669 l_adr_accounting_coa_id NUMBER;
199670 l_adr_flexfield_segment_code VARCHAR2(30);
199671 l_adr_flex_value_set_id NUMBER;
199672 l_adr_value_type_code VARCHAR2(30);
199673 l_adr_value_combination_id NUMBER;
199674 l_adr_value_segment_code VARCHAR2(30);
199675
199676 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
199677 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
199678 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
199679 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
199680
199681 -- 4262811 Variables ------------------------------------------------------------------------------------------
199682 l_entered_amt_idx NUMBER;
199683 l_accted_amt_idx NUMBER;
199684 l_acc_rev_flag VARCHAR2(1);
199685 l_accrual_line_num NUMBER;
199686 l_tmp_amt NUMBER;
199687 l_acc_rev_natural_side_code VARCHAR2(1);
199688
199689 l_num_entries NUMBER;
199690 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
199691 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
199692 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
199693 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
199694 l_recog_line_1 NUMBER;
199695 l_recog_line_2 NUMBER;
199696
199697 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
199698 l_bflow_applied_to_amt NUMBER; -- 5132302
199699 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
199700
199701 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
199702
199703 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
199704 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
199705
199706 ---------------------------------------------------------------------------------------------------------------
199707
199708
199709 --
199710 -- bulk performance
199711 --
199712 l_balance_type_code VARCHAR2(1);
199713 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
199714 l_log_module VARCHAR2(240);
199715
199716 --
199717 -- Upgrade strategy
199718 --
199719 l_actual_upg_option VARCHAR2(1);
199720 l_enc_upg_option VARCHAR2(1);
199721
199722 --
199723 BEGIN
199724 --
199725 IF g_log_enabled THEN
199726 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_365';
199727 END IF;
199728 --
199729 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
199730
199731 trace
199732 (p_msg => 'BEGIN of AcctLineType_365'
199733 ,p_level => C_LEVEL_PROCEDURE
199734 ,p_module => l_log_module);
199735
199736 END IF;
199737 --
199738 l_component_type := 'AMB_JLT';
199739 l_component_code := 'OFFSET';
199740 l_component_type_code := 'S';
199741 l_component_appl_id := 707;
199742 l_amb_context_code := 'DEFAULT';
199743 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
199744 l_event_class_code := 'PURCHASE_ORDER';
199745 l_event_type_code := 'RET_RI_INV';
199746 l_line_definition_owner_code := 'S';
199747 l_line_definition_code := 'PI_RET_RI_INV';
199748 --
199749 l_balance_type_code := 'A';
199750 l_segment := NULL;
199751 l_ccid := NULL;
199752 l_adr_transaction_coa_id := NULL;
199753 l_adr_accounting_coa_id := NULL;
199754 l_adr_flexfield_segment_code := NULL;
199755 l_adr_flex_value_set_id := NULL;
199756 l_adr_value_type_code := NULL;
199757 l_adr_value_combination_id := NULL;
199758 l_adr_value_segment_code := NULL;
199759
199760 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
199761 l_bflow_class_code := ''; -- 4219869 Business Flow
199762 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
199763 l_budgetary_control_flag := 'N';
199764
199765 l_bflow_applied_to_amt_idx := NULL; -- 5132302
199766 l_bflow_applied_to_amt := NULL; -- 5132302
199767 l_entered_amt_idx := NULL; -- 4262811
199768 l_accted_amt_idx := NULL; -- 4262811
199769 l_acc_rev_flag := NULL; -- 4262811
199770 l_accrual_line_num := NULL; -- 4262811
199771 l_tmp_amt := NULL; -- 4262811
199772 --
199773
199774 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
199775 l_balance_type_code <> 'B' THEN
199776 IF NVL(p_source_97,9E125) = 2
199777 THEN
199778
199779 --
199780 XLA_AE_LINES_PKG.SetNewLine;
199781
199782 p_balance_type_code := l_balance_type_code;
199783 -- set the flag so later we will know whether the gain loss line needs to be created
199784
199785 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
199786 p_actual_flag :='A';
199787 END IF;
199788
199789 --
199790 -- bulk performance
199791 --
199792 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
199793 p_header_num => 0); -- 4262811
199794 --
199795 -- set accounting line options
199796 --
199797 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
199798 p_natural_side_code => 'D'
199799 , p_gain_or_loss_flag => 'N'
199800 , p_gl_transfer_mode_code => 'S'
199801 , p_acct_entry_type_code => 'A'
199802 , p_switch_side_flag => 'Y'
199803 , p_merge_duplicate_code => 'N'
199804 );
199805 --
199806 l_acc_rev_natural_side_code := 'C'; -- 4262811
199807 --
199808 --
199809 -- set accounting line type info
199810 --
199811 xla_ae_lines_pkg.SetAcctLineType
199812 (p_component_type => l_component_type
199813 ,p_event_type_code => l_event_type_code
199814 ,p_line_definition_owner_code => l_line_definition_owner_code
199815 ,p_line_definition_code => l_line_definition_code
199816 ,p_accounting_line_code => l_component_code
199817 ,p_accounting_line_type_code => l_component_type_code
199818 ,p_accounting_line_appl_id => l_component_appl_id
199819 ,p_amb_context_code => l_amb_context_code
199820 ,p_entity_code => l_entity_code
199821 ,p_event_class_code => l_event_class_code);
199822 --
199823 -- set accounting class
199824 --
199825 xla_ae_lines_pkg.SetAcctClass(
199826 p_accounting_class_code => 'OFFSET'
199827 , p_ae_header_id => l_ae_header_id
199828 );
199829
199830 --
199831 -- set rounding class
199832 --
199833 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
199834 'OFFSET';
199835
199836 --
199837 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
199838 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
199839 --
199840 -- bulk performance
199841 --
199842 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
199843
199844 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
199845 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
199846
199847 -- 4955764
199848 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
199849 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
199850
199851 -- 4458381 Public Sector Enh
199852
199853 --
199854 -- set accounting attributes for the line type
199855 --
199856 l_entered_amt_idx := 17;
199857 l_accted_amt_idx := 22;
199858 l_bflow_applied_to_amt_idx := NULL; -- 5132302
199859 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
199860 l_rec_acct_attrs.array_num_value(1) := p_source_79;
199861 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
199862 l_rec_acct_attrs.array_char_value(2) := p_source_80;
199863 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
199864 l_rec_acct_attrs.array_char_value(3) := p_source_81;
199865 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
199866 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
199867 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
199868 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
199869 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
199870 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
199871 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
199872 l_rec_acct_attrs.array_char_value(7) := p_source_85;
199873 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
199874 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
199875 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
199876 l_rec_acct_attrs.array_num_value(9) := p_source_87;
199877 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
199878 l_rec_acct_attrs.array_char_value(10) := p_source_88;
199879 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
199880 l_rec_acct_attrs.array_num_value(11) := p_source_89;
199881 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
199882 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
199883 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
199884 l_rec_acct_attrs.array_num_value(13) := p_source_87;
199885 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
199886 l_rec_acct_attrs.array_char_value(14) := p_source_88;
199887 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
199888 l_rec_acct_attrs.array_num_value(15) := p_source_89;
199889 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
199890 l_rec_acct_attrs.array_char_value(16) := p_source_100;
199891 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
199892 l_rec_acct_attrs.array_num_value(17) := p_source_91;
199893 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
199894 l_rec_acct_attrs.array_char_value(18) := p_source_88;
199895 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
199896 l_rec_acct_attrs.array_date_value(19) := p_source_92;
199897 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
199898 l_rec_acct_attrs.array_num_value(20) := p_source_93;
199899 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
199900 l_rec_acct_attrs.array_char_value(21) := p_source_94;
199901 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
199902 l_rec_acct_attrs.array_num_value(22) := p_source_95;
199903 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
199904 l_rec_acct_attrs.array_num_value(23) := p_source_96;
199905 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
199906 l_rec_acct_attrs.array_num_value(24) := p_source_96;
199907
199908 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
199909 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
199910
199911 ---------------------------------------------------------------------------------------------------------------
199912 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
199913 ---------------------------------------------------------------------------------------------------------------
199914 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
199915
199916 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
199917 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
199918
199919 IF xla_accounting_cache_pkg.GetValueChar
199920 (p_source_code => 'LEDGER_CATEGORY_CODE'
199921 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
199922 AND l_bflow_method_code = 'PRIOR_ENTRY'
199923 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
199924 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
199925 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
199926 )
199927 THEN
199928 xla_ae_lines_pkg.BflowUpgEntry
199929 (p_business_method_code => l_bflow_method_code
199930 ,p_business_class_code => l_bflow_class_code
199931 ,p_balance_type => l_balance_type_code);
199932 ELSE
199933 NULL;
199934 -- No business flow processing for business flow method of NONE.
199935 END IF;
199936
199937 --
199938 -- call analytical criteria
199939 --
199940
199941 --
199942 -- call description
199943 --
199944
199945 xla_ae_lines_pkg.SetLineDescription(
199946 p_ae_header_id => l_ae_header_id
199947 ,p_description => Description_1 (
199948 p_application_id => p_application_id
199949 , p_ae_header_id => l_ae_header_id
199950 , p_source_1 => p_source_1
199951 , p_source_2 => p_source_2
199952 , p_source_3 => p_source_3
199953 , p_source_4 => p_source_4
199954 , p_source_5 => p_source_5
199955 )
199956 );
199957
199958
199959 --
199960 -- call ADRs
199961 -- Bug 4922099
199962 --
199963 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
199964 (NVL(l_actual_upg_option, 'N') = 'O') OR
199965 (NVL(l_enc_upg_option, 'N') = 'O')
199966 )
199967 THEN
199968 NULL;
199969 --
199970 --
199971
199972 l_ccid := AcctDerRule_6(
199973 p_application_id => p_application_id
199974 , p_ae_header_id => l_ae_header_id
199975 , p_source_11 => p_source_11
199976 , x_transaction_coa_id => l_adr_transaction_coa_id
199977 , x_accounting_coa_id => l_adr_accounting_coa_id
199978 , x_value_type_code => l_adr_value_type_code
199979 , p_side => 'NA'
199980 );
199981
199982 xla_ae_lines_pkg.set_ccid(
199983 p_code_combination_id => l_ccid
199984 , p_value_type_code => l_adr_value_type_code
199985 , p_transaction_coa_id => l_adr_transaction_coa_id
199986 , p_accounting_coa_id => l_adr_accounting_coa_id
199987 , p_adr_code => 'CST_DEFAULT'
199988 , p_adr_type_code => 'S'
199989 , p_component_type => l_component_type
199990 , p_component_code => l_component_code
199991 , p_component_type_code => l_component_type_code
199992 , p_component_appl_id => l_component_appl_id
199993 , p_amb_context_code => l_amb_context_code
199994 , p_side => 'NA'
199995 );
199996
199997
199998 --
199999 --
200000 END IF;
200001 --
200002 -- Bug 4922099
200003 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
200004 (NVL(l_enc_upg_option, 'N') = 'O')
200005 ) AND
200006 (l_bflow_method_code = 'PRIOR_ENTRY')
200007 )
200008 THEN
200009 IF
200010 --
200011 1 = 2
200012 --
200013 THEN
200014 xla_accounting_err_pkg.build_message
200015 (p_appli_s_name => 'XLA'
200016 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
200017 ,p_token_1 => 'LINE_NUMBER'
200018 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
200019 ,p_token_2 => 'LINE_TYPE_NAME'
200020 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
200021 l_component_type
200022 ,l_component_code
200023 ,l_component_type_code
200024 ,l_component_appl_id
200025 ,l_amb_context_code
200026 ,l_entity_code
200027 ,l_event_class_code
200028 )
200029 ,p_token_3 => 'OWNER'
200030 ,p_value_3 => xla_lookups_pkg.get_meaning(
200031 p_lookup_type => 'XLA_OWNER_TYPE'
200032 ,p_lookup_code => l_component_type_code
200033 )
200034 ,p_token_4 => 'PRODUCT_NAME'
200035 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
200036 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
200037 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
200038 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
200039 ,p_ae_header_id => NULL
200040 );
200041
200042 IF (C_LEVEL_ERROR>= g_log_level) THEN
200043 trace
200044 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
200045 ,p_level => C_LEVEL_ERROR
200046 ,p_module => l_log_module);
200047 END IF;
200048 END IF;
200049 END IF;
200050 --
200051 --
200052 ------------------------------------------------------------------------------------------------
200053 -- 4219869 Business Flow
200054 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
200055 -- Prior Entry. Currently, the following code is always generated.
200056 ------------------------------------------------------------------------------------------------
200057 XLA_AE_LINES_PKG.ValidateCurrentLine;
200058
200059 ------------------------------------------------------------------------------------
200060 -- 4219869 Business Flow
200061 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
200062 ------------------------------------------------------------------------------------
200063 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
200064
200065 ----------------------------------------------------------------------------------
200066 -- 4219869 Business Flow
200067 -- Update journal entry status -- Need to generate this within IF <condition>
200068 ----------------------------------------------------------------------------------
200069 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
200070 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
200071 ,p_balance_type_code => l_balance_type_code
200072 );
200073
200074 -------------------------------------------------------------------------------------------
200075 -- 4262811 - Generate the Accrual Reversal lines
200076 -------------------------------------------------------------------------------------------
200077 BEGIN
200078 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
200079 (g_array_event(p_event_id).array_value_num('header_index'));
200080 IF l_acc_rev_flag IS NULL THEN
200081 l_acc_rev_flag := 'N';
200082 END IF;
200083 EXCEPTION
200084 WHEN OTHERS THEN
200085 l_acc_rev_flag := 'N';
200086 END;
200087 --
200088 IF (l_acc_rev_flag = 'Y') THEN
200089
200090 -- 4645092 ------------------------------------------------------------------------------
200091 -- To allow MPA report to determine if it should generate report process
200092 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
200093 ------------------------------------------------------------------------------------------
200094
200095 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
200096 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
200097 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
200098 -- call ADRs
200099 -- Bug 4922099
200100 --
200101 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
200102 (NVL(l_actual_upg_option, 'N') = 'O') OR
200103 (NVL(l_enc_upg_option, 'N') = 'O')
200104 )
200105 THEN
200106 NULL;
200107 --
200108 --
200109
200110 l_ccid := AcctDerRule_6(
200111 p_application_id => p_application_id
200112 , p_ae_header_id => l_ae_header_id
200113 , p_source_11 => p_source_11
200114 , x_transaction_coa_id => l_adr_transaction_coa_id
200115 , x_accounting_coa_id => l_adr_accounting_coa_id
200116 , x_value_type_code => l_adr_value_type_code
200117 , p_side => 'NA'
200118 );
200119
200120 xla_ae_lines_pkg.set_ccid(
200121 p_code_combination_id => l_ccid
200122 , p_value_type_code => l_adr_value_type_code
200123 , p_transaction_coa_id => l_adr_transaction_coa_id
200124 , p_accounting_coa_id => l_adr_accounting_coa_id
200125 , p_adr_code => 'CST_DEFAULT'
200126 , p_adr_type_code => 'S'
200127 , p_component_type => l_component_type
200128 , p_component_code => l_component_code
200129 , p_component_type_code => l_component_type_code
200130 , p_component_appl_id => l_component_appl_id
200131 , p_amb_context_code => l_amb_context_code
200132 , p_side => 'NA'
200133 );
200134
200135
200136 --
200137 --
200138 END IF;
200139
200140 --
200141 -- Update the line information that should be overwritten
200142 --
200143 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
200144 p_header_num => 1);
200145 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
200146
200147 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
200148
200149 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
200150 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
200151 END IF;
200152
200153 --
200154 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
200155 --
200156 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
200157 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
200158 ELSE
200159 ---------------------------------------------------------------------------------------------------
200160 -- 4262811a Switch Sign
200161 ---------------------------------------------------------------------------------------------------
200162 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
200163 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
200164 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200165 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
200166 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200167 -- 5132302
200168 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
200169 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200170
200171 END IF;
200172
200173 -- 4955764
200174 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
200175 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
200176
200177
200178 XLA_AE_LINES_PKG.ValidateCurrentLine;
200179 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
200180
200181 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
200182 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
200183 ,p_balance_type_code => l_balance_type_code);
200184
200185 END IF;
200186
200187 -----------------------------------------------------------------------------------------
200188 -- 4262811 Multiperiod Accounting
200189 -----------------------------------------------------------------------------------------
200190 -- No MPA option is assigned.
200191
200192
200193 END IF;
200194 END IF;
200195 --
200196
200197 --
200198 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
200199 trace
200200 (p_msg => 'END of AcctLineType_365'
200201 ,p_level => C_LEVEL_PROCEDURE
200202 ,p_module => l_log_module);
200203 END IF;
200204 --
200205 EXCEPTION
200206 WHEN xla_exceptions_pkg.application_exception THEN
200207 RAISE;
200208 WHEN OTHERS THEN
200209 xla_exceptions_pkg.raise_message
200210 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_365');
200211 END AcctLineType_365;
200212 --
200213
200214 ---------------------------------------
200215 --
200216 -- PRIVATE FUNCTION
200217 -- AcctLineType_366
200218 --
200219 ---------------------------------------
200220 PROCEDURE AcctLineType_366 (
200221 p_application_id IN NUMBER
200222 ,p_event_id IN NUMBER
200223 ,p_calculate_acctd_flag IN VARCHAR2
200224 ,p_calculate_g_l_flag IN VARCHAR2
200225 ,p_actual_flag IN OUT VARCHAR2
200226 ,p_balance_type_code OUT VARCHAR2
200227 ,p_gain_or_loss_ref OUT VARCHAR2
200228
200229 --TRANSACTION_ID
200230 , p_source_1 IN NUMBER
200231 --Item Concatenated Segments
200232 , p_source_2 IN VARCHAR2
200233 --Transaction Quantity
200234 , p_source_3 IN NUMBER
200235 --Transaction Unit of Measure Code
200236 , p_source_4 IN VARCHAR2
200237 --Inventory Transaction Type Description
200238 , p_source_5 IN VARCHAR2
200239 --Cost Management Default Account
200240 , p_source_11 IN NUMBER
200241 --DISTRIBUTION_IDENTIFIER
200242 , p_source_84 IN NUMBER
200243 --Distribution Type
200244 , p_source_85 IN VARCHAR2
200245 , p_source_85_meaning IN VARCHAR2
200246 --Entered Currency Code
200247 , p_source_88 IN VARCHAR2
200248 --Entered Amount
200249 , p_source_91 IN NUMBER
200250 --Currency Conversion Date
200251 , p_source_92 IN DATE
200252 --Currency Conversion Rate
200253 , p_source_93 IN NUMBER
200254 --Currency Conversion Type
200255 , p_source_94 IN VARCHAR2
200256 --Accounted Amount
200257 , p_source_95 IN NUMBER
200258 --Accounting Line Type
200259 , p_source_97 IN NUMBER
200260 )
200261 IS
200262
200263 l_component_type VARCHAR2(80);
200264 l_component_code VARCHAR2(30);
200265 l_component_type_code VARCHAR2(1);
200266 l_component_appl_id INTEGER;
200267 l_amb_context_code VARCHAR2(30);
200268 l_entity_code VARCHAR2(30);
200269 l_event_class_code VARCHAR2(30);
200270 l_ae_header_id NUMBER;
200271 l_event_type_code VARCHAR2(30);
200272 l_line_definition_code VARCHAR2(30);
200273 l_line_definition_owner_code VARCHAR2(1);
200274 --
200275 -- adr variables
200276 l_segment VARCHAR2(30);
200277 l_ccid NUMBER;
200278 l_adr_transaction_coa_id NUMBER;
200279 l_adr_accounting_coa_id NUMBER;
200280 l_adr_flexfield_segment_code VARCHAR2(30);
200281 l_adr_flex_value_set_id NUMBER;
200282 l_adr_value_type_code VARCHAR2(30);
200283 l_adr_value_combination_id NUMBER;
200284 l_adr_value_segment_code VARCHAR2(30);
200285
200286 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
200287 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
200288 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
200289 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
200290
200291 -- 4262811 Variables ------------------------------------------------------------------------------------------
200292 l_entered_amt_idx NUMBER;
200293 l_accted_amt_idx NUMBER;
200294 l_acc_rev_flag VARCHAR2(1);
200295 l_accrual_line_num NUMBER;
200296 l_tmp_amt NUMBER;
200297 l_acc_rev_natural_side_code VARCHAR2(1);
200298
200299 l_num_entries NUMBER;
200300 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
200301 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
200302 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
200303 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
200304 l_recog_line_1 NUMBER;
200305 l_recog_line_2 NUMBER;
200306
200307 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
200308 l_bflow_applied_to_amt NUMBER; -- 5132302
200309 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
200310
200311 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
200312
200313 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
200314 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
200315
200316 ---------------------------------------------------------------------------------------------------------------
200317
200318
200319 --
200320 -- bulk performance
200321 --
200322 l_balance_type_code VARCHAR2(1);
200323 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
200324 l_log_module VARCHAR2(240);
200325
200326 --
200327 -- Upgrade strategy
200328 --
200329 l_actual_upg_option VARCHAR2(1);
200330 l_enc_upg_option VARCHAR2(1);
200331
200332 --
200333 BEGIN
200334 --
200335 IF g_log_enabled THEN
200336 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_366';
200337 END IF;
200338 --
200339 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
200340
200341 trace
200342 (p_msg => 'BEGIN of AcctLineType_366'
200343 ,p_level => C_LEVEL_PROCEDURE
200344 ,p_module => l_log_module);
200345
200346 END IF;
200347 --
200348 l_component_type := 'AMB_JLT';
200349 l_component_code := 'OFFSET';
200350 l_component_type_code := 'S';
200351 l_component_appl_id := 707;
200352 l_amb_context_code := 'DEFAULT';
200353 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
200354 l_event_class_code := 'USER_DEFINE';
200355 l_event_type_code := 'UDIR_INTERORG_SHIP';
200356 l_line_definition_owner_code := 'S';
200357 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
200358 --
200359 l_balance_type_code := 'A';
200360 l_segment := NULL;
200361 l_ccid := NULL;
200362 l_adr_transaction_coa_id := NULL;
200363 l_adr_accounting_coa_id := NULL;
200364 l_adr_flexfield_segment_code := NULL;
200365 l_adr_flex_value_set_id := NULL;
200366 l_adr_value_type_code := NULL;
200367 l_adr_value_combination_id := NULL;
200368 l_adr_value_segment_code := NULL;
200369
200370 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
200371 l_bflow_class_code := ''; -- 4219869 Business Flow
200372 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
200373 l_budgetary_control_flag := 'N';
200374
200375 l_bflow_applied_to_amt_idx := NULL; -- 5132302
200376 l_bflow_applied_to_amt := NULL; -- 5132302
200377 l_entered_amt_idx := NULL; -- 4262811
200378 l_accted_amt_idx := NULL; -- 4262811
200379 l_acc_rev_flag := NULL; -- 4262811
200380 l_accrual_line_num := NULL; -- 4262811
200381 l_tmp_amt := NULL; -- 4262811
200382 --
200383
200384 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
200385 l_balance_type_code <> 'B' THEN
200386 IF NVL(p_source_97,9E125) = 2
200387 THEN
200388
200389 --
200390 XLA_AE_LINES_PKG.SetNewLine;
200391
200392 p_balance_type_code := l_balance_type_code;
200393 -- set the flag so later we will know whether the gain loss line needs to be created
200394
200395 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
200396 p_actual_flag :='A';
200397 END IF;
200398
200399 --
200400 -- bulk performance
200401 --
200402 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
200403 p_header_num => 0); -- 4262811
200404 --
200405 -- set accounting line options
200406 --
200407 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
200408 p_natural_side_code => 'D'
200409 , p_gain_or_loss_flag => 'N'
200410 , p_gl_transfer_mode_code => 'S'
200411 , p_acct_entry_type_code => 'A'
200412 , p_switch_side_flag => 'Y'
200413 , p_merge_duplicate_code => 'N'
200414 );
200415 --
200416 l_acc_rev_natural_side_code := 'C'; -- 4262811
200417 --
200418 --
200419 -- set accounting line type info
200420 --
200421 xla_ae_lines_pkg.SetAcctLineType
200422 (p_component_type => l_component_type
200423 ,p_event_type_code => l_event_type_code
200424 ,p_line_definition_owner_code => l_line_definition_owner_code
200425 ,p_line_definition_code => l_line_definition_code
200426 ,p_accounting_line_code => l_component_code
200427 ,p_accounting_line_type_code => l_component_type_code
200428 ,p_accounting_line_appl_id => l_component_appl_id
200429 ,p_amb_context_code => l_amb_context_code
200430 ,p_entity_code => l_entity_code
200431 ,p_event_class_code => l_event_class_code);
200432 --
200433 -- set accounting class
200434 --
200435 xla_ae_lines_pkg.SetAcctClass(
200436 p_accounting_class_code => 'OFFSET'
200437 , p_ae_header_id => l_ae_header_id
200438 );
200439
200440 --
200441 -- set rounding class
200442 --
200443 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
200444 'OFFSET';
200445
200446 --
200447 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
200448 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
200449 --
200450 -- bulk performance
200451 --
200452 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
200453
200454 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
200455 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
200456
200457 -- 4955764
200458 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
200459 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
200460
200461 -- 4458381 Public Sector Enh
200462
200463 --
200464 -- set accounting attributes for the line type
200465 --
200466 l_entered_amt_idx := 3;
200467 l_accted_amt_idx := 8;
200468 l_bflow_applied_to_amt_idx := NULL; -- 5132302
200469 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
200470 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
200471 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
200472 l_rec_acct_attrs.array_char_value(2) := p_source_85;
200473 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
200474 l_rec_acct_attrs.array_num_value(3) := p_source_91;
200475 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
200476 l_rec_acct_attrs.array_char_value(4) := p_source_88;
200477 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
200478 l_rec_acct_attrs.array_date_value(5) := p_source_92;
200479 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
200480 l_rec_acct_attrs.array_num_value(6) := p_source_93;
200481 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
200482 l_rec_acct_attrs.array_char_value(7) := p_source_94;
200483 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
200484 l_rec_acct_attrs.array_num_value(8) := p_source_95;
200485
200486 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
200487 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
200488
200489 ---------------------------------------------------------------------------------------------------------------
200490 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
200491 ---------------------------------------------------------------------------------------------------------------
200492 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
200493
200494 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
200495 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
200496
200497 IF xla_accounting_cache_pkg.GetValueChar
200498 (p_source_code => 'LEDGER_CATEGORY_CODE'
200499 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
200500 AND l_bflow_method_code = 'PRIOR_ENTRY'
200501 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
200502 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
200503 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
200504 )
200505 THEN
200506 xla_ae_lines_pkg.BflowUpgEntry
200507 (p_business_method_code => l_bflow_method_code
200508 ,p_business_class_code => l_bflow_class_code
200509 ,p_balance_type => l_balance_type_code);
200510 ELSE
200511 NULL;
200512 -- No business flow processing for business flow method of NONE.
200513 END IF;
200514
200515 --
200516 -- call analytical criteria
200517 --
200518
200519 --
200520 -- call description
200521 --
200522
200523 xla_ae_lines_pkg.SetLineDescription(
200524 p_ae_header_id => l_ae_header_id
200525 ,p_description => Description_1 (
200526 p_application_id => p_application_id
200527 , p_ae_header_id => l_ae_header_id
200528 , p_source_1 => p_source_1
200529 , p_source_2 => p_source_2
200530 , p_source_3 => p_source_3
200531 , p_source_4 => p_source_4
200532 , p_source_5 => p_source_5
200533 )
200534 );
200535
200536
200537 --
200538 -- call ADRs
200539 -- Bug 4922099
200540 --
200541 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
200542 (NVL(l_actual_upg_option, 'N') = 'O') OR
200543 (NVL(l_enc_upg_option, 'N') = 'O')
200544 )
200545 THEN
200546 NULL;
200547 --
200548 --
200549
200550 l_ccid := AcctDerRule_6(
200551 p_application_id => p_application_id
200552 , p_ae_header_id => l_ae_header_id
200553 , p_source_11 => p_source_11
200554 , x_transaction_coa_id => l_adr_transaction_coa_id
200555 , x_accounting_coa_id => l_adr_accounting_coa_id
200556 , x_value_type_code => l_adr_value_type_code
200557 , p_side => 'NA'
200558 );
200559
200560 xla_ae_lines_pkg.set_ccid(
200561 p_code_combination_id => l_ccid
200562 , p_value_type_code => l_adr_value_type_code
200563 , p_transaction_coa_id => l_adr_transaction_coa_id
200564 , p_accounting_coa_id => l_adr_accounting_coa_id
200565 , p_adr_code => 'CST_DEFAULT'
200566 , p_adr_type_code => 'S'
200567 , p_component_type => l_component_type
200568 , p_component_code => l_component_code
200569 , p_component_type_code => l_component_type_code
200570 , p_component_appl_id => l_component_appl_id
200571 , p_amb_context_code => l_amb_context_code
200572 , p_side => 'NA'
200573 );
200574
200575
200576 --
200577 --
200578 END IF;
200579 --
200580 -- Bug 4922099
200581 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
200582 (NVL(l_enc_upg_option, 'N') = 'O')
200583 ) AND
200584 (l_bflow_method_code = 'PRIOR_ENTRY')
200585 )
200586 THEN
200587 IF
200588 --
200589 1 = 2
200590 --
200591 THEN
200592 xla_accounting_err_pkg.build_message
200593 (p_appli_s_name => 'XLA'
200594 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
200595 ,p_token_1 => 'LINE_NUMBER'
200596 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
200597 ,p_token_2 => 'LINE_TYPE_NAME'
200598 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
200599 l_component_type
200600 ,l_component_code
200601 ,l_component_type_code
200602 ,l_component_appl_id
200603 ,l_amb_context_code
200604 ,l_entity_code
200605 ,l_event_class_code
200606 )
200607 ,p_token_3 => 'OWNER'
200608 ,p_value_3 => xla_lookups_pkg.get_meaning(
200609 p_lookup_type => 'XLA_OWNER_TYPE'
200610 ,p_lookup_code => l_component_type_code
200611 )
200612 ,p_token_4 => 'PRODUCT_NAME'
200613 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
200614 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
200615 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
200616 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
200617 ,p_ae_header_id => NULL
200618 );
200619
200620 IF (C_LEVEL_ERROR>= g_log_level) THEN
200621 trace
200622 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
200623 ,p_level => C_LEVEL_ERROR
200624 ,p_module => l_log_module);
200625 END IF;
200626 END IF;
200627 END IF;
200628 --
200629 --
200630 ------------------------------------------------------------------------------------------------
200631 -- 4219869 Business Flow
200632 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
200633 -- Prior Entry. Currently, the following code is always generated.
200634 ------------------------------------------------------------------------------------------------
200635 XLA_AE_LINES_PKG.ValidateCurrentLine;
200636
200637 ------------------------------------------------------------------------------------
200638 -- 4219869 Business Flow
200639 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
200640 ------------------------------------------------------------------------------------
200641 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
200642
200643 ----------------------------------------------------------------------------------
200644 -- 4219869 Business Flow
200645 -- Update journal entry status -- Need to generate this within IF <condition>
200646 ----------------------------------------------------------------------------------
200647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
200648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
200649 ,p_balance_type_code => l_balance_type_code
200650 );
200651
200652 -------------------------------------------------------------------------------------------
200653 -- 4262811 - Generate the Accrual Reversal lines
200654 -------------------------------------------------------------------------------------------
200655 BEGIN
200656 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
200657 (g_array_event(p_event_id).array_value_num('header_index'));
200658 IF l_acc_rev_flag IS NULL THEN
200659 l_acc_rev_flag := 'N';
200660 END IF;
200661 EXCEPTION
200662 WHEN OTHERS THEN
200663 l_acc_rev_flag := 'N';
200664 END;
200665 --
200666 IF (l_acc_rev_flag = 'Y') THEN
200667
200668 -- 4645092 ------------------------------------------------------------------------------
200669 -- To allow MPA report to determine if it should generate report process
200670 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
200671 ------------------------------------------------------------------------------------------
200672
200673 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
200674 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
200675 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
200676 -- call ADRs
200677 -- Bug 4922099
200678 --
200679 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
200680 (NVL(l_actual_upg_option, 'N') = 'O') OR
200681 (NVL(l_enc_upg_option, 'N') = 'O')
200682 )
200683 THEN
200684 NULL;
200685 --
200686 --
200687
200688 l_ccid := AcctDerRule_6(
200689 p_application_id => p_application_id
200690 , p_ae_header_id => l_ae_header_id
200691 , p_source_11 => p_source_11
200692 , x_transaction_coa_id => l_adr_transaction_coa_id
200693 , x_accounting_coa_id => l_adr_accounting_coa_id
200694 , x_value_type_code => l_adr_value_type_code
200695 , p_side => 'NA'
200696 );
200697
200698 xla_ae_lines_pkg.set_ccid(
200699 p_code_combination_id => l_ccid
200700 , p_value_type_code => l_adr_value_type_code
200701 , p_transaction_coa_id => l_adr_transaction_coa_id
200702 , p_accounting_coa_id => l_adr_accounting_coa_id
200703 , p_adr_code => 'CST_DEFAULT'
200704 , p_adr_type_code => 'S'
200705 , p_component_type => l_component_type
200706 , p_component_code => l_component_code
200707 , p_component_type_code => l_component_type_code
200708 , p_component_appl_id => l_component_appl_id
200709 , p_amb_context_code => l_amb_context_code
200710 , p_side => 'NA'
200711 );
200712
200713
200714 --
200715 --
200716 END IF;
200717
200718 --
200719 -- Update the line information that should be overwritten
200720 --
200721 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
200722 p_header_num => 1);
200723 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
200724
200725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
200726
200727 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
200728 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
200729 END IF;
200730
200731 --
200732 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
200733 --
200734 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
200735 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
200736 ELSE
200737 ---------------------------------------------------------------------------------------------------
200738 -- 4262811a Switch Sign
200739 ---------------------------------------------------------------------------------------------------
200740 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
200741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
200742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
200744 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200745 -- 5132302
200746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
200747 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
200748
200749 END IF;
200750
200751 -- 4955764
200752 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
200753 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
200754
200755
200756 XLA_AE_LINES_PKG.ValidateCurrentLine;
200757 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
200758
200759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
200760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
200761 ,p_balance_type_code => l_balance_type_code);
200762
200763 END IF;
200764
200765 -----------------------------------------------------------------------------------------
200766 -- 4262811 Multiperiod Accounting
200767 -----------------------------------------------------------------------------------------
200768 -- No MPA option is assigned.
200769
200770
200771 END IF;
200772 END IF;
200773 --
200774
200775 --
200776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
200777 trace
200778 (p_msg => 'END of AcctLineType_366'
200779 ,p_level => C_LEVEL_PROCEDURE
200780 ,p_module => l_log_module);
200781 END IF;
200782 --
200783 EXCEPTION
200784 WHEN xla_exceptions_pkg.application_exception THEN
200785 RAISE;
200786 WHEN OTHERS THEN
200787 xla_exceptions_pkg.raise_message
200788 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_366');
200789 END AcctLineType_366;
200790 --
200791
200792 ---------------------------------------
200793 --
200794 -- PRIVATE FUNCTION
200795 -- AcctLineType_367
200796 --
200797 ---------------------------------------
200798 PROCEDURE AcctLineType_367 (
200799 p_application_id IN NUMBER
200800 ,p_event_id IN NUMBER
200801 ,p_calculate_acctd_flag IN VARCHAR2
200802 ,p_calculate_g_l_flag IN VARCHAR2
200803 ,p_actual_flag IN OUT VARCHAR2
200804 ,p_balance_type_code OUT VARCHAR2
200805 ,p_gain_or_loss_ref OUT VARCHAR2
200806
200807 --TRANSACTION_ID
200808 , p_source_1 IN NUMBER
200809 --Item Concatenated Segments
200810 , p_source_2 IN VARCHAR2
200811 --Transaction Quantity
200812 , p_source_3 IN NUMBER
200813 --Transaction Unit of Measure Code
200814 , p_source_4 IN VARCHAR2
200815 --Inventory Transaction Type Description
200816 , p_source_5 IN VARCHAR2
200817 --Cost Management Default Account
200818 , p_source_11 IN NUMBER
200819 --DISTRIBUTION_IDENTIFIER
200820 , p_source_84 IN NUMBER
200821 --Distribution Type
200822 , p_source_85 IN VARCHAR2
200823 , p_source_85_meaning IN VARCHAR2
200824 --Entered Currency Code
200825 , p_source_88 IN VARCHAR2
200826 --Entered Amount
200827 , p_source_91 IN NUMBER
200828 --Currency Conversion Date
200829 , p_source_92 IN DATE
200830 --Currency Conversion Rate
200831 , p_source_93 IN NUMBER
200832 --Currency Conversion Type
200833 , p_source_94 IN VARCHAR2
200834 --Accounted Amount
200835 , p_source_95 IN NUMBER
200836 --Accounting Line Type
200837 , p_source_97 IN NUMBER
200838 )
200839 IS
200840
200841 l_component_type VARCHAR2(80);
200842 l_component_code VARCHAR2(30);
200843 l_component_type_code VARCHAR2(1);
200844 l_component_appl_id INTEGER;
200845 l_amb_context_code VARCHAR2(30);
200846 l_entity_code VARCHAR2(30);
200847 l_event_class_code VARCHAR2(30);
200848 l_ae_header_id NUMBER;
200849 l_event_type_code VARCHAR2(30);
200850 l_line_definition_code VARCHAR2(30);
200851 l_line_definition_owner_code VARCHAR2(1);
200852 --
200853 -- adr variables
200854 l_segment VARCHAR2(30);
200855 l_ccid NUMBER;
200856 l_adr_transaction_coa_id NUMBER;
200857 l_adr_accounting_coa_id NUMBER;
200858 l_adr_flexfield_segment_code VARCHAR2(30);
200859 l_adr_flex_value_set_id NUMBER;
200860 l_adr_value_type_code VARCHAR2(30);
200861 l_adr_value_combination_id NUMBER;
200862 l_adr_value_segment_code VARCHAR2(30);
200863
200864 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
200865 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
200866 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
200867 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
200868
200869 -- 4262811 Variables ------------------------------------------------------------------------------------------
200870 l_entered_amt_idx NUMBER;
200871 l_accted_amt_idx NUMBER;
200872 l_acc_rev_flag VARCHAR2(1);
200873 l_accrual_line_num NUMBER;
200874 l_tmp_amt NUMBER;
200875 l_acc_rev_natural_side_code VARCHAR2(1);
200876
200877 l_num_entries NUMBER;
200878 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
200879 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
200880 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
200881 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
200882 l_recog_line_1 NUMBER;
200883 l_recog_line_2 NUMBER;
200884
200885 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
200886 l_bflow_applied_to_amt NUMBER; -- 5132302
200887 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
200888
200889 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
200890
200891 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
200892 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
200893
200894 ---------------------------------------------------------------------------------------------------------------
200895
200896
200897 --
200898 -- bulk performance
200899 --
200900 l_balance_type_code VARCHAR2(1);
200901 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
200902 l_log_module VARCHAR2(240);
200903
200904 --
200905 -- Upgrade strategy
200906 --
200907 l_actual_upg_option VARCHAR2(1);
200908 l_enc_upg_option VARCHAR2(1);
200909
200910 --
200911 BEGIN
200912 --
200913 IF g_log_enabled THEN
200914 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_367';
200915 END IF;
200916 --
200917 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
200918
200919 trace
200920 (p_msg => 'BEGIN of AcctLineType_367'
200921 ,p_level => C_LEVEL_PROCEDURE
200922 ,p_module => l_log_module);
200923
200924 END IF;
200925 --
200926 l_component_type := 'AMB_JLT';
200927 l_component_code := 'OFFSET';
200928 l_component_type_code := 'S';
200929 l_component_appl_id := 707;
200930 l_amb_context_code := 'DEFAULT';
200931 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
200932 l_event_class_code := 'USER_DEFINE';
200933 l_event_type_code := 'UFOB_SHIP_SENDER_SHIP_NO_TP';
200934 l_line_definition_owner_code := 'S';
200935 l_line_definition_code := 'PI_FOB_SHIP_SENDER_SHIP_NTP';
200936 --
200937 l_balance_type_code := 'A';
200938 l_segment := NULL;
200939 l_ccid := NULL;
200940 l_adr_transaction_coa_id := NULL;
200941 l_adr_accounting_coa_id := NULL;
200942 l_adr_flexfield_segment_code := NULL;
200943 l_adr_flex_value_set_id := NULL;
200944 l_adr_value_type_code := NULL;
200945 l_adr_value_combination_id := NULL;
200946 l_adr_value_segment_code := NULL;
200947
200948 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
200949 l_bflow_class_code := ''; -- 4219869 Business Flow
200950 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
200951 l_budgetary_control_flag := 'N';
200952
200953 l_bflow_applied_to_amt_idx := NULL; -- 5132302
200954 l_bflow_applied_to_amt := NULL; -- 5132302
200955 l_entered_amt_idx := NULL; -- 4262811
200956 l_accted_amt_idx := NULL; -- 4262811
200957 l_acc_rev_flag := NULL; -- 4262811
200958 l_accrual_line_num := NULL; -- 4262811
200959 l_tmp_amt := NULL; -- 4262811
200960 --
200961
200962 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
200963 l_balance_type_code <> 'B' THEN
200964 IF NVL(p_source_97,9E125) = 2
200965 THEN
200966
200967 --
200968 XLA_AE_LINES_PKG.SetNewLine;
200969
200970 p_balance_type_code := l_balance_type_code;
200971 -- set the flag so later we will know whether the gain loss line needs to be created
200972
200973 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
200974 p_actual_flag :='A';
200975 END IF;
200976
200977 --
200978 -- bulk performance
200979 --
200980 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
200981 p_header_num => 0); -- 4262811
200982 --
200983 -- set accounting line options
200984 --
200985 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
200986 p_natural_side_code => 'D'
200987 , p_gain_or_loss_flag => 'N'
200988 , p_gl_transfer_mode_code => 'S'
200989 , p_acct_entry_type_code => 'A'
200990 , p_switch_side_flag => 'Y'
200991 , p_merge_duplicate_code => 'N'
200992 );
200993 --
200994 l_acc_rev_natural_side_code := 'C'; -- 4262811
200995 --
200996 --
200997 -- set accounting line type info
200998 --
200999 xla_ae_lines_pkg.SetAcctLineType
201000 (p_component_type => l_component_type
201001 ,p_event_type_code => l_event_type_code
201002 ,p_line_definition_owner_code => l_line_definition_owner_code
201003 ,p_line_definition_code => l_line_definition_code
201004 ,p_accounting_line_code => l_component_code
201005 ,p_accounting_line_type_code => l_component_type_code
201006 ,p_accounting_line_appl_id => l_component_appl_id
201007 ,p_amb_context_code => l_amb_context_code
201008 ,p_entity_code => l_entity_code
201009 ,p_event_class_code => l_event_class_code);
201010 --
201011 -- set accounting class
201012 --
201013 xla_ae_lines_pkg.SetAcctClass(
201014 p_accounting_class_code => 'OFFSET'
201015 , p_ae_header_id => l_ae_header_id
201016 );
201017
201018 --
201019 -- set rounding class
201020 --
201021 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
201022 'OFFSET';
201023
201024 --
201025 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
201026 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
201027 --
201028 -- bulk performance
201029 --
201030 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
201031
201032 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
201033 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
201034
201035 -- 4955764
201036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
201037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
201038
201039 -- 4458381 Public Sector Enh
201040
201041 --
201042 -- set accounting attributes for the line type
201043 --
201044 l_entered_amt_idx := 3;
201045 l_accted_amt_idx := 8;
201046 l_bflow_applied_to_amt_idx := NULL; -- 5132302
201047 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
201048 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
201049 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
201050 l_rec_acct_attrs.array_char_value(2) := p_source_85;
201051 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
201052 l_rec_acct_attrs.array_num_value(3) := p_source_91;
201053 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
201054 l_rec_acct_attrs.array_char_value(4) := p_source_88;
201055 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
201056 l_rec_acct_attrs.array_date_value(5) := p_source_92;
201057 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
201058 l_rec_acct_attrs.array_num_value(6) := p_source_93;
201059 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
201060 l_rec_acct_attrs.array_char_value(7) := p_source_94;
201061 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
201062 l_rec_acct_attrs.array_num_value(8) := p_source_95;
201063
201064 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
201065 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
201066
201067 ---------------------------------------------------------------------------------------------------------------
201068 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
201069 ---------------------------------------------------------------------------------------------------------------
201070 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
201071
201072 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
201073 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
201074
201075 IF xla_accounting_cache_pkg.GetValueChar
201076 (p_source_code => 'LEDGER_CATEGORY_CODE'
201077 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
201078 AND l_bflow_method_code = 'PRIOR_ENTRY'
201079 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
201080 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
201081 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
201082 )
201083 THEN
201084 xla_ae_lines_pkg.BflowUpgEntry
201085 (p_business_method_code => l_bflow_method_code
201086 ,p_business_class_code => l_bflow_class_code
201087 ,p_balance_type => l_balance_type_code);
201088 ELSE
201089 NULL;
201090 -- No business flow processing for business flow method of NONE.
201091 END IF;
201092
201093 --
201094 -- call analytical criteria
201095 --
201096
201097 --
201098 -- call description
201099 --
201100
201101 xla_ae_lines_pkg.SetLineDescription(
201102 p_ae_header_id => l_ae_header_id
201103 ,p_description => Description_1 (
201104 p_application_id => p_application_id
201105 , p_ae_header_id => l_ae_header_id
201106 , p_source_1 => p_source_1
201107 , p_source_2 => p_source_2
201108 , p_source_3 => p_source_3
201109 , p_source_4 => p_source_4
201110 , p_source_5 => p_source_5
201111 )
201112 );
201113
201114
201115 --
201116 -- call ADRs
201117 -- Bug 4922099
201118 --
201119 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
201120 (NVL(l_actual_upg_option, 'N') = 'O') OR
201121 (NVL(l_enc_upg_option, 'N') = 'O')
201122 )
201123 THEN
201124 NULL;
201125 --
201126 --
201127
201128 l_ccid := AcctDerRule_6(
201129 p_application_id => p_application_id
201130 , p_ae_header_id => l_ae_header_id
201131 , p_source_11 => p_source_11
201132 , x_transaction_coa_id => l_adr_transaction_coa_id
201133 , x_accounting_coa_id => l_adr_accounting_coa_id
201134 , x_value_type_code => l_adr_value_type_code
201135 , p_side => 'NA'
201136 );
201137
201138 xla_ae_lines_pkg.set_ccid(
201139 p_code_combination_id => l_ccid
201140 , p_value_type_code => l_adr_value_type_code
201141 , p_transaction_coa_id => l_adr_transaction_coa_id
201142 , p_accounting_coa_id => l_adr_accounting_coa_id
201143 , p_adr_code => 'CST_DEFAULT'
201144 , p_adr_type_code => 'S'
201145 , p_component_type => l_component_type
201146 , p_component_code => l_component_code
201147 , p_component_type_code => l_component_type_code
201148 , p_component_appl_id => l_component_appl_id
201149 , p_amb_context_code => l_amb_context_code
201150 , p_side => 'NA'
201151 );
201152
201153
201154 --
201155 --
201156 END IF;
201157 --
201158 -- Bug 4922099
201159 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
201160 (NVL(l_enc_upg_option, 'N') = 'O')
201161 ) AND
201162 (l_bflow_method_code = 'PRIOR_ENTRY')
201163 )
201164 THEN
201165 IF
201166 --
201167 1 = 2
201168 --
201169 THEN
201170 xla_accounting_err_pkg.build_message
201171 (p_appli_s_name => 'XLA'
201172 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
201173 ,p_token_1 => 'LINE_NUMBER'
201174 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
201175 ,p_token_2 => 'LINE_TYPE_NAME'
201176 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
201177 l_component_type
201178 ,l_component_code
201179 ,l_component_type_code
201180 ,l_component_appl_id
201181 ,l_amb_context_code
201182 ,l_entity_code
201183 ,l_event_class_code
201184 )
201185 ,p_token_3 => 'OWNER'
201186 ,p_value_3 => xla_lookups_pkg.get_meaning(
201187 p_lookup_type => 'XLA_OWNER_TYPE'
201188 ,p_lookup_code => l_component_type_code
201189 )
201190 ,p_token_4 => 'PRODUCT_NAME'
201191 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
201192 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
201193 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
201194 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
201195 ,p_ae_header_id => NULL
201196 );
201197
201198 IF (C_LEVEL_ERROR>= g_log_level) THEN
201199 trace
201200 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
201201 ,p_level => C_LEVEL_ERROR
201202 ,p_module => l_log_module);
201203 END IF;
201204 END IF;
201205 END IF;
201206 --
201207 --
201208 ------------------------------------------------------------------------------------------------
201209 -- 4219869 Business Flow
201210 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
201211 -- Prior Entry. Currently, the following code is always generated.
201212 ------------------------------------------------------------------------------------------------
201213 XLA_AE_LINES_PKG.ValidateCurrentLine;
201214
201215 ------------------------------------------------------------------------------------
201216 -- 4219869 Business Flow
201217 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
201218 ------------------------------------------------------------------------------------
201219 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
201220
201221 ----------------------------------------------------------------------------------
201222 -- 4219869 Business Flow
201223 -- Update journal entry status -- Need to generate this within IF <condition>
201224 ----------------------------------------------------------------------------------
201225 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
201226 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
201227 ,p_balance_type_code => l_balance_type_code
201228 );
201229
201230 -------------------------------------------------------------------------------------------
201231 -- 4262811 - Generate the Accrual Reversal lines
201232 -------------------------------------------------------------------------------------------
201233 BEGIN
201234 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
201235 (g_array_event(p_event_id).array_value_num('header_index'));
201236 IF l_acc_rev_flag IS NULL THEN
201237 l_acc_rev_flag := 'N';
201238 END IF;
201239 EXCEPTION
201240 WHEN OTHERS THEN
201241 l_acc_rev_flag := 'N';
201242 END;
201243 --
201244 IF (l_acc_rev_flag = 'Y') THEN
201245
201246 -- 4645092 ------------------------------------------------------------------------------
201247 -- To allow MPA report to determine if it should generate report process
201248 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
201249 ------------------------------------------------------------------------------------------
201250
201251 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
201252 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
201253 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
201254 -- call ADRs
201255 -- Bug 4922099
201256 --
201257 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
201258 (NVL(l_actual_upg_option, 'N') = 'O') OR
201259 (NVL(l_enc_upg_option, 'N') = 'O')
201260 )
201261 THEN
201262 NULL;
201263 --
201264 --
201265
201266 l_ccid := AcctDerRule_6(
201267 p_application_id => p_application_id
201268 , p_ae_header_id => l_ae_header_id
201269 , p_source_11 => p_source_11
201270 , x_transaction_coa_id => l_adr_transaction_coa_id
201271 , x_accounting_coa_id => l_adr_accounting_coa_id
201272 , x_value_type_code => l_adr_value_type_code
201273 , p_side => 'NA'
201274 );
201275
201276 xla_ae_lines_pkg.set_ccid(
201277 p_code_combination_id => l_ccid
201278 , p_value_type_code => l_adr_value_type_code
201279 , p_transaction_coa_id => l_adr_transaction_coa_id
201280 , p_accounting_coa_id => l_adr_accounting_coa_id
201281 , p_adr_code => 'CST_DEFAULT'
201282 , p_adr_type_code => 'S'
201283 , p_component_type => l_component_type
201284 , p_component_code => l_component_code
201285 , p_component_type_code => l_component_type_code
201286 , p_component_appl_id => l_component_appl_id
201287 , p_amb_context_code => l_amb_context_code
201288 , p_side => 'NA'
201289 );
201290
201291
201292 --
201293 --
201294 END IF;
201295
201296 --
201297 -- Update the line information that should be overwritten
201298 --
201299 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
201300 p_header_num => 1);
201301 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
201302
201303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
201304
201305 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
201306 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
201307 END IF;
201308
201309 --
201310 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
201311 --
201312 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
201313 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
201314 ELSE
201315 ---------------------------------------------------------------------------------------------------
201316 -- 4262811a Switch Sign
201317 ---------------------------------------------------------------------------------------------------
201318 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
201319 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
201320 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201321 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
201322 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201323 -- 5132302
201324 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
201325 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201326
201327 END IF;
201328
201329 -- 4955764
201330 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
201331 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
201332
201333
201334 XLA_AE_LINES_PKG.ValidateCurrentLine;
201335 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
201336
201337 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
201338 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
201339 ,p_balance_type_code => l_balance_type_code);
201340
201341 END IF;
201342
201343 -----------------------------------------------------------------------------------------
201344 -- 4262811 Multiperiod Accounting
201345 -----------------------------------------------------------------------------------------
201346 -- No MPA option is assigned.
201347
201348
201349 END IF;
201350 END IF;
201351 --
201352
201353 --
201354 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
201355 trace
201356 (p_msg => 'END of AcctLineType_367'
201357 ,p_level => C_LEVEL_PROCEDURE
201358 ,p_module => l_log_module);
201359 END IF;
201360 --
201361 EXCEPTION
201362 WHEN xla_exceptions_pkg.application_exception THEN
201363 RAISE;
201364 WHEN OTHERS THEN
201365 xla_exceptions_pkg.raise_message
201366 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_367');
201367 END AcctLineType_367;
201368 --
201369
201370 ---------------------------------------
201371 --
201372 -- PRIVATE FUNCTION
201373 -- AcctLineType_368
201374 --
201375 ---------------------------------------
201376 PROCEDURE AcctLineType_368 (
201377 p_application_id IN NUMBER
201378 ,p_event_id IN NUMBER
201379 ,p_calculate_acctd_flag IN VARCHAR2
201380 ,p_calculate_g_l_flag IN VARCHAR2
201381 ,p_actual_flag IN OUT VARCHAR2
201382 ,p_balance_type_code OUT VARCHAR2
201383 ,p_gain_or_loss_ref OUT VARCHAR2
201384
201385 --Cost Management Default Account
201386 , p_source_11 IN NUMBER
201387 --DISTRIBUTION_IDENTIFIER
201388 , p_source_84 IN NUMBER
201389 --Distribution Type
201390 , p_source_85 IN VARCHAR2
201391 , p_source_85_meaning IN VARCHAR2
201392 --Entered Currency Code
201393 , p_source_88 IN VARCHAR2
201394 --Entered Amount
201395 , p_source_91 IN NUMBER
201396 --Currency Conversion Date
201397 , p_source_92 IN DATE
201398 --Currency Conversion Rate
201399 , p_source_93 IN NUMBER
201400 --Currency Conversion Type
201401 , p_source_94 IN VARCHAR2
201402 --Accounted Amount
201403 , p_source_95 IN NUMBER
201404 --Accounting Line Type
201405 , p_source_97 IN NUMBER
201406 )
201407 IS
201408
201409 l_component_type VARCHAR2(80);
201410 l_component_code VARCHAR2(30);
201411 l_component_type_code VARCHAR2(1);
201412 l_component_appl_id INTEGER;
201413 l_amb_context_code VARCHAR2(30);
201414 l_entity_code VARCHAR2(30);
201415 l_event_class_code VARCHAR2(30);
201416 l_ae_header_id NUMBER;
201417 l_event_type_code VARCHAR2(30);
201418 l_line_definition_code VARCHAR2(30);
201419 l_line_definition_owner_code VARCHAR2(1);
201420 --
201421 -- adr variables
201422 l_segment VARCHAR2(30);
201423 l_ccid NUMBER;
201424 l_adr_transaction_coa_id NUMBER;
201425 l_adr_accounting_coa_id NUMBER;
201426 l_adr_flexfield_segment_code VARCHAR2(30);
201427 l_adr_flex_value_set_id NUMBER;
201428 l_adr_value_type_code VARCHAR2(30);
201429 l_adr_value_combination_id NUMBER;
201430 l_adr_value_segment_code VARCHAR2(30);
201431
201432 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
201433 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
201434 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
201435 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
201436
201437 -- 4262811 Variables ------------------------------------------------------------------------------------------
201438 l_entered_amt_idx NUMBER;
201439 l_accted_amt_idx NUMBER;
201440 l_acc_rev_flag VARCHAR2(1);
201441 l_accrual_line_num NUMBER;
201442 l_tmp_amt NUMBER;
201443 l_acc_rev_natural_side_code VARCHAR2(1);
201444
201445 l_num_entries NUMBER;
201446 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
201447 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
201448 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
201449 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
201450 l_recog_line_1 NUMBER;
201451 l_recog_line_2 NUMBER;
201452
201453 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
201454 l_bflow_applied_to_amt NUMBER; -- 5132302
201455 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
201456
201457 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
201458
201459 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
201460 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
201461
201462 ---------------------------------------------------------------------------------------------------------------
201463
201464
201465 --
201466 -- bulk performance
201467 --
201468 l_balance_type_code VARCHAR2(1);
201469 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
201470 l_log_module VARCHAR2(240);
201471
201472 --
201473 -- Upgrade strategy
201474 --
201475 l_actual_upg_option VARCHAR2(1);
201476 l_enc_upg_option VARCHAR2(1);
201477
201478 --
201479 BEGIN
201480 --
201481 IF g_log_enabled THEN
201482 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_368';
201483 END IF;
201484 --
201485 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
201486
201487 trace
201488 (p_msg => 'BEGIN of AcctLineType_368'
201489 ,p_level => C_LEVEL_PROCEDURE
201490 ,p_module => l_log_module);
201491
201492 END IF;
201493 --
201494 l_component_type := 'AMB_JLT';
201495 l_component_code := 'OFFSET';
201496 l_component_type_code := 'S';
201497 l_component_appl_id := 707;
201498 l_amb_context_code := 'DEFAULT';
201499 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
201500 l_event_class_code := 'USER_DEFINE';
201501 l_event_type_code := 'UMISC_RCPT';
201502 l_line_definition_owner_code := 'S';
201503 l_line_definition_code := 'PI_USER_RCPT';
201504 --
201505 l_balance_type_code := 'A';
201506 l_segment := NULL;
201507 l_ccid := NULL;
201508 l_adr_transaction_coa_id := NULL;
201509 l_adr_accounting_coa_id := NULL;
201510 l_adr_flexfield_segment_code := NULL;
201511 l_adr_flex_value_set_id := NULL;
201512 l_adr_value_type_code := NULL;
201513 l_adr_value_combination_id := NULL;
201514 l_adr_value_segment_code := NULL;
201515
201516 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
201517 l_bflow_class_code := ''; -- 4219869 Business Flow
201518 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
201519 l_budgetary_control_flag := 'N';
201520
201521 l_bflow_applied_to_amt_idx := NULL; -- 5132302
201522 l_bflow_applied_to_amt := NULL; -- 5132302
201523 l_entered_amt_idx := NULL; -- 4262811
201524 l_accted_amt_idx := NULL; -- 4262811
201525 l_acc_rev_flag := NULL; -- 4262811
201526 l_accrual_line_num := NULL; -- 4262811
201527 l_tmp_amt := NULL; -- 4262811
201528 --
201529
201530 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
201531 l_balance_type_code <> 'B' THEN
201532 IF NVL(p_source_97,9E125) = 2
201533 THEN
201534
201535 --
201536 XLA_AE_LINES_PKG.SetNewLine;
201537
201538 p_balance_type_code := l_balance_type_code;
201539 -- set the flag so later we will know whether the gain loss line needs to be created
201540
201541 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
201542 p_actual_flag :='A';
201543 END IF;
201544
201545 --
201546 -- bulk performance
201547 --
201548 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
201549 p_header_num => 0); -- 4262811
201550 --
201551 -- set accounting line options
201552 --
201553 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
201554 p_natural_side_code => 'D'
201555 , p_gain_or_loss_flag => 'N'
201556 , p_gl_transfer_mode_code => 'S'
201557 , p_acct_entry_type_code => 'A'
201558 , p_switch_side_flag => 'Y'
201559 , p_merge_duplicate_code => 'N'
201560 );
201561 --
201562 l_acc_rev_natural_side_code := 'C'; -- 4262811
201563 --
201564 --
201565 -- set accounting line type info
201566 --
201567 xla_ae_lines_pkg.SetAcctLineType
201568 (p_component_type => l_component_type
201569 ,p_event_type_code => l_event_type_code
201570 ,p_line_definition_owner_code => l_line_definition_owner_code
201571 ,p_line_definition_code => l_line_definition_code
201572 ,p_accounting_line_code => l_component_code
201573 ,p_accounting_line_type_code => l_component_type_code
201574 ,p_accounting_line_appl_id => l_component_appl_id
201575 ,p_amb_context_code => l_amb_context_code
201576 ,p_entity_code => l_entity_code
201577 ,p_event_class_code => l_event_class_code);
201578 --
201579 -- set accounting class
201580 --
201581 xla_ae_lines_pkg.SetAcctClass(
201582 p_accounting_class_code => 'OFFSET'
201583 , p_ae_header_id => l_ae_header_id
201584 );
201585
201586 --
201587 -- set rounding class
201588 --
201589 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
201590 'OFFSET';
201591
201592 --
201593 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
201594 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
201595 --
201596 -- bulk performance
201597 --
201598 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
201599
201600 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
201601 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
201602
201603 -- 4955764
201604 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
201605 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
201606
201607 -- 4458381 Public Sector Enh
201608
201609 --
201610 -- set accounting attributes for the line type
201611 --
201612 l_entered_amt_idx := 3;
201613 l_accted_amt_idx := 8;
201614 l_bflow_applied_to_amt_idx := NULL; -- 5132302
201615 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
201616 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
201617 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
201618 l_rec_acct_attrs.array_char_value(2) := p_source_85;
201619 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
201620 l_rec_acct_attrs.array_num_value(3) := p_source_91;
201621 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
201622 l_rec_acct_attrs.array_char_value(4) := p_source_88;
201623 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
201624 l_rec_acct_attrs.array_date_value(5) := p_source_92;
201625 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
201626 l_rec_acct_attrs.array_num_value(6) := p_source_93;
201627 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
201628 l_rec_acct_attrs.array_char_value(7) := p_source_94;
201629 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
201630 l_rec_acct_attrs.array_num_value(8) := p_source_95;
201631
201632 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
201633 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
201634
201635 ---------------------------------------------------------------------------------------------------------------
201636 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
201637 ---------------------------------------------------------------------------------------------------------------
201638 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
201639
201640 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
201641 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
201642
201643 IF xla_accounting_cache_pkg.GetValueChar
201644 (p_source_code => 'LEDGER_CATEGORY_CODE'
201645 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
201646 AND l_bflow_method_code = 'PRIOR_ENTRY'
201647 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
201648 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
201649 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
201650 )
201651 THEN
201652 xla_ae_lines_pkg.BflowUpgEntry
201653 (p_business_method_code => l_bflow_method_code
201654 ,p_business_class_code => l_bflow_class_code
201655 ,p_balance_type => l_balance_type_code);
201656 ELSE
201657 NULL;
201658 -- No business flow processing for business flow method of NONE.
201659 END IF;
201660
201661 --
201662 -- call analytical criteria
201663 --
201664
201665 --
201666 -- call description
201667 --
201668 -- No description or it is inherited.
201669 --
201670 -- call ADRs
201671 -- Bug 4922099
201672 --
201673 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
201674 (NVL(l_actual_upg_option, 'N') = 'O') OR
201675 (NVL(l_enc_upg_option, 'N') = 'O')
201676 )
201677 THEN
201678 NULL;
201679 --
201680 --
201681
201682 l_ccid := AcctDerRule_6(
201683 p_application_id => p_application_id
201684 , p_ae_header_id => l_ae_header_id
201685 , p_source_11 => p_source_11
201686 , x_transaction_coa_id => l_adr_transaction_coa_id
201687 , x_accounting_coa_id => l_adr_accounting_coa_id
201688 , x_value_type_code => l_adr_value_type_code
201689 , p_side => 'NA'
201690 );
201691
201692 xla_ae_lines_pkg.set_ccid(
201693 p_code_combination_id => l_ccid
201694 , p_value_type_code => l_adr_value_type_code
201695 , p_transaction_coa_id => l_adr_transaction_coa_id
201696 , p_accounting_coa_id => l_adr_accounting_coa_id
201697 , p_adr_code => 'CST_DEFAULT'
201698 , p_adr_type_code => 'S'
201699 , p_component_type => l_component_type
201700 , p_component_code => l_component_code
201701 , p_component_type_code => l_component_type_code
201702 , p_component_appl_id => l_component_appl_id
201703 , p_amb_context_code => l_amb_context_code
201704 , p_side => 'NA'
201705 );
201706
201707
201708 --
201709 --
201710 END IF;
201711 --
201712 -- Bug 4922099
201713 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
201714 (NVL(l_enc_upg_option, 'N') = 'O')
201715 ) AND
201716 (l_bflow_method_code = 'PRIOR_ENTRY')
201717 )
201718 THEN
201719 IF
201720 --
201721 1 = 2
201722 --
201723 THEN
201724 xla_accounting_err_pkg.build_message
201725 (p_appli_s_name => 'XLA'
201726 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
201727 ,p_token_1 => 'LINE_NUMBER'
201728 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
201729 ,p_token_2 => 'LINE_TYPE_NAME'
201730 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
201731 l_component_type
201732 ,l_component_code
201733 ,l_component_type_code
201734 ,l_component_appl_id
201735 ,l_amb_context_code
201736 ,l_entity_code
201737 ,l_event_class_code
201738 )
201739 ,p_token_3 => 'OWNER'
201740 ,p_value_3 => xla_lookups_pkg.get_meaning(
201741 p_lookup_type => 'XLA_OWNER_TYPE'
201742 ,p_lookup_code => l_component_type_code
201743 )
201744 ,p_token_4 => 'PRODUCT_NAME'
201745 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
201746 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
201747 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
201748 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
201749 ,p_ae_header_id => NULL
201750 );
201751
201752 IF (C_LEVEL_ERROR>= g_log_level) THEN
201753 trace
201754 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
201755 ,p_level => C_LEVEL_ERROR
201756 ,p_module => l_log_module);
201757 END IF;
201758 END IF;
201759 END IF;
201760 --
201761 --
201762 ------------------------------------------------------------------------------------------------
201763 -- 4219869 Business Flow
201764 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
201765 -- Prior Entry. Currently, the following code is always generated.
201766 ------------------------------------------------------------------------------------------------
201767 XLA_AE_LINES_PKG.ValidateCurrentLine;
201768
201769 ------------------------------------------------------------------------------------
201770 -- 4219869 Business Flow
201771 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
201772 ------------------------------------------------------------------------------------
201773 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
201774
201775 ----------------------------------------------------------------------------------
201776 -- 4219869 Business Flow
201777 -- Update journal entry status -- Need to generate this within IF <condition>
201778 ----------------------------------------------------------------------------------
201779 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
201780 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
201781 ,p_balance_type_code => l_balance_type_code
201782 );
201783
201784 -------------------------------------------------------------------------------------------
201785 -- 4262811 - Generate the Accrual Reversal lines
201786 -------------------------------------------------------------------------------------------
201787 BEGIN
201788 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
201789 (g_array_event(p_event_id).array_value_num('header_index'));
201790 IF l_acc_rev_flag IS NULL THEN
201791 l_acc_rev_flag := 'N';
201792 END IF;
201793 EXCEPTION
201794 WHEN OTHERS THEN
201795 l_acc_rev_flag := 'N';
201796 END;
201797 --
201798 IF (l_acc_rev_flag = 'Y') THEN
201799
201800 -- 4645092 ------------------------------------------------------------------------------
201801 -- To allow MPA report to determine if it should generate report process
201802 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
201803 ------------------------------------------------------------------------------------------
201804
201805 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
201806 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
201807 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
201808 -- call ADRs
201809 -- Bug 4922099
201810 --
201811 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
201812 (NVL(l_actual_upg_option, 'N') = 'O') OR
201813 (NVL(l_enc_upg_option, 'N') = 'O')
201814 )
201815 THEN
201816 NULL;
201817 --
201818 --
201819
201820 l_ccid := AcctDerRule_6(
201821 p_application_id => p_application_id
201822 , p_ae_header_id => l_ae_header_id
201823 , p_source_11 => p_source_11
201824 , x_transaction_coa_id => l_adr_transaction_coa_id
201825 , x_accounting_coa_id => l_adr_accounting_coa_id
201826 , x_value_type_code => l_adr_value_type_code
201827 , p_side => 'NA'
201828 );
201829
201830 xla_ae_lines_pkg.set_ccid(
201831 p_code_combination_id => l_ccid
201832 , p_value_type_code => l_adr_value_type_code
201833 , p_transaction_coa_id => l_adr_transaction_coa_id
201834 , p_accounting_coa_id => l_adr_accounting_coa_id
201835 , p_adr_code => 'CST_DEFAULT'
201836 , p_adr_type_code => 'S'
201837 , p_component_type => l_component_type
201838 , p_component_code => l_component_code
201839 , p_component_type_code => l_component_type_code
201840 , p_component_appl_id => l_component_appl_id
201841 , p_amb_context_code => l_amb_context_code
201842 , p_side => 'NA'
201843 );
201844
201845
201846 --
201847 --
201848 END IF;
201849
201850 --
201851 -- Update the line information that should be overwritten
201852 --
201853 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
201854 p_header_num => 1);
201855 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
201856
201857 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
201858
201859 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
201860 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
201861 END IF;
201862
201863 --
201864 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
201865 --
201866 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
201867 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
201868 ELSE
201869 ---------------------------------------------------------------------------------------------------
201870 -- 4262811a Switch Sign
201871 ---------------------------------------------------------------------------------------------------
201872 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
201873 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
201874 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201875 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
201876 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201877 -- 5132302
201878 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
201879 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
201880
201881 END IF;
201882
201883 -- 4955764
201884 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
201885 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
201886
201887
201888 XLA_AE_LINES_PKG.ValidateCurrentLine;
201889 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
201890
201891 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
201892 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
201893 ,p_balance_type_code => l_balance_type_code);
201894
201895 END IF;
201896
201897 -----------------------------------------------------------------------------------------
201898 -- 4262811 Multiperiod Accounting
201899 -----------------------------------------------------------------------------------------
201900 -- No MPA option is assigned.
201901
201902
201903 END IF;
201904 END IF;
201905 --
201906
201907 --
201908 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
201909 trace
201910 (p_msg => 'END of AcctLineType_368'
201911 ,p_level => C_LEVEL_PROCEDURE
201912 ,p_module => l_log_module);
201913 END IF;
201914 --
201915 EXCEPTION
201916 WHEN xla_exceptions_pkg.application_exception THEN
201917 RAISE;
201918 WHEN OTHERS THEN
201919 xla_exceptions_pkg.raise_message
201920 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_368');
201921 END AcctLineType_368;
201922 --
201923
201924 ---------------------------------------
201925 --
201926 -- PRIVATE FUNCTION
201927 -- AcctLineType_369
201928 --
201929 ---------------------------------------
201930 PROCEDURE AcctLineType_369 (
201931 p_application_id IN NUMBER
201932 ,p_event_id IN NUMBER
201933 ,p_calculate_acctd_flag IN VARCHAR2
201934 ,p_calculate_g_l_flag IN VARCHAR2
201935 ,p_actual_flag IN OUT VARCHAR2
201936 ,p_balance_type_code OUT VARCHAR2
201937 ,p_gain_or_loss_ref OUT VARCHAR2
201938
201939 --TRANSACTION_ID
201940 , p_source_1 IN NUMBER
201941 --Item Concatenated Segments
201942 , p_source_2 IN VARCHAR2
201943 --Transaction Quantity
201944 , p_source_3 IN NUMBER
201945 --Transaction Unit of Measure Code
201946 , p_source_4 IN VARCHAR2
201947 --Inventory Transaction Type Description
201948 , p_source_5 IN VARCHAR2
201949 --Cost Management Default Account
201950 , p_source_11 IN NUMBER
201951 --DISTRIBUTION_IDENTIFIER
201952 , p_source_84 IN NUMBER
201953 --Distribution Type
201954 , p_source_85 IN VARCHAR2
201955 , p_source_85_meaning IN VARCHAR2
201956 --Entered Currency Code
201957 , p_source_88 IN VARCHAR2
201958 --Entered Amount
201959 , p_source_91 IN NUMBER
201960 --Currency Conversion Date
201961 , p_source_92 IN DATE
201962 --Currency Conversion Rate
201963 , p_source_93 IN NUMBER
201964 --Currency Conversion Type
201965 , p_source_94 IN VARCHAR2
201966 --Accounted Amount
201967 , p_source_95 IN NUMBER
201968 --Accounting Line Type
201969 , p_source_97 IN NUMBER
201970 )
201971 IS
201972
201973 l_component_type VARCHAR2(80);
201974 l_component_code VARCHAR2(30);
201975 l_component_type_code VARCHAR2(1);
201976 l_component_appl_id INTEGER;
201977 l_amb_context_code VARCHAR2(30);
201978 l_entity_code VARCHAR2(30);
201979 l_event_class_code VARCHAR2(30);
201980 l_ae_header_id NUMBER;
201981 l_event_type_code VARCHAR2(30);
201982 l_line_definition_code VARCHAR2(30);
201983 l_line_definition_owner_code VARCHAR2(1);
201984 --
201985 -- adr variables
201986 l_segment VARCHAR2(30);
201987 l_ccid NUMBER;
201988 l_adr_transaction_coa_id NUMBER;
201989 l_adr_accounting_coa_id NUMBER;
201990 l_adr_flexfield_segment_code VARCHAR2(30);
201991 l_adr_flex_value_set_id NUMBER;
201992 l_adr_value_type_code VARCHAR2(30);
201993 l_adr_value_combination_id NUMBER;
201994 l_adr_value_segment_code VARCHAR2(30);
201995
201996 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
201997 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
201998 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
201999 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
202000
202001 -- 4262811 Variables ------------------------------------------------------------------------------------------
202002 l_entered_amt_idx NUMBER;
202003 l_accted_amt_idx NUMBER;
202004 l_acc_rev_flag VARCHAR2(1);
202005 l_accrual_line_num NUMBER;
202006 l_tmp_amt NUMBER;
202007 l_acc_rev_natural_side_code VARCHAR2(1);
202008
202009 l_num_entries NUMBER;
202010 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
202011 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
202012 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
202013 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
202014 l_recog_line_1 NUMBER;
202015 l_recog_line_2 NUMBER;
202016
202017 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
202018 l_bflow_applied_to_amt NUMBER; -- 5132302
202019 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
202020
202021 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
202022
202023 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
202024 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
202025
202026 ---------------------------------------------------------------------------------------------------------------
202027
202028
202029 --
202030 -- bulk performance
202031 --
202032 l_balance_type_code VARCHAR2(1);
202033 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
202034 l_log_module VARCHAR2(240);
202035
202036 --
202037 -- Upgrade strategy
202038 --
202039 l_actual_upg_option VARCHAR2(1);
202040 l_enc_upg_option VARCHAR2(1);
202041
202042 --
202043 BEGIN
202044 --
202045 IF g_log_enabled THEN
202046 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_369';
202047 END IF;
202048 --
202049 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
202050
202051 trace
202052 (p_msg => 'BEGIN of AcctLineType_369'
202053 ,p_level => C_LEVEL_PROCEDURE
202054 ,p_module => l_log_module);
202055
202056 END IF;
202057 --
202058 l_component_type := 'AMB_JLT';
202059 l_component_code := 'OFFSET';
202060 l_component_type_code := 'S';
202061 l_component_appl_id := 707;
202062 l_amb_context_code := 'DEFAULT';
202063 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
202064 l_event_class_code := 'WIP_MTL';
202065 l_event_type_code := 'WIP_ASSEMBLY_COMPLETION';
202066 l_line_definition_owner_code := 'S';
202067 l_line_definition_code := 'PI_WIP_ASSEMBLY_COMPLETION';
202068 --
202069 l_balance_type_code := 'A';
202070 l_segment := NULL;
202071 l_ccid := NULL;
202072 l_adr_transaction_coa_id := NULL;
202073 l_adr_accounting_coa_id := NULL;
202074 l_adr_flexfield_segment_code := NULL;
202075 l_adr_flex_value_set_id := NULL;
202076 l_adr_value_type_code := NULL;
202077 l_adr_value_combination_id := NULL;
202078 l_adr_value_segment_code := NULL;
202079
202080 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
202081 l_bflow_class_code := ''; -- 4219869 Business Flow
202082 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
202083 l_budgetary_control_flag := 'N';
202084
202085 l_bflow_applied_to_amt_idx := NULL; -- 5132302
202086 l_bflow_applied_to_amt := NULL; -- 5132302
202087 l_entered_amt_idx := NULL; -- 4262811
202088 l_accted_amt_idx := NULL; -- 4262811
202089 l_acc_rev_flag := NULL; -- 4262811
202090 l_accrual_line_num := NULL; -- 4262811
202091 l_tmp_amt := NULL; -- 4262811
202092 --
202093
202094 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
202095 l_balance_type_code <> 'B' THEN
202096 IF NVL(p_source_97,9E125) = 2
202097 THEN
202098
202099 --
202100 XLA_AE_LINES_PKG.SetNewLine;
202101
202102 p_balance_type_code := l_balance_type_code;
202103 -- set the flag so later we will know whether the gain loss line needs to be created
202104
202105 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
202106 p_actual_flag :='A';
202107 END IF;
202108
202109 --
202110 -- bulk performance
202111 --
202112 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
202113 p_header_num => 0); -- 4262811
202114 --
202115 -- set accounting line options
202116 --
202117 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
202118 p_natural_side_code => 'D'
202119 , p_gain_or_loss_flag => 'N'
202120 , p_gl_transfer_mode_code => 'S'
202121 , p_acct_entry_type_code => 'A'
202122 , p_switch_side_flag => 'Y'
202123 , p_merge_duplicate_code => 'N'
202124 );
202125 --
202126 l_acc_rev_natural_side_code := 'C'; -- 4262811
202127 --
202128 --
202129 -- set accounting line type info
202130 --
202131 xla_ae_lines_pkg.SetAcctLineType
202132 (p_component_type => l_component_type
202133 ,p_event_type_code => l_event_type_code
202134 ,p_line_definition_owner_code => l_line_definition_owner_code
202135 ,p_line_definition_code => l_line_definition_code
202136 ,p_accounting_line_code => l_component_code
202137 ,p_accounting_line_type_code => l_component_type_code
202138 ,p_accounting_line_appl_id => l_component_appl_id
202139 ,p_amb_context_code => l_amb_context_code
202140 ,p_entity_code => l_entity_code
202141 ,p_event_class_code => l_event_class_code);
202142 --
202143 -- set accounting class
202144 --
202145 xla_ae_lines_pkg.SetAcctClass(
202146 p_accounting_class_code => 'OFFSET'
202147 , p_ae_header_id => l_ae_header_id
202148 );
202149
202150 --
202151 -- set rounding class
202152 --
202153 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
202154 'OFFSET';
202155
202156 --
202157 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
202158 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
202159 --
202160 -- bulk performance
202161 --
202162 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
202163
202164 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
202165 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
202166
202167 -- 4955764
202168 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
202169 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
202170
202171 -- 4458381 Public Sector Enh
202172
202173 --
202174 -- set accounting attributes for the line type
202175 --
202176 l_entered_amt_idx := 3;
202177 l_accted_amt_idx := 8;
202178 l_bflow_applied_to_amt_idx := NULL; -- 5132302
202179 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
202180 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
202181 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
202182 l_rec_acct_attrs.array_char_value(2) := p_source_85;
202183 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
202184 l_rec_acct_attrs.array_num_value(3) := p_source_91;
202185 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
202186 l_rec_acct_attrs.array_char_value(4) := p_source_88;
202187 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
202188 l_rec_acct_attrs.array_date_value(5) := p_source_92;
202189 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
202190 l_rec_acct_attrs.array_num_value(6) := p_source_93;
202191 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
202192 l_rec_acct_attrs.array_char_value(7) := p_source_94;
202193 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
202194 l_rec_acct_attrs.array_num_value(8) := p_source_95;
202195
202196 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
202197 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
202198
202199 ---------------------------------------------------------------------------------------------------------------
202200 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
202201 ---------------------------------------------------------------------------------------------------------------
202202 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
202203
202204 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
202205 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
202206
202207 IF xla_accounting_cache_pkg.GetValueChar
202208 (p_source_code => 'LEDGER_CATEGORY_CODE'
202209 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
202210 AND l_bflow_method_code = 'PRIOR_ENTRY'
202211 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
202212 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
202213 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
202214 )
202215 THEN
202216 xla_ae_lines_pkg.BflowUpgEntry
202217 (p_business_method_code => l_bflow_method_code
202218 ,p_business_class_code => l_bflow_class_code
202219 ,p_balance_type => l_balance_type_code);
202220 ELSE
202221 NULL;
202222 -- No business flow processing for business flow method of NONE.
202223 END IF;
202224
202225 --
202226 -- call analytical criteria
202227 --
202228
202229 --
202230 -- call description
202231 --
202232
202233 xla_ae_lines_pkg.SetLineDescription(
202234 p_ae_header_id => l_ae_header_id
202235 ,p_description => Description_1 (
202236 p_application_id => p_application_id
202237 , p_ae_header_id => l_ae_header_id
202238 , p_source_1 => p_source_1
202239 , p_source_2 => p_source_2
202240 , p_source_3 => p_source_3
202241 , p_source_4 => p_source_4
202242 , p_source_5 => p_source_5
202243 )
202244 );
202245
202246
202247 --
202248 -- call ADRs
202249 -- Bug 4922099
202250 --
202251 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
202252 (NVL(l_actual_upg_option, 'N') = 'O') OR
202253 (NVL(l_enc_upg_option, 'N') = 'O')
202254 )
202255 THEN
202256 NULL;
202257 --
202258 --
202259
202260 l_ccid := AcctDerRule_6(
202261 p_application_id => p_application_id
202262 , p_ae_header_id => l_ae_header_id
202263 , p_source_11 => p_source_11
202264 , x_transaction_coa_id => l_adr_transaction_coa_id
202265 , x_accounting_coa_id => l_adr_accounting_coa_id
202266 , x_value_type_code => l_adr_value_type_code
202267 , p_side => 'NA'
202268 );
202269
202270 xla_ae_lines_pkg.set_ccid(
202271 p_code_combination_id => l_ccid
202272 , p_value_type_code => l_adr_value_type_code
202273 , p_transaction_coa_id => l_adr_transaction_coa_id
202274 , p_accounting_coa_id => l_adr_accounting_coa_id
202275 , p_adr_code => 'CST_DEFAULT'
202276 , p_adr_type_code => 'S'
202277 , p_component_type => l_component_type
202278 , p_component_code => l_component_code
202279 , p_component_type_code => l_component_type_code
202280 , p_component_appl_id => l_component_appl_id
202281 , p_amb_context_code => l_amb_context_code
202282 , p_side => 'NA'
202283 );
202284
202285
202286 --
202287 --
202288 END IF;
202289 --
202290 -- Bug 4922099
202291 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
202292 (NVL(l_enc_upg_option, 'N') = 'O')
202293 ) AND
202294 (l_bflow_method_code = 'PRIOR_ENTRY')
202295 )
202296 THEN
202297 IF
202298 --
202299 1 = 2
202300 --
202301 THEN
202302 xla_accounting_err_pkg.build_message
202303 (p_appli_s_name => 'XLA'
202304 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
202305 ,p_token_1 => 'LINE_NUMBER'
202306 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
202307 ,p_token_2 => 'LINE_TYPE_NAME'
202308 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
202309 l_component_type
202310 ,l_component_code
202311 ,l_component_type_code
202312 ,l_component_appl_id
202313 ,l_amb_context_code
202314 ,l_entity_code
202315 ,l_event_class_code
202316 )
202317 ,p_token_3 => 'OWNER'
202318 ,p_value_3 => xla_lookups_pkg.get_meaning(
202319 p_lookup_type => 'XLA_OWNER_TYPE'
202320 ,p_lookup_code => l_component_type_code
202321 )
202322 ,p_token_4 => 'PRODUCT_NAME'
202323 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
202324 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
202325 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
202326 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
202327 ,p_ae_header_id => NULL
202328 );
202329
202330 IF (C_LEVEL_ERROR>= g_log_level) THEN
202331 trace
202332 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
202333 ,p_level => C_LEVEL_ERROR
202334 ,p_module => l_log_module);
202335 END IF;
202336 END IF;
202337 END IF;
202338 --
202339 --
202340 ------------------------------------------------------------------------------------------------
202341 -- 4219869 Business Flow
202342 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
202343 -- Prior Entry. Currently, the following code is always generated.
202344 ------------------------------------------------------------------------------------------------
202345 XLA_AE_LINES_PKG.ValidateCurrentLine;
202346
202347 ------------------------------------------------------------------------------------
202348 -- 4219869 Business Flow
202349 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
202350 ------------------------------------------------------------------------------------
202351 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
202352
202353 ----------------------------------------------------------------------------------
202354 -- 4219869 Business Flow
202355 -- Update journal entry status -- Need to generate this within IF <condition>
202356 ----------------------------------------------------------------------------------
202357 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
202358 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
202359 ,p_balance_type_code => l_balance_type_code
202360 );
202361
202362 -------------------------------------------------------------------------------------------
202363 -- 4262811 - Generate the Accrual Reversal lines
202364 -------------------------------------------------------------------------------------------
202365 BEGIN
202366 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
202367 (g_array_event(p_event_id).array_value_num('header_index'));
202368 IF l_acc_rev_flag IS NULL THEN
202369 l_acc_rev_flag := 'N';
202370 END IF;
202371 EXCEPTION
202372 WHEN OTHERS THEN
202373 l_acc_rev_flag := 'N';
202374 END;
202375 --
202376 IF (l_acc_rev_flag = 'Y') THEN
202377
202378 -- 4645092 ------------------------------------------------------------------------------
202379 -- To allow MPA report to determine if it should generate report process
202380 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
202381 ------------------------------------------------------------------------------------------
202382
202383 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
202384 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
202385 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
202386 -- call ADRs
202387 -- Bug 4922099
202388 --
202389 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
202390 (NVL(l_actual_upg_option, 'N') = 'O') OR
202391 (NVL(l_enc_upg_option, 'N') = 'O')
202392 )
202393 THEN
202394 NULL;
202395 --
202396 --
202397
202398 l_ccid := AcctDerRule_6(
202399 p_application_id => p_application_id
202400 , p_ae_header_id => l_ae_header_id
202401 , p_source_11 => p_source_11
202402 , x_transaction_coa_id => l_adr_transaction_coa_id
202403 , x_accounting_coa_id => l_adr_accounting_coa_id
202404 , x_value_type_code => l_adr_value_type_code
202405 , p_side => 'NA'
202406 );
202407
202408 xla_ae_lines_pkg.set_ccid(
202409 p_code_combination_id => l_ccid
202410 , p_value_type_code => l_adr_value_type_code
202411 , p_transaction_coa_id => l_adr_transaction_coa_id
202412 , p_accounting_coa_id => l_adr_accounting_coa_id
202413 , p_adr_code => 'CST_DEFAULT'
202414 , p_adr_type_code => 'S'
202415 , p_component_type => l_component_type
202416 , p_component_code => l_component_code
202417 , p_component_type_code => l_component_type_code
202418 , p_component_appl_id => l_component_appl_id
202419 , p_amb_context_code => l_amb_context_code
202420 , p_side => 'NA'
202421 );
202422
202423
202424 --
202425 --
202426 END IF;
202427
202428 --
202429 -- Update the line information that should be overwritten
202430 --
202431 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
202432 p_header_num => 1);
202433 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
202434
202435 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
202436
202437 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
202438 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
202439 END IF;
202440
202441 --
202442 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
202443 --
202444 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
202445 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
202446 ELSE
202447 ---------------------------------------------------------------------------------------------------
202448 -- 4262811a Switch Sign
202449 ---------------------------------------------------------------------------------------------------
202450 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
202451 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
202452 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
202453 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
202454 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
202455 -- 5132302
202456 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
202457 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
202458
202459 END IF;
202460
202461 -- 4955764
202462 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
202463 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
202464
202465
202466 XLA_AE_LINES_PKG.ValidateCurrentLine;
202467 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
202468
202469 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
202470 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
202471 ,p_balance_type_code => l_balance_type_code);
202472
202473 END IF;
202474
202475 -----------------------------------------------------------------------------------------
202476 -- 4262811 Multiperiod Accounting
202477 -----------------------------------------------------------------------------------------
202478 -- No MPA option is assigned.
202479
202480
202481 END IF;
202482 END IF;
202483 --
202484
202485 --
202486 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
202487 trace
202488 (p_msg => 'END of AcctLineType_369'
202489 ,p_level => C_LEVEL_PROCEDURE
202490 ,p_module => l_log_module);
202491 END IF;
202492 --
202493 EXCEPTION
202494 WHEN xla_exceptions_pkg.application_exception THEN
202495 RAISE;
202496 WHEN OTHERS THEN
202497 xla_exceptions_pkg.raise_message
202498 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_369');
202499 END AcctLineType_369;
202500 --
202501
202502 ---------------------------------------
202503 --
202504 -- PRIVATE FUNCTION
202505 -- AcctLineType_370
202506 --
202507 ---------------------------------------
202508 PROCEDURE AcctLineType_370 (
202509 p_application_id IN NUMBER
202510 ,p_event_id IN NUMBER
202511 ,p_calculate_acctd_flag IN VARCHAR2
202512 ,p_calculate_g_l_flag IN VARCHAR2
202513 ,p_actual_flag IN OUT VARCHAR2
202514 ,p_balance_type_code OUT VARCHAR2
202515 ,p_gain_or_loss_ref OUT VARCHAR2
202516
202517 --Cost Management Default Account
202518 , p_source_11 IN NUMBER
202519 --DISTRIBUTION_IDENTIFIER
202520 , p_source_84 IN NUMBER
202521 --Distribution Type
202522 , p_source_85 IN VARCHAR2
202523 , p_source_85_meaning IN VARCHAR2
202524 --Entered Currency Code
202525 , p_source_88 IN VARCHAR2
202526 --Entered Amount
202527 , p_source_91 IN NUMBER
202528 --Currency Conversion Date
202529 , p_source_92 IN DATE
202530 --Currency Conversion Rate
202531 , p_source_93 IN NUMBER
202532 --Accounted Amount
202533 , p_source_95 IN NUMBER
202534 --Accounting Line Type
202535 , p_source_97 IN NUMBER
202536 )
202537 IS
202538
202539 l_component_type VARCHAR2(80);
202540 l_component_code VARCHAR2(30);
202541 l_component_type_code VARCHAR2(1);
202542 l_component_appl_id INTEGER;
202543 l_amb_context_code VARCHAR2(30);
202544 l_entity_code VARCHAR2(30);
202545 l_event_class_code VARCHAR2(30);
202546 l_ae_header_id NUMBER;
202547 l_event_type_code VARCHAR2(30);
202548 l_line_definition_code VARCHAR2(30);
202549 l_line_definition_owner_code VARCHAR2(1);
202550 --
202551 -- adr variables
202552 l_segment VARCHAR2(30);
202553 l_ccid NUMBER;
202554 l_adr_transaction_coa_id NUMBER;
202555 l_adr_accounting_coa_id NUMBER;
202556 l_adr_flexfield_segment_code VARCHAR2(30);
202557 l_adr_flex_value_set_id NUMBER;
202558 l_adr_value_type_code VARCHAR2(30);
202559 l_adr_value_combination_id NUMBER;
202560 l_adr_value_segment_code VARCHAR2(30);
202561
202562 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
202563 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
202564 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
202565 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
202566
202567 -- 4262811 Variables ------------------------------------------------------------------------------------------
202568 l_entered_amt_idx NUMBER;
202569 l_accted_amt_idx NUMBER;
202570 l_acc_rev_flag VARCHAR2(1);
202571 l_accrual_line_num NUMBER;
202572 l_tmp_amt NUMBER;
202573 l_acc_rev_natural_side_code VARCHAR2(1);
202574
202575 l_num_entries NUMBER;
202576 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
202577 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
202578 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
202579 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
202580 l_recog_line_1 NUMBER;
202581 l_recog_line_2 NUMBER;
202582
202583 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
202584 l_bflow_applied_to_amt NUMBER; -- 5132302
202585 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
202586
202587 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
202588
202589 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
202590 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
202591
202592 ---------------------------------------------------------------------------------------------------------------
202593
202594
202595 --
202596 -- bulk performance
202597 --
202598 l_balance_type_code VARCHAR2(1);
202599 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
202600 l_log_module VARCHAR2(240);
202601
202602 --
202603 -- Upgrade strategy
202604 --
202605 l_actual_upg_option VARCHAR2(1);
202606 l_enc_upg_option VARCHAR2(1);
202607
202608 --
202609 BEGIN
202610 --
202611 IF g_log_enabled THEN
202612 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_370';
202613 END IF;
202614 --
202615 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
202616
202617 trace
202618 (p_msg => 'BEGIN of AcctLineType_370'
202619 ,p_level => C_LEVEL_PROCEDURE
202620 ,p_module => l_log_module);
202621
202622 END IF;
202623 --
202624 l_component_type := 'AMB_JLT';
202625 l_component_code := 'OVERHEAD_ABSORPTION';
202626 l_component_type_code := 'S';
202627 l_component_appl_id := 707;
202628 l_amb_context_code := 'DEFAULT';
202629 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
202630 l_event_class_code := 'OSP';
202631 l_event_type_code := 'IPV_TRANSFER_WO';
202632 l_line_definition_owner_code := 'S';
202633 l_line_definition_code := 'PI_IPV_TRANSFER_WO';
202634 --
202635 l_balance_type_code := 'A';
202636 l_segment := NULL;
202637 l_ccid := NULL;
202638 l_adr_transaction_coa_id := NULL;
202639 l_adr_accounting_coa_id := NULL;
202640 l_adr_flexfield_segment_code := NULL;
202641 l_adr_flex_value_set_id := NULL;
202642 l_adr_value_type_code := NULL;
202643 l_adr_value_combination_id := NULL;
202644 l_adr_value_segment_code := NULL;
202645
202646 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
202647 l_bflow_class_code := ''; -- 4219869 Business Flow
202648 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
202649 l_budgetary_control_flag := 'N';
202650
202651 l_bflow_applied_to_amt_idx := NULL; -- 5132302
202652 l_bflow_applied_to_amt := NULL; -- 5132302
202653 l_entered_amt_idx := NULL; -- 4262811
202654 l_accted_amt_idx := NULL; -- 4262811
202655 l_acc_rev_flag := NULL; -- 4262811
202656 l_accrual_line_num := NULL; -- 4262811
202657 l_tmp_amt := NULL; -- 4262811
202658 --
202659
202660 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
202661 l_balance_type_code <> 'B' THEN
202662 IF NVL(p_source_97,9E125) = 3
202663 THEN
202664
202665 --
202666 XLA_AE_LINES_PKG.SetNewLine;
202667
202668 p_balance_type_code := l_balance_type_code;
202669 -- set the flag so later we will know whether the gain loss line needs to be created
202670
202671 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
202672 p_actual_flag :='A';
202673 END IF;
202674
202675 --
202676 -- bulk performance
202677 --
202678 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
202679 p_header_num => 0); -- 4262811
202680 --
202681 -- set accounting line options
202682 --
202683 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
202684 p_natural_side_code => 'D'
202685 , p_gain_or_loss_flag => 'N'
202686 , p_gl_transfer_mode_code => 'S'
202687 , p_acct_entry_type_code => 'A'
202688 , p_switch_side_flag => 'Y'
202689 , p_merge_duplicate_code => 'N'
202690 );
202691 --
202692 l_acc_rev_natural_side_code := 'C'; -- 4262811
202693 --
202694 --
202695 -- set accounting line type info
202696 --
202697 xla_ae_lines_pkg.SetAcctLineType
202698 (p_component_type => l_component_type
202699 ,p_event_type_code => l_event_type_code
202700 ,p_line_definition_owner_code => l_line_definition_owner_code
202701 ,p_line_definition_code => l_line_definition_code
202702 ,p_accounting_line_code => l_component_code
202703 ,p_accounting_line_type_code => l_component_type_code
202704 ,p_accounting_line_appl_id => l_component_appl_id
202705 ,p_amb_context_code => l_amb_context_code
202706 ,p_entity_code => l_entity_code
202707 ,p_event_class_code => l_event_class_code);
202708 --
202709 -- set accounting class
202710 --
202711 xla_ae_lines_pkg.SetAcctClass(
202712 p_accounting_class_code => 'OVERHEAD_ABSORPTION'
202713 , p_ae_header_id => l_ae_header_id
202714 );
202715
202716 --
202717 -- set rounding class
202718 --
202719 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
202720 'OVERHEAD_ABSORPTION';
202721
202722 --
202723 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
202724 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
202725 --
202726 -- bulk performance
202727 --
202728 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
202729
202730 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
202731 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
202732
202733 -- 4955764
202734 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
202735 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
202736
202737 -- 4458381 Public Sector Enh
202738
202739 --
202740 -- set accounting attributes for the line type
202741 --
202742 l_entered_amt_idx := 3;
202743 l_accted_amt_idx := 8;
202744 l_bflow_applied_to_amt_idx := NULL; -- 5132302
202745 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
202746 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
202747 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
202748 l_rec_acct_attrs.array_char_value(2) := p_source_85;
202749 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
202750 l_rec_acct_attrs.array_num_value(3) := p_source_91;
202751 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
202752 l_rec_acct_attrs.array_char_value(4) := p_source_88;
202753 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
202754 l_rec_acct_attrs.array_date_value(5) := p_source_92;
202755 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
202756 l_rec_acct_attrs.array_num_value(6) := p_source_93;
202757 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
202758 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
202759 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
202760 l_rec_acct_attrs.array_num_value(8) := p_source_95;
202761
202762 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
202763 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
202764
202765 ---------------------------------------------------------------------------------------------------------------
202766 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
202767 ---------------------------------------------------------------------------------------------------------------
202768 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
202769
202770 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
202771 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
202772
202773 IF xla_accounting_cache_pkg.GetValueChar
202774 (p_source_code => 'LEDGER_CATEGORY_CODE'
202775 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
202776 AND l_bflow_method_code = 'PRIOR_ENTRY'
202777 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
202778 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
202779 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
202780 )
202781 THEN
202782 xla_ae_lines_pkg.BflowUpgEntry
202783 (p_business_method_code => l_bflow_method_code
202784 ,p_business_class_code => l_bflow_class_code
202785 ,p_balance_type => l_balance_type_code);
202786 ELSE
202787 NULL;
202788 -- No business flow processing for business flow method of NONE.
202789 END IF;
202790
202791 --
202792 -- call analytical criteria
202793 --
202794
202795 --
202796 -- call description
202797 --
202798 -- No description or it is inherited.
202799 --
202800 -- call ADRs
202801 -- Bug 4922099
202802 --
202803 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
202804 (NVL(l_actual_upg_option, 'N') = 'O') OR
202805 (NVL(l_enc_upg_option, 'N') = 'O')
202806 )
202807 THEN
202808 NULL;
202809 --
202810 --
202811
202812 l_ccid := AcctDerRule_6(
202813 p_application_id => p_application_id
202814 , p_ae_header_id => l_ae_header_id
202815 , p_source_11 => p_source_11
202816 , x_transaction_coa_id => l_adr_transaction_coa_id
202817 , x_accounting_coa_id => l_adr_accounting_coa_id
202818 , x_value_type_code => l_adr_value_type_code
202819 , p_side => 'NA'
202820 );
202821
202822 xla_ae_lines_pkg.set_ccid(
202823 p_code_combination_id => l_ccid
202824 , p_value_type_code => l_adr_value_type_code
202825 , p_transaction_coa_id => l_adr_transaction_coa_id
202826 , p_accounting_coa_id => l_adr_accounting_coa_id
202827 , p_adr_code => 'CST_DEFAULT'
202828 , p_adr_type_code => 'S'
202829 , p_component_type => l_component_type
202830 , p_component_code => l_component_code
202831 , p_component_type_code => l_component_type_code
202832 , p_component_appl_id => l_component_appl_id
202833 , p_amb_context_code => l_amb_context_code
202834 , p_side => 'NA'
202835 );
202836
202837
202838 --
202839 --
202840 END IF;
202841 --
202842 -- Bug 4922099
202843 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
202844 (NVL(l_enc_upg_option, 'N') = 'O')
202845 ) AND
202846 (l_bflow_method_code = 'PRIOR_ENTRY')
202847 )
202848 THEN
202849 IF
202850 --
202851 1 = 2
202852 --
202853 THEN
202854 xla_accounting_err_pkg.build_message
202855 (p_appli_s_name => 'XLA'
202856 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
202857 ,p_token_1 => 'LINE_NUMBER'
202858 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
202859 ,p_token_2 => 'LINE_TYPE_NAME'
202860 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
202861 l_component_type
202862 ,l_component_code
202863 ,l_component_type_code
202864 ,l_component_appl_id
202865 ,l_amb_context_code
202866 ,l_entity_code
202867 ,l_event_class_code
202868 )
202869 ,p_token_3 => 'OWNER'
202870 ,p_value_3 => xla_lookups_pkg.get_meaning(
202871 p_lookup_type => 'XLA_OWNER_TYPE'
202872 ,p_lookup_code => l_component_type_code
202873 )
202874 ,p_token_4 => 'PRODUCT_NAME'
202875 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
202876 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
202877 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
202878 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
202879 ,p_ae_header_id => NULL
202880 );
202881
202882 IF (C_LEVEL_ERROR>= g_log_level) THEN
202883 trace
202884 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
202885 ,p_level => C_LEVEL_ERROR
202886 ,p_module => l_log_module);
202887 END IF;
202888 END IF;
202889 END IF;
202890 --
202891 --
202892 ------------------------------------------------------------------------------------------------
202893 -- 4219869 Business Flow
202894 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
202895 -- Prior Entry. Currently, the following code is always generated.
202896 ------------------------------------------------------------------------------------------------
202897 XLA_AE_LINES_PKG.ValidateCurrentLine;
202898
202899 ------------------------------------------------------------------------------------
202900 -- 4219869 Business Flow
202901 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
202902 ------------------------------------------------------------------------------------
202903 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
202904
202905 ----------------------------------------------------------------------------------
202906 -- 4219869 Business Flow
202907 -- Update journal entry status -- Need to generate this within IF <condition>
202908 ----------------------------------------------------------------------------------
202909 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
202910 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
202911 ,p_balance_type_code => l_balance_type_code
202912 );
202913
202914 -------------------------------------------------------------------------------------------
202915 -- 4262811 - Generate the Accrual Reversal lines
202916 -------------------------------------------------------------------------------------------
202917 BEGIN
202918 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
202919 (g_array_event(p_event_id).array_value_num('header_index'));
202920 IF l_acc_rev_flag IS NULL THEN
202921 l_acc_rev_flag := 'N';
202922 END IF;
202923 EXCEPTION
202924 WHEN OTHERS THEN
202925 l_acc_rev_flag := 'N';
202926 END;
202927 --
202928 IF (l_acc_rev_flag = 'Y') THEN
202929
202930 -- 4645092 ------------------------------------------------------------------------------
202931 -- To allow MPA report to determine if it should generate report process
202932 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
202933 ------------------------------------------------------------------------------------------
202934
202935 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
202936 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
202937 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
202938 -- call ADRs
202939 -- Bug 4922099
202940 --
202941 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
202942 (NVL(l_actual_upg_option, 'N') = 'O') OR
202943 (NVL(l_enc_upg_option, 'N') = 'O')
202944 )
202945 THEN
202946 NULL;
202947 --
202948 --
202949
202950 l_ccid := AcctDerRule_6(
202951 p_application_id => p_application_id
202952 , p_ae_header_id => l_ae_header_id
202953 , p_source_11 => p_source_11
202954 , x_transaction_coa_id => l_adr_transaction_coa_id
202955 , x_accounting_coa_id => l_adr_accounting_coa_id
202956 , x_value_type_code => l_adr_value_type_code
202957 , p_side => 'NA'
202958 );
202959
202960 xla_ae_lines_pkg.set_ccid(
202961 p_code_combination_id => l_ccid
202962 , p_value_type_code => l_adr_value_type_code
202963 , p_transaction_coa_id => l_adr_transaction_coa_id
202964 , p_accounting_coa_id => l_adr_accounting_coa_id
202965 , p_adr_code => 'CST_DEFAULT'
202966 , p_adr_type_code => 'S'
202967 , p_component_type => l_component_type
202968 , p_component_code => l_component_code
202969 , p_component_type_code => l_component_type_code
202970 , p_component_appl_id => l_component_appl_id
202971 , p_amb_context_code => l_amb_context_code
202972 , p_side => 'NA'
202973 );
202974
202975
202976 --
202977 --
202978 END IF;
202979
202980 --
202981 -- Update the line information that should be overwritten
202982 --
202983 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
202984 p_header_num => 1);
202985 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
202986
202987 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
202988
202989 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
202990 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
202991 END IF;
202992
202993 --
202994 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
202995 --
202996 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
202997 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
202998 ELSE
202999 ---------------------------------------------------------------------------------------------------
203000 -- 4262811a Switch Sign
203001 ---------------------------------------------------------------------------------------------------
203002 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
203003 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
203004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203005 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
203006 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203007 -- 5132302
203008 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
203009 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203010
203011 END IF;
203012
203013 -- 4955764
203014 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
203015 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
203016
203017
203018 XLA_AE_LINES_PKG.ValidateCurrentLine;
203019 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
203020
203021 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
203022 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
203023 ,p_balance_type_code => l_balance_type_code);
203024
203025 END IF;
203026
203027 -----------------------------------------------------------------------------------------
203028 -- 4262811 Multiperiod Accounting
203029 -----------------------------------------------------------------------------------------
203030 -- No MPA option is assigned.
203031
203032
203033 END IF;
203034 END IF;
203035 --
203036
203037 --
203038 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
203039 trace
203040 (p_msg => 'END of AcctLineType_370'
203041 ,p_level => C_LEVEL_PROCEDURE
203042 ,p_module => l_log_module);
203043 END IF;
203044 --
203045 EXCEPTION
203046 WHEN xla_exceptions_pkg.application_exception THEN
203047 RAISE;
203048 WHEN OTHERS THEN
203049 xla_exceptions_pkg.raise_message
203050 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_370');
203051 END AcctLineType_370;
203052 --
203053
203054 ---------------------------------------
203055 --
203056 -- PRIVATE FUNCTION
203057 -- AcctLineType_371
203058 --
203059 ---------------------------------------
203060 PROCEDURE AcctLineType_371 (
203061 p_application_id IN NUMBER
203062 ,p_event_id IN NUMBER
203063 ,p_calculate_acctd_flag IN VARCHAR2
203064 ,p_calculate_g_l_flag IN VARCHAR2
203065 ,p_actual_flag IN OUT VARCHAR2
203066 ,p_balance_type_code OUT VARCHAR2
203067 ,p_gain_or_loss_ref OUT VARCHAR2
203068
203069 --TRANSACTION_ID
203070 , p_source_1 IN NUMBER
203071 --Transaction Unit of Measure Code
203072 , p_source_4 IN VARCHAR2
203073 --Primary Quantity of the Transaction
203074 , p_source_6 IN NUMBER
203075 --WIP Transaction Type
203076 , p_source_7 IN NUMBER
203077 , p_source_7_meaning IN VARCHAR2
203078 --Cost Management Default Account
203079 , p_source_11 IN NUMBER
203080 --DISTRIBUTION_IDENTIFIER
203081 , p_source_84 IN NUMBER
203082 --Distribution Type
203083 , p_source_85 IN VARCHAR2
203084 , p_source_85_meaning IN VARCHAR2
203085 --Entered Currency Code
203086 , p_source_88 IN VARCHAR2
203087 --Entered Amount
203088 , p_source_91 IN NUMBER
203089 --Currency Conversion Date
203090 , p_source_92 IN DATE
203091 --Currency Conversion Rate
203092 , p_source_93 IN NUMBER
203093 --Accounted Amount
203094 , p_source_95 IN NUMBER
203095 --Accounting Line Type
203096 , p_source_97 IN NUMBER
203097 )
203098 IS
203099
203100 l_component_type VARCHAR2(80);
203101 l_component_code VARCHAR2(30);
203102 l_component_type_code VARCHAR2(1);
203103 l_component_appl_id INTEGER;
203104 l_amb_context_code VARCHAR2(30);
203105 l_entity_code VARCHAR2(30);
203106 l_event_class_code VARCHAR2(30);
203107 l_ae_header_id NUMBER;
203108 l_event_type_code VARCHAR2(30);
203109 l_line_definition_code VARCHAR2(30);
203110 l_line_definition_owner_code VARCHAR2(1);
203111 --
203112 -- adr variables
203113 l_segment VARCHAR2(30);
203114 l_ccid NUMBER;
203115 l_adr_transaction_coa_id NUMBER;
203116 l_adr_accounting_coa_id NUMBER;
203117 l_adr_flexfield_segment_code VARCHAR2(30);
203118 l_adr_flex_value_set_id NUMBER;
203119 l_adr_value_type_code VARCHAR2(30);
203120 l_adr_value_combination_id NUMBER;
203121 l_adr_value_segment_code VARCHAR2(30);
203122
203123 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
203124 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
203125 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
203126 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
203127
203128 -- 4262811 Variables ------------------------------------------------------------------------------------------
203129 l_entered_amt_idx NUMBER;
203130 l_accted_amt_idx NUMBER;
203131 l_acc_rev_flag VARCHAR2(1);
203132 l_accrual_line_num NUMBER;
203133 l_tmp_amt NUMBER;
203134 l_acc_rev_natural_side_code VARCHAR2(1);
203135
203136 l_num_entries NUMBER;
203137 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
203138 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
203139 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
203140 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
203141 l_recog_line_1 NUMBER;
203142 l_recog_line_2 NUMBER;
203143
203144 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
203145 l_bflow_applied_to_amt NUMBER; -- 5132302
203146 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
203147
203148 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
203149
203150 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
203151 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
203152
203153 ---------------------------------------------------------------------------------------------------------------
203154
203155
203156 --
203157 -- bulk performance
203158 --
203159 l_balance_type_code VARCHAR2(1);
203160 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
203161 l_log_module VARCHAR2(240);
203162
203163 --
203164 -- Upgrade strategy
203165 --
203166 l_actual_upg_option VARCHAR2(1);
203167 l_enc_upg_option VARCHAR2(1);
203168
203169 --
203170 BEGIN
203171 --
203172 IF g_log_enabled THEN
203173 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_371';
203174 END IF;
203175 --
203176 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
203177
203178 trace
203179 (p_msg => 'BEGIN of AcctLineType_371'
203180 ,p_level => C_LEVEL_PROCEDURE
203181 ,p_module => l_log_module);
203182
203183 END IF;
203184 --
203185 l_component_type := 'AMB_JLT';
203186 l_component_code := 'OVERHEAD_ABSORPTION';
203187 l_component_type_code := 'S';
203188 l_component_appl_id := 707;
203189 l_amb_context_code := 'DEFAULT';
203190 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
203191 l_event_class_code := 'OSP';
203192 l_event_type_code := 'OSP';
203193 l_line_definition_owner_code := 'S';
203194 l_line_definition_code := 'PI_OSP';
203195 --
203196 l_balance_type_code := 'A';
203197 l_segment := NULL;
203198 l_ccid := NULL;
203199 l_adr_transaction_coa_id := NULL;
203200 l_adr_accounting_coa_id := NULL;
203201 l_adr_flexfield_segment_code := NULL;
203202 l_adr_flex_value_set_id := NULL;
203203 l_adr_value_type_code := NULL;
203204 l_adr_value_combination_id := NULL;
203205 l_adr_value_segment_code := NULL;
203206
203207 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
203208 l_bflow_class_code := ''; -- 4219869 Business Flow
203209 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
203210 l_budgetary_control_flag := 'N';
203211
203212 l_bflow_applied_to_amt_idx := NULL; -- 5132302
203213 l_bflow_applied_to_amt := NULL; -- 5132302
203214 l_entered_amt_idx := NULL; -- 4262811
203215 l_accted_amt_idx := NULL; -- 4262811
203216 l_acc_rev_flag := NULL; -- 4262811
203217 l_accrual_line_num := NULL; -- 4262811
203218 l_tmp_amt := NULL; -- 4262811
203219 --
203220
203221 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
203222 l_balance_type_code <> 'B' THEN
203223 IF NVL(p_source_97,9E125) = 3
203224 THEN
203225
203226 --
203227 XLA_AE_LINES_PKG.SetNewLine;
203228
203229 p_balance_type_code := l_balance_type_code;
203230 -- set the flag so later we will know whether the gain loss line needs to be created
203231
203232 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
203233 p_actual_flag :='A';
203234 END IF;
203235
203236 --
203237 -- bulk performance
203238 --
203239 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
203240 p_header_num => 0); -- 4262811
203241 --
203242 -- set accounting line options
203243 --
203244 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
203245 p_natural_side_code => 'D'
203246 , p_gain_or_loss_flag => 'N'
203247 , p_gl_transfer_mode_code => 'S'
203248 , p_acct_entry_type_code => 'A'
203249 , p_switch_side_flag => 'Y'
203250 , p_merge_duplicate_code => 'N'
203251 );
203252 --
203253 l_acc_rev_natural_side_code := 'C'; -- 4262811
203254 --
203255 --
203256 -- set accounting line type info
203257 --
203258 xla_ae_lines_pkg.SetAcctLineType
203259 (p_component_type => l_component_type
203260 ,p_event_type_code => l_event_type_code
203261 ,p_line_definition_owner_code => l_line_definition_owner_code
203262 ,p_line_definition_code => l_line_definition_code
203263 ,p_accounting_line_code => l_component_code
203264 ,p_accounting_line_type_code => l_component_type_code
203265 ,p_accounting_line_appl_id => l_component_appl_id
203266 ,p_amb_context_code => l_amb_context_code
203267 ,p_entity_code => l_entity_code
203268 ,p_event_class_code => l_event_class_code);
203269 --
203270 -- set accounting class
203271 --
203272 xla_ae_lines_pkg.SetAcctClass(
203273 p_accounting_class_code => 'OVERHEAD_ABSORPTION'
203274 , p_ae_header_id => l_ae_header_id
203275 );
203276
203277 --
203278 -- set rounding class
203279 --
203280 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
203281 'OVERHEAD_ABSORPTION';
203282
203283 --
203284 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
203285 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
203286 --
203287 -- bulk performance
203288 --
203289 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
203290
203291 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
203292 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
203293
203294 -- 4955764
203295 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
203296 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
203297
203298 -- 4458381 Public Sector Enh
203299
203300 --
203301 -- set accounting attributes for the line type
203302 --
203303 l_entered_amt_idx := 3;
203304 l_accted_amt_idx := 8;
203305 l_bflow_applied_to_amt_idx := NULL; -- 5132302
203306 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
203307 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
203308 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
203309 l_rec_acct_attrs.array_char_value(2) := p_source_85;
203310 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
203311 l_rec_acct_attrs.array_num_value(3) := p_source_91;
203312 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
203313 l_rec_acct_attrs.array_char_value(4) := p_source_88;
203314 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
203315 l_rec_acct_attrs.array_date_value(5) := p_source_92;
203316 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
203317 l_rec_acct_attrs.array_num_value(6) := p_source_93;
203318 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
203319 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
203320 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
203321 l_rec_acct_attrs.array_num_value(8) := p_source_95;
203322
203323 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
203324 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
203325
203326 ---------------------------------------------------------------------------------------------------------------
203327 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
203328 ---------------------------------------------------------------------------------------------------------------
203329 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
203330
203331 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
203332 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
203333
203334 IF xla_accounting_cache_pkg.GetValueChar
203335 (p_source_code => 'LEDGER_CATEGORY_CODE'
203336 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
203337 AND l_bflow_method_code = 'PRIOR_ENTRY'
203338 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
203339 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
203340 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
203341 )
203342 THEN
203343 xla_ae_lines_pkg.BflowUpgEntry
203344 (p_business_method_code => l_bflow_method_code
203345 ,p_business_class_code => l_bflow_class_code
203346 ,p_balance_type => l_balance_type_code);
203347 ELSE
203348 NULL;
203349 -- No business flow processing for business flow method of NONE.
203350 END IF;
203351
203352 --
203353 -- call analytical criteria
203354 --
203355
203356 --
203357 -- call description
203358 --
203359
203360 xla_ae_lines_pkg.SetLineDescription(
203361 p_ae_header_id => l_ae_header_id
203362 ,p_description => Description_2 (
203363 p_application_id => p_application_id
203364 , p_ae_header_id => l_ae_header_id
203365 , p_source_1 => p_source_1
203366 , p_source_4 => p_source_4
203367 , p_source_6 => p_source_6
203368 , p_source_7 => p_source_7
203369 , p_source_7_meaning => p_source_7_meaning
203370 )
203371 );
203372
203373
203374 --
203375 -- call ADRs
203376 -- Bug 4922099
203377 --
203378 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
203379 (NVL(l_actual_upg_option, 'N') = 'O') OR
203380 (NVL(l_enc_upg_option, 'N') = 'O')
203381 )
203382 THEN
203383 NULL;
203384 --
203385 --
203386
203387 l_ccid := AcctDerRule_6(
203388 p_application_id => p_application_id
203389 , p_ae_header_id => l_ae_header_id
203390 , p_source_11 => p_source_11
203391 , x_transaction_coa_id => l_adr_transaction_coa_id
203392 , x_accounting_coa_id => l_adr_accounting_coa_id
203393 , x_value_type_code => l_adr_value_type_code
203394 , p_side => 'NA'
203395 );
203396
203397 xla_ae_lines_pkg.set_ccid(
203398 p_code_combination_id => l_ccid
203399 , p_value_type_code => l_adr_value_type_code
203400 , p_transaction_coa_id => l_adr_transaction_coa_id
203401 , p_accounting_coa_id => l_adr_accounting_coa_id
203402 , p_adr_code => 'CST_DEFAULT'
203403 , p_adr_type_code => 'S'
203404 , p_component_type => l_component_type
203405 , p_component_code => l_component_code
203406 , p_component_type_code => l_component_type_code
203407 , p_component_appl_id => l_component_appl_id
203408 , p_amb_context_code => l_amb_context_code
203409 , p_side => 'NA'
203410 );
203411
203412
203413 --
203414 --
203415 END IF;
203416 --
203417 -- Bug 4922099
203418 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
203419 (NVL(l_enc_upg_option, 'N') = 'O')
203420 ) AND
203421 (l_bflow_method_code = 'PRIOR_ENTRY')
203422 )
203423 THEN
203424 IF
203425 --
203426 1 = 2
203427 --
203428 THEN
203429 xla_accounting_err_pkg.build_message
203430 (p_appli_s_name => 'XLA'
203431 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
203432 ,p_token_1 => 'LINE_NUMBER'
203433 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
203434 ,p_token_2 => 'LINE_TYPE_NAME'
203435 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
203436 l_component_type
203437 ,l_component_code
203438 ,l_component_type_code
203439 ,l_component_appl_id
203440 ,l_amb_context_code
203441 ,l_entity_code
203442 ,l_event_class_code
203443 )
203444 ,p_token_3 => 'OWNER'
203445 ,p_value_3 => xla_lookups_pkg.get_meaning(
203446 p_lookup_type => 'XLA_OWNER_TYPE'
203447 ,p_lookup_code => l_component_type_code
203448 )
203449 ,p_token_4 => 'PRODUCT_NAME'
203450 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
203451 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
203452 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
203453 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
203454 ,p_ae_header_id => NULL
203455 );
203456
203457 IF (C_LEVEL_ERROR>= g_log_level) THEN
203458 trace
203459 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
203460 ,p_level => C_LEVEL_ERROR
203461 ,p_module => l_log_module);
203462 END IF;
203463 END IF;
203464 END IF;
203465 --
203466 --
203467 ------------------------------------------------------------------------------------------------
203468 -- 4219869 Business Flow
203469 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
203470 -- Prior Entry. Currently, the following code is always generated.
203471 ------------------------------------------------------------------------------------------------
203472 XLA_AE_LINES_PKG.ValidateCurrentLine;
203473
203474 ------------------------------------------------------------------------------------
203475 -- 4219869 Business Flow
203476 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
203477 ------------------------------------------------------------------------------------
203478 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
203479
203480 ----------------------------------------------------------------------------------
203481 -- 4219869 Business Flow
203482 -- Update journal entry status -- Need to generate this within IF <condition>
203483 ----------------------------------------------------------------------------------
203484 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
203485 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
203486 ,p_balance_type_code => l_balance_type_code
203487 );
203488
203489 -------------------------------------------------------------------------------------------
203490 -- 4262811 - Generate the Accrual Reversal lines
203491 -------------------------------------------------------------------------------------------
203492 BEGIN
203493 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
203494 (g_array_event(p_event_id).array_value_num('header_index'));
203495 IF l_acc_rev_flag IS NULL THEN
203496 l_acc_rev_flag := 'N';
203497 END IF;
203498 EXCEPTION
203499 WHEN OTHERS THEN
203500 l_acc_rev_flag := 'N';
203501 END;
203502 --
203503 IF (l_acc_rev_flag = 'Y') THEN
203504
203505 -- 4645092 ------------------------------------------------------------------------------
203506 -- To allow MPA report to determine if it should generate report process
203507 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
203508 ------------------------------------------------------------------------------------------
203509
203510 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
203511 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
203512 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
203513 -- call ADRs
203514 -- Bug 4922099
203515 --
203516 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
203517 (NVL(l_actual_upg_option, 'N') = 'O') OR
203518 (NVL(l_enc_upg_option, 'N') = 'O')
203519 )
203520 THEN
203521 NULL;
203522 --
203523 --
203524
203525 l_ccid := AcctDerRule_6(
203526 p_application_id => p_application_id
203527 , p_ae_header_id => l_ae_header_id
203528 , p_source_11 => p_source_11
203529 , x_transaction_coa_id => l_adr_transaction_coa_id
203530 , x_accounting_coa_id => l_adr_accounting_coa_id
203531 , x_value_type_code => l_adr_value_type_code
203532 , p_side => 'NA'
203533 );
203534
203535 xla_ae_lines_pkg.set_ccid(
203536 p_code_combination_id => l_ccid
203537 , p_value_type_code => l_adr_value_type_code
203538 , p_transaction_coa_id => l_adr_transaction_coa_id
203539 , p_accounting_coa_id => l_adr_accounting_coa_id
203540 , p_adr_code => 'CST_DEFAULT'
203541 , p_adr_type_code => 'S'
203542 , p_component_type => l_component_type
203543 , p_component_code => l_component_code
203544 , p_component_type_code => l_component_type_code
203545 , p_component_appl_id => l_component_appl_id
203546 , p_amb_context_code => l_amb_context_code
203547 , p_side => 'NA'
203548 );
203549
203550
203551 --
203552 --
203553 END IF;
203554
203555 --
203556 -- Update the line information that should be overwritten
203557 --
203558 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
203559 p_header_num => 1);
203560 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
203561
203562 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
203563
203564 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
203565 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
203566 END IF;
203567
203568 --
203569 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
203570 --
203571 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
203572 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
203573 ELSE
203574 ---------------------------------------------------------------------------------------------------
203575 -- 4262811a Switch Sign
203576 ---------------------------------------------------------------------------------------------------
203577 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
203578 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
203579 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203580 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
203581 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203582 -- 5132302
203583 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
203584 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
203585
203586 END IF;
203587
203588 -- 4955764
203589 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
203590 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
203591
203592
203593 XLA_AE_LINES_PKG.ValidateCurrentLine;
203594 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
203595
203596 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
203597 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
203598 ,p_balance_type_code => l_balance_type_code);
203599
203600 END IF;
203601
203602 -----------------------------------------------------------------------------------------
203603 -- 4262811 Multiperiod Accounting
203604 -----------------------------------------------------------------------------------------
203605 -- No MPA option is assigned.
203606
203607
203608 END IF;
203609 END IF;
203610 --
203611
203612 --
203613 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
203614 trace
203615 (p_msg => 'END of AcctLineType_371'
203616 ,p_level => C_LEVEL_PROCEDURE
203617 ,p_module => l_log_module);
203618 END IF;
203619 --
203620 EXCEPTION
203621 WHEN xla_exceptions_pkg.application_exception THEN
203622 RAISE;
203623 WHEN OTHERS THEN
203624 xla_exceptions_pkg.raise_message
203625 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_371');
203626 END AcctLineType_371;
203627 --
203628
203629 ---------------------------------------
203630 --
203631 -- PRIVATE FUNCTION
203632 -- AcctLineType_372
203633 --
203634 ---------------------------------------
203635 PROCEDURE AcctLineType_372 (
203636 p_application_id IN NUMBER
203637 ,p_event_id IN NUMBER
203638 ,p_calculate_acctd_flag IN VARCHAR2
203639 ,p_calculate_g_l_flag IN VARCHAR2
203640 ,p_actual_flag IN OUT VARCHAR2
203641 ,p_balance_type_code OUT VARCHAR2
203642 ,p_gain_or_loss_ref OUT VARCHAR2
203643
203644 --Cost Management Default Account
203645 , p_source_11 IN NUMBER
203646 --DISTRIBUTION_IDENTIFIER
203647 , p_source_84 IN NUMBER
203648 --Distribution Type
203649 , p_source_85 IN VARCHAR2
203650 , p_source_85_meaning IN VARCHAR2
203651 --Entered Currency Code
203652 , p_source_88 IN VARCHAR2
203653 --Entered Amount
203654 , p_source_91 IN NUMBER
203655 --Currency Conversion Date
203656 , p_source_92 IN DATE
203657 --Currency Conversion Rate
203658 , p_source_93 IN NUMBER
203659 --Currency Conversion Type
203660 , p_source_94 IN VARCHAR2
203661 --Accounted Amount
203662 , p_source_95 IN NUMBER
203663 --Accounting Line Type
203664 , p_source_97 IN NUMBER
203665 )
203666 IS
203667
203668 l_component_type VARCHAR2(80);
203669 l_component_code VARCHAR2(30);
203670 l_component_type_code VARCHAR2(1);
203671 l_component_appl_id INTEGER;
203672 l_amb_context_code VARCHAR2(30);
203673 l_entity_code VARCHAR2(30);
203674 l_event_class_code VARCHAR2(30);
203675 l_ae_header_id NUMBER;
203676 l_event_type_code VARCHAR2(30);
203677 l_line_definition_code VARCHAR2(30);
203678 l_line_definition_owner_code VARCHAR2(1);
203679 --
203680 -- adr variables
203681 l_segment VARCHAR2(30);
203682 l_ccid NUMBER;
203683 l_adr_transaction_coa_id NUMBER;
203684 l_adr_accounting_coa_id NUMBER;
203685 l_adr_flexfield_segment_code VARCHAR2(30);
203686 l_adr_flex_value_set_id NUMBER;
203687 l_adr_value_type_code VARCHAR2(30);
203688 l_adr_value_combination_id NUMBER;
203689 l_adr_value_segment_code VARCHAR2(30);
203690
203691 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
203692 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
203693 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
203694 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
203695
203696 -- 4262811 Variables ------------------------------------------------------------------------------------------
203697 l_entered_amt_idx NUMBER;
203698 l_accted_amt_idx NUMBER;
203699 l_acc_rev_flag VARCHAR2(1);
203700 l_accrual_line_num NUMBER;
203701 l_tmp_amt NUMBER;
203702 l_acc_rev_natural_side_code VARCHAR2(1);
203703
203704 l_num_entries NUMBER;
203705 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
203706 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
203707 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
203708 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
203709 l_recog_line_1 NUMBER;
203710 l_recog_line_2 NUMBER;
203711
203712 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
203713 l_bflow_applied_to_amt NUMBER; -- 5132302
203714 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
203715
203716 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
203717
203718 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
203719 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
203720
203721 ---------------------------------------------------------------------------------------------------------------
203722
203723
203724 --
203725 -- bulk performance
203726 --
203727 l_balance_type_code VARCHAR2(1);
203728 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
203729 l_log_module VARCHAR2(240);
203730
203731 --
203732 -- Upgrade strategy
203733 --
203734 l_actual_upg_option VARCHAR2(1);
203735 l_enc_upg_option VARCHAR2(1);
203736
203737 --
203738 BEGIN
203739 --
203740 IF g_log_enabled THEN
203741 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_372';
203742 END IF;
203743 --
203744 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
203745
203746 trace
203747 (p_msg => 'BEGIN of AcctLineType_372'
203748 ,p_level => C_LEVEL_PROCEDURE
203749 ,p_module => l_log_module);
203750
203751 END IF;
203752 --
203753 l_component_type := 'AMB_JLT';
203754 l_component_code := 'OVERHEAD_ABSORPTION';
203755 l_component_type_code := 'S';
203756 l_component_appl_id := 707;
203757 l_amb_context_code := 'DEFAULT';
203758 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
203759 l_event_class_code := 'ABSORPTION';
203760 l_event_type_code := 'ABSORPTION_ALL';
203761 l_line_definition_owner_code := 'S';
203762 l_line_definition_code := 'ABSORPTION';
203763 --
203764 l_balance_type_code := 'A';
203765 l_segment := NULL;
203766 l_ccid := NULL;
203767 l_adr_transaction_coa_id := NULL;
203768 l_adr_accounting_coa_id := NULL;
203769 l_adr_flexfield_segment_code := NULL;
203770 l_adr_flex_value_set_id := NULL;
203771 l_adr_value_type_code := NULL;
203772 l_adr_value_combination_id := NULL;
203773 l_adr_value_segment_code := NULL;
203774
203775 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
203776 l_bflow_class_code := ''; -- 4219869 Business Flow
203777 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
203778 l_budgetary_control_flag := 'N';
203779
203780 l_bflow_applied_to_amt_idx := NULL; -- 5132302
203781 l_bflow_applied_to_amt := NULL; -- 5132302
203782 l_entered_amt_idx := NULL; -- 4262811
203783 l_accted_amt_idx := NULL; -- 4262811
203784 l_acc_rev_flag := NULL; -- 4262811
203785 l_accrual_line_num := NULL; -- 4262811
203786 l_tmp_amt := NULL; -- 4262811
203787 --
203788
203789 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
203790 l_balance_type_code <> 'B' THEN
203791 IF NVL(p_source_97,9E125) = 3
203792 THEN
203793
203794 --
203795 XLA_AE_LINES_PKG.SetNewLine;
203796
203797 p_balance_type_code := l_balance_type_code;
203798 -- set the flag so later we will know whether the gain loss line needs to be created
203799
203800 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
203801 p_actual_flag :='A';
203802 END IF;
203803
203804 --
203805 -- bulk performance
203806 --
203807 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
203808 p_header_num => 0); -- 4262811
203809 --
203810 -- set accounting line options
203811 --
203812 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
203813 p_natural_side_code => 'D'
203814 , p_gain_or_loss_flag => 'N'
203815 , p_gl_transfer_mode_code => 'S'
203816 , p_acct_entry_type_code => 'A'
203817 , p_switch_side_flag => 'Y'
203818 , p_merge_duplicate_code => 'N'
203819 );
203820 --
203821 l_acc_rev_natural_side_code := 'C'; -- 4262811
203822 --
203823 --
203824 -- set accounting line type info
203825 --
203826 xla_ae_lines_pkg.SetAcctLineType
203827 (p_component_type => l_component_type
203828 ,p_event_type_code => l_event_type_code
203829 ,p_line_definition_owner_code => l_line_definition_owner_code
203830 ,p_line_definition_code => l_line_definition_code
203831 ,p_accounting_line_code => l_component_code
203832 ,p_accounting_line_type_code => l_component_type_code
203833 ,p_accounting_line_appl_id => l_component_appl_id
203834 ,p_amb_context_code => l_amb_context_code
203835 ,p_entity_code => l_entity_code
203836 ,p_event_class_code => l_event_class_code);
203837 --
203838 -- set accounting class
203839 --
203840 xla_ae_lines_pkg.SetAcctClass(
203841 p_accounting_class_code => 'OVERHEAD_ABSORPTION'
203842 , p_ae_header_id => l_ae_header_id
203843 );
203844
203845 --
203846 -- set rounding class
203847 --
203848 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
203849 'OVERHEAD_ABSORPTION';
203850
203851 --
203852 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
203853 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
203854 --
203855 -- bulk performance
203856 --
203857 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
203858
203859 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
203860 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
203861
203862 -- 4955764
203863 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
203864 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
203865
203866 -- 4458381 Public Sector Enh
203867
203868 --
203869 -- set accounting attributes for the line type
203870 --
203871 l_entered_amt_idx := 3;
203872 l_accted_amt_idx := 8;
203873 l_bflow_applied_to_amt_idx := NULL; -- 5132302
203874 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
203875 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
203876 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
203877 l_rec_acct_attrs.array_char_value(2) := p_source_85;
203878 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
203879 l_rec_acct_attrs.array_num_value(3) := p_source_91;
203880 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
203881 l_rec_acct_attrs.array_char_value(4) := p_source_88;
203882 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
203883 l_rec_acct_attrs.array_date_value(5) := p_source_92;
203884 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
203885 l_rec_acct_attrs.array_num_value(6) := p_source_93;
203886 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
203887 l_rec_acct_attrs.array_char_value(7) := p_source_94;
203888 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
203889 l_rec_acct_attrs.array_num_value(8) := p_source_95;
203890
203891 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
203892 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
203893
203894 ---------------------------------------------------------------------------------------------------------------
203895 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
203896 ---------------------------------------------------------------------------------------------------------------
203897 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
203898
203899 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
203900 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
203901
203902 IF xla_accounting_cache_pkg.GetValueChar
203903 (p_source_code => 'LEDGER_CATEGORY_CODE'
203904 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
203905 AND l_bflow_method_code = 'PRIOR_ENTRY'
203906 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
203907 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
203908 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
203909 )
203910 THEN
203911 xla_ae_lines_pkg.BflowUpgEntry
203912 (p_business_method_code => l_bflow_method_code
203913 ,p_business_class_code => l_bflow_class_code
203914 ,p_balance_type => l_balance_type_code);
203915 ELSE
203916 NULL;
203917 -- No business flow processing for business flow method of NONE.
203918 END IF;
203919
203920 --
203921 -- call analytical criteria
203922 --
203923
203924 --
203925 -- call description
203926 --
203927 -- No description or it is inherited.
203928 --
203929 -- call ADRs
203930 -- Bug 4922099
203931 --
203932 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
203933 (NVL(l_actual_upg_option, 'N') = 'O') OR
203934 (NVL(l_enc_upg_option, 'N') = 'O')
203935 )
203936 THEN
203937 NULL;
203938 --
203939 --
203940
203941 l_ccid := AcctDerRule_6(
203942 p_application_id => p_application_id
203943 , p_ae_header_id => l_ae_header_id
203944 , p_source_11 => p_source_11
203945 , x_transaction_coa_id => l_adr_transaction_coa_id
203946 , x_accounting_coa_id => l_adr_accounting_coa_id
203947 , x_value_type_code => l_adr_value_type_code
203948 , p_side => 'NA'
203949 );
203950
203951 xla_ae_lines_pkg.set_ccid(
203952 p_code_combination_id => l_ccid
203953 , p_value_type_code => l_adr_value_type_code
203954 , p_transaction_coa_id => l_adr_transaction_coa_id
203955 , p_accounting_coa_id => l_adr_accounting_coa_id
203956 , p_adr_code => 'CST_DEFAULT'
203957 , p_adr_type_code => 'S'
203958 , p_component_type => l_component_type
203959 , p_component_code => l_component_code
203960 , p_component_type_code => l_component_type_code
203961 , p_component_appl_id => l_component_appl_id
203962 , p_amb_context_code => l_amb_context_code
203963 , p_side => 'NA'
203964 );
203965
203966
203967 --
203968 --
203969 END IF;
203970 --
203971 -- Bug 4922099
203972 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
203973 (NVL(l_enc_upg_option, 'N') = 'O')
203974 ) AND
203975 (l_bflow_method_code = 'PRIOR_ENTRY')
203976 )
203977 THEN
203978 IF
203979 --
203980 1 = 2
203981 --
203982 THEN
203983 xla_accounting_err_pkg.build_message
203984 (p_appli_s_name => 'XLA'
203985 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
203986 ,p_token_1 => 'LINE_NUMBER'
203987 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
203988 ,p_token_2 => 'LINE_TYPE_NAME'
203989 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
203990 l_component_type
203991 ,l_component_code
203992 ,l_component_type_code
203993 ,l_component_appl_id
203994 ,l_amb_context_code
203995 ,l_entity_code
203996 ,l_event_class_code
203997 )
203998 ,p_token_3 => 'OWNER'
203999 ,p_value_3 => xla_lookups_pkg.get_meaning(
204000 p_lookup_type => 'XLA_OWNER_TYPE'
204001 ,p_lookup_code => l_component_type_code
204002 )
204003 ,p_token_4 => 'PRODUCT_NAME'
204004 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
204005 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
204006 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
204007 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
204008 ,p_ae_header_id => NULL
204009 );
204010
204011 IF (C_LEVEL_ERROR>= g_log_level) THEN
204012 trace
204013 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
204014 ,p_level => C_LEVEL_ERROR
204015 ,p_module => l_log_module);
204016 END IF;
204017 END IF;
204018 END IF;
204019 --
204020 --
204021 ------------------------------------------------------------------------------------------------
204022 -- 4219869 Business Flow
204023 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
204024 -- Prior Entry. Currently, the following code is always generated.
204025 ------------------------------------------------------------------------------------------------
204026 XLA_AE_LINES_PKG.ValidateCurrentLine;
204027
204028 ------------------------------------------------------------------------------------
204029 -- 4219869 Business Flow
204030 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
204031 ------------------------------------------------------------------------------------
204032 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
204033
204034 ----------------------------------------------------------------------------------
204035 -- 4219869 Business Flow
204036 -- Update journal entry status -- Need to generate this within IF <condition>
204037 ----------------------------------------------------------------------------------
204038 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
204039 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
204040 ,p_balance_type_code => l_balance_type_code
204041 );
204042
204043 -------------------------------------------------------------------------------------------
204044 -- 4262811 - Generate the Accrual Reversal lines
204045 -------------------------------------------------------------------------------------------
204046 BEGIN
204047 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
204048 (g_array_event(p_event_id).array_value_num('header_index'));
204049 IF l_acc_rev_flag IS NULL THEN
204050 l_acc_rev_flag := 'N';
204051 END IF;
204052 EXCEPTION
204053 WHEN OTHERS THEN
204054 l_acc_rev_flag := 'N';
204055 END;
204056 --
204057 IF (l_acc_rev_flag = 'Y') THEN
204058
204059 -- 4645092 ------------------------------------------------------------------------------
204060 -- To allow MPA report to determine if it should generate report process
204061 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
204062 ------------------------------------------------------------------------------------------
204063
204064 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
204065 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
204066 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
204067 -- call ADRs
204068 -- Bug 4922099
204069 --
204070 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
204071 (NVL(l_actual_upg_option, 'N') = 'O') OR
204072 (NVL(l_enc_upg_option, 'N') = 'O')
204073 )
204074 THEN
204075 NULL;
204076 --
204077 --
204078
204079 l_ccid := AcctDerRule_6(
204080 p_application_id => p_application_id
204081 , p_ae_header_id => l_ae_header_id
204082 , p_source_11 => p_source_11
204083 , x_transaction_coa_id => l_adr_transaction_coa_id
204084 , x_accounting_coa_id => l_adr_accounting_coa_id
204085 , x_value_type_code => l_adr_value_type_code
204086 , p_side => 'NA'
204087 );
204088
204089 xla_ae_lines_pkg.set_ccid(
204090 p_code_combination_id => l_ccid
204091 , p_value_type_code => l_adr_value_type_code
204092 , p_transaction_coa_id => l_adr_transaction_coa_id
204093 , p_accounting_coa_id => l_adr_accounting_coa_id
204094 , p_adr_code => 'CST_DEFAULT'
204095 , p_adr_type_code => 'S'
204096 , p_component_type => l_component_type
204097 , p_component_code => l_component_code
204098 , p_component_type_code => l_component_type_code
204099 , p_component_appl_id => l_component_appl_id
204100 , p_amb_context_code => l_amb_context_code
204101 , p_side => 'NA'
204102 );
204103
204104
204105 --
204106 --
204107 END IF;
204108
204109 --
204110 -- Update the line information that should be overwritten
204111 --
204112 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
204113 p_header_num => 1);
204114 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
204115
204116 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
204117
204118 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
204119 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
204120 END IF;
204121
204122 --
204123 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
204124 --
204125 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
204126 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
204127 ELSE
204128 ---------------------------------------------------------------------------------------------------
204129 -- 4262811a Switch Sign
204130 ---------------------------------------------------------------------------------------------------
204131 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
204132 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
204133 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204134 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
204135 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204136 -- 5132302
204137 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
204138 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204139
204140 END IF;
204141
204142 -- 4955764
204143 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
204144 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
204145
204146
204147 XLA_AE_LINES_PKG.ValidateCurrentLine;
204148 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
204149
204150 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
204151 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
204152 ,p_balance_type_code => l_balance_type_code);
204153
204154 END IF;
204155
204156 -----------------------------------------------------------------------------------------
204157 -- 4262811 Multiperiod Accounting
204158 -----------------------------------------------------------------------------------------
204159 -- No MPA option is assigned.
204160
204161
204162 END IF;
204163 END IF;
204164 --
204165
204166 --
204167 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
204168 trace
204169 (p_msg => 'END of AcctLineType_372'
204170 ,p_level => C_LEVEL_PROCEDURE
204171 ,p_module => l_log_module);
204172 END IF;
204173 --
204174 EXCEPTION
204175 WHEN xla_exceptions_pkg.application_exception THEN
204176 RAISE;
204177 WHEN OTHERS THEN
204178 xla_exceptions_pkg.raise_message
204179 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_372');
204180 END AcctLineType_372;
204181 --
204182
204183 ---------------------------------------
204184 --
204185 -- PRIVATE FUNCTION
204186 -- AcctLineType_373
204187 --
204188 ---------------------------------------
204189 PROCEDURE AcctLineType_373 (
204190 p_application_id IN NUMBER
204191 ,p_event_id IN NUMBER
204192 ,p_calculate_acctd_flag IN VARCHAR2
204193 ,p_calculate_g_l_flag IN VARCHAR2
204194 ,p_actual_flag IN OUT VARCHAR2
204195 ,p_balance_type_code OUT VARCHAR2
204196 ,p_gain_or_loss_ref OUT VARCHAR2
204197
204198 --Cost Management Default Account
204199 , p_source_11 IN NUMBER
204200 --DISTRIBUTION_IDENTIFIER
204201 , p_source_84 IN NUMBER
204202 --Distribution Type
204203 , p_source_85 IN VARCHAR2
204204 , p_source_85_meaning IN VARCHAR2
204205 --Entered Currency Code
204206 , p_source_88 IN VARCHAR2
204207 --Entered Amount
204208 , p_source_91 IN NUMBER
204209 --Currency Conversion Date
204210 , p_source_92 IN DATE
204211 --Currency Conversion Rate
204212 , p_source_93 IN NUMBER
204213 --Accounted Amount
204214 , p_source_95 IN NUMBER
204215 --Accounting Line Type
204216 , p_source_97 IN NUMBER
204217 )
204218 IS
204219
204220 l_component_type VARCHAR2(80);
204221 l_component_code VARCHAR2(30);
204222 l_component_type_code VARCHAR2(1);
204223 l_component_appl_id INTEGER;
204224 l_amb_context_code VARCHAR2(30);
204225 l_entity_code VARCHAR2(30);
204226 l_event_class_code VARCHAR2(30);
204227 l_ae_header_id NUMBER;
204228 l_event_type_code VARCHAR2(30);
204229 l_line_definition_code VARCHAR2(30);
204230 l_line_definition_owner_code VARCHAR2(1);
204231 --
204232 -- adr variables
204233 l_segment VARCHAR2(30);
204234 l_ccid NUMBER;
204235 l_adr_transaction_coa_id NUMBER;
204236 l_adr_accounting_coa_id NUMBER;
204237 l_adr_flexfield_segment_code VARCHAR2(30);
204238 l_adr_flex_value_set_id NUMBER;
204239 l_adr_value_type_code VARCHAR2(30);
204240 l_adr_value_combination_id NUMBER;
204241 l_adr_value_segment_code VARCHAR2(30);
204242
204243 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
204244 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
204245 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
204246 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
204247
204248 -- 4262811 Variables ------------------------------------------------------------------------------------------
204249 l_entered_amt_idx NUMBER;
204250 l_accted_amt_idx NUMBER;
204251 l_acc_rev_flag VARCHAR2(1);
204252 l_accrual_line_num NUMBER;
204253 l_tmp_amt NUMBER;
204254 l_acc_rev_natural_side_code VARCHAR2(1);
204255
204256 l_num_entries NUMBER;
204257 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
204258 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
204259 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
204260 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
204261 l_recog_line_1 NUMBER;
204262 l_recog_line_2 NUMBER;
204263
204264 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
204265 l_bflow_applied_to_amt NUMBER; -- 5132302
204266 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
204267
204268 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
204269
204270 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
204271 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
204272
204273 ---------------------------------------------------------------------------------------------------------------
204274
204275
204276 --
204277 -- bulk performance
204278 --
204279 l_balance_type_code VARCHAR2(1);
204280 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
204281 l_log_module VARCHAR2(240);
204282
204283 --
204284 -- Upgrade strategy
204285 --
204286 l_actual_upg_option VARCHAR2(1);
204287 l_enc_upg_option VARCHAR2(1);
204288
204289 --
204290 BEGIN
204291 --
204292 IF g_log_enabled THEN
204293 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_373';
204294 END IF;
204295 --
204296 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
204297
204298 trace
204299 (p_msg => 'BEGIN of AcctLineType_373'
204300 ,p_level => C_LEVEL_PROCEDURE
204301 ,p_module => l_log_module);
204302
204303 END IF;
204304 --
204305 l_component_type := 'AMB_JLT';
204306 l_component_code := 'OVERHEAD_ABSORPTION';
204307 l_component_type_code := 'S';
204308 l_component_appl_id := 707;
204309 l_amb_context_code := 'DEFAULT';
204310 l_entity_code := 'WIP_ACCOUNTING_EVENTS';
204311 l_event_class_code := 'OSP';
204312 l_event_type_code := 'EAM_DIRECT_SHOP_FLOOR_DELIVER';
204313 l_line_definition_owner_code := 'S';
204314 l_line_definition_code := 'PI_EAM_DIRECT_DELIVERY';
204315 --
204316 l_balance_type_code := 'A';
204317 l_segment := NULL;
204318 l_ccid := NULL;
204319 l_adr_transaction_coa_id := NULL;
204320 l_adr_accounting_coa_id := NULL;
204321 l_adr_flexfield_segment_code := NULL;
204322 l_adr_flex_value_set_id := NULL;
204323 l_adr_value_type_code := NULL;
204324 l_adr_value_combination_id := NULL;
204325 l_adr_value_segment_code := NULL;
204326
204327 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
204328 l_bflow_class_code := ''; -- 4219869 Business Flow
204329 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
204330 l_budgetary_control_flag := 'N';
204331
204332 l_bflow_applied_to_amt_idx := NULL; -- 5132302
204333 l_bflow_applied_to_amt := NULL; -- 5132302
204334 l_entered_amt_idx := NULL; -- 4262811
204335 l_accted_amt_idx := NULL; -- 4262811
204336 l_acc_rev_flag := NULL; -- 4262811
204337 l_accrual_line_num := NULL; -- 4262811
204338 l_tmp_amt := NULL; -- 4262811
204339 --
204340
204341 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
204342 l_balance_type_code <> 'B' THEN
204343 IF NVL(p_source_97,9E125) = 3
204344 THEN
204345
204346 --
204347 XLA_AE_LINES_PKG.SetNewLine;
204348
204349 p_balance_type_code := l_balance_type_code;
204350 -- set the flag so later we will know whether the gain loss line needs to be created
204351
204352 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
204353 p_actual_flag :='A';
204354 END IF;
204355
204356 --
204357 -- bulk performance
204358 --
204359 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
204360 p_header_num => 0); -- 4262811
204361 --
204362 -- set accounting line options
204363 --
204364 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
204365 p_natural_side_code => 'D'
204366 , p_gain_or_loss_flag => 'N'
204367 , p_gl_transfer_mode_code => 'S'
204368 , p_acct_entry_type_code => 'A'
204369 , p_switch_side_flag => 'Y'
204370 , p_merge_duplicate_code => 'N'
204371 );
204372 --
204373 l_acc_rev_natural_side_code := 'C'; -- 4262811
204374 --
204375 --
204376 -- set accounting line type info
204377 --
204378 xla_ae_lines_pkg.SetAcctLineType
204379 (p_component_type => l_component_type
204380 ,p_event_type_code => l_event_type_code
204381 ,p_line_definition_owner_code => l_line_definition_owner_code
204382 ,p_line_definition_code => l_line_definition_code
204383 ,p_accounting_line_code => l_component_code
204384 ,p_accounting_line_type_code => l_component_type_code
204385 ,p_accounting_line_appl_id => l_component_appl_id
204386 ,p_amb_context_code => l_amb_context_code
204387 ,p_entity_code => l_entity_code
204388 ,p_event_class_code => l_event_class_code);
204389 --
204390 -- set accounting class
204391 --
204392 xla_ae_lines_pkg.SetAcctClass(
204393 p_accounting_class_code => 'OVERHEAD_ABSORPTION'
204394 , p_ae_header_id => l_ae_header_id
204395 );
204396
204397 --
204398 -- set rounding class
204399 --
204400 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
204401 'OVERHEAD_ABSORPTION';
204402
204403 --
204404 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
204405 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
204406 --
204407 -- bulk performance
204408 --
204409 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
204410
204411 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
204412 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
204413
204414 -- 4955764
204415 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
204416 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
204417
204418 -- 4458381 Public Sector Enh
204419
204420 --
204421 -- set accounting attributes for the line type
204422 --
204423 l_entered_amt_idx := 3;
204424 l_accted_amt_idx := 8;
204425 l_bflow_applied_to_amt_idx := NULL; -- 5132302
204426 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
204427 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
204428 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
204429 l_rec_acct_attrs.array_char_value(2) := p_source_85;
204430 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
204431 l_rec_acct_attrs.array_num_value(3) := p_source_91;
204432 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
204433 l_rec_acct_attrs.array_char_value(4) := p_source_88;
204434 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
204435 l_rec_acct_attrs.array_date_value(5) := p_source_92;
204436 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
204437 l_rec_acct_attrs.array_num_value(6) := p_source_93;
204438 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
204439 l_rec_acct_attrs.array_num_value(7) := to_char(p_source_93);
204440 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
204441 l_rec_acct_attrs.array_num_value(8) := p_source_95;
204442
204443 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
204444 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
204445
204446 ---------------------------------------------------------------------------------------------------------------
204447 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
204448 ---------------------------------------------------------------------------------------------------------------
204449 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
204450
204451 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
204452 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
204453
204454 IF xla_accounting_cache_pkg.GetValueChar
204455 (p_source_code => 'LEDGER_CATEGORY_CODE'
204456 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
204457 AND l_bflow_method_code = 'PRIOR_ENTRY'
204458 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
204459 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
204460 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
204461 )
204462 THEN
204463 xla_ae_lines_pkg.BflowUpgEntry
204464 (p_business_method_code => l_bflow_method_code
204465 ,p_business_class_code => l_bflow_class_code
204466 ,p_balance_type => l_balance_type_code);
204467 ELSE
204468 NULL;
204469 -- No business flow processing for business flow method of NONE.
204470 END IF;
204471
204472 --
204473 -- call analytical criteria
204474 --
204475
204476 --
204477 -- call description
204478 --
204479 -- No description or it is inherited.
204480 --
204481 -- call ADRs
204482 -- Bug 4922099
204483 --
204484 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
204485 (NVL(l_actual_upg_option, 'N') = 'O') OR
204486 (NVL(l_enc_upg_option, 'N') = 'O')
204487 )
204488 THEN
204489 NULL;
204490 --
204491 --
204492
204493 l_ccid := AcctDerRule_6(
204494 p_application_id => p_application_id
204495 , p_ae_header_id => l_ae_header_id
204496 , p_source_11 => p_source_11
204497 , x_transaction_coa_id => l_adr_transaction_coa_id
204498 , x_accounting_coa_id => l_adr_accounting_coa_id
204499 , x_value_type_code => l_adr_value_type_code
204500 , p_side => 'NA'
204501 );
204502
204503 xla_ae_lines_pkg.set_ccid(
204504 p_code_combination_id => l_ccid
204505 , p_value_type_code => l_adr_value_type_code
204506 , p_transaction_coa_id => l_adr_transaction_coa_id
204507 , p_accounting_coa_id => l_adr_accounting_coa_id
204508 , p_adr_code => 'CST_DEFAULT'
204509 , p_adr_type_code => 'S'
204510 , p_component_type => l_component_type
204511 , p_component_code => l_component_code
204512 , p_component_type_code => l_component_type_code
204513 , p_component_appl_id => l_component_appl_id
204514 , p_amb_context_code => l_amb_context_code
204515 , p_side => 'NA'
204516 );
204517
204518
204519 --
204520 --
204521 END IF;
204522 --
204523 -- Bug 4922099
204524 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
204525 (NVL(l_enc_upg_option, 'N') = 'O')
204526 ) AND
204527 (l_bflow_method_code = 'PRIOR_ENTRY')
204528 )
204529 THEN
204530 IF
204531 --
204532 1 = 2
204533 --
204534 THEN
204535 xla_accounting_err_pkg.build_message
204536 (p_appli_s_name => 'XLA'
204537 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
204538 ,p_token_1 => 'LINE_NUMBER'
204539 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
204540 ,p_token_2 => 'LINE_TYPE_NAME'
204541 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
204542 l_component_type
204543 ,l_component_code
204544 ,l_component_type_code
204545 ,l_component_appl_id
204546 ,l_amb_context_code
204547 ,l_entity_code
204548 ,l_event_class_code
204549 )
204550 ,p_token_3 => 'OWNER'
204551 ,p_value_3 => xla_lookups_pkg.get_meaning(
204552 p_lookup_type => 'XLA_OWNER_TYPE'
204553 ,p_lookup_code => l_component_type_code
204554 )
204555 ,p_token_4 => 'PRODUCT_NAME'
204556 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
204557 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
204558 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
204559 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
204560 ,p_ae_header_id => NULL
204561 );
204562
204563 IF (C_LEVEL_ERROR>= g_log_level) THEN
204564 trace
204565 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
204566 ,p_level => C_LEVEL_ERROR
204567 ,p_module => l_log_module);
204568 END IF;
204569 END IF;
204570 END IF;
204571 --
204572 --
204573 ------------------------------------------------------------------------------------------------
204574 -- 4219869 Business Flow
204575 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
204576 -- Prior Entry. Currently, the following code is always generated.
204577 ------------------------------------------------------------------------------------------------
204578 XLA_AE_LINES_PKG.ValidateCurrentLine;
204579
204580 ------------------------------------------------------------------------------------
204581 -- 4219869 Business Flow
204582 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
204583 ------------------------------------------------------------------------------------
204584 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
204585
204586 ----------------------------------------------------------------------------------
204587 -- 4219869 Business Flow
204588 -- Update journal entry status -- Need to generate this within IF <condition>
204589 ----------------------------------------------------------------------------------
204590 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
204591 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
204592 ,p_balance_type_code => l_balance_type_code
204593 );
204594
204595 -------------------------------------------------------------------------------------------
204596 -- 4262811 - Generate the Accrual Reversal lines
204597 -------------------------------------------------------------------------------------------
204598 BEGIN
204599 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
204600 (g_array_event(p_event_id).array_value_num('header_index'));
204601 IF l_acc_rev_flag IS NULL THEN
204602 l_acc_rev_flag := 'N';
204603 END IF;
204604 EXCEPTION
204605 WHEN OTHERS THEN
204606 l_acc_rev_flag := 'N';
204607 END;
204608 --
204609 IF (l_acc_rev_flag = 'Y') THEN
204610
204611 -- 4645092 ------------------------------------------------------------------------------
204612 -- To allow MPA report to determine if it should generate report process
204613 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
204614 ------------------------------------------------------------------------------------------
204615
204616 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
204617 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
204618 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
204619 -- call ADRs
204620 -- Bug 4922099
204621 --
204622 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
204623 (NVL(l_actual_upg_option, 'N') = 'O') OR
204624 (NVL(l_enc_upg_option, 'N') = 'O')
204625 )
204626 THEN
204627 NULL;
204628 --
204629 --
204630
204631 l_ccid := AcctDerRule_6(
204632 p_application_id => p_application_id
204633 , p_ae_header_id => l_ae_header_id
204634 , p_source_11 => p_source_11
204635 , x_transaction_coa_id => l_adr_transaction_coa_id
204636 , x_accounting_coa_id => l_adr_accounting_coa_id
204637 , x_value_type_code => l_adr_value_type_code
204638 , p_side => 'NA'
204639 );
204640
204641 xla_ae_lines_pkg.set_ccid(
204642 p_code_combination_id => l_ccid
204643 , p_value_type_code => l_adr_value_type_code
204644 , p_transaction_coa_id => l_adr_transaction_coa_id
204645 , p_accounting_coa_id => l_adr_accounting_coa_id
204646 , p_adr_code => 'CST_DEFAULT'
204647 , p_adr_type_code => 'S'
204648 , p_component_type => l_component_type
204649 , p_component_code => l_component_code
204650 , p_component_type_code => l_component_type_code
204651 , p_component_appl_id => l_component_appl_id
204652 , p_amb_context_code => l_amb_context_code
204653 , p_side => 'NA'
204654 );
204655
204656
204657 --
204658 --
204659 END IF;
204660
204661 --
204662 -- Update the line information that should be overwritten
204663 --
204664 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
204665 p_header_num => 1);
204666 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
204667
204668 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
204669
204670 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
204671 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
204672 END IF;
204673
204674 --
204675 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
204676 --
204677 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
204678 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
204679 ELSE
204680 ---------------------------------------------------------------------------------------------------
204681 -- 4262811a Switch Sign
204682 ---------------------------------------------------------------------------------------------------
204683 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
204684 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
204685 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204686 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
204687 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204688 -- 5132302
204689 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
204690 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
204691
204692 END IF;
204693
204694 -- 4955764
204695 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
204696 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
204697
204698
204699 XLA_AE_LINES_PKG.ValidateCurrentLine;
204700 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
204701
204702 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
204703 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
204704 ,p_balance_type_code => l_balance_type_code);
204705
204706 END IF;
204707
204708 -----------------------------------------------------------------------------------------
204709 -- 4262811 Multiperiod Accounting
204710 -----------------------------------------------------------------------------------------
204711 -- No MPA option is assigned.
204712
204713
204714 END IF;
204715 END IF;
204716 --
204717
204718 --
204719 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
204720 trace
204721 (p_msg => 'END of AcctLineType_373'
204722 ,p_level => C_LEVEL_PROCEDURE
204723 ,p_module => l_log_module);
204724 END IF;
204725 --
204726 EXCEPTION
204727 WHEN xla_exceptions_pkg.application_exception THEN
204728 RAISE;
204729 WHEN OTHERS THEN
204730 xla_exceptions_pkg.raise_message
204731 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_373');
204732 END AcctLineType_373;
204733 --
204734
204735 ---------------------------------------
204736 --
204737 -- PRIVATE FUNCTION
204738 -- AcctLineType_374
204739 --
204740 ---------------------------------------
204741 PROCEDURE AcctLineType_374 (
204742 p_application_id IN NUMBER
204743 ,p_event_id IN NUMBER
204744 ,p_calculate_acctd_flag IN VARCHAR2
204745 ,p_calculate_g_l_flag IN VARCHAR2
204746 ,p_actual_flag IN OUT VARCHAR2
204747 ,p_balance_type_code OUT VARCHAR2
204748 ,p_gain_or_loss_ref OUT VARCHAR2
204749
204750 --TRANSACTION_ID
204751 , p_source_1 IN NUMBER
204752 --Item Concatenated Segments
204753 , p_source_2 IN VARCHAR2
204754 --Transaction Quantity
204755 , p_source_3 IN NUMBER
204756 --Transaction Unit of Measure Code
204757 , p_source_4 IN VARCHAR2
204758 --Inventory Transaction Type Description
204759 , p_source_5 IN VARCHAR2
204760 --Product Line Accounting Category Bridging Account
204761 , p_source_22 IN NUMBER
204762 --DISTRIBUTION_IDENTIFIER
204763 , p_source_84 IN NUMBER
204764 --Distribution Type
204765 , p_source_85 IN VARCHAR2
204766 , p_source_85_meaning IN VARCHAR2
204767 --Entered Currency Code
204768 , p_source_88 IN VARCHAR2
204769 --Entered Amount
204770 , p_source_91 IN NUMBER
204771 --Currency Conversion Date
204772 , p_source_92 IN DATE
204773 --Currency Conversion Rate
204774 , p_source_93 IN NUMBER
204775 --Currency Conversion Type
204776 , p_source_94 IN VARCHAR2
204777 --Accounted Amount
204778 , p_source_95 IN NUMBER
204779 --Accounting Line Type
204780 , p_source_97 IN NUMBER
204781 )
204782 IS
204783
204784 l_component_type VARCHAR2(80);
204785 l_component_code VARCHAR2(30);
204786 l_component_type_code VARCHAR2(1);
204787 l_component_appl_id INTEGER;
204788 l_amb_context_code VARCHAR2(30);
204789 l_entity_code VARCHAR2(30);
204790 l_event_class_code VARCHAR2(30);
204791 l_ae_header_id NUMBER;
204792 l_event_type_code VARCHAR2(30);
204793 l_line_definition_code VARCHAR2(30);
204794 l_line_definition_owner_code VARCHAR2(1);
204795 --
204796 -- adr variables
204797 l_segment VARCHAR2(30);
204798 l_ccid NUMBER;
204799 l_adr_transaction_coa_id NUMBER;
204800 l_adr_accounting_coa_id NUMBER;
204801 l_adr_flexfield_segment_code VARCHAR2(30);
204802 l_adr_flex_value_set_id NUMBER;
204803 l_adr_value_type_code VARCHAR2(30);
204804 l_adr_value_combination_id NUMBER;
204805 l_adr_value_segment_code VARCHAR2(30);
204806
204807 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
204808 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
204809 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
204810 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
204811
204812 -- 4262811 Variables ------------------------------------------------------------------------------------------
204813 l_entered_amt_idx NUMBER;
204814 l_accted_amt_idx NUMBER;
204815 l_acc_rev_flag VARCHAR2(1);
204816 l_accrual_line_num NUMBER;
204817 l_tmp_amt NUMBER;
204818 l_acc_rev_natural_side_code VARCHAR2(1);
204819
204820 l_num_entries NUMBER;
204821 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
204822 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
204823 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
204824 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
204825 l_recog_line_1 NUMBER;
204826 l_recog_line_2 NUMBER;
204827
204828 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
204829 l_bflow_applied_to_amt NUMBER; -- 5132302
204830 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
204831
204832 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
204833
204834 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
204835 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
204836
204837 ---------------------------------------------------------------------------------------------------------------
204838
204839
204840 --
204841 -- bulk performance
204842 --
204843 l_balance_type_code VARCHAR2(1);
204844 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
204845 l_log_module VARCHAR2(240);
204846
204847 --
204848 -- Upgrade strategy
204849 --
204850 l_actual_upg_option VARCHAR2(1);
204851 l_enc_upg_option VARCHAR2(1);
204852
204853 --
204854 BEGIN
204855 --
204856 IF g_log_enabled THEN
204857 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_374';
204858 END IF;
204859 --
204860 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
204861
204862 trace
204863 (p_msg => 'BEGIN of AcctLineType_374'
204864 ,p_level => C_LEVEL_PROCEDURE
204865 ,p_module => l_log_module);
204866
204867 END IF;
204868 --
204869 l_component_type := 'AMB_JLT';
204870 l_component_code := 'PI_BRIDGING';
204871 l_component_type_code := 'S';
204872 l_component_appl_id := 707;
204873 l_amb_context_code := 'DEFAULT';
204874 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
204875 l_event_class_code := 'USER_DEFINE';
204876 l_event_type_code := 'UDIR_INTERORG_SHIP_TP';
204877 l_line_definition_owner_code := 'S';
204878 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_TP';
204879 --
204880 l_balance_type_code := 'A';
204881 l_segment := NULL;
204882 l_ccid := NULL;
204883 l_adr_transaction_coa_id := NULL;
204884 l_adr_accounting_coa_id := NULL;
204885 l_adr_flexfield_segment_code := NULL;
204886 l_adr_flex_value_set_id := NULL;
204887 l_adr_value_type_code := NULL;
204888 l_adr_value_combination_id := NULL;
204889 l_adr_value_segment_code := NULL;
204890
204891 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
204892 l_bflow_class_code := ''; -- 4219869 Business Flow
204893 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
204894 l_budgetary_control_flag := 'N';
204895
204896 l_bflow_applied_to_amt_idx := NULL; -- 5132302
204897 l_bflow_applied_to_amt := NULL; -- 5132302
204898 l_entered_amt_idx := NULL; -- 4262811
204899 l_accted_amt_idx := NULL; -- 4262811
204900 l_acc_rev_flag := NULL; -- 4262811
204901 l_accrual_line_num := NULL; -- 4262811
204902 l_tmp_amt := NULL; -- 4262811
204903 --
204904
204905 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
204906 l_balance_type_code <> 'B' THEN
204907 IF NVL(p_source_97,9E125) = 1
204908 THEN
204909
204910 --
204911 XLA_AE_LINES_PKG.SetNewLine;
204912
204913 p_balance_type_code := l_balance_type_code;
204914 -- set the flag so later we will know whether the gain loss line needs to be created
204915
204916 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
204917 p_actual_flag :='A';
204918 END IF;
204919
204920 --
204921 -- bulk performance
204922 --
204923 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
204924 p_header_num => 0); -- 4262811
204925 --
204926 -- set accounting line options
204927 --
204928 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
204929 p_natural_side_code => 'C'
204930 , p_gain_or_loss_flag => 'N'
204931 , p_gl_transfer_mode_code => 'S'
204932 , p_acct_entry_type_code => 'A'
204933 , p_switch_side_flag => 'Y'
204934 , p_merge_duplicate_code => 'N'
204935 );
204936 --
204937 l_acc_rev_natural_side_code := 'D'; -- 4262811
204938 --
204939 --
204940 -- set accounting line type info
204941 --
204942 xla_ae_lines_pkg.SetAcctLineType
204943 (p_component_type => l_component_type
204944 ,p_event_type_code => l_event_type_code
204945 ,p_line_definition_owner_code => l_line_definition_owner_code
204946 ,p_line_definition_code => l_line_definition_code
204947 ,p_accounting_line_code => l_component_code
204948 ,p_accounting_line_type_code => l_component_type_code
204949 ,p_accounting_line_appl_id => l_component_appl_id
204950 ,p_amb_context_code => l_amb_context_code
204951 ,p_entity_code => l_entity_code
204952 ,p_event_class_code => l_event_class_code);
204953 --
204954 -- set accounting class
204955 --
204956 xla_ae_lines_pkg.SetAcctClass(
204957 p_accounting_class_code => 'BRIDGING'
204958 , p_ae_header_id => l_ae_header_id
204959 );
204960
204961 --
204962 -- set rounding class
204963 --
204964 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
204965 'BRIDGING';
204966
204967 --
204968 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
204969 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
204970 --
204971 -- bulk performance
204972 --
204973 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
204974
204975 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
204976 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
204977
204978 -- 4955764
204979 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
204980 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
204981
204982 -- 4458381 Public Sector Enh
204983
204984 --
204985 -- set accounting attributes for the line type
204986 --
204987 l_entered_amt_idx := 3;
204988 l_accted_amt_idx := 8;
204989 l_bflow_applied_to_amt_idx := NULL; -- 5132302
204990 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
204991 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
204992 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
204993 l_rec_acct_attrs.array_char_value(2) := p_source_85;
204994 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
204995 l_rec_acct_attrs.array_num_value(3) := p_source_91;
204996 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
204997 l_rec_acct_attrs.array_char_value(4) := p_source_88;
204998 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
204999 l_rec_acct_attrs.array_date_value(5) := p_source_92;
205000 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
205001 l_rec_acct_attrs.array_num_value(6) := p_source_93;
205002 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
205003 l_rec_acct_attrs.array_char_value(7) := p_source_94;
205004 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
205005 l_rec_acct_attrs.array_num_value(8) := p_source_95;
205006
205007 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
205008 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
205009
205010 ---------------------------------------------------------------------------------------------------------------
205011 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
205012 ---------------------------------------------------------------------------------------------------------------
205013 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
205014
205015 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
205016 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
205017
205018 IF xla_accounting_cache_pkg.GetValueChar
205019 (p_source_code => 'LEDGER_CATEGORY_CODE'
205020 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
205021 AND l_bflow_method_code = 'PRIOR_ENTRY'
205022 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
205023 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
205024 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
205025 )
205026 THEN
205027 xla_ae_lines_pkg.BflowUpgEntry
205028 (p_business_method_code => l_bflow_method_code
205029 ,p_business_class_code => l_bflow_class_code
205030 ,p_balance_type => l_balance_type_code);
205031 ELSE
205032 NULL;
205033 -- No business flow processing for business flow method of NONE.
205034 END IF;
205035
205036 --
205037 -- call analytical criteria
205038 --
205039
205040 --
205041 -- call description
205042 --
205043
205044 xla_ae_lines_pkg.SetLineDescription(
205045 p_ae_header_id => l_ae_header_id
205046 ,p_description => Description_1 (
205047 p_application_id => p_application_id
205048 , p_ae_header_id => l_ae_header_id
205049 , p_source_1 => p_source_1
205050 , p_source_2 => p_source_2
205051 , p_source_3 => p_source_3
205052 , p_source_4 => p_source_4
205053 , p_source_5 => p_source_5
205054 )
205055 );
205056
205057
205058 --
205059 -- call ADRs
205060 -- Bug 4922099
205061 --
205062 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
205063 (NVL(l_actual_upg_option, 'N') = 'O') OR
205064 (NVL(l_enc_upg_option, 'N') = 'O')
205065 )
205066 THEN
205067 NULL;
205068 --
205069 --
205070
205071 l_ccid := AcctDerRule_11(
205072 p_application_id => p_application_id
205073 , p_ae_header_id => l_ae_header_id
205074 , p_source_22 => p_source_22
205075 , x_transaction_coa_id => l_adr_transaction_coa_id
205076 , x_accounting_coa_id => l_adr_accounting_coa_id
205077 , x_value_type_code => l_adr_value_type_code
205078 , p_side => 'NA'
205079 );
205080
205081 xla_ae_lines_pkg.set_ccid(
205082 p_code_combination_id => l_ccid
205083 , p_value_type_code => l_adr_value_type_code
205084 , p_transaction_coa_id => l_adr_transaction_coa_id
205085 , p_accounting_coa_id => l_adr_accounting_coa_id
205086 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
205087 , p_adr_type_code => 'S'
205088 , p_component_type => l_component_type
205089 , p_component_code => l_component_code
205090 , p_component_type_code => l_component_type_code
205091 , p_component_appl_id => l_component_appl_id
205092 , p_amb_context_code => l_amb_context_code
205093 , p_side => 'NA'
205094 );
205095
205096
205097 --
205098 --
205099 END IF;
205100 --
205101 -- Bug 4922099
205102 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
205103 (NVL(l_enc_upg_option, 'N') = 'O')
205104 ) AND
205105 (l_bflow_method_code = 'PRIOR_ENTRY')
205106 )
205107 THEN
205108 IF
205109 --
205110 1 = 2
205111 --
205112 THEN
205113 xla_accounting_err_pkg.build_message
205114 (p_appli_s_name => 'XLA'
205115 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
205116 ,p_token_1 => 'LINE_NUMBER'
205117 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
205118 ,p_token_2 => 'LINE_TYPE_NAME'
205119 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
205120 l_component_type
205121 ,l_component_code
205122 ,l_component_type_code
205123 ,l_component_appl_id
205124 ,l_amb_context_code
205125 ,l_entity_code
205126 ,l_event_class_code
205127 )
205128 ,p_token_3 => 'OWNER'
205129 ,p_value_3 => xla_lookups_pkg.get_meaning(
205130 p_lookup_type => 'XLA_OWNER_TYPE'
205131 ,p_lookup_code => l_component_type_code
205132 )
205133 ,p_token_4 => 'PRODUCT_NAME'
205134 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
205135 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
205136 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
205137 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
205138 ,p_ae_header_id => NULL
205139 );
205140
205141 IF (C_LEVEL_ERROR>= g_log_level) THEN
205142 trace
205143 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
205144 ,p_level => C_LEVEL_ERROR
205145 ,p_module => l_log_module);
205146 END IF;
205147 END IF;
205148 END IF;
205149 --
205150 --
205151 ------------------------------------------------------------------------------------------------
205152 -- 4219869 Business Flow
205153 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
205154 -- Prior Entry. Currently, the following code is always generated.
205155 ------------------------------------------------------------------------------------------------
205156 XLA_AE_LINES_PKG.ValidateCurrentLine;
205157
205158 ------------------------------------------------------------------------------------
205159 -- 4219869 Business Flow
205160 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
205161 ------------------------------------------------------------------------------------
205162 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
205163
205164 ----------------------------------------------------------------------------------
205165 -- 4219869 Business Flow
205166 -- Update journal entry status -- Need to generate this within IF <condition>
205167 ----------------------------------------------------------------------------------
205168 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
205169 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
205170 ,p_balance_type_code => l_balance_type_code
205171 );
205172
205173 -------------------------------------------------------------------------------------------
205174 -- 4262811 - Generate the Accrual Reversal lines
205175 -------------------------------------------------------------------------------------------
205176 BEGIN
205177 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
205178 (g_array_event(p_event_id).array_value_num('header_index'));
205179 IF l_acc_rev_flag IS NULL THEN
205180 l_acc_rev_flag := 'N';
205181 END IF;
205182 EXCEPTION
205183 WHEN OTHERS THEN
205184 l_acc_rev_flag := 'N';
205185 END;
205186 --
205187 IF (l_acc_rev_flag = 'Y') THEN
205188
205189 -- 4645092 ------------------------------------------------------------------------------
205190 -- To allow MPA report to determine if it should generate report process
205191 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
205192 ------------------------------------------------------------------------------------------
205193
205194 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
205195 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
205196 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
205197 -- call ADRs
205198 -- Bug 4922099
205199 --
205200 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
205201 (NVL(l_actual_upg_option, 'N') = 'O') OR
205202 (NVL(l_enc_upg_option, 'N') = 'O')
205203 )
205204 THEN
205205 NULL;
205206 --
205207 --
205208
205209 l_ccid := AcctDerRule_11(
205210 p_application_id => p_application_id
205211 , p_ae_header_id => l_ae_header_id
205212 , p_source_22 => p_source_22
205213 , x_transaction_coa_id => l_adr_transaction_coa_id
205214 , x_accounting_coa_id => l_adr_accounting_coa_id
205215 , x_value_type_code => l_adr_value_type_code
205216 , p_side => 'NA'
205217 );
205218
205219 xla_ae_lines_pkg.set_ccid(
205220 p_code_combination_id => l_ccid
205221 , p_value_type_code => l_adr_value_type_code
205222 , p_transaction_coa_id => l_adr_transaction_coa_id
205223 , p_accounting_coa_id => l_adr_accounting_coa_id
205224 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
205225 , p_adr_type_code => 'S'
205226 , p_component_type => l_component_type
205227 , p_component_code => l_component_code
205228 , p_component_type_code => l_component_type_code
205229 , p_component_appl_id => l_component_appl_id
205230 , p_amb_context_code => l_amb_context_code
205231 , p_side => 'NA'
205232 );
205233
205234
205235 --
205236 --
205237 END IF;
205238
205239 --
205240 -- Update the line information that should be overwritten
205241 --
205242 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
205243 p_header_num => 1);
205244 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
205245
205246 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
205247
205248 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
205249 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
205250 END IF;
205251
205252 --
205253 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
205254 --
205255 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
205256 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
205257 ELSE
205258 ---------------------------------------------------------------------------------------------------
205259 -- 4262811a Switch Sign
205260 ---------------------------------------------------------------------------------------------------
205261 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
205262 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
205263 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205264 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
205265 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205266 -- 5132302
205267 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
205268 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205269
205270 END IF;
205271
205272 -- 4955764
205273 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
205274 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
205275
205276
205277 XLA_AE_LINES_PKG.ValidateCurrentLine;
205278 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
205279
205280 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
205281 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
205282 ,p_balance_type_code => l_balance_type_code);
205283
205284 END IF;
205285
205286 -----------------------------------------------------------------------------------------
205287 -- 4262811 Multiperiod Accounting
205288 -----------------------------------------------------------------------------------------
205289 -- No MPA option is assigned.
205290
205291
205292 END IF;
205293 END IF;
205294 --
205295
205296 --
205297 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
205298 trace
205299 (p_msg => 'END of AcctLineType_374'
205300 ,p_level => C_LEVEL_PROCEDURE
205301 ,p_module => l_log_module);
205302 END IF;
205303 --
205304 EXCEPTION
205305 WHEN xla_exceptions_pkg.application_exception THEN
205306 RAISE;
205307 WHEN OTHERS THEN
205308 xla_exceptions_pkg.raise_message
205309 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_374');
205310 END AcctLineType_374;
205311 --
205312
205313 ---------------------------------------
205314 --
205315 -- PRIVATE FUNCTION
205316 -- AcctLineType_375
205317 --
205318 ---------------------------------------
205319 PROCEDURE AcctLineType_375 (
205320 p_application_id IN NUMBER
205321 ,p_event_id IN NUMBER
205322 ,p_calculate_acctd_flag IN VARCHAR2
205323 ,p_calculate_g_l_flag IN VARCHAR2
205324 ,p_actual_flag IN OUT VARCHAR2
205325 ,p_balance_type_code OUT VARCHAR2
205326 ,p_gain_or_loss_ref OUT VARCHAR2
205327
205328 --TRANSACTION_ID
205329 , p_source_1 IN NUMBER
205330 --Item Concatenated Segments
205331 , p_source_2 IN VARCHAR2
205332 --Transaction Quantity
205333 , p_source_3 IN NUMBER
205334 --Transaction Unit of Measure Code
205335 , p_source_4 IN VARCHAR2
205336 --Inventory Transaction Type Description
205337 , p_source_5 IN VARCHAR2
205338 --Product Line Accounting Category Bridging Account
205339 , p_source_22 IN NUMBER
205340 --Applied to Application ID
205341 , p_source_79 IN NUMBER
205342 --Applied to Distribution Link Type
205343 , p_source_80 IN VARCHAR2
205344 --Applied to Entity Code
205345 , p_source_81 IN VARCHAR2
205346 --Applied To Purchase Document Identifier
205347 , p_source_83 IN NUMBER
205348 --DISTRIBUTION_IDENTIFIER
205349 , p_source_84 IN NUMBER
205350 --Distribution Type
205351 , p_source_85 IN VARCHAR2
205352 , p_source_85_meaning IN VARCHAR2
205353 --PO Budget Account
205354 , p_source_86 IN NUMBER
205355 --Encumbrance Reversal Amount Entered
205356 , p_source_87 IN NUMBER
205357 --Entered Currency Code
205358 , p_source_88 IN VARCHAR2
205359 --Transaction Encumbrance Reversal Amount
205360 , p_source_89 IN NUMBER
205361 --Entered Amount
205362 , p_source_91 IN NUMBER
205363 --Currency Conversion Date
205364 , p_source_92 IN DATE
205365 --Currency Conversion Rate
205366 , p_source_93 IN NUMBER
205367 --Currency Conversion Type
205368 , p_source_94 IN VARCHAR2
205369 --Accounted Amount
205370 , p_source_95 IN NUMBER
205371 --Purchasing Encumbrance Type Identifier
205372 , p_source_96 IN NUMBER
205373 --Accounting Line Type
205374 , p_source_97 IN NUMBER
205375 --Costing Encumbrance Upgrade Option
205376 , p_source_100 IN VARCHAR2
205377 --TXN_PO_DISTRIBUTION_ID
205378 , p_source_101 IN NUMBER
205379 --Subinventory Type Indicator
205380 , p_source_110 IN VARCHAR2
205381 , p_source_110_meaning IN VARCHAR2
205382 )
205383 IS
205384
205385 l_component_type VARCHAR2(80);
205386 l_component_code VARCHAR2(30);
205387 l_component_type_code VARCHAR2(1);
205388 l_component_appl_id INTEGER;
205389 l_amb_context_code VARCHAR2(30);
205390 l_entity_code VARCHAR2(30);
205391 l_event_class_code VARCHAR2(30);
205392 l_ae_header_id NUMBER;
205393 l_event_type_code VARCHAR2(30);
205394 l_line_definition_code VARCHAR2(30);
205395 l_line_definition_owner_code VARCHAR2(1);
205396 --
205397 -- adr variables
205398 l_segment VARCHAR2(30);
205399 l_ccid NUMBER;
205400 l_adr_transaction_coa_id NUMBER;
205401 l_adr_accounting_coa_id NUMBER;
205402 l_adr_flexfield_segment_code VARCHAR2(30);
205403 l_adr_flex_value_set_id NUMBER;
205404 l_adr_value_type_code VARCHAR2(30);
205405 l_adr_value_combination_id NUMBER;
205406 l_adr_value_segment_code VARCHAR2(30);
205407
205408 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
205409 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
205410 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
205411 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
205412
205413 -- 4262811 Variables ------------------------------------------------------------------------------------------
205414 l_entered_amt_idx NUMBER;
205415 l_accted_amt_idx NUMBER;
205416 l_acc_rev_flag VARCHAR2(1);
205417 l_accrual_line_num NUMBER;
205418 l_tmp_amt NUMBER;
205419 l_acc_rev_natural_side_code VARCHAR2(1);
205420
205421 l_num_entries NUMBER;
205422 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
205423 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
205424 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
205425 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
205426 l_recog_line_1 NUMBER;
205427 l_recog_line_2 NUMBER;
205428
205429 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
205430 l_bflow_applied_to_amt NUMBER; -- 5132302
205431 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
205432
205433 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
205434
205435 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
205436 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
205437
205438 ---------------------------------------------------------------------------------------------------------------
205439
205440
205441 --
205442 -- bulk performance
205443 --
205444 l_balance_type_code VARCHAR2(1);
205445 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
205446 l_log_module VARCHAR2(240);
205447
205448 --
205449 -- Upgrade strategy
205450 --
205451 l_actual_upg_option VARCHAR2(1);
205452 l_enc_upg_option VARCHAR2(1);
205453
205454 --
205455 BEGIN
205456 --
205457 IF g_log_enabled THEN
205458 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_375';
205459 END IF;
205460 --
205461 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
205462
205463 trace
205464 (p_msg => 'BEGIN of AcctLineType_375'
205465 ,p_level => C_LEVEL_PROCEDURE
205466 ,p_module => l_log_module);
205467
205468 END IF;
205469 --
205470 l_component_type := 'AMB_JLT';
205471 l_component_code := 'PI_BRIDGING';
205472 l_component_type_code := 'S';
205473 l_component_appl_id := 707;
205474 l_amb_context_code := 'DEFAULT';
205475 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
205476 l_event_class_code := 'PURCHASE_ORDER';
205477 l_event_type_code := 'PO_DEL_INV';
205478 l_line_definition_owner_code := 'S';
205479 l_line_definition_code := 'PI_PO_DEL_INV';
205480 --
205481 l_balance_type_code := 'A';
205482 l_segment := NULL;
205483 l_ccid := NULL;
205484 l_adr_transaction_coa_id := NULL;
205485 l_adr_accounting_coa_id := NULL;
205486 l_adr_flexfield_segment_code := NULL;
205487 l_adr_flex_value_set_id := NULL;
205488 l_adr_value_type_code := NULL;
205489 l_adr_value_combination_id := NULL;
205490 l_adr_value_segment_code := NULL;
205491
205492 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
205493 l_bflow_class_code := ''; -- 4219869 Business Flow
205494 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
205495 l_budgetary_control_flag := 'N';
205496
205497 l_bflow_applied_to_amt_idx := NULL; -- 5132302
205498 l_bflow_applied_to_amt := NULL; -- 5132302
205499 l_entered_amt_idx := NULL; -- 4262811
205500 l_accted_amt_idx := NULL; -- 4262811
205501 l_acc_rev_flag := NULL; -- 4262811
205502 l_accrual_line_num := NULL; -- 4262811
205503 l_tmp_amt := NULL; -- 4262811
205504 --
205505
205506 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
205507 l_balance_type_code <> 'B' THEN
205508 IF (NVL(p_source_97,9E125) = 5 AND
205509 p_source_110 IS NOT NULL AND
205510 NVL(p_source_110,'
205511 ') = 'Y')
205512 THEN
205513
205514 --
205515 XLA_AE_LINES_PKG.SetNewLine;
205516
205517 p_balance_type_code := l_balance_type_code;
205518 -- set the flag so later we will know whether the gain loss line needs to be created
205519
205520 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
205521 p_actual_flag :='A';
205522 END IF;
205523
205524 --
205525 -- bulk performance
205526 --
205527 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
205528 p_header_num => 0); -- 4262811
205529 --
205530 -- set accounting line options
205531 --
205532 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
205533 p_natural_side_code => 'D'
205534 , p_gain_or_loss_flag => 'N'
205535 , p_gl_transfer_mode_code => 'S'
205536 , p_acct_entry_type_code => 'A'
205537 , p_switch_side_flag => 'Y'
205538 , p_merge_duplicate_code => 'N'
205539 );
205540 --
205541 l_acc_rev_natural_side_code := 'C'; -- 4262811
205542 --
205543 --
205544 -- set accounting line type info
205545 --
205546 xla_ae_lines_pkg.SetAcctLineType
205547 (p_component_type => l_component_type
205548 ,p_event_type_code => l_event_type_code
205549 ,p_line_definition_owner_code => l_line_definition_owner_code
205550 ,p_line_definition_code => l_line_definition_code
205551 ,p_accounting_line_code => l_component_code
205552 ,p_accounting_line_type_code => l_component_type_code
205553 ,p_accounting_line_appl_id => l_component_appl_id
205554 ,p_amb_context_code => l_amb_context_code
205555 ,p_entity_code => l_entity_code
205556 ,p_event_class_code => l_event_class_code);
205557 --
205558 -- set accounting class
205559 --
205560 xla_ae_lines_pkg.SetAcctClass(
205561 p_accounting_class_code => 'BRIDGING'
205562 , p_ae_header_id => l_ae_header_id
205563 );
205564
205565 --
205566 -- set rounding class
205567 --
205568 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
205569 'BRIDGING';
205570
205571 --
205572 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
205573 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
205574 --
205575 -- bulk performance
205576 --
205577 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
205578
205579 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
205580 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
205581
205582 -- 4955764
205583 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
205584 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
205585
205586 -- 4458381 Public Sector Enh
205587
205588 --
205589 -- set accounting attributes for the line type
205590 --
205591 l_entered_amt_idx := 17;
205592 l_accted_amt_idx := 22;
205593 l_bflow_applied_to_amt_idx := NULL; -- 5132302
205594 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
205595 l_rec_acct_attrs.array_num_value(1) := p_source_79;
205596 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
205597 l_rec_acct_attrs.array_char_value(2) := p_source_80;
205598 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
205599 l_rec_acct_attrs.array_char_value(3) := p_source_81;
205600 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
205601 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
205602 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
205603 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_83);
205604 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
205605 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
205606 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
205607 l_rec_acct_attrs.array_char_value(7) := p_source_85;
205608 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
205609 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_86);
205610 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
205611 l_rec_acct_attrs.array_num_value(9) := p_source_87;
205612 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
205613 l_rec_acct_attrs.array_char_value(10) := p_source_88;
205614 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
205615 l_rec_acct_attrs.array_num_value(11) := p_source_89;
205616 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
205617 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_86);
205618 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
205619 l_rec_acct_attrs.array_num_value(13) := p_source_87;
205620 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
205621 l_rec_acct_attrs.array_char_value(14) := p_source_88;
205622 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
205623 l_rec_acct_attrs.array_num_value(15) := p_source_89;
205624 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
205625 l_rec_acct_attrs.array_char_value(16) := p_source_100;
205626 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
205627 l_rec_acct_attrs.array_num_value(17) := p_source_91;
205628 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
205629 l_rec_acct_attrs.array_char_value(18) := p_source_88;
205630 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
205631 l_rec_acct_attrs.array_date_value(19) := p_source_92;
205632 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
205633 l_rec_acct_attrs.array_num_value(20) := p_source_93;
205634 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
205635 l_rec_acct_attrs.array_char_value(21) := p_source_94;
205636 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
205637 l_rec_acct_attrs.array_num_value(22) := p_source_95;
205638 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
205639 l_rec_acct_attrs.array_num_value(23) := p_source_96;
205640 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
205641 l_rec_acct_attrs.array_num_value(24) := p_source_96;
205642
205643 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
205644 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
205645
205646 ---------------------------------------------------------------------------------------------------------------
205647 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
205648 ---------------------------------------------------------------------------------------------------------------
205649 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
205650
205651 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
205652 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
205653
205654 IF xla_accounting_cache_pkg.GetValueChar
205655 (p_source_code => 'LEDGER_CATEGORY_CODE'
205656 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
205657 AND l_bflow_method_code = 'PRIOR_ENTRY'
205658 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
205659 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
205660 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
205661 )
205662 THEN
205663 xla_ae_lines_pkg.BflowUpgEntry
205664 (p_business_method_code => l_bflow_method_code
205665 ,p_business_class_code => l_bflow_class_code
205666 ,p_balance_type => l_balance_type_code);
205667 ELSE
205668 NULL;
205669 -- No business flow processing for business flow method of NONE.
205670 END IF;
205671
205672 --
205673 -- call analytical criteria
205674 --
205675
205676 --
205677 -- call description
205678 --
205679
205680 xla_ae_lines_pkg.SetLineDescription(
205681 p_ae_header_id => l_ae_header_id
205682 ,p_description => Description_1 (
205683 p_application_id => p_application_id
205684 , p_ae_header_id => l_ae_header_id
205685 , p_source_1 => p_source_1
205686 , p_source_2 => p_source_2
205687 , p_source_3 => p_source_3
205688 , p_source_4 => p_source_4
205689 , p_source_5 => p_source_5
205690 )
205691 );
205692
205693
205694 --
205695 -- call ADRs
205696 -- Bug 4922099
205697 --
205698 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
205699 (NVL(l_actual_upg_option, 'N') = 'O') OR
205700 (NVL(l_enc_upg_option, 'N') = 'O')
205701 )
205702 THEN
205703 NULL;
205704 --
205705 --
205706
205707 l_ccid := AcctDerRule_11(
205708 p_application_id => p_application_id
205709 , p_ae_header_id => l_ae_header_id
205710 , p_source_22 => p_source_22
205711 , x_transaction_coa_id => l_adr_transaction_coa_id
205712 , x_accounting_coa_id => l_adr_accounting_coa_id
205713 , x_value_type_code => l_adr_value_type_code
205714 , p_side => 'NA'
205715 );
205716
205717 xla_ae_lines_pkg.set_ccid(
205718 p_code_combination_id => l_ccid
205719 , p_value_type_code => l_adr_value_type_code
205720 , p_transaction_coa_id => l_adr_transaction_coa_id
205721 , p_accounting_coa_id => l_adr_accounting_coa_id
205722 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
205723 , p_adr_type_code => 'S'
205724 , p_component_type => l_component_type
205725 , p_component_code => l_component_code
205726 , p_component_type_code => l_component_type_code
205727 , p_component_appl_id => l_component_appl_id
205728 , p_amb_context_code => l_amb_context_code
205729 , p_side => 'NA'
205730 );
205731
205732
205733 --
205734 --
205735 END IF;
205736 --
205737 -- Bug 4922099
205738 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
205739 (NVL(l_enc_upg_option, 'N') = 'O')
205740 ) AND
205741 (l_bflow_method_code = 'PRIOR_ENTRY')
205742 )
205743 THEN
205744 IF
205745 --
205746 1 = 2
205747 --
205748 THEN
205749 xla_accounting_err_pkg.build_message
205750 (p_appli_s_name => 'XLA'
205751 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
205752 ,p_token_1 => 'LINE_NUMBER'
205753 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
205754 ,p_token_2 => 'LINE_TYPE_NAME'
205755 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
205756 l_component_type
205757 ,l_component_code
205758 ,l_component_type_code
205759 ,l_component_appl_id
205760 ,l_amb_context_code
205761 ,l_entity_code
205762 ,l_event_class_code
205763 )
205764 ,p_token_3 => 'OWNER'
205765 ,p_value_3 => xla_lookups_pkg.get_meaning(
205766 p_lookup_type => 'XLA_OWNER_TYPE'
205767 ,p_lookup_code => l_component_type_code
205768 )
205769 ,p_token_4 => 'PRODUCT_NAME'
205770 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
205771 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
205772 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
205773 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
205774 ,p_ae_header_id => NULL
205775 );
205776
205777 IF (C_LEVEL_ERROR>= g_log_level) THEN
205778 trace
205779 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
205780 ,p_level => C_LEVEL_ERROR
205781 ,p_module => l_log_module);
205782 END IF;
205783 END IF;
205784 END IF;
205785 --
205786 --
205787 ------------------------------------------------------------------------------------------------
205788 -- 4219869 Business Flow
205789 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
205790 -- Prior Entry. Currently, the following code is always generated.
205791 ------------------------------------------------------------------------------------------------
205792 XLA_AE_LINES_PKG.ValidateCurrentLine;
205793
205794 ------------------------------------------------------------------------------------
205795 -- 4219869 Business Flow
205796 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
205797 ------------------------------------------------------------------------------------
205798 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
205799
205800 ----------------------------------------------------------------------------------
205801 -- 4219869 Business Flow
205802 -- Update journal entry status -- Need to generate this within IF <condition>
205803 ----------------------------------------------------------------------------------
205804 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
205805 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
205806 ,p_balance_type_code => l_balance_type_code
205807 );
205808
205809 -------------------------------------------------------------------------------------------
205810 -- 4262811 - Generate the Accrual Reversal lines
205811 -------------------------------------------------------------------------------------------
205812 BEGIN
205813 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
205814 (g_array_event(p_event_id).array_value_num('header_index'));
205815 IF l_acc_rev_flag IS NULL THEN
205816 l_acc_rev_flag := 'N';
205817 END IF;
205818 EXCEPTION
205819 WHEN OTHERS THEN
205820 l_acc_rev_flag := 'N';
205821 END;
205822 --
205823 IF (l_acc_rev_flag = 'Y') THEN
205824
205825 -- 4645092 ------------------------------------------------------------------------------
205826 -- To allow MPA report to determine if it should generate report process
205827 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
205828 ------------------------------------------------------------------------------------------
205829
205830 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
205831 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
205832 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
205833 -- call ADRs
205834 -- Bug 4922099
205835 --
205836 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
205837 (NVL(l_actual_upg_option, 'N') = 'O') OR
205838 (NVL(l_enc_upg_option, 'N') = 'O')
205839 )
205840 THEN
205841 NULL;
205842 --
205843 --
205844
205845 l_ccid := AcctDerRule_11(
205846 p_application_id => p_application_id
205847 , p_ae_header_id => l_ae_header_id
205848 , p_source_22 => p_source_22
205849 , x_transaction_coa_id => l_adr_transaction_coa_id
205850 , x_accounting_coa_id => l_adr_accounting_coa_id
205851 , x_value_type_code => l_adr_value_type_code
205852 , p_side => 'NA'
205853 );
205854
205855 xla_ae_lines_pkg.set_ccid(
205856 p_code_combination_id => l_ccid
205857 , p_value_type_code => l_adr_value_type_code
205858 , p_transaction_coa_id => l_adr_transaction_coa_id
205859 , p_accounting_coa_id => l_adr_accounting_coa_id
205860 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
205861 , p_adr_type_code => 'S'
205862 , p_component_type => l_component_type
205863 , p_component_code => l_component_code
205864 , p_component_type_code => l_component_type_code
205865 , p_component_appl_id => l_component_appl_id
205866 , p_amb_context_code => l_amb_context_code
205867 , p_side => 'NA'
205868 );
205869
205870
205871 --
205872 --
205873 END IF;
205874
205875 --
205876 -- Update the line information that should be overwritten
205877 --
205878 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
205879 p_header_num => 1);
205880 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
205881
205882 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
205883
205884 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
205885 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
205886 END IF;
205887
205888 --
205889 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
205890 --
205891 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
205892 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
205893 ELSE
205894 ---------------------------------------------------------------------------------------------------
205895 -- 4262811a Switch Sign
205896 ---------------------------------------------------------------------------------------------------
205897 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
205898 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
205899 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205900 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
205901 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205902 -- 5132302
205903 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
205904 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
205905
205906 END IF;
205907
205908 -- 4955764
205909 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
205910 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
205911
205912
205913 XLA_AE_LINES_PKG.ValidateCurrentLine;
205914 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
205915
205916 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
205917 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
205918 ,p_balance_type_code => l_balance_type_code);
205919
205920 END IF;
205921
205922 -----------------------------------------------------------------------------------------
205923 -- 4262811 Multiperiod Accounting
205924 -----------------------------------------------------------------------------------------
205925 -- No MPA option is assigned.
205926
205927
205928 END IF;
205929 END IF;
205930 --
205931
205932 --
205933 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
205934 trace
205935 (p_msg => 'END of AcctLineType_375'
205936 ,p_level => C_LEVEL_PROCEDURE
205937 ,p_module => l_log_module);
205938 END IF;
205939 --
205940 EXCEPTION
205941 WHEN xla_exceptions_pkg.application_exception THEN
205942 RAISE;
205943 WHEN OTHERS THEN
205944 xla_exceptions_pkg.raise_message
205945 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_375');
205946 END AcctLineType_375;
205947 --
205948
205949 ---------------------------------------
205950 --
205951 -- PRIVATE FUNCTION
205952 -- AcctLineType_376
205953 --
205954 ---------------------------------------
205955 PROCEDURE AcctLineType_376 (
205956 p_application_id IN NUMBER
205957 ,p_event_id IN NUMBER
205958 ,p_calculate_acctd_flag IN VARCHAR2
205959 ,p_calculate_g_l_flag IN VARCHAR2
205960 ,p_actual_flag IN OUT VARCHAR2
205961 ,p_balance_type_code OUT VARCHAR2
205962 ,p_gain_or_loss_ref OUT VARCHAR2
205963
205964 --TRANSACTION_ID
205965 , p_source_1 IN NUMBER
205966 --Item Concatenated Segments
205967 , p_source_2 IN VARCHAR2
205968 --Transaction Quantity
205969 , p_source_3 IN NUMBER
205970 --Transaction Unit of Measure Code
205971 , p_source_4 IN VARCHAR2
205972 --Inventory Transaction Type Description
205973 , p_source_5 IN VARCHAR2
205974 --Product Line Accounting Category Bridging Account
205975 , p_source_22 IN NUMBER
205976 --Applied to Application ID
205977 , p_source_79 IN NUMBER
205978 --Applied to Distribution Link Type
205979 , p_source_80 IN VARCHAR2
205980 --Applied to Entity Code
205981 , p_source_81 IN VARCHAR2
205982 --DISTRIBUTION_IDENTIFIER
205983 , p_source_84 IN NUMBER
205984 --Distribution Type
205985 , p_source_85 IN VARCHAR2
205986 , p_source_85_meaning IN VARCHAR2
205987 --Encumbrance Reversal Amount Entered
205988 , p_source_87 IN NUMBER
205989 --Entered Currency Code
205990 , p_source_88 IN VARCHAR2
205991 --Transaction Encumbrance Reversal Amount
205992 , p_source_89 IN NUMBER
205993 --Entered Amount
205994 , p_source_91 IN NUMBER
205995 --Currency Conversion Date
205996 , p_source_92 IN DATE
205997 --Currency Conversion Rate
205998 , p_source_93 IN NUMBER
205999 --Currency Conversion Type
206000 , p_source_94 IN VARCHAR2
206001 --Accounted Amount
206002 , p_source_95 IN NUMBER
206003 --Accounting Line Type
206004 , p_source_97 IN NUMBER
206005 --Costing Encumbrance Upgrade Option
206006 , p_source_100 IN VARCHAR2
206007 --TXN_PO_DISTRIBUTION_ID
206008 , p_source_101 IN NUMBER
206009 --TXN_PO_HEADER_ID
206010 , p_source_102 IN NUMBER
206011 --Requisition Budget Account
206012 , p_source_103 IN NUMBER
206013 --Requisition Encumbrance Type Identifier
206014 , p_source_104 IN NUMBER
206015 )
206016 IS
206017
206018 l_component_type VARCHAR2(80);
206019 l_component_code VARCHAR2(30);
206020 l_component_type_code VARCHAR2(1);
206021 l_component_appl_id INTEGER;
206022 l_amb_context_code VARCHAR2(30);
206023 l_entity_code VARCHAR2(30);
206024 l_event_class_code VARCHAR2(30);
206025 l_ae_header_id NUMBER;
206026 l_event_type_code VARCHAR2(30);
206027 l_line_definition_code VARCHAR2(30);
206028 l_line_definition_owner_code VARCHAR2(1);
206029 --
206030 -- adr variables
206031 l_segment VARCHAR2(30);
206032 l_ccid NUMBER;
206033 l_adr_transaction_coa_id NUMBER;
206034 l_adr_accounting_coa_id NUMBER;
206035 l_adr_flexfield_segment_code VARCHAR2(30);
206036 l_adr_flex_value_set_id NUMBER;
206037 l_adr_value_type_code VARCHAR2(30);
206038 l_adr_value_combination_id NUMBER;
206039 l_adr_value_segment_code VARCHAR2(30);
206040
206041 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
206042 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
206043 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
206044 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
206045
206046 -- 4262811 Variables ------------------------------------------------------------------------------------------
206047 l_entered_amt_idx NUMBER;
206048 l_accted_amt_idx NUMBER;
206049 l_acc_rev_flag VARCHAR2(1);
206050 l_accrual_line_num NUMBER;
206051 l_tmp_amt NUMBER;
206052 l_acc_rev_natural_side_code VARCHAR2(1);
206053
206054 l_num_entries NUMBER;
206055 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
206056 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
206057 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
206058 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
206059 l_recog_line_1 NUMBER;
206060 l_recog_line_2 NUMBER;
206061
206062 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
206063 l_bflow_applied_to_amt NUMBER; -- 5132302
206064 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
206065
206066 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
206067
206068 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
206069 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
206070
206071 ---------------------------------------------------------------------------------------------------------------
206072
206073
206074 --
206075 -- bulk performance
206076 --
206077 l_balance_type_code VARCHAR2(1);
206078 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
206079 l_log_module VARCHAR2(240);
206080
206081 --
206082 -- Upgrade strategy
206083 --
206084 l_actual_upg_option VARCHAR2(1);
206085 l_enc_upg_option VARCHAR2(1);
206086
206087 --
206088 BEGIN
206089 --
206090 IF g_log_enabled THEN
206091 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_376';
206092 END IF;
206093 --
206094 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
206095
206096 trace
206097 (p_msg => 'BEGIN of AcctLineType_376'
206098 ,p_level => C_LEVEL_PROCEDURE
206099 ,p_module => l_log_module);
206100
206101 END IF;
206102 --
206103 l_component_type := 'AMB_JLT';
206104 l_component_code := 'PI_BRIDGING';
206105 l_component_type_code := 'S';
206106 l_component_appl_id := 707;
206107 l_amb_context_code := 'DEFAULT';
206108 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
206109 l_event_class_code := 'DIR_INTERORG_RCPT';
206110 l_event_type_code := 'DIR_INTERORG_RCPT_ALL';
206111 l_line_definition_owner_code := 'S';
206112 l_line_definition_code := 'PI_DIR_INTERORG_RCPT';
206113 --
206114 l_balance_type_code := 'A';
206115 l_segment := NULL;
206116 l_ccid := NULL;
206117 l_adr_transaction_coa_id := NULL;
206118 l_adr_accounting_coa_id := NULL;
206119 l_adr_flexfield_segment_code := NULL;
206120 l_adr_flex_value_set_id := NULL;
206121 l_adr_value_type_code := NULL;
206122 l_adr_value_combination_id := NULL;
206123 l_adr_value_segment_code := NULL;
206124
206125 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
206126 l_bflow_class_code := ''; -- 4219869 Business Flow
206127 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
206128 l_budgetary_control_flag := 'N';
206129
206130 l_bflow_applied_to_amt_idx := NULL; -- 5132302
206131 l_bflow_applied_to_amt := NULL; -- 5132302
206132 l_entered_amt_idx := NULL; -- 4262811
206133 l_accted_amt_idx := NULL; -- 4262811
206134 l_acc_rev_flag := NULL; -- 4262811
206135 l_accrual_line_num := NULL; -- 4262811
206136 l_tmp_amt := NULL; -- 4262811
206137 --
206138
206139 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
206140 l_balance_type_code <> 'B' THEN
206141 IF NVL(p_source_97,9E125) = 1
206142 THEN
206143
206144 --
206145 XLA_AE_LINES_PKG.SetNewLine;
206146
206147 p_balance_type_code := l_balance_type_code;
206148 -- set the flag so later we will know whether the gain loss line needs to be created
206149
206150 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
206151 p_actual_flag :='A';
206152 END IF;
206153
206154 --
206155 -- bulk performance
206156 --
206157 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
206158 p_header_num => 0); -- 4262811
206159 --
206160 -- set accounting line options
206161 --
206162 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
206163 p_natural_side_code => 'C'
206164 , p_gain_or_loss_flag => 'N'
206165 , p_gl_transfer_mode_code => 'S'
206166 , p_acct_entry_type_code => 'A'
206167 , p_switch_side_flag => 'Y'
206168 , p_merge_duplicate_code => 'N'
206169 );
206170 --
206171 l_acc_rev_natural_side_code := 'D'; -- 4262811
206172 --
206173 --
206174 -- set accounting line type info
206175 --
206176 xla_ae_lines_pkg.SetAcctLineType
206177 (p_component_type => l_component_type
206178 ,p_event_type_code => l_event_type_code
206179 ,p_line_definition_owner_code => l_line_definition_owner_code
206180 ,p_line_definition_code => l_line_definition_code
206181 ,p_accounting_line_code => l_component_code
206182 ,p_accounting_line_type_code => l_component_type_code
206183 ,p_accounting_line_appl_id => l_component_appl_id
206184 ,p_amb_context_code => l_amb_context_code
206185 ,p_entity_code => l_entity_code
206186 ,p_event_class_code => l_event_class_code);
206187 --
206188 -- set accounting class
206189 --
206190 xla_ae_lines_pkg.SetAcctClass(
206191 p_accounting_class_code => 'BRIDGING'
206192 , p_ae_header_id => l_ae_header_id
206193 );
206194
206195 --
206196 -- set rounding class
206197 --
206198 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
206199 'BRIDGING';
206200
206201 --
206202 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
206203 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
206204 --
206205 -- bulk performance
206206 --
206207 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
206208
206209 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
206210 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
206211
206212 -- 4955764
206213 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
206214 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
206215
206216 -- 4458381 Public Sector Enh
206217
206218 --
206219 -- set accounting attributes for the line type
206220 --
206221 l_entered_amt_idx := 17;
206222 l_accted_amt_idx := 22;
206223 l_bflow_applied_to_amt_idx := NULL; -- 5132302
206224 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
206225 l_rec_acct_attrs.array_num_value(1) := p_source_79;
206226 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
206227 l_rec_acct_attrs.array_char_value(2) := p_source_80;
206228 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
206229 l_rec_acct_attrs.array_char_value(3) := p_source_81;
206230 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
206231 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_101);
206232 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
206233 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_102);
206234 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
206235 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_84);
206236 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
206237 l_rec_acct_attrs.array_char_value(7) := p_source_85;
206238 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENC_UPG_CR_CCID';
206239 l_rec_acct_attrs.array_num_value(8) := TO_NUMBER(p_source_103);
206240 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENC_UPG_CR_ENTERED_AMT';
206241 l_rec_acct_attrs.array_num_value(9) := p_source_87;
206242 l_rec_acct_attrs.array_acct_attr_code(10) := 'ENC_UPG_CR_ENTERED_CURR';
206243 l_rec_acct_attrs.array_char_value(10) := p_source_88;
206244 l_rec_acct_attrs.array_acct_attr_code(11) := 'ENC_UPG_CR_LEDGER_AMT';
206245 l_rec_acct_attrs.array_num_value(11) := p_source_89;
206246 l_rec_acct_attrs.array_acct_attr_code(12) := 'ENC_UPG_DR_CCID';
206247 l_rec_acct_attrs.array_num_value(12) := TO_NUMBER(p_source_103);
206248 l_rec_acct_attrs.array_acct_attr_code(13) := 'ENC_UPG_DR_ENTERED_AMT';
206249 l_rec_acct_attrs.array_num_value(13) := p_source_87;
206250 l_rec_acct_attrs.array_acct_attr_code(14) := 'ENC_UPG_DR_ENTERED_CURR';
206251 l_rec_acct_attrs.array_char_value(14) := p_source_88;
206252 l_rec_acct_attrs.array_acct_attr_code(15) := 'ENC_UPG_DR_LEDGER_AMT';
206253 l_rec_acct_attrs.array_num_value(15) := p_source_89;
206254 l_rec_acct_attrs.array_acct_attr_code(16) := 'ENC_UPG_OPTION';
206255 l_rec_acct_attrs.array_char_value(16) := p_source_100;
206256 l_rec_acct_attrs.array_acct_attr_code(17) := 'ENTERED_CURRENCY_AMOUNT';
206257 l_rec_acct_attrs.array_num_value(17) := p_source_91;
206258 l_rec_acct_attrs.array_acct_attr_code(18) := 'ENTERED_CURRENCY_CODE';
206259 l_rec_acct_attrs.array_char_value(18) := p_source_88;
206260 l_rec_acct_attrs.array_acct_attr_code(19) := 'EXCHANGE_DATE';
206261 l_rec_acct_attrs.array_date_value(19) := p_source_92;
206262 l_rec_acct_attrs.array_acct_attr_code(20) := 'EXCHANGE_RATE';
206263 l_rec_acct_attrs.array_num_value(20) := p_source_93;
206264 l_rec_acct_attrs.array_acct_attr_code(21) := 'EXCHANGE_RATE_TYPE';
206265 l_rec_acct_attrs.array_char_value(21) := p_source_94;
206266 l_rec_acct_attrs.array_acct_attr_code(22) := 'LEDGER_AMOUNT';
206267 l_rec_acct_attrs.array_num_value(22) := p_source_95;
206268 l_rec_acct_attrs.array_acct_attr_code(23) := 'UPG_CR_ENC_TYPE_ID';
206269 l_rec_acct_attrs.array_num_value(23) := p_source_104;
206270 l_rec_acct_attrs.array_acct_attr_code(24) := 'UPG_DR_ENC_TYPE_ID';
206271 l_rec_acct_attrs.array_num_value(24) := p_source_104;
206272
206273 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
206274 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
206275
206276 ---------------------------------------------------------------------------------------------------------------
206277 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
206278 ---------------------------------------------------------------------------------------------------------------
206279 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
206280
206281 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
206282 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
206283
206284 IF xla_accounting_cache_pkg.GetValueChar
206285 (p_source_code => 'LEDGER_CATEGORY_CODE'
206286 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
206287 AND l_bflow_method_code = 'PRIOR_ENTRY'
206288 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
206289 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
206290 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
206291 )
206292 THEN
206293 xla_ae_lines_pkg.BflowUpgEntry
206294 (p_business_method_code => l_bflow_method_code
206295 ,p_business_class_code => l_bflow_class_code
206296 ,p_balance_type => l_balance_type_code);
206297 ELSE
206298 NULL;
206299 -- No business flow processing for business flow method of NONE.
206300 END IF;
206301
206302 --
206303 -- call analytical criteria
206304 --
206305
206306 --
206307 -- call description
206308 --
206309
206310 xla_ae_lines_pkg.SetLineDescription(
206311 p_ae_header_id => l_ae_header_id
206312 ,p_description => Description_1 (
206313 p_application_id => p_application_id
206314 , p_ae_header_id => l_ae_header_id
206315 , p_source_1 => p_source_1
206316 , p_source_2 => p_source_2
206317 , p_source_3 => p_source_3
206318 , p_source_4 => p_source_4
206319 , p_source_5 => p_source_5
206320 )
206321 );
206322
206323
206324 --
206325 -- call ADRs
206326 -- Bug 4922099
206327 --
206328 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
206329 (NVL(l_actual_upg_option, 'N') = 'O') OR
206330 (NVL(l_enc_upg_option, 'N') = 'O')
206331 )
206332 THEN
206333 NULL;
206334 --
206335 --
206336
206337 l_ccid := AcctDerRule_11(
206338 p_application_id => p_application_id
206339 , p_ae_header_id => l_ae_header_id
206340 , p_source_22 => p_source_22
206341 , x_transaction_coa_id => l_adr_transaction_coa_id
206342 , x_accounting_coa_id => l_adr_accounting_coa_id
206343 , x_value_type_code => l_adr_value_type_code
206344 , p_side => 'NA'
206345 );
206346
206347 xla_ae_lines_pkg.set_ccid(
206348 p_code_combination_id => l_ccid
206349 , p_value_type_code => l_adr_value_type_code
206350 , p_transaction_coa_id => l_adr_transaction_coa_id
206351 , p_accounting_coa_id => l_adr_accounting_coa_id
206352 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
206353 , p_adr_type_code => 'S'
206354 , p_component_type => l_component_type
206355 , p_component_code => l_component_code
206356 , p_component_type_code => l_component_type_code
206357 , p_component_appl_id => l_component_appl_id
206358 , p_amb_context_code => l_amb_context_code
206359 , p_side => 'NA'
206360 );
206361
206362
206363 --
206364 --
206365 END IF;
206366 --
206367 -- Bug 4922099
206368 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
206369 (NVL(l_enc_upg_option, 'N') = 'O')
206370 ) AND
206371 (l_bflow_method_code = 'PRIOR_ENTRY')
206372 )
206373 THEN
206374 IF
206375 --
206376 1 = 2
206377 --
206378 THEN
206379 xla_accounting_err_pkg.build_message
206380 (p_appli_s_name => 'XLA'
206381 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
206382 ,p_token_1 => 'LINE_NUMBER'
206383 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
206384 ,p_token_2 => 'LINE_TYPE_NAME'
206385 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
206386 l_component_type
206387 ,l_component_code
206388 ,l_component_type_code
206389 ,l_component_appl_id
206390 ,l_amb_context_code
206391 ,l_entity_code
206392 ,l_event_class_code
206393 )
206394 ,p_token_3 => 'OWNER'
206395 ,p_value_3 => xla_lookups_pkg.get_meaning(
206396 p_lookup_type => 'XLA_OWNER_TYPE'
206397 ,p_lookup_code => l_component_type_code
206398 )
206399 ,p_token_4 => 'PRODUCT_NAME'
206400 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
206401 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
206402 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
206403 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
206404 ,p_ae_header_id => NULL
206405 );
206406
206407 IF (C_LEVEL_ERROR>= g_log_level) THEN
206408 trace
206409 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
206410 ,p_level => C_LEVEL_ERROR
206411 ,p_module => l_log_module);
206412 END IF;
206413 END IF;
206414 END IF;
206415 --
206416 --
206417 ------------------------------------------------------------------------------------------------
206418 -- 4219869 Business Flow
206419 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
206420 -- Prior Entry. Currently, the following code is always generated.
206421 ------------------------------------------------------------------------------------------------
206422 XLA_AE_LINES_PKG.ValidateCurrentLine;
206423
206424 ------------------------------------------------------------------------------------
206425 -- 4219869 Business Flow
206426 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
206427 ------------------------------------------------------------------------------------
206428 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
206429
206430 ----------------------------------------------------------------------------------
206431 -- 4219869 Business Flow
206432 -- Update journal entry status -- Need to generate this within IF <condition>
206433 ----------------------------------------------------------------------------------
206434 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
206435 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
206436 ,p_balance_type_code => l_balance_type_code
206437 );
206438
206439 -------------------------------------------------------------------------------------------
206440 -- 4262811 - Generate the Accrual Reversal lines
206441 -------------------------------------------------------------------------------------------
206442 BEGIN
206443 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
206444 (g_array_event(p_event_id).array_value_num('header_index'));
206445 IF l_acc_rev_flag IS NULL THEN
206446 l_acc_rev_flag := 'N';
206447 END IF;
206448 EXCEPTION
206449 WHEN OTHERS THEN
206450 l_acc_rev_flag := 'N';
206451 END;
206452 --
206453 IF (l_acc_rev_flag = 'Y') THEN
206454
206455 -- 4645092 ------------------------------------------------------------------------------
206456 -- To allow MPA report to determine if it should generate report process
206457 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
206458 ------------------------------------------------------------------------------------------
206459
206460 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
206461 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
206462 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
206463 -- call ADRs
206464 -- Bug 4922099
206465 --
206466 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
206467 (NVL(l_actual_upg_option, 'N') = 'O') OR
206468 (NVL(l_enc_upg_option, 'N') = 'O')
206469 )
206470 THEN
206471 NULL;
206472 --
206473 --
206474
206475 l_ccid := AcctDerRule_11(
206476 p_application_id => p_application_id
206477 , p_ae_header_id => l_ae_header_id
206478 , p_source_22 => p_source_22
206479 , x_transaction_coa_id => l_adr_transaction_coa_id
206480 , x_accounting_coa_id => l_adr_accounting_coa_id
206481 , x_value_type_code => l_adr_value_type_code
206482 , p_side => 'NA'
206483 );
206484
206485 xla_ae_lines_pkg.set_ccid(
206486 p_code_combination_id => l_ccid
206487 , p_value_type_code => l_adr_value_type_code
206488 , p_transaction_coa_id => l_adr_transaction_coa_id
206489 , p_accounting_coa_id => l_adr_accounting_coa_id
206490 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
206491 , p_adr_type_code => 'S'
206492 , p_component_type => l_component_type
206493 , p_component_code => l_component_code
206494 , p_component_type_code => l_component_type_code
206495 , p_component_appl_id => l_component_appl_id
206496 , p_amb_context_code => l_amb_context_code
206497 , p_side => 'NA'
206498 );
206499
206500
206501 --
206502 --
206503 END IF;
206504
206505 --
206506 -- Update the line information that should be overwritten
206507 --
206508 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
206509 p_header_num => 1);
206510 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
206511
206512 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
206513
206514 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
206515 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
206516 END IF;
206517
206518 --
206519 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
206520 --
206521 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
206522 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
206523 ELSE
206524 ---------------------------------------------------------------------------------------------------
206525 -- 4262811a Switch Sign
206526 ---------------------------------------------------------------------------------------------------
206527 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
206528 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
206529 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
206530 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
206531 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
206532 -- 5132302
206533 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
206534 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
206535
206536 END IF;
206537
206538 -- 4955764
206539 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
206540 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
206541
206542
206543 XLA_AE_LINES_PKG.ValidateCurrentLine;
206544 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
206545
206546 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
206547 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
206548 ,p_balance_type_code => l_balance_type_code);
206549
206550 END IF;
206551
206552 -----------------------------------------------------------------------------------------
206553 -- 4262811 Multiperiod Accounting
206554 -----------------------------------------------------------------------------------------
206555 -- No MPA option is assigned.
206556
206557
206558 END IF;
206559 END IF;
206560 --
206561
206562 --
206563 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
206564 trace
206565 (p_msg => 'END of AcctLineType_376'
206566 ,p_level => C_LEVEL_PROCEDURE
206567 ,p_module => l_log_module);
206568 END IF;
206569 --
206570 EXCEPTION
206571 WHEN xla_exceptions_pkg.application_exception THEN
206572 RAISE;
206573 WHEN OTHERS THEN
206574 xla_exceptions_pkg.raise_message
206575 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_376');
206576 END AcctLineType_376;
206577 --
206578
206579 ---------------------------------------
206580 --
206581 -- PRIVATE FUNCTION
206582 -- AcctLineType_377
206583 --
206584 ---------------------------------------
206585 PROCEDURE AcctLineType_377 (
206586 p_application_id IN NUMBER
206587 ,p_event_id IN NUMBER
206588 ,p_calculate_acctd_flag IN VARCHAR2
206589 ,p_calculate_g_l_flag IN VARCHAR2
206590 ,p_actual_flag IN OUT VARCHAR2
206591 ,p_balance_type_code OUT VARCHAR2
206592 ,p_gain_or_loss_ref OUT VARCHAR2
206593
206594 --TRANSACTION_ID
206595 , p_source_1 IN NUMBER
206596 --Item Concatenated Segments
206597 , p_source_2 IN VARCHAR2
206598 --Transaction Quantity
206599 , p_source_3 IN NUMBER
206600 --Transaction Unit of Measure Code
206601 , p_source_4 IN VARCHAR2
206602 --Inventory Transaction Type Description
206603 , p_source_5 IN VARCHAR2
206604 --Product Line Accounting Category Bridging Account
206605 , p_source_22 IN NUMBER
206606 --DISTRIBUTION_IDENTIFIER
206607 , p_source_84 IN NUMBER
206608 --Distribution Type
206609 , p_source_85 IN VARCHAR2
206610 , p_source_85_meaning IN VARCHAR2
206611 --Entered Currency Code
206612 , p_source_88 IN VARCHAR2
206613 --Entered Amount
206614 , p_source_91 IN NUMBER
206615 --Currency Conversion Date
206616 , p_source_92 IN DATE
206617 --Currency Conversion Rate
206618 , p_source_93 IN NUMBER
206619 --Currency Conversion Type
206620 , p_source_94 IN VARCHAR2
206621 --Accounted Amount
206622 , p_source_95 IN NUMBER
206623 --Accounting Line Type
206624 , p_source_97 IN NUMBER
206625 --Subinventory Type Indicator
206626 , p_source_110 IN VARCHAR2
206627 , p_source_110_meaning IN VARCHAR2
206628 )
206629 IS
206630
206631 l_component_type VARCHAR2(80);
206632 l_component_code VARCHAR2(30);
206633 l_component_type_code VARCHAR2(1);
206634 l_component_appl_id INTEGER;
206635 l_amb_context_code VARCHAR2(30);
206636 l_entity_code VARCHAR2(30);
206637 l_event_class_code VARCHAR2(30);
206638 l_ae_header_id NUMBER;
206639 l_event_type_code VARCHAR2(30);
206640 l_line_definition_code VARCHAR2(30);
206641 l_line_definition_owner_code VARCHAR2(1);
206642 --
206643 -- adr variables
206644 l_segment VARCHAR2(30);
206645 l_ccid NUMBER;
206646 l_adr_transaction_coa_id NUMBER;
206647 l_adr_accounting_coa_id NUMBER;
206648 l_adr_flexfield_segment_code VARCHAR2(30);
206649 l_adr_flex_value_set_id NUMBER;
206650 l_adr_value_type_code VARCHAR2(30);
206651 l_adr_value_combination_id NUMBER;
206652 l_adr_value_segment_code VARCHAR2(30);
206653
206654 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
206655 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
206656 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
206657 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
206658
206659 -- 4262811 Variables ------------------------------------------------------------------------------------------
206660 l_entered_amt_idx NUMBER;
206661 l_accted_amt_idx NUMBER;
206662 l_acc_rev_flag VARCHAR2(1);
206663 l_accrual_line_num NUMBER;
206664 l_tmp_amt NUMBER;
206665 l_acc_rev_natural_side_code VARCHAR2(1);
206666
206667 l_num_entries NUMBER;
206668 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
206669 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
206670 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
206671 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
206672 l_recog_line_1 NUMBER;
206673 l_recog_line_2 NUMBER;
206674
206675 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
206676 l_bflow_applied_to_amt NUMBER; -- 5132302
206677 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
206678
206679 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
206680
206681 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
206682 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
206683
206684 ---------------------------------------------------------------------------------------------------------------
206685
206686
206687 --
206688 -- bulk performance
206689 --
206690 l_balance_type_code VARCHAR2(1);
206691 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
206692 l_log_module VARCHAR2(240);
206693
206694 --
206695 -- Upgrade strategy
206696 --
206697 l_actual_upg_option VARCHAR2(1);
206698 l_enc_upg_option VARCHAR2(1);
206699
206700 --
206701 BEGIN
206702 --
206703 IF g_log_enabled THEN
206704 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_377';
206705 END IF;
206706 --
206707 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
206708
206709 trace
206710 (p_msg => 'BEGIN of AcctLineType_377'
206711 ,p_level => C_LEVEL_PROCEDURE
206712 ,p_module => l_log_module);
206713
206714 END IF;
206715 --
206716 l_component_type := 'AMB_JLT';
206717 l_component_code := 'PI_BRIDGING';
206718 l_component_type_code := 'S';
206719 l_component_appl_id := 707;
206720 l_amb_context_code := 'DEFAULT';
206721 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
206722 l_event_class_code := 'WIP_MTL';
206723 l_event_type_code := 'WIP_ASSEMBLY_RETURN';
206724 l_line_definition_owner_code := 'S';
206725 l_line_definition_code := 'PI_WIP_ASSEMBLY_RETURN';
206726 --
206727 l_balance_type_code := 'A';
206728 l_segment := NULL;
206729 l_ccid := NULL;
206730 l_adr_transaction_coa_id := NULL;
206731 l_adr_accounting_coa_id := NULL;
206732 l_adr_flexfield_segment_code := NULL;
206733 l_adr_flex_value_set_id := NULL;
206734 l_adr_value_type_code := NULL;
206735 l_adr_value_combination_id := NULL;
206736 l_adr_value_segment_code := NULL;
206737
206738 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
206739 l_bflow_class_code := ''; -- 4219869 Business Flow
206740 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
206741 l_budgetary_control_flag := 'N';
206742
206743 l_bflow_applied_to_amt_idx := NULL; -- 5132302
206744 l_bflow_applied_to_amt := NULL; -- 5132302
206745 l_entered_amt_idx := NULL; -- 4262811
206746 l_accted_amt_idx := NULL; -- 4262811
206747 l_acc_rev_flag := NULL; -- 4262811
206748 l_accrual_line_num := NULL; -- 4262811
206749 l_tmp_amt := NULL; -- 4262811
206750 --
206751
206752 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
206753 l_balance_type_code <> 'B' THEN
206754 IF (NVL(p_source_97,9E125) = 1 OR
206755 NVL(p_source_97,9E125) = 2 OR
206756 NVL(p_source_97,9E125) = 3) AND
206757 NVL(p_source_110,'
206758 ') = 'Y'
206759 THEN
206760
206761 --
206762 XLA_AE_LINES_PKG.SetNewLine;
206763
206764 p_balance_type_code := l_balance_type_code;
206765 -- set the flag so later we will know whether the gain loss line needs to be created
206766
206767 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
206768 p_actual_flag :='A';
206769 END IF;
206770
206771 --
206772 -- bulk performance
206773 --
206774 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
206775 p_header_num => 0); -- 4262811
206776 --
206777 -- set accounting line options
206778 --
206779 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
206780 p_natural_side_code => 'C'
206781 , p_gain_or_loss_flag => 'N'
206782 , p_gl_transfer_mode_code => 'S'
206783 , p_acct_entry_type_code => 'A'
206784 , p_switch_side_flag => 'Y'
206785 , p_merge_duplicate_code => 'N'
206786 );
206787 --
206788 l_acc_rev_natural_side_code := 'D'; -- 4262811
206789 --
206790 --
206791 -- set accounting line type info
206792 --
206793 xla_ae_lines_pkg.SetAcctLineType
206794 (p_component_type => l_component_type
206795 ,p_event_type_code => l_event_type_code
206796 ,p_line_definition_owner_code => l_line_definition_owner_code
206797 ,p_line_definition_code => l_line_definition_code
206798 ,p_accounting_line_code => l_component_code
206799 ,p_accounting_line_type_code => l_component_type_code
206800 ,p_accounting_line_appl_id => l_component_appl_id
206801 ,p_amb_context_code => l_amb_context_code
206802 ,p_entity_code => l_entity_code
206803 ,p_event_class_code => l_event_class_code);
206804 --
206805 -- set accounting class
206806 --
206807 xla_ae_lines_pkg.SetAcctClass(
206808 p_accounting_class_code => 'BRIDGING'
206809 , p_ae_header_id => l_ae_header_id
206810 );
206811
206812 --
206813 -- set rounding class
206814 --
206815 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
206816 'BRIDGING';
206817
206818 --
206819 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
206820 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
206821 --
206822 -- bulk performance
206823 --
206824 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
206825
206826 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
206827 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
206828
206829 -- 4955764
206830 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
206831 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
206832
206833 -- 4458381 Public Sector Enh
206834
206835 --
206836 -- set accounting attributes for the line type
206837 --
206838 l_entered_amt_idx := 3;
206839 l_accted_amt_idx := 8;
206840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
206841 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
206842 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
206843 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
206844 l_rec_acct_attrs.array_char_value(2) := p_source_85;
206845 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
206846 l_rec_acct_attrs.array_num_value(3) := p_source_91;
206847 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
206848 l_rec_acct_attrs.array_char_value(4) := p_source_88;
206849 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
206850 l_rec_acct_attrs.array_date_value(5) := p_source_92;
206851 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
206852 l_rec_acct_attrs.array_num_value(6) := p_source_93;
206853 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
206854 l_rec_acct_attrs.array_char_value(7) := p_source_94;
206855 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
206856 l_rec_acct_attrs.array_num_value(8) := p_source_95;
206857
206858 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
206859 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
206860
206861 ---------------------------------------------------------------------------------------------------------------
206862 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
206863 ---------------------------------------------------------------------------------------------------------------
206864 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
206865
206866 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
206867 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
206868
206869 IF xla_accounting_cache_pkg.GetValueChar
206870 (p_source_code => 'LEDGER_CATEGORY_CODE'
206871 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
206872 AND l_bflow_method_code = 'PRIOR_ENTRY'
206873 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
206874 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
206875 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
206876 )
206877 THEN
206878 xla_ae_lines_pkg.BflowUpgEntry
206879 (p_business_method_code => l_bflow_method_code
206880 ,p_business_class_code => l_bflow_class_code
206881 ,p_balance_type => l_balance_type_code);
206882 ELSE
206883 NULL;
206884 -- No business flow processing for business flow method of NONE.
206885 END IF;
206886
206887 --
206888 -- call analytical criteria
206889 --
206890
206891 --
206892 -- call description
206893 --
206894
206895 xla_ae_lines_pkg.SetLineDescription(
206896 p_ae_header_id => l_ae_header_id
206897 ,p_description => Description_1 (
206898 p_application_id => p_application_id
206899 , p_ae_header_id => l_ae_header_id
206900 , p_source_1 => p_source_1
206901 , p_source_2 => p_source_2
206902 , p_source_3 => p_source_3
206903 , p_source_4 => p_source_4
206904 , p_source_5 => p_source_5
206905 )
206906 );
206907
206908
206909 --
206910 -- call ADRs
206911 -- Bug 4922099
206912 --
206913 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
206914 (NVL(l_actual_upg_option, 'N') = 'O') OR
206915 (NVL(l_enc_upg_option, 'N') = 'O')
206916 )
206917 THEN
206918 NULL;
206919 --
206920 --
206921
206922 l_ccid := AcctDerRule_11(
206923 p_application_id => p_application_id
206924 , p_ae_header_id => l_ae_header_id
206925 , p_source_22 => p_source_22
206926 , x_transaction_coa_id => l_adr_transaction_coa_id
206927 , x_accounting_coa_id => l_adr_accounting_coa_id
206928 , x_value_type_code => l_adr_value_type_code
206929 , p_side => 'NA'
206930 );
206931
206932 xla_ae_lines_pkg.set_ccid(
206933 p_code_combination_id => l_ccid
206934 , p_value_type_code => l_adr_value_type_code
206935 , p_transaction_coa_id => l_adr_transaction_coa_id
206936 , p_accounting_coa_id => l_adr_accounting_coa_id
206937 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
206938 , p_adr_type_code => 'S'
206939 , p_component_type => l_component_type
206940 , p_component_code => l_component_code
206941 , p_component_type_code => l_component_type_code
206942 , p_component_appl_id => l_component_appl_id
206943 , p_amb_context_code => l_amb_context_code
206944 , p_side => 'NA'
206945 );
206946
206947
206948 --
206949 --
206950 END IF;
206951 --
206952 -- Bug 4922099
206953 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
206954 (NVL(l_enc_upg_option, 'N') = 'O')
206955 ) AND
206956 (l_bflow_method_code = 'PRIOR_ENTRY')
206957 )
206958 THEN
206959 IF
206960 --
206961 1 = 2
206962 --
206963 THEN
206964 xla_accounting_err_pkg.build_message
206965 (p_appli_s_name => 'XLA'
206966 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
206967 ,p_token_1 => 'LINE_NUMBER'
206968 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
206969 ,p_token_2 => 'LINE_TYPE_NAME'
206970 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
206971 l_component_type
206972 ,l_component_code
206973 ,l_component_type_code
206974 ,l_component_appl_id
206975 ,l_amb_context_code
206976 ,l_entity_code
206977 ,l_event_class_code
206978 )
206979 ,p_token_3 => 'OWNER'
206980 ,p_value_3 => xla_lookups_pkg.get_meaning(
206981 p_lookup_type => 'XLA_OWNER_TYPE'
206982 ,p_lookup_code => l_component_type_code
206983 )
206984 ,p_token_4 => 'PRODUCT_NAME'
206985 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
206986 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
206987 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
206988 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
206989 ,p_ae_header_id => NULL
206990 );
206991
206992 IF (C_LEVEL_ERROR>= g_log_level) THEN
206993 trace
206994 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
206995 ,p_level => C_LEVEL_ERROR
206996 ,p_module => l_log_module);
206997 END IF;
206998 END IF;
206999 END IF;
207000 --
207001 --
207002 ------------------------------------------------------------------------------------------------
207003 -- 4219869 Business Flow
207004 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
207005 -- Prior Entry. Currently, the following code is always generated.
207006 ------------------------------------------------------------------------------------------------
207007 XLA_AE_LINES_PKG.ValidateCurrentLine;
207008
207009 ------------------------------------------------------------------------------------
207010 -- 4219869 Business Flow
207011 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
207012 ------------------------------------------------------------------------------------
207013 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
207014
207015 ----------------------------------------------------------------------------------
207016 -- 4219869 Business Flow
207017 -- Update journal entry status -- Need to generate this within IF <condition>
207018 ----------------------------------------------------------------------------------
207019 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
207020 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
207021 ,p_balance_type_code => l_balance_type_code
207022 );
207023
207024 -------------------------------------------------------------------------------------------
207025 -- 4262811 - Generate the Accrual Reversal lines
207026 -------------------------------------------------------------------------------------------
207027 BEGIN
207028 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
207029 (g_array_event(p_event_id).array_value_num('header_index'));
207030 IF l_acc_rev_flag IS NULL THEN
207031 l_acc_rev_flag := 'N';
207032 END IF;
207033 EXCEPTION
207034 WHEN OTHERS THEN
207035 l_acc_rev_flag := 'N';
207036 END;
207037 --
207038 IF (l_acc_rev_flag = 'Y') THEN
207039
207040 -- 4645092 ------------------------------------------------------------------------------
207041 -- To allow MPA report to determine if it should generate report process
207042 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
207043 ------------------------------------------------------------------------------------------
207044
207045 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
207046 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
207047 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
207048 -- call ADRs
207049 -- Bug 4922099
207050 --
207051 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
207052 (NVL(l_actual_upg_option, 'N') = 'O') OR
207053 (NVL(l_enc_upg_option, 'N') = 'O')
207054 )
207055 THEN
207056 NULL;
207057 --
207058 --
207059
207060 l_ccid := AcctDerRule_11(
207061 p_application_id => p_application_id
207062 , p_ae_header_id => l_ae_header_id
207063 , p_source_22 => p_source_22
207064 , x_transaction_coa_id => l_adr_transaction_coa_id
207065 , x_accounting_coa_id => l_adr_accounting_coa_id
207066 , x_value_type_code => l_adr_value_type_code
207067 , p_side => 'NA'
207068 );
207069
207070 xla_ae_lines_pkg.set_ccid(
207071 p_code_combination_id => l_ccid
207072 , p_value_type_code => l_adr_value_type_code
207073 , p_transaction_coa_id => l_adr_transaction_coa_id
207074 , p_accounting_coa_id => l_adr_accounting_coa_id
207075 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
207076 , p_adr_type_code => 'S'
207077 , p_component_type => l_component_type
207078 , p_component_code => l_component_code
207079 , p_component_type_code => l_component_type_code
207080 , p_component_appl_id => l_component_appl_id
207081 , p_amb_context_code => l_amb_context_code
207082 , p_side => 'NA'
207083 );
207084
207085
207086 --
207087 --
207088 END IF;
207089
207090 --
207091 -- Update the line information that should be overwritten
207092 --
207093 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
207094 p_header_num => 1);
207095 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
207096
207097 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
207098
207099 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
207100 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
207101 END IF;
207102
207103 --
207104 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
207105 --
207106 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
207107 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
207108 ELSE
207109 ---------------------------------------------------------------------------------------------------
207110 -- 4262811a Switch Sign
207111 ---------------------------------------------------------------------------------------------------
207112 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
207113 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
207114 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207115 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
207116 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207117 -- 5132302
207118 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
207119 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207120
207121 END IF;
207122
207123 -- 4955764
207124 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
207125 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
207126
207127
207128 XLA_AE_LINES_PKG.ValidateCurrentLine;
207129 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
207130
207131 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
207132 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
207133 ,p_balance_type_code => l_balance_type_code);
207134
207135 END IF;
207136
207137 -----------------------------------------------------------------------------------------
207138 -- 4262811 Multiperiod Accounting
207139 -----------------------------------------------------------------------------------------
207140 -- No MPA option is assigned.
207141
207142
207143 END IF;
207144 END IF;
207145 --
207146
207147 --
207148 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
207149 trace
207150 (p_msg => 'END of AcctLineType_377'
207151 ,p_level => C_LEVEL_PROCEDURE
207152 ,p_module => l_log_module);
207153 END IF;
207154 --
207155 EXCEPTION
207156 WHEN xla_exceptions_pkg.application_exception THEN
207157 RAISE;
207158 WHEN OTHERS THEN
207159 xla_exceptions_pkg.raise_message
207160 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_377');
207161 END AcctLineType_377;
207162 --
207163
207164 ---------------------------------------
207165 --
207166 -- PRIVATE FUNCTION
207167 -- AcctLineType_378
207168 --
207169 ---------------------------------------
207170 PROCEDURE AcctLineType_378 (
207171 p_application_id IN NUMBER
207172 ,p_event_id IN NUMBER
207173 ,p_calculate_acctd_flag IN VARCHAR2
207174 ,p_calculate_g_l_flag IN VARCHAR2
207175 ,p_actual_flag IN OUT VARCHAR2
207176 ,p_balance_type_code OUT VARCHAR2
207177 ,p_gain_or_loss_ref OUT VARCHAR2
207178
207179 --TRANSACTION_ID
207180 , p_source_1 IN NUMBER
207181 --Item Concatenated Segments
207182 , p_source_2 IN VARCHAR2
207183 --Transaction Quantity
207184 , p_source_3 IN NUMBER
207185 --Transaction Unit of Measure Code
207186 , p_source_4 IN VARCHAR2
207187 --Inventory Transaction Type Description
207188 , p_source_5 IN VARCHAR2
207189 --Product Line Accounting Category Bridging Account
207190 , p_source_22 IN NUMBER
207191 --DISTRIBUTION_IDENTIFIER
207192 , p_source_84 IN NUMBER
207193 --Distribution Type
207194 , p_source_85 IN VARCHAR2
207195 , p_source_85_meaning IN VARCHAR2
207196 --Entered Currency Code
207197 , p_source_88 IN VARCHAR2
207198 --Entered Amount
207199 , p_source_91 IN NUMBER
207200 --Currency Conversion Date
207201 , p_source_92 IN DATE
207202 --Currency Conversion Rate
207203 , p_source_93 IN NUMBER
207204 --Currency Conversion Type
207205 , p_source_94 IN VARCHAR2
207206 --Accounted Amount
207207 , p_source_95 IN NUMBER
207208 --Accounting Line Type
207209 , p_source_97 IN NUMBER
207210 )
207211 IS
207212
207213 l_component_type VARCHAR2(80);
207214 l_component_code VARCHAR2(30);
207215 l_component_type_code VARCHAR2(1);
207216 l_component_appl_id INTEGER;
207217 l_amb_context_code VARCHAR2(30);
207218 l_entity_code VARCHAR2(30);
207219 l_event_class_code VARCHAR2(30);
207220 l_ae_header_id NUMBER;
207221 l_event_type_code VARCHAR2(30);
207222 l_line_definition_code VARCHAR2(30);
207223 l_line_definition_owner_code VARCHAR2(1);
207224 --
207225 -- adr variables
207226 l_segment VARCHAR2(30);
207227 l_ccid NUMBER;
207228 l_adr_transaction_coa_id NUMBER;
207229 l_adr_accounting_coa_id NUMBER;
207230 l_adr_flexfield_segment_code VARCHAR2(30);
207231 l_adr_flex_value_set_id NUMBER;
207232 l_adr_value_type_code VARCHAR2(30);
207233 l_adr_value_combination_id NUMBER;
207234 l_adr_value_segment_code VARCHAR2(30);
207235
207236 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
207237 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
207238 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
207239 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
207240
207241 -- 4262811 Variables ------------------------------------------------------------------------------------------
207242 l_entered_amt_idx NUMBER;
207243 l_accted_amt_idx NUMBER;
207244 l_acc_rev_flag VARCHAR2(1);
207245 l_accrual_line_num NUMBER;
207246 l_tmp_amt NUMBER;
207247 l_acc_rev_natural_side_code VARCHAR2(1);
207248
207249 l_num_entries NUMBER;
207250 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
207251 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
207252 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
207253 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
207254 l_recog_line_1 NUMBER;
207255 l_recog_line_2 NUMBER;
207256
207257 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
207258 l_bflow_applied_to_amt NUMBER; -- 5132302
207259 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
207260
207261 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
207262
207263 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
207264 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
207265
207266 ---------------------------------------------------------------------------------------------------------------
207267
207268
207269 --
207270 -- bulk performance
207271 --
207272 l_balance_type_code VARCHAR2(1);
207273 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
207274 l_log_module VARCHAR2(240);
207275
207276 --
207277 -- Upgrade strategy
207278 --
207279 l_actual_upg_option VARCHAR2(1);
207280 l_enc_upg_option VARCHAR2(1);
207281
207282 --
207283 BEGIN
207284 --
207285 IF g_log_enabled THEN
207286 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_378';
207287 END IF;
207288 --
207289 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
207290
207291 trace
207292 (p_msg => 'BEGIN of AcctLineType_378'
207293 ,p_level => C_LEVEL_PROCEDURE
207294 ,p_module => l_log_module);
207295
207296 END IF;
207297 --
207298 l_component_type := 'AMB_JLT';
207299 l_component_code := 'PI_BRIDGING';
207300 l_component_type_code := 'S';
207301 l_component_appl_id := 707;
207302 l_amb_context_code := 'DEFAULT';
207303 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
207304 l_event_class_code := 'USER_DEFINE';
207305 l_event_type_code := 'UDIR_INTERORG_SHIP_NO_TP';
207306 l_line_definition_owner_code := 'S';
207307 l_line_definition_code := 'PI_USER_DIR_INTERORG_SHIP_NTP';
207308 --
207309 l_balance_type_code := 'A';
207310 l_segment := NULL;
207311 l_ccid := NULL;
207312 l_adr_transaction_coa_id := NULL;
207313 l_adr_accounting_coa_id := NULL;
207314 l_adr_flexfield_segment_code := NULL;
207315 l_adr_flex_value_set_id := NULL;
207316 l_adr_value_type_code := NULL;
207317 l_adr_value_combination_id := NULL;
207318 l_adr_value_segment_code := NULL;
207319
207320 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
207321 l_bflow_class_code := ''; -- 4219869 Business Flow
207322 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
207323 l_budgetary_control_flag := 'N';
207324
207325 l_bflow_applied_to_amt_idx := NULL; -- 5132302
207326 l_bflow_applied_to_amt := NULL; -- 5132302
207327 l_entered_amt_idx := NULL; -- 4262811
207328 l_accted_amt_idx := NULL; -- 4262811
207329 l_acc_rev_flag := NULL; -- 4262811
207330 l_accrual_line_num := NULL; -- 4262811
207331 l_tmp_amt := NULL; -- 4262811
207332 --
207333
207334 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
207335 l_balance_type_code <> 'B' THEN
207336 IF NVL(p_source_97,9E125) = 1
207337 THEN
207338
207339 --
207340 XLA_AE_LINES_PKG.SetNewLine;
207341
207342 p_balance_type_code := l_balance_type_code;
207343 -- set the flag so later we will know whether the gain loss line needs to be created
207344
207345 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
207346 p_actual_flag :='A';
207347 END IF;
207348
207349 --
207350 -- bulk performance
207351 --
207352 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
207353 p_header_num => 0); -- 4262811
207354 --
207355 -- set accounting line options
207356 --
207357 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
207358 p_natural_side_code => 'C'
207359 , p_gain_or_loss_flag => 'N'
207360 , p_gl_transfer_mode_code => 'S'
207361 , p_acct_entry_type_code => 'A'
207362 , p_switch_side_flag => 'Y'
207363 , p_merge_duplicate_code => 'N'
207364 );
207365 --
207366 l_acc_rev_natural_side_code := 'D'; -- 4262811
207367 --
207368 --
207369 -- set accounting line type info
207370 --
207371 xla_ae_lines_pkg.SetAcctLineType
207372 (p_component_type => l_component_type
207373 ,p_event_type_code => l_event_type_code
207374 ,p_line_definition_owner_code => l_line_definition_owner_code
207375 ,p_line_definition_code => l_line_definition_code
207376 ,p_accounting_line_code => l_component_code
207377 ,p_accounting_line_type_code => l_component_type_code
207378 ,p_accounting_line_appl_id => l_component_appl_id
207379 ,p_amb_context_code => l_amb_context_code
207380 ,p_entity_code => l_entity_code
207381 ,p_event_class_code => l_event_class_code);
207382 --
207383 -- set accounting class
207384 --
207385 xla_ae_lines_pkg.SetAcctClass(
207386 p_accounting_class_code => 'BRIDGING'
207387 , p_ae_header_id => l_ae_header_id
207388 );
207389
207390 --
207391 -- set rounding class
207392 --
207393 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
207394 'BRIDGING';
207395
207396 --
207397 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
207398 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
207399 --
207400 -- bulk performance
207401 --
207402 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
207403
207404 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
207405 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
207406
207407 -- 4955764
207408 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
207409 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
207410
207411 -- 4458381 Public Sector Enh
207412
207413 --
207414 -- set accounting attributes for the line type
207415 --
207416 l_entered_amt_idx := 3;
207417 l_accted_amt_idx := 8;
207418 l_bflow_applied_to_amt_idx := NULL; -- 5132302
207419 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
207420 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
207421 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
207422 l_rec_acct_attrs.array_char_value(2) := p_source_85;
207423 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
207424 l_rec_acct_attrs.array_num_value(3) := p_source_91;
207425 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
207426 l_rec_acct_attrs.array_char_value(4) := p_source_88;
207427 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
207428 l_rec_acct_attrs.array_date_value(5) := p_source_92;
207429 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
207430 l_rec_acct_attrs.array_num_value(6) := p_source_93;
207431 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
207432 l_rec_acct_attrs.array_char_value(7) := p_source_94;
207433 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
207434 l_rec_acct_attrs.array_num_value(8) := p_source_95;
207435
207436 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
207437 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
207438
207439 ---------------------------------------------------------------------------------------------------------------
207440 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
207441 ---------------------------------------------------------------------------------------------------------------
207442 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
207443
207444 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
207445 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
207446
207447 IF xla_accounting_cache_pkg.GetValueChar
207448 (p_source_code => 'LEDGER_CATEGORY_CODE'
207449 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
207450 AND l_bflow_method_code = 'PRIOR_ENTRY'
207451 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
207452 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
207453 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
207454 )
207455 THEN
207456 xla_ae_lines_pkg.BflowUpgEntry
207457 (p_business_method_code => l_bflow_method_code
207458 ,p_business_class_code => l_bflow_class_code
207459 ,p_balance_type => l_balance_type_code);
207460 ELSE
207461 NULL;
207462 -- No business flow processing for business flow method of NONE.
207463 END IF;
207464
207465 --
207466 -- call analytical criteria
207467 --
207468
207469 --
207470 -- call description
207471 --
207472
207473 xla_ae_lines_pkg.SetLineDescription(
207474 p_ae_header_id => l_ae_header_id
207475 ,p_description => Description_1 (
207476 p_application_id => p_application_id
207477 , p_ae_header_id => l_ae_header_id
207478 , p_source_1 => p_source_1
207479 , p_source_2 => p_source_2
207480 , p_source_3 => p_source_3
207481 , p_source_4 => p_source_4
207482 , p_source_5 => p_source_5
207483 )
207484 );
207485
207486
207487 --
207488 -- call ADRs
207489 -- Bug 4922099
207490 --
207491 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
207492 (NVL(l_actual_upg_option, 'N') = 'O') OR
207493 (NVL(l_enc_upg_option, 'N') = 'O')
207494 )
207495 THEN
207496 NULL;
207497 --
207498 --
207499
207500 l_ccid := AcctDerRule_11(
207501 p_application_id => p_application_id
207502 , p_ae_header_id => l_ae_header_id
207503 , p_source_22 => p_source_22
207504 , x_transaction_coa_id => l_adr_transaction_coa_id
207505 , x_accounting_coa_id => l_adr_accounting_coa_id
207506 , x_value_type_code => l_adr_value_type_code
207507 , p_side => 'NA'
207508 );
207509
207510 xla_ae_lines_pkg.set_ccid(
207511 p_code_combination_id => l_ccid
207512 , p_value_type_code => l_adr_value_type_code
207513 , p_transaction_coa_id => l_adr_transaction_coa_id
207514 , p_accounting_coa_id => l_adr_accounting_coa_id
207515 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
207516 , p_adr_type_code => 'S'
207517 , p_component_type => l_component_type
207518 , p_component_code => l_component_code
207519 , p_component_type_code => l_component_type_code
207520 , p_component_appl_id => l_component_appl_id
207521 , p_amb_context_code => l_amb_context_code
207522 , p_side => 'NA'
207523 );
207524
207525
207526 --
207527 --
207528 END IF;
207529 --
207530 -- Bug 4922099
207531 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
207532 (NVL(l_enc_upg_option, 'N') = 'O')
207533 ) AND
207534 (l_bflow_method_code = 'PRIOR_ENTRY')
207535 )
207536 THEN
207537 IF
207538 --
207539 1 = 2
207540 --
207541 THEN
207542 xla_accounting_err_pkg.build_message
207543 (p_appli_s_name => 'XLA'
207544 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
207545 ,p_token_1 => 'LINE_NUMBER'
207546 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
207547 ,p_token_2 => 'LINE_TYPE_NAME'
207548 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
207549 l_component_type
207550 ,l_component_code
207551 ,l_component_type_code
207552 ,l_component_appl_id
207553 ,l_amb_context_code
207554 ,l_entity_code
207555 ,l_event_class_code
207556 )
207557 ,p_token_3 => 'OWNER'
207558 ,p_value_3 => xla_lookups_pkg.get_meaning(
207559 p_lookup_type => 'XLA_OWNER_TYPE'
207560 ,p_lookup_code => l_component_type_code
207561 )
207562 ,p_token_4 => 'PRODUCT_NAME'
207563 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
207564 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
207565 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
207566 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
207567 ,p_ae_header_id => NULL
207568 );
207569
207570 IF (C_LEVEL_ERROR>= g_log_level) THEN
207571 trace
207572 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
207573 ,p_level => C_LEVEL_ERROR
207574 ,p_module => l_log_module);
207575 END IF;
207576 END IF;
207577 END IF;
207578 --
207579 --
207580 ------------------------------------------------------------------------------------------------
207581 -- 4219869 Business Flow
207582 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
207583 -- Prior Entry. Currently, the following code is always generated.
207584 ------------------------------------------------------------------------------------------------
207585 XLA_AE_LINES_PKG.ValidateCurrentLine;
207586
207587 ------------------------------------------------------------------------------------
207588 -- 4219869 Business Flow
207589 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
207590 ------------------------------------------------------------------------------------
207591 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
207592
207593 ----------------------------------------------------------------------------------
207594 -- 4219869 Business Flow
207595 -- Update journal entry status -- Need to generate this within IF <condition>
207596 ----------------------------------------------------------------------------------
207597 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
207598 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
207599 ,p_balance_type_code => l_balance_type_code
207600 );
207601
207602 -------------------------------------------------------------------------------------------
207603 -- 4262811 - Generate the Accrual Reversal lines
207604 -------------------------------------------------------------------------------------------
207605 BEGIN
207606 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
207607 (g_array_event(p_event_id).array_value_num('header_index'));
207608 IF l_acc_rev_flag IS NULL THEN
207609 l_acc_rev_flag := 'N';
207610 END IF;
207611 EXCEPTION
207612 WHEN OTHERS THEN
207613 l_acc_rev_flag := 'N';
207614 END;
207615 --
207616 IF (l_acc_rev_flag = 'Y') THEN
207617
207618 -- 4645092 ------------------------------------------------------------------------------
207619 -- To allow MPA report to determine if it should generate report process
207620 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
207621 ------------------------------------------------------------------------------------------
207622
207623 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
207624 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
207625 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
207626 -- call ADRs
207627 -- Bug 4922099
207628 --
207629 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
207630 (NVL(l_actual_upg_option, 'N') = 'O') OR
207631 (NVL(l_enc_upg_option, 'N') = 'O')
207632 )
207633 THEN
207634 NULL;
207635 --
207636 --
207637
207638 l_ccid := AcctDerRule_11(
207639 p_application_id => p_application_id
207640 , p_ae_header_id => l_ae_header_id
207641 , p_source_22 => p_source_22
207642 , x_transaction_coa_id => l_adr_transaction_coa_id
207643 , x_accounting_coa_id => l_adr_accounting_coa_id
207644 , x_value_type_code => l_adr_value_type_code
207645 , p_side => 'NA'
207646 );
207647
207648 xla_ae_lines_pkg.set_ccid(
207649 p_code_combination_id => l_ccid
207650 , p_value_type_code => l_adr_value_type_code
207651 , p_transaction_coa_id => l_adr_transaction_coa_id
207652 , p_accounting_coa_id => l_adr_accounting_coa_id
207653 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
207654 , p_adr_type_code => 'S'
207655 , p_component_type => l_component_type
207656 , p_component_code => l_component_code
207657 , p_component_type_code => l_component_type_code
207658 , p_component_appl_id => l_component_appl_id
207659 , p_amb_context_code => l_amb_context_code
207660 , p_side => 'NA'
207661 );
207662
207663
207664 --
207665 --
207666 END IF;
207667
207668 --
207669 -- Update the line information that should be overwritten
207670 --
207671 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
207672 p_header_num => 1);
207673 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
207674
207675 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
207676
207677 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
207678 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
207679 END IF;
207680
207681 --
207682 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
207683 --
207684 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
207685 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
207686 ELSE
207687 ---------------------------------------------------------------------------------------------------
207688 -- 4262811a Switch Sign
207689 ---------------------------------------------------------------------------------------------------
207690 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
207691 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
207692 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207693 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
207694 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207695 -- 5132302
207696 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
207697 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
207698
207699 END IF;
207700
207701 -- 4955764
207702 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
207703 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
207704
207705
207706 XLA_AE_LINES_PKG.ValidateCurrentLine;
207707 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
207708
207709 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
207710 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
207711 ,p_balance_type_code => l_balance_type_code);
207712
207713 END IF;
207714
207715 -----------------------------------------------------------------------------------------
207716 -- 4262811 Multiperiod Accounting
207717 -----------------------------------------------------------------------------------------
207718 -- No MPA option is assigned.
207719
207720
207721 END IF;
207722 END IF;
207723 --
207724
207725 --
207726 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
207727 trace
207728 (p_msg => 'END of AcctLineType_378'
207729 ,p_level => C_LEVEL_PROCEDURE
207730 ,p_module => l_log_module);
207731 END IF;
207732 --
207733 EXCEPTION
207734 WHEN xla_exceptions_pkg.application_exception THEN
207735 RAISE;
207736 WHEN OTHERS THEN
207737 xla_exceptions_pkg.raise_message
207738 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_378');
207739 END AcctLineType_378;
207740 --
207741
207742 ---------------------------------------
207743 --
207744 -- PRIVATE FUNCTION
207745 -- AcctLineType_379
207746 --
207747 ---------------------------------------
207748 PROCEDURE AcctLineType_379 (
207749 p_application_id IN NUMBER
207750 ,p_event_id IN NUMBER
207751 ,p_calculate_acctd_flag IN VARCHAR2
207752 ,p_calculate_g_l_flag IN VARCHAR2
207753 ,p_actual_flag IN OUT VARCHAR2
207754 ,p_balance_type_code OUT VARCHAR2
207755 ,p_gain_or_loss_ref OUT VARCHAR2
207756
207757 --TRANSACTION_ID
207758 , p_source_1 IN NUMBER
207759 --Item Concatenated Segments
207760 , p_source_2 IN VARCHAR2
207761 --Transaction Quantity
207762 , p_source_3 IN NUMBER
207763 --Transaction Unit of Measure Code
207764 , p_source_4 IN VARCHAR2
207765 --Inventory Transaction Type Description
207766 , p_source_5 IN VARCHAR2
207767 --Product Line Accounting Category Bridging Account
207768 , p_source_22 IN NUMBER
207769 --DISTRIBUTION_IDENTIFIER
207770 , p_source_84 IN NUMBER
207771 --Distribution Type
207772 , p_source_85 IN VARCHAR2
207773 , p_source_85_meaning IN VARCHAR2
207774 --Entered Currency Code
207775 , p_source_88 IN VARCHAR2
207776 --Entered Amount
207777 , p_source_91 IN NUMBER
207778 --Currency Conversion Date
207779 , p_source_92 IN DATE
207780 --Currency Conversion Rate
207781 , p_source_93 IN NUMBER
207782 --Currency Conversion Type
207783 , p_source_94 IN VARCHAR2
207784 --Accounted Amount
207785 , p_source_95 IN NUMBER
207786 --Accounting Line Type
207787 , p_source_97 IN NUMBER
207788 )
207789 IS
207790
207791 l_component_type VARCHAR2(80);
207792 l_component_code VARCHAR2(30);
207793 l_component_type_code VARCHAR2(1);
207794 l_component_appl_id INTEGER;
207795 l_amb_context_code VARCHAR2(30);
207796 l_entity_code VARCHAR2(30);
207797 l_event_class_code VARCHAR2(30);
207798 l_ae_header_id NUMBER;
207799 l_event_type_code VARCHAR2(30);
207800 l_line_definition_code VARCHAR2(30);
207801 l_line_definition_owner_code VARCHAR2(1);
207802 --
207803 -- adr variables
207804 l_segment VARCHAR2(30);
207805 l_ccid NUMBER;
207806 l_adr_transaction_coa_id NUMBER;
207807 l_adr_accounting_coa_id NUMBER;
207808 l_adr_flexfield_segment_code VARCHAR2(30);
207809 l_adr_flex_value_set_id NUMBER;
207810 l_adr_value_type_code VARCHAR2(30);
207811 l_adr_value_combination_id NUMBER;
207812 l_adr_value_segment_code VARCHAR2(30);
207813
207814 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
207815 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
207816 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
207817 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
207818
207819 -- 4262811 Variables ------------------------------------------------------------------------------------------
207820 l_entered_amt_idx NUMBER;
207821 l_accted_amt_idx NUMBER;
207822 l_acc_rev_flag VARCHAR2(1);
207823 l_accrual_line_num NUMBER;
207824 l_tmp_amt NUMBER;
207825 l_acc_rev_natural_side_code VARCHAR2(1);
207826
207827 l_num_entries NUMBER;
207828 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
207829 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
207830 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
207831 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
207832 l_recog_line_1 NUMBER;
207833 l_recog_line_2 NUMBER;
207834
207835 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
207836 l_bflow_applied_to_amt NUMBER; -- 5132302
207837 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
207838
207839 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
207840
207841 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
207842 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
207843
207844 ---------------------------------------------------------------------------------------------------------------
207845
207846
207847 --
207848 -- bulk performance
207849 --
207850 l_balance_type_code VARCHAR2(1);
207851 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
207852 l_log_module VARCHAR2(240);
207853
207854 --
207855 -- Upgrade strategy
207856 --
207857 l_actual_upg_option VARCHAR2(1);
207858 l_enc_upg_option VARCHAR2(1);
207859
207860 --
207861 BEGIN
207862 --
207863 IF g_log_enabled THEN
207864 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_379';
207865 END IF;
207866 --
207867 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
207868
207869 trace
207870 (p_msg => 'BEGIN of AcctLineType_379'
207871 ,p_level => C_LEVEL_PROCEDURE
207872 ,p_module => l_log_module);
207873
207874 END IF;
207875 --
207876 l_component_type := 'AMB_JLT';
207877 l_component_code := 'PI_BRIDGING';
207878 l_component_type_code := 'S';
207879 l_component_appl_id := 707;
207880 l_amb_context_code := 'DEFAULT';
207881 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
207882 l_event_class_code := 'USER_DEFINE';
207883 l_event_type_code := 'UDIR_INTERORG_SHIP';
207884 l_line_definition_owner_code := 'S';
207885 l_line_definition_code := 'PI_DIR_INTERORG_SHIP';
207886 --
207887 l_balance_type_code := 'A';
207888 l_segment := NULL;
207889 l_ccid := NULL;
207890 l_adr_transaction_coa_id := NULL;
207891 l_adr_accounting_coa_id := NULL;
207892 l_adr_flexfield_segment_code := NULL;
207893 l_adr_flex_value_set_id := NULL;
207894 l_adr_value_type_code := NULL;
207895 l_adr_value_combination_id := NULL;
207896 l_adr_value_segment_code := NULL;
207897
207898 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
207899 l_bflow_class_code := ''; -- 4219869 Business Flow
207900 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
207901 l_budgetary_control_flag := 'N';
207902
207903 l_bflow_applied_to_amt_idx := NULL; -- 5132302
207904 l_bflow_applied_to_amt := NULL; -- 5132302
207905 l_entered_amt_idx := NULL; -- 4262811
207906 l_accted_amt_idx := NULL; -- 4262811
207907 l_acc_rev_flag := NULL; -- 4262811
207908 l_accrual_line_num := NULL; -- 4262811
207909 l_tmp_amt := NULL; -- 4262811
207910 --
207911
207912 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
207913 l_balance_type_code <> 'B' THEN
207914 IF NVL(p_source_97,9E125) = 1
207915 THEN
207916
207917 --
207918 XLA_AE_LINES_PKG.SetNewLine;
207919
207920 p_balance_type_code := l_balance_type_code;
207921 -- set the flag so later we will know whether the gain loss line needs to be created
207922
207923 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
207924 p_actual_flag :='A';
207925 END IF;
207926
207927 --
207928 -- bulk performance
207929 --
207930 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
207931 p_header_num => 0); -- 4262811
207932 --
207933 -- set accounting line options
207934 --
207935 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
207936 p_natural_side_code => 'C'
207937 , p_gain_or_loss_flag => 'N'
207938 , p_gl_transfer_mode_code => 'S'
207939 , p_acct_entry_type_code => 'A'
207940 , p_switch_side_flag => 'Y'
207941 , p_merge_duplicate_code => 'N'
207942 );
207943 --
207944 l_acc_rev_natural_side_code := 'D'; -- 4262811
207945 --
207946 --
207947 -- set accounting line type info
207948 --
207949 xla_ae_lines_pkg.SetAcctLineType
207950 (p_component_type => l_component_type
207951 ,p_event_type_code => l_event_type_code
207952 ,p_line_definition_owner_code => l_line_definition_owner_code
207953 ,p_line_definition_code => l_line_definition_code
207954 ,p_accounting_line_code => l_component_code
207955 ,p_accounting_line_type_code => l_component_type_code
207956 ,p_accounting_line_appl_id => l_component_appl_id
207957 ,p_amb_context_code => l_amb_context_code
207958 ,p_entity_code => l_entity_code
207959 ,p_event_class_code => l_event_class_code);
207960 --
207961 -- set accounting class
207962 --
207963 xla_ae_lines_pkg.SetAcctClass(
207964 p_accounting_class_code => 'BRIDGING'
207965 , p_ae_header_id => l_ae_header_id
207966 );
207967
207968 --
207969 -- set rounding class
207970 --
207971 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
207972 'BRIDGING';
207973
207974 --
207975 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
207976 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
207977 --
207978 -- bulk performance
207979 --
207980 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
207981
207982 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
207983 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
207984
207985 -- 4955764
207986 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
207987 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
207988
207989 -- 4458381 Public Sector Enh
207990
207991 --
207992 -- set accounting attributes for the line type
207993 --
207994 l_entered_amt_idx := 3;
207995 l_accted_amt_idx := 8;
207996 l_bflow_applied_to_amt_idx := NULL; -- 5132302
207997 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
207998 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
207999 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
208000 l_rec_acct_attrs.array_char_value(2) := p_source_85;
208001 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
208002 l_rec_acct_attrs.array_num_value(3) := p_source_91;
208003 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
208004 l_rec_acct_attrs.array_char_value(4) := p_source_88;
208005 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
208006 l_rec_acct_attrs.array_date_value(5) := p_source_92;
208007 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
208008 l_rec_acct_attrs.array_num_value(6) := p_source_93;
208009 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
208010 l_rec_acct_attrs.array_char_value(7) := p_source_94;
208011 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
208012 l_rec_acct_attrs.array_num_value(8) := p_source_95;
208013
208014 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
208015 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
208016
208017 ---------------------------------------------------------------------------------------------------------------
208018 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
208019 ---------------------------------------------------------------------------------------------------------------
208020 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
208021
208022 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
208023 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
208024
208025 IF xla_accounting_cache_pkg.GetValueChar
208026 (p_source_code => 'LEDGER_CATEGORY_CODE'
208027 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
208028 AND l_bflow_method_code = 'PRIOR_ENTRY'
208029 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
208030 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
208031 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
208032 )
208033 THEN
208034 xla_ae_lines_pkg.BflowUpgEntry
208035 (p_business_method_code => l_bflow_method_code
208036 ,p_business_class_code => l_bflow_class_code
208037 ,p_balance_type => l_balance_type_code);
208038 ELSE
208039 NULL;
208040 -- No business flow processing for business flow method of NONE.
208041 END IF;
208042
208043 --
208044 -- call analytical criteria
208045 --
208046
208047 --
208048 -- call description
208049 --
208050
208051 xla_ae_lines_pkg.SetLineDescription(
208052 p_ae_header_id => l_ae_header_id
208053 ,p_description => Description_1 (
208054 p_application_id => p_application_id
208055 , p_ae_header_id => l_ae_header_id
208056 , p_source_1 => p_source_1
208057 , p_source_2 => p_source_2
208058 , p_source_3 => p_source_3
208059 , p_source_4 => p_source_4
208060 , p_source_5 => p_source_5
208061 )
208062 );
208063
208064
208065 --
208066 -- call ADRs
208067 -- Bug 4922099
208068 --
208069 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
208070 (NVL(l_actual_upg_option, 'N') = 'O') OR
208071 (NVL(l_enc_upg_option, 'N') = 'O')
208072 )
208073 THEN
208074 NULL;
208075 --
208076 --
208077
208078 l_ccid := AcctDerRule_11(
208079 p_application_id => p_application_id
208080 , p_ae_header_id => l_ae_header_id
208081 , p_source_22 => p_source_22
208082 , x_transaction_coa_id => l_adr_transaction_coa_id
208083 , x_accounting_coa_id => l_adr_accounting_coa_id
208084 , x_value_type_code => l_adr_value_type_code
208085 , p_side => 'NA'
208086 );
208087
208088 xla_ae_lines_pkg.set_ccid(
208089 p_code_combination_id => l_ccid
208090 , p_value_type_code => l_adr_value_type_code
208091 , p_transaction_coa_id => l_adr_transaction_coa_id
208092 , p_accounting_coa_id => l_adr_accounting_coa_id
208093 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
208094 , p_adr_type_code => 'S'
208095 , p_component_type => l_component_type
208096 , p_component_code => l_component_code
208097 , p_component_type_code => l_component_type_code
208098 , p_component_appl_id => l_component_appl_id
208099 , p_amb_context_code => l_amb_context_code
208100 , p_side => 'NA'
208101 );
208102
208103
208104 --
208105 --
208106 END IF;
208107 --
208108 -- Bug 4922099
208109 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
208110 (NVL(l_enc_upg_option, 'N') = 'O')
208111 ) AND
208112 (l_bflow_method_code = 'PRIOR_ENTRY')
208113 )
208114 THEN
208115 IF
208116 --
208117 1 = 2
208118 --
208119 THEN
208120 xla_accounting_err_pkg.build_message
208121 (p_appli_s_name => 'XLA'
208122 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
208123 ,p_token_1 => 'LINE_NUMBER'
208124 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
208125 ,p_token_2 => 'LINE_TYPE_NAME'
208126 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
208127 l_component_type
208128 ,l_component_code
208129 ,l_component_type_code
208130 ,l_component_appl_id
208131 ,l_amb_context_code
208132 ,l_entity_code
208133 ,l_event_class_code
208134 )
208135 ,p_token_3 => 'OWNER'
208136 ,p_value_3 => xla_lookups_pkg.get_meaning(
208137 p_lookup_type => 'XLA_OWNER_TYPE'
208138 ,p_lookup_code => l_component_type_code
208139 )
208140 ,p_token_4 => 'PRODUCT_NAME'
208141 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
208142 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
208143 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
208144 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
208145 ,p_ae_header_id => NULL
208146 );
208147
208148 IF (C_LEVEL_ERROR>= g_log_level) THEN
208149 trace
208150 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
208151 ,p_level => C_LEVEL_ERROR
208152 ,p_module => l_log_module);
208153 END IF;
208154 END IF;
208155 END IF;
208156 --
208157 --
208158 ------------------------------------------------------------------------------------------------
208159 -- 4219869 Business Flow
208160 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
208161 -- Prior Entry. Currently, the following code is always generated.
208162 ------------------------------------------------------------------------------------------------
208163 XLA_AE_LINES_PKG.ValidateCurrentLine;
208164
208165 ------------------------------------------------------------------------------------
208166 -- 4219869 Business Flow
208167 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
208168 ------------------------------------------------------------------------------------
208169 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
208170
208171 ----------------------------------------------------------------------------------
208172 -- 4219869 Business Flow
208173 -- Update journal entry status -- Need to generate this within IF <condition>
208174 ----------------------------------------------------------------------------------
208175 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
208176 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
208177 ,p_balance_type_code => l_balance_type_code
208178 );
208179
208180 -------------------------------------------------------------------------------------------
208181 -- 4262811 - Generate the Accrual Reversal lines
208182 -------------------------------------------------------------------------------------------
208183 BEGIN
208184 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
208185 (g_array_event(p_event_id).array_value_num('header_index'));
208186 IF l_acc_rev_flag IS NULL THEN
208187 l_acc_rev_flag := 'N';
208188 END IF;
208189 EXCEPTION
208190 WHEN OTHERS THEN
208191 l_acc_rev_flag := 'N';
208192 END;
208193 --
208194 IF (l_acc_rev_flag = 'Y') THEN
208195
208196 -- 4645092 ------------------------------------------------------------------------------
208197 -- To allow MPA report to determine if it should generate report process
208198 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
208199 ------------------------------------------------------------------------------------------
208200
208201 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
208202 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
208203 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
208204 -- call ADRs
208205 -- Bug 4922099
208206 --
208207 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
208208 (NVL(l_actual_upg_option, 'N') = 'O') OR
208209 (NVL(l_enc_upg_option, 'N') = 'O')
208210 )
208211 THEN
208212 NULL;
208213 --
208214 --
208215
208216 l_ccid := AcctDerRule_11(
208217 p_application_id => p_application_id
208218 , p_ae_header_id => l_ae_header_id
208219 , p_source_22 => p_source_22
208220 , x_transaction_coa_id => l_adr_transaction_coa_id
208221 , x_accounting_coa_id => l_adr_accounting_coa_id
208222 , x_value_type_code => l_adr_value_type_code
208223 , p_side => 'NA'
208224 );
208225
208226 xla_ae_lines_pkg.set_ccid(
208227 p_code_combination_id => l_ccid
208228 , p_value_type_code => l_adr_value_type_code
208229 , p_transaction_coa_id => l_adr_transaction_coa_id
208230 , p_accounting_coa_id => l_adr_accounting_coa_id
208231 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
208232 , p_adr_type_code => 'S'
208233 , p_component_type => l_component_type
208234 , p_component_code => l_component_code
208235 , p_component_type_code => l_component_type_code
208236 , p_component_appl_id => l_component_appl_id
208237 , p_amb_context_code => l_amb_context_code
208238 , p_side => 'NA'
208239 );
208240
208241
208242 --
208243 --
208244 END IF;
208245
208246 --
208247 -- Update the line information that should be overwritten
208248 --
208249 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
208250 p_header_num => 1);
208251 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
208252
208253 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
208254
208255 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
208256 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
208257 END IF;
208258
208259 --
208260 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
208261 --
208262 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
208263 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
208264 ELSE
208265 ---------------------------------------------------------------------------------------------------
208266 -- 4262811a Switch Sign
208267 ---------------------------------------------------------------------------------------------------
208268 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
208269 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
208270 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208271 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
208272 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208273 -- 5132302
208274 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
208275 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208276
208277 END IF;
208278
208279 -- 4955764
208280 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
208281 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
208282
208283
208284 XLA_AE_LINES_PKG.ValidateCurrentLine;
208285 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
208286
208287 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
208288 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
208289 ,p_balance_type_code => l_balance_type_code);
208290
208291 END IF;
208292
208293 -----------------------------------------------------------------------------------------
208294 -- 4262811 Multiperiod Accounting
208295 -----------------------------------------------------------------------------------------
208296 -- No MPA option is assigned.
208297
208298
208299 END IF;
208300 END IF;
208301 --
208302
208303 --
208304 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
208305 trace
208306 (p_msg => 'END of AcctLineType_379'
208307 ,p_level => C_LEVEL_PROCEDURE
208308 ,p_module => l_log_module);
208309 END IF;
208310 --
208311 EXCEPTION
208312 WHEN xla_exceptions_pkg.application_exception THEN
208313 RAISE;
208314 WHEN OTHERS THEN
208315 xla_exceptions_pkg.raise_message
208316 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_379');
208317 END AcctLineType_379;
208318 --
208319
208320 ---------------------------------------
208321 --
208322 -- PRIVATE FUNCTION
208323 -- AcctLineType_380
208324 --
208325 ---------------------------------------
208326 PROCEDURE AcctLineType_380 (
208327 p_application_id IN NUMBER
208328 ,p_event_id IN NUMBER
208329 ,p_calculate_acctd_flag IN VARCHAR2
208330 ,p_calculate_g_l_flag IN VARCHAR2
208331 ,p_actual_flag IN OUT VARCHAR2
208332 ,p_balance_type_code OUT VARCHAR2
208333 ,p_gain_or_loss_ref OUT VARCHAR2
208334
208335 --TRANSACTION_ID
208336 , p_source_1 IN NUMBER
208337 --Item Concatenated Segments
208338 , p_source_2 IN VARCHAR2
208339 --Transaction Quantity
208340 , p_source_3 IN NUMBER
208341 --Transaction Unit of Measure Code
208342 , p_source_4 IN VARCHAR2
208343 --Inventory Transaction Type Description
208344 , p_source_5 IN VARCHAR2
208345 --Product Line Accounting Category Bridging Account
208346 , p_source_22 IN NUMBER
208347 --DISTRIBUTION_IDENTIFIER
208348 , p_source_84 IN NUMBER
208349 --Distribution Type
208350 , p_source_85 IN VARCHAR2
208351 , p_source_85_meaning IN VARCHAR2
208352 --Entered Currency Code
208353 , p_source_88 IN VARCHAR2
208354 --Entered Amount
208355 , p_source_91 IN NUMBER
208356 --Currency Conversion Date
208357 , p_source_92 IN DATE
208358 --Currency Conversion Rate
208359 , p_source_93 IN NUMBER
208360 --Currency Conversion Type
208361 , p_source_94 IN VARCHAR2
208362 --Accounted Amount
208363 , p_source_95 IN NUMBER
208364 --Accounting Line Type
208365 , p_source_97 IN NUMBER
208366 )
208367 IS
208368
208369 l_component_type VARCHAR2(80);
208370 l_component_code VARCHAR2(30);
208371 l_component_type_code VARCHAR2(1);
208372 l_component_appl_id INTEGER;
208373 l_amb_context_code VARCHAR2(30);
208374 l_entity_code VARCHAR2(30);
208375 l_event_class_code VARCHAR2(30);
208376 l_ae_header_id NUMBER;
208377 l_event_type_code VARCHAR2(30);
208378 l_line_definition_code VARCHAR2(30);
208379 l_line_definition_owner_code VARCHAR2(1);
208380 --
208381 -- adr variables
208382 l_segment VARCHAR2(30);
208383 l_ccid NUMBER;
208384 l_adr_transaction_coa_id NUMBER;
208385 l_adr_accounting_coa_id NUMBER;
208386 l_adr_flexfield_segment_code VARCHAR2(30);
208387 l_adr_flex_value_set_id NUMBER;
208388 l_adr_value_type_code VARCHAR2(30);
208389 l_adr_value_combination_id NUMBER;
208390 l_adr_value_segment_code VARCHAR2(30);
208391
208392 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
208393 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
208394 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
208395 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
208396
208397 -- 4262811 Variables ------------------------------------------------------------------------------------------
208398 l_entered_amt_idx NUMBER;
208399 l_accted_amt_idx NUMBER;
208400 l_acc_rev_flag VARCHAR2(1);
208401 l_accrual_line_num NUMBER;
208402 l_tmp_amt NUMBER;
208403 l_acc_rev_natural_side_code VARCHAR2(1);
208404
208405 l_num_entries NUMBER;
208406 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
208407 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
208408 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
208409 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
208410 l_recog_line_1 NUMBER;
208411 l_recog_line_2 NUMBER;
208412
208413 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
208414 l_bflow_applied_to_amt NUMBER; -- 5132302
208415 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
208416
208417 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
208418
208419 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
208420 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
208421
208422 ---------------------------------------------------------------------------------------------------------------
208423
208424
208425 --
208426 -- bulk performance
208427 --
208428 l_balance_type_code VARCHAR2(1);
208429 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
208430 l_log_module VARCHAR2(240);
208431
208432 --
208433 -- Upgrade strategy
208434 --
208435 l_actual_upg_option VARCHAR2(1);
208436 l_enc_upg_option VARCHAR2(1);
208437
208438 --
208439 BEGIN
208440 --
208441 IF g_log_enabled THEN
208442 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_380';
208443 END IF;
208444 --
208445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
208446
208447 trace
208448 (p_msg => 'BEGIN of AcctLineType_380'
208449 ,p_level => C_LEVEL_PROCEDURE
208450 ,p_module => l_log_module);
208451
208452 END IF;
208453 --
208454 l_component_type := 'AMB_JLT';
208455 l_component_code := 'PI_BRIDGING';
208456 l_component_type_code := 'S';
208457 l_component_appl_id := 707;
208458 l_amb_context_code := 'DEFAULT';
208459 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
208460 l_event_class_code := 'USER_DEFINE';
208461 l_event_type_code := 'UDIR_INTERORG_RCPT_TP';
208462 l_line_definition_owner_code := 'S';
208463 l_line_definition_code := 'PI_DIR_INTERORG_RCPT_TP';
208464 --
208465 l_balance_type_code := 'A';
208466 l_segment := NULL;
208467 l_ccid := NULL;
208468 l_adr_transaction_coa_id := NULL;
208469 l_adr_accounting_coa_id := NULL;
208470 l_adr_flexfield_segment_code := NULL;
208471 l_adr_flex_value_set_id := NULL;
208472 l_adr_value_type_code := NULL;
208473 l_adr_value_combination_id := NULL;
208474 l_adr_value_segment_code := NULL;
208475
208476 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
208477 l_bflow_class_code := ''; -- 4219869 Business Flow
208478 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
208479 l_budgetary_control_flag := 'N';
208480
208481 l_bflow_applied_to_amt_idx := NULL; -- 5132302
208482 l_bflow_applied_to_amt := NULL; -- 5132302
208483 l_entered_amt_idx := NULL; -- 4262811
208484 l_accted_amt_idx := NULL; -- 4262811
208485 l_acc_rev_flag := NULL; -- 4262811
208486 l_accrual_line_num := NULL; -- 4262811
208487 l_tmp_amt := NULL; -- 4262811
208488 --
208489
208490 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
208491 l_balance_type_code <> 'B' THEN
208492 IF NVL(p_source_97,9E125) = 1
208493 THEN
208494
208495 --
208496 XLA_AE_LINES_PKG.SetNewLine;
208497
208498 p_balance_type_code := l_balance_type_code;
208499 -- set the flag so later we will know whether the gain loss line needs to be created
208500
208501 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
208502 p_actual_flag :='A';
208503 END IF;
208504
208505 --
208506 -- bulk performance
208507 --
208508 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
208509 p_header_num => 0); -- 4262811
208510 --
208511 -- set accounting line options
208512 --
208513 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
208514 p_natural_side_code => 'C'
208515 , p_gain_or_loss_flag => 'N'
208516 , p_gl_transfer_mode_code => 'S'
208517 , p_acct_entry_type_code => 'A'
208518 , p_switch_side_flag => 'Y'
208519 , p_merge_duplicate_code => 'N'
208520 );
208521 --
208522 l_acc_rev_natural_side_code := 'D'; -- 4262811
208523 --
208524 --
208525 -- set accounting line type info
208526 --
208527 xla_ae_lines_pkg.SetAcctLineType
208528 (p_component_type => l_component_type
208529 ,p_event_type_code => l_event_type_code
208530 ,p_line_definition_owner_code => l_line_definition_owner_code
208531 ,p_line_definition_code => l_line_definition_code
208532 ,p_accounting_line_code => l_component_code
208533 ,p_accounting_line_type_code => l_component_type_code
208534 ,p_accounting_line_appl_id => l_component_appl_id
208535 ,p_amb_context_code => l_amb_context_code
208536 ,p_entity_code => l_entity_code
208537 ,p_event_class_code => l_event_class_code);
208538 --
208539 -- set accounting class
208540 --
208541 xla_ae_lines_pkg.SetAcctClass(
208542 p_accounting_class_code => 'BRIDGING'
208543 , p_ae_header_id => l_ae_header_id
208544 );
208545
208546 --
208547 -- set rounding class
208548 --
208549 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
208550 'BRIDGING';
208551
208552 --
208553 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
208554 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
208555 --
208556 -- bulk performance
208557 --
208558 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
208559
208560 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
208561 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
208562
208563 -- 4955764
208564 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
208565 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
208566
208567 -- 4458381 Public Sector Enh
208568
208569 --
208570 -- set accounting attributes for the line type
208571 --
208572 l_entered_amt_idx := 3;
208573 l_accted_amt_idx := 8;
208574 l_bflow_applied_to_amt_idx := NULL; -- 5132302
208575 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
208576 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_84);
208577 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
208578 l_rec_acct_attrs.array_char_value(2) := p_source_85;
208579 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
208580 l_rec_acct_attrs.array_num_value(3) := p_source_91;
208581 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
208582 l_rec_acct_attrs.array_char_value(4) := p_source_88;
208583 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
208584 l_rec_acct_attrs.array_date_value(5) := p_source_92;
208585 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
208586 l_rec_acct_attrs.array_num_value(6) := p_source_93;
208587 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
208588 l_rec_acct_attrs.array_char_value(7) := p_source_94;
208589 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
208590 l_rec_acct_attrs.array_num_value(8) := p_source_95;
208591
208592 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
208593 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
208594
208595 ---------------------------------------------------------------------------------------------------------------
208596 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
208597 ---------------------------------------------------------------------------------------------------------------
208598 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
208599
208600 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
208601 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
208602
208603 IF xla_accounting_cache_pkg.GetValueChar
208604 (p_source_code => 'LEDGER_CATEGORY_CODE'
208605 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
208606 AND l_bflow_method_code = 'PRIOR_ENTRY'
208607 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
208608 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
208609 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
208610 )
208611 THEN
208612 xla_ae_lines_pkg.BflowUpgEntry
208613 (p_business_method_code => l_bflow_method_code
208614 ,p_business_class_code => l_bflow_class_code
208615 ,p_balance_type => l_balance_type_code);
208616 ELSE
208617 NULL;
208618 -- No business flow processing for business flow method of NONE.
208619 END IF;
208620
208621 --
208622 -- call analytical criteria
208623 --
208624
208625 --
208626 -- call description
208627 --
208628
208629 xla_ae_lines_pkg.SetLineDescription(
208630 p_ae_header_id => l_ae_header_id
208631 ,p_description => Description_1 (
208632 p_application_id => p_application_id
208633 , p_ae_header_id => l_ae_header_id
208634 , p_source_1 => p_source_1
208635 , p_source_2 => p_source_2
208636 , p_source_3 => p_source_3
208637 , p_source_4 => p_source_4
208638 , p_source_5 => p_source_5
208639 )
208640 );
208641
208642
208643 --
208644 -- call ADRs
208645 -- Bug 4922099
208646 --
208647 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
208648 (NVL(l_actual_upg_option, 'N') = 'O') OR
208649 (NVL(l_enc_upg_option, 'N') = 'O')
208650 )
208651 THEN
208652 NULL;
208653 --
208654 --
208655
208656 l_ccid := AcctDerRule_11(
208657 p_application_id => p_application_id
208658 , p_ae_header_id => l_ae_header_id
208659 , p_source_22 => p_source_22
208660 , x_transaction_coa_id => l_adr_transaction_coa_id
208661 , x_accounting_coa_id => l_adr_accounting_coa_id
208662 , x_value_type_code => l_adr_value_type_code
208663 , p_side => 'NA'
208664 );
208665
208666 xla_ae_lines_pkg.set_ccid(
208667 p_code_combination_id => l_ccid
208668 , p_value_type_code => l_adr_value_type_code
208669 , p_transaction_coa_id => l_adr_transaction_coa_id
208670 , p_accounting_coa_id => l_adr_accounting_coa_id
208671 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
208672 , p_adr_type_code => 'S'
208673 , p_component_type => l_component_type
208674 , p_component_code => l_component_code
208675 , p_component_type_code => l_component_type_code
208676 , p_component_appl_id => l_component_appl_id
208677 , p_amb_context_code => l_amb_context_code
208678 , p_side => 'NA'
208679 );
208680
208681
208682 --
208683 --
208684 END IF;
208685 --
208686 -- Bug 4922099
208687 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
208688 (NVL(l_enc_upg_option, 'N') = 'O')
208689 ) AND
208690 (l_bflow_method_code = 'PRIOR_ENTRY')
208691 )
208692 THEN
208693 IF
208694 --
208695 1 = 2
208696 --
208697 THEN
208698 xla_accounting_err_pkg.build_message
208699 (p_appli_s_name => 'XLA'
208700 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
208701 ,p_token_1 => 'LINE_NUMBER'
208702 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
208703 ,p_token_2 => 'LINE_TYPE_NAME'
208704 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
208705 l_component_type
208706 ,l_component_code
208707 ,l_component_type_code
208708 ,l_component_appl_id
208709 ,l_amb_context_code
208710 ,l_entity_code
208711 ,l_event_class_code
208712 )
208713 ,p_token_3 => 'OWNER'
208714 ,p_value_3 => xla_lookups_pkg.get_meaning(
208715 p_lookup_type => 'XLA_OWNER_TYPE'
208716 ,p_lookup_code => l_component_type_code
208717 )
208718 ,p_token_4 => 'PRODUCT_NAME'
208719 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
208720 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
208721 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
208722 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
208723 ,p_ae_header_id => NULL
208724 );
208725
208726 IF (C_LEVEL_ERROR>= g_log_level) THEN
208727 trace
208728 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
208729 ,p_level => C_LEVEL_ERROR
208730 ,p_module => l_log_module);
208731 END IF;
208732 END IF;
208733 END IF;
208734 --
208735 --
208736 ------------------------------------------------------------------------------------------------
208737 -- 4219869 Business Flow
208738 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
208739 -- Prior Entry. Currently, the following code is always generated.
208740 ------------------------------------------------------------------------------------------------
208741 XLA_AE_LINES_PKG.ValidateCurrentLine;
208742
208743 ------------------------------------------------------------------------------------
208744 -- 4219869 Business Flow
208745 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
208746 ------------------------------------------------------------------------------------
208747 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
208748
208749 ----------------------------------------------------------------------------------
208750 -- 4219869 Business Flow
208751 -- Update journal entry status -- Need to generate this within IF <condition>
208752 ----------------------------------------------------------------------------------
208753 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
208754 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
208755 ,p_balance_type_code => l_balance_type_code
208756 );
208757
208758 -------------------------------------------------------------------------------------------
208759 -- 4262811 - Generate the Accrual Reversal lines
208760 -------------------------------------------------------------------------------------------
208761 BEGIN
208762 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
208763 (g_array_event(p_event_id).array_value_num('header_index'));
208764 IF l_acc_rev_flag IS NULL THEN
208765 l_acc_rev_flag := 'N';
208766 END IF;
208767 EXCEPTION
208768 WHEN OTHERS THEN
208769 l_acc_rev_flag := 'N';
208770 END;
208771 --
208772 IF (l_acc_rev_flag = 'Y') THEN
208773
208774 -- 4645092 ------------------------------------------------------------------------------
208775 -- To allow MPA report to determine if it should generate report process
208776 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
208777 ------------------------------------------------------------------------------------------
208778
208779 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
208780 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
208781 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
208782 -- call ADRs
208783 -- Bug 4922099
208784 --
208785 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
208786 (NVL(l_actual_upg_option, 'N') = 'O') OR
208787 (NVL(l_enc_upg_option, 'N') = 'O')
208788 )
208789 THEN
208790 NULL;
208791 --
208792 --
208793
208794 l_ccid := AcctDerRule_11(
208795 p_application_id => p_application_id
208796 , p_ae_header_id => l_ae_header_id
208797 , p_source_22 => p_source_22
208798 , x_transaction_coa_id => l_adr_transaction_coa_id
208799 , x_accounting_coa_id => l_adr_accounting_coa_id
208800 , x_value_type_code => l_adr_value_type_code
208801 , p_side => 'NA'
208802 );
208803
208804 xla_ae_lines_pkg.set_ccid(
208805 p_code_combination_id => l_ccid
208806 , p_value_type_code => l_adr_value_type_code
208807 , p_transaction_coa_id => l_adr_transaction_coa_id
208808 , p_accounting_coa_id => l_adr_accounting_coa_id
208809 , p_adr_code => 'PI_BRIDGING_ACCOUNT'
208810 , p_adr_type_code => 'S'
208811 , p_component_type => l_component_type
208812 , p_component_code => l_component_code
208813 , p_component_type_code => l_component_type_code
208814 , p_component_appl_id => l_component_appl_id
208815 , p_amb_context_code => l_amb_context_code
208816 , p_side => 'NA'
208817 );
208818
208819
208820 --
208821 --
208822 END IF;
208823
208824 --
208825 -- Update the line information that should be overwritten
208826 --
208827 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
208828 p_header_num => 1);
208829 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
208830
208831 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
208832
208833 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
208834 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
208835 END IF;
208836
208837 --
208838 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
208839 --
208840 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
208841 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
208842 ELSE
208843 ---------------------------------------------------------------------------------------------------
208844 -- 4262811a Switch Sign
208845 ---------------------------------------------------------------------------------------------------
208846 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
208847 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
208848 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208849 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
208850 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208851 -- 5132302
208852 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
208853 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
208854
208855 END IF;
208856
208857 -- 4955764
208858 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
208859 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
208860
208861
208862 XLA_AE_LINES_PKG.ValidateCurrentLine;
208863 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
208864
208865 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
208866 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
208867 ,p_balance_type_code => l_balance_type_code);
208868
208869 END IF;
208870
208871 -----------------------------------------------------------------------------------------
208872 -- 4262811 Multiperiod Accounting
208873 -----------------------------------------------------------------------------------------
208874 -- No MPA option is assigned.
208875
208876
208877 END IF;
208878 END IF;
208879 --
208880
208881 --
208882 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
208883 trace
208884 (p_msg => 'END of AcctLineType_380'
208885 ,p_level => C_LEVEL_PROCEDURE
208886 ,p_module => l_log_module);
208887 END IF;
208888 --
208889 EXCEPTION
208890 WHEN xla_exceptions_pkg.application_exception THEN
208891 RAISE;
208892 WHEN OTHERS THEN
208893 xla_exceptions_pkg.raise_message
208894 (p_location => 'XLA_00707_AAD_S_000020_PKG.AcctLineType_380');
208895 END AcctLineType_380;
208896 --
208897
208898 ---------------------------------------
208899 --
208900 -- PRIVATE FUNCTION
208901 -- AcctLineType_381
208902 --
208903 ---------------------------------------
208904 PROCEDURE AcctLineType_381 (
208905 p_application_id IN NUMBER
208906 ,p_event_id IN NUMBER
208907 ,p_calculate_acctd_flag IN VARCHAR2
208908 ,p_calculate_g_l_flag IN VARCHAR2
208909 ,p_actual_flag IN OUT VARCHAR2
208910 ,p_balance_type_code OUT VARCHAR2
208911 ,p_gain_or_loss_ref OUT VARCHAR2
208912
208913 --TRANSACTION_ID
208914 , p_source_1 IN NUMBER
208915 --Item Concatenated Segments
208916 , p_source_2 IN VARCHAR2
208917 --Transaction Quantity
208918 , p_source_3 IN NUMBER
208919 --Transaction Unit of Measure Code
208920 , p_source_4 IN VARCHAR2
208921 --Inventory Transaction Type Description
208922 , p_source_5 IN VARCHAR2
208923 --Product Line Accounting Category Bridging Account
208924 , p_source_22 IN NUMBER
208925 --DISTRIBUTION_IDENTIFIER
208926 , p_source_84 IN NUMBER
208927 --Distribution Type
208928 , p_source_85 IN VARCHAR2
208929 , p_source_85_meaning IN VARCHAR2
208930 --Entered Currency Code
208931 , p_source_88 IN VARCHAR2
208932 --Entered Amount
208933 , p_source_91 IN NUMBER
208934 --Currency Conversion Date
208935 , p_source_92 IN DATE
208936 --Currency Conversion Rate
208937 , p_source_93 IN NUMBER
208938 --Currency Conversion Type
208939 , p_source_94 IN VARCHAR2
208940 --Accounted Amount
208941 , p_source_95 IN NUMBER
208942 --Accounting Line Type
208943 , p_source_97 IN NUMBER
208944 --Subinventory Type Indicator
208945 , p_source_110 IN VARCHAR2
208946 , p_source_110_meaning IN VARCHAR2
208947 )
208948 IS
208949
208950 l_component_type VARCHAR2(80);
208951 l_component_code VARCHAR2(30);
208952 l_component_type_code VARCHAR2(1);
208953 l_component_appl_id INTEGER;
208954 l_amb_context_code VARCHAR2(30);
208955 l_entity_code VARCHAR2(30);
208956 l_event_class_code VARCHAR2(30);
208957 l_ae_header_id NUMBER;
208958 l_event_type_code VARCHAR2(30);
208959 l_line_definition_code VARCHAR2(30);
208960 l_line_definition_owner_code VARCHAR2(1);
208961 --
208962 -- adr variables
208963 l_segment VARCHAR2(30);
208964 l_ccid NUMBER;
208965 l_adr_transaction_coa_id NUMBER;
208966 l_adr_accounting_coa_id NUMBER;
208967 l_adr_flexfield_segment_code VARCHAR2(30);
208968 l_adr_flex_value_set_id NUMBER;
208969 l_adr_value_type_code VARCHAR2(30);
208970 l_adr_value_combination_id NUMBER;
208971 l_adr_value_segment_code VARCHAR2(30);
208972
208973 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
208974 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
208975 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
208976 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
208977
208978 -- 4262811 Variables ------------------------------------------------------------------------------------------
208979 l_entered_amt_idx NUMBER;
208980 l_accted_amt_idx NUMBER;
208981 l_acc_rev_flag VARCHAR2(1);
208982 l_accrual_line_num NUMBER;
208983 l_tmp_amt NUMBER;
208984 l_acc_rev_natural_side_code VARCHAR2(1);
208985
208986 l_num_entries NUMBER;
208987 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
208988 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
208989 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
208990 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
208991 l_recog_line_1 NUMBER;
208992 l_recog_line_2 NUMBER;
208993
208994 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
208995 l_bflow_applied_to_amt NUMBER; -- 5132302
208996 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
208997
208998 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
208999
209000 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
209001 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
209002
209003 ---------------------------------------------------------------------------------------------------------------
209004
209005
209006 --
209007 -- bulk performance
209008 --
209009 l_balance_type_code VARCHAR2(1);
209010 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
209011 l_log_module VARCHAR2(240);
209012
209013 --
209014 -- Upgrade strategy
209015 --
209016 l_actual_upg_option VARCHAR2(1);
209017 l_enc_upg_option VARCHAR2(1);
209018
209019 --
209020 BEGIN
209021 --
209022 IF g_log_enabled THEN
209023 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_381';
209024 END IF;
209025 --
209026 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
209027
209028 trace
209029 (p_msg => 'BEGIN of AcctLineType_381'
209030 ,p_level => C_LEVEL_PROCEDURE
209031 ,p_module => l_log_module);
209032
209033 END IF;
209034 --
209035 l_component_type := 'AMB_JLT';
209036 l_component_code := 'PI_BRIDGING';
209037 l_component_type_code := 'S';
209038 l_component_appl_id := 707;
209039 l_amb_context_code := 'DEFAULT';
209040 l_entity_code := 'MTL_ACCOUNTING_EVENTS';
209041 l_event_class_code := 'WIP_MTL';
209042 l_event_type_code := 'WIP_NEG_COMP_RETURN';
209043 l_line_definition_owner_code := 'S';
209044 l_line_definition_code := 'PI_WIP_NEG_COMP_RETURN';
209045 --
209046 l_balance_type_code := 'A';
209047 l_segment := NULL;
209048 l_ccid := NULL;
209049 l_adr_transaction_coa_id := NULL;
209050 l_adr_accounting_coa_id := NULL;
209051 l_adr_flexfield_segment_code := NULL;
209052 l_adr_flex_value_set_id := NULL;
209053 l_adr_value_type_code := NULL;
209054 l_adr_value_combination_id := NULL;
209055 l_adr_value_segment_code := NULL;
209056
209057 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
209058 l_bflow_class_code := ''; -- 4219869 Business Flow
209059 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
209060 l_budgetary_control_flag := 'N';
209061
209062 l_bflow_applied_to_amt_idx := NULL; -- 5132302
209063 l_bflow_applied_to_amt := NULL; -- 5132302
209064 l_entered_amt_idx := NULL; -- 4262811
209065 l_accted_amt_idx := NULL; -- 4262811
209066 l_acc_rev_flag := NULL; -- 4262811
209067 l_accrual_line_num := NULL; -- 4262811
209068 l_tmp_amt := NULL; -- 4262811
209069 --
209070
209071 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
209072 l_balance_type_code <> 'B' THEN
209073 IF (NVL(p_source_97,9E125) = 1 OR
209074 NVL(p_source_97,9E125) = 2 OR
209075 NVL(p_source_97,9E125) = 3) AND
209076 NVL(p_source_110,'
209077 ') = 'Y'
209078 THEN
209079
209080 --
209081 XLA_AE_LINES_PKG.SetNewLine;
209082
209083 p_balance_type_code := l_balance_type_code;
209084 -- set the flag so later we will know whether the gain loss line needs to be created
209085
209086 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
209087 p_actual_flag :='A';
209088 END IF;
209089
209090 --
209091 -- bulk performance
209092 --
209093 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
209094 p_header_num =>